diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index bae76f0ce3d..974273dc685 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -0cf9fc10ba9d47099f3507080dd736054d877a20 \ No newline at end of file +c3e20f18fe37993ddcbf11dccb55663b4c0d02fd \ 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 5d488ee7b2f..4d07117f346 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -1237,10 +1237,10 @@ var LazyComponent = 16; var IncompleteClassComponent = 17; var DehydratedFragment = 18; var SuspenseListComponent = 19; +var FundamentalComponent = 20; var ScopeComponent = 21; var OffscreenComponent = 22; var LegacyHiddenComponent = 23; -var CacheComponent = 24; /** * Instance of element that should respond to touch/move types of interactions, @@ -2493,27 +2493,14 @@ function getFiberCurrentPropsFromNode$1(inst) { // Module provided by RN: var ReactFabricGlobalResponderHandler = { onChange: function(from, to, blockNativeResponder) { - var fromOrTo = from || to; - var isFabric = !!fromOrTo.stateNode.canonical._internalInstanceHandle; - - if (isFabric) { - if (from) { - nativeFabricUIManager.setIsJSResponder(from.stateNode.node, false); - } - - if (to) { - nativeFabricUIManager.setIsJSResponder(to.stateNode.node, true); - } + if (to !== null) { + var tag = to.stateNode.canonical._nativeTag; + ReactNativePrivateInterface.UIManager.setJSResponder( + tag, + blockNativeResponder + ); } else { - if (to !== null) { - var tag = to.stateNode.canonical._nativeTag; - ReactNativePrivateInterface.UIManager.setJSResponder( - tag, - blockNativeResponder - ); - } else { - ReactNativePrivateInterface.UIManager.clearJSResponder(); - } + ReactNativePrivateInterface.UIManager.clearJSResponder(); } } }; @@ -2560,12 +2547,12 @@ var REACT_SUSPENSE_TYPE = 0xead1; var REACT_SUSPENSE_LIST_TYPE = 0xead8; var REACT_MEMO_TYPE = 0xead3; var REACT_LAZY_TYPE = 0xead4; +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; -var REACT_CACHE_TYPE = 0xeae4; if (typeof Symbol === "function" && Symbol.for) { var symbolFor = Symbol.for; @@ -2581,12 +2568,12 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); + 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"); - REACT_CACHE_TYPE = symbolFor("react.cache"); } var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; @@ -2660,9 +2647,6 @@ function getComponentName(type) { case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList"; - - case REACT_CACHE_TYPE: - return "Cache"; } if (typeof type === "object") { @@ -2700,10 +2684,8 @@ function getComponentName(type) { // The rest of the flags are static for better dead code elimination. var enableProfilerTimer = true; -var enableLazyElements = false; var warnAboutStringRefs = false; var enableNewReconciler = false; -var deferRenderPhaseUpdateToNextBatch = true; // Don't change these two values. They're used by React Dev Tools. var NoFlags = @@ -2721,84 +2703,53 @@ var Update = 4; var PlacementAndUpdate = /* */ - Placement | Update; -var ChildDeletion = - /* */ - 16; + 6; +var Deletion = + /* */ + 8; var ContentReset = /* */ - 32; + 16; var Callback = /* */ - 64; + 32; var DidCapture = /* */ - 128; + 64; var Ref = /* */ - 256; + 128; var Snapshot = /* */ - 512; + 256; var Passive = /* */ - 1024; + 512; var Hydrating = /* */ - 2048; + 1024; var HydratingAndUpdate = /* */ - Hydrating | Update; -var Visibility = - /* */ - 4096; + 1028; var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot; // Union of all commit flags (flags with the lifetime of a particular commit) var HostEffectMask = /* */ - 8191; // 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 = /* */ - 8192; + 4096; var ShouldCapture = /* */ - 16384; // TODO (effects) Remove this bit once the new reconciler is synced to the old. + 8192; // TODO (effects) Remove this bit once the new reconciler is synced to the old. var PassiveUnmountPendingDev = /* */ - 32768; + 16384; var ForceUpdateForLegacySuspense = /* */ - 65536; // Static tags describe aspects of a fiber that are not specific to a render, -// e.g. a fiber uses a passive effect (even if there are no updates on this particular render). -// This enables us to defer more work in the unmount case, -// since we can defer traversing the tree during layout to look for Passive effects, -// and instead rely on the static flag as a signal that there may be cleanup work. - -var PassiveStatic = - /* */ - 131072; // These flags allow us to traverse to fibers that have effects on mount -// don't contain effects, by checking subtreeFlags. - -var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visiblity - // flag logic (see #20043) - Update | Snapshot | 0; -var MutationMask = - Placement | - Update | - ChildDeletion | - ContentReset | - Ref | - Hydrating | - Visibility; -var LayoutMask = Update | Callback | Ref; // TODO: Split into PassiveMountMask and PassiveUnmountMask - -var PassiveMask = Passive | ChildDeletion; // Union of tags that don't get reset on clones. -// This allows certain concepts to persist without recalculting them, -// e.g. whether a subtree contains passive effects or portals. - -var StaticMask = PassiveStatic; + 32768; // Static tags describe aspects of a fiber that are not specific to a render, var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -3038,28 +2989,38 @@ function findCurrentFiberUsingSlowPath(fiber) { } function findCurrentHostFiber(parent) { var currentParent = findCurrentFiberUsingSlowPath(parent); - return currentParent !== null - ? findCurrentHostFiberImpl(currentParent) - : null; -} -function findCurrentHostFiberImpl(node) { - // Next we'll drill down this component to find the first HostComponent/Text. - if (node.tag === HostComponent || node.tag === HostText) { - return node; - } + if (!currentParent) { + return null; + } // Next we'll drill down this component to find the first HostComponent/Text. - var child = node.child; + var node = currentParent; - while (child !== null) { - var match = findCurrentHostFiberImpl(child); - - if (match !== null) { - return match; + while (true) { + if (node.tag === HostComponent || node.tag === HostText) { + return node; + } else if (node.child) { + node.child.return = node; + node = node.child; + continue; } - child = child.sibling; - } + if (node === currentParent) { + return null; + } + + while (!node.sibling) { + if (!node.return || node.return === currentParent) { + return null; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } // Flow needs the return null here, but ESLint complains about it. + // eslint-disable-next-line no-unreachable return null; } @@ -3728,961 +3689,6 @@ function dispatchEvent(target, topLevelType, nativeEvent) { // where it would do it. } -// 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; - -{ - // 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" - ); - } -} - -// 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. -var ImmediatePriority = 99; -var UserBlockingPriority = 98; -var NormalPriority = 97; -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; - - case NormalPriority: - return Scheduler_NormalPriority; - - case LowPriority: - return Scheduler_LowPriority; - - case IdlePriority: - return Scheduler_IdlePriority; - - default: { - throw Error("Unknown priority level."); - } - } -} - -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]; // TODO: Figure out how to remove this It's only here as a last resort if we - // forget to explicitly flush. - - { - // Flush the queue in the next tick. - 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); - } -} -function cancelCallback(callbackNode) { - Scheduler_cancelCallback(callbackNode); -} -function flushSyncCallbackQueue() { - if (immediateQueueCallbackNode !== null) { - var node = immediateQueueCallbackNode; - immediateQueueCallbackNode = null; - Scheduler_cancelCallback(node); - } - - flushSyncCallbackQueueImpl(); -} - -function flushSyncCallbackQueueImpl() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrancy. - isFlushingSyncQueue = true; - var i = 0; - - { - try { - var _isSync2 = true; - var _queue = syncQueue; - runWithPriority(ImmediatePriority, 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 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; // Lane values below should be kept in sync with getLabelsForLanes(), used by react-devtools-scheduling-profiler. -// If those values are changed that package should be rebuilt and redeployed. - -var TotalLanes = 31; -var NoLanes = - /* */ - 0; -var NoLane = - /* */ - 0; -var SyncLane = - /* */ - 1; -var SyncBatchedLane = - /* */ - 2; -var InputDiscreteHydrationLane = - /* */ - 4; -var InputDiscreteLane = - /* */ - 8; -var InputContinuousHydrationLane = - /* */ - 16; -var InputContinuousLane = - /* */ - 32; -var DefaultHydrationLane = - /* */ - 64; -var DefaultLane = - /* */ - 128; -var TransitionHydrationLane = - /* */ - 256; -var TransitionLanes = - /* */ - 8388096; -var TransitionLane1 = - /* */ - 512; -var TransitionLane2 = - /* */ - 1024; -var TransitionLane3 = - /* */ - 2048; -var TransitionLane4 = - /* */ - 4096; -var TransitionLane5 = - /* */ - 8192; -var TransitionLane6 = - /* */ - 16384; -var TransitionLane7 = - /* */ - 32768; -var TransitionLane8 = - /* */ - 65536; -var TransitionLane9 = - /* */ - 131072; -var TransitionLane10 = - /* */ - 262144; -var TransitionLane11 = - /* */ - 524288; -var TransitionLane12 = - /* */ - 1048576; -var TransitionLane13 = - /* */ - 2097152; -var TransitionLane14 = - /* */ - 4194304; -var RetryLanes = - /* */ - 125829120; -var RetryLane1 = - /* */ - 8388608; -var RetryLane2 = - /* */ - 16777216; -var RetryLane3 = - /* */ - 33554432; -var RetryLane4 = - /* */ - 67108864; -var SomeRetryLane = RetryLane1; -var SelectiveHydrationLane = - /* */ - 134217728; -var NonIdleLanes = - /* */ - 268435455; -var IdleHydrationLane = - /* */ - 268435456; -var IdleLane = - /* */ - 536870912; -var OffscreenLane = - /* */ - 1073741824; // This function is used for the experimental scheduling profiler (react-devtools-scheduling-profiler) -var NoTimestamp = -1; -var nextTransitionLane = TransitionLane1; -var nextRetryLane = RetryLane1; -// Used by getHighestPriorityLanes and getNextLanes: - -var return_highestLanePriority = DefaultLanePriority; - -function getHighestPriorityLanes(lanes) { - switch (getHighestPriorityLane(lanes)) { - case SyncLane: - return_highestLanePriority = SyncLanePriority; - return SyncLane; - - case SyncBatchedLane: - return_highestLanePriority = SyncBatchedLanePriority; - return SyncBatchedLane; - - case InputDiscreteHydrationLane: - return_highestLanePriority = InputDiscreteHydrationLanePriority; - return InputDiscreteHydrationLane; - - case InputDiscreteLane: - return_highestLanePriority = InputDiscreteLanePriority; - return InputDiscreteLane; - - case InputContinuousHydrationLane: - return_highestLanePriority = InputContinuousHydrationLanePriority; - return InputContinuousHydrationLane; - - case InputContinuousLane: - return_highestLanePriority = InputContinuousLanePriority; - return InputContinuousLane; - - case DefaultHydrationLane: - return_highestLanePriority = DefaultHydrationLanePriority; - return DefaultHydrationLane; - - case DefaultLane: - return_highestLanePriority = DefaultLanePriority; - return DefaultLane; - - case TransitionHydrationLane: - return_highestLanePriority = TransitionHydrationPriority; - return TransitionHydrationLane; - - case TransitionLane1: - case TransitionLane2: - case TransitionLane3: - case TransitionLane4: - case TransitionLane5: - case TransitionLane6: - case TransitionLane7: - case TransitionLane8: - case TransitionLane9: - case TransitionLane10: - case TransitionLane11: - case TransitionLane12: - case TransitionLane13: - case TransitionLane14: - return_highestLanePriority = TransitionPriority; - return lanes & TransitionLanes; - - case RetryLane1: - case RetryLane2: - case RetryLane3: - case RetryLane4: - return_highestLanePriority = RetryLanePriority; - return lanes & RetryLanes; - - case SelectiveHydrationLane: - return_highestLanePriority = SelectiveHydrationLanePriority; - return SelectiveHydrationLane; - - case IdleHydrationLane: - return_highestLanePriority = IdleHydrationLanePriority; - return IdleHydrationLane; - - case IdleLane: - return_highestLanePriority = IdleLanePriority; - return IdleLane; - - case OffscreenLane: - return_highestLanePriority = OffscreenLanePriority; - return OffscreenLane; - - default: - { - 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_highestLanePriority = DefaultLanePriority; - return lanes; - } -} - -function schedulerPriorityToLanePriority(schedulerPriorityLevel) { - switch (schedulerPriorityLevel) { - case ImmediatePriority: - return SyncLanePriority; - - case UserBlockingPriority: - return InputContinuousLanePriority; - - case NormalPriority: - case LowPriority: - // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. - return DefaultLanePriority; - - case IdlePriority: - return IdleLanePriority; - - default: - return NoLanePriority; - } -} -function lanePriorityToSchedulerPriority(lanePriority) { - switch (lanePriority) { - case SyncLanePriority: - case SyncBatchedLanePriority: - return ImmediatePriority; - - case InputDiscreteHydrationLanePriority: - case InputDiscreteLanePriority: - case InputContinuousHydrationLanePriority: - case InputContinuousLanePriority: - return UserBlockingPriority; - - case DefaultHydrationLanePriority: - case DefaultLanePriority: - case TransitionHydrationPriority: - case TransitionPriority: - case SelectiveHydrationLanePriority: - case RetryLanePriority: - return NormalPriority; - - 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." - ); - } - } -} -function getNextLanes(root, wipLanes) { - // Early bailout if there's no pending work left. - var pendingLanes = root.pendingLanes; - - if (pendingLanes === NoLanes) { - return_highestLanePriority = NoLanePriority; - return NoLanes; - } - - var nextLanes = NoLanes; - var nextLanePriority = NoLanePriority; - var expiredLanes = root.expiredLanes; - var suspendedLanes = root.suspendedLanes; - var pingedLanes = root.pingedLanes; // Check if any work has expired. - - if (expiredLanes !== NoLanes) { - // TODO: Should entangle with SyncLane - 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 (nonIdlePendingLanes !== NoLanes) { - var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; - - 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; - - 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 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 ( - 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; - - if ( - nextLanePriority <= wipLanePriority || // Default priority updates should not interrupt transition updates. The - // only difference between default updates and transition updates is that - // default updates do not support refresh transitions. - (nextLanePriority === DefaultLanePriority && - wipLanePriority === TransitionPriority) - ) { - // Keep working on the existing in-progress tree. Do not interrupt. - 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. - // TODO: Reconsider this. The counter-argument is that the partial work - // represents an intermediate state, which we don't want to show to the user. - // And by spending extra time finishing it, we're increasing the amount of - // time it takes to show the final state, which is what they are actually - // waiting for. - // - // 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. - - var entangledLanes = root.entangledLanes; - - 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; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - var eventTime = eventTimes[index]; - - if (eventTime > mostRecentEventTime) { - mostRecentEventTime = eventTime; - } - - lanes &= ~lane; - } - - return mostRecentEventTime; -} - -function computeExpirationTime(lane, currentTime) { - // TODO: Expiration heuristic is constant per lane, so could use a map. - getHighestPriorityLanes(lane); - var priority = return_highestLanePriority; - - 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; - - if (everythingButOffscreen !== NoLanes) { - return everythingButOffscreen; - } - - if (everythingButOffscreen & OffscreenLane) { - return OffscreenLane; - } - - return NoLanes; -} -function returnNextLanesPriority() { - return return_highestLanePriority; -} -function includesNonIdleWork(lanes) { - return (lanes & NonIdleLanes) !== NoLanes; -} -function includesOnlyRetries(lanes) { - return (lanes & RetryLanes) === lanes; -} -function includesOnlyTransitions(lanes) { - return (lanes & TransitionLanes) === lanes; -} -function isTransitionLane(lane) { - return (lane & TransitionLanes) !== 0; -} // 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) { - switch (lanePriority) { - case NoLanePriority: - break; - - case SyncLanePriority: - return SyncLane; - - case SyncBatchedLanePriority: - return SyncBatchedLane; - - case InputDiscreteLanePriority: - return InputDiscreteLane; - - case InputContinuousLanePriority: - return InputContinuousLane; - - case DefaultLanePriority: - return DefaultLane; - - case TransitionPriority: // Should be handled by findTransitionLane instead - - case RetryLanePriority: - // Should be handled by findRetryLane instead - break; - - case IdleLanePriority: - return IdleLane; - } - - { - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } -} -function claimNextTransitionLane() { - // Cycle through the lanes, assigning each new transition to the next lane. - // In most cases, this means every transition gets its own lane, until we - // run out of lanes and cycle back to the beginning. - var lane = nextTransitionLane; - nextTransitionLane <<= 1; - - if ((nextTransitionLane & TransitionLanes) === 0) { - nextTransitionLane = TransitionLane1; - } - - return lane; -} -function claimNextRetryLane() { - var lane = nextRetryLane; - nextRetryLane <<= 1; - - if ((nextRetryLane & RetryLanes) === 0) { - nextRetryLane = RetryLane1; - } - - return lane; -} - -function getHighestPriorityLane(lanes) { - return lanes & -lanes; -} - -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); -} - -function pickArbitraryLaneIndex(lanes) { - return 31 - clz32(lanes); -} - -function laneToIndex(lane) { - return pickArbitraryLaneIndex(lane); -} - -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; -} -function intersectLanes(a, b) { - return a & b; -} // Seems redundant, but it changes the type from a single lane (used for -// updates) to a group of lanes (used for flushing work). - -function laneToLanes(lane) { - return lane; -} -function createLaneMap(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; // If there are any suspended transitions, it's possible this new update - // could unblock them. Clear the suspended lanes so that we can try rendering - // them again. - // - // TODO: We really only need to unsuspend only lanes that are in the - // `subtreeLanes` of the updated fiber, or the update lanes of the return - // path. This would exclude suspended updates in an unrelated sibling tree, - // since there's no way for this update to unblock it. - // - // We don't do this if the incoming update is idle, because we never process - // idle updates until after all the regular updates have finished; there's no - // way it could unblock a transition. - - if (updateLane !== IdleLane) { - root.suspendedLanes = NoLanes; - root.pingedLanes = NoLanes; - } - - 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. - - 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 markRootExpired(root, expiredLanes) { - root.expiredLanes |= expiredLanes & root.pendingLanes; -} -function hasDiscreteLanes(lanes) { - return (lanes & InputDiscreteLane) !== 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) { - // In addition to entangling each of the given lanes with each other, we also - // have to consider _transitive_ entanglements. For each lane that is already - // entangled with *any* of the given lanes, that lane is now transitively - // entangled with *all* the given lanes. - // - // Translated: If C is entangled with A, then entangling A with B also - // entangles C with B. - // - // If this is hard to grasp, it might help to intentionally break this - // function and look at the tests that fail in ReactTransition-test.js. Try - // commenting out one of the conditions below. - var rootEntangledLanes = (root.entangledLanes |= entangledLanes); - var entanglements = root.entanglements; - var lanes = rootEntangledLanes; - - while (lanes) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - - if ( - // Is this one of the newly entangled lanes? - (lane & entangledLanes) | // Is this lane transitively entangled with the newly entangled lanes? - (entanglements[index] & entangledLanes) - ) { - 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_now$1 = Scheduler.unstable_now; - -{ - // 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" - ); - } -} -var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. - // can re-export everything from this module. function shim() { @@ -4724,7 +3730,8 @@ var _nativeFabricUIManage = nativeFabricUIManager, registerEventHandler = _nativeFabricUIManage.registerEventHandler, fabricMeasure = _nativeFabricUIManage.measure, fabricMeasureInWindow = _nativeFabricUIManage.measureInWindow, - fabricMeasureLayout = _nativeFabricUIManage.measureLayout; + fabricMeasureLayout = _nativeFabricUIManage.measureLayout, + sendAccessibilityEvent = _nativeFabricUIManage.sendAccessibilityEvent; var getViewConfigForType = ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get; // Counter for uniquely identifying views. // % 10 === 1 means it is a rootTag. @@ -4942,7 +3949,7 @@ function shouldSetTextContent(type, props) { // It's not clear to me which is better so I'm deferring for now. // More context @ github.com/facebook/react/pull/8560#discussion_r92111303 return false; -} +} // The Fabric renderer is secondary to the existing React Native renderer. var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; var noTimeout = -1; // ------------------- @@ -5760,47 +4767,953 @@ function onCommitUnmount(fiber) { } } -var NoFlags$1 = - /* */ - 0; // Represents whether effect should fire. +// Intentionally not named imports because Rollup would use dynamic dispatch for +var Scheduler_now = Scheduler.unstable_now; -var HasEffect = - /* */ - 1; // Represents the phase in which the effect (not the clean-up) fires. +{ + // 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" + ); + } +} +// ascending numbers so we can compare them like numbers. They start at 90 to +// avoid clashing with Scheduler's priorities. -var Layout = - /* */ +var ImmediatePriority = 99; +var UserBlockingPriority = 98; +var NormalPriority = 97; +var LowPriority = 96; +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 = 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 Passive$1 = - /* */ +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; + +function getHighestPriorityLanes(lanes) { + if ((SyncLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncLanePriority; + return SyncLane; + } + + if ((SyncBatchedLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncBatchedLanePriority; + return SyncBatchedLane; + } + + if ((InputDiscreteHydrationLane & lanes) !== NoLanes) { + return_highestLanePriority = InputDiscreteHydrationLanePriority; + return InputDiscreteHydrationLane; + } + + var inputDiscreteLanes = InputDiscreteLanes & lanes; + + if (inputDiscreteLanes !== NoLanes) { + return_highestLanePriority = InputDiscreteLanePriority; + return inputDiscreteLanes; + } + + if ((lanes & InputContinuousHydrationLane) !== NoLanes) { + return_highestLanePriority = InputContinuousHydrationLanePriority; + return InputContinuousHydrationLane; + } + + var inputContinuousLanes = InputContinuousLanes & lanes; + + if (inputContinuousLanes !== NoLanes) { + return_highestLanePriority = InputContinuousLanePriority; + return inputContinuousLanes; + } + + if ((lanes & DefaultHydrationLane) !== NoLanes) { + return_highestLanePriority = DefaultHydrationLanePriority; + return DefaultHydrationLane; + } + + var defaultLanes = DefaultLanes & lanes; + + if (defaultLanes !== NoLanes) { + return_highestLanePriority = DefaultLanePriority; + return defaultLanes; + } + + if ((lanes & TransitionHydrationLane) !== NoLanes) { + return_highestLanePriority = TransitionHydrationPriority; + return TransitionHydrationLane; + } + + var transitionLanes = TransitionLanes & lanes; + + if (transitionLanes !== NoLanes) { + return_highestLanePriority = TransitionPriority; + return transitionLanes; + } + + var retryLanes = RetryLanes & lanes; + + if (retryLanes !== NoLanes) { + return_highestLanePriority = RetryLanePriority; + return retryLanes; + } + + if (lanes & SelectiveHydrationLane) { + return_highestLanePriority = SelectiveHydrationLanePriority; + return SelectiveHydrationLane; + } + + if ((lanes & IdleHydrationLane) !== NoLanes) { + return_highestLanePriority = IdleHydrationLanePriority; + return IdleHydrationLane; + } + + var idleLanes = IdleLanes & lanes; + + if (idleLanes !== NoLanes) { + return_highestLanePriority = IdleLanePriority; + return idleLanes; + } + + if ((OffscreenLane & lanes) !== NoLanes) { + return_highestLanePriority = OffscreenLanePriority; + return OffscreenLane; + } + + { + 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_highestLanePriority = DefaultLanePriority; + return lanes; +} + +function schedulerPriorityToLanePriority(schedulerPriorityLevel) { + switch (schedulerPriorityLevel) { + case ImmediatePriority: + return SyncLanePriority; + + case UserBlockingPriority: + return InputContinuousLanePriority; + + case NormalPriority: + case LowPriority: + // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. + return DefaultLanePriority; + + case IdlePriority: + return IdleLanePriority; + + default: + return NoLanePriority; + } +} +function lanePriorityToSchedulerPriority(lanePriority) { + switch (lanePriority) { + case SyncLanePriority: + case SyncBatchedLanePriority: + return ImmediatePriority; + + case InputDiscreteHydrationLanePriority: + case InputDiscreteLanePriority: + case InputContinuousHydrationLanePriority: + case InputContinuousLanePriority: + return UserBlockingPriority; + + case DefaultHydrationLanePriority: + case DefaultLanePriority: + case TransitionHydrationPriority: + case TransitionPriority: + case SelectiveHydrationLanePriority: + case RetryLanePriority: + return NormalPriority; + + 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." + ); + } + } +} +function getNextLanes(root, wipLanes) { + // Early bailout if there's no pending work left. + var pendingLanes = root.pendingLanes; + + if (pendingLanes === NoLanes) { + return_highestLanePriority = NoLanePriority; + return NoLanes; + } + + var nextLanes = NoLanes; + var nextLanePriority = NoLanePriority; + var expiredLanes = root.expiredLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; // Check if any work has expired. + + 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 (nonIdlePendingLanes !== NoLanes) { + var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; + + 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; + + 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 ( + 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; + + 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. + + var entangledLanes = root.entangledLanes; + + 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; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + var eventTime = eventTimes[index]; + + if (eventTime > mostRecentEventTime) { + mostRecentEventTime = eventTime; + } + + lanes &= ~lane; + } + + return mostRecentEventTime; +} + +function computeExpirationTime(lane, currentTime) { + // TODO: Expiration heuristic is constant per lane, so could use a map. + getHighestPriorityLanes(lane); + var priority = return_highestLanePriority; + + 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; + + if (everythingButOffscreen !== NoLanes) { + return everythingButOffscreen; + } + + if (everythingButOffscreen & OffscreenLane) { + return OffscreenLane; + } + + return NoLanes; +} +function returnNextLanesPriority() { + return return_highestLanePriority; +} +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. + +function findUpdateLane(lanePriority, wipLanes) { + switch (lanePriority) { + case NoLanePriority: + break; + + case SyncLanePriority: + return SyncLane; + + case SyncBatchedLanePriority: + return SyncBatchedLane; + + case InputDiscreteLanePriority: { + var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes); + + if (_lane === NoLane) { + // Shift to the next priority level + return findUpdateLane(InputContinuousLanePriority, wipLanes); + } + + return _lane; + } + + case InputContinuousLanePriority: { + var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes); + + if (_lane2 === NoLane) { + // Shift to the next priority level + return findUpdateLane(DefaultLanePriority, wipLanes); + } + + return _lane2; + } + + case DefaultLanePriority: { + var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes); + + 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 (_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); + } + } + + return _lane3; + } + + case TransitionPriority: // Should be handled by findTransitionLane instead + + case RetryLanePriority: + // Should be handled by findRetryLane instead + break; + + case IdleLanePriority: + var lane = pickArbitraryLane(IdleLanes & ~wipLanes); + + if (lane === NoLane) { + lane = pickArbitraryLane(IdleLanes); + } + + return lane; + } + + { + 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. + +function findTransitionLane(wipLanes, pendingLanes) { + // First look for lanes that are completely unclaimed, i.e. have no + // pending work. + var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes); + + 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); + } + } + + 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. + +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); + + if (lane === NoLane) { + lane = pickArbitraryLane(RetryLanes); + } + + return lane; +} + +function getHighestPriorityLane(lanes) { + return lanes & -lanes; +} + +function getLowestPriorityLane(lanes) { + // This finds the most significant non-zero bit. + var index = 31 - clz32(lanes); + return index < 0 ? NoLanes : 1 << index; +} + +function getEqualOrHigherPriorityLanes(lanes) { + return (getLowestPriorityLane(lanes) << 1) - 1; +} + +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); +} + +function pickArbitraryLaneIndex(lanes) { + return 31 - clz32(lanes); +} + +function laneToIndex(lane) { + return pickArbitraryLaneIndex(lane); +} + +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). + +function laneToLanes(lane) { + return lane; +} +function createLaneMap(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 + // 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. + + var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111 + + 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. + + 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" + ); + } +} + +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. + +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. + +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 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; + + case Scheduler_UserBlockingPriority: + return UserBlockingPriority$1; + + case Scheduler_NormalPriority: + return NormalPriority$1; + + case Scheduler_LowPriority: + return LowPriority$1; + + case Scheduler_IdlePriority: + return IdlePriority$1; + + default: { + throw Error("Unknown priority level."); + } + } +} + +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case ImmediatePriority$1: + return Scheduler_ImmediatePriority; + + case UserBlockingPriority$1: + return Scheduler_UserBlockingPriority; + + case NormalPriority$1: + return Scheduler_NormalPriority; + + case LowPriority$1: + return Scheduler_LowPriority; + + case IdlePriority$1: + return Scheduler_IdlePriority; + + default: { + throw Error("Unknown priority level."); + } + } +} + +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. + + 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 fakeCallbackNode; +} +function cancelCallback(callbackNode) { + if (callbackNode !== fakeCallbackNode) { + Scheduler_cancelCallback(callbackNode); + } +} +function flushSyncCallbackQueue() { + if (immediateQueueCallbackNode !== null) { + var node = immediateQueueCallbackNode; + immediateQueueCallbackNode = null; + Scheduler_cancelCallback(node); + } + + flushSyncCallbackQueueImpl(); +} + +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; + } + } + } +} // TODO: this is special because it gets imported during build. -// -// TODO: 17.0.2 has not been released to NPM; -// It exists as a placeholder so that DevTools can support work tag changes between releases. -// When we next publish a release (either 17.0.2 or 17.1.0), update the matching TODO in backend/renderer.js -var ReactVersion = "17.0.2"; +var ReactVersion = "17.0.1-454c2211c"; -var NoMode = - /* */ - 0; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root tag instead +var NoMode = 0; +var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root +// tag instead -var BlockingMode = - /* */ - 1; -var ConcurrentMode = - /* */ - 2; -var ProfileMode = - /* */ - 4; -var DebugTracingMode = - /* */ - 8; -var StrictLegacyMode = - /* */ - 16; +var BlockingMode = 2; +var ConcurrentMode = 4; +var ProfileMode = 8; +var DebugTracingMode = 16; var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -5978,7 +5891,7 @@ var ReactStrictModeWarnings = { var node = fiber; while (node !== null) { - if (node.mode & StrictLegacyMode) { + if (node.mode & StrictMode) { maybeStrictRoot = node; } @@ -6009,7 +5922,7 @@ var ReactStrictModeWarnings = { fiber, instance ) { - // Dedupe strategy: Warn once per component. + // Dedup strategy: Warn once per component. if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { return; } @@ -6022,7 +5935,7 @@ var ReactStrictModeWarnings = { } if ( - fiber.mode & StrictLegacyMode && + fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === "function" ) { pendingUNSAFE_ComponentWillMountWarnings.push(fiber); @@ -6036,7 +5949,7 @@ var ReactStrictModeWarnings = { } if ( - fiber.mode & StrictLegacyMode && + fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === "function" ) { pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); @@ -6050,7 +5963,7 @@ var ReactStrictModeWarnings = { } if ( - fiber.mode & StrictLegacyMode && + fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === "function" ) { pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); @@ -6368,7 +6281,9 @@ function exitDisallowedContextReadInDEV() { isDisallowedContextReadInDEV = false; } } -function pushProvider(providerFiber, context, nextValue) { +function pushProvider(providerFiber, nextValue) { + var context = providerFiber.type._context; + { push(valueCursor, context._currentValue2, providerFiber); context._currentValue2 = nextValue; @@ -6389,9 +6304,10 @@ function pushProvider(providerFiber, context, nextValue) { } } } -function popProvider(context, providerFiber) { +function popProvider(providerFiber) { var currentValue = valueCursor.current; pop(valueCursor, providerFiber); + var context = providerFiber.type._context; { context._currentValue2 = currentValue; @@ -6478,31 +6394,16 @@ function propagateContextChange( // Match! Schedule an update on this fiber. if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. - var lane = pickArbitraryLane(renderLanes); - var update = createUpdate(NoTimestamp, lane); + 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 // worth fixing. - // Inlined `enqueueUpdate` to remove interleaved update check - var updateQueue = fiber.updateQueue; - - if (updateQueue === null); - else { - var sharedQueue = updateQueue.shared; - var pending = sharedQueue.pending; - - if (pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = pending.next; - pending.next = update; - } - - sharedQueue.pending = update; - } + enqueueUpdate(fiber, update); } fiber.lanes = mergeLanes(fiber.lanes, renderLanes); @@ -6637,48 +6538,6 @@ function readContext(context, observedBits) { return context._currentValue2; } -// An array of all update queues that received updates during the current -// render. When this render exits, either because it finishes or because it is -// interrupted, the interleaved updates will be transfered onto the main part -// of the queue. -var interleavedQueues = null; -function pushInterleavedQueue(queue) { - if (interleavedQueues === null) { - interleavedQueues = [queue]; - } else { - interleavedQueues.push(queue); - } -} -function enqueueInterleavedUpdates() { - // Transfer the interleaved updates onto the main queue. Each queue has a - // `pending` field and an `interleaved` field. When they are not null, they - // point to the last node in a circular linked list. We need to append the - // interleaved list to the end of the pending list by joining them into a - // single, circular list. - if (interleavedQueues !== null) { - for (var i = 0; i < interleavedQueues.length; i++) { - var queue = interleavedQueues[i]; - var lastInterleavedUpdate = queue.interleaved; - - if (lastInterleavedUpdate !== null) { - queue.interleaved = null; - var firstInterleavedUpdate = lastInterleavedUpdate.next; - var lastPendingUpdate = queue.pending; - - if (lastPendingUpdate !== null) { - var firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = firstInterleavedUpdate; - lastInterleavedUpdate.next = firstPendingUpdate; - } - - queue.pending = lastInterleavedUpdate; - } - } - - interleavedQueues = null; - } -} - var UpdateState = 0; var ReplaceState = 1; var ForceUpdate = 2; @@ -6701,9 +6560,7 @@ function initializeUpdateQueue(fiber) { firstBaseUpdate: null, lastBaseUpdate: null, shared: { - pending: null, - interleaved: null, - lanes: NoLanes + pending: null }, effects: null }; @@ -6736,7 +6593,7 @@ function createUpdate(eventTime, lane) { }; return update; } -function enqueueUpdate(fiber, update, lane) { +function enqueueUpdate(fiber, update) { var updateQueue = fiber.updateQueue; if (updateQueue === null) { @@ -6745,36 +6602,18 @@ function enqueueUpdate(fiber, update, lane) { } var sharedQueue = updateQueue.shared; + var pending = sharedQueue.pending; - if (isInterleavedUpdate(fiber)) { - var interleaved = sharedQueue.interleaved; - - if (interleaved === null) { - // This is the first update. Create a circular list. - update.next = update; // At the end of the current render, this queue's interleaved updates will - // be transfered to the pending queue. - - pushInterleavedQueue(sharedQueue); - } else { - update.next = interleaved.next; - interleaved.next = update; - } - - sharedQueue.interleaved = update; + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; } else { - var pending = sharedQueue.pending; - - if (pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = pending.next; - pending.next = update; - } - - sharedQueue.pending = update; + update.next = pending.next; + pending.next = update; } + sharedQueue.pending = update; + { if ( currentlyProcessingQueue === sharedQueue && @@ -6791,33 +6630,6 @@ function enqueueUpdate(fiber, update, lane) { } } } -function entangleTransitions(root, fiber, lane) { - var updateQueue = fiber.updateQueue; - - if (updateQueue === null) { - // Only occurs if the fiber has been unmounted. - return; - } - - var sharedQueue = updateQueue.shared; - - if (isTransitionLane(lane)) { - var queueLanes = sharedQueue.lanes; // If any entangled lanes are no longer pending on the root, then they must - // have finished. We can remove them from the shared queue, which represents - // a superset of the actually pending lanes. In some cases we may entangle - // more than we need to, but that's OK. In fact it's worse if we *don't* - // entangle when we should. - - queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes. - - var newQueueLanes = mergeLanes(queueLanes, lane); - sharedQueue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if - // the lane finished since the last time we entangled it. So we need to - // entangle it again, just to be sure. - - markRootEntangled(root, newQueueLanes); - } -} 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, @@ -6919,7 +6731,7 @@ function getStateFromUpdate( var nextState = payload.call(instance, prevState, nextProps); { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -6957,7 +6769,7 @@ function getStateFromUpdate( partialState = _payload.call(instance, prevState, nextProps); { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -7147,24 +6959,7 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { queue.baseState = newBaseState; queue.firstBaseUpdate = newFirstBaseUpdate; - queue.lastBaseUpdate = newLastBaseUpdate; // Interleaved updates are stored on a separate queue. We aren't going to - // process them during this render, but we do need to track which lanes - // are remaining. - - var lastInterleaved = queue.shared.interleaved; - - if (lastInterleaved !== null) { - var interleaved = lastInterleaved; - - do { - newLanes = mergeLanes(newLanes, interleaved.lane); - interleaved = interleaved.next; - } while (interleaved !== lastInterleaved); - } else if (firstBaseUpdate === null) { - // `queue.lanes` is used for entangling transitions. We can set it back to - // zero once the queue is empty. - queue.shared.lanes = NoLanes; - } // Set the remaining expiration time to be whatever is remaining in the queue. + 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 @@ -7305,7 +7100,7 @@ function applyDerivedStateFromProps( var prevState = workInProgress.memoizedState; { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -7354,11 +7149,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - - if (root !== null) { - entangleTransitions(root, fiber, lane); - } + scheduleUpdateOnFiber(fiber, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { var fiber = get(inst); @@ -7377,11 +7168,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - - if (root !== null) { - entangleTransitions(root, fiber, lane); - } + scheduleUpdateOnFiber(fiber, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); @@ -7399,11 +7186,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - - if (root !== null) { - entangleTransitions(root, fiber, lane); - } + scheduleUpdateOnFiber(fiber, lane, eventTime); } }; @@ -7420,7 +7203,7 @@ function checkShouldComponentUpdate( if (typeof instance.shouldComponentUpdate === "function") { { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -7756,7 +7539,7 @@ function constructClassInstance(workInProgress, ctor, props) { } // Instantiate twice to help detect side-effects. { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -7969,7 +7752,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } } - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { ReactStrictModeWarnings.recordLegacyContextWarning( workInProgress, instance @@ -8013,9 +7796,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } if (typeof instance.componentDidMount === "function") { - { - workInProgress.flags |= Update; - } + workInProgress.flags |= Update; } } @@ -8077,9 +7858,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.flags |= Update; - } + workInProgress.flags |= Update; } return false; @@ -8125,17 +7904,13 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { } if (typeof instance.componentDidMount === "function") { - { - workInProgress.flags |= 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.flags |= Update; - } + workInProgress.flags |= Update; } // If shouldComponentUpdate returned false, we should still update the // memoized state to indicate that this work can be reused. @@ -8385,7 +8160,7 @@ function coerceRef(returnFiber, current, element) { // TODO: Clean this up once we turn on the string ref warning for // everyone, because the strict mode case will no longer be relevant if ( - (returnFiber.mode & StrictLegacyMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs + (returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs // because these cannot be automatically converted to an arrow function // using a codemod. Therefore, we don't have to warn about string refs again. !( @@ -8487,14 +8262,12 @@ function coerceRef(returnFiber, current, element) { function throwOnInvalidObjectType(returnFiber, newChild) { if (returnFiber.type !== "textarea") { - var childString = Object.prototype.toString.call(newChild); - { throw Error( "Objects are not valid as a React child (found: " + - (childString === "[object Object]" + (Object.prototype.toString.call(newChild) === "[object Object]" ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : childString) + + : newChild) + "). If you meant to render a collection of children, use an array instead." ); } @@ -8517,7 +8290,7 @@ function warnOnFunctionType(returnFiber) { "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 // 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. @@ -8527,16 +8300,23 @@ function ChildReconciler(shouldTrackSideEffects) { if (!shouldTrackSideEffects) { // Noop. return; - } + } // Deletions are added in reversed order so we add it to the front. + // At this point, the return fiber's effect list is empty except for + // deletions, so we can just append the deletion to the list. The remaining + // effects aren't added until the complete phase. Once we implement + // resuming, this may not be true. - var deletions = returnFiber.deletions; + var last = returnFiber.lastEffect; - if (deletions === null) { - returnFiber.deletions = [childToDelete]; - returnFiber.flags |= ChildDeletion; + if (last !== null) { + last.nextEffect = childToDelete; + returnFiber.lastEffect = childToDelete; } else { - deletions.push(childToDelete); + returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; } + + childToDelete.nextEffect = null; + childToDelete.flags = Deletion; } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -8600,7 +8380,7 @@ function ChildReconciler(shouldTrackSideEffects) { if (oldIndex < lastPlacedIndex) { // This is a move. - newFiber.flags |= Placement; + newFiber.flags = Placement; return lastPlacedIndex; } else { // This item can stay in place. @@ -8608,7 +8388,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.flags |= Placement; + newFiber.flags = Placement; return lastPlacedIndex; } } @@ -8617,7 +8397,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.flags |= Placement; + newFiber.flags = Placement; } return newFiber; @@ -8638,26 +8418,10 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current, element, lanes) { - var elementType = element.type; - - if (elementType === REACT_FRAGMENT_TYPE) { - return updateFragment( - returnFiber, - current, - element.props.children, - lanes, - element.key - ); - } - if (current !== null) { if ( - current.elementType === elementType || // Keep this check inline so it only runs on the false path: - isCompatibleFamilyForHotReloading(current, element) || // Lazy types should reconcile their resolved type. - // We need to do this after the Hot Reloading check above, - // because hot reloading has different semantics than prod because - // it doesn't resuspend. So we can't let the call below suspend. - enableLazyElements + current.elementType === element.type || // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(current, element) ) { // Move based on index var existing = useFiber(current, element.props); @@ -8796,6 +8560,16 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: { if (newChild.key === key) { + if (newChild.type === REACT_FRAGMENT_TYPE) { + return updateFragment( + returnFiber, + oldFiber, + newChild.props.children, + lanes, + key + ); + } + return updateElement(returnFiber, oldFiber, newChild, lanes); } else { return null; @@ -8853,6 +8627,16 @@ function ChildReconciler(shouldTrackSideEffects) { newChild.key === null ? newIdx : newChild.key ) || null; + if (newChild.type === REACT_FRAGMENT_TYPE) { + return updateFragment( + returnFiber, + _matchedFiber, + newChild.props.children, + lanes, + newChild.key + ); + } + return updateElement(returnFiber, _matchedFiber, newChild, lanes); } @@ -9346,43 +9130,45 @@ function ChildReconciler(shouldTrackSideEffects) { // TODO: If key === null and child.key === null, then this only applies to // the first item in the list. if (child.key === key) { - var elementType = element.type; + switch (child.tag) { + case Fragment: { + if (element.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren(returnFiber, child.sibling); + var existing = useFiber(child, element.props.children); + existing.return = returnFiber; - if (elementType === REACT_FRAGMENT_TYPE) { - if (child.tag === Fragment) { - deleteRemainingChildren(returnFiber, child.sibling); - var existing = useFiber(child, element.props.children); - existing.return = returnFiber; + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; + return existing; } - return existing; + break; } - } else { - if ( - child.elementType === elementType || // Keep this check inline so it only runs on the false path: - isCompatibleFamilyForHotReloading(child, element) || // Lazy types should reconcile their resolved type. - // We need to do this after the Hot Reloading check above, - // because hot reloading has different semantics than prod because - // it doesn't resuspend. So we can't let the call below suspend. - enableLazyElements - ) { - deleteRemainingChildren(returnFiber, child.sibling); - var _existing = useFiber(child, element.props); + default: { + if ( + child.elementType === element.type || // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(child, element) + ) { + deleteRemainingChildren(returnFiber, child.sibling); - _existing.ref = coerceRef(returnFiber, child, element); - _existing.return = returnFiber; + var _existing = useFiber(child, element.props); - { - _existing._debugSource = element._source; - _existing._debugOwner = element._owner; + _existing.ref = coerceRef(returnFiber, child, element); + _existing.return = returnFiber; + + { + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; + } + + return _existing; } - return _existing; + break; } } // Didn't match. @@ -9813,6 +9599,21 @@ function findFirstSuspended(row) { return null; } +var NoFlags$1 = + /* */ + 0; // Represents whether effect should fire. + +var HasEffect = + /* */ + 1; // Represents the phase in which the effect (not the clean-up) fires. + +var Layout = + /* */ + 2; +var Passive$1 = + /* */ + 4; + var isHydrating = false; function enterHydrationState(fiber) { @@ -9908,12 +9709,6 @@ function warnAboutMultipleRenderersDEV(mutableSource) { } } // Eager reads the version of a mutable source and stores it on the root. -function getSuspendedCachePool() { - { - return null; - } // We check the cache on the stack first, since that's the one any new Caches -} - var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; @@ -10199,20 +9994,7 @@ function renderWithHooks( { currentHookNameInDev = null; hookTypesDev = null; - hookTypesUpdateIndexDev = -1; // Confirm that a static flag was not added or removed since the last - // render. If this fires, it suggests that we incorrectly reset the static - // flags in some other part of the codebase. This has happened before, for - // example, in the SuspenseList implementation. - - if ( - current !== null && - (current.flags & PassiveStatic) !== (workInProgress.flags & PassiveStatic) - ) { - error( - "Internal React error: Expected static flag was missing. Please " + - "notify the React team." - ); - } + hookTypesUpdateIndexDev = -1; } didScheduleRenderPhaseUpdate = false; @@ -10226,13 +10008,8 @@ function renderWithHooks( return children; } function bailoutHooks(current, workInProgress, lanes) { - workInProgress.updateQueue = current.updateQueue; // TODO: Don't need to reset the flags here, because they're reset in the - // complete phase (bubbleProperties). - - { - workInProgress.flags &= ~(Passive | Update); - } - + workInProgress.updateQueue = current.updateQueue; + workInProgress.flags &= ~(Passive | Update); current.lanes = removeLanes(current.lanes, lanes); } function resetHooksAfterThrow() { @@ -10383,8 +10160,6 @@ function mountReducer(reducer, initialArg, init) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { pending: null, - interleaved: null, - lanes: NoLanes, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialState @@ -10522,28 +10297,6 @@ function updateReducer(reducer, initialArg, init) { hook.baseState = newBaseState; hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; - } // Interleaved updates are stored on a separate queue. We aren't going to - // process them during this render, but we do need to track which lanes - // are remaining. - - var lastInterleaved = queue.interleaved; - - if (lastInterleaved !== null) { - var interleaved = lastInterleaved; - - do { - var interleavedLane = interleaved.lane; - currentlyRenderingFiber$1.lanes = mergeLanes( - currentlyRenderingFiber$1.lanes, - interleavedLane - ); - markSkippedUpdateLanes(interleavedLane); - interleaved = interleaved.next; - } while (interleaved !== lastInterleaved); - } else if (baseQueue === null) { - // `queue.lanes` is used for entangling transitions. We can set it back to - // zero once the queue is empty. - queue.lanes = NoLanes; } var dispatch = queue.dispatch; @@ -10671,48 +10424,11 @@ function readFromUnsubcribedMutableSource(root, source, getSnapshot) { // // 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); // Intentioally throw an error to force React to retry synchronously. During - // the synchronous retry, it will block interleaved mutations, so we should - // get a consistent read. Therefore, the following error should never be - // visible to the user. - // - // If it were to become visible to the user, it suggests one of two things: - // a bug in React, or (more likely), a mutation during the render phase that - // caused the second re-render attempt to be different from the first. - // - // We know it's the second case if the logs are currently disabled. So in - // dev, we can present a more accurate error message. - - { - // eslint-disable-next-line react-internal/no-production-logging - if (console.log.__reactDisabledLog) { - // If the logs are disabled, this is the dev-only double render. This is - // only reachable if there was a mutation during render. Show a helpful - // error message. - // - // Something interesting to note: because we only double render in - // development, this error will never happen during production. This is - // actually true of all errors that occur during a double render, - // because if the first render had thrown, we would have exited the - // begin phase without double rendering. We should consider suppressing - // any error from a double render (with a warning) to more closely match - // the production behavior. - var componentName = getComponentName(currentlyRenderingFiber$1.type); - - { - throw Error( - "A mutable source was mutated while the " + - componentName + - " component was rendering. This is not supported. Move any mutations into event handlers or effects." - ); - } - } - } // We expect this error not to be thrown during the synchronous retry, - // because we blocked interleaved mutations. + markSourceAsDirty(source); { throw Error( - "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." ); } } @@ -10848,8 +10564,6 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { // including any interleaving updates that occur. var newQueue = { pending: null, - interleaved: null, - lanes: NoLanes, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot @@ -10897,8 +10611,6 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { pending: null, - interleaved: null, - lanes: NoLanes, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -10992,7 +10704,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var prevDeps = prevEffect.deps; if (areHookInputsEqual(nextDeps, prevDeps)) { - hook.memoizedState = pushEffect(hookFlags, create, destroy, nextDeps); + pushEffect(hookFlags, create, destroy, nextDeps); return; } } @@ -11008,19 +10720,15 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { } function mountEffect(create, deps) { - { - return mountEffectImpl(Passive | PassiveStatic, Passive$1, create, deps); - } + return mountEffectImpl(Update | Passive, Passive$1, create, deps); } function updateEffect(create, deps) { - return updateEffectImpl(Passive, Passive$1, create, deps); + return updateEffectImpl(Update | Passive, Passive$1, create, deps); } function mountLayoutEffect(create, deps) { - { - return mountEffectImpl(Update, Layout, create, deps); - } + return mountEffectImpl(Update, Layout, create, deps); } function updateLayoutEffect(create, deps) { @@ -11072,15 +10780,12 @@ function mountImperativeHandle(ref, create, deps) { var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; - - { - return mountEffectImpl( - Update, - Layout, - imperativeHandleEffect.bind(null, create, ref), - effectDeps - ); - } + return mountEffectImpl( + Update, + Layout, + imperativeHandleEffect.bind(null, create, ref), + effectDeps + ); } function updateImperativeHandle(ref, create, deps) { @@ -11235,15 +10940,15 @@ function startTransition(setPending, callback) { { runWithPriority( - priorityLevel < UserBlockingPriority - ? UserBlockingPriority + priorityLevel < UserBlockingPriority$1 + ? UserBlockingPriority$1 : priorityLevel, function() { setPending(true); } ); runWithPriority( - priorityLevel > NormalPriority ? NormalPriority : priorityLevel, + priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, function() { var prevTransition = ReactCurrentBatchConfig$1.transition; ReactCurrentBatchConfig$1.transition = 1; @@ -11355,7 +11060,19 @@ function dispatchAction(fiber, queue, action) { eagerReducer: null, eagerState: null, next: null - }; + }; // Append the update to the end of the list. + + var pending = queue.pending; + + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } + + queue.pending = update; var alternate = fiber.alternate; if ( @@ -11366,47 +11083,7 @@ function dispatchAction(fiber, queue, action) { // 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. didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; - var pending = queue.pending; - - if (pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = pending.next; - pending.next = update; - } - - queue.pending = update; } else { - if (isInterleavedUpdate(fiber)) { - var interleaved = queue.interleaved; - - if (interleaved === null) { - // This is the first update. Create a circular list. - update.next = update; // At the end of the current render, this queue's interleaved updates will - // be transfered to the pending queue. - - pushInterleavedQueue(queue); - } else { - update.next = interleaved.next; - interleaved.next = update; - } - - queue.interleaved = update; - } else { - var _pending = queue.pending; - - if (_pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = _pending.next; - _pending.next = update; - } - - queue.pending = update; - } - if ( fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes) @@ -11451,24 +11128,7 @@ function dispatchAction(fiber, queue, action) { } } - var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - - if (isTransitionLane(lane) && root !== null) { - var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they - // must have finished. We can remove them from the shared queue, which - // represents a superset of the actually pending lanes. In some cases we - // may entangle more than we need to, but that's OK. In fact it's worse if - // we *don't* entangle when we should. - - queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes. - - var newQueueLanes = mergeLanes(queueLanes, lane); - queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if - // the lane finished since the last time we entangled it. So we need to - // entangle it again, just to be sure. - - markRootEntangled(root, newQueueLanes); - } + scheduleUpdateOnFiber(fiber, lane, eventTime); } } @@ -11490,7 +11150,6 @@ var ContextOnlyDispatcher = { useOpaqueIdentifier: throwInvalidHookError, unstable_isNewReconciler: enableNewReconciler }; - var HooksDispatcherOnMountInDEV = null; var HooksDispatcherOnMountWithHookTypesInDEV = null; var HooksDispatcherOnUpdateInDEV = null; @@ -11620,7 +11279,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - HooksDispatcherOnMountWithHookTypesInDEV = { readContext: function(context, observedBits) { return readContext(context, observedBits); @@ -11718,7 +11376,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - HooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { return readContext(context, observedBits); @@ -11816,7 +11473,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - HooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { return readContext(context, observedBits); @@ -11914,7 +11570,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - InvalidNestedHooksDispatcherOnMountInDEV = { readContext: function(context, observedBits) { warnInvalidContextAccess(); @@ -12027,7 +11682,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - InvalidNestedHooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { warnInvalidContextAccess(); @@ -12140,7 +11794,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - InvalidNestedHooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { warnInvalidContextAccess(); @@ -12430,7 +12083,7 @@ function updateForwardRef( renderLanes ); - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -12664,29 +12317,21 @@ function updateSimpleMemoComponent( function updateOffscreenComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var nextChildren = nextProps.children; - var prevState = current !== null ? current.memoizedState : null; // If this is not null, this is a cache pool that was carried over from the - // previous render. We will push this to the cache pool context so that we can - // resume in-flight requests. - - var spawnedCachePool = null; + var prevState = current !== null ? current.memoizedState : null; if ( nextProps.mode === "hidden" || nextProps.mode === "unstable-defer-without-hiding" ) { - // Rendering a hidden tree. 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, - cachePool: null + baseLanes: NoLanes }; workInProgress.memoizedState = nextState; pushRenderLanes(workInProgress, renderLanes); } else if (!includesSomeLane(renderLanes, OffscreenLane)) { - // We're hidden, and we're not rendering at Offscreen. We will bail out - // and resume this tree later. var nextBaseLanes; if (prevState !== null) { @@ -12704,19 +12349,17 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { OffscreenLane ); var _nextState = { - baseLanes: nextBaseLanes, - cachePool: spawnedCachePool + baseLanes: nextBaseLanes }; - workInProgress.memoizedState = _nextState; - workInProgress.updateQueue = null; // We're about to bail out, but we need to push this to the stack anyway + 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, - cachePool: null + baseLanes: NoLanes }; workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out. @@ -12725,12 +12368,10 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { pushRenderLanes(workInProgress, subtreeRenderLanes); } } else { - // Rendering a visible tree. var _subtreeRenderLanes; if (prevState !== null) { - // We're going from hidden -> visible. - _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); + _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state workInProgress.memoizedState = null; } else { @@ -12837,7 +12478,7 @@ function updateFunctionComponent( renderLanes ); - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -13012,7 +12653,7 @@ function finishClassComponent( setIsRendering(true); nextChildren = instance.render(); - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -13082,11 +12723,10 @@ function updateHostRoot(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; - var prevChildren = prevState.element; + var prevChildren = prevState !== null ? prevState.element : null; cloneUpdateQueue(current, workInProgress); processUpdateQueue(workInProgress, nextProps, null, renderLanes); - var nextState = workInProgress.memoizedState; - var root = workInProgress.stateNode; + var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". var nextChildren = nextState.element; @@ -13095,6 +12735,8 @@ function updateHostRoot(current, workInProgress, renderLanes) { return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } + var root = workInProgress.stateNode; + if (root.hydrate && enterHydrationState()) { var child = mountChildFibers( workInProgress, @@ -13375,7 +13017,7 @@ function mountIndeterminateComponent( } } - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); } @@ -13494,7 +13136,7 @@ function mountIndeterminateComponent( workInProgress.tag = FunctionComponent; { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -13598,17 +13240,13 @@ var SUSPENDED_MARKER = { function mountSuspenseOffscreenState(renderLanes) { return { - baseLanes: renderLanes, - cachePool: getSuspendedCachePool() + baseLanes: renderLanes }; } function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { - var cachePool = null; - return { - baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes), - cachePool: cachePool + baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) }; } // TODO: Probably should inline this back @@ -13968,14 +13606,9 @@ function updateSuspensePrimaryChildren( if (currentFallbackChildFragment !== null) { // Delete the fallback child fragment - var deletions = workInProgress.deletions; - - if (deletions === null) { - workInProgress.deletions = [currentFallbackChildFragment]; - workInProgress.flags |= ChildDeletion; - } else { - deletions.push(currentFallbackChildFragment); - } + currentFallbackChildFragment.nextEffect = null; + currentFallbackChildFragment.flags = Deletion; + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; } workInProgress.child = primaryChildFragment; @@ -14025,21 +13658,28 @@ function updateSuspenseFallbackChildren( currentPrimaryChildFragment.selfBaseDuration; primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration; - } // The fallback fiber was added as a deletion during the first pass. + } // 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. + // 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. - workInProgress.deletions = null; + 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 - ); // Since we're reusing a current tree, we need to reuse the flags, too. - // (We don't do this in legacy mode, because in legacy mode we don't re-use - // the current tree; see previous branch.) - - primaryChildFragment.subtreeFlags = - currentPrimaryChildFragment.subtreeFlags & StaticMask; + ); } var fallbackChildFragment; @@ -14309,7 +13949,8 @@ function initSuspenseListRenderState( isBackwards, tail, lastContentRow, - tailMode + tailMode, + lastEffectBeforeRendering ) { var renderState = workInProgress.memoizedState; @@ -14320,7 +13961,8 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailMode: tailMode + tailMode: tailMode, + lastEffect: lastEffectBeforeRendering }; } else { // We can reuse the existing object from previous renders. @@ -14330,6 +13972,7 @@ function initSuspenseListRenderState( renderState.last = lastContentRow; renderState.tail = tail; renderState.tailMode = tailMode; + renderState.lastEffect = lastEffectBeforeRendering; } } // This can end up rendering this component multiple passes. // The first pass splits the children fibers into two sets. A head and tail. @@ -14407,7 +14050,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { false, // isBackwards tail, lastContentRow, - tailMode + tailMode, + workInProgress.lastEffect ); break; } @@ -14441,7 +14085,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { true, // isBackwards _tail, null, // last - tailMode + tailMode, + workInProgress.lastEffect ); break; } @@ -14452,7 +14097,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { false, // isBackwards null, // tail null, // last - undefined + undefined, + workInProgress.lastEffect ); break; } @@ -14518,7 +14164,7 @@ function updateContextProvider(current, workInProgress, renderLanes) { } } - pushProvider(workInProgress, context, newValue); + pushProvider(workInProgress, newValue); if (oldProps !== null) { var oldValue = oldProps.value; @@ -14674,15 +14320,17 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { } // Delete the old fiber and place the new one. // Since the old fiber is disconnected, we have to schedule it manually. - var deletions = returnFiber.deletions; + var last = returnFiber.lastEffect; - if (deletions === null) { - returnFiber.deletions = [current]; - returnFiber.flags |= ChildDeletion; + if (last !== null) { + last.nextEffect = current; + returnFiber.lastEffect = current; } else { - deletions.push(current); + returnFiber.firstEffect = returnFiber.lastEffect = current; } + current.nextEffect = null; + current.flags = Deletion; newWorkInProgress.flags |= Placement; // Restart work from the new fiber. return newWorkInProgress; @@ -14755,8 +14403,7 @@ function beginWork(current, workInProgress, renderLanes) { case ContextProvider: { var newValue = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - pushProvider(workInProgress, context, newValue); + pushProvider(workInProgress, newValue); break; } @@ -15090,6 +14737,10 @@ function beginWork(current, workInProgress, renderLanes) { return updateSuspenseListComponent(current, workInProgress, renderLanes); } + case FundamentalComponent: { + break; + } + case ScopeComponent: { break; } @@ -15122,34 +14773,6 @@ function markRef$1(workInProgress) { workInProgress.flags |= Ref; } -function hadNoMutationsEffects(current, completedWork) { - var didBailout = current !== null && current.child === completedWork.child; - - if (didBailout) { - return true; - } - - if ((completedWork.flags & ChildDeletion) !== NoFlags) { - return false; - } // TODO: If we move the `hadNoMutationsEffects` call after `bubbleProperties` - // then we only have to check the `completedWork.subtreeFlags`. - - var child = completedWork.child; - - while (child !== null) { - if ( - (child.flags & MutationMask) !== NoFlags || - (child.subtreeFlags & MutationMask) !== NoFlags - ) { - return false; - } - - child = child.sibling; - } - - return true; -} - var appendAllChildren; var updateHostContainer; var updateHostComponent$1; @@ -15276,15 +14899,15 @@ var updateHostText$1; appendChildToContainerChildSet(containerChildSet, instance); } else if (node.tag === HostText) { - var _instance2 = node.stateNode; + var _instance3 = node.stateNode; if (needsVisibilityToggle && isHidden) { // This child is inside a timed out tree. Hide it. var text = node.memoizedProps; - _instance2 = cloneHiddenTextInstance(); + _instance3 = cloneHiddenTextInstance(); } - appendChildToContainerChildSet(containerChildSet, _instance2); + appendChildToContainerChildSet(containerChildSet, _instance3); } else if (node.tag === HostPortal); else if (node.tag === SuspenseComponent) { if ((node.flags & Update) !== NoFlags) { @@ -15347,9 +14970,9 @@ var updateHostText$1; } }; - updateHostContainer = function(current, workInProgress) { + updateHostContainer = function(workInProgress) { var portalOrRoot = workInProgress.stateNode; - var childrenUnchanged = hadNoMutationsEffects(current, workInProgress); + var childrenUnchanged = workInProgress.firstEffect === null; if (childrenUnchanged); else { @@ -15375,7 +14998,7 @@ var updateHostText$1; var oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates. // This guarantees that we can reuse all of them. - var childrenUnchanged = hadNoMutationsEffects(current, workInProgress); + var childrenUnchanged = workInProgress.firstEffect === null; if (childrenUnchanged && oldProps === newProps) { // No changes, just reuse the existing instance. @@ -15517,115 +15140,6 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { } } -function bubbleProperties(completedWork) { - var didBailout = - completedWork.alternate !== null && - completedWork.alternate.child === completedWork.child; - var newChildLanes = NoLanes; - var subtreeFlags = NoFlags; - - if (!didBailout) { - // Bubble up the earliest expiration time. - if ((completedWork.mode & ProfileMode) !== NoMode) { - // In profiling mode, resetChildExpirationTime is also used to reset - // profiler durations. - var actualDuration = completedWork.actualDuration; - var treeBaseDuration = completedWork.selfBaseDuration; - var child = completedWork.child; - - while (child !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(child.lanes, child.childLanes) - ); - subtreeFlags |= child.subtreeFlags; - subtreeFlags |= child.flags; // 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. - - actualDuration += child.actualDuration; - treeBaseDuration += child.treeBaseDuration; - child = child.sibling; - } - - completedWork.actualDuration = actualDuration; - completedWork.treeBaseDuration = treeBaseDuration; - } else { - var _child = completedWork.child; - - while (_child !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(_child.lanes, _child.childLanes) - ); - subtreeFlags |= _child.subtreeFlags; - subtreeFlags |= _child.flags; // Update the return pointer so the tree is consistent. This is a code - // smell because it assumes the commit phase is never concurrent with - // the render phase. Will address during refactor to alternate model. - - _child.return = completedWork; - _child = _child.sibling; - } - } - - completedWork.subtreeFlags |= subtreeFlags; - } else { - // Bubble up the earliest expiration time. - if ((completedWork.mode & ProfileMode) !== NoMode) { - // In profiling mode, resetChildExpirationTime is also used to reset - // profiler durations. - var _treeBaseDuration = completedWork.selfBaseDuration; - var _child2 = completedWork.child; - - while (_child2 !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(_child2.lanes, _child2.childLanes) - ); // "Static" flags share the lifetime of the fiber/hook they belong to, - // so we should bubble those up even during a bailout. All the other - // flags have a lifetime only of a single render + commit, so we should - // ignore them. - - subtreeFlags |= _child2.subtreeFlags & StaticMask; - subtreeFlags |= _child2.flags & StaticMask; - _treeBaseDuration += _child2.treeBaseDuration; - _child2 = _child2.sibling; - } - - completedWork.treeBaseDuration = _treeBaseDuration; - } else { - var _child3 = completedWork.child; - - while (_child3 !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(_child3.lanes, _child3.childLanes) - ); // "Static" flags share the lifetime of the fiber/hook they belong to, - // so we should bubble those up even during a bailout. All the other - // flags have a lifetime only of a single render + commit, so we should - // ignore them. - - subtreeFlags |= _child3.subtreeFlags & StaticMask; - subtreeFlags |= _child3.flags & StaticMask; // Update the return pointer so the tree is consistent. This is a code - // smell because it assumes the commit phase is never concurrent with - // the render phase. Will address during refactor to alternate model. - - _child3.return = completedWork; - _child3 = _child3.sibling; - } - } - - completedWork.subtreeFlags |= subtreeFlags; - } - - completedWork.childLanes = newChildLanes; - return didBailout; -} - function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; @@ -15640,7 +15154,6 @@ function completeWork(current, workInProgress, renderLanes) { case Profiler: case ContextConsumer: case MemoComponent: - bubbleProperties(workInProgress); return null; case ClassComponent: { @@ -15650,16 +15163,14 @@ function completeWork(current, workInProgress, renderLanes) { popContext(workInProgress); } - bubbleProperties(workInProgress); return null; } case HostRoot: { - var fiberRoot = workInProgress.stateNode; - popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); resetWorkInProgressVersions(); + var fiberRoot = workInProgress.stateNode; if (fiberRoot.pendingContext) { fiberRoot.context = fiberRoot.pendingContext; @@ -15684,8 +15195,7 @@ function completeWork(current, workInProgress, renderLanes) { } } - updateHostContainer(current, workInProgress); - bubbleProperties(workInProgress); + updateHostContainer(workInProgress); return null; } @@ -15714,7 +15224,6 @@ function completeWork(current, workInProgress, renderLanes) { ); } // This can happen when we abort work. - bubbleProperties(workInProgress); return null; } @@ -15751,7 +15260,6 @@ function completeWork(current, workInProgress, renderLanes) { } } - bubbleProperties(workInProgress); return null; } @@ -15792,7 +15300,6 @@ function completeWork(current, workInProgress, renderLanes) { } } - bubbleProperties(workInProgress); return null; } @@ -15806,7 +15313,7 @@ function completeWork(current, workInProgress, renderLanes) { if ((workInProgress.mode & ProfileMode) !== NoMode) { transferActualDuration(workInProgress); - } // Don't bubble properties in this case. + } return workInProgress; } @@ -15822,7 +15329,7 @@ function completeWork(current, workInProgress, renderLanes) { } if (nextDidTimeout && !prevDidTimeout) { - // If this subtree is running in blocking mode we can suspend, + // If this subtreee is running in blocking mode we can suspend, // otherwise we won't suspend. // TODO: This will still suspend a synchronous tree if anything // in the concurrent tree already suspended during this render. @@ -15867,42 +15374,22 @@ function completeWork(current, workInProgress, renderLanes) { } } - bubbleProperties(workInProgress); - - { - if ((workInProgress.mode & ProfileMode) !== NoMode) { - if (nextDidTimeout) { - // Don't count time spent in a timed out Suspense subtree as part of the base duration. - var _primaryChildFragment2 = workInProgress.child; - - if (_primaryChildFragment2 !== null) { - // $FlowFixMe Flow doens't support type casting in combiation with the -= operator - workInProgress.treeBaseDuration -= - _primaryChildFragment2.treeBaseDuration; - } - } - } - } - return null; } case HostPortal: popHostContainer(workInProgress); - updateHostContainer(current, workInProgress); + updateHostContainer(workInProgress); if (current === null) { preparePortalMount(workInProgress.stateNode.containerInfo); } - bubbleProperties(workInProgress); return null; case ContextProvider: // Pop provider fiber - var context = workInProgress.type._context; - popProvider(context, workInProgress); - bubbleProperties(workInProgress); + popProvider(workInProgress); return null; case IncompleteClassComponent: { @@ -15914,7 +15401,6 @@ function completeWork(current, workInProgress, renderLanes) { popContext(workInProgress); } - bubbleProperties(workInProgress); return null; } @@ -15925,7 +15411,6 @@ function completeWork(current, workInProgress, renderLanes) { if (renderState === null) { // We're running in the default, "independent" mode. // We don't do anything in this mode. - bubbleProperties(workInProgress); return null; } @@ -15977,10 +15462,14 @@ function completeWork(current, workInProgress, renderLanes) { workInProgress.flags |= Update; } // Rerender the whole list, but this time, we'll force fallbacks // to stay in place. - // Reset the effect flags before doing the second pass since that's now invalid. - // Reset the child fibers to their original state. + // Reset the effect list before doing the second pass since that's now invalid. + + if (renderState.lastEffect === null) { + workInProgress.firstEffect = null; + } + + workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. - workInProgress.subtreeFlags = NoFlags; resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately // rerender the children. @@ -15990,8 +15479,7 @@ function completeWork(current, workInProgress, renderLanes) { suspenseStackCursor.current, ForceSuspenseFallback ) - ); // Don't bubble properties in this case. - + ); return workInProgress.child; } @@ -16048,8 +15536,16 @@ function completeWork(current, workInProgress, renderLanes) { !renderedTail.alternate && !getIsHydrating() // We don't cut it if we're hydrating. ) { - // We're done. - bubbleProperties(workInProgress); + // We need to delete the row we just rendered. + // Reset the effect list to what it was before we rendered this + // child. The nested children have already appended themselves. + var lastEffect = (workInProgress.lastEffect = + renderState.lastEffect); // Remove any effects that were appended after this point. + + if (lastEffect !== null) { + lastEffect.nextEffect = null; + } // We're done. + return null; } } else if ( @@ -16109,6 +15605,7 @@ function completeWork(current, workInProgress, renderLanes) { var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; + renderState.lastEffect = workInProgress.lastEffect; renderState.renderingStartTime = now(); next.sibling = null; // Restore the context. // TODO: We can probably just avoid popping it instead and only @@ -16126,15 +15623,17 @@ function completeWork(current, workInProgress, renderLanes) { } pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row. - // Don't bubble properties in this case. return next; } - bubbleProperties(workInProgress); return null; } + case FundamentalComponent: { + break; + } + case ScopeComponent: { break; } @@ -16142,12 +15641,12 @@ function completeWork(current, workInProgress, renderLanes) { case OffscreenComponent: case LegacyHiddenComponent: { popRenderLanes(workInProgress); - var _nextState = workInProgress.memoizedState; - var nextIsHidden = _nextState !== null; if (current !== null) { + var _nextState = workInProgress.memoizedState; var _prevState = current.memoizedState; var prevIsHidden = _prevState !== null; + var nextIsHidden = _nextState !== null; if ( prevIsHidden !== nextIsHidden && @@ -16155,14 +15654,6 @@ function completeWork(current, workInProgress, renderLanes) { ) { workInProgress.flags |= Update; } - } // Don't bubble properties for hidden children. - - if ( - !nextIsHidden || - includesSomeLane(subtreeRenderLanes, OffscreenLane) || - (workInProgress.mode & ConcurrentMode) === NoMode - ) { - bubbleProperties(workInProgress); } return null; @@ -16254,17 +15745,12 @@ function unwindWork(workInProgress, renderLanes) { return null; case ContextProvider: - var context = workInProgress.type._context; - popProvider(context, workInProgress); + popProvider(workInProgress); return null; case OffscreenComponent: case LegacyHiddenComponent: popRenderLanes(workInProgress); - - return null; - - case CacheComponent: return null; default: @@ -16272,7 +15758,7 @@ function unwindWork(workInProgress, renderLanes) { } } -function unwindInterruptedWork(interruptedWork, renderLanes) { +function unwindInterruptedWork(interruptedWork) { switch (interruptedWork.tag) { case ClassComponent: { var childContextTypes = interruptedWork.type.childContextTypes; @@ -16309,14 +15795,12 @@ function unwindInterruptedWork(interruptedWork, renderLanes) { break; case ContextProvider: - var context = interruptedWork.type._context; - popProvider(context, interruptedWork); + popProvider(interruptedWork); break; case OffscreenComponent: case LegacyHiddenComponent: popRenderLanes(interruptedWork); - break; } } @@ -16555,7 +16039,9 @@ function throwException( rootRenderLanes ) { // The source fiber did not complete. - sourceFiber.flags |= Incomplete; + sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. + + sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( value !== null && @@ -16564,16 +16050,10 @@ function throwException( ) { // This is a wakeable. var wakeable = value; - // A legacy mode Suspense quirk, only relevant to hook components. - var tag = sourceFiber.tag; - - if ( - (sourceFiber.mode & BlockingMode) === NoMode && - (tag === FunctionComponent || - tag === ForwardRef || - tag === SimpleMemoComponent) - ) { + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. var currentSource = sourceFiber.alternate; if (currentSource) { @@ -16617,16 +16097,8 @@ function throwException( // 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 the suspense boundary suspended itself suspended, we don't have to - // do this trick because nothing was partially started. We can just - // directly do a second pass over the fallback in this render and - // pretend we meant to render that directly. - if ( - (_workInProgress.mode & BlockingMode) === NoMode && - _workInProgress !== returnFiber - ) { + 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 @@ -16780,7 +16252,6 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null; } var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; -var nextEffect = null; var callComponentWillUnmountWithTimer = function(current, instance) { instance.props = current.memoizedProps; @@ -16791,11 +16262,7 @@ var callComponentWillUnmountWithTimer = function(current, instance) { } }; // Capture errors so they don't interrupt unmounting. -function safelyCallComponentWillUnmount( - current, - nearestMountedAncestor, - instance -) { +function safelyCallComponentWillUnmount(current, instance) { { invokeGuardedCallback( null, @@ -16807,12 +16274,12 @@ function safelyCallComponentWillUnmount( if (hasCaughtError()) { var unmountError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, unmountError); + captureCommitPhaseError(current, unmountError); } } } -function safelyDetachRef(current, nearestMountedAncestor) { +function safelyDetachRef(current) { var ref = current.ref; if (ref !== null) { @@ -16824,7 +16291,7 @@ function safelyDetachRef(current, nearestMountedAncestor) { if (hasCaughtError()) { var refError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, refError); + captureCommitPhaseError(current, refError); } } } else { @@ -16833,117 +16300,27 @@ function safelyDetachRef(current, nearestMountedAncestor) { } } -function safelyCallDestroy(current, nearestMountedAncestor, destroy) { +function safelyCallDestroy(current, destroy) { { invokeGuardedCallback(null, destroy, null); if (hasCaughtError()) { var error = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, error); + captureCommitPhaseError(current, error); } } } -var focusedInstanceHandle = null; -var shouldFireAfterActiveInstanceBlur = false; -function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = prepareForCommit(root.containerInfo); - nextEffect = firstChild; - commitBeforeMutationEffects_begin(); // We no longer need to track the active instance fiber - - var shouldFire = shouldFireAfterActiveInstanceBlur; - shouldFireAfterActiveInstanceBlur = false; - focusedInstanceHandle = null; - return shouldFire; -} - -function commitBeforeMutationEffects_begin() { - while (nextEffect !== null) { - var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization - - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var deletion = deletions[i]; - commitBeforeMutationEffectsDeletion(deletion); - } - } - - var child = fiber.child; - - if ( - (fiber.subtreeFlags & BeforeMutationMask) !== NoFlags && - child !== null - ) { - ensureCorrectReturnPointer(child, fiber); - nextEffect = child; - } else { - commitBeforeMutationEffects_complete(); - } - } -} - -function commitBeforeMutationEffects_complete() { - while (nextEffect !== null) { - var fiber = nextEffect; - - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitBeforeMutationEffectsOnFiber, - null, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; +function commitBeforeMutationLifeCycles(current, finishedWork) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { return; } - nextEffect = fiber.return; - } -} - -function commitBeforeMutationEffectsOnFiber(finishedWork) { - var current = finishedWork.alternate; - var flags = finishedWork.flags; - - if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - // Check to see if the focused element was inside of a hidden (Suspense) subtree. - // TODO: Move this out of the hot path using a dedicated effect tag. - if ( - finishedWork.tag === SuspenseComponent && - isSuspenseBoundaryBeingHidden(current, finishedWork) && - doesFiberContain(finishedWork, focusedInstanceHandle) - ) { - shouldFireAfterActiveInstanceBlur = true; - } - } - - if ((flags & Snapshot) !== NoFlags) { - setCurrentFiber(finishedWork); - - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - break; - } - - case ClassComponent: { + case ClassComponent: { + if (finishedWork.flags & Snapshot) { if (current !== null) { var prevProps = current.memoizedProps; var prevState = current.memoizedState; @@ -17003,49 +16380,31 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { instance.__reactInternalSnapshotBeforeUpdate = snapshot; } - - break; } - case HostRoot: { - break; - } - - case HostComponent: - case HostText: - case HostPortal: - case IncompleteClassComponent: - // Nothing to do for these component types - break; - - default: { - { - 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." - ); - } - } + return; } - resetCurrentFiber(); + case HostRoot: { + return; + } + + case HostComponent: + case HostText: + case HostPortal: + case IncompleteClassComponent: + // Nothing to do for these component types + 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 commitBeforeMutationEffectsDeletion(deletion) { - // TODO (effects) It would be nice to avoid calling doesFiberContain() - // Maybe we can repurpose one of the subtreeFlags positions for this instead? - // Use it to store which part of the tree the focused instance is in? - // This assumes we can safely determine that instance during the "render" phase. - if (doesFiberContain(deletion, focusedInstanceHandle)) { - shouldFireAfterActiveInstanceBlur = true; - } -} - -function commitHookEffectListUnmount( - flags, - finishedWork, - nearestMountedAncestor -) { +function commitHookEffectListUnmount(tag, finishedWork) { var updateQueue = finishedWork.updateQueue; var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; @@ -17054,13 +16413,13 @@ function commitHookEffectListUnmount( var effect = firstEffect; do { - if ((effect.tag & flags) === flags) { + if ((effect.tag & tag) === tag) { // Unmount var destroy = effect.destroy; effect.destroy = undefined; if (destroy !== undefined) { - safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy); + destroy(); } } @@ -17125,120 +16484,54 @@ function commitHookEffectListMount(tag, finishedWork) { } } -function commitLayoutEffectOnFiber( - finishedRoot, - current, - finishedWork, - committedLanes -) { - if ((finishedWork.flags & (Update | Callback)) !== NoFlags) { - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - // At this point layout effects have already been destroyed (during mutation phase). - // This is done to prevent 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. - { - commitHookEffectListMount(Layout | 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); } - case ClassComponent: { - var instance = finishedWork.stateNode; + effect = next; + } while (effect !== firstEffect); + } +} - 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. - // TODO: revisit this when we implement resuming. - { - if ( - finishedWork.type === finishedWork.elementType && - !didWarnAboutReassigningProps - ) { - if (instance.props !== finishedWork.memoizedProps) { - error( - "Expected %s props to match memoized props before " + - "componentDidMount. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ); - } +function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + // At this point layout effects have already been destroyed (during mutation phase). + // This is done to prevent 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. + { + commitHookEffectListMount(Layout | HasEffect, finishedWork); + } - if (instance.state !== finishedWork.memoizedState) { - error( - "Expected %s state to match memoized state before " + - "componentDidMount. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.state`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ); - } - } - } + schedulePassiveEffects(finishedWork); + return; + } - { - instance.componentDidMount(); - } - } else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps(finishedWork.type, current.memoizedProps); - 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. + case ClassComponent: { + var instance = finishedWork.stateNode; - { - if ( - finishedWork.type === finishedWork.elementType && - !didWarnAboutReassigningProps - ) { - if (instance.props !== finishedWork.memoizedProps) { - error( - "Expected %s props to match memoized props before " + - "componentDidUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ); - } - - if (instance.state !== finishedWork.memoizedState) { - error( - "Expected %s state to match memoized state before " + - "componentDidUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.state`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ); - } - } - } - - { - instance.componentDidUpdate( - prevProps, - prevState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - } - } // 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) { + 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. + // TODO: revisit this when we implement resuming. { if ( finishedWork.type === finishedWork.elementType && @@ -17247,7 +16540,7 @@ function commitLayoutEffectOnFiber( if (instance.props !== finishedWork.memoizedProps) { error( "Expected %s props to match memoized props before " + - "processing the update queue. " + + "componentDidMount. " + "This might either be because of a bug in React, or because " + "a component reassigns its own `this.props`. " + "Please file an issue.", @@ -17258,7 +16551,7 @@ function commitLayoutEffectOnFiber( if (instance.state !== finishedWork.memoizedState) { error( "Expected %s state to match memoized state before " + - "processing the update queue. " + + "componentDidMount. " + "This might either be because of a bug in React, or because " + "a component reassigns its own `this.state`. " + "Please file an issue.", @@ -17266,117 +16559,194 @@ function commitLayoutEffectOnFiber( ); } } - } // We could update instance props and state here, + } + + { + instance.componentDidMount(); + } + } else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps(finishedWork.type, current.memoizedProps); + 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. - commitUpdateQueue(finishedWork, updateQueue, instance); - } + { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } - break; - } - - 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) { - var _instance = null; - - if (finishedWork.child !== null) { - switch (finishedWork.child.tag) { - case HostComponent: - _instance = getPublicInstance(finishedWork.child.stateNode); - break; - - case ClassComponent: - _instance = finishedWork.child.stateNode; - break; + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.state`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } - commitUpdateQueue(finishedWork, _updateQueue, _instance); + { + instance.componentDidUpdate( + prevProps, + prevState, + instance.__reactInternalSnapshotBeforeUpdate + ); + } } + } // TODO: I think this is now always non-null by the time it reaches the + // commit phase. Consider removing the type check. - break; - } + var updateQueue = finishedWork.updateQueue; - case HostComponent: { - var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted - // (eg DOM renderer may schedule auto-focus for inputs and form controls). - // These effects should only be committed when components are first mounted, - // aka when there is no current/alternate. - - if (current === null && finishedWork.flags & Update) { - var type = finishedWork.type; - var props = finishedWork.memoizedProps; - commitMount(); - } - - break; - } - - case HostText: { - // We have no life-cycles associated with text. - break; - } - - case HostPortal: { - // We have no life-cycles associated with portals. - break; - } - - case Profiler: { + if (updateQueue !== null) { { - var _finishedWork$memoize2 = finishedWork.memoizedProps, - onCommit = _finishedWork$memoize2.onCommit, - onRender = _finishedWork$memoize2.onRender; - var effectDuration = finishedWork.stateNode.effectDuration; - var commitTime = getCommitTime(); - var phase = current === null ? "mount" : "update"; + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } - if (typeof onRender === "function") { - { - onRender( - finishedWork.memoizedProps.id, - phase, - finishedWork.actualDuration, - finishedWork.treeBaseDuration, - finishedWork.actualStartTime, - commitTime, - finishedRoot.memoizedInteractions + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.state`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ); } } + } // 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. + + commitUpdateQueue(finishedWork, updateQueue, instance); + } + + return; + } + + 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) { + var _instance = null; + + if (finishedWork.child !== null) { + switch (finishedWork.child.tag) { + case HostComponent: + _instance = getPublicInstance(finishedWork.child.stateNode); + break; + + case ClassComponent: + _instance = finishedWork.child.stateNode; + break; + } } - break; + commitUpdateQueue(finishedWork, _updateQueue, _instance); } - case SuspenseComponent: { - break; - } - - case SuspenseListComponent: - case IncompleteClassComponent: - case ScopeComponent: - case OffscreenComponent: - case LegacyHiddenComponent: - break; - - default: { - 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." - ); - } + return; } + + case HostComponent: { + var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted + // (eg DOM renderer may schedule auto-focus for inputs and form controls). + // These effects should only be committed when components are first mounted, + // aka when there is no current/alternate. + + if (current === null && finishedWork.flags & Update) { + var type = finishedWork.type; + var props = finishedWork.memoizedProps; + commitMount(); + } + + return; + } + + case HostText: { + // We have no life-cycles associated with text. + return; + } + + case HostPortal: { + // We have no life-cycles associated with portals. + return; + } + + case Profiler: { + { + var _finishedWork$memoize2 = finishedWork.memoizedProps, + onCommit = _finishedWork$memoize2.onCommit, + onRender = _finishedWork$memoize2.onRender; + var effectDuration = finishedWork.stateNode.effectDuration; + var commitTime = getCommitTime(); + + if (typeof onRender === "function") { + { + onRender( + finishedWork.memoizedProps.id, + current === null ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + commitTime, + finishedRoot.memoizedInteractions + ); + } + } + } + + return; + } + + case SuspenseComponent: { + return; + } + + case SuspenseListComponent: + case IncompleteClassComponent: + case FundamentalComponent: + case ScopeComponent: + case OffscreenComponent: + case LegacyHiddenComponent: + return; } { - if (finishedWork.flags & Ref) { - commitAttachRef(finishedWork); - } + 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." + ); } } @@ -17432,12 +16802,7 @@ function commitDetachRef(current) { // deletion, so don't let them throw. Host-originating errors should // interrupt deletion, so it's okay -function commitUnmount( - finishedRoot, - current, - nearestMountedAncestor, - renderPriorityLevel -) { +function commitUnmount(finishedRoot, current, renderPriorityLevel) { onCommitUnmount(current); switch (current.tag) { @@ -17455,14 +16820,16 @@ function commitUnmount( var effect = firstEffect; do { - var _effect = effect, - destroy = _effect.destroy, - tag = _effect.tag; + var _effect2 = effect, + destroy = _effect2.destroy, + tag = _effect2.tag; if (destroy !== undefined) { - if ((tag & Layout) !== NoFlags$1) { + if ((tag & Passive$1) !== NoFlags$1) { + enqueuePendingPassiveHookEffectUnmount(current, effect); + } else { { - safelyCallDestroy(current, nearestMountedAncestor, destroy); + safelyCallDestroy(current, destroy); } } } @@ -17476,22 +16843,18 @@ function commitUnmount( } case ClassComponent: { - safelyDetachRef(current, nearestMountedAncestor); + safelyDetachRef(current); var instance = current.stateNode; if (typeof instance.componentWillUnmount === "function") { - safelyCallComponentWillUnmount( - current, - nearestMountedAncestor, - instance - ); + safelyCallComponentWillUnmount(current, instance); } return; } case HostComponent: { - safelyDetachRef(current, nearestMountedAncestor); + safelyDetachRef(current); return; } @@ -17506,6 +16869,10 @@ function commitUnmount( return; } + case FundamentalComponent: { + return; + } + case DehydratedFragment: { return; } @@ -17516,12 +16883,7 @@ function commitUnmount( } } -function commitNestedUnmounts( - finishedRoot, - root, - nearestMountedAncestor, - renderPriorityLevel -) { +function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { // While we're inside a removed host node we don't want to call // removeChild on the inner nodes because they're removed by the top // call anyway. We also want to call componentWillUnmount on all @@ -17530,7 +16892,7 @@ function commitNestedUnmounts( var node = root; while (true) { - commitUnmount(finishedRoot, node, nearestMountedAncestor); // 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 ( @@ -17561,37 +16923,28 @@ function commitNestedUnmounts( } function detachFiberMutation(fiber) { - // Cut off the return pointer to disconnect it from the tree. - // This enables us to detect and warn against state updates on an unmounted component. - // It also prevents events from bubbling from within disconnected components. - // - // Ideally, we should also clear the child pointer of the parent alternate to let this + // 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. + // 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. // - // Note that we can't clear child or sibling pointers yet. - // They're needed for passive effects and for findDOMNode. - // We defer those fields, and all other cleanup, to the passive phase (see detachFiberAfterEffects). - // - // Don't reset the alternate yet, either. We need that so we can detach the - // alternate's fields in the passive phase. Clearing the return pointer is - // sufficient for findDOMNode semantics. - fiber.return = null; -} - -function detachFiberAfterEffects(fiber) { - // Null out fields to improve GC for references that may be lingering (e.g. DevTools). - // Note that we already cleared the return pointer in detachFiberMutation(). + // 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.deletions = null; fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; + fiber.return = null; fiber.updateQueue = null; { @@ -17609,7 +16962,8 @@ function commitContainer(finishedWork) { switch (finishedWork.tag) { case ClassComponent: case HostComponent: - case HostText: { + case HostText: + case FundamentalComponent: { return; } @@ -17629,15 +16983,10 @@ function commitContainer(finishedWork) { } } -function commitDeletion( - finishedRoot, - current, - nearestMountedAncestor, - renderPriorityLevel -) { +function commitDeletion(finishedRoot, current, renderPriorityLevel) { { // Detach refs and call componentWillUnmount() on the whole subtree. - commitNestedUnmounts(finishedRoot, current, nearestMountedAncestor); + commitNestedUnmounts(finishedRoot, current); } var alternate = current.alternate; @@ -17661,11 +17010,7 @@ function commitWork(current, finishedWork) { // 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, - finishedWork.return - ); + commitHookEffectListUnmount(Layout | HasEffect, finishedWork); } return; @@ -17756,454 +17101,6 @@ function isSuspenseBoundaryBeingHidden(current, finishedWork) { return false; } -function commitMutationEffects(root, renderPriorityLevel, firstChild) { - nextEffect = firstChild; - commitMutationEffects_begin(root, renderPriorityLevel); -} - -function commitMutationEffects_begin(root, renderPriorityLevel) { - while (nextEffect !== null) { - var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization - - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var childToDelete = deletions[i]; - - { - invokeGuardedCallback( - null, - commitDeletion, - null, - root, - childToDelete, - fiber, - renderPriorityLevel - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(childToDelete, fiber, error); - } - } - } - } - - var child = fiber.child; - - if ((fiber.subtreeFlags & MutationMask) !== NoFlags && child !== null) { - ensureCorrectReturnPointer(child, fiber); - nextEffect = child; - } else { - commitMutationEffects_complete(root, renderPriorityLevel); - } - } -} - -function commitMutationEffects_complete(root, renderPriorityLevel) { - while (nextEffect !== null) { - var fiber = nextEffect; - - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitMutationEffectsOnFiber, - null, - fiber, - root, - renderPriorityLevel - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitMutationEffectsOnFiber(finishedWork, root, renderPriorityLevel) { - var flags = finishedWork.flags; - - if (flags & Ref) { - var current = finishedWork.alternate; - - 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 primaryFlags = flags & (Placement | Update | Hydrating); - - 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. - - finishedWork.flags &= ~Placement; - break; - } - - case PlacementAndUpdate: { - // inserted, before any life-cycles like componentDidMount gets called. - - finishedWork.flags &= ~Placement; // Update - - var _current = finishedWork.alternate; - commitWork(_current, finishedWork); - break; - } - - case Hydrating: { - finishedWork.flags &= ~Hydrating; - break; - } - - case HydratingAndUpdate: { - finishedWork.flags &= ~Hydrating; // Update - - var _current2 = finishedWork.alternate; - commitWork(_current2, finishedWork); - break; - } - - case Update: { - var _current3 = finishedWork.alternate; - commitWork(_current3, finishedWork); - break; - } - } -} - -function commitLayoutEffects(finishedWork, root, committedLanes) { - nextEffect = finishedWork; - commitLayoutEffects_begin(finishedWork, root, committedLanes); -} - -function commitLayoutEffects_begin(subtreeRoot, root, committedLanes) { - while (nextEffect !== null) { - var fiber = nextEffect; - var firstChild = fiber.child; - - if ((fiber.subtreeFlags & LayoutMask) !== NoFlags && firstChild !== null) { - ensureCorrectReturnPointer(firstChild, fiber); - nextEffect = firstChild; - } else { - commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes); - } - } -} - -function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) { - while (nextEffect !== null) { - var fiber = nextEffect; - - if ((fiber.flags & LayoutMask) !== NoFlags) { - var current = fiber.alternate; - - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitLayoutEffectOnFiber, - null, - root, - current, - fiber, - committedLanes - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); - } - } - - if (fiber === subtreeRoot) { - nextEffect = null; - return; - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitPassiveMountEffects(root, finishedWork) { - nextEffect = finishedWork; - commitPassiveMountEffects_begin(finishedWork, root); -} - -function commitPassiveMountEffects_begin(subtreeRoot, root) { - while (nextEffect !== null) { - var fiber = nextEffect; - var firstChild = fiber.child; - - if ((fiber.subtreeFlags & PassiveMask) !== NoFlags && firstChild !== null) { - ensureCorrectReturnPointer(firstChild, fiber); - nextEffect = firstChild; - } else { - commitPassiveMountEffects_complete(subtreeRoot, root); - } - } -} - -function commitPassiveMountEffects_complete(subtreeRoot, root) { - while (nextEffect !== null) { - var fiber = nextEffect; - - if ((fiber.flags & Passive) !== NoFlags) { - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitPassiveMountOnFiber, - null, - root, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); - } - } - - if (fiber === subtreeRoot) { - nextEffect = null; - return; - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitPassiveMountOnFiber(finishedRoot, finishedWork) { - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - { - commitHookEffectListMount(Passive$1 | HasEffect, finishedWork); - } - - break; - } - } -} - -function commitPassiveUnmountEffects(firstChild) { - nextEffect = firstChild; - commitPassiveUnmountEffects_begin(); -} - -function commitPassiveUnmountEffects_begin() { - while (nextEffect !== null) { - var fiber = nextEffect; - var child = fiber.child; - - if ((nextEffect.flags & ChildDeletion) !== NoFlags) { - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var fiberToDelete = deletions[i]; - nextEffect = fiberToDelete; - commitPassiveUnmountEffectsInsideOfDeletedTree_begin( - fiberToDelete, - fiber - ); // Now that passive effects have been processed, it's safe to detach lingering pointers. - - var alternate = fiberToDelete.alternate; - detachFiberAfterEffects(fiberToDelete); - - if (alternate !== null) { - detachFiberAfterEffects(alternate); - } - } - - nextEffect = fiber; - } - } - - if ((fiber.subtreeFlags & PassiveMask) !== NoFlags && child !== null) { - ensureCorrectReturnPointer(child, fiber); - nextEffect = child; - } else { - commitPassiveUnmountEffects_complete(); - } - } -} - -function commitPassiveUnmountEffects_complete() { - while (nextEffect !== null) { - var fiber = nextEffect; - - if ((fiber.flags & Passive) !== NoFlags) { - setCurrentFiber(fiber); - commitPassiveUnmountOnFiber(fiber); - resetCurrentFiber(); - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitPassiveUnmountOnFiber(finishedWork) { - { - finishedWork.flags &= ~PassiveUnmountPendingDev; - var alternate = finishedWork.alternate; - - if (alternate !== null) { - alternate.flags &= ~PassiveUnmountPendingDev; - } - } - - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - { - commitHookEffectListUnmount( - Passive$1 | HasEffect, - finishedWork, - finishedWork.return - ); - } - - break; - } - } -} - -function commitPassiveUnmountEffectsInsideOfDeletedTree_begin( - deletedSubtreeRoot, - nearestMountedAncestor -) { - while (nextEffect !== null) { - var fiber = nextEffect; // Deletion effects fire in parent -> child order - // TODO: Check if fiber has a PassiveStatic flag - - setCurrentFiber(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentFiber(); - var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag - - if (child !== null) { - ensureCorrectReturnPointer(child, fiber); - nextEffect = child; - } else { - commitPassiveUnmountEffectsInsideOfDeletedTree_complete( - deletedSubtreeRoot - ); - } - } -} - -function commitPassiveUnmountEffectsInsideOfDeletedTree_complete( - deletedSubtreeRoot -) { - while (nextEffect !== null) { - var fiber = nextEffect; - - if (fiber === deletedSubtreeRoot) { - nextEffect = null; - return; - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitPassiveUnmountInsideDeletedTreeOnFiber( - current, - nearestMountedAncestor -) { - switch (current.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - { - commitHookEffectListUnmount(Passive$1, current, nearestMountedAncestor); - } - - break; - } - } -} - -var didWarnWrongReturnPointer = false; - -function ensureCorrectReturnPointer(fiber, expectedReturnFiber) { - { - if (!didWarnWrongReturnPointer && fiber.return !== expectedReturnFiber) { - didWarnWrongReturnPointer = true; - - error( - "Internal React error: Return pointer is inconsistent " + "with parent." - ); - } - } // TODO: Remove this assignment once we're confident that it won't break - // anything, by checking the warning logs for the above invariant - - fiber.return = expectedReturnFiber; -} - var COMPONENT_TYPE = 0; var HAS_PSEUDO_CLASS_TYPE = 1; var ROLE_TYPE = 2; @@ -18283,7 +17180,8 @@ var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. -var workInProgressRootPingedLanes = NoLanes; // The most recent time we committed a fallback. This lets us ensure a train +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; @@ -18302,13 +17200,16 @@ function resetRenderTimer() { function getRenderTargetTime() { return workInProgressRootRenderTargetTime; } +var nextEffect = null; var hasUncaughtError = false; var firstUncaughtError = null; -var legacyErrorBoundariesThatAlreadyFailed = null; // Only used when enableProfilerNestedUpdateScheduledHook is true; +var legacyErrorBoundariesThatAlreadyFailed = null; var rootDoesHavePassiveEffects = false; var rootWithPendingPassiveEffects = null; -var pendingPassiveEffectsRenderPriority = NoPriority; +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; @@ -18326,10 +17227,13 @@ var spawnedWorkDuringRender = null; // If two updates are scheduled within the s // between the first and second call. var currentEventTime = NoTimestamp; -var currentEventTransitionLane = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed. +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; } @@ -18354,41 +17258,63 @@ function requestUpdateLane(fiber) { if ((mode & BlockingMode) === NoMode) { return SyncLane; } else if ((mode & ConcurrentMode) === NoMode) { - return getCurrentPriorityLevel() === ImmediatePriority + 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 (currentEventTransitionLane === NoLane) { - currentEventTransitionLane = claimNextTransitionLane(); + if (currentEventPendingLanes !== NoLanes) { + currentEventPendingLanes = + mostRecentlyUpdatedRoot !== null + ? mostRecentlyUpdatedRoot.pendingLanes + : NoLanes; } - return currentEventTransitionLane; + 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(); // Find the correct lane based on priorities. Ideally, this would just be - // the update lane priority, but for now we're also checking for discrete - // updates and falling back to the scheduler 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 + schedulerPriority === UserBlockingPriority$1 ) { - lane = findUpdateLane(InputDiscreteLanePriority); + lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes); } else { - { - var schedulerLanePriority = schedulerPriorityToLanePriority( - schedulerPriority - ); - lane = findUpdateLane(schedulerLanePriority); - } + var schedulerLanePriority = schedulerPriorityToLanePriority( + schedulerPriority + ); + + lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes); } return lane; @@ -18404,12 +17330,16 @@ function requestRetryLane(fiber) { if ((mode & BlockingMode) === NoMode) { return SyncLane; } else if ((mode & ConcurrentMode) === NoMode) { - return getCurrentPriorityLevel() === ImmediatePriority + return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane; } // See `requestUpdateLane` for explanation of `currentEventWipLanes` - return claimNextRetryLane(); + if (currentEventWipLanes === NoLanes) { + currentEventWipLanes = workInProgressRootIncludedLanes; + } + + return findRetryLane(currentEventWipLanes); } function scheduleUpdateOnFiber(fiber, lane, eventTime) { @@ -18482,8 +17412,8 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { if ( (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered // discrete, even inside a discrete event. - (priorityLevel === UserBlockingPriority || - priorityLevel === ImmediatePriority) + (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. @@ -18496,9 +17426,13 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { 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. - return root; + 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 @@ -18520,7 +17454,7 @@ function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { ) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } - } // Walk the parent path to the root and update the child lanes. + } // Walk the parent path to the root and update the child expiration time. var node = sourceFiber; var parent = sourceFiber.return; @@ -18549,20 +17483,6 @@ function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { } else { return null; } -} - -function isInterleavedUpdate(fiber, lane) { - return ( - // TODO: Optimize slightly by comparing to root that fiber belongs to. - // Requires some refactoring. Not a big deal though since it's rare for - // concurrent apps to have more than a single root. - workInProgressRoot !== null && - (fiber.mode & BlockingMode) !== NoMode && // If this is a render phase update (i.e. UNSAFE_componentWillReceiveProps), - // then don't treat this as an interleaved update. This pattern is - // accompanied by a warning but we haven't fully deprecated it yet. We can - // remove once the deferRenderPhaseUpdateToNextBatch flag is enabled. - deferRenderPhaseUpdateToNextBatch - ); } // 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 @@ -18586,36 +17506,22 @@ function ensureRootIsScheduled(root, currentTime) { // Special case: There's nothing to work on. if (existingCallbackNode !== null) { cancelCallback(existingCallbackNode); + root.callbackNode = null; + root.callbackPriority = NoLanePriority; } - root.callbackNode = null; - root.callbackPriority = NoLanePriority; return; } // Check if there's an existing task. We may be able to reuse it. - var existingCallbackPriority = root.callbackPriority; + if (existingCallbackNode !== null) { + var existingCallbackPriority = root.callbackPriority; - if (existingCallbackPriority === newCallbackPriority) { - { - // If we're going to re-use an existing task, it needs to exist. - // Assume that discrete update microtasks are non-cancellable and null. - // TODO: Temporary until we confirm this warning is not fired. - if ( - existingCallbackNode == null && - existingCallbackPriority !== InputDiscreteLanePriority && - existingCallbackPriority !== SyncLanePriority - ) { - error( - "Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue." - ); - } - } // The priority hasn't changed. We can reuse the existing task. Exit. + 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. - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. cancelCallback(existingCallbackNode); } // Schedule a new callback. @@ -18624,11 +17530,12 @@ function ensureRootIsScheduled(root, currentTime) { if (newCallbackPriority === SyncLanePriority) { // Special case: Sync React callbacks are scheduled on a special // internal queue - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - newCallbackNode = null; + newCallbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + ); } else if (newCallbackPriority === SyncBatchedLanePriority) { newCallbackNode = scheduleCallback( - ImmediatePriority, + ImmediatePriority$1, performSyncWorkOnRoot.bind(null, root) ); } else { @@ -18646,11 +17553,12 @@ 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; - currentEventTransitionLane = NoLanes; + currentEventWipLanes = NoLanes; + currentEventPendingLanes = NoLanes; if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { throw Error("Should not already be working."); @@ -18680,22 +17588,24 @@ 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 we're still investigating. 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); - if (exitStatus !== RootIncomplete) { + 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. @@ -18887,9 +17797,26 @@ function performSyncWorkOnRoot(root) { // rendering it before rendering the rest of the expired work. lanes = workInProgressRootRenderLanes; exitStatus = renderRootSync(root, lanes); - } else { - lanes = getNextLanes(root, NoLanes); // Because we don't cancel synchronous tasks, sometimes more than one + 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); } @@ -18967,7 +17894,7 @@ function flushSync(fn, a) { { try { if (fn) { - return runWithPriority(ImmediatePriority, fn.bind(null, a)); + return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); } else { return undefined; } @@ -19023,7 +17950,6 @@ function prepareFreshStack(root, lanes) { workInProgressRootSkippedLanes = NoLanes; workInProgressRootUpdatedLanes = NoLanes; workInProgressRootPingedLanes = NoLanes; - enqueueInterleavedUpdates(); { spawnedWorkDuringRender = null; @@ -19347,6 +18273,47 @@ function completeUnitOfWork(unitOfWork) { workInProgress = next; return; } + + resetChildLanes(completedWork); + + 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 (completedWork.lastEffect !== null) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = completedWork.firstEffect; + } + + 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 (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, @@ -19379,10 +18346,9 @@ function completeUnitOfWork(unitOfWork) { } if (returnFiber !== null) { - // Mark the parent fiber as incomplete and clear its subtree flags. + // Mark the parent fiber as incomplete and clear its effect list. + returnFiber.firstEffect = returnFiber.lastEffect = null; returnFiber.flags |= Incomplete; - returnFiber.subtreeFlags = NoFlags; - returnFiber.deletions = null; } } @@ -19404,10 +18370,88 @@ function completeUnitOfWork(unitOfWork) { } } +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; + } + + var newChildLanes = NoLanes; // Bubble up the earliest expiration time. + + 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 shouldBubbleActualDurations = + completedWork.alternate === null || + completedWork.child !== completedWork.alternate.child; + var child = completedWork.child; + + while (child !== null) { + newChildLanes = mergeLanes( + newChildLanes, + mergeLanes(child.lanes, child.childLanes) + ); + + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } + + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + + var isTimedOutSuspense = + completedWork.tag === SuspenseComponent && + completedWork.memoizedState !== null; + + 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 { + var _child = completedWork.child; + + while (_child !== null) { + newChildLanes = mergeLanes( + newChildLanes, + mergeLanes(_child.lanes, _child.childLanes) + ); + _child = _child.sibling; + } + } + + completedWork.childLanes = newChildLanes; +} + function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority( - ImmediatePriority, + ImmediatePriority$1, commitRootImpl.bind(null, root, renderPriorityLevel) ); return null; @@ -19447,8 +18491,7 @@ function commitRootImpl(root, renderPriorityLevel) { } // commitRoot never returns a continuation; it always finishes synchronously. // So we can clear these now to allow a new callback to be scheduled. - root.callbackNode = null; - root.callbackPriority = NoLanePriority; // Update the first and last pending times on this root. The new first + 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. var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes); @@ -19470,39 +18513,27 @@ function commitRootImpl(root, renderPriorityLevel) { workInProgressRoot = null; workInProgress = null; workInProgressRootRenderLanes = NoLanes; - } // If there are pending passive effects, schedule a callback to process them. - // Do this as early as possible, so it is queued before anything else that - // might get scheduled in the commit phase. (See #16714.) - // TODO: Delete all other places that schedule the passive effect callback - // They're redundant. + } // Get the list of effects. - if ( - (finishedWork.subtreeFlags & PassiveMask) !== NoFlags || - (finishedWork.flags & PassiveMask) !== NoFlags - ) { - if (!rootDoesHavePassiveEffects) { - rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority, function() { - flushPassiveEffects(); - return null; - }); + 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; } - } // Check if there are any effects in the whole tree. - // TODO: This is left over from the effect list implementation, where we had - // to check for the existence of `firstEffect` to satsify Flow. I think the - // only other reason this optimization exists is because it affects profiling. - // Reconsider whether this is necessary. + } else { + // There is no effect on the root. + firstEffect = finishedWork.firstEffect; + } - var subtreeHasEffects = - (finishedWork.subtreeFlags & - (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== - NoFlags; - var rootHasEffect = - (finishedWork.flags & - (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== - NoFlags; - - if (subtreeHasEffects || rootHasEffect) { + if (firstEffect !== null) { var prevExecutionContext = executionContext; executionContext |= CommitContext; var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles @@ -19514,18 +18545,58 @@ function commitRootImpl(root, renderPriorityLevel) { // state of the host tree right before we mutate it. This is where // getSnapshotBeforeUpdate is called. - var shouldFireAfterActiveInstanceBlur = commitBeforeMutationEffects( - root, - finishedWork - ); + focusedInstanceHandle = prepareForCommit(root.containerInfo); + shouldFireAfterActiveInstanceBlur = false; + nextEffect = firstEffect; + + do { + { + invokeGuardedCallback(null, commitBeforeMutationEffects, null); + + 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 + + focusedInstanceHandle = null; { // 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. - commitMutationEffects(root, renderPriorityLevel, finishedWork); + nextEffect = firstEffect; + + do { + { + invokeGuardedCallback( + null, + commitMutationEffects, + null, + root, + renderPriorityLevel + ); + + 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); 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 @@ -19533,8 +18604,29 @@ function commitRootImpl(root, renderPriorityLevel) { // work is current during componentDidMount/Update. 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. - commitLayoutEffects(finishedWork, root, lanes); + nextEffect = firstEffect; + + do { + { + invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes); + + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + throw Error("Should be working on an effect."); + } + + var _error2 = clearCaughtError(); + + captureCommitPhaseError(nextEffect, _error2); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + + nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an // opportunity to paint. requestPaint(); @@ -19564,6 +18656,22 @@ function commitRootImpl(root, renderPriorityLevel) { 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; + + while (nextEffect !== null) { + var nextNextEffect = nextEffect.nextEffect; + nextEffect.nextEffect = null; + + if (nextEffect.flags & Deletion) { + detachFiberAfterEffects(nextEffect); + } + + nextEffect = nextNextEffect; + } } // Read this again, since an effect might have updated it remainingLanes = root.pendingLanes; // Check if there's remaining work on this root @@ -19601,9 +18709,9 @@ function commitRootImpl(root, renderPriorityLevel) { } } - if (includesSomeLane(remainingLanes, SyncLane)) { + 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 { @@ -19621,9 +18729,9 @@ function commitRootImpl(root, renderPriorityLevel) { if (hasUncaughtError) { hasUncaughtError = false; - var error = firstUncaughtError; + var _error3 = firstUncaughtError; firstUncaughtError = null; - throw error; + throw _error3; } if ((executionContext & LegacyUnbatchedContext) !== NoContext) { @@ -19639,14 +18747,149 @@ function commitRootImpl(root, renderPriorityLevel) { return null; } +function commitBeforeMutationEffects() { + while (nextEffect !== null) { + var current = nextEffect.alternate; + + 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; + } + } + } + + var flags = nextEffect.flags; + + if ((flags & Snapshot) !== NoFlags) { + setCurrentFiber(nextEffect); + commitBeforeMutationLifeCycles(current, nextEffect); + resetCurrentFiber(); + } + + 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; + }); + } + } + + nextEffect = nextEffect.nextEffect; + } +} + +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 (flags & Ref) { + var current = nextEffect.alternate; + + 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 primaryFlags = flags & (Placement | Update | Deletion | Hydrating); + + 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.flags &= ~Placement; + break; + } + + case PlacementAndUpdate: { + // inserted, before any life-cycles like componentDidMount gets called. + + nextEffect.flags &= ~Placement; // Update + + var _current = nextEffect.alternate; + commitWork(_current, nextEffect); + break; + } + + case Hydrating: { + nextEffect.flags &= ~Hydrating; + break; + } + + case HydratingAndUpdate: { + nextEffect.flags &= ~Hydrating; // Update + + var _current2 = nextEffect.alternate; + commitWork(_current2, nextEffect); + break; + } + + case Update: { + var _current3 = nextEffect.alternate; + commitWork(_current3, nextEffect); + break; + } + + case Deletion: { + commitDeletion(root, nextEffect); + break; + } + } + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} + +function commitLayoutEffects(root, committedLanes) { + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + var flags = nextEffect.flags; + + if (flags & (Update | Callback)) { + var current = nextEffect.alternate; + commitLifeCycles(root, current, nextEffect); + } + + { + if (flags & Ref) { + commitAttachRef(nextEffect); + } + } + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} + function flushPassiveEffects() { // Returns whether passive effects were flushed. - if (pendingPassiveEffectsRenderPriority !== NoPriority) { + if (pendingPassiveEffectsRenderPriority !== NoPriority$1) { var priorityLevel = - pendingPassiveEffectsRenderPriority > NormalPriority - ? NormalPriority + pendingPassiveEffectsRenderPriority > NormalPriority$1 + ? NormalPriority$1 : pendingPassiveEffectsRenderPriority; - pendingPassiveEffectsRenderPriority = NoPriority; + pendingPassiveEffectsRenderPriority = NoPriority$1; { return runWithPriority(priorityLevel, flushPassiveEffectsImpl); @@ -19655,6 +18898,42 @@ function flushPassiveEffects() { return false; } +function enqueuePendingPassiveHookEffectMount(fiber, effect) { + pendingPassiveHookEffectsMount.push(effect, fiber); + + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); + } +} +function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { + pendingPassiveHookEffectsUnmount.push(effect, fiber); + + { + fiber.flags |= PassiveUnmountPendingDev; + var alternate = fiber.alternate; + + if (alternate !== null) { + alternate.flags |= PassiveUnmountPendingDev; + } + } + + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); + } +} + +function invokePassiveEffectCreate(effect) { + var create = effect.create; + effect.destroy = create(); +} function flushPassiveEffectsImpl() { if (rootWithPendingPassiveEffects === null) { @@ -19676,9 +18955,97 @@ function flushPassiveEffectsImpl() { var prevExecutionContext = executionContext; executionContext |= CommitContext; - var prevInteractions = pushInteractions(root); - commitPassiveUnmountEffects(root.current); - commitPassiveMountEffects(root, root.current); // TODO: Move to commitPassiveMountEffects + 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; + + { + fiber.flags &= ~PassiveUnmountPendingDev; + var alternate = fiber.alternate; + + if (alternate !== null) { + alternate.flags &= ~PassiveUnmountPendingDev; + } + } + + if (typeof destroy === "function") { + { + setCurrentFiber(fiber); + + { + invokeGuardedCallback(null, destroy, null); + } + + if (hasCaughtError()) { + if (!(fiber !== null)) { + throw Error("Should be working on an effect."); + } + + var error = clearCaughtError(); + captureCommitPhaseError(fiber, error); + } + + resetCurrentFiber(); + } + } + } // Second pass: Create new passive effects. + + var mountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + + for (var _i = 0; _i < mountEffects.length; _i += 2) { + var _effect2 = mountEffects[_i]; + var _fiber = mountEffects[_i + 1]; + + { + setCurrentFiber(_fiber); + + { + invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2); + } + + if (hasCaughtError()) { + if (!(_fiber !== null)) { + throw Error("Should be working on an effect."); + } + + var _error4 = clearCaughtError(); + + captureCommitPhaseError(_fiber, _error4); + } + + 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. + + var effect = root.current.firstEffect; + + while (effect !== null) { + var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC + + effect.nextEffect = null; + + if (effect.flags & Deletion) { + detachFiberAfterEffects(effect); + } + + effect = nextNextEffect; + } { popInteractions(prevInteractions); @@ -19735,23 +19102,19 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { } } -function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { +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$1); + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); return; } - var fiber = null; - - { - fiber = sourceFiber.return; - } + var fiber = sourceFiber.return; while (fiber !== null) { if (fiber.tag === HostRoot) { - captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error$1); + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); return; } else if (fiber.tag === ClassComponent) { var ctor = fiber.type; @@ -19762,7 +19125,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { (typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) ) { - var errorInfo = createCapturedValue(error$1, sourceFiber); + var errorInfo = createCapturedValue(error, sourceFiber); var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); enqueueUpdate(fiber, update); var eventTime = requestEventTime(); @@ -19772,6 +19135,24 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { 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; @@ -19780,22 +19161,6 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { fiber = fiber.return; } - - { - // TODO: Until we re-land skipUnmountedBoundaries (see #20147), this warning - // will fire for errors that are thrown by destroy functions inside deleted - // trees. What it should instead do is propagate the error to the parent of - // the deleted tree. In the meantime, do not add this warning to the - // allowlist; this is only for our internal use. - error( - "Internal React error: Attempted to capture a commit phase error " + - "inside a detached tree. This indicates a bug in React. Likely " + - "causes include deleting the same fiber more than once, committing an " + - "already-finished tree, or an inconsistent return pointer.\n\n" + - "Error message:\n\n%s", - error$1 - ); - } } function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; @@ -19848,8 +19213,6 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { // 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) { - // TODO: Assign this to `suspenseState.retryLane`? to avoid - // unnecessary entanglement? retryLane = requestRetryLane(boundaryFiber); } // TODO: Special case idle priority? @@ -20018,29 +19381,11 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { ) { // 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 & PassiveStatic) !== NoFlags) { - var updateQueue = fiber.updateQueue; - - if (updateQueue !== null) { - var lastEffect = updateQueue.lastEffect; - - if (lastEffect !== null) { - var firstEffect = lastEffect.next; - var effect = firstEffect; - - do { - if (effect.destroy !== undefined) { - if ((effect.tag & Passive$1) !== NoFlags$1) { - return; - } - } - - effect = effect.next; - } while (effect !== firstEffect); - } - } + 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. @@ -20128,23 +19473,14 @@ var beginWork$1; invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes); if (hasCaughtError()) { - var replayError = clearCaughtError(); + var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. + // Rethrow this error instead of the original one. - if ( - typeof replayError === "object" && - replayError !== null && - replayError._suppressLogging && - typeof originalError === "object" && - originalError !== null && - !originalError._suppressLogging - ) { - // If suppressed, let the flag carry over to the original error which is the one we'll rethrow. - originalError._suppressLogging = true; - } - } // We always throw the original error in case the second render pass is not idempotent. - // This can happen if a memoized function or CommonJS module doesn't throw after first invokation. - - throw originalError; + throw replayError; + } else { + // This branch is reachable if the render phase is impure. + throw originalError; + } } }; } @@ -20330,7 +19666,7 @@ function startWorkOnPendingInteractions(root, lanes) { subscriber.onWorkStarted(interactions, threadID); } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { + scheduleCallback(ImmediatePriority$1, function() { throw error; }); } @@ -20352,7 +19688,7 @@ function finishPendingInteractions(root, committedLanes) { } } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { + scheduleCallback(ImmediatePriority$1, function() { throw error; }); } finally { @@ -20374,7 +19710,7 @@ function finishPendingInteractions(root, committedLanes) { subscriber.onInteractionScheduledWorkCompleted(interaction); } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { + scheduleCallback(ImmediatePriority$1, function() { throw error; }); } @@ -20393,6 +19729,11 @@ function shouldForceFlushFallbacksInDEV() { var actingUpdatesScopeDepth = 0; +function detachFiberAfterEffects(fiber) { + fiber.sibling = null; + fiber.stateNode = null; +} + var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. var failedBoundaries = null; @@ -20869,8 +20210,9 @@ function FiberNode(tag, pendingProps, key, mode) { this.mode = mode; // Effects this.flags = NoFlags; - this.subtreeFlags = NoFlags; - this.deletions = null; + this.nextEffect = null; + this.firstEffect = null; + this.lastEffect = null; this.lanes = NoLanes; this.childLanes = NoLanes; this.alternate = null; @@ -20997,10 +20339,11 @@ function createWorkInProgress(current, pendingProps) { workInProgress.type = current.type; // We already have an alternate. // Reset the effect tag. - workInProgress.flags = NoFlags; // The effects are no longer valid. + workInProgress.flags = NoFlags; // The effect list is no longer valid. - workInProgress.subtreeFlags = NoFlags; - workInProgress.deletions = null; + workInProgress.nextEffect = null; + workInProgress.firstEffect = null; + workInProgress.lastEffect = null; { // We intentionally reset, rather than copy, actualDuration & actualStartTime. @@ -21010,10 +20353,8 @@ function createWorkInProgress(current, pendingProps) { workInProgress.actualDuration = 0; workInProgress.actualStartTime = -1; } - } // Reset all effects except static ones. - // Static effects are not specific to a render. + } - workInProgress.flags = current.flags & StaticMask; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -21070,10 +20411,13 @@ function resetWorkInProgress(workInProgress, renderLanes) { // when they should be reading from current and writing to workInProgress. // We assume pendingProps, index, key, ref, return are still untouched to // avoid doing another reconciliation. - // Reset the effect flags but keep any Placement tags, since that's something + // Reset the effect tag but keep any Placement tags, since that's something // that child fiber is setting, not the reconciliation. - workInProgress.flags &= StaticMask | Placement; // The effects are no longer valid. + workInProgress.flags &= Placement; // The effect list is no longer valid. + workInProgress.nextEffect = null; + workInProgress.firstEffect = null; + workInProgress.lastEffect = null; var current = workInProgress.alternate; if (current === null) { @@ -21081,7 +20425,6 @@ function resetWorkInProgress(workInProgress, renderLanes) { workInProgress.childLanes = NoLanes; workInProgress.lanes = renderLanes; workInProgress.child = null; - workInProgress.subtreeFlags = NoFlags; workInProgress.memoizedProps = null; workInProgress.memoizedState = null; workInProgress.updateQueue = null; @@ -21098,12 +20441,7 @@ function resetWorkInProgress(workInProgress, renderLanes) { // Reset to the cloned values that createWorkInProgress would've. workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; - workInProgress.child = current.child; // TODO: `subtreeFlags` should be reset to NoFlags, like we do in - // `createWorkInProgress`. Nothing reads this until the complete phase, - // currently, but it might in the future, and we should be consistent. - - workInProgress.subtreeFlags = current.subtreeFlags; - workInProgress.deletions = null; + workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type. @@ -21130,33 +20468,13 @@ function resetWorkInProgress(workInProgress, renderLanes) { return workInProgress; } -function createHostRootFiber(tag, strictModeLevelOverride) { +function createHostRootFiber(tag) { var mode; if (tag === ConcurrentRoot) { - mode = ConcurrentMode | BlockingMode; - - if (strictModeLevelOverride !== null) { - if (strictModeLevelOverride >= 1) { - mode |= StrictLegacyMode; - } - } else { - { - mode |= StrictLegacyMode; - } - } + mode = ConcurrentMode | BlockingMode | StrictMode; } else if (tag === BlockingRoot) { - mode = BlockingMode; - - if (strictModeLevelOverride !== null) { - if (strictModeLevelOverride >= 1) { - mode |= StrictLegacyMode; - } - } else { - { - mode |= StrictLegacyMode; - } - } + mode = BlockingMode | StrictMode; } else { mode = NoMode; } @@ -21207,16 +20525,8 @@ function createFiberFromTypeAndProps( break; case REACT_STRICT_MODE_TYPE: - fiberTag = Mode; // Legacy strict mode ( without any level prop) defaults to level 1. - - var level = - pendingProps.unstable_level == null ? 1 : pendingProps.unstable_level; // Levels cascade; higher levels inherit all lower level modes. - // It is explicitly not supported to lower a mode with nesting, only to increase it. - - if (level >= 1) { - mode |= StrictLegacyMode; - } - + fiberTag = Mode; + mode |= StrictMode; break; case REACT_PROFILER_TYPE: @@ -21238,10 +20548,6 @@ function createFiberFromTypeAndProps( // eslint-disable-next-line no-fallthrough - case REACT_CACHE_TYPE: - - // eslint-disable-next-line no-fallthrough - default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -21470,8 +20776,9 @@ function assignFiberPropertiesInDEV(target, source) { target.dependencies = source.dependencies; target.mode = source.mode; target.flags = source.flags; - target.subtreeFlags = source.subtreeFlags; - target.deletions = source.deletions; + target.nextEffect = source.nextEffect; + target.firstEffect = source.firstEffect; + target.lastEffect = source.lastEffect; target.lanes = source.lanes; target.childLanes = source.childLanes; target.alternate = source.alternate; @@ -21538,27 +20845,13 @@ function FiberRootNode(containerInfo, tag, hydrate) { } } -function createFiberRoot( - containerInfo, - tag, - hydrate, - hydrationCallbacks, - strictModeLevelOverride -) { +function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { var root = new FiberRootNode(containerInfo, tag, hydrate); // stateNode is any. - var uninitializedFiber = createHostRootFiber(tag, strictModeLevelOverride); + var uninitializedFiber = createHostRootFiber(tag); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; - - { - var _initialState = { - element: null - }; - uninitializedFiber.memoizedState = _initialState; - } - initializeUpdateQueue(uninitializedFiber); return root; } @@ -21632,7 +20925,7 @@ function findHostInstanceWithWarning(component, methodName) { return null; } - if (hostFiber.mode & StrictLegacyMode) { + if (hostFiber.mode & StrictMode) { var componentName = getComponentName(fiber.type) || "Component"; if (!didWarnAboutFindNodeInStrictMode[componentName]) { @@ -21642,7 +20935,7 @@ function findHostInstanceWithWarning(component, methodName) { try { setCurrentFiber(hostFiber); - if (fiber.mode & StrictLegacyMode) { + if (fiber.mode & StrictMode) { error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which is inside StrictMode. " + @@ -21681,20 +20974,8 @@ function findHostInstanceWithWarning(component, methodName) { } } -function createContainer( - containerInfo, - tag, - hydrate, - hydrationCallbacks, - strictModeLevelOverride -) { - return createFiberRoot( - containerInfo, - tag, - hydrate, - hydrationCallbacks, - strictModeLevelOverride - ); +function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { + return createFiberRoot(containerInfo, tag, hydrate); } function updateContainer(element, container, parentComponent, callback) { { @@ -21758,12 +21039,7 @@ function updateContainer(element, container, parentComponent, callback) { } enqueueUpdate(current$1, update); - var root = scheduleUpdateOnFiber(current$1, lane, eventTime); - - if (root !== null) { - entangleTransitions(root, current$1, lane); - } - + scheduleUpdateOnFiber(current$1, lane, eventTime); return lane; } function getPublicRootInstance(container) { @@ -22303,15 +21579,13 @@ function findHostInstance_DEPRECATED(componentOrHandle) { if (componentOrHandle == null) { return null; - } // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN + } if (componentOrHandle._nativeTag) { - // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN return componentOrHandle; - } // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN + } if (componentOrHandle.canonical && componentOrHandle.canonical._nativeTag) { - // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN return componentOrHandle.canonical; } @@ -22453,12 +21727,11 @@ function render(element, containerTag, callback) { if (!root) { // TODO (bvaughn): If we decide to keep the wrapper component, // We could create a wrapper for containerTag as well to reduce special casing. - root = createContainer(containerTag, LegacyRoot, false, null, null); + root = createContainer(containerTag, LegacyRoot, false); roots.set(containerTag, root); } - updateContainer(element, root, null, callback); // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN - + updateContainer(element, root, null, callback); return getPublicRootInstance(root); } @@ -22503,8 +21776,8 @@ exports.createPortal = createPortal$1; exports.dispatchCommand = dispatchCommand; exports.findHostInstance_DEPRECATED = findHostInstance_DEPRECATED; exports.findNodeHandle = findNodeHandle; -exports.render = render; exports.sendAccessibilityEvent = sendAccessibilityEvent; +exports.render = render; exports.stopSurface = stopSurface; exports.unmountComponentAtNode = unmountComponentAtNode; diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index dc0d1975d80..035c6c10c7b 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_210 = { +var injectedNamesToPlugins$jscomp$inline_219 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -954,34 +954,34 @@ var injectedNamesToPlugins$jscomp$inline_210 = { } } }, - isOrderingDirty$jscomp$inline_211 = !1, - pluginName$jscomp$inline_212; -for (pluginName$jscomp$inline_212 in injectedNamesToPlugins$jscomp$inline_210) + isOrderingDirty$jscomp$inline_220 = !1, + pluginName$jscomp$inline_221; +for (pluginName$jscomp$inline_221 in injectedNamesToPlugins$jscomp$inline_219) if ( - injectedNamesToPlugins$jscomp$inline_210.hasOwnProperty( - pluginName$jscomp$inline_212 + injectedNamesToPlugins$jscomp$inline_219.hasOwnProperty( + pluginName$jscomp$inline_221 ) ) { - var pluginModule$jscomp$inline_213 = - injectedNamesToPlugins$jscomp$inline_210[pluginName$jscomp$inline_212]; + var pluginModule$jscomp$inline_222 = + injectedNamesToPlugins$jscomp$inline_219[pluginName$jscomp$inline_221]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_212) || - namesToPlugins[pluginName$jscomp$inline_212] !== - pluginModule$jscomp$inline_213 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_221) || + namesToPlugins[pluginName$jscomp$inline_221] !== + pluginModule$jscomp$inline_222 ) { - if (namesToPlugins[pluginName$jscomp$inline_212]) + if (namesToPlugins[pluginName$jscomp$inline_221]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_212 + + pluginName$jscomp$inline_221 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_212 - ] = pluginModule$jscomp$inline_213; - isOrderingDirty$jscomp$inline_211 = !0; + pluginName$jscomp$inline_221 + ] = pluginModule$jscomp$inline_222; + isOrderingDirty$jscomp$inline_220 = !0; } } -isOrderingDirty$jscomp$inline_211 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_220 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -996,11 +996,7 @@ getNodeFromInstance = function(inst) { }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ onChange: function(from, to, blockNativeResponder) { - (from || to).stateNode.canonical._internalInstanceHandle - ? (from && - nativeFabricUIManager.setIsJSResponder(from.stateNode.node, !1), - to && nativeFabricUIManager.setIsJSResponder(to.stateNode.node, !0)) - : null !== to + null !== to ? ReactNativePrivateInterface.UIManager.setJSResponder( to.stateNode.canonical._nativeTag, blockNativeResponder @@ -1024,8 +1020,7 @@ var ReactSharedInternals = REACT_LAZY_TYPE = 60116, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, - REACT_LEGACY_HIDDEN_TYPE = 60131, - REACT_CACHE_TYPE = 60132; + REACT_LEGACY_HIDDEN_TYPE = 60131; if ("function" === typeof Symbol && Symbol.for) { var symbolFor = Symbol.for; REACT_ELEMENT_TYPE = symbolFor("react.element"); @@ -1044,7 +1039,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); - REACT_CACHE_TYPE = symbolFor("react.cache"); } var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { @@ -1071,8 +1065,6 @@ function getComponentName(type) { return "Suspense"; case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList"; - case REACT_CACHE_TYPE: - return "Cache"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -1106,7 +1098,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.flags & 2050) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1194,14 +1186,19 @@ function findCurrentFiberUsingSlowPath(fiber) { } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); - return null !== parent ? findCurrentHostFiberImpl(parent) : null; -} -function findCurrentHostFiberImpl(node) { - if (5 === node.tag || 6 === node.tag) return node; - for (node = node.child; null !== node; ) { - var match = findCurrentHostFiberImpl(node); - if (null !== match) return match; - node = node.sibling; + if (!parent) return null; + for (var node = parent; ; ) { + if (5 === node.tag || 6 === node.tag) return node; + if (node.child) (node.child.return = node), (node = node.child); + else { + if (node === parent) break; + for (; !node.sibling; ) { + if (!node.return || node.return === parent) return null; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } } return null; } @@ -1528,328 +1525,6 @@ function dispatchEvent(target, topLevelType, nativeEvent) { } }); } -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, - requestPaint = - void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, - syncQueue = null, - immediateQueueCallbackNode = null, - isFlushingSyncQueue = !1, - initialTimeMs = Scheduler_now(), - now = - 1e4 > initialTimeMs - ? Scheduler_now - : function() { - return Scheduler_now() - initialTimeMs; - }; -function getCurrentPriorityLevel() { - switch (Scheduler_getCurrentPriorityLevel()) { - case Scheduler_ImmediatePriority: - return 99; - case Scheduler_UserBlockingPriority: - return 98; - case Scheduler_NormalPriority: - return 97; - case Scheduler_LowPriority: - return 96; - case Scheduler_IdlePriority: - return 95; - default: - throw Error("Unknown priority level."); - } -} -function reactPriorityToSchedulerPriority(reactPriorityLevel) { - switch (reactPriorityLevel) { - case 99: - return Scheduler_ImmediatePriority; - case 98: - return Scheduler_UserBlockingPriority; - case 97: - return Scheduler_NormalPriority; - case 96: - return Scheduler_LowPriority; - case 95: - return Scheduler_IdlePriority; - default: - throw Error("Unknown priority level."); - } -} -function runWithPriority(reactPriorityLevel, fn) { - reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_runWithPriority(reactPriorityLevel, fn); -} -function scheduleCallback(reactPriorityLevel, callback, options) { - reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); -} -function flushSyncCallbackQueue() { - if (null !== immediateQueueCallbackNode) { - var node = immediateQueueCallbackNode; - immediateQueueCallbackNode = null; - Scheduler_cancelCallback(node); - } - flushSyncCallbackQueueImpl(); -} -function flushSyncCallbackQueueImpl() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var i = 0; - try { - var queue = syncQueue; - runWithPriority(99, function() { - for (; i < queue.length; i++) { - var callback = queue[i]; - do callback = callback(!0); - while (null !== callback); - } - }); - syncQueue = null; - } catch (error) { - throw (null !== syncQueue && (syncQueue = syncQueue.slice(i + 1)), - Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueue - ), - error); - } finally { - isFlushingSyncQueue = !1; - } - } -} -var nextTransitionLane = 512, - nextRetryLane = 8388608, - return_highestLanePriority = 8; -function getHighestPriorityLanes(lanes) { - switch (lanes & -lanes) { - case 1: - return (return_highestLanePriority = 15), 1; - case 2: - return (return_highestLanePriority = 14), 2; - case 4: - return (return_highestLanePriority = 13), 4; - case 8: - return (return_highestLanePriority = 12), 8; - case 16: - return (return_highestLanePriority = 11), 16; - case 32: - return (return_highestLanePriority = 10), 32; - case 64: - return (return_highestLanePriority = 9), 64; - case 128: - return (return_highestLanePriority = 8), 128; - case 256: - return (return_highestLanePriority = 7), 256; - case 512: - case 1024: - case 2048: - case 4096: - case 8192: - case 16384: - case 32768: - case 65536: - case 131072: - case 262144: - case 524288: - case 1048576: - case 2097152: - case 4194304: - return (return_highestLanePriority = 6), lanes & 8388096; - case 8388608: - case 16777216: - case 33554432: - case 67108864: - return (return_highestLanePriority = 5), lanes & 125829120; - case 134217728: - return (return_highestLanePriority = 4), 134217728; - case 268435456: - return (return_highestLanePriority = 3), 268435456; - case 536870912: - return (return_highestLanePriority = 2), 536870912; - case 1073741824: - return (return_highestLanePriority = 1), 1073741824; - default: - return (return_highestLanePriority = 8), 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; - 0 !== expiredLanes - ? ((nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 15)) - : ((expiredLanes = pendingLanes & 268435455), - 0 !== expiredLanes - ? ((pendingLanes = expiredLanes & ~suspendedLanes), - 0 !== pendingLanes - ? ((nextLanes = getHighestPriorityLanes(pendingLanes)), - (nextLanePriority = return_highestLanePriority)) - : ((pingedLanes &= expiredLanes), - 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)))) - : ((pendingLanes &= ~suspendedLanes), - 0 !== pendingLanes - ? ((nextLanes = getHighestPriorityLanes(pendingLanes)), - (nextLanePriority = return_highestLanePriority)) - : 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)))); - if (0 === nextLanes) return 0; - if ( - 0 !== wipLanes && - wipLanes !== nextLanes && - 0 === (wipLanes & suspendedLanes) - ) { - getHighestPriorityLanes(wipLanes); - suspendedLanes = return_highestLanePriority; - if ( - nextLanePriority <= suspendedLanes || - (8 === nextLanePriority && 6 === suspendedLanes) - ) - return wipLanes; - return_highestLanePriority = nextLanePriority; - } - wipLanes = root.entangledLanes; - if (0 !== wipLanes) - for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) - (nextLanePriority = 31 - clz32(wipLanes)), - (suspendedLanes = 1 << nextLanePriority), - (nextLanes |= root[nextLanePriority]), - (wipLanes &= ~suspendedLanes); - return nextLanes; -} -function getLanesToRetrySynchronouslyOnError(root) { - root = root.pendingLanes & -1073741825; - return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; -} -function findUpdateLane(lanePriority) { - switch (lanePriority) { - case 15: - return 1; - case 14: - return 2; - case 12: - return 8; - case 10: - return 32; - case 8: - return 128; - case 2: - return 536870912; - } - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); -} -function createLaneMap(initial) { - for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); - return laneMap; -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; - 536870912 !== updateLane && - ((root.suspendedLanes = 0), (root.pingedLanes = 0)); - root = root.eventTimes; - updateLane = 31 - clz32(updateLane); - root[updateLane] = eventTime; -} -function markRootFinished(root, remainingLanes) { - var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; - root.pendingLanes = remainingLanes; - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes; - root.mutableReadLanes &= remainingLanes; - root.entangledLanes &= remainingLanes; - remainingLanes = root.entanglements; - var eventTimes = root.eventTimes; - for (root = root.expirationTimes; 0 < noLongerPendingLanes; ) { - var index$7 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$7; - remainingLanes[index$7] = 0; - eventTimes[index$7] = -1; - root[index$7] = -1; - noLongerPendingLanes &= ~lane; - } -} -function markRootEntangled(root, entangledLanes) { - var rootEntangledLanes = (root.entangledLanes |= entangledLanes); - for (root = root.entanglements; rootEntangledLanes; ) { - var index$8 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$8; - (lane & entangledLanes) | (root[index$8] & entangledLanes) && - (root[index$8] |= entangledLanes); - rootEntangledLanes &= ~lane; - } -} -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_now$1 = Scheduler.unstable_now; -Scheduler_now$1(); 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." @@ -2065,17 +1740,296 @@ function invalidateContextProvider(workInProgress, type, didChange) { push(didPerformWorkStackCursor, didChange); } var rendererID = null, - injectedHook = null; -function onCommitRoot(root) { - if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) - try { - injectedHook.onCommitFiberRoot( - rendererID, - root, - void 0, - 128 === (root.current.flags & 128) + 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." ); - } catch (err) {} + } +} +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$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, + fakeCallbackNode = {}, + requestPaint = + void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, + syncQueue = null, + immediateQueueCallbackNode = null, + isFlushingSyncQueue = !1, + initialTimeMs$1 = Scheduler_now$1(), + now = + 1e4 > initialTimeMs$1 + ? Scheduler_now$1 + : function() { + return Scheduler_now$1() - initialTimeMs$1; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return 99; + case Scheduler_UserBlockingPriority: + return 98; + case Scheduler_NormalPriority: + return 97; + case Scheduler_LowPriority: + return 96; + case Scheduler_IdlePriority: + return 95; + default: + throw Error("Unknown priority level."); + } +} +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case 99: + return Scheduler_ImmediatePriority; + case 98: + return Scheduler_UserBlockingPriority; + case 97: + return Scheduler_NormalPriority; + case 96: + return Scheduler_LowPriority; + case 95: + return Scheduler_IdlePriority; + default: + throw Error("Unknown priority level."); + } +} +function runWithPriority(reactPriorityLevel, fn) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(reactPriorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); +} +function flushSyncCallbackQueue() { + if (null !== immediateQueueCallbackNode) { + var node = immediateQueueCallbackNode; + immediateQueueCallbackNode = null; + Scheduler_cancelCallback(node); + } + flushSyncCallbackQueueImpl(); +} +function flushSyncCallbackQueueImpl() { + if (!isFlushingSyncQueue && null !== syncQueue) { + isFlushingSyncQueue = !0; + var i = 0; + try { + var queue = syncQueue; + runWithPriority(99, function() { + for (; i < queue.length; i++) { + var callback = queue[i]; + do callback = callback(!0); + while (null !== callback); + } + }); + syncQueue = null; + } catch (error) { + throw (null !== syncQueue && (syncQueue = syncQueue.slice(i + 1)), + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueue + ), + error); + } finally { + isFlushingSyncQueue = !1; + } + } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { @@ -2143,10 +2097,10 @@ var valueCursor = createCursor(null), function resetContextDependencies() { lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; } -function popProvider(context) { +function popProvider(providerFiber) { var currentValue = valueCursor.current; pop(valueCursor); - context._currentValue2 = currentValue; + providerFiber.type._context._currentValue2 = currentValue; } function scheduleWorkOnParentPath(parent, renderLanes) { for (; null !== parent; ) { @@ -2197,14 +2151,13 @@ function readContext(context, observedBits) { } return context._currentValue2; } -var interleavedQueues = null, - hasForceUpdate = !1; +var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, firstBaseUpdate: null, lastBaseUpdate: null, - shared: { pending: null, interleaved: null, lanes: 0 }, + shared: { pending: null }, effects: null }; } @@ -2230,32 +2183,14 @@ function createUpdate(eventTime, lane) { }; } function enqueueUpdate(fiber, update) { - var updateQueue = fiber.updateQueue; - null !== updateQueue && - ((updateQueue = updateQueue.shared), - null !== workInProgressRoot && 0 !== (fiber.mode & 1) - ? ((fiber = updateQueue.interleaved), - null === fiber - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [updateQueue]) - : interleavedQueues.push(updateQueue)) - : ((update.next = fiber.next), (fiber.next = update)), - (updateQueue.interleaved = update)) - : ((fiber = updateQueue.pending), - null === fiber - ? (update.next = update) - : ((update.next = fiber.next), (fiber.next = update)), - (updateQueue.pending = update))); -} -function entangleTransitions(root, fiber, lane) { fiber = fiber.updateQueue; - if (null !== fiber && ((fiber = fiber.shared), 0 !== (lane & 8388096))) { - var queueLanes = fiber.lanes; - queueLanes &= root.pendingLanes; - lane |= queueLanes; - fiber.lanes = lane; - markRootEntangled(root, lane); + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; } } function enqueueCapturedUpdate(workInProgress, capturedUpdate) { @@ -2324,110 +2259,111 @@ function processUpdateQueue( : (lastBaseUpdate.next = firstPendingUpdate); lastBaseUpdate = lastPendingUpdate; var current = workInProgress$jscomp$0.alternate; - null !== current && - ((current = current.updateQueue), - (pendingQueue = current.lastBaseUpdate), - pendingQueue !== lastBaseUpdate && - (null === pendingQueue + if (null !== current) { + current = current.updateQueue; + var currentLastBaseUpdate = current.lastBaseUpdate; + currentLastBaseUpdate !== lastBaseUpdate && + (null === currentLastBaseUpdate ? (current.firstBaseUpdate = firstPendingUpdate) - : (pendingQueue.next = firstPendingUpdate), - (current.lastBaseUpdate = lastPendingUpdate))); + : (currentLastBaseUpdate.next = firstPendingUpdate), + (current.lastBaseUpdate = lastPendingUpdate)); + } } if (null !== firstBaseUpdate) { - var newState = queue.baseState; + currentLastBaseUpdate = queue.baseState; lastBaseUpdate = 0; current = firstPendingUpdate = lastPendingUpdate = null; - pendingQueue = firstBaseUpdate; do { - var updateLane = pendingQueue.lane, - updateEventTime = pendingQueue.eventTime; - if ((renderLanes & updateLane) === updateLane) { + pendingQueue = firstBaseUpdate.lane; + var updateEventTime = firstBaseUpdate.eventTime; + if ((renderLanes & pendingQueue) === pendingQueue) { null !== current && (current = current.next = { eventTime: updateEventTime, lane: 0, - tag: pendingQueue.tag, - payload: pendingQueue.payload, - callback: pendingQueue.callback, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null }); a: { var workInProgress = workInProgress$jscomp$0, - update = pendingQueue; - updateLane = props; + update = firstBaseUpdate; + pendingQueue = props; updateEventTime = instance; switch (update.tag) { case 1: workInProgress = update.payload; if ("function" === typeof workInProgress) { - newState = workInProgress.call( + currentLastBaseUpdate = workInProgress.call( updateEventTime, - newState, - updateLane + currentLastBaseUpdate, + pendingQueue ); break a; } - newState = workInProgress; + currentLastBaseUpdate = workInProgress; break a; case 3: - workInProgress.flags = (workInProgress.flags & -16385) | 128; + workInProgress.flags = (workInProgress.flags & -8193) | 64; case 0: workInProgress = update.payload; - updateLane = + pendingQueue = "function" === typeof workInProgress - ? workInProgress.call(updateEventTime, newState, updateLane) + ? workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ) : workInProgress; - if (null === updateLane || void 0 === updateLane) break a; - newState = Object.assign({}, newState, updateLane); + if (null === pendingQueue || void 0 === pendingQueue) break a; + currentLastBaseUpdate = Object.assign( + {}, + currentLastBaseUpdate, + pendingQueue + ); break a; case 2: hasForceUpdate = !0; } } - null !== pendingQueue.callback && - ((workInProgress$jscomp$0.flags |= 64), - (updateLane = queue.effects), - null === updateLane - ? (queue.effects = [pendingQueue]) - : updateLane.push(pendingQueue)); + null !== firstBaseUpdate.callback && + ((workInProgress$jscomp$0.flags |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [firstBaseUpdate]) + : pendingQueue.push(firstBaseUpdate)); } else (updateEventTime = { eventTime: updateEventTime, - lane: updateLane, - tag: pendingQueue.tag, - payload: pendingQueue.payload, - callback: pendingQueue.callback, + lane: pendingQueue, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null }), null === current ? ((firstPendingUpdate = current = updateEventTime), - (lastPendingUpdate = newState)) + (lastPendingUpdate = currentLastBaseUpdate)) : (current = current.next = updateEventTime), - (lastBaseUpdate |= updateLane); - pendingQueue = pendingQueue.next; - if (null === pendingQueue) + (lastBaseUpdate |= pendingQueue); + firstBaseUpdate = firstBaseUpdate.next; + if (null === firstBaseUpdate) if (((pendingQueue = queue.shared.pending), null === pendingQueue)) break; else - (updateLane = pendingQueue), - (pendingQueue = updateLane.next), - (updateLane.next = null), - (queue.lastBaseUpdate = updateLane), + (firstBaseUpdate = pendingQueue.next), + (pendingQueue.next = null), + (queue.lastBaseUpdate = pendingQueue), (queue.shared.pending = null); } while (1); - null === current && (lastPendingUpdate = newState); + null === current && (lastPendingUpdate = currentLastBaseUpdate); queue.baseState = lastPendingUpdate; queue.firstBaseUpdate = firstPendingUpdate; queue.lastBaseUpdate = current; - props = queue.shared.interleaved; - if (null !== props) { - queue = props; - do (lastBaseUpdate |= queue.lane), (queue = queue.next); - while (queue !== props); - } else null === firstBaseUpdate && (queue.shared.lanes = 0); workInProgressRootSkippedLanes |= lastBaseUpdate; workInProgress$jscomp$0.lanes = lastBaseUpdate; - workInProgress$jscomp$0.memoizedState = newState; + workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2483,8 +2419,7 @@ var classComponentUpdater = { update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - payload = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== payload && entangleTransitions(payload, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; @@ -2495,8 +2430,7 @@ var classComponentUpdater = { update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - payload = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== payload && entangleTransitions(payload, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternals; @@ -2506,8 +2440,7 @@ var classComponentUpdater = { update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - callback = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== callback && entangleTransitions(callback, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); } }; function checkShouldComponentUpdate( @@ -2655,22 +2588,24 @@ function coerceRef(returnFiber, current, element) { } function throwOnInvalidObjectType(returnFiber, newChild) { if ("textarea" !== returnFiber.type) - throw ((returnFiber = Object.prototype.toString.call(newChild)), - Error( + throw Error( "Objects are not valid as a React child (found: " + - ("[object Object]" === returnFiber + ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : returnFiber) + + : newChild) + "). If you meant to render a collection of children, use an array instead." - )); + ); } function ChildReconciler(shouldTrackSideEffects) { function deleteChild(returnFiber, childToDelete) { if (shouldTrackSideEffects) { - var deletions = returnFiber.deletions; - null === deletions - ? ((returnFiber.deletions = [childToDelete]), (returnFiber.flags |= 16)) - : deletions.push(childToDelete); + var last = returnFiber.lastEffect; + null !== last + ? ((last.nextEffect = childToDelete), + (returnFiber.lastEffect = childToDelete)) + : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); + childToDelete.nextEffect = null; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2702,16 +2637,16 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.flags |= 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.flags |= 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.flags |= 2); + (newFiber.flags = 2); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -2726,16 +2661,7 @@ function ChildReconciler(shouldTrackSideEffects) { return current; } function updateElement(returnFiber, current, element, lanes) { - var elementType = element.type; - if (elementType === REACT_FRAGMENT_TYPE) - return updateFragment( - returnFiber, - current, - element.props.children, - lanes, - element.key - ); - if (null !== current && current.elementType === elementType) + if (null !== current && current.elementType === element.type) return ( (lanes = useFiber(current, element.props)), (lanes.ref = coerceRef(returnFiber, current, element)), @@ -2849,7 +2775,15 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return newChild.key === key - ? updateElement(returnFiber, oldFiber, newChild, lanes) + ? newChild.type === REACT_FRAGMENT_TYPE + ? updateFragment( + returnFiber, + oldFiber, + newChild.props.children, + lanes, + key + ) + : updateElement(returnFiber, oldFiber, newChild, lanes) : null; case REACT_PORTAL_TYPE: return newChild.key === key @@ -2884,7 +2818,15 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updateElement(returnFiber, existingChildren, newChild, lanes) + newChild.type === REACT_FRAGMENT_TYPE + ? updateFragment( + returnFiber, + existingChildren, + newChild.props.children, + lanes, + newChild.key + ) + : updateElement(returnFiber, existingChildren, newChild, lanes) ); case REACT_PORTAL_TYPE: return ( @@ -3090,38 +3032,43 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) { - isObject = newChild.type; - if (isObject === REACT_FRAGMENT_TYPE) { - if (7 === isUnkeyedTopLevelFragment.tag) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props.children - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } - } else if (isUnkeyedTopLevelFragment.elementType === isObject) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); break; @@ -3299,7 +3246,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.flags & 128)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3451,11 +3398,10 @@ function updateReducer(reducer) { queue.pending = null; } if (null !== baseQueue) { - pendingQueue = baseQueue.next; + baseQueue = baseQueue.next; current = current.baseState; - var newBaseQueueFirst = (baseFirst = null), - newBaseQueueLast = null, - update = pendingQueue; + var newBaseQueueLast = (baseFirst = pendingQueue = null), + update = baseQueue; do { var updateLane = update.lane; if ((renderLanes & updateLane) === updateLane) @@ -3480,33 +3426,22 @@ function updateReducer(reducer) { next: null }; null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (baseFirst = current)) + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) : (newBaseQueueLast = newBaseQueueLast.next = clone); currentlyRenderingFiber$1.lanes |= updateLane; workInProgressRootSkippedLanes |= updateLane; } update = update.next; - } while (null !== update && update !== pendingQueue); + } while (null !== update && update !== baseQueue); null === newBaseQueueLast - ? (baseFirst = current) - : (newBaseQueueLast.next = newBaseQueueFirst); + ? (pendingQueue = current) + : (newBaseQueueLast.next = baseFirst); objectIs(current, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = current; - hook.baseState = baseFirst; + hook.baseState = pendingQueue; hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = current; } - reducer = queue.interleaved; - if (null !== reducer) { - baseQueue = reducer; - do - (pendingQueue = baseQueue.lane), - (currentlyRenderingFiber$1.lanes |= pendingQueue), - (workInProgressRootSkippedLanes |= pendingQueue), - (baseQueue = baseQueue.next); - while (baseQueue !== reducer); - } else null === baseQueue && (queue.lanes = 0); return [hook.memoizedState, queue.dispatch]; } function rerenderReducer(reducer) { @@ -3546,7 +3481,7 @@ function readFromUnsubcribedMutableSource(root, source, getSnapshot) { if (root) return getSnapshot(source._source); workInProgressSources.push(source); throw Error( - "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + "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) { @@ -3576,13 +3511,25 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { refs.getSnapshot = getSnapshot; refs.setSnapshot = setSnapshot; var maybeNewVersion = getVersion(source._source); - objectIs(version, maybeNewVersion) || - ((maybeNewVersion = getSnapshot(source._source)), + if (!objectIs(version, maybeNewVersion)) { + maybeNewVersion = getSnapshot(source._source); objectIs(snapshot, maybeNewVersion) || (setSnapshot(maybeNewVersion), (maybeNewVersion = requestUpdateLane(fiber)), - (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)), - markRootEntangled(root, root.mutableReadLanes)); + (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] ); @@ -3609,8 +3556,6 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { objectIs(memoizedState, subscribe)) || ((hook = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot @@ -3636,8 +3581,6 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3686,7 +3629,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - hook.memoizedState = pushEffect(hookFlags, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } @@ -3694,10 +3637,10 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(132096, 4, create, deps); + return mountEffectImpl(516, 4, create, deps); } function updateEffect(create, deps) { - return updateEffectImpl(1024, 4, create, deps); + return updateEffectImpl(516, 4, create, deps); } function updateLayoutEffect(create, deps) { return updateEffectImpl(4, 2, create, deps); @@ -3782,55 +3725,33 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }, - alternate = fiber.alternate; + pending = queue.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; + pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || - (null !== alternate && alternate === currentlyRenderingFiber$1) + (null !== pending && pending === currentlyRenderingFiber$1) ) - (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0), - (lane = queue.pending), - null === lane - ? (update.next = update) - : ((update.next = lane.next), (lane.next = update)), - (queue.pending = update); + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; else { - if (null !== workInProgressRoot && 0 !== (fiber.mode & 1)) { - var interleaved = queue.interleaved; - null === interleaved - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [queue]) - : interleavedQueues.push(queue)) - : ((update.next = interleaved.next), (interleaved.next = update)); - queue.interleaved = update; - } else - (interleaved = queue.pending), - null === interleaved - ? (update.next = update) - : ((update.next = interleaved.next), (interleaved.next = update)), - (queue.pending = update); if ( 0 === fiber.lanes && - (null === alternate || 0 === alternate.lanes) && - ((alternate = queue.lastRenderedReducer), null !== alternate) + (null === pending || 0 === pending.lanes) && + ((pending = queue.lastRenderedReducer), null !== pending) ) try { var currentState = queue.lastRenderedState, - eagerState = alternate(currentState, action); - update.eagerReducer = alternate; + eagerState = pending(currentState, action); + update.eagerReducer = pending; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - update = scheduleUpdateOnFiber(fiber, lane, eventTime); - 0 !== (lane & 8388096) && - null !== update && - ((fiber = queue.lanes), - (fiber &= update.pendingLanes), - (lane |= fiber), - (queue.lanes = lane), - markRootEntangled(update, lane)); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } var ContextOnlyDispatcher = { @@ -3887,8 +3808,6 @@ var ContextOnlyDispatcher = { hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -4064,7 +3983,7 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4140,15 +4059,14 @@ function updateSimpleMemoComponent( null !== current && shallowEqual(current.memoizedProps, nextProps) && current.ref === workInProgress.ref - ) { - didReceiveUpdate = !1; - if (0 === (renderLanes & updateLanes)) + ) + if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); + else return ( (workInProgress.lanes = current.lanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - 0 !== (current.flags & 65536) && (didReceiveUpdate = !0); - } return updateFunctionComponent( current, workInProgress, @@ -4165,39 +4083,30 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { "hidden" === nextProps.mode || "unstable-defer-without-hiding" === nextProps.mode ) - if (0 === (workInProgress.mode & 2)) - (workInProgress.memoizedState = { baseLanes: 0, cachePool: null }), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= renderLanes); - else { - if (0 === (renderLanes & 1073741824)) - return ( - (current = - null !== prevState - ? prevState.baseLanes | renderLanes - : renderLanes), - (workInProgress.lanes = workInProgress.childLanes = 1073741824), - (workInProgress.memoizedState = { - baseLanes: current, - cachePool: null - }), - (workInProgress.updateQueue = null), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= current), - null + 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 ); - workInProgress.memoizedState = { baseLanes: 0, cachePool: null }; - nextProps = null !== prevState ? prevState.baseLanes : renderLanes; - push(subtreeRenderLanesCursor, subtreeRenderLanes); - subtreeRenderLanes |= nextProps; - } + 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), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= nextProps); + pushRenderLanes(workInProgress, nextProps); reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -4207,7 +4116,7 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.flags |= 256; + workInProgress.flags |= 128; } function updateFunctionComponent( current, @@ -4232,7 +4141,7 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4407,7 +4316,7 @@ function updateClassComponent( "function" === typeof instance.componentDidUpdate && (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.flags |= 512)) + (workInProgress.flags |= 256)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || @@ -4415,7 +4324,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -4429,7 +4338,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 256), (nextProps = !1)); } return finishClassComponent( @@ -4450,7 +4359,7 @@ function finishClassComponent( renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.flags & 128); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), @@ -4494,21 +4403,18 @@ function pushHostRootContext(workInProgress) { pushHostContainer(workInProgress, root.containerInfo); } var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; -function mountSuspenseOffscreenState(renderLanes) { - return { baseLanes: renderLanes, cachePool: null }; -} function updateSuspenseComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.flags & 128)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = null !== current && null === current.memoizedState ? !1 : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.flags &= -129)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || @@ -4525,9 +4431,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext, renderLanes )), - (workInProgress.child.memoizedState = mountSuspenseOffscreenState( - renderLanes - )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), current ); @@ -4539,11 +4443,9 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext, renderLanes )), - (workInProgress.child.memoizedState = mountSuspenseOffscreenState( - renderLanes - )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), - (workInProgress.lanes = 8388608), + (workInProgress.lanes = 33554432), current ); renderLanes = createFiberFromOffscreen( @@ -4569,11 +4471,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (suspenseContext = current.child.memoizedState), (showFallback.memoizedState = null === suspenseContext - ? mountSuspenseOffscreenState(renderLanes) - : { - baseLanes: suspenseContext.baseLanes | renderLanes, - cachePool: null - }), + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps @@ -4600,11 +4499,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (suspenseContext = current.child.memoizedState), (showFallback.memoizedState = null === suspenseContext - ? mountSuspenseOffscreenState(renderLanes) - : { - baseLanes: suspenseContext.baseLanes | renderLanes, - cachePool: null - }), + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps @@ -4627,7 +4523,7 @@ function mountSuspenseFallbackChildren( var mode = workInProgress.mode, progressedPrimaryFragment = workInProgress.child; primaryChildren = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 1) && null !== progressedPrimaryFragment + 0 === (mode & 2) && null !== progressedPrimaryFragment ? ((progressedPrimaryFragment.childLanes = 0), (progressedPrimaryFragment.pendingProps = primaryChildren)) : (progressedPrimaryFragment = createFiberFromOffscreen( @@ -4660,14 +4556,13 @@ function updateSuspensePrimaryChildren( mode: "visible", children: primaryChildren }); - 0 === (workInProgress.mode & 1) && (primaryChildren.lanes = renderLanes); + 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); primaryChildren.return = workInProgress; primaryChildren.sibling = null; null !== current && - ((renderLanes = workInProgress.deletions), - null === renderLanes - ? ((workInProgress.deletions = [current]), (workInProgress.flags |= 16)) - : renderLanes.push(current)); + ((current.nextEffect = null), + (current.flags = 8), + (workInProgress.firstEffect = workInProgress.lastEffect = current)); return (workInProgress.child = primaryChildren); } function updateSuspenseFallbackChildren( @@ -4677,22 +4572,26 @@ function updateSuspenseFallbackChildren( fallbackChildren, renderLanes ) { - var mode = workInProgress.mode; - current = current.child; - var currentFallbackChildFragment = current.sibling, - primaryChildProps = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 1) && workInProgress.child !== current + 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.deletions = null)) - : ((primaryChildren = createWorkInProgress(current, primaryChildProps)), - (primaryChildren.subtreeFlags = current.subtreeFlags & 131072)); - null !== currentFallbackChildFragment - ? (fallbackChildren = createWorkInProgress( - currentFallbackChildFragment, - fallbackChildren - )) + (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, @@ -4717,7 +4616,8 @@ function initSuspenseListRenderState( isBackwards, tail, lastContentRow, - tailMode + tailMode, + lastEffectBeforeRendering ) { var renderState = workInProgress.memoizedState; null === renderState @@ -4727,14 +4627,16 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailMode: tailMode + tailMode: tailMode, + lastEffect: lastEffectBeforeRendering }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailMode = tailMode)); + (renderState.tailMode = tailMode), + (renderState.lastEffect = lastEffectBeforeRendering)); } function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, @@ -4743,9 +4645,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 128); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.flags & 128)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && @@ -4768,7 +4670,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { nextProps &= 1; } push(suspenseStackCursor, nextProps); - if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null; + if (0 === (workInProgress.mode & 2)) workInProgress.memoizedState = null; else switch (revealOrder) { case "forwards": @@ -4789,7 +4691,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { !1, revealOrder, renderLanes, - tailMode + tailMode, + workInProgress.lastEffect ); break; case "backwards": @@ -4811,11 +4714,19 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { !0, renderLanes, null, - tailMode + tailMode, + workInProgress.lastEffect ); break; case "together": - initSuspenseListRenderState(workInProgress, !1, null, null, void 0); + initSuspenseListRenderState( + workInProgress, + !1, + null, + null, + void 0, + workInProgress.lastEffect + ); break; default: workInProgress.memoizedState = null; @@ -4825,33 +4736,25 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { null !== current && (workInProgress.dependencies = current.dependencies); workInProgressRootSkippedLanes |= workInProgress.lanes; - if (0 === (renderLanes & workInProgress.childLanes)) return null; - 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; + 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; -} -function hadNoMutationsEffects(current, completedWork) { - if (null !== current && current.child === completedWork.child) return !0; - if (0 !== (completedWork.flags & 16)) return !1; - for (current = completedWork.child; null !== current; ) { - if (0 !== (current.flags & 6454) || 0 !== (current.subtreeFlags & 6454)) - return !1; - current = current.sibling; - } - return !0; + return null; } var appendAllChildren, updateHostContainer, @@ -4968,24 +4871,21 @@ function appendAllChildrenToContainer( node = node.sibling; } } -updateHostContainer = function(current, workInProgress) { +updateHostContainer = function(workInProgress) { var portalOrRoot = workInProgress.stateNode; - if (!hadNoMutationsEffects(current, workInProgress)) { - current = portalOrRoot.containerInfo; - var newChildSet = createChildNodeSet(current); + if (null !== workInProgress.firstEffect) { + var container = portalOrRoot.containerInfo, + newChildSet = createChildNodeSet(container); appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; workInProgress.flags |= 4; - completeRoot(current, newChildSet); + completeRoot(container, newChildSet); } }; updateHostComponent$1 = function(current, workInProgress, type, newProps) { type = current.stateNode; var oldProps = current.memoizedProps; - if ( - (current = hadNoMutationsEffects(current, workInProgress)) && - oldProps === newProps - ) + if ((current = null === workInProgress.firstEffect) && oldProps === newProps) workInProgress.stateNode = type; else { var recyclableInstance = workInProgress.stateNode; @@ -5003,15 +4903,15 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { current && null === updatePayload ? (workInProgress.stateNode = type) : ((newProps = updatePayload), - (oldProps = type.node), + (recyclableInstance = type.node), (type = { node: current ? null !== newProps - ? cloneNodeWithNewProps(oldProps, newProps) - : cloneNode(oldProps) + ? cloneNodeWithNewProps(recyclableInstance, newProps) + : cloneNode(recyclableInstance) : null !== newProps - ? cloneNodeWithNewChildrenAndProps(oldProps, newProps) - : cloneNodeWithNewChildren(oldProps), + ? cloneNodeWithNewChildrenAndProps(recyclableInstance, newProps) + : cloneNodeWithNewChildren(recyclableInstance), canonical: type.canonical }), (workInProgress.stateNode = type), @@ -5047,40 +4947,16 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$62 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$62 = lastTailNode), + for (var lastTailNode$64 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$62 + null === lastTailNode$64 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$62.sibling = null); + : (lastTailNode$64.sibling = null); } } -function bubbleProperties(completedWork) { - var didBailout = - null !== completedWork.alternate && - completedWork.alternate.child === completedWork.child, - newChildLanes = 0, - subtreeFlags = 0; - if (didBailout) - for (var child$63 = completedWork.child; null !== child$63; ) - (newChildLanes |= child$63.lanes | child$63.childLanes), - (subtreeFlags |= child$63.subtreeFlags & 131072), - (subtreeFlags |= child$63.flags & 131072), - (child$63.return = completedWork), - (child$63 = child$63.sibling); - else - for (child$63 = completedWork.child; null !== child$63; ) - (newChildLanes |= child$63.lanes | child$63.childLanes), - (subtreeFlags |= child$63.subtreeFlags), - (subtreeFlags |= child$63.flags), - (child$63.return = completedWork), - (child$63 = child$63.sibling); - completedWork.subtreeFlags |= subtreeFlags; - completedWork.childLanes = newChildLanes; - return didBailout; -} function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { @@ -5094,81 +4970,76 @@ function completeWork(current, workInProgress, renderLanes) { case 12: case 9: case 14: - return bubbleProperties(workInProgress), null; + return null; case 1: - return ( - isContextProvider(workInProgress.type) && popContext(), - bubbleProperties(workInProgress), - null - ); + return isContextProvider(workInProgress.type) && popContext(), null; case 3: return ( - (newProps = workInProgress.stateNode), popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), resetWorkInProgressVersions(), + (newProps = workInProgress.stateNode), newProps.pendingContext && ((newProps.context = newProps.pendingContext), (newProps.pendingContext = null)), (null !== current && null !== current.child) || newProps.hydrate || - (workInProgress.flags |= 512), - updateHostContainer(current, workInProgress), - bubbleProperties(workInProgress), + (workInProgress.flags |= 256), + updateHostContainer(workInProgress), null ); case 5: popHostContext(workInProgress); - renderLanes = requiredContext(rootInstanceStackCursor.current); - var type = workInProgress.type; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ); + renderLanes = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - type, + renderLanes, newProps, - renderLanes + rootContainerInstance ), - current.ref !== workInProgress.ref && (workInProgress.flags |= 256); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); - bubbleProperties(workInProgress); return null; } requiredContext(contextStackCursor$1.current); current = nextReactTag; nextReactTag += 2; - type = getViewConfigForType(type); + renderLanes = getViewConfigForType(renderLanes); var updatePayload = diffProperties( null, emptyObject, newProps, - type.validAttributes + renderLanes.validAttributes ); - renderLanes = createNode( + rootContainerInstance = createNode( current, - type.uiViewClassName, - renderLanes, + renderLanes.uiViewClassName, + rootContainerInstance, updatePayload, workInProgress ); current = new ReactFabricHostComponent( current, - type, + renderLanes, newProps, workInProgress ); - current = { node: renderLanes, canonical: current }; + current = { node: rootContainerInstance, canonical: current }; appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; - null !== workInProgress.ref && (workInProgress.flags |= 256); + null !== workInProgress.ref && (workInProgress.flags |= 128); } - bubbleProperties(workInProgress); return null; case 6: if (current && null != workInProgress.stateNode) @@ -5184,25 +5055,25 @@ function completeWork(current, workInProgress, renderLanes) { "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); current = requiredContext(rootInstanceStackCursor.current); - renderLanes = requiredContext(contextStackCursor$1.current); + rootContainerInstance = requiredContext(contextStackCursor$1.current); workInProgress.stateNode = createTextInstance( newProps, current, - renderLanes, + rootContainerInstance, workInProgress ); } - bubbleProperties(workInProgress); return null; case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.flags & 128)) + if (0 !== (workInProgress.flags & 64)) return (workInProgress.lanes = renderLanes), workInProgress; newProps = null !== newProps; - renderLanes = !1; - null !== current && (renderLanes = null !== current.memoizedState); - if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1)) + rootContainerInstance = !1; + null !== current && + (rootContainerInstance = null !== current.memoizedState); + if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || @@ -5217,92 +5088,82 @@ function completeWork(current, workInProgress, renderLanes) { ) workInProgressRootExitStatus = 4; null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootUpdatedLanes & 268435455)) || + (0 === (workInProgressRootSkippedLanes & 134217727) && + 0 === (workInProgressRootUpdatedLanes & 134217727)) || markRootSuspended$1( workInProgressRoot, workInProgressRootRenderLanes ); } newProps && (workInProgress.flags |= 4); - bubbleProperties(workInProgress); return null; case 4: - return ( - popHostContainer(), - updateHostContainer(current, workInProgress), - bubbleProperties(workInProgress), - null - ); + return popHostContainer(), updateHostContainer(workInProgress), null; case 10: - return ( - popProvider(workInProgress.type._context), - bubbleProperties(workInProgress), - null - ); + return popProvider(workInProgress), null; case 17: - return ( - isContextProvider(workInProgress.type) && popContext(), - bubbleProperties(workInProgress), - null - ); + return isContextProvider(workInProgress.type) && popContext(), null; case 19: pop(suspenseStackCursor); - type = workInProgress.memoizedState; - if (null === type) return bubbleProperties(workInProgress), null; - newProps = 0 !== (workInProgress.flags & 128); - updatePayload = type.rendering; + newProps = workInProgress.memoizedState; + if (null === newProps) return null; + rootContainerInstance = 0 !== (workInProgress.flags & 64); + updatePayload = newProps.rendering; if (null === updatePayload) - if (newProps) cutOffTailIfNeeded(type, !1); + if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || - (null !== current && 0 !== (current.flags & 128)) + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.flags |= 128; - cutOffTailIfNeeded(type, !1); + workInProgress.flags |= 64; + cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), (workInProgress.flags |= 4)); - workInProgress.subtreeFlags = 0; + null === newProps.lastEffect && + (workInProgress.firstEffect = null); + workInProgress.lastEffect = newProps.lastEffect; current = renderLanes; for (newProps = workInProgress.child; null !== newProps; ) - (renderLanes = newProps), - (type = current), - (renderLanes.flags &= 131074), - (updatePayload = renderLanes.alternate), + (rootContainerInstance = newProps), + (renderLanes = current), + (rootContainerInstance.flags &= 2), + (rootContainerInstance.nextEffect = null), + (rootContainerInstance.firstEffect = null), + (rootContainerInstance.lastEffect = null), + (updatePayload = rootContainerInstance.alternate), null === updatePayload - ? ((renderLanes.childLanes = 0), - (renderLanes.lanes = type), - (renderLanes.child = null), - (renderLanes.subtreeFlags = 0), - (renderLanes.memoizedProps = null), - (renderLanes.memoizedState = null), - (renderLanes.updateQueue = null), - (renderLanes.dependencies = null), - (renderLanes.stateNode = null)) - : ((renderLanes.childLanes = updatePayload.childLanes), - (renderLanes.lanes = updatePayload.lanes), - (renderLanes.child = updatePayload.child), - (renderLanes.subtreeFlags = updatePayload.subtreeFlags), - (renderLanes.deletions = null), - (renderLanes.memoizedProps = + ? ((rootContainerInstance.childLanes = 0), + (rootContainerInstance.lanes = renderLanes), + (rootContainerInstance.child = null), + (rootContainerInstance.memoizedProps = null), + (rootContainerInstance.memoizedState = null), + (rootContainerInstance.updateQueue = null), + (rootContainerInstance.dependencies = null), + (rootContainerInstance.stateNode = null)) + : ((rootContainerInstance.childLanes = + updatePayload.childLanes), + (rootContainerInstance.lanes = updatePayload.lanes), + (rootContainerInstance.child = updatePayload.child), + (rootContainerInstance.memoizedProps = updatePayload.memoizedProps), - (renderLanes.memoizedState = + (rootContainerInstance.memoizedState = updatePayload.memoizedState), - (renderLanes.updateQueue = updatePayload.updateQueue), - (renderLanes.type = updatePayload.type), - (type = updatePayload.dependencies), - (renderLanes.dependencies = - null === type + (rootContainerInstance.updateQueue = + updatePayload.updateQueue), + (rootContainerInstance.type = updatePayload.type), + (renderLanes = updatePayload.dependencies), + (rootContainerInstance.dependencies = + null === renderLanes ? null : { - lanes: type.lanes, - firstContext: type.firstContext + lanes: renderLanes.lanes, + firstContext: renderLanes.firstContext })), (newProps = newProps.sibling); push( @@ -5313,74 +5174,78 @@ function completeWork(current, workInProgress, renderLanes) { } current = current.sibling; } - null !== type.tail && + null !== newProps.tail && now() > workInProgressRootRenderTargetTime && - ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), - (workInProgress.lanes = 8388608)); + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432)); } else { - if (!newProps) + if (!rootContainerInstance) if ( ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.flags |= 128), - (newProps = !0), + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), (workInProgress.flags |= 4)), - cutOffTailIfNeeded(type, !0), - null === type.tail && - "hidden" === type.tailMode && + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "hidden" === newProps.tailMode && !updatePayload.alternate) ) - return bubbleProperties(workInProgress), null; + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); } else - 2 * now() - type.renderingStartTime > + 2 * now() - newProps.renderingStartTime > workInProgressRootRenderTargetTime && 1073741824 !== renderLanes && - ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), - (workInProgress.lanes = 8388608)); - type.isBackwards + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432)); + newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) - : ((current = type.last), + : ((current = newProps.last), null !== current ? (current.sibling = updatePayload) : (workInProgress.child = updatePayload), - (type.last = updatePayload)); + (newProps.last = updatePayload)); } - if (null !== type.tail) - return ( - (workInProgress = type.tail), - (type.rendering = workInProgress), - (type.tail = workInProgress.sibling), - (type.renderingStartTime = now()), - (workInProgress.sibling = null), - (current = suspenseStackCursor.current), - push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1), - workInProgress - ); - bubbleProperties(workInProgress); - return null; + return null !== newProps.tail + ? ((current = newProps.tail), + (newProps.rendering = current), + (newProps.tail = current.sibling), + (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), + (current.sibling = null), + (workInProgress = suspenseStackCursor.current), + push( + suspenseStackCursor, + rootContainerInstance + ? (workInProgress & 1) | 2 + : workInProgress & 1 + ), + current) + : null; case 22: case 23: return ( popRenderLanes(), - (renderLanes = null !== workInProgress.memoizedState), null !== current && - (null !== current.memoizedState) !== renderLanes && + (null !== current.memoizedState) !== + (null !== workInProgress.memoizedState) && "unstable-defer-without-hiding" !== newProps.mode && (workInProgress.flags |= 4), - (renderLanes && - 0 === (subtreeRenderLanes & 1073741824) && - 0 !== (workInProgress.mode & 2)) || - bubbleProperties(workInProgress), null ); } @@ -5395,8 +5260,8 @@ function unwindWork(workInProgress) { case 1: isContextProvider(workInProgress.type) && popContext(); var flags = workInProgress.flags; - return flags & 16384 - ? ((workInProgress.flags = (flags & -16385) | 128), workInProgress) + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null; case 3: popHostContainer(); @@ -5404,11 +5269,11 @@ function unwindWork(workInProgress) { pop(contextStackCursor); resetWorkInProgressVersions(); flags = workInProgress.flags; - if (0 !== (flags & 128)) + 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.flags = (flags & -16385) | 128; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; @@ -5416,8 +5281,8 @@ function unwindWork(workInProgress) { return ( pop(suspenseStackCursor), (flags = workInProgress.flags), - flags & 16384 - ? ((workInProgress.flags = (flags & -16385) | 128), workInProgress) + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null ); case 19: @@ -5425,12 +5290,10 @@ function unwindWork(workInProgress) { case 4: return popHostContainer(), null; case 10: - return popProvider(workInProgress.type._context), null; + return popProvider(workInProgress), null; case 22: case 23: return popRenderLanes(), null; - case 24: - return null; default: return null; } @@ -5509,161 +5372,152 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { }); return lane; } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set, - nextEffect = null; -function safelyDetachRef(current, nearestMountedAncestor) { +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) if ("function" === typeof ref) try { ref(null); } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + captureCommitPhaseError(current, refError); } else ref.current = null; } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; -function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) - (firstChild.return = root), (nextEffect = firstChild); - else - for (; null !== nextEffect; ) { - root = nextEffect; - try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); +function commitBeforeMutationLifeCycles(current, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + return; + case 1: + if (finishedWork.flags & 256 && null !== current) { + var prevProps = current.memoizedProps, + prevState = current.memoizedState; + current = finishedWork.stateNode; + finishedWork = current.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); + current.__reactInternalSnapshotBeforeUpdate = finishedWork; + } + return; + case 3: + return; + case 5: + case 6: + case 4: + case 17: + 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 commitLifeCycles(finishedRoot, current, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + 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(); } - if (0 !== (flags & 512)) - switch (root.tag) { - case 0: - case 11: - case 15: - break; - case 1: - if (null !== current) { - var prevProps = current.memoizedProps, - prevState = current.memoizedState, - instance = root.stateNode, - snapshot = instance.getSnapshotBeforeUpdate( - root.elementType === root.type - ? prevProps - : resolveDefaultProps(root.type, prevProps), - prevState - ); - instance.__reactInternalSnapshotBeforeUpdate = snapshot; - } - break; - case 3: - break; - case 5: - case 6: - case 4: - case 17: - break; - default: - 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." - ); - } - } catch (error) { - captureCommitPhaseError(root, root.return, error); - } - firstChild = root.sibling; - if (null !== firstChild) { - firstChild.return = root.return; - nextEffect = firstChild; - break; - } - nextEffect = root.return; + finishedRoot = finishedRoot.next; + } while (finishedRoot !== current); } - } - current = shouldFireAfterActiveInstanceBlur; - shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; - return current; -} -function commitHookEffectListUnmount( - flags, - finishedWork, - nearestMountedAncestor$jscomp$0 -) { - var updateQueue = finishedWork.updateQueue; - updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; - if (null !== updateQueue) { - var effect = (updateQueue = updateQueue.next); - do { - if ((effect.tag & flags) === flags) { - var destroy = effect.destroy; - effect.destroy = void 0; - if (void 0 !== destroy) { - var current = finishedWork, - nearestMountedAncestor = nearestMountedAncestor$jscomp$0; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(current, nearestMountedAncestor, error); + 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; + 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); + return; + case 3: + current = finishedWork.updateQueue; + if (null !== current) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode.canonical; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; } - } + commitUpdateQueue(finishedWork, current, finishedRoot); } - effect = effect.next; - } while (effect !== updateQueue); + return; + case 5: + null === current && finishedWork.flags & 4 && shim(); + return; + case 6: + return; + case 4: + return; + case 12: + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + case 22: + case 23: + 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 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$80 = effect.create; - effect.destroy = create$80(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} -function detachFiberAfterEffects(fiber) { +function detachFiberMutation(fiber) { fiber.alternate = null; fiber.child = null; - fiber.deletions = null; fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; + fiber.return = null; fiber.updateQueue = null; } function commitWork(current, finishedWork) { @@ -5672,7 +5526,19 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - commitHookEffectListUnmount(3, finishedWork, finishedWork.return); + 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; @@ -5693,6 +5559,7 @@ function commitWork(current, finishedWork) { case 1: case 5: case 6: + case 20: break a; case 3: case 4: @@ -5717,261 +5584,13 @@ function attachSuspenseRetryListeners(finishedWork) { }); } } -function commitMutationEffects(root, renderPriorityLevel, firstChild) { - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - renderPriorityLevel = root.deletions; - if (null !== renderPriorityLevel) - for ( - firstChild = 0; - firstChild < renderPriorityLevel.length; - firstChild++ - ) { - var childToDelete = renderPriorityLevel[firstChild]; - try { - a: for (var node = childToDelete; ; ) { - var current = node; - if ( - injectedHook && - "function" === typeof injectedHook.onCommitFiberUnmount - ) - try { - injectedHook.onCommitFiberUnmount(rendererID, current); - } catch (err) {} - switch (current.tag) { - case 0: - case 11: - case 14: - case 15: - var updateQueue = current.updateQueue; - if (null !== updateQueue) { - var lastEffect = updateQueue.lastEffect; - if (null !== lastEffect) { - var firstEffect = lastEffect.next, - effect = firstEffect; - do { - var _effect = effect, - destroy = _effect.destroy, - tag = _effect.tag; - if (void 0 !== destroy && 0 !== (tag & 2)) { - _effect = current; - var nearestMountedAncestor = root; - try { - destroy(); - } catch (error) { - captureCommitPhaseError( - _effect, - nearestMountedAncestor, - error - ); - } - } - effect = effect.next; - } while (effect !== firstEffect); - } - } - break; - case 1: - safelyDetachRef(current, root); - var instance = current.stateNode; - if ("function" === typeof instance.componentWillUnmount) - try { - (effect = current), - (_effect = instance), - (_effect.props = effect.memoizedProps), - (_effect.state = effect.memoizedState), - _effect.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current, root, unmountError); - } - break; - case 5: - safelyDetachRef(current, root); - break; - case 4: - createChildNodeSet(current.stateNode.containerInfo); - } - if (null !== node.child) - (node.child.return = node), (node = node.child); - else { - if (node === childToDelete) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === childToDelete) - break a; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - var alternate = childToDelete.alternate; - childToDelete.return = null; - null !== alternate && (alternate.return = null); - } catch (error) { - captureCommitPhaseError(childToDelete, root, error); - } - } - renderPriorityLevel = root.child; - if (0 !== (root.subtreeFlags & 6454) && null !== renderPriorityLevel) - (renderPriorityLevel.return = root), (nextEffect = renderPriorityLevel); - else - for (; null !== nextEffect; ) { - root = nextEffect; - try { - var flags = root.flags; - if (flags & 256) { - var current$jscomp$0 = root.alternate; - if (null !== current$jscomp$0) { - var currentRef = current$jscomp$0.ref; - null !== currentRef && - ("function" === typeof currentRef - ? currentRef(null) - : (currentRef.current = null)); - } - } - switch (flags & 2054) { - case 2: - root.flags &= -3; - break; - case 6: - root.flags &= -3; - commitWork(root.alternate, root); - break; - case 2048: - root.flags &= -2049; - break; - case 2052: - root.flags &= -2049; - commitWork(root.alternate, root); - break; - case 4: - commitWork(root.alternate, root); - } - } catch (error) { - captureCommitPhaseError(root, root.return, error); - } - renderPriorityLevel = root.sibling; - if (null !== renderPriorityLevel) { - renderPriorityLevel.return = root.return; - nextEffect = renderPriorityLevel; - break; - } - nextEffect = root.return; - } - } -} -function commitLayoutEffects(finishedWork) { - for (nextEffect = finishedWork; null !== nextEffect; ) { - var fiber = nextEffect, - firstChild = fiber.child; - if (0 !== (fiber.subtreeFlags & 324) && null !== firstChild) - (firstChild.return = fiber), (nextEffect = firstChild); - else - for (fiber = finishedWork; null !== nextEffect; ) { - firstChild = nextEffect; - if (0 !== (firstChild.flags & 324)) { - var current = firstChild.alternate; - try { - if (0 !== (firstChild.flags & 68)) - switch (firstChild.tag) { - case 0: - case 11: - case 15: - commitHookEffectListMount(3, firstChild); - break; - case 1: - var instance = firstChild.stateNode; - if (firstChild.flags & 4) - if (null === current) instance.componentDidMount(); - else { - var prevProps = - firstChild.elementType === firstChild.type - ? current.memoizedProps - : resolveDefaultProps( - firstChild.type, - current.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = firstChild.updateQueue; - null !== updateQueue && - commitUpdateQueue(firstChild, updateQueue, instance); - break; - case 3: - var updateQueue$81 = firstChild.updateQueue; - if (null !== updateQueue$81) { - current = null; - if (null !== firstChild.child) - switch (firstChild.child.tag) { - case 5: - current = firstChild.child.stateNode.canonical; - break; - case 1: - current = firstChild.child.stateNode; - } - commitUpdateQueue(firstChild, updateQueue$81, current); - } - break; - case 5: - null === current && firstChild.flags & 4 && shim(); - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 19: - case 17: - case 21: - case 22: - case 23: - break; - default: - 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 (firstChild.flags & 256) { - current = void 0; - var ref = firstChild.ref; - if (null !== ref) { - var instance$jscomp$0 = firstChild.stateNode; - switch (firstChild.tag) { - case 5: - current = instance$jscomp$0.canonical; - break; - default: - current = instance$jscomp$0; - } - "function" === typeof ref - ? ref(current) - : (ref.current = current); - } - } - } catch (error) { - captureCommitPhaseError(firstChild, firstChild.return, error); - } - } - if (firstChild === fiber) { - nextEffect = null; - break; - } - current = firstChild.sibling; - if (null !== current) { - current.return = firstChild.return; - nextEffect = current; - break; - } - nextEffect = firstChild.return; - } - } +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$2 = ReactSharedInternals.ReactCurrentDispatcher, @@ -5984,22 +5603,30 @@ var ceil = Math.ceil, subtreeRenderLanesCursor = createCursor(0), workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, + workInProgressRootIncludedLanes = 0, workInProgressRootSkippedLanes = 0, workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, + mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, workInProgressRootRenderTargetTime = Infinity, + nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, legacyErrorBoundariesThatAlreadyFailed = null, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, + pendingPassiveHookEffectsMount = [], + pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, currentEventTime = -1, - currentEventTransitionLane = 0; + currentEventWipLanes = 0, + currentEventPendingLanes = 0, + focusedInstanceHandle = null, + shouldFireAfterActiveInstanceBlur = !1; function requestEventTime() { return 0 !== (executionContext & 48) ? now() @@ -6009,22 +5636,30 @@ function requestEventTime() { } function requestUpdateLane(fiber) { fiber = fiber.mode; - if (0 === (fiber & 1)) return 1; - if (0 === (fiber & 2)) return 99 === getCurrentPriorityLevel() ? 1 : 2; - if (0 !== ReactCurrentBatchConfig.transition) - return ( - 0 === currentEventTransitionLane && - ((fiber = nextTransitionLane), - (nextTransitionLane <<= 1), - 0 === (nextTransitionLane & 8388096) && (nextTransitionLane = 512), - (currentEventTransitionLane = fiber)), - currentEventTransitionLane - ); + 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)) + ? (fiber = findUpdateLane(12, currentEventWipLanes)) : ((fiber = schedulerPriorityToLanePriority(fiber)), - (fiber = findUpdateLane(fiber))); + (fiber = findUpdateLane(fiber, currentEventWipLanes))); return fiber; } function scheduleUpdateOnFiber(fiber, lane, eventTime) { @@ -6055,7 +5690,7 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) : rootsWithPendingDiscreteUpdates.add(fiber)), ensureRootIsScheduled(fiber, eventTime)); - return fiber; + mostRecentlyUpdatedRoot = fiber; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { sourceFiber.lanes |= lane; @@ -6103,42 +5738,45 @@ function ensureRootIsScheduled(root, currentTime) { root === workInProgressRoot ? workInProgressRootRenderLanes : 0 ); currentTime = return_highestLanePriority; - 0 === suspendedLanes - ? (null !== existingCallbackNode && + if (0 === suspendedLanes) + null !== existingCallbackNode && + (existingCallbackNode !== fakeCallbackNode && Scheduler_cancelCallback(existingCallbackNode), (root.callbackNode = null), - (root.callbackPriority = 0)) - : root.callbackPriority !== currentTime && - (null != existingCallbackNode && - Scheduler_cancelCallback(existingCallbackNode), - 15 === currentTime - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? ((syncQueue = [existingCallbackNode]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(existingCallbackNode), - (existingCallbackNode = null)) - : 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)); + (root.callbackPriority = 0)); + else { + 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) { +function performConcurrentWorkOnRoot(root) { currentEventTime = -1; - currentEventTransitionLane = 0; + currentEventPendingLanes = currentEventWipLanes = 0; if (0 !== (executionContext & 48)) throw Error("Should not already be working."); var originalCallbackNode = root.callbackNode; @@ -6149,22 +5787,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(); if ( workInProgressRoot !== root || - workInProgressRootRenderLanes !== didTimeout + workInProgressRootRenderLanes !== exitStatus ) (workInProgressRootRenderTargetTime = now() + 500), - prepareFreshStack(root, didTimeout); + prepareFreshStack(root, exitStatus); do try { workLoopConcurrent(); @@ -6177,17 +5809,19 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ReactCurrentDispatcher$2.current = prevDispatcher; executionContext = prevExecutionContext; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = 0) : ((workInProgressRoot = null), (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); - if (0 !== didTimeout) { - 2 === didTimeout && + (exitStatus = workInProgressRootExitStatus)); + 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 && (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), @@ -6195,7 +5829,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."); @@ -6205,9 +5839,9 @@ function performConcurrentWorkOnRoot(root, didTimeout) { case 3: markRootSuspended$1(root, lanes); if ( - (lanes & 125829120) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + (lanes & 62914560) === lanes && + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { if (0 !== getNextLanes(root, 0)) break; prevExecutionContext = root.suspendedLanes; @@ -6218,7 +5852,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + exitStatus ); break; } @@ -6226,12 +5860,12 @@ function performConcurrentWorkOnRoot(root, didTimeout) { break; case 4: markRootSuspended$1(root, lanes); - if ((lanes & 8388096) === lanes) break; - didTimeout = root.eventTimes; + 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 = didTimeout[index$4]; + index$4 = exitStatus[index$4]; index$4 > prevExecutionContext && (prevExecutionContext = index$4); lanes &= ~prevDispatcher; } @@ -6278,9 +5912,9 @@ function markRootSuspended$1(root, suspendedLanes) { root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$6 = 31 - clz32(suspendedLanes), - lane = 1 << index$6; - root[index$6] = -1; + var index$9 = 31 - clz32(suspendedLanes), + lane = 1 << index$9; + root[index$9] = -1; suspendedLanes &= ~lane; } } @@ -6288,12 +5922,17 @@ function performSyncWorkOnRoot(root) { if (0 !== (executionContext & 48)) throw Error("Should not already be working."); flushPassiveEffects(); - var lanes = + if ( root === workInProgressRoot && 0 !== (root.expiredLanes & workInProgressRootRenderLanes) - ? workInProgressRootRenderLanes - : getNextLanes(root, 0); - var exitStatus = renderRootSync(root, lanes); + ) { + 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 && 2 === exitStatus && ((executionContext |= 64), @@ -6312,6 +5951,11 @@ function performSyncWorkOnRoot(root) { ensureRootIsScheduled(root, now()); return null; } +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes); + subtreeRenderLanes |= lanes; + workInProgressRootIncludedLanes |= lanes; +} function popRenderLanes() { subtreeRenderLanes = subtreeRenderLanesCursor.current; pop(subtreeRenderLanesCursor); @@ -6351,7 +5995,7 @@ function prepareFreshStack(root, lanes) { pop(suspenseStackCursor); break; case 10: - popProvider(interruptedWork.type._context); + popProvider(interruptedWork); break; case 22: case 23: @@ -6361,29 +6005,10 @@ function prepareFreshStack(root, lanes) { } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = lanes; + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; - if (null !== interleavedQueues) { - for (root = 0; root < interleavedQueues.length; root++) - if ( - ((lanes = interleavedQueues[root]), - (timeoutHandle = lanes.interleaved), - null !== timeoutHandle) - ) { - lanes.interleaved = null; - interruptedWork = timeoutHandle.next; - var lastPendingUpdate = lanes.pending; - if (null !== lastPendingUpdate) { - var firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = interruptedWork; - timeoutHandle.next = firstPendingUpdate; - } - lanes.pending = timeoutHandle; - } - interleavedQueues = null; - } } function handleError(root$jscomp$0, thrownValue) { do { @@ -6419,18 +6044,15 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.flags |= 8192; + sourceFiber.flags |= 4096; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - var wakeable = value, - tag = sourceFiber.tag; - if ( - 0 === (sourceFiber.mode & 1) && - (0 === tag || 11 === tag || 15 === tag) - ) { + var wakeable = value; + if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), @@ -6441,15 +6063,15 @@ function handleError(root$jscomp$0, thrownValue) { } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - workInProgress$75 = returnFiber; + workInProgress$76 = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$75.tag)) { - var nextState = workInProgress$75.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$75.memoizedProps; + var props = workInProgress$76.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6461,19 +6083,16 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var wakeables = workInProgress$75.updateQueue; + var wakeables = workInProgress$76.updateQueue; if (null === wakeables) { var updateQueue = new Set(); updateQueue.add(wakeable); - workInProgress$75.updateQueue = updateQueue; + workInProgress$76.updateQueue = updateQueue; } else wakeables.add(wakeable); - if ( - 0 === (workInProgress$75.mode & 1) && - workInProgress$75 !== returnFiber - ) { - workInProgress$75.flags |= 128; - sourceFiber.flags |= 65536; - sourceFiber.flags &= -10053; + 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 { @@ -6504,12 +6123,12 @@ function handleError(root$jscomp$0, thrownValue) { ); wakeable.then(ping, ping); } - workInProgress$75.flags |= 16384; - workInProgress$75.lanes = thrownValue; + workInProgress$76.flags |= 8192; + workInProgress$76.lanes = thrownValue; break a; } - workInProgress$75 = workInProgress$75.return; - } while (null !== workInProgress$75); + 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." @@ -6518,47 +6137,47 @@ function handleError(root$jscomp$0, thrownValue) { 5 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - workInProgress$75 = returnFiber; + workInProgress$76 = returnFiber; do { - switch (workInProgress$75.tag) { + switch (workInProgress$76.tag) { case 3: root = value; - workInProgress$75.flags |= 16384; + workInProgress$76.flags |= 8192; thrownValue &= -thrownValue; - workInProgress$75.lanes |= thrownValue; - var update$76 = createRootErrorUpdate( - workInProgress$75, + workInProgress$76.lanes |= thrownValue; + var update$77 = createRootErrorUpdate( + workInProgress$76, root, thrownValue ); - enqueueCapturedUpdate(workInProgress$75, update$76); + enqueueCapturedUpdate(workInProgress$76, update$77); break a; case 1: root = value; - var ctor = workInProgress$75.type, - instance = workInProgress$75.stateNode; + var ctor = workInProgress$76.type, + instance = workInProgress$76.stateNode; if ( - 0 === (workInProgress$75.flags & 128) && + 0 === (workInProgress$76.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$75.flags |= 16384; + workInProgress$76.flags |= 8192; thrownValue &= -thrownValue; - workInProgress$75.lanes |= thrownValue; - var update$79 = createClassErrorUpdate( - workInProgress$75, + workInProgress$76.lanes |= thrownValue; + var update$80 = createClassErrorUpdate( + workInProgress$76, root, thrownValue ); - enqueueCapturedUpdate(workInProgress$75, update$79); + enqueueCapturedUpdate(workInProgress$76, update$80); break a; } } - workInProgress$75 = workInProgress$75.return; - } while (null !== workInProgress$75); + workInProgress$76 = workInProgress$76.return; + } while (null !== workInProgress$76); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { @@ -6619,25 +6238,47 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.flags & 8192)) { - if ( - ((current = completeWork(current, completedWork, subtreeRenderLanes)), - null !== current) - ) { + if (0 === (completedWork.flags & 4096)) { + current = completeWork(current, completedWork, subtreeRenderLanes); + if (null !== current) { workInProgress = current; return; } + current = completedWork; + if ( + (23 !== current.tag && 22 !== current.tag) || + null === current.memoizedState || + 0 !== (subtreeRenderLanes & 1073741824) || + 0 === (current.mode & 4) + ) { + for (var newChildLanes = 0, child = current.child; null !== child; ) + (newChildLanes |= child.lanes | child.childLanes), + (child = child.sibling); + current.childLanes = newChildLanes; + } + null !== unitOfWork && + 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.flags && + (null !== unitOfWork.lastEffect + ? (unitOfWork.lastEffect.nextEffect = completedWork) + : (unitOfWork.firstEffect = completedWork), + (unitOfWork.lastEffect = completedWork))); } else { current = unwindWork(completedWork); if (null !== current) { - current.flags &= 8191; + current.flags &= 4095; workInProgress = current; return; } null !== unitOfWork && - ((unitOfWork.flags |= 8192), - (unitOfWork.subtreeFlags = 0), - (unitOfWork.deletions = null)); + ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), + (unitOfWork.flags |= 4096)); } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -6658,8 +6299,7 @@ function commitRootImpl(root, renderPriorityLevel) { while (null !== rootWithPendingPassiveEffects); if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - var finishedWork = root.finishedWork, - lanes = root.finishedLanes; + var finishedWork = root.finishedWork; if (null === finishedWork) return null; root.finishedWork = null; root.finishedLanes = 0; @@ -6668,48 +6308,252 @@ function commitRootImpl(root, renderPriorityLevel) { "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); root.callbackNode = null; - root.callbackPriority = 0; - var remainingLanes = finishedWork.lanes | finishedWork.childLanes; - markRootFinished(root, remainingLanes); + 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 & 8) && + 0 === (remainingLanes & 24) && rootsWithPendingDiscreteUpdates.has(root) && rootsWithPendingDiscreteUpdates.delete(root); root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - (0 === (finishedWork.subtreeFlags & 1040) && - 0 === (finishedWork.flags & 1040)) || - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); - remainingLanes = 0 !== (finishedWork.flags & 8054); - 0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes - ? ((remainingLanes = executionContext), - (executionContext |= 32), - (ReactCurrentOwner$2.current = null), - commitBeforeMutationEffects(root, finishedWork), - commitMutationEffects(root, renderPriorityLevel, finishedWork), - (root.current = finishedWork), - commitLayoutEffects(finishedWork, root, lanes), - requestPaint(), - (executionContext = remainingLanes)) - : (root.current = finishedWork); - rootDoesHavePassiveEffects && - ((rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel)); + 1 < finishedWork.flags + ? null !== finishedWork.lastEffect + ? ((finishedWork.lastEffect.nextEffect = finishedWork), + (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(); + } catch (error) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + focusedInstanceHandle = null; + nextEffect = remainingLanes; + do + try { + for (; null !== nextEffect; ) { + var flags = nextEffect.flags; + if (flags & 128) { + var current = nextEffect.alternate; + if (null !== current) { + var currentRef = current.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (flags & 1038) { + case 2: + nextEffect.flags &= -3; + break; + case 6: + nextEffect.flags &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 1024: + nextEffect.flags &= -1025; + break; + case 1028: + nextEffect.flags &= -1025; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + eventTimes = nextEffect; + a: for (noLongerPendingLanes = expirationTimes = eventTimes; ; ) { + index$10 = noLongerPendingLanes; + if ( + injectedHook && + "function" === typeof injectedHook.onCommitFiberUnmount + ) + try { + injectedHook.onCommitFiberUnmount(rendererID, index$10); + } catch (err) {} + switch (index$10.tag) { + case 0: + case 11: + case 14: + case 15: + 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 (noLongerPendingLanes === expirationTimes) break; + for (; null === noLongerPendingLanes.sibling; ) { + if ( + null === noLongerPendingLanes.return || + noLongerPendingLanes.return === expirationTimes + ) + break a; + noLongerPendingLanes = noLongerPendingLanes.return; + } + noLongerPendingLanes.sibling.return = + noLongerPendingLanes.return; + noLongerPendingLanes = noLongerPendingLanes.sibling; + } + } + var alternate = eventTimes.alternate; + detachFiberMutation(eventTimes); + null !== alternate && detachFiberMutation(alternate); + } + nextEffect = nextEffect.nextEffect; + } + } catch (error$87) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error$87); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + root.current = finishedWork; + nextEffect = remainingLanes; + do + try { + 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$jscomp$0 = nextEffect.stateNode; + switch (nextEffect.tag) { + case 5: + current = instance$jscomp$0.canonical; + break; + default: + current = instance$jscomp$0; + } + "function" === typeof ref + ? ref(current) + : (ref.current = current); + } + } + nextEffect = nextEffect.nextEffect; + } + } catch (error$88) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error$88); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + nextEffect = null; + requestPaint(); + executionContext = remainingLanes$jscomp$0; + } else root.current = finishedWork; + if (rootDoesHavePassiveEffects) + (rootDoesHavePassiveEffects = !1), + (rootWithPendingPassiveEffects = root), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel); + else + for (nextEffect = remainingLanes; null !== nextEffect; ) + (renderPriorityLevel = nextEffect.nextEffect), + (nextEffect.nextEffect = 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); - 0 !== (remainingLanes & 1) + 1 === remainingLanes ? root === rootWithNestedUpdates ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - onCommitRoot(finishedWork.stateNode, renderPriorityLevel); + 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), @@ -6720,6 +6564,30 @@ function commitRootImpl(root, renderPriorityLevel) { flushSyncCallbackQueue(); return null; } +function commitBeforeMutationEffects() { + for (; null !== nextEffect; ) { + 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() { + flushPassiveEffects(); + return null; + })); + nextEffect = nextEffect.nextEffect; + } +} function flushPassiveEffects() { if (90 !== pendingPassiveEffectsRenderPriority) { var priorityLevel = @@ -6731,6 +6599,24 @@ function flushPassiveEffects() { } 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; @@ -6739,103 +6625,40 @@ function flushPassiveEffectsImpl() { throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; executionContext |= 32; - for (nextEffect = root.current; null !== nextEffect; ) { - var fiber = nextEffect, - child = fiber.child; - if (0 !== (nextEffect.flags & 16)) { - var deletions = fiber.deletions; - if (null !== deletions) { - for (var i = 0; i < deletions.length; i++) { - var fiberToDelete = deletions[i]; - for (nextEffect = fiberToDelete; null !== nextEffect; ) { - var fiber$jscomp$0 = nextEffect; - switch (fiber$jscomp$0.tag) { - case 0: - case 11: - case 15: - commitHookEffectListUnmount(4, fiber$jscomp$0, fiber); - } - var child$jscomp$0 = fiber$jscomp$0.child; - if (null !== child$jscomp$0) - (child$jscomp$0.return = fiber$jscomp$0), - (nextEffect = child$jscomp$0); - else - for (; null !== nextEffect; ) { - fiber$jscomp$0 = nextEffect; - if (fiber$jscomp$0 === fiberToDelete) { - nextEffect = null; - break; - } - child$jscomp$0 = fiber$jscomp$0.sibling; - if (null !== child$jscomp$0) { - child$jscomp$0.return = fiber$jscomp$0.return; - nextEffect = child$jscomp$0; - break; - } - nextEffect = fiber$jscomp$0.return; - } - } - fiber$jscomp$0 = fiberToDelete.alternate; - detachFiberAfterEffects(fiberToDelete); - null !== fiber$jscomp$0 && detachFiberAfterEffects(fiber$jscomp$0); - } - nextEffect = fiber; - } - } - if (0 !== (fiber.subtreeFlags & 1040) && null !== child) - (child.return = fiber), (nextEffect = child); - else - a: for (; null !== nextEffect; ) { - fiber = nextEffect; - if (0 !== (fiber.flags & 1024)) - switch (fiber.tag) { - case 0: - case 11: - case 15: - commitHookEffectListUnmount(5, fiber, fiber.return); - } - child = fiber.sibling; - if (null !== child) { - child.return = fiber.return; - nextEffect = child; - break a; - } - nextEffect = fiber.return; + 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); } } - for (nextEffect = root = root.current; null !== nextEffect; ) - if ( - ((fiber = nextEffect), - (child = fiber.child), - 0 !== (fiber.subtreeFlags & 1040) && null !== child) - ) - (child.return = fiber), (nextEffect = child); - else - a: for (fiber = root; null !== nextEffect; ) { - child = nextEffect; - if (0 !== (child.flags & 1024)) - try { - switch (child.tag) { - case 0: - case 11: - case 15: - commitHookEffectListMount(5, child); - } - } catch (error) { - captureCommitPhaseError(child, child.return, error); - } - if (child === fiber) { - nextEffect = null; - break a; - } - deletions = child.sibling; - if (null !== deletions) { - deletions.return = child.return; - nextEffect = deletions; - break a; - } - nextEffect = child.return; - } + unmountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + for (i = 0; i < unmountEffects.length; i += 2) { + effect$93 = unmountEffects[i]; + fiber = unmountEffects[i + 1]; + try { + 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); + } + } + 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; @@ -6850,50 +6673,42 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { (markRootUpdated(rootFiber, 1, sourceFiber), ensureRootIsScheduled(rootFiber, sourceFiber)); } -function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { +function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); else - for ( - nearestMountedAncestor = sourceFiber.return; - null !== nearestMountedAncestor; - - ) { - if (3 === nearestMountedAncestor.tag) { - captureCommitPhaseErrorOnRoot( - nearestMountedAncestor, - sourceFiber, - error - ); + for (var fiber = sourceFiber.return; null !== fiber; ) { + if (3 === fiber.tag) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); break; - } else if (1 === nearestMountedAncestor.tag) { - var instance = nearestMountedAncestor.stateNode; + } else if (1 === fiber.tag) { + var instance = fiber.stateNode; if ( - "function" === - typeof nearestMountedAncestor.type.getDerivedStateFromError || + "function" === typeof fiber.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 1 - ); - enqueueUpdate(nearestMountedAncestor, sourceFiber); - sourceFiber = requestEventTime(); - nearestMountedAncestor = markUpdateLaneFromFiberToRoot( - nearestMountedAncestor, - 1 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 1, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + 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; } } - nearestMountedAncestor = nearestMountedAncestor.return; + fiber = fiber.return; } } function pingSuspendedRoot(root, wakeable, pingedLanes) { @@ -6905,7 +6720,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && (4 === workInProgressRootExitStatus || (3 === workInProgressRootExitStatus && - (workInProgressRootRenderLanes & 125829120) === + (workInProgressRootRenderLanes & 62914560) === workInProgressRootRenderLanes && 500 > now() - globalMostRecentFallbackTime) ? prepareFreshStack(root, 0) @@ -6918,13 +6733,14 @@ function resolveRetryWakeable(boundaryFiber, wakeable) { wakeable = 0; 0 === wakeable && ((wakeable = boundaryFiber.mode), - 0 === (wakeable & 1) + 0 === (wakeable & 2) ? (wakeable = 1) - : 0 === (wakeable & 2) + : 0 === (wakeable & 4) ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) - : ((wakeable = nextRetryLane), - (nextRetryLane <<= 1), - 0 === (nextRetryLane & 125829120) && (nextRetryLane = 8388608))); + : (0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes), + (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), + 0 === wakeable && (wakeable = 4194304))); retryCache = requestEventTime(); boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); null !== boundaryFiber && @@ -6940,83 +6756,78 @@ beginWork$1 = function(current, workInProgress, renderLanes) { didPerformWorkStackCursor.current ) didReceiveUpdate = !0; + else if (0 !== (renderLanes & updateLanes)) + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { - if (0 === (renderLanes & updateLanes)) { - 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.type._context; - var nextValue = workInProgress.memoizedProps.value; - push(valueCursor, updateLanes._currentValue2); - updateLanes._currentValue2 = nextValue; - 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( + 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 ); - return null !== workInProgress ? workInProgress.sibling : null; - } push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.flags & 128)) { - if (updateLanes) - return updateSuspenseListComponent( - current, - workInProgress, - renderLanes - ); - workInProgress.flags |= 128; - } - nextValue = workInProgress.memoizedState; - null !== nextValue && - ((nextValue.rendering = null), - (nextValue.tail = null), - (nextValue.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (updateLanes) break; - else return null; - case 22: - case 23: - return ( - (workInProgress.lanes = 0), - updateOffscreenComponent(current, workInProgress, renderLanes) + workInProgress = bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderLanes ); - } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderLanes - ); + 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, + renderLanes + ); + 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 22: + case 23: + return ( + (workInProgress.lanes = 0), + updateOffscreenComponent(current, workInProgress, renderLanes) + ); } - didReceiveUpdate = 0 !== (current.flags & 65536) ? !0 : !1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else didReceiveUpdate = !1; workInProgress.lanes = 0; @@ -7028,22 +6839,22 @@ beginWork$1 = function(current, workInProgress, renderLanes) { (workInProgress.alternate = null), (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - nextValue = getMaskedContext(workInProgress, contextStackCursor.current); + context = getMaskedContext(workInProgress, contextStackCursor.current); prepareToReadContext(workInProgress, renderLanes); - nextValue = renderWithHooks( + context = renderWithHooks( null, workInProgress, updateLanes, current, - nextValue, + context, renderLanes ); workInProgress.flags |= 1; if ( - "object" === typeof nextValue && - null !== nextValue && - "function" === typeof nextValue.render && - void 0 === nextValue.$$typeof + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof ) { workInProgress.tag = 1; workInProgress.memoizedState = null; @@ -7053,8 +6864,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { pushContextProvider(workInProgress); } else hasContext = !1; workInProgress.memoizedState = - null !== nextValue.state && void 0 !== nextValue.state - ? nextValue.state + null !== context.state && void 0 !== context.state + ? context.state : null; initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; @@ -7065,9 +6876,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { getDerivedStateFromProps, current ); - nextValue.updater = classComponentUpdater; - workInProgress.stateNode = nextValue; - nextValue._reactInternals = workInProgress; + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternals = workInProgress; mountClassInstance(workInProgress, updateLanes, current, renderLanes); workInProgress = finishClassComponent( null, @@ -7079,28 +6890,28 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); } else (workInProgress.tag = 0), - reconcileChildren(null, workInProgress, nextValue, renderLanes), + reconcileChildren(null, workInProgress, context, renderLanes), (workInProgress = workInProgress.child); return workInProgress; case 16: - nextValue = workInProgress.elementType; + context = workInProgress.elementType; a: { null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - hasContext = nextValue._init; - nextValue = hasContext(nextValue._payload); - workInProgress.type = nextValue; - hasContext = workInProgress.tag = resolveLazyComponentTag(nextValue); - current = resolveDefaultProps(nextValue, current); + hasContext = context._init; + context = hasContext(context._payload); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current = resolveDefaultProps(context, current); switch (hasContext) { case 0: workInProgress = updateFunctionComponent( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7109,7 +6920,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateClassComponent( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7118,7 +6929,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateForwardRef( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7127,8 +6938,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateMemoComponent( null, workInProgress, - nextValue, - resolveDefaultProps(nextValue.type, current), + context, + resolveDefaultProps(context.type, current), updateLanes, renderLanes ); @@ -7136,7 +6947,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } throw Error( "Element type is invalid. Received a promise that resolves to: " + - nextValue + + context + ". Lazy element type must resolve to a class or function." ); } @@ -7144,32 +6955,32 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 0: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateFunctionComponent( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); case 1: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateClassComponent( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); @@ -7180,18 +6991,19 @@ beginWork$1 = function(current, workInProgress, renderLanes) { 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." ); - nextValue = workInProgress.pendingProps; - updateLanes = workInProgress.memoizedState.element; + updateLanes = workInProgress.pendingProps; + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, nextValue, null, renderLanes); - nextValue = workInProgress.memoizedState.element; - nextValue === updateLanes + processUpdateQueue(workInProgress, updateLanes, null, renderLanes); + updateLanes = workInProgress.memoizedState.element; + updateLanes === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, renderLanes )) - : (reconcileChildren(current, workInProgress, nextValue, renderLanes), + : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), (workInProgress = workInProgress.child)); return workInProgress; case 5: @@ -7231,16 +7043,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 11: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateForwardRef( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); @@ -7277,21 +7089,27 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 10: a: { updateLanes = workInProgress.type._context; - nextValue = workInProgress.pendingProps; + context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; - hasContext = nextValue.value; - push(valueCursor, updateLanes._currentValue2); - updateLanes._currentValue2 = hasContext; - if (null !== getDerivedStateFromProps) { - var oldValue = getDerivedStateFromProps.value; - hasContext = objectIs(oldValue, hasContext) - ? 0 - : ("function" === typeof updateLanes._calculateChangedBits - ? updateLanes._calculateChangedBits(oldValue, hasContext) - : 1073741823) | 0; - if (0 === hasContext) { + hasContext = context.value; + var context$jscomp$0 = workInProgress.type._context; + push(valueCursor, context$jscomp$0._currentValue2); + context$jscomp$0._currentValue2 = hasContext; + if (null !== getDerivedStateFromProps) + if ( + ((context$jscomp$0 = getDerivedStateFromProps.value), + (hasContext = objectIs(context$jscomp$0, hasContext) + ? 0 + : ("function" === typeof updateLanes._calculateChangedBits + ? updateLanes._calculateChangedBits( + context$jscomp$0, + hasContext + ) + : 1073741823) | 0), + 0 === hasContext) + ) { if ( - getDerivedStateFromProps.children === nextValue.children && + getDerivedStateFromProps.children === context.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -7303,14 +7121,15 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } } else for ( - oldValue = workInProgress.child, - null !== oldValue && (oldValue.return = workInProgress); - null !== oldValue; + context$jscomp$0 = workInProgress.child, + null !== context$jscomp$0 && + (context$jscomp$0.return = workInProgress); + null !== context$jscomp$0; ) { - var list = oldValue.dependencies; + var list = context$jscomp$0.dependencies; if (null !== list) { - getDerivedStateFromProps = oldValue.child; + getDerivedStateFromProps = context$jscomp$0.child; for ( var dependency = list.firstContext; null !== dependency; @@ -7320,24 +7139,20 @@ beginWork$1 = function(current, workInProgress, renderLanes) { dependency.context === updateLanes && 0 !== (dependency.observedBits & hasContext) ) { - if (1 === oldValue.tag) { - dependency = createUpdate(-1, renderLanes & -renderLanes); - dependency.tag = 2; - var updateQueue = oldValue.updateQueue; - if (null !== updateQueue) { - updateQueue = updateQueue.shared; - var pending = updateQueue.pending; - null === pending - ? (dependency.next = dependency) - : ((dependency.next = pending.next), - (pending.next = dependency)); - updateQueue.pending = dependency; - } - } - oldValue.lanes |= renderLanes; - dependency = oldValue.alternate; + 1 === context$jscomp$0.tag && + ((dependency = createUpdate( + -1, + renderLanes & -renderLanes + )), + (dependency.tag = 2), + enqueueUpdate(context$jscomp$0, dependency)); + context$jscomp$0.lanes |= renderLanes; + dependency = context$jscomp$0.alternate; null !== dependency && (dependency.lanes |= renderLanes); - scheduleWorkOnParentPath(oldValue.return, renderLanes); + scheduleWorkOnParentPath( + context$jscomp$0.return, + renderLanes + ); list.lanes |= renderLanes; break; } @@ -7345,16 +7160,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } } else getDerivedStateFromProps = - 10 === oldValue.tag - ? oldValue.type === workInProgress.type + 10 === context$jscomp$0.tag + ? context$jscomp$0.type === workInProgress.type ? null - : oldValue.child - : oldValue.child; + : context$jscomp$0.child + : context$jscomp$0.child; if (null !== getDerivedStateFromProps) - getDerivedStateFromProps.return = oldValue; + getDerivedStateFromProps.return = context$jscomp$0; else for ( - getDerivedStateFromProps = oldValue; + getDerivedStateFromProps = context$jscomp$0; null !== getDerivedStateFromProps; ) { @@ -7362,21 +7177,20 @@ beginWork$1 = function(current, workInProgress, renderLanes) { getDerivedStateFromProps = null; break; } - oldValue = getDerivedStateFromProps.sibling; - if (null !== oldValue) { - oldValue.return = getDerivedStateFromProps.return; - getDerivedStateFromProps = oldValue; + context$jscomp$0 = getDerivedStateFromProps.sibling; + if (null !== context$jscomp$0) { + context$jscomp$0.return = getDerivedStateFromProps.return; + getDerivedStateFromProps = context$jscomp$0; break; } getDerivedStateFromProps = getDerivedStateFromProps.return; } - oldValue = getDerivedStateFromProps; + context$jscomp$0 = getDerivedStateFromProps; } - } reconcileChildren( current, workInProgress, - nextValue.children, + context.children, renderLanes ); workInProgress = workInProgress.child; @@ -7384,28 +7198,28 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return workInProgress; case 9: return ( - (nextValue = workInProgress.type), + (context = workInProgress.type), (hasContext = workInProgress.pendingProps), (updateLanes = hasContext.children), prepareToReadContext(workInProgress, renderLanes), - (nextValue = readContext(nextValue, hasContext.unstable_observedBits)), - (updateLanes = updateLanes(nextValue)), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateLanes = updateLanes(context)), (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); case 14: return ( - (nextValue = workInProgress.type), + (context = workInProgress.type), (hasContext = resolveDefaultProps( - nextValue, + context, workInProgress.pendingProps )), - (hasContext = resolveDefaultProps(nextValue.type, hasContext)), + (hasContext = resolveDefaultProps(context.type, hasContext)), updateMemoComponent( current, workInProgress, - nextValue, + context, hasContext, updateLanes, renderLanes @@ -7423,11 +7237,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 17: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), @@ -7437,8 +7251,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), prepareToReadContext(workInProgress, renderLanes), - constructClassInstance(workInProgress, updateLanes, nextValue), - mountClassInstance(workInProgress, updateLanes, nextValue, renderLanes), + constructClassInstance(workInProgress, updateLanes, context), + mountClassInstance(workInProgress, updateLanes, context, renderLanes), finishClassComponent( null, workInProgress, @@ -7470,8 +7284,8 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.subtreeFlags = this.flags = 0; - this.deletions = null; + this.flags = 0; + this.lastEffect = this.firstEffect = this.nextEffect = null; this.childLanes = this.lanes = 0; this.alternate = null; } @@ -7509,9 +7323,9 @@ function createWorkInProgress(current, pendingProps) { : ((workInProgress.pendingProps = pendingProps), (workInProgress.type = current.type), (workInProgress.flags = 0), - (workInProgress.subtreeFlags = 0), - (workInProgress.deletions = null)); - workInProgress.flags = current.flags & 131072; + (workInProgress.nextEffect = null), + (workInProgress.firstEffect = null), + (workInProgress.lastEffect = null)); workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -7546,18 +7360,15 @@ function createFiberFromTypeAndProps( return createFiberFromFragment(pendingProps.children, mode, lanes, key); case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = 8; - mode |= 8; + mode |= 16; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; - 1 <= - (null == pendingProps.unstable_level - ? 1 - : pendingProps.unstable_level) && (mode |= 16); + mode |= 1; break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.lanes = lanes), @@ -7744,8 +7555,7 @@ function updateContainer(element, container, parentComponent, callback) { callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - element = scheduleUpdateOnFiber(current, lane, eventTime); - null !== element && entangleTransitions(element, current, lane); + scheduleUpdateOnFiber(current, lane, eventTime); return lane; } function emptyFindFiberByHostInstance() { @@ -7777,10 +7587,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_914 = { + devToolsConfig$jscomp$inline_865 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "17.0.2", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -7795,11 +7605,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1178 = { - bundleType: devToolsConfig$jscomp$inline_914.bundleType, - version: devToolsConfig$jscomp$inline_914.version, - rendererPackageName: devToolsConfig$jscomp$inline_914.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_914.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, @@ -7814,7 +7624,7 @@ var internals$jscomp$inline_1178 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_914.findFiberByHostInstance || + devToolsConfig$jscomp$inline_865.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, @@ -7823,16 +7633,16 @@ var internals$jscomp$inline_1178 = { getCurrentFiber: null }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1179 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1055 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1179.isDisabled && - hook$jscomp$inline_1179.supportsFiber + !hook$jscomp$inline_1055.isDisabled && + hook$jscomp$inline_1055.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1179.inject( - internals$jscomp$inline_1178 + (rendererID = hook$jscomp$inline_1055.inject( + internals$jscomp$inline_1054 )), - (injectedHook = hook$jscomp$inline_1179); + (injectedHook = hook$jscomp$inline_1055); } catch (err) {} } exports.createPortal = function(children, containerTag) { @@ -7874,11 +7684,10 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var JSCompiler_inline_result = createFiber(3, null, null, 0); - root.current = JSCompiler_inline_result; - JSCompiler_inline_result.stateNode = root; - JSCompiler_inline_result.memoizedState = { element: null }; - initializeUpdateQueue(JSCompiler_inline_result); + var uninitializedFiber = createFiber(3, null, null, 0); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 96243f376c9..51f399468cd 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_216 = { +var injectedNamesToPlugins$jscomp$inline_223 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -955,34 +955,34 @@ var injectedNamesToPlugins$jscomp$inline_216 = { } } }, - isOrderingDirty$jscomp$inline_217 = !1, - pluginName$jscomp$inline_218; -for (pluginName$jscomp$inline_218 in injectedNamesToPlugins$jscomp$inline_216) + isOrderingDirty$jscomp$inline_224 = !1, + pluginName$jscomp$inline_225; +for (pluginName$jscomp$inline_225 in injectedNamesToPlugins$jscomp$inline_223) if ( - injectedNamesToPlugins$jscomp$inline_216.hasOwnProperty( - pluginName$jscomp$inline_218 + injectedNamesToPlugins$jscomp$inline_223.hasOwnProperty( + pluginName$jscomp$inline_225 ) ) { - var pluginModule$jscomp$inline_219 = - injectedNamesToPlugins$jscomp$inline_216[pluginName$jscomp$inline_218]; + var pluginModule$jscomp$inline_226 = + injectedNamesToPlugins$jscomp$inline_223[pluginName$jscomp$inline_225]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_218) || - namesToPlugins[pluginName$jscomp$inline_218] !== - pluginModule$jscomp$inline_219 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_225) || + namesToPlugins[pluginName$jscomp$inline_225] !== + pluginModule$jscomp$inline_226 ) { - if (namesToPlugins[pluginName$jscomp$inline_218]) + if (namesToPlugins[pluginName$jscomp$inline_225]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_218 + + pluginName$jscomp$inline_225 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_218 - ] = pluginModule$jscomp$inline_219; - isOrderingDirty$jscomp$inline_217 = !0; + pluginName$jscomp$inline_225 + ] = pluginModule$jscomp$inline_226; + isOrderingDirty$jscomp$inline_224 = !0; } } -isOrderingDirty$jscomp$inline_217 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_224 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -997,11 +997,7 @@ getNodeFromInstance = function(inst) { }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ onChange: function(from, to, blockNativeResponder) { - (from || to).stateNode.canonical._internalInstanceHandle - ? (from && - nativeFabricUIManager.setIsJSResponder(from.stateNode.node, !1), - to && nativeFabricUIManager.setIsJSResponder(to.stateNode.node, !0)) - : null !== to + null !== to ? ReactNativePrivateInterface.UIManager.setJSResponder( to.stateNode.canonical._nativeTag, blockNativeResponder @@ -1025,8 +1021,7 @@ var ReactSharedInternals = REACT_LAZY_TYPE = 60116, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, - REACT_LEGACY_HIDDEN_TYPE = 60131, - REACT_CACHE_TYPE = 60132; + REACT_LEGACY_HIDDEN_TYPE = 60131; if ("function" === typeof Symbol && Symbol.for) { var symbolFor = Symbol.for; REACT_ELEMENT_TYPE = symbolFor("react.element"); @@ -1045,7 +1040,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); - REACT_CACHE_TYPE = symbolFor("react.cache"); } var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { @@ -1072,8 +1066,6 @@ function getComponentName(type) { return "Suspense"; case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList"; - case REACT_CACHE_TYPE: - return "Cache"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -1107,7 +1099,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.flags & 2050) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1195,14 +1187,19 @@ function findCurrentFiberUsingSlowPath(fiber) { } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); - return null !== parent ? findCurrentHostFiberImpl(parent) : null; -} -function findCurrentHostFiberImpl(node) { - if (5 === node.tag || 6 === node.tag) return node; - for (node = node.child; null !== node; ) { - var match = findCurrentHostFiberImpl(node); - if (null !== match) return match; - node = node.sibling; + if (!parent) return null; + for (var node = parent; ; ) { + if (5 === node.tag || 6 === node.tag) return node; + if (node.child) (node.child.return = node), (node = node.child); + else { + if (node === parent) break; + for (; !node.sibling; ) { + if (!node.return || node.return === parent) return null; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } } return null; } @@ -1529,342 +1526,6 @@ function dispatchEvent(target, topLevelType, nativeEvent) { } }); } -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; -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" - ); -var requestPaint = - void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, - syncQueue = null, - immediateQueueCallbackNode = null, - isFlushingSyncQueue = !1, - initialTimeMs = Scheduler_now(), - now = - 1e4 > initialTimeMs - ? Scheduler_now - : function() { - return Scheduler_now() - initialTimeMs; - }; -function getCurrentPriorityLevel() { - switch (Scheduler_getCurrentPriorityLevel()) { - case Scheduler_ImmediatePriority: - return 99; - case Scheduler_UserBlockingPriority: - return 98; - case Scheduler_NormalPriority: - return 97; - case Scheduler_LowPriority: - return 96; - case Scheduler_IdlePriority: - return 95; - default: - throw Error("Unknown priority level."); - } -} -function reactPriorityToSchedulerPriority(reactPriorityLevel) { - switch (reactPriorityLevel) { - case 99: - return Scheduler_ImmediatePriority; - case 98: - return Scheduler_UserBlockingPriority; - case 97: - return Scheduler_NormalPriority; - case 96: - return Scheduler_LowPriority; - case 95: - return Scheduler_IdlePriority; - default: - throw Error("Unknown priority level."); - } -} -function runWithPriority(reactPriorityLevel, fn) { - reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_runWithPriority(reactPriorityLevel, fn); -} -function scheduleCallback(reactPriorityLevel, callback, options) { - reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); -} -function flushSyncCallbackQueue() { - if (null !== immediateQueueCallbackNode) { - var node = immediateQueueCallbackNode; - immediateQueueCallbackNode = null; - Scheduler_cancelCallback(node); - } - flushSyncCallbackQueueImpl(); -} -function flushSyncCallbackQueueImpl() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var i = 0; - try { - var queue = syncQueue; - runWithPriority(99, function() { - for (; i < queue.length; i++) { - var callback = queue[i]; - do callback = callback(!0); - while (null !== callback); - } - }); - syncQueue = null; - } catch (error) { - throw (null !== syncQueue && (syncQueue = syncQueue.slice(i + 1)), - Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueue - ), - error); - } finally { - isFlushingSyncQueue = !1; - } - } -} -var nextTransitionLane = 512, - nextRetryLane = 8388608, - return_highestLanePriority = 8; -function getHighestPriorityLanes(lanes) { - switch (lanes & -lanes) { - case 1: - return (return_highestLanePriority = 15), 1; - case 2: - return (return_highestLanePriority = 14), 2; - case 4: - return (return_highestLanePriority = 13), 4; - case 8: - return (return_highestLanePriority = 12), 8; - case 16: - return (return_highestLanePriority = 11), 16; - case 32: - return (return_highestLanePriority = 10), 32; - case 64: - return (return_highestLanePriority = 9), 64; - case 128: - return (return_highestLanePriority = 8), 128; - case 256: - return (return_highestLanePriority = 7), 256; - case 512: - case 1024: - case 2048: - case 4096: - case 8192: - case 16384: - case 32768: - case 65536: - case 131072: - case 262144: - case 524288: - case 1048576: - case 2097152: - case 4194304: - return (return_highestLanePriority = 6), lanes & 8388096; - case 8388608: - case 16777216: - case 33554432: - case 67108864: - return (return_highestLanePriority = 5), lanes & 125829120; - case 134217728: - return (return_highestLanePriority = 4), 134217728; - case 268435456: - return (return_highestLanePriority = 3), 268435456; - case 536870912: - return (return_highestLanePriority = 2), 536870912; - case 1073741824: - return (return_highestLanePriority = 1), 1073741824; - default: - return (return_highestLanePriority = 8), 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; - 0 !== expiredLanes - ? ((nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 15)) - : ((expiredLanes = pendingLanes & 268435455), - 0 !== expiredLanes - ? ((pendingLanes = expiredLanes & ~suspendedLanes), - 0 !== pendingLanes - ? ((nextLanes = getHighestPriorityLanes(pendingLanes)), - (nextLanePriority = return_highestLanePriority)) - : ((pingedLanes &= expiredLanes), - 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)))) - : ((pendingLanes &= ~suspendedLanes), - 0 !== pendingLanes - ? ((nextLanes = getHighestPriorityLanes(pendingLanes)), - (nextLanePriority = return_highestLanePriority)) - : 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)))); - if (0 === nextLanes) return 0; - if ( - 0 !== wipLanes && - wipLanes !== nextLanes && - 0 === (wipLanes & suspendedLanes) - ) { - getHighestPriorityLanes(wipLanes); - suspendedLanes = return_highestLanePriority; - if ( - nextLanePriority <= suspendedLanes || - (8 === nextLanePriority && 6 === suspendedLanes) - ) - return wipLanes; - return_highestLanePriority = nextLanePriority; - } - wipLanes = root.entangledLanes; - if (0 !== wipLanes) - for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) - (nextLanePriority = 31 - clz32(wipLanes)), - (suspendedLanes = 1 << nextLanePriority), - (nextLanes |= root[nextLanePriority]), - (wipLanes &= ~suspendedLanes); - return nextLanes; -} -function getLanesToRetrySynchronouslyOnError(root) { - root = root.pendingLanes & -1073741825; - return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; -} -function findUpdateLane(lanePriority) { - switch (lanePriority) { - case 15: - return 1; - case 14: - return 2; - case 12: - return 8; - case 10: - return 32; - case 8: - return 128; - case 2: - return 536870912; - } - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); -} -function createLaneMap(initial) { - for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); - return laneMap; -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; - 536870912 !== updateLane && - ((root.suspendedLanes = 0), (root.pingedLanes = 0)); - root = root.eventTimes; - updateLane = 31 - clz32(updateLane); - root[updateLane] = eventTime; -} -function markRootFinished(root, remainingLanes) { - var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; - root.pendingLanes = remainingLanes; - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes; - root.mutableReadLanes &= remainingLanes; - root.entangledLanes &= remainingLanes; - remainingLanes = root.entanglements; - var eventTimes = root.eventTimes; - for (root = root.expirationTimes; 0 < noLongerPendingLanes; ) { - var index$7 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$7; - remainingLanes[index$7] = 0; - eventTimes[index$7] = -1; - root[index$7] = -1; - noLongerPendingLanes &= ~lane; - } -} -function markRootEntangled(root, entangledLanes) { - var rootEntangledLanes = (root.entangledLanes |= entangledLanes); - for (root = root.entanglements; rootEntangledLanes; ) { - var index$8 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$8; - (lane & entangledLanes) | (root[index$8] & entangledLanes) && - (root[index$8] |= entangledLanes); - rootEntangledLanes &= ~lane; - } -} -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_now$1 = 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$1(); 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." @@ -2081,17 +1742,310 @@ function invalidateContextProvider(workInProgress, type, didChange) { } var rendererID = null, injectedHook = null, - isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__; -function onCommitRoot(root, priorityLevel) { - if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) - try { - injectedHook.onCommitFiberRoot( - rendererID, - root, - priorityLevel, - 128 === (root.current.flags & 128) + 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." ); - } catch (err) {} + } +} +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$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; +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" + ); +var fakeCallbackNode = {}, + requestPaint = + void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, + syncQueue = null, + immediateQueueCallbackNode = null, + isFlushingSyncQueue = !1, + initialTimeMs$1 = Scheduler_now$1(), + now = + 1e4 > initialTimeMs$1 + ? Scheduler_now$1 + : function() { + return Scheduler_now$1() - initialTimeMs$1; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return 99; + case Scheduler_UserBlockingPriority: + return 98; + case Scheduler_NormalPriority: + return 97; + case Scheduler_LowPriority: + return 96; + case Scheduler_IdlePriority: + return 95; + default: + throw Error("Unknown priority level."); + } +} +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case 99: + return Scheduler_ImmediatePriority; + case 98: + return Scheduler_UserBlockingPriority; + case 97: + return Scheduler_NormalPriority; + case 96: + return Scheduler_LowPriority; + case 95: + return Scheduler_IdlePriority; + default: + throw Error("Unknown priority level."); + } +} +function runWithPriority(reactPriorityLevel, fn) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(reactPriorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); +} +function flushSyncCallbackQueue() { + if (null !== immediateQueueCallbackNode) { + var node = immediateQueueCallbackNode; + immediateQueueCallbackNode = null; + Scheduler_cancelCallback(node); + } + flushSyncCallbackQueueImpl(); +} +function flushSyncCallbackQueueImpl() { + if (!isFlushingSyncQueue && null !== syncQueue) { + isFlushingSyncQueue = !0; + var i = 0; + try { + var queue = syncQueue; + runWithPriority(99, function() { + for (; i < queue.length; i++) { + var callback = queue[i]; + do callback = callback(!0); + while (null !== callback); + } + }); + syncQueue = null; + } catch (error) { + throw (null !== syncQueue && (syncQueue = syncQueue.slice(i + 1)), + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueue + ), + error); + } finally { + isFlushingSyncQueue = !1; + } + } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { @@ -2159,10 +2113,10 @@ var valueCursor = createCursor(null), function resetContextDependencies() { lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; } -function popProvider(context) { +function popProvider(providerFiber) { var currentValue = valueCursor.current; pop(valueCursor); - context._currentValue2 = currentValue; + providerFiber.type._context._currentValue2 = currentValue; } function scheduleWorkOnParentPath(parent, renderLanes) { for (; null !== parent; ) { @@ -2213,14 +2167,13 @@ function readContext(context, observedBits) { } return context._currentValue2; } -var interleavedQueues = null, - hasForceUpdate = !1; +var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, firstBaseUpdate: null, lastBaseUpdate: null, - shared: { pending: null, interleaved: null, lanes: 0 }, + shared: { pending: null }, effects: null }; } @@ -2246,32 +2199,14 @@ function createUpdate(eventTime, lane) { }; } function enqueueUpdate(fiber, update) { - var updateQueue = fiber.updateQueue; - null !== updateQueue && - ((updateQueue = updateQueue.shared), - null !== workInProgressRoot && 0 !== (fiber.mode & 1) - ? ((fiber = updateQueue.interleaved), - null === fiber - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [updateQueue]) - : interleavedQueues.push(updateQueue)) - : ((update.next = fiber.next), (fiber.next = update)), - (updateQueue.interleaved = update)) - : ((fiber = updateQueue.pending), - null === fiber - ? (update.next = update) - : ((update.next = fiber.next), (fiber.next = update)), - (updateQueue.pending = update))); -} -function entangleTransitions(root, fiber, lane) { fiber = fiber.updateQueue; - if (null !== fiber && ((fiber = fiber.shared), 0 !== (lane & 8388096))) { - var queueLanes = fiber.lanes; - queueLanes &= root.pendingLanes; - lane |= queueLanes; - fiber.lanes = lane; - markRootEntangled(root, lane); + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; } } function enqueueCapturedUpdate(workInProgress, capturedUpdate) { @@ -2340,110 +2275,111 @@ function processUpdateQueue( : (lastBaseUpdate.next = firstPendingUpdate); lastBaseUpdate = lastPendingUpdate; var current = workInProgress$jscomp$0.alternate; - null !== current && - ((current = current.updateQueue), - (pendingQueue = current.lastBaseUpdate), - pendingQueue !== lastBaseUpdate && - (null === pendingQueue + if (null !== current) { + current = current.updateQueue; + var currentLastBaseUpdate = current.lastBaseUpdate; + currentLastBaseUpdate !== lastBaseUpdate && + (null === currentLastBaseUpdate ? (current.firstBaseUpdate = firstPendingUpdate) - : (pendingQueue.next = firstPendingUpdate), - (current.lastBaseUpdate = lastPendingUpdate))); + : (currentLastBaseUpdate.next = firstPendingUpdate), + (current.lastBaseUpdate = lastPendingUpdate)); + } } if (null !== firstBaseUpdate) { - var newState = queue.baseState; + currentLastBaseUpdate = queue.baseState; lastBaseUpdate = 0; current = firstPendingUpdate = lastPendingUpdate = null; - pendingQueue = firstBaseUpdate; do { - var updateLane = pendingQueue.lane, - updateEventTime = pendingQueue.eventTime; - if ((renderLanes & updateLane) === updateLane) { + pendingQueue = firstBaseUpdate.lane; + var updateEventTime = firstBaseUpdate.eventTime; + if ((renderLanes & pendingQueue) === pendingQueue) { null !== current && (current = current.next = { eventTime: updateEventTime, lane: 0, - tag: pendingQueue.tag, - payload: pendingQueue.payload, - callback: pendingQueue.callback, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null }); a: { var workInProgress = workInProgress$jscomp$0, - update = pendingQueue; - updateLane = props; + update = firstBaseUpdate; + pendingQueue = props; updateEventTime = instance; switch (update.tag) { case 1: workInProgress = update.payload; if ("function" === typeof workInProgress) { - newState = workInProgress.call( + currentLastBaseUpdate = workInProgress.call( updateEventTime, - newState, - updateLane + currentLastBaseUpdate, + pendingQueue ); break a; } - newState = workInProgress; + currentLastBaseUpdate = workInProgress; break a; case 3: - workInProgress.flags = (workInProgress.flags & -16385) | 128; + workInProgress.flags = (workInProgress.flags & -8193) | 64; case 0: workInProgress = update.payload; - updateLane = + pendingQueue = "function" === typeof workInProgress - ? workInProgress.call(updateEventTime, newState, updateLane) + ? workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ) : workInProgress; - if (null === updateLane || void 0 === updateLane) break a; - newState = Object.assign({}, newState, updateLane); + if (null === pendingQueue || void 0 === pendingQueue) break a; + currentLastBaseUpdate = Object.assign( + {}, + currentLastBaseUpdate, + pendingQueue + ); break a; case 2: hasForceUpdate = !0; } } - null !== pendingQueue.callback && - ((workInProgress$jscomp$0.flags |= 64), - (updateLane = queue.effects), - null === updateLane - ? (queue.effects = [pendingQueue]) - : updateLane.push(pendingQueue)); + null !== firstBaseUpdate.callback && + ((workInProgress$jscomp$0.flags |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [firstBaseUpdate]) + : pendingQueue.push(firstBaseUpdate)); } else (updateEventTime = { eventTime: updateEventTime, - lane: updateLane, - tag: pendingQueue.tag, - payload: pendingQueue.payload, - callback: pendingQueue.callback, + lane: pendingQueue, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null }), null === current ? ((firstPendingUpdate = current = updateEventTime), - (lastPendingUpdate = newState)) + (lastPendingUpdate = currentLastBaseUpdate)) : (current = current.next = updateEventTime), - (lastBaseUpdate |= updateLane); - pendingQueue = pendingQueue.next; - if (null === pendingQueue) + (lastBaseUpdate |= pendingQueue); + firstBaseUpdate = firstBaseUpdate.next; + if (null === firstBaseUpdate) if (((pendingQueue = queue.shared.pending), null === pendingQueue)) break; else - (updateLane = pendingQueue), - (pendingQueue = updateLane.next), - (updateLane.next = null), - (queue.lastBaseUpdate = updateLane), + (firstBaseUpdate = pendingQueue.next), + (pendingQueue.next = null), + (queue.lastBaseUpdate = pendingQueue), (queue.shared.pending = null); } while (1); - null === current && (lastPendingUpdate = newState); + null === current && (lastPendingUpdate = currentLastBaseUpdate); queue.baseState = lastPendingUpdate; queue.firstBaseUpdate = firstPendingUpdate; queue.lastBaseUpdate = current; - props = queue.shared.interleaved; - if (null !== props) { - queue = props; - do (lastBaseUpdate |= queue.lane), (queue = queue.next); - while (queue !== props); - } else null === firstBaseUpdate && (queue.shared.lanes = 0); workInProgressRootSkippedLanes |= lastBaseUpdate; workInProgress$jscomp$0.lanes = lastBaseUpdate; - workInProgress$jscomp$0.memoizedState = newState; + workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2499,8 +2435,7 @@ var classComponentUpdater = { update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - payload = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== payload && entangleTransitions(payload, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; @@ -2511,8 +2446,7 @@ var classComponentUpdater = { update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - payload = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== payload && entangleTransitions(payload, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternals; @@ -2522,8 +2456,7 @@ var classComponentUpdater = { update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - callback = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== callback && entangleTransitions(callback, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); } }; function checkShouldComponentUpdate( @@ -2671,22 +2604,24 @@ function coerceRef(returnFiber, current, element) { } function throwOnInvalidObjectType(returnFiber, newChild) { if ("textarea" !== returnFiber.type) - throw ((returnFiber = Object.prototype.toString.call(newChild)), - Error( + throw Error( "Objects are not valid as a React child (found: " + - ("[object Object]" === returnFiber + ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : returnFiber) + + : newChild) + "). If you meant to render a collection of children, use an array instead." - )); + ); } function ChildReconciler(shouldTrackSideEffects) { function deleteChild(returnFiber, childToDelete) { if (shouldTrackSideEffects) { - var deletions = returnFiber.deletions; - null === deletions - ? ((returnFiber.deletions = [childToDelete]), (returnFiber.flags |= 16)) - : deletions.push(childToDelete); + var last = returnFiber.lastEffect; + null !== last + ? ((last.nextEffect = childToDelete), + (returnFiber.lastEffect = childToDelete)) + : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); + childToDelete.nextEffect = null; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2718,16 +2653,16 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.flags |= 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.flags |= 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.flags |= 2); + (newFiber.flags = 2); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -2742,16 +2677,7 @@ function ChildReconciler(shouldTrackSideEffects) { return current; } function updateElement(returnFiber, current, element, lanes) { - var elementType = element.type; - if (elementType === REACT_FRAGMENT_TYPE) - return updateFragment( - returnFiber, - current, - element.props.children, - lanes, - element.key - ); - if (null !== current && current.elementType === elementType) + if (null !== current && current.elementType === element.type) return ( (lanes = useFiber(current, element.props)), (lanes.ref = coerceRef(returnFiber, current, element)), @@ -2865,7 +2791,15 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return newChild.key === key - ? updateElement(returnFiber, oldFiber, newChild, lanes) + ? newChild.type === REACT_FRAGMENT_TYPE + ? updateFragment( + returnFiber, + oldFiber, + newChild.props.children, + lanes, + key + ) + : updateElement(returnFiber, oldFiber, newChild, lanes) : null; case REACT_PORTAL_TYPE: return newChild.key === key @@ -2900,7 +2834,15 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updateElement(returnFiber, existingChildren, newChild, lanes) + newChild.type === REACT_FRAGMENT_TYPE + ? updateFragment( + returnFiber, + existingChildren, + newChild.props.children, + lanes, + newChild.key + ) + : updateElement(returnFiber, existingChildren, newChild, lanes) ); case REACT_PORTAL_TYPE: return ( @@ -3106,38 +3048,43 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) { - isObject = newChild.type; - if (isObject === REACT_FRAGMENT_TYPE) { - if (7 === isUnkeyedTopLevelFragment.tag) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props.children - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } - } else if (isUnkeyedTopLevelFragment.elementType === isObject) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); break; @@ -3315,7 +3262,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.flags & 128)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3467,11 +3414,10 @@ function updateReducer(reducer) { queue.pending = null; } if (null !== baseQueue) { - pendingQueue = baseQueue.next; + baseQueue = baseQueue.next; current = current.baseState; - var newBaseQueueFirst = (baseFirst = null), - newBaseQueueLast = null, - update = pendingQueue; + var newBaseQueueLast = (baseFirst = pendingQueue = null), + update = baseQueue; do { var updateLane = update.lane; if ((renderLanes & updateLane) === updateLane) @@ -3496,33 +3442,22 @@ function updateReducer(reducer) { next: null }; null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (baseFirst = current)) + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) : (newBaseQueueLast = newBaseQueueLast.next = clone); currentlyRenderingFiber$1.lanes |= updateLane; workInProgressRootSkippedLanes |= updateLane; } update = update.next; - } while (null !== update && update !== pendingQueue); + } while (null !== update && update !== baseQueue); null === newBaseQueueLast - ? (baseFirst = current) - : (newBaseQueueLast.next = newBaseQueueFirst); + ? (pendingQueue = current) + : (newBaseQueueLast.next = baseFirst); objectIs(current, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = current; - hook.baseState = baseFirst; + hook.baseState = pendingQueue; hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = current; } - reducer = queue.interleaved; - if (null !== reducer) { - baseQueue = reducer; - do - (pendingQueue = baseQueue.lane), - (currentlyRenderingFiber$1.lanes |= pendingQueue), - (workInProgressRootSkippedLanes |= pendingQueue), - (baseQueue = baseQueue.next); - while (baseQueue !== reducer); - } else null === baseQueue && (queue.lanes = 0); return [hook.memoizedState, queue.dispatch]; } function rerenderReducer(reducer) { @@ -3562,7 +3497,7 @@ function readFromUnsubcribedMutableSource(root, source, getSnapshot) { if (root) return getSnapshot(source._source); workInProgressSources.push(source); throw Error( - "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + "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) { @@ -3592,13 +3527,25 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { refs.getSnapshot = getSnapshot; refs.setSnapshot = setSnapshot; var maybeNewVersion = getVersion(source._source); - objectIs(version, maybeNewVersion) || - ((maybeNewVersion = getSnapshot(source._source)), + if (!objectIs(version, maybeNewVersion)) { + maybeNewVersion = getSnapshot(source._source); objectIs(snapshot, maybeNewVersion) || (setSnapshot(maybeNewVersion), (maybeNewVersion = requestUpdateLane(fiber)), - (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)), - markRootEntangled(root, root.mutableReadLanes)); + (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] ); @@ -3625,8 +3572,6 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { objectIs(memoizedState, subscribe)) || ((hook = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot @@ -3652,8 +3597,6 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3702,7 +3645,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - hook.memoizedState = pushEffect(hookFlags, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } @@ -3710,10 +3653,10 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(132096, 4, create, deps); + return mountEffectImpl(516, 4, create, deps); } function updateEffect(create, deps) { - return updateEffectImpl(1024, 4, create, deps); + return updateEffectImpl(516, 4, create, deps); } function updateLayoutEffect(create, deps) { return updateEffectImpl(4, 2, create, deps); @@ -3798,55 +3741,33 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }, - alternate = fiber.alternate; + pending = queue.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; + pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || - (null !== alternate && alternate === currentlyRenderingFiber$1) + (null !== pending && pending === currentlyRenderingFiber$1) ) - (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0), - (lane = queue.pending), - null === lane - ? (update.next = update) - : ((update.next = lane.next), (lane.next = update)), - (queue.pending = update); + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; else { - if (null !== workInProgressRoot && 0 !== (fiber.mode & 1)) { - var interleaved = queue.interleaved; - null === interleaved - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [queue]) - : interleavedQueues.push(queue)) - : ((update.next = interleaved.next), (interleaved.next = update)); - queue.interleaved = update; - } else - (interleaved = queue.pending), - null === interleaved - ? (update.next = update) - : ((update.next = interleaved.next), (interleaved.next = update)), - (queue.pending = update); if ( 0 === fiber.lanes && - (null === alternate || 0 === alternate.lanes) && - ((alternate = queue.lastRenderedReducer), null !== alternate) + (null === pending || 0 === pending.lanes) && + ((pending = queue.lastRenderedReducer), null !== pending) ) try { var currentState = queue.lastRenderedState, - eagerState = alternate(currentState, action); - update.eagerReducer = alternate; + eagerState = pending(currentState, action); + update.eagerReducer = pending; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - update = scheduleUpdateOnFiber(fiber, lane, eventTime); - 0 !== (lane & 8388096) && - null !== update && - ((fiber = queue.lanes), - (fiber &= update.pendingLanes), - (lane |= fiber), - (queue.lanes = lane), - markRootEntangled(update, lane)); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } var ContextOnlyDispatcher = { @@ -3903,8 +3824,6 @@ var ContextOnlyDispatcher = { hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -4095,7 +4014,7 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4171,15 +4090,14 @@ function updateSimpleMemoComponent( null !== current && shallowEqual(current.memoizedProps, nextProps) && current.ref === workInProgress.ref - ) { - didReceiveUpdate = !1; - if (0 === (renderLanes & updateLanes)) + ) + if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); + else return ( (workInProgress.lanes = current.lanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - 0 !== (current.flags & 65536) && (didReceiveUpdate = !0); - } return updateFunctionComponent( current, workInProgress, @@ -4196,40 +4114,31 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { "hidden" === nextProps.mode || "unstable-defer-without-hiding" === nextProps.mode ) - if (0 === (workInProgress.mode & 2)) - (workInProgress.memoizedState = { baseLanes: 0, cachePool: null }), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= renderLanes); - else { - if (0 === (renderLanes & 1073741824)) - return ( - (current = - null !== prevState - ? prevState.baseLanes | renderLanes - : renderLanes), - markSpawnedWork(1073741824), - (workInProgress.lanes = workInProgress.childLanes = 1073741824), - (workInProgress.memoizedState = { - baseLanes: current, - cachePool: null - }), - (workInProgress.updateQueue = null), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= current), - null + 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 ); - workInProgress.memoizedState = { baseLanes: 0, cachePool: null }; - nextProps = null !== prevState ? prevState.baseLanes : renderLanes; - push(subtreeRenderLanesCursor, subtreeRenderLanes); - subtreeRenderLanes |= nextProps; - } + 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), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= nextProps); + pushRenderLanes(workInProgress, nextProps); reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -4239,7 +4148,7 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.flags |= 256; + workInProgress.flags |= 128; } function updateFunctionComponent( current, @@ -4264,7 +4173,7 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4439,7 +4348,7 @@ function updateClassComponent( "function" === typeof instance.componentDidUpdate && (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.flags |= 512)) + (workInProgress.flags |= 256)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || @@ -4447,7 +4356,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -4461,7 +4370,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 256), (nextProps = !1)); } return finishClassComponent( @@ -4482,7 +4391,7 @@ function finishClassComponent( renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.flags & 128); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), @@ -4530,21 +4439,18 @@ function pushHostRootContext(workInProgress) { pushHostContainer(workInProgress, root.containerInfo); } var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; -function mountSuspenseOffscreenState(renderLanes) { - return { baseLanes: renderLanes, cachePool: null }; -} function updateSuspenseComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.flags & 128)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = null !== current && null === current.memoizedState ? !1 : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.flags &= -129)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || @@ -4561,9 +4467,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext, renderLanes )), - (workInProgress.child.memoizedState = mountSuspenseOffscreenState( - renderLanes - )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), current ); @@ -4575,12 +4479,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext, renderLanes )), - (workInProgress.child.memoizedState = mountSuspenseOffscreenState( - renderLanes - )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), - (workInProgress.lanes = 8388608), - markSpawnedWork(8388608), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432), current ); renderLanes = createFiberFromOffscreen( @@ -4606,11 +4508,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (suspenseContext = current.child.memoizedState), (showFallback.memoizedState = null === suspenseContext - ? mountSuspenseOffscreenState(renderLanes) - : { - baseLanes: suspenseContext.baseLanes | renderLanes, - cachePool: null - }), + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps @@ -4637,11 +4536,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (suspenseContext = current.child.memoizedState), (showFallback.memoizedState = null === suspenseContext - ? mountSuspenseOffscreenState(renderLanes) - : { - baseLanes: suspenseContext.baseLanes | renderLanes, - cachePool: null - }), + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps @@ -4664,10 +4560,10 @@ function mountSuspenseFallbackChildren( var mode = workInProgress.mode, progressedPrimaryFragment = workInProgress.child; primaryChildren = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 1) && null !== progressedPrimaryFragment + 0 === (mode & 2) && null !== progressedPrimaryFragment ? ((progressedPrimaryFragment.childLanes = 0), (progressedPrimaryFragment.pendingProps = primaryChildren), - workInProgress.mode & 4 && + workInProgress.mode & 8 && ((progressedPrimaryFragment.actualDuration = 0), (progressedPrimaryFragment.actualStartTime = -1), (progressedPrimaryFragment.selfBaseDuration = 0), @@ -4702,14 +4598,13 @@ function updateSuspensePrimaryChildren( mode: "visible", children: primaryChildren }); - 0 === (workInProgress.mode & 1) && (primaryChildren.lanes = renderLanes); + 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); primaryChildren.return = workInProgress; primaryChildren.sibling = null; null !== current && - ((renderLanes = workInProgress.deletions), - null === renderLanes - ? ((workInProgress.deletions = [current]), (workInProgress.flags |= 16)) - : renderLanes.push(current)); + ((current.nextEffect = null), + (current.flags = 8), + (workInProgress.firstEffect = workInProgress.lastEffect = current)); return (workInProgress.child = primaryChildren); } function updateSuspenseFallbackChildren( @@ -4719,27 +4614,33 @@ function updateSuspenseFallbackChildren( fallbackChildren, renderLanes ) { - var mode = workInProgress.mode; - current = current.child; - var currentFallbackChildFragment = current.sibling, - primaryChildProps = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 1) && workInProgress.child !== current + 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 & 4 && + workInProgress.mode & 8 && ((primaryChildren.actualDuration = 0), (primaryChildren.actualStartTime = -1), - (primaryChildren.selfBaseDuration = current.selfBaseDuration), - (primaryChildren.treeBaseDuration = current.treeBaseDuration)), - (workInProgress.deletions = null)) - : ((primaryChildren = createWorkInProgress(current, primaryChildProps)), - (primaryChildren.subtreeFlags = current.subtreeFlags & 131072)); - null !== currentFallbackChildFragment - ? (fallbackChildren = createWorkInProgress( - currentFallbackChildFragment, - fallbackChildren - )) + (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, @@ -4764,7 +4665,8 @@ function initSuspenseListRenderState( isBackwards, tail, lastContentRow, - tailMode + tailMode, + lastEffectBeforeRendering ) { var renderState = workInProgress.memoizedState; null === renderState @@ -4774,14 +4676,16 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailMode: tailMode + tailMode: tailMode, + lastEffect: lastEffectBeforeRendering }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailMode = tailMode)); + (renderState.tailMode = tailMode), + (renderState.lastEffect = lastEffectBeforeRendering)); } function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, @@ -4790,9 +4694,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 128); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.flags & 128)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && @@ -4815,7 +4719,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { nextProps &= 1; } push(suspenseStackCursor, nextProps); - if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null; + if (0 === (workInProgress.mode & 2)) workInProgress.memoizedState = null; else switch (revealOrder) { case "forwards": @@ -4836,7 +4740,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { !1, revealOrder, renderLanes, - tailMode + tailMode, + workInProgress.lastEffect ); break; case "backwards": @@ -4858,11 +4763,19 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { !0, renderLanes, null, - tailMode + tailMode, + workInProgress.lastEffect ); break; case "together": - initSuspenseListRenderState(workInProgress, !1, null, null, void 0); + initSuspenseListRenderState( + workInProgress, + !1, + null, + null, + void 0, + workInProgress.lastEffect + ); break; default: workInProgress.memoizedState = null; @@ -4873,33 +4786,25 @@ function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { null !== current && (workInProgress.dependencies = current.dependencies); profilerStartTime = -1; workInProgressRootSkippedLanes |= workInProgress.lanes; - if (0 === (renderLanes & workInProgress.childLanes)) return null; - 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; + 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; -} -function hadNoMutationsEffects(current, completedWork) { - if (null !== current && current.child === completedWork.child) return !0; - if (0 !== (completedWork.flags & 16)) return !1; - for (current = completedWork.child; null !== current; ) { - if (0 !== (current.flags & 6454) || 0 !== (current.subtreeFlags & 6454)) - return !1; - current = current.sibling; - } - return !0; + return null; } var appendAllChildren, updateHostContainer, @@ -5016,24 +4921,21 @@ function appendAllChildrenToContainer( node = node.sibling; } } -updateHostContainer = function(current, workInProgress) { +updateHostContainer = function(workInProgress) { var portalOrRoot = workInProgress.stateNode; - if (!hadNoMutationsEffects(current, workInProgress)) { - current = portalOrRoot.containerInfo; - var newChildSet = createChildNodeSet(current); + if (null !== workInProgress.firstEffect) { + var container = portalOrRoot.containerInfo, + newChildSet = createChildNodeSet(container); appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; workInProgress.flags |= 4; - completeRoot(current, newChildSet); + completeRoot(container, newChildSet); } }; updateHostComponent$1 = function(current, workInProgress, type, newProps) { type = current.stateNode; var oldProps = current.memoizedProps; - if ( - (current = hadNoMutationsEffects(current, workInProgress)) && - oldProps === newProps - ) + if ((current = null === workInProgress.firstEffect) && oldProps === newProps) workInProgress.stateNode = type; else { var recyclableInstance = workInProgress.stateNode; @@ -5051,15 +4953,15 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { current && null === updatePayload ? (workInProgress.stateNode = type) : ((newProps = updatePayload), - (oldProps = type.node), + (recyclableInstance = type.node), (type = { node: current ? null !== newProps - ? cloneNodeWithNewProps(oldProps, newProps) - : cloneNode(oldProps) + ? cloneNodeWithNewProps(recyclableInstance, newProps) + : cloneNode(recyclableInstance) : null !== newProps - ? cloneNodeWithNewChildrenAndProps(oldProps, newProps) - : cloneNodeWithNewChildren(oldProps), + ? cloneNodeWithNewChildrenAndProps(recyclableInstance, newProps) + : cloneNodeWithNewChildren(recyclableInstance), canonical: type.canonical }), (workInProgress.stateNode = type), @@ -5095,76 +4997,16 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$63 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$63 = lastTailNode), + for (var lastTailNode$65 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$65 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$63 + null === lastTailNode$65 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$63.sibling = null); + : (lastTailNode$65.sibling = null); } } -function bubbleProperties(completedWork) { - var didBailout = - null !== completedWork.alternate && - completedWork.alternate.child === completedWork.child, - newChildLanes = 0, - subtreeFlags = 0; - if (didBailout) - if (0 !== (completedWork.mode & 4)) { - for ( - var treeBaseDuration$65 = completedWork.selfBaseDuration, - child$66 = completedWork.child; - null !== child$66; - - ) - (newChildLanes |= child$66.lanes | child$66.childLanes), - (subtreeFlags |= child$66.subtreeFlags & 131072), - (subtreeFlags |= child$66.flags & 131072), - (treeBaseDuration$65 += child$66.treeBaseDuration), - (child$66 = child$66.sibling); - completedWork.treeBaseDuration = treeBaseDuration$65; - } else - for ( - treeBaseDuration$65 = completedWork.child; - null !== treeBaseDuration$65; - - ) - (newChildLanes |= - treeBaseDuration$65.lanes | treeBaseDuration$65.childLanes), - (subtreeFlags |= treeBaseDuration$65.subtreeFlags & 131072), - (subtreeFlags |= treeBaseDuration$65.flags & 131072), - (treeBaseDuration$65.return = completedWork), - (treeBaseDuration$65 = treeBaseDuration$65.sibling); - else if (0 !== (completedWork.mode & 4)) { - treeBaseDuration$65 = completedWork.actualDuration; - child$66 = completedWork.selfBaseDuration; - for (var child = completedWork.child; null !== child; ) - (newChildLanes |= child.lanes | child.childLanes), - (subtreeFlags |= child.subtreeFlags), - (subtreeFlags |= child.flags), - (treeBaseDuration$65 += child.actualDuration), - (child$66 += child.treeBaseDuration), - (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$65; - completedWork.treeBaseDuration = child$66; - } else - for ( - treeBaseDuration$65 = completedWork.child; - null !== treeBaseDuration$65; - - ) - (newChildLanes |= - treeBaseDuration$65.lanes | treeBaseDuration$65.childLanes), - (subtreeFlags |= treeBaseDuration$65.subtreeFlags), - (subtreeFlags |= treeBaseDuration$65.flags), - (treeBaseDuration$65.return = completedWork), - (treeBaseDuration$65 = treeBaseDuration$65.sibling); - completedWork.subtreeFlags |= subtreeFlags; - completedWork.childLanes = newChildLanes; - return didBailout; -} function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { @@ -5178,81 +5020,76 @@ function completeWork(current, workInProgress, renderLanes) { case 12: case 9: case 14: - return bubbleProperties(workInProgress), null; + return null; case 1: - return ( - isContextProvider(workInProgress.type) && popContext(), - bubbleProperties(workInProgress), - null - ); + return isContextProvider(workInProgress.type) && popContext(), null; case 3: return ( - (newProps = workInProgress.stateNode), popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), resetWorkInProgressVersions(), + (newProps = workInProgress.stateNode), newProps.pendingContext && ((newProps.context = newProps.pendingContext), (newProps.pendingContext = null)), (null !== current && null !== current.child) || newProps.hydrate || - (workInProgress.flags |= 512), - updateHostContainer(current, workInProgress), - bubbleProperties(workInProgress), + (workInProgress.flags |= 256), + updateHostContainer(workInProgress), null ); case 5: popHostContext(workInProgress); - renderLanes = requiredContext(rootInstanceStackCursor.current); - var type = workInProgress.type; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ); + renderLanes = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - type, + renderLanes, newProps, - renderLanes + rootContainerInstance ), - current.ref !== workInProgress.ref && (workInProgress.flags |= 256); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); - bubbleProperties(workInProgress); return null; } requiredContext(contextStackCursor$1.current); current = nextReactTag; nextReactTag += 2; - type = getViewConfigForType(type); + renderLanes = getViewConfigForType(renderLanes); var updatePayload = diffProperties( null, emptyObject, newProps, - type.validAttributes + renderLanes.validAttributes ); - renderLanes = createNode( + rootContainerInstance = createNode( current, - type.uiViewClassName, - renderLanes, + renderLanes.uiViewClassName, + rootContainerInstance, updatePayload, workInProgress ); current = new ReactFabricHostComponent( current, - type, + renderLanes, newProps, workInProgress ); - current = { node: renderLanes, canonical: current }; + current = { node: rootContainerInstance, canonical: current }; appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; - null !== workInProgress.ref && (workInProgress.flags |= 256); + null !== workInProgress.ref && (workInProgress.flags |= 128); } - bubbleProperties(workInProgress); return null; case 6: if (current && null != workInProgress.stateNode) @@ -5268,30 +5105,30 @@ function completeWork(current, workInProgress, renderLanes) { "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); current = requiredContext(rootInstanceStackCursor.current); - renderLanes = requiredContext(contextStackCursor$1.current); + rootContainerInstance = requiredContext(contextStackCursor$1.current); workInProgress.stateNode = createTextInstance( newProps, current, - renderLanes, + rootContainerInstance, workInProgress ); } - bubbleProperties(workInProgress); return null; case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.flags & 128)) + if (0 !== (workInProgress.flags & 64)) return ( (workInProgress.lanes = renderLanes), - 0 !== (workInProgress.mode & 4) && + 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress ); newProps = null !== newProps; - renderLanes = !1; - null !== current && (renderLanes = null !== current.memoizedState); - if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1)) + rootContainerInstance = !1; + null !== current && + (rootContainerInstance = null !== current.memoizedState); + if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || @@ -5306,100 +5143,89 @@ function completeWork(current, workInProgress, renderLanes) { ) workInProgressRootExitStatus = 4; null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootUpdatedLanes & 268435455)) || + (0 === (workInProgressRootSkippedLanes & 134217727) && + 0 === (workInProgressRootUpdatedLanes & 134217727)) || markRootSuspended$1( workInProgressRoot, workInProgressRootRenderLanes ); } newProps && (workInProgress.flags |= 4); - bubbleProperties(workInProgress); - 0 !== (workInProgress.mode & 4) && - newProps && - ((current = workInProgress.child), - null !== current && - (workInProgress.treeBaseDuration -= current.treeBaseDuration)); return null; case 4: - return ( - popHostContainer(), - updateHostContainer(current, workInProgress), - bubbleProperties(workInProgress), - null - ); + return popHostContainer(), updateHostContainer(workInProgress), null; case 10: - return ( - popProvider(workInProgress.type._context), - bubbleProperties(workInProgress), - null - ); + return popProvider(workInProgress), null; case 17: - return ( - isContextProvider(workInProgress.type) && popContext(), - bubbleProperties(workInProgress), - null - ); + return isContextProvider(workInProgress.type) && popContext(), null; case 19: pop(suspenseStackCursor); - type = workInProgress.memoizedState; - if (null === type) return bubbleProperties(workInProgress), null; - newProps = 0 !== (workInProgress.flags & 128); - updatePayload = type.rendering; + newProps = workInProgress.memoizedState; + if (null === newProps) return null; + rootContainerInstance = 0 !== (workInProgress.flags & 64); + updatePayload = newProps.rendering; if (null === updatePayload) - if (newProps) cutOffTailIfNeeded(type, !1); + if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || - (null !== current && 0 !== (current.flags & 128)) + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.flags |= 128; - cutOffTailIfNeeded(type, !1); + workInProgress.flags |= 64; + cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), (workInProgress.flags |= 4)); - workInProgress.subtreeFlags = 0; + null === newProps.lastEffect && + (workInProgress.firstEffect = null); + workInProgress.lastEffect = newProps.lastEffect; current = renderLanes; for (newProps = workInProgress.child; null !== newProps; ) - (renderLanes = newProps), + (rootContainerInstance = newProps), (updatePayload = current), - (renderLanes.flags &= 131074), - (type = renderLanes.alternate), - null === type - ? ((renderLanes.childLanes = 0), - (renderLanes.lanes = updatePayload), - (renderLanes.child = null), - (renderLanes.subtreeFlags = 0), - (renderLanes.memoizedProps = null), - (renderLanes.memoizedState = null), - (renderLanes.updateQueue = null), - (renderLanes.dependencies = null), - (renderLanes.stateNode = null), - (renderLanes.selfBaseDuration = 0), - (renderLanes.treeBaseDuration = 0)) - : ((renderLanes.childLanes = type.childLanes), - (renderLanes.lanes = type.lanes), - (renderLanes.child = type.child), - (renderLanes.subtreeFlags = type.subtreeFlags), - (renderLanes.deletions = null), - (renderLanes.memoizedProps = type.memoizedProps), - (renderLanes.memoizedState = type.memoizedState), - (renderLanes.updateQueue = type.updateQueue), - (renderLanes.type = type.type), - (updatePayload = type.dependencies), - (renderLanes.dependencies = + (rootContainerInstance.flags &= 2), + (rootContainerInstance.nextEffect = null), + (rootContainerInstance.firstEffect = null), + (rootContainerInstance.lastEffect = null), + (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.childLanes = + renderLanes.childLanes), + (rootContainerInstance.lanes = renderLanes.lanes), + (rootContainerInstance.child = renderLanes.child), + (rootContainerInstance.memoizedProps = + renderLanes.memoizedProps), + (rootContainerInstance.memoizedState = + renderLanes.memoizedState), + (rootContainerInstance.updateQueue = + renderLanes.updateQueue), + (rootContainerInstance.type = renderLanes.type), + (updatePayload = renderLanes.dependencies), + (rootContainerInstance.dependencies = null === updatePayload ? null : { lanes: updatePayload.lanes, firstContext: updatePayload.firstContext }), - (renderLanes.selfBaseDuration = type.selfBaseDuration), - (renderLanes.treeBaseDuration = type.treeBaseDuration)), + (rootContainerInstance.selfBaseDuration = + renderLanes.selfBaseDuration), + (rootContainerInstance.treeBaseDuration = + renderLanes.treeBaseDuration)), (newProps = newProps.sibling); push( suspenseStackCursor, @@ -5409,76 +5235,80 @@ function completeWork(current, workInProgress, renderLanes) { } current = current.sibling; } - null !== type.tail && + null !== newProps.tail && now() > workInProgressRootRenderTargetTime && - ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), - (workInProgress.lanes = 8388608), - markSpawnedWork(8388608)); + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); } else { - if (!newProps) + if (!rootContainerInstance) if ( ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.flags |= 128), - (newProps = !0), + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), (workInProgress.flags |= 4)), - cutOffTailIfNeeded(type, !0), - null === type.tail && - "hidden" === type.tailMode && + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "hidden" === newProps.tailMode && !updatePayload.alternate) ) - return bubbleProperties(workInProgress), null; + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); } else - 2 * now() - type.renderingStartTime > + 2 * now() - newProps.renderingStartTime > workInProgressRootRenderTargetTime && 1073741824 !== renderLanes && - ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), - (workInProgress.lanes = 8388608), - markSpawnedWork(8388608)); - type.isBackwards + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); + newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) - : ((current = type.last), + : ((current = newProps.last), null !== current ? (current.sibling = updatePayload) : (workInProgress.child = updatePayload), - (type.last = updatePayload)); + (newProps.last = updatePayload)); } - if (null !== type.tail) - return ( - (workInProgress = type.tail), - (type.rendering = workInProgress), - (type.tail = workInProgress.sibling), - (type.renderingStartTime = now()), - (workInProgress.sibling = null), - (current = suspenseStackCursor.current), - push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1), - workInProgress - ); - bubbleProperties(workInProgress); - return null; + return null !== newProps.tail + ? ((current = newProps.tail), + (newProps.rendering = current), + (newProps.tail = current.sibling), + (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), + (current.sibling = null), + (workInProgress = suspenseStackCursor.current), + push( + suspenseStackCursor, + rootContainerInstance + ? (workInProgress & 1) | 2 + : workInProgress & 1 + ), + current) + : null; case 22: case 23: return ( popRenderLanes(), - (renderLanes = null !== workInProgress.memoizedState), null !== current && - (null !== current.memoizedState) !== renderLanes && + (null !== current.memoizedState) !== + (null !== workInProgress.memoizedState) && "unstable-defer-without-hiding" !== newProps.mode && (workInProgress.flags |= 4), - (renderLanes && - 0 === (subtreeRenderLanes & 1073741824) && - 0 !== (workInProgress.mode & 2)) || - bubbleProperties(workInProgress), null ); } @@ -5493,9 +5323,9 @@ function unwindWork(workInProgress) { case 1: isContextProvider(workInProgress.type) && popContext(); var flags = workInProgress.flags; - return flags & 16384 - ? ((workInProgress.flags = (flags & -16385) | 128), - 0 !== (workInProgress.mode & 4) && + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), + 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress) : null; @@ -5505,11 +5335,11 @@ function unwindWork(workInProgress) { pop(contextStackCursor); resetWorkInProgressVersions(); flags = workInProgress.flags; - if (0 !== (flags & 128)) + 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.flags = (flags & -16385) | 128; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; @@ -5517,9 +5347,9 @@ function unwindWork(workInProgress) { return ( pop(suspenseStackCursor), (flags = workInProgress.flags), - flags & 16384 - ? ((workInProgress.flags = (flags & -16385) | 128), - 0 !== (workInProgress.mode & 4) && + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), + 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress) : null @@ -5529,12 +5359,10 @@ function unwindWork(workInProgress) { case 4: return popHostContainer(), null; case 10: - return popProvider(workInProgress.type._context), null; + return popProvider(workInProgress), null; case 22: case 23: return popRenderLanes(), null; - case 24: - return null; default: return null; } @@ -5613,161 +5441,164 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { }); return lane; } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set, - nextEffect = null; -function safelyDetachRef(current, nearestMountedAncestor) { +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) if ("function" === typeof ref) try { ref(null); } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + captureCommitPhaseError(current, refError); } else ref.current = null; } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; -function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) - (firstChild.return = root), (nextEffect = firstChild); - else - for (; null !== nextEffect; ) { - root = nextEffect; - try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); +function commitBeforeMutationLifeCycles(current, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + return; + case 1: + if (finishedWork.flags & 256 && null !== current) { + var prevProps = current.memoizedProps, + prevState = current.memoizedState; + current = finishedWork.stateNode; + finishedWork = current.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); + current.__reactInternalSnapshotBeforeUpdate = finishedWork; + } + return; + case 3: + return; + case 5: + case 6: + case 4: + case 17: + 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 commitLifeCycles(finishedRoot, current, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + 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(); } - if (0 !== (flags & 512)) - switch (root.tag) { - case 0: - case 11: - case 15: - break; - case 1: - if (null !== current) { - var prevProps = current.memoizedProps, - prevState = current.memoizedState, - instance = root.stateNode, - snapshot = instance.getSnapshotBeforeUpdate( - root.elementType === root.type - ? prevProps - : resolveDefaultProps(root.type, prevProps), - prevState - ); - instance.__reactInternalSnapshotBeforeUpdate = snapshot; - } - break; - case 3: - break; - case 5: - case 6: - case 4: - case 17: - break; - default: - 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." - ); - } - } catch (error) { - captureCommitPhaseError(root, root.return, error); - } - firstChild = root.sibling; - if (null !== firstChild) { - firstChild.return = root.return; - nextEffect = firstChild; - break; - } - nextEffect = root.return; + finishedRoot = finishedRoot.next; + } while (finishedRoot !== current); } - } - current = shouldFireAfterActiveInstanceBlur; - shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; - return current; -} -function commitHookEffectListUnmount( - flags, - finishedWork, - nearestMountedAncestor$jscomp$0 -) { - var updateQueue = finishedWork.updateQueue; - updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; - if (null !== updateQueue) { - var effect = (updateQueue = updateQueue.next); - do { - if ((effect.tag & flags) === flags) { - var destroy = effect.destroy; - effect.destroy = void 0; - if (void 0 !== destroy) { - var current = finishedWork, - nearestMountedAncestor = nearestMountedAncestor$jscomp$0; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(current, nearestMountedAncestor, error); + 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; + 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); + return; + case 3: + current = finishedWork.updateQueue; + if (null !== current) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode.canonical; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; } - } + commitUpdateQueue(finishedWork, current, finishedRoot); } - effect = effect.next; - } while (effect !== updateQueue); + return; + case 5: + null === current && finishedWork.flags & 4 && shim(); + return; + case 6: + return; + case 4: + return; + case 12: + 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, + _effect, + finishedRoot.memoizedInteractions + ); + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + case 22: + case 23: + 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 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$84 = effect.create; - effect.destroy = create$84(); - } - effect = effect.next; - } while (effect !== finishedWork); - } -} -function detachFiberAfterEffects(fiber) { +function detachFiberMutation(fiber) { fiber.alternate = null; fiber.child = null; - fiber.deletions = null; fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; + fiber.return = null; fiber.updateQueue = null; } function commitWork(current, finishedWork) { @@ -5776,7 +5607,19 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - commitHookEffectListUnmount(3, finishedWork, finishedWork.return); + 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; @@ -5797,6 +5640,7 @@ function commitWork(current, finishedWork) { case 1: case 5: case 6: + case 20: break a; case 3: case 4: @@ -5824,284 +5668,13 @@ function attachSuspenseRetryListeners(finishedWork) { }); } } -function commitMutationEffects(root, renderPriorityLevel, firstChild) { - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - renderPriorityLevel = root.deletions; - if (null !== renderPriorityLevel) - for ( - firstChild = 0; - firstChild < renderPriorityLevel.length; - firstChild++ - ) { - var childToDelete = renderPriorityLevel[firstChild]; - try { - a: for (var node = childToDelete; ; ) { - var current = node; - if ( - injectedHook && - "function" === typeof injectedHook.onCommitFiberUnmount - ) - try { - injectedHook.onCommitFiberUnmount(rendererID, current); - } catch (err) {} - switch (current.tag) { - case 0: - case 11: - case 14: - case 15: - var updateQueue = current.updateQueue; - if (null !== updateQueue) { - var lastEffect = updateQueue.lastEffect; - if (null !== lastEffect) { - var firstEffect = lastEffect.next, - effect = firstEffect; - do { - var _effect = effect, - destroy = _effect.destroy, - tag = _effect.tag; - if (void 0 !== destroy && 0 !== (tag & 2)) { - _effect = current; - var nearestMountedAncestor = root; - try { - destroy(); - } catch (error) { - captureCommitPhaseError( - _effect, - nearestMountedAncestor, - error - ); - } - } - effect = effect.next; - } while (effect !== firstEffect); - } - } - break; - case 1: - safelyDetachRef(current, root); - var instance = current.stateNode; - if ("function" === typeof instance.componentWillUnmount) - try { - (effect = current), - (_effect = instance), - (_effect.props = effect.memoizedProps), - (_effect.state = effect.memoizedState), - _effect.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current, root, unmountError); - } - break; - case 5: - safelyDetachRef(current, root); - break; - case 4: - createChildNodeSet(current.stateNode.containerInfo); - } - if (null !== node.child) - (node.child.return = node), (node = node.child); - else { - if (node === childToDelete) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === childToDelete) - break a; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - var alternate = childToDelete.alternate; - childToDelete.return = null; - null !== alternate && (alternate.return = null); - } catch (error) { - captureCommitPhaseError(childToDelete, root, error); - } - } - renderPriorityLevel = root.child; - if (0 !== (root.subtreeFlags & 6454) && null !== renderPriorityLevel) - (renderPriorityLevel.return = root), (nextEffect = renderPriorityLevel); - else - for (; null !== nextEffect; ) { - root = nextEffect; - try { - var flags = root.flags; - if (flags & 256) { - var current$jscomp$0 = root.alternate; - if (null !== current$jscomp$0) { - var currentRef = current$jscomp$0.ref; - null !== currentRef && - ("function" === typeof currentRef - ? currentRef(null) - : (currentRef.current = null)); - } - } - switch (flags & 2054) { - case 2: - root.flags &= -3; - break; - case 6: - root.flags &= -3; - commitWork(root.alternate, root); - break; - case 2048: - root.flags &= -2049; - break; - case 2052: - root.flags &= -2049; - commitWork(root.alternate, root); - break; - case 4: - commitWork(root.alternate, root); - } - } catch (error) { - captureCommitPhaseError(root, root.return, error); - } - renderPriorityLevel = root.sibling; - if (null !== renderPriorityLevel) { - renderPriorityLevel.return = root.return; - nextEffect = renderPriorityLevel; - break; - } - nextEffect = root.return; - } - } -} -function commitLayoutEffects(finishedWork, root) { - for (nextEffect = finishedWork; null !== nextEffect; ) { - var fiber = nextEffect, - firstChild = fiber.child; - if (0 !== (fiber.subtreeFlags & 324) && null !== firstChild) - (firstChild.return = fiber), (nextEffect = firstChild); - else - for (fiber = finishedWork, firstChild = root; null !== nextEffect; ) { - var fiber$jscomp$0 = nextEffect; - if (0 !== (fiber$jscomp$0.flags & 324)) { - var current = fiber$jscomp$0.alternate; - try { - var finishedRoot = firstChild; - if (0 !== (fiber$jscomp$0.flags & 68)) - switch (fiber$jscomp$0.tag) { - case 0: - case 11: - case 15: - commitHookEffectListMount(3, fiber$jscomp$0); - break; - case 1: - var instance = fiber$jscomp$0.stateNode; - if (fiber$jscomp$0.flags & 4) - if (null === current) instance.componentDidMount(); - else { - var prevProps = - fiber$jscomp$0.elementType === fiber$jscomp$0.type - ? current.memoizedProps - : resolveDefaultProps( - fiber$jscomp$0.type, - current.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = fiber$jscomp$0.updateQueue; - null !== updateQueue && - commitUpdateQueue(fiber$jscomp$0, updateQueue, instance); - break; - case 3: - var updateQueue$85 = fiber$jscomp$0.updateQueue; - if (null !== updateQueue$85) { - finishedRoot = null; - if (null !== fiber$jscomp$0.child) - switch (fiber$jscomp$0.child.tag) { - case 5: - finishedRoot = - fiber$jscomp$0.child.stateNode.canonical; - break; - case 1: - finishedRoot = fiber$jscomp$0.child.stateNode; - } - commitUpdateQueue( - fiber$jscomp$0, - updateQueue$85, - finishedRoot - ); - } - break; - case 5: - null === current && fiber$jscomp$0.flags & 4 && shim(); - break; - case 6: - break; - case 4: - break; - case 12: - var onRender = fiber$jscomp$0.memoizedProps.onRender, - commitTime$88 = commitTime; - current = null === current ? "mount" : "update"; - "function" === typeof onRender && - onRender( - fiber$jscomp$0.memoizedProps.id, - current, - fiber$jscomp$0.actualDuration, - fiber$jscomp$0.treeBaseDuration, - fiber$jscomp$0.actualStartTime, - commitTime$88, - finishedRoot.memoizedInteractions - ); - break; - case 13: - break; - case 19: - case 17: - case 21: - case 22: - case 23: - break; - default: - 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 (fiber$jscomp$0.flags & 256) { - finishedRoot = void 0; - var ref = fiber$jscomp$0.ref; - if (null !== ref) { - var instance$jscomp$0 = fiber$jscomp$0.stateNode; - switch (fiber$jscomp$0.tag) { - case 5: - finishedRoot = instance$jscomp$0.canonical; - break; - default: - finishedRoot = instance$jscomp$0; - } - "function" === typeof ref - ? ref(finishedRoot) - : (ref.current = finishedRoot); - } - } - } catch (error) { - captureCommitPhaseError( - fiber$jscomp$0, - fiber$jscomp$0.return, - error - ); - } - } - if (fiber$jscomp$0 === fiber) { - nextEffect = null; - break; - } - finishedRoot = fiber$jscomp$0.sibling; - if (null !== finishedRoot) { - finishedRoot.return = fiber$jscomp$0.return; - nextEffect = finishedRoot; - break; - } - nextEffect = fiber$jscomp$0.return; - } - } +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$2 = ReactSharedInternals.ReactCurrentDispatcher, @@ -6114,11 +5687,14 @@ var ceil = Math.ceil, subtreeRenderLanesCursor = createCursor(0), workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, + workInProgressRootIncludedLanes = 0, workInProgressRootSkippedLanes = 0, workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, + mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, workInProgressRootRenderTargetTime = Infinity, + nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, legacyErrorBoundariesThatAlreadyFailed = null, @@ -6126,12 +5702,17 @@ var ceil = Math.ceil, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, pendingPassiveEffectsLanes = 0, + pendingPassiveHookEffectsMount = [], + pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, spawnedWorkDuringRender = null, currentEventTime = -1, - currentEventTransitionLane = 0; + currentEventWipLanes = 0, + currentEventPendingLanes = 0, + focusedInstanceHandle = null, + shouldFireAfterActiveInstanceBlur = !1; function requestEventTime() { return 0 !== (executionContext & 48) ? now() @@ -6141,22 +5722,30 @@ function requestEventTime() { } function requestUpdateLane(fiber) { fiber = fiber.mode; - if (0 === (fiber & 1)) return 1; - if (0 === (fiber & 2)) return 99 === getCurrentPriorityLevel() ? 1 : 2; - if (0 !== ReactCurrentBatchConfig.transition) - return ( - 0 === currentEventTransitionLane && - ((fiber = nextTransitionLane), - (nextTransitionLane <<= 1), - 0 === (nextTransitionLane & 8388096) && (nextTransitionLane = 512), - (currentEventTransitionLane = fiber)), - currentEventTransitionLane - ); + 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)) + ? (fiber = findUpdateLane(12, currentEventWipLanes)) : ((fiber = schedulerPriorityToLanePriority(fiber)), - (fiber = findUpdateLane(fiber))); + (fiber = findUpdateLane(fiber, currentEventWipLanes))); return fiber; } function scheduleUpdateOnFiber(fiber, lane, eventTime) { @@ -6189,7 +5778,7 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { : rootsWithPendingDiscreteUpdates.add(fiber)), ensureRootIsScheduled(fiber, eventTime), schedulePendingInteractions(fiber, lane)); - return fiber; + mostRecentlyUpdatedRoot = fiber; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { sourceFiber.lanes |= lane; @@ -6237,42 +5826,45 @@ function ensureRootIsScheduled(root, currentTime) { root === workInProgressRoot ? workInProgressRootRenderLanes : 0 ); currentTime = return_highestLanePriority; - 0 === suspendedLanes - ? (null !== existingCallbackNode && + if (0 === suspendedLanes) + null !== existingCallbackNode && + (existingCallbackNode !== fakeCallbackNode && Scheduler_cancelCallback(existingCallbackNode), (root.callbackNode = null), - (root.callbackPriority = 0)) - : root.callbackPriority !== currentTime && - (null != existingCallbackNode && - Scheduler_cancelCallback(existingCallbackNode), - 15 === currentTime - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? ((syncQueue = [existingCallbackNode]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(existingCallbackNode), - (existingCallbackNode = null)) - : 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)); + (root.callbackPriority = 0)); + else { + 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) { +function performConcurrentWorkOnRoot(root) { currentEventTime = -1; - currentEventTransitionLane = 0; + currentEventPendingLanes = currentEventWipLanes = 0; if (0 !== (executionContext & 48)) throw Error("Should not already be working."); var originalCallbackNode = root.callbackNode; @@ -6283,14 +5875,8 @@ 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 ( @@ -6312,19 +5898,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)); - if (0 !== didTimeout) { - 2 === didTimeout && + (exitStatus = workInProgressRootExitStatus)); + 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 && (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), @@ -6332,7 +5920,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."); @@ -6342,9 +5930,9 @@ function performConcurrentWorkOnRoot(root, didTimeout) { case 3: markRootSuspended$1(root, lanes); if ( - (lanes & 125829120) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + (lanes & 62914560) === lanes && + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { if (0 !== getNextLanes(root, 0)) break; prevDispatcher = root.suspendedLanes; @@ -6355,7 +5943,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + exitStatus ); break; } @@ -6363,12 +5951,12 @@ function performConcurrentWorkOnRoot(root, didTimeout) { break; case 4: markRootSuspended$1(root, lanes); - if ((lanes & 8388096) === lanes) break; - didTimeout = root.eventTimes; + 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 = didTimeout[index$4]; + index$4 = exitStatus[index$4]; index$4 > prevDispatcher && (prevDispatcher = index$4); lanes &= ~lanes$jscomp$0; } @@ -6415,9 +6003,9 @@ function markRootSuspended$1(root, suspendedLanes) { root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$6 = 31 - clz32(suspendedLanes), - lane = 1 << index$6; - root[index$6] = -1; + var index$9 = 31 - clz32(suspendedLanes), + lane = 1 << index$9; + root[index$9] = -1; suspendedLanes &= ~lane; } } @@ -6425,12 +6013,17 @@ function performSyncWorkOnRoot(root) { if (0 !== (executionContext & 48)) throw Error("Should not already be working."); flushPassiveEffects(); - var lanes = + if ( root === workInProgressRoot && 0 !== (root.expiredLanes & workInProgressRootRenderLanes) - ? workInProgressRootRenderLanes - : getNextLanes(root, 0); - var exitStatus = renderRootSync(root, lanes); + ) { + 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 && 2 === exitStatus && ((executionContext |= 64), @@ -6449,6 +6042,11 @@ function performSyncWorkOnRoot(root) { ensureRootIsScheduled(root, now()); return null; } +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes); + subtreeRenderLanes |= lanes; + workInProgressRootIncludedLanes |= lanes; +} function popRenderLanes() { subtreeRenderLanes = subtreeRenderLanesCursor.current; pop(subtreeRenderLanesCursor); @@ -6488,7 +6086,7 @@ function prepareFreshStack(root, lanes) { pop(suspenseStackCursor); break; case 10: - popProvider(interruptedWork.type._context); + popProvider(interruptedWork); break; case 22: case 23: @@ -6498,29 +6096,10 @@ function prepareFreshStack(root, lanes) { } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = lanes; + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; - if (null !== interleavedQueues) { - for (root = 0; root < interleavedQueues.length; root++) - if ( - ((lanes = interleavedQueues[root]), - (timeoutHandle = lanes.interleaved), - null !== timeoutHandle) - ) { - lanes.interleaved = null; - interruptedWork = timeoutHandle.next; - var lastPendingUpdate = lanes.pending; - if (null !== lastPendingUpdate) { - var firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = interruptedWork; - timeoutHandle.next = firstPendingUpdate; - } - lanes.pending = timeoutHandle; - } - interleavedQueues = null; - } spawnedWorkDuringRender = null; } function handleError(root$jscomp$0, thrownValue) { @@ -6551,7 +6130,7 @@ function handleError(root$jscomp$0, thrownValue) { workInProgress = null; break; } - erroredWork.mode & 4 && + erroredWork.mode & 8 && stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0); a: { var root = root$jscomp$0, @@ -6559,18 +6138,15 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.flags |= 8192; + sourceFiber.flags |= 4096; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - var wakeable = value, - tag = sourceFiber.tag; - if ( - 0 === (sourceFiber.mode & 1) && - (0 === tag || 11 === tag || 15 === tag) - ) { + var wakeable = value; + if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), @@ -6581,15 +6157,15 @@ function handleError(root$jscomp$0, thrownValue) { } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - workInProgress$79 = returnFiber; + workInProgress$77 = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$79.tag)) { - var nextState = workInProgress$79.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$79.memoizedProps; + var props = workInProgress$77.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6601,19 +6177,16 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var wakeables = workInProgress$79.updateQueue; + var wakeables = workInProgress$77.updateQueue; if (null === wakeables) { var updateQueue = new Set(); updateQueue.add(wakeable); - workInProgress$79.updateQueue = updateQueue; + workInProgress$77.updateQueue = updateQueue; } else wakeables.add(wakeable); - if ( - 0 === (workInProgress$79.mode & 1) && - workInProgress$79 !== returnFiber - ) { - workInProgress$79.flags |= 128; - sourceFiber.flags |= 65536; - sourceFiber.flags &= -10053; + 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 { @@ -6644,12 +6217,12 @@ function handleError(root$jscomp$0, thrownValue) { ); wakeable.then(ping, ping); } - workInProgress$79.flags |= 16384; - workInProgress$79.lanes = thrownValue; + workInProgress$77.flags |= 8192; + workInProgress$77.lanes = thrownValue; break a; } - workInProgress$79 = workInProgress$79.return; - } while (null !== workInProgress$79); + 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." @@ -6658,47 +6231,47 @@ function handleError(root$jscomp$0, thrownValue) { 5 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - workInProgress$79 = returnFiber; + workInProgress$77 = returnFiber; do { - switch (workInProgress$79.tag) { + switch (workInProgress$77.tag) { case 3: root = value; - workInProgress$79.flags |= 16384; + workInProgress$77.flags |= 8192; thrownValue &= -thrownValue; - workInProgress$79.lanes |= thrownValue; - var update$80 = createRootErrorUpdate( - workInProgress$79, + workInProgress$77.lanes |= thrownValue; + var update$78 = createRootErrorUpdate( + workInProgress$77, root, thrownValue ); - enqueueCapturedUpdate(workInProgress$79, update$80); + enqueueCapturedUpdate(workInProgress$77, update$78); break a; case 1: root = value; - var ctor = workInProgress$79.type, - instance = workInProgress$79.stateNode; + var ctor = workInProgress$77.type, + instance = workInProgress$77.stateNode; if ( - 0 === (workInProgress$79.flags & 128) && + 0 === (workInProgress$77.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$79.flags |= 16384; + workInProgress$77.flags |= 8192; thrownValue &= -thrownValue; - workInProgress$79.lanes |= thrownValue; - var update$83 = createClassErrorUpdate( - workInProgress$79, + workInProgress$77.lanes |= thrownValue; + var update$81 = createClassErrorUpdate( + workInProgress$77, root, thrownValue ); - enqueueCapturedUpdate(workInProgress$79, update$83); + enqueueCapturedUpdate(workInProgress$77, update$81); break a; } } - workInProgress$79 = workInProgress$79.return; - } while (null !== workInProgress$79); + workInProgress$77 = workInProgress$77.return; + } while (null !== workInProgress$77); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { @@ -6757,7 +6330,7 @@ function workLoopConcurrent() { } function performUnitOfWork(unitOfWork) { var current = unitOfWork.alternate; - 0 !== (unitOfWork.mode & 4) + 0 !== (unitOfWork.mode & 8) ? ((profilerStartTime = now$1()), 0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()), (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)), @@ -6774,8 +6347,8 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.flags & 8192)) { - if (0 === (completedWork.mode & 4)) + if (0 === (completedWork.flags & 4096)) { + if (0 === (completedWork.mode & 8)) current = completeWork(current, completedWork, subtreeRenderLanes); else { var fiber = completedWork; @@ -6788,14 +6361,65 @@ function completeUnitOfWork(unitOfWork) { workInProgress = current; return; } + current = completedWork; + if ( + (23 !== current.tag && 22 !== current.tag) || + null === current.memoizedState || + 0 !== (subtreeRenderLanes & 1073741824) || + 0 === (current.mode & 4) + ) { + fiber = 0; + if (0 !== (current.mode & 8)) { + for ( + var actualDuration = current.actualDuration, + treeBaseDuration = current.selfBaseDuration, + shouldBubbleActualDurations = + null === current.alternate || + current.child !== current.alternate.child, + child = current.child; + null !== child; + + ) + (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 = current.child; null !== actualDuration; ) + (fiber |= actualDuration.lanes | actualDuration.childLanes), + (actualDuration = actualDuration.sibling); + current.childLanes = fiber; + } + null !== unitOfWork && + 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.flags && + (null !== unitOfWork.lastEffect + ? (unitOfWork.lastEffect.nextEffect = completedWork) + : (unitOfWork.firstEffect = completedWork), + (unitOfWork.lastEffect = completedWork))); } else { current = unwindWork(completedWork); if (null !== current) { - current.flags &= 8191; + current.flags &= 4095; workInProgress = current; return; } - if (0 !== (completedWork.mode & 4)) { + if (0 !== (completedWork.mode & 8)) { stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); current = completedWork.actualDuration; for (fiber = completedWork.child; null !== fiber; ) @@ -6803,9 +6427,8 @@ function completeUnitOfWork(unitOfWork) { completedWork.actualDuration = current; } null !== unitOfWork && - ((unitOfWork.flags |= 8192), - (unitOfWork.subtreeFlags = 0), - (unitOfWork.deletions = null)); + ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), + (unitOfWork.flags |= 4096)); } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -6836,65 +6459,271 @@ function commitRootImpl(root, renderPriorityLevel) { "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); root.callbackNode = null; - root.callbackPriority = 0; - var remainingLanes = finishedWork.lanes | finishedWork.childLanes; - markRootFinished(root, remainingLanes); + 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 & 8) && + 0 === (remainingLanes & 24) && rootsWithPendingDiscreteUpdates.has(root) && rootsWithPendingDiscreteUpdates.delete(root); root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - (0 === (finishedWork.subtreeFlags & 1040) && - 0 === (finishedWork.flags & 1040)) || - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); - remainingLanes = 0 !== (finishedWork.flags & 8054); - if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) { - remainingLanes = executionContext; + 1 < finishedWork.flags + ? null !== finishedWork.lastEffect + ? ((finishedWork.lastEffect.nextEffect = finishedWork), + (remainingLanes = finishedWork.firstEffect)) + : (remainingLanes = finishedWork) + : (remainingLanes = finishedWork.firstEffect); + if (null !== remainingLanes) { + remainingLanes$jscomp$0 = executionContext; executionContext |= 32; - var prevInteractions = pushInteractions(root); - ReactCurrentOwner$2.current = null; - commitBeforeMutationEffects(root, finishedWork); + eventTimes = pushInteractions(root); + focusedInstanceHandle = ReactCurrentOwner$2.current = null; + shouldFireAfterActiveInstanceBlur = !1; + nextEffect = remainingLanes; + do + try { + commitBeforeMutationEffects(); + } catch (error) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + focusedInstanceHandle = null; commitTime = now$1(); - commitMutationEffects(root, renderPriorityLevel, finishedWork); + nextEffect = remainingLanes; + do + try { + for (; null !== nextEffect; ) { + var flags = nextEffect.flags; + if (flags & 128) { + var current = nextEffect.alternate; + if (null !== current) { + var currentRef = current.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (flags & 1038) { + case 2: + nextEffect.flags &= -3; + break; + case 6: + nextEffect.flags &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 1024: + nextEffect.flags &= -1025; + break; + case 1028: + nextEffect.flags &= -1025; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + expirationTimes = nextEffect; + a: for (index$10 = noLongerPendingLanes = expirationTimes; ; ) { + lane = index$10; + if ( + injectedHook && + "function" === typeof injectedHook.onCommitFiberUnmount + ) + try { + injectedHook.onCommitFiberUnmount(rendererID, lane); + } catch (err) {} + switch (lane.tag) { + case 0: + case 11: + case 14: + case 15: + 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 (index$10 === noLongerPendingLanes) break; + for (; null === index$10.sibling; ) { + if ( + null === index$10.return || + index$10.return === noLongerPendingLanes + ) + break a; + index$10 = index$10.return; + } + index$10.sibling.return = index$10.return; + index$10 = index$10.sibling; + } + } + var alternate = expirationTimes.alternate; + detachFiberMutation(expirationTimes); + null !== alternate && detachFiberMutation(alternate); + } + nextEffect = nextEffect.nextEffect; + } + } catch (error$90) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error$90); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); root.current = finishedWork; - commitLayoutEffects(finishedWork, root, lanes); + nextEffect = remainingLanes; + do + try { + 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$jscomp$0 = nextEffect.stateNode; + switch (nextEffect.tag) { + case 5: + current = instance$jscomp$0.canonical; + break; + default: + current = instance$jscomp$0; + } + "function" === typeof ref + ? ref(current) + : (ref.current = current); + } + } + nextEffect = nextEffect.nextEffect; + } + } catch (error$91) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error$91); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + nextEffect = null; requestPaint(); - tracing.__interactionsRef.current = prevInteractions; - executionContext = remainingLanes; + tracing.__interactionsRef.current = eventTimes; + executionContext = remainingLanes$jscomp$0; } else (root.current = finishedWork), (commitTime = now$1()); - if ((prevInteractions = rootDoesHavePassiveEffects)) + if ((flags$jscomp$0 = rootDoesHavePassiveEffects)) (rootDoesHavePassiveEffects = !1), (rootWithPendingPassiveEffects = root), (pendingPassiveEffectsLanes = lanes), (pendingPassiveEffectsRenderPriority = renderPriorityLevel); + else + for (nextEffect = remainingLanes; null !== nextEffect; ) + (ref = nextEffect.nextEffect), + (nextEffect.nextEffect = null), + 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) { - var expirationTimes = spawnedWorkDuringRender; - spawnedWorkDuringRender = null; - for (var i = 0; i < expirationTimes.length; i++) + if (null !== spawnedWorkDuringRender) + for ( + ref = spawnedWorkDuringRender, + spawnedWorkDuringRender = null, + instance$jscomp$0 = 0; + instance$jscomp$0 < ref.length; + instance$jscomp$0++ + ) scheduleInteractions( root, - expirationTimes[i], + ref[instance$jscomp$0], root.memoizedInteractions ); - } schedulePendingInteractions(root, remainingLanes); } else legacyErrorBoundariesThatAlreadyFailed = null; - prevInteractions || finishPendingInteractions(root, lanes); - 0 !== (remainingLanes & 1) + flags$jscomp$0 || finishPendingInteractions(root, lanes); + 1 === remainingLanes ? root === rootWithNestedUpdates ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - onCommitRoot(finishedWork.stateNode, renderPriorityLevel); + 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), @@ -6905,6 +6734,30 @@ function commitRootImpl(root, renderPriorityLevel) { flushSyncCallbackQueue(); return null; } +function commitBeforeMutationEffects() { + for (; null !== nextEffect; ) { + 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() { + flushPassiveEffects(); + return null; + })); + nextEffect = nextEffect.nextEffect; + } +} function flushPassiveEffects() { if (90 !== pendingPassiveEffectsRenderPriority) { var priorityLevel = @@ -6916,6 +6769,24 @@ function flushPassiveEffects() { } 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, @@ -6926,104 +6797,41 @@ function flushPassiveEffectsImpl() { throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; executionContext |= 32; - var prevInteractions = pushInteractions(root); - for (nextEffect = root.current; null !== nextEffect; ) { - var fiber = nextEffect, - child = fiber.child; - if (0 !== (nextEffect.flags & 16)) { - var deletions = fiber.deletions; - if (null !== deletions) { - for (var i = 0; i < deletions.length; i++) { - var fiberToDelete = deletions[i]; - for (nextEffect = fiberToDelete; null !== nextEffect; ) { - var fiber$jscomp$0 = nextEffect; - switch (fiber$jscomp$0.tag) { - case 0: - case 11: - case 15: - commitHookEffectListUnmount(4, fiber$jscomp$0, fiber); - } - var child$jscomp$0 = fiber$jscomp$0.child; - if (null !== child$jscomp$0) - (child$jscomp$0.return = fiber$jscomp$0), - (nextEffect = child$jscomp$0); - else - for (; null !== nextEffect; ) { - fiber$jscomp$0 = nextEffect; - if (fiber$jscomp$0 === fiberToDelete) { - nextEffect = null; - break; - } - child$jscomp$0 = fiber$jscomp$0.sibling; - if (null !== child$jscomp$0) { - child$jscomp$0.return = fiber$jscomp$0.return; - nextEffect = child$jscomp$0; - break; - } - nextEffect = fiber$jscomp$0.return; - } - } - fiber$jscomp$0 = fiberToDelete.alternate; - detachFiberAfterEffects(fiberToDelete); - null !== fiber$jscomp$0 && detachFiberAfterEffects(fiber$jscomp$0); - } - nextEffect = fiber; - } - } - if (0 !== (fiber.subtreeFlags & 1040) && null !== child) - (child.return = fiber), (nextEffect = child); - else - a: for (; null !== nextEffect; ) { - fiber = nextEffect; - if (0 !== (fiber.flags & 1024)) - switch (fiber.tag) { - case 0: - case 11: - case 15: - commitHookEffectListUnmount(5, fiber, fiber.return); - } - child = fiber.sibling; - if (null !== child) { - child.return = fiber.return; - nextEffect = child; - break a; - } - nextEffect = fiber.return; + 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); } } - for (nextEffect = fiber = root.current; null !== nextEffect; ) - if ( - ((child = nextEffect), - (deletions = child.child), - 0 !== (child.subtreeFlags & 1040) && null !== deletions) - ) - (deletions.return = child), (nextEffect = deletions); - else - a: for (child = fiber; null !== nextEffect; ) { - deletions = nextEffect; - if (0 !== (deletions.flags & 1024)) - try { - switch (deletions.tag) { - case 0: - case 11: - case 15: - commitHookEffectListMount(5, deletions); - } - } catch (error) { - captureCommitPhaseError(deletions, deletions.return, error); - } - if (deletions === child) { - nextEffect = null; - break a; - } - i = deletions.sibling; - if (null !== i) { - i.return = deletions.return; - nextEffect = i; - break a; - } - nextEffect = deletions.return; - } + unmountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + for (i = 0; i < unmountEffects.length; i += 2) { + effect$96 = unmountEffects[i]; + fiber = unmountEffects[i + 1]; + try { + 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); + } + } + 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, lanes); executionContext = prevExecutionContext; @@ -7041,51 +6849,43 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { ensureRootIsScheduled(rootFiber, sourceFiber), schedulePendingInteractions(rootFiber, 1)); } -function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { +function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); else - for ( - nearestMountedAncestor = sourceFiber.return; - null !== nearestMountedAncestor; - - ) { - if (3 === nearestMountedAncestor.tag) { - captureCommitPhaseErrorOnRoot( - nearestMountedAncestor, - sourceFiber, - error - ); + for (var fiber = sourceFiber.return; null !== fiber; ) { + if (3 === fiber.tag) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); break; - } else if (1 === nearestMountedAncestor.tag) { - var instance = nearestMountedAncestor.stateNode; + } else if (1 === fiber.tag) { + var instance = fiber.stateNode; if ( - "function" === - typeof nearestMountedAncestor.type.getDerivedStateFromError || + "function" === typeof fiber.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 1 - ); - enqueueUpdate(nearestMountedAncestor, sourceFiber); - sourceFiber = requestEventTime(); - nearestMountedAncestor = markUpdateLaneFromFiberToRoot( - nearestMountedAncestor, - 1 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 1, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber), - schedulePendingInteractions(nearestMountedAncestor, 1)); + 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; } } - nearestMountedAncestor = nearestMountedAncestor.return; + fiber = fiber.return; } } function pingSuspendedRoot(root, wakeable, pingedLanes) { @@ -7097,7 +6897,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && (4 === workInProgressRootExitStatus || (3 === workInProgressRootExitStatus && - (workInProgressRootRenderLanes & 125829120) === + (workInProgressRootRenderLanes & 62914560) === workInProgressRootRenderLanes && 500 > now() - globalMostRecentFallbackTime) ? prepareFreshStack(root, 0) @@ -7111,13 +6911,14 @@ function resolveRetryWakeable(boundaryFiber, wakeable) { wakeable = 0; 0 === wakeable && ((wakeable = boundaryFiber.mode), - 0 === (wakeable & 1) + 0 === (wakeable & 2) ? (wakeable = 1) - : 0 === (wakeable & 2) + : 0 === (wakeable & 4) ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) - : ((wakeable = nextRetryLane), - (nextRetryLane <<= 1), - 0 === (nextRetryLane & 125829120) && (nextRetryLane = 8388608))); + : (0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes), + (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), + 0 === wakeable && (wakeable = 4194304))); retryCache = requestEventTime(); boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); null !== boundaryFiber && @@ -7134,90 +6935,85 @@ beginWork$1 = function(current, workInProgress, renderLanes) { didPerformWorkStackCursor.current ) didReceiveUpdate = !0; + else if (0 !== (renderLanes & updateLanes)) + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { - if (0 === (renderLanes & updateLanes)) { - 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.type._context; - var nextValue = workInProgress.memoizedProps.value; - push(valueCursor, updateLanes._currentValue2); - updateLanes._currentValue2 = nextValue; - 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( + 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 ); - return null !== workInProgress ? workInProgress.sibling : null; - } push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.flags & 128)) { - if (updateLanes) - return updateSuspenseListComponent( - current, - workInProgress, - renderLanes - ); - workInProgress.flags |= 128; - } - nextValue = workInProgress.memoizedState; - null !== nextValue && - ((nextValue.rendering = null), - (nextValue.tail = null), - (nextValue.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (updateLanes) break; - else return null; - case 22: - case 23: - return ( - (workInProgress.lanes = 0), - updateOffscreenComponent(current, workInProgress, renderLanes) + workInProgress = bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderLanes ); - } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderLanes - ); + 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, + renderLanes + ); + 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 22: + case 23: + return ( + (workInProgress.lanes = 0), + updateOffscreenComponent(current, workInProgress, renderLanes) + ); } - didReceiveUpdate = 0 !== (current.flags & 65536) ? !0 : !1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else didReceiveUpdate = !1; workInProgress.lanes = 0; @@ -7229,22 +7025,22 @@ beginWork$1 = function(current, workInProgress, renderLanes) { (workInProgress.alternate = null), (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - nextValue = getMaskedContext(workInProgress, contextStackCursor.current); + context = getMaskedContext(workInProgress, contextStackCursor.current); prepareToReadContext(workInProgress, renderLanes); - nextValue = renderWithHooks( + context = renderWithHooks( null, workInProgress, updateLanes, current, - nextValue, + context, renderLanes ); workInProgress.flags |= 1; if ( - "object" === typeof nextValue && - null !== nextValue && - "function" === typeof nextValue.render && - void 0 === nextValue.$$typeof + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof ) { workInProgress.tag = 1; workInProgress.memoizedState = null; @@ -7254,8 +7050,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { pushContextProvider(workInProgress); } else hasContext = !1; workInProgress.memoizedState = - null !== nextValue.state && void 0 !== nextValue.state - ? nextValue.state + null !== context.state && void 0 !== context.state + ? context.state : null; initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; @@ -7266,9 +7062,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { getDerivedStateFromProps, current ); - nextValue.updater = classComponentUpdater; - workInProgress.stateNode = nextValue; - nextValue._reactInternals = workInProgress; + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternals = workInProgress; mountClassInstance(workInProgress, updateLanes, current, renderLanes); workInProgress = finishClassComponent( null, @@ -7280,28 +7076,28 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); } else (workInProgress.tag = 0), - reconcileChildren(null, workInProgress, nextValue, renderLanes), + reconcileChildren(null, workInProgress, context, renderLanes), (workInProgress = workInProgress.child); return workInProgress; case 16: - nextValue = workInProgress.elementType; + context = workInProgress.elementType; a: { null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - hasContext = nextValue._init; - nextValue = hasContext(nextValue._payload); - workInProgress.type = nextValue; - hasContext = workInProgress.tag = resolveLazyComponentTag(nextValue); - current = resolveDefaultProps(nextValue, current); + hasContext = context._init; + context = hasContext(context._payload); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current = resolveDefaultProps(context, current); switch (hasContext) { case 0: workInProgress = updateFunctionComponent( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7310,7 +7106,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateClassComponent( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7319,7 +7115,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateForwardRef( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7328,8 +7124,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateMemoComponent( null, workInProgress, - nextValue, - resolveDefaultProps(nextValue.type, current), + context, + resolveDefaultProps(context.type, current), updateLanes, renderLanes ); @@ -7337,7 +7133,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } throw Error( "Element type is invalid. Received a promise that resolves to: " + - nextValue + + context + ". Lazy element type must resolve to a class or function." ); } @@ -7345,32 +7141,32 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 0: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateFunctionComponent( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); case 1: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateClassComponent( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); @@ -7381,18 +7177,19 @@ beginWork$1 = function(current, workInProgress, renderLanes) { 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." ); - nextValue = workInProgress.pendingProps; - updateLanes = workInProgress.memoizedState.element; + updateLanes = workInProgress.pendingProps; + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, nextValue, null, renderLanes); - nextValue = workInProgress.memoizedState.element; - nextValue === updateLanes + processUpdateQueue(workInProgress, updateLanes, null, renderLanes); + updateLanes = workInProgress.memoizedState.element; + updateLanes === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, renderLanes )) - : (reconcileChildren(current, workInProgress, nextValue, renderLanes), + : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), (workInProgress = workInProgress.child)); return workInProgress; case 5: @@ -7432,16 +7229,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 11: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateForwardRef( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); @@ -7482,21 +7279,27 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 10: a: { updateLanes = workInProgress.type._context; - nextValue = workInProgress.pendingProps; + context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; - hasContext = nextValue.value; - push(valueCursor, updateLanes._currentValue2); - updateLanes._currentValue2 = hasContext; - if (null !== getDerivedStateFromProps) { - var oldValue = getDerivedStateFromProps.value; - hasContext = objectIs(oldValue, hasContext) - ? 0 - : ("function" === typeof updateLanes._calculateChangedBits - ? updateLanes._calculateChangedBits(oldValue, hasContext) - : 1073741823) | 0; - if (0 === hasContext) { + hasContext = context.value; + var context$jscomp$0 = workInProgress.type._context; + push(valueCursor, context$jscomp$0._currentValue2); + context$jscomp$0._currentValue2 = hasContext; + if (null !== getDerivedStateFromProps) + if ( + ((context$jscomp$0 = getDerivedStateFromProps.value), + (hasContext = objectIs(context$jscomp$0, hasContext) + ? 0 + : ("function" === typeof updateLanes._calculateChangedBits + ? updateLanes._calculateChangedBits( + context$jscomp$0, + hasContext + ) + : 1073741823) | 0), + 0 === hasContext) + ) { if ( - getDerivedStateFromProps.children === nextValue.children && + getDerivedStateFromProps.children === context.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -7508,14 +7311,15 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } } else for ( - oldValue = workInProgress.child, - null !== oldValue && (oldValue.return = workInProgress); - null !== oldValue; + context$jscomp$0 = workInProgress.child, + null !== context$jscomp$0 && + (context$jscomp$0.return = workInProgress); + null !== context$jscomp$0; ) { - var list = oldValue.dependencies; + var list = context$jscomp$0.dependencies; if (null !== list) { - getDerivedStateFromProps = oldValue.child; + getDerivedStateFromProps = context$jscomp$0.child; for ( var dependency = list.firstContext; null !== dependency; @@ -7525,24 +7329,20 @@ beginWork$1 = function(current, workInProgress, renderLanes) { dependency.context === updateLanes && 0 !== (dependency.observedBits & hasContext) ) { - if (1 === oldValue.tag) { - dependency = createUpdate(-1, renderLanes & -renderLanes); - dependency.tag = 2; - var updateQueue = oldValue.updateQueue; - if (null !== updateQueue) { - updateQueue = updateQueue.shared; - var pending = updateQueue.pending; - null === pending - ? (dependency.next = dependency) - : ((dependency.next = pending.next), - (pending.next = dependency)); - updateQueue.pending = dependency; - } - } - oldValue.lanes |= renderLanes; - dependency = oldValue.alternate; + 1 === context$jscomp$0.tag && + ((dependency = createUpdate( + -1, + renderLanes & -renderLanes + )), + (dependency.tag = 2), + enqueueUpdate(context$jscomp$0, dependency)); + context$jscomp$0.lanes |= renderLanes; + dependency = context$jscomp$0.alternate; null !== dependency && (dependency.lanes |= renderLanes); - scheduleWorkOnParentPath(oldValue.return, renderLanes); + scheduleWorkOnParentPath( + context$jscomp$0.return, + renderLanes + ); list.lanes |= renderLanes; break; } @@ -7550,16 +7350,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } } else getDerivedStateFromProps = - 10 === oldValue.tag - ? oldValue.type === workInProgress.type + 10 === context$jscomp$0.tag + ? context$jscomp$0.type === workInProgress.type ? null - : oldValue.child - : oldValue.child; + : context$jscomp$0.child + : context$jscomp$0.child; if (null !== getDerivedStateFromProps) - getDerivedStateFromProps.return = oldValue; + getDerivedStateFromProps.return = context$jscomp$0; else for ( - getDerivedStateFromProps = oldValue; + getDerivedStateFromProps = context$jscomp$0; null !== getDerivedStateFromProps; ) { @@ -7567,21 +7367,20 @@ beginWork$1 = function(current, workInProgress, renderLanes) { getDerivedStateFromProps = null; break; } - oldValue = getDerivedStateFromProps.sibling; - if (null !== oldValue) { - oldValue.return = getDerivedStateFromProps.return; - getDerivedStateFromProps = oldValue; + context$jscomp$0 = getDerivedStateFromProps.sibling; + if (null !== context$jscomp$0) { + context$jscomp$0.return = getDerivedStateFromProps.return; + getDerivedStateFromProps = context$jscomp$0; break; } getDerivedStateFromProps = getDerivedStateFromProps.return; } - oldValue = getDerivedStateFromProps; + context$jscomp$0 = getDerivedStateFromProps; } - } reconcileChildren( current, workInProgress, - nextValue.children, + context.children, renderLanes ); workInProgress = workInProgress.child; @@ -7589,28 +7388,28 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return workInProgress; case 9: return ( - (nextValue = workInProgress.type), + (context = workInProgress.type), (hasContext = workInProgress.pendingProps), (updateLanes = hasContext.children), prepareToReadContext(workInProgress, renderLanes), - (nextValue = readContext(nextValue, hasContext.unstable_observedBits)), - (updateLanes = updateLanes(nextValue)), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateLanes = updateLanes(context)), (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); case 14: return ( - (nextValue = workInProgress.type), + (context = workInProgress.type), (hasContext = resolveDefaultProps( - nextValue, + context, workInProgress.pendingProps )), - (hasContext = resolveDefaultProps(nextValue.type, hasContext)), + (hasContext = resolveDefaultProps(context.type, hasContext)), updateMemoComponent( current, workInProgress, - nextValue, + context, hasContext, updateLanes, renderLanes @@ -7628,11 +7427,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 17: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), @@ -7642,8 +7441,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), prepareToReadContext(workInProgress, renderLanes), - constructClassInstance(workInProgress, updateLanes, nextValue), - mountClassInstance(workInProgress, updateLanes, nextValue, renderLanes), + constructClassInstance(workInProgress, updateLanes, context), + mountClassInstance(workInProgress, updateLanes, context, renderLanes), finishClassComponent( null, workInProgress, @@ -7744,9 +7543,9 @@ function finishPendingInteractions(root, committedLanes) { if (null !== subscriber && 0 === interaction.__count) try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error$95) { + } catch (error$102) { scheduleCallback(99, function() { - throw error$95; + throw error$102; }); } })); @@ -7762,8 +7561,8 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.subtreeFlags = this.flags = 0; - this.deletions = null; + this.flags = 0; + this.lastEffect = this.firstEffect = this.nextEffect = null; this.childLanes = this.lanes = 0; this.alternate = null; this.actualDuration = 0; @@ -7804,11 +7603,11 @@ function createWorkInProgress(current, pendingProps) { : ((workInProgress.pendingProps = pendingProps), (workInProgress.type = current.type), (workInProgress.flags = 0), - (workInProgress.subtreeFlags = 0), - (workInProgress.deletions = null), + (workInProgress.nextEffect = null), + (workInProgress.firstEffect = null), + (workInProgress.lastEffect = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.flags = current.flags & 131072; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -7845,18 +7644,15 @@ function createFiberFromTypeAndProps( return createFiberFromFragment(pendingProps.children, mode, lanes, key); case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = 8; - mode |= 8; + mode |= 16; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; - 1 <= - (null == pendingProps.unstable_level - ? 1 - : pendingProps.unstable_level) && (mode |= 16); + mode |= 1; break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.lanes = lanes), @@ -8047,8 +7843,7 @@ function updateContainer(element, container, parentComponent, callback) { callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - element = scheduleUpdateOnFiber(current, lane, eventTime); - null !== element && entangleTransitions(element, current, lane); + scheduleUpdateOnFiber(current, lane, eventTime); return lane; } function emptyFindFiberByHostInstance() { @@ -8080,10 +7875,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_941 = { + devToolsConfig$jscomp$inline_887 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "17.0.2", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8098,11 +7893,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1218 = { - bundleType: devToolsConfig$jscomp$inline_941.bundleType, - version: devToolsConfig$jscomp$inline_941.version, - rendererPackageName: devToolsConfig$jscomp$inline_941.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_941.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, @@ -8117,7 +7912,7 @@ var internals$jscomp$inline_1218 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_941.findFiberByHostInstance || + devToolsConfig$jscomp$inline_887.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, @@ -8126,16 +7921,16 @@ var internals$jscomp$inline_1218 = { getCurrentFiber: null }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1219 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1088 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1219.isDisabled && - hook$jscomp$inline_1219.supportsFiber + !hook$jscomp$inline_1088.isDisabled && + hook$jscomp$inline_1088.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1219.inject( - internals$jscomp$inline_1218 + (rendererID = hook$jscomp$inline_1088.inject( + internals$jscomp$inline_1087 )), - (injectedHook = hook$jscomp$inline_1219); + (injectedHook = hook$jscomp$inline_1088); } catch (err) {} } exports.createPortal = function(children, containerTag) { @@ -8178,7 +7973,7 @@ exports.render = function(element, containerTag, callback) { if (!root) { root = new FiberRootNode(containerTag, 0, !1); var JSCompiler_inline_result = 0; - isDevToolsPresent && (JSCompiler_inline_result |= 4); + isDevToolsPresent && (JSCompiler_inline_result |= 8); JSCompiler_inline_result = createFiber( 3, null, @@ -8187,7 +7982,6 @@ exports.render = function(element, containerTag, callback) { ); root.current = JSCompiler_inline_result; JSCompiler_inline_result.stateNode = root; - JSCompiler_inline_result.memoizedState = { element: null }; initializeUpdateQueue(JSCompiler_inline_result); roots.set(containerTag, root); } diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 96a631c87dd..6b9ea503d38 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -1237,10 +1237,10 @@ var LazyComponent = 16; var IncompleteClassComponent = 17; var DehydratedFragment = 18; var SuspenseListComponent = 19; +var FundamentalComponent = 20; var ScopeComponent = 21; var OffscreenComponent = 22; var LegacyHiddenComponent = 23; -var CacheComponent = 24; /** * Instance of element that should respond to touch/move types of interactions, @@ -2864,12 +2864,12 @@ var REACT_SUSPENSE_TYPE = 0xead1; var REACT_SUSPENSE_LIST_TYPE = 0xead8; var REACT_MEMO_TYPE = 0xead3; var REACT_LAZY_TYPE = 0xead4; +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; -var REACT_CACHE_TYPE = 0xeae4; if (typeof Symbol === "function" && Symbol.for) { var symbolFor = Symbol.for; @@ -2885,12 +2885,12 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); + 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"); - REACT_CACHE_TYPE = symbolFor("react.cache"); } var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; @@ -2964,9 +2964,6 @@ function getComponentName(type) { case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList"; - - case REACT_CACHE_TYPE: - return "Cache"; } if (typeof type === "object") { @@ -3004,10 +3001,9 @@ function getComponentName(type) { // The rest of the flags are static for better dead code elimination. var enableProfilerTimer = true; -var enableLazyElements = false; +var enableFundamentalAPI = false; var warnAboutStringRefs = false; var enableNewReconciler = false; -var deferRenderPhaseUpdateToNextBatch = true; // Don't change these two values. They're used by React Dev Tools. var NoFlags = @@ -3025,84 +3021,53 @@ var Update = 4; var PlacementAndUpdate = /* */ - Placement | Update; -var ChildDeletion = - /* */ - 16; + 6; +var Deletion = + /* */ + 8; var ContentReset = /* */ - 32; + 16; var Callback = /* */ - 64; + 32; var DidCapture = /* */ - 128; + 64; var Ref = /* */ - 256; + 128; var Snapshot = /* */ - 512; + 256; var Passive = /* */ - 1024; + 512; var Hydrating = /* */ - 2048; + 1024; var HydratingAndUpdate = /* */ - Hydrating | Update; -var Visibility = - /* */ - 4096; + 1028; var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot; // Union of all commit flags (flags with the lifetime of a particular commit) var HostEffectMask = /* */ - 8191; // 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 = /* */ - 8192; + 4096; var ShouldCapture = /* */ - 16384; // TODO (effects) Remove this bit once the new reconciler is synced to the old. + 8192; // TODO (effects) Remove this bit once the new reconciler is synced to the old. var PassiveUnmountPendingDev = /* */ - 32768; + 16384; var ForceUpdateForLegacySuspense = /* */ - 65536; // Static tags describe aspects of a fiber that are not specific to a render, -// e.g. a fiber uses a passive effect (even if there are no updates on this particular render). -// This enables us to defer more work in the unmount case, -// since we can defer traversing the tree during layout to look for Passive effects, -// and instead rely on the static flag as a signal that there may be cleanup work. - -var PassiveStatic = - /* */ - 131072; // These flags allow us to traverse to fibers that have effects on mount -// don't contain effects, by checking subtreeFlags. - -var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visiblity - // flag logic (see #20043) - Update | Snapshot | 0; -var MutationMask = - Placement | - Update | - ChildDeletion | - ContentReset | - Ref | - Hydrating | - Visibility; -var LayoutMask = Update | Callback | Ref; // TODO: Split into PassiveMountMask and PassiveUnmountMask - -var PassiveMask = Passive | ChildDeletion; // Union of tags that don't get reset on clones. -// This allows certain concepts to persist without recalculting them, -// e.g. whether a subtree contains passive effects or portals. - -var StaticMask = PassiveStatic; + 32768; // Static tags describe aspects of a fiber that are not specific to a render, var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -3342,28 +3307,38 @@ function findCurrentFiberUsingSlowPath(fiber) { } function findCurrentHostFiber(parent) { var currentParent = findCurrentFiberUsingSlowPath(parent); - return currentParent !== null - ? findCurrentHostFiberImpl(currentParent) - : null; -} -function findCurrentHostFiberImpl(node) { - // Next we'll drill down this component to find the first HostComponent/Text. - if (node.tag === HostComponent || node.tag === HostText) { - return node; - } + if (!currentParent) { + return null; + } // Next we'll drill down this component to find the first HostComponent/Text. - var child = node.child; + var node = currentParent; - while (child !== null) { - var match = findCurrentHostFiberImpl(child); - - if (match !== null) { - return match; + while (true) { + if (node.tag === HostComponent || node.tag === HostText) { + return node; + } else if (node.child) { + node.child.return = node; + node = node.child; + continue; } - child = child.sibling; - } + if (node === currentParent) { + return null; + } + + while (!node.sibling) { + if (!node.return || node.return === currentParent) { + return null; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } // Flow needs the return null here, but ESLint complains about it. + // eslint-disable-next-line no-unreachable return null; } @@ -3984,961 +3959,6 @@ var ReactNativeFiberHostComponent = /*#__PURE__*/ (function() { return ReactNativeFiberHostComponent; })(); // eslint-disable-next-line no-unused-expressions -// 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; - -{ - // 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" - ); - } -} - -// 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. -var ImmediatePriority = 99; -var UserBlockingPriority = 98; -var NormalPriority = 97; -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; - - case NormalPriority: - return Scheduler_NormalPriority; - - case LowPriority: - return Scheduler_LowPriority; - - case IdlePriority: - return Scheduler_IdlePriority; - - default: { - throw Error("Unknown priority level."); - } - } -} - -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]; // TODO: Figure out how to remove this It's only here as a last resort if we - // forget to explicitly flush. - - { - // Flush the queue in the next tick. - 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); - } -} -function cancelCallback(callbackNode) { - Scheduler_cancelCallback(callbackNode); -} -function flushSyncCallbackQueue() { - if (immediateQueueCallbackNode !== null) { - var node = immediateQueueCallbackNode; - immediateQueueCallbackNode = null; - Scheduler_cancelCallback(node); - } - - flushSyncCallbackQueueImpl(); -} - -function flushSyncCallbackQueueImpl() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrancy. - isFlushingSyncQueue = true; - var i = 0; - - { - try { - var _isSync2 = true; - var _queue = syncQueue; - runWithPriority(ImmediatePriority, 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 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; // Lane values below should be kept in sync with getLabelsForLanes(), used by react-devtools-scheduling-profiler. -// If those values are changed that package should be rebuilt and redeployed. - -var TotalLanes = 31; -var NoLanes = - /* */ - 0; -var NoLane = - /* */ - 0; -var SyncLane = - /* */ - 1; -var SyncBatchedLane = - /* */ - 2; -var InputDiscreteHydrationLane = - /* */ - 4; -var InputDiscreteLane = - /* */ - 8; -var InputContinuousHydrationLane = - /* */ - 16; -var InputContinuousLane = - /* */ - 32; -var DefaultHydrationLane = - /* */ - 64; -var DefaultLane = - /* */ - 128; -var TransitionHydrationLane = - /* */ - 256; -var TransitionLanes = - /* */ - 8388096; -var TransitionLane1 = - /* */ - 512; -var TransitionLane2 = - /* */ - 1024; -var TransitionLane3 = - /* */ - 2048; -var TransitionLane4 = - /* */ - 4096; -var TransitionLane5 = - /* */ - 8192; -var TransitionLane6 = - /* */ - 16384; -var TransitionLane7 = - /* */ - 32768; -var TransitionLane8 = - /* */ - 65536; -var TransitionLane9 = - /* */ - 131072; -var TransitionLane10 = - /* */ - 262144; -var TransitionLane11 = - /* */ - 524288; -var TransitionLane12 = - /* */ - 1048576; -var TransitionLane13 = - /* */ - 2097152; -var TransitionLane14 = - /* */ - 4194304; -var RetryLanes = - /* */ - 125829120; -var RetryLane1 = - /* */ - 8388608; -var RetryLane2 = - /* */ - 16777216; -var RetryLane3 = - /* */ - 33554432; -var RetryLane4 = - /* */ - 67108864; -var SomeRetryLane = RetryLane1; -var SelectiveHydrationLane = - /* */ - 134217728; -var NonIdleLanes = - /* */ - 268435455; -var IdleHydrationLane = - /* */ - 268435456; -var IdleLane = - /* */ - 536870912; -var OffscreenLane = - /* */ - 1073741824; // This function is used for the experimental scheduling profiler (react-devtools-scheduling-profiler) -var NoTimestamp = -1; -var nextTransitionLane = TransitionLane1; -var nextRetryLane = RetryLane1; -// Used by getHighestPriorityLanes and getNextLanes: - -var return_highestLanePriority = DefaultLanePriority; - -function getHighestPriorityLanes(lanes) { - switch (getHighestPriorityLane(lanes)) { - case SyncLane: - return_highestLanePriority = SyncLanePriority; - return SyncLane; - - case SyncBatchedLane: - return_highestLanePriority = SyncBatchedLanePriority; - return SyncBatchedLane; - - case InputDiscreteHydrationLane: - return_highestLanePriority = InputDiscreteHydrationLanePriority; - return InputDiscreteHydrationLane; - - case InputDiscreteLane: - return_highestLanePriority = InputDiscreteLanePriority; - return InputDiscreteLane; - - case InputContinuousHydrationLane: - return_highestLanePriority = InputContinuousHydrationLanePriority; - return InputContinuousHydrationLane; - - case InputContinuousLane: - return_highestLanePriority = InputContinuousLanePriority; - return InputContinuousLane; - - case DefaultHydrationLane: - return_highestLanePriority = DefaultHydrationLanePriority; - return DefaultHydrationLane; - - case DefaultLane: - return_highestLanePriority = DefaultLanePriority; - return DefaultLane; - - case TransitionHydrationLane: - return_highestLanePriority = TransitionHydrationPriority; - return TransitionHydrationLane; - - case TransitionLane1: - case TransitionLane2: - case TransitionLane3: - case TransitionLane4: - case TransitionLane5: - case TransitionLane6: - case TransitionLane7: - case TransitionLane8: - case TransitionLane9: - case TransitionLane10: - case TransitionLane11: - case TransitionLane12: - case TransitionLane13: - case TransitionLane14: - return_highestLanePriority = TransitionPriority; - return lanes & TransitionLanes; - - case RetryLane1: - case RetryLane2: - case RetryLane3: - case RetryLane4: - return_highestLanePriority = RetryLanePriority; - return lanes & RetryLanes; - - case SelectiveHydrationLane: - return_highestLanePriority = SelectiveHydrationLanePriority; - return SelectiveHydrationLane; - - case IdleHydrationLane: - return_highestLanePriority = IdleHydrationLanePriority; - return IdleHydrationLane; - - case IdleLane: - return_highestLanePriority = IdleLanePriority; - return IdleLane; - - case OffscreenLane: - return_highestLanePriority = OffscreenLanePriority; - return OffscreenLane; - - default: - { - 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_highestLanePriority = DefaultLanePriority; - return lanes; - } -} - -function schedulerPriorityToLanePriority(schedulerPriorityLevel) { - switch (schedulerPriorityLevel) { - case ImmediatePriority: - return SyncLanePriority; - - case UserBlockingPriority: - return InputContinuousLanePriority; - - case NormalPriority: - case LowPriority: - // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. - return DefaultLanePriority; - - case IdlePriority: - return IdleLanePriority; - - default: - return NoLanePriority; - } -} -function lanePriorityToSchedulerPriority(lanePriority) { - switch (lanePriority) { - case SyncLanePriority: - case SyncBatchedLanePriority: - return ImmediatePriority; - - case InputDiscreteHydrationLanePriority: - case InputDiscreteLanePriority: - case InputContinuousHydrationLanePriority: - case InputContinuousLanePriority: - return UserBlockingPriority; - - case DefaultHydrationLanePriority: - case DefaultLanePriority: - case TransitionHydrationPriority: - case TransitionPriority: - case SelectiveHydrationLanePriority: - case RetryLanePriority: - return NormalPriority; - - 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." - ); - } - } -} -function getNextLanes(root, wipLanes) { - // Early bailout if there's no pending work left. - var pendingLanes = root.pendingLanes; - - if (pendingLanes === NoLanes) { - return_highestLanePriority = NoLanePriority; - return NoLanes; - } - - var nextLanes = NoLanes; - var nextLanePriority = NoLanePriority; - var expiredLanes = root.expiredLanes; - var suspendedLanes = root.suspendedLanes; - var pingedLanes = root.pingedLanes; // Check if any work has expired. - - if (expiredLanes !== NoLanes) { - // TODO: Should entangle with SyncLane - 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 (nonIdlePendingLanes !== NoLanes) { - var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; - - 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; - - 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 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 ( - 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; - - if ( - nextLanePriority <= wipLanePriority || // Default priority updates should not interrupt transition updates. The - // only difference between default updates and transition updates is that - // default updates do not support refresh transitions. - (nextLanePriority === DefaultLanePriority && - wipLanePriority === TransitionPriority) - ) { - // Keep working on the existing in-progress tree. Do not interrupt. - 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. - // TODO: Reconsider this. The counter-argument is that the partial work - // represents an intermediate state, which we don't want to show to the user. - // And by spending extra time finishing it, we're increasing the amount of - // time it takes to show the final state, which is what they are actually - // waiting for. - // - // 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. - - var entangledLanes = root.entangledLanes; - - 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; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - var eventTime = eventTimes[index]; - - if (eventTime > mostRecentEventTime) { - mostRecentEventTime = eventTime; - } - - lanes &= ~lane; - } - - return mostRecentEventTime; -} - -function computeExpirationTime(lane, currentTime) { - // TODO: Expiration heuristic is constant per lane, so could use a map. - getHighestPriorityLanes(lane); - var priority = return_highestLanePriority; - - 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; - - if (everythingButOffscreen !== NoLanes) { - return everythingButOffscreen; - } - - if (everythingButOffscreen & OffscreenLane) { - return OffscreenLane; - } - - return NoLanes; -} -function returnNextLanesPriority() { - return return_highestLanePriority; -} -function includesNonIdleWork(lanes) { - return (lanes & NonIdleLanes) !== NoLanes; -} -function includesOnlyRetries(lanes) { - return (lanes & RetryLanes) === lanes; -} -function includesOnlyTransitions(lanes) { - return (lanes & TransitionLanes) === lanes; -} -function isTransitionLane(lane) { - return (lane & TransitionLanes) !== 0; -} // 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) { - switch (lanePriority) { - case NoLanePriority: - break; - - case SyncLanePriority: - return SyncLane; - - case SyncBatchedLanePriority: - return SyncBatchedLane; - - case InputDiscreteLanePriority: - return InputDiscreteLane; - - case InputContinuousLanePriority: - return InputContinuousLane; - - case DefaultLanePriority: - return DefaultLane; - - case TransitionPriority: // Should be handled by findTransitionLane instead - - case RetryLanePriority: - // Should be handled by findRetryLane instead - break; - - case IdleLanePriority: - return IdleLane; - } - - { - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } -} -function claimNextTransitionLane() { - // Cycle through the lanes, assigning each new transition to the next lane. - // In most cases, this means every transition gets its own lane, until we - // run out of lanes and cycle back to the beginning. - var lane = nextTransitionLane; - nextTransitionLane <<= 1; - - if ((nextTransitionLane & TransitionLanes) === 0) { - nextTransitionLane = TransitionLane1; - } - - return lane; -} -function claimNextRetryLane() { - var lane = nextRetryLane; - nextRetryLane <<= 1; - - if ((nextRetryLane & RetryLanes) === 0) { - nextRetryLane = RetryLane1; - } - - return lane; -} - -function getHighestPriorityLane(lanes) { - return lanes & -lanes; -} - -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); -} - -function pickArbitraryLaneIndex(lanes) { - return 31 - clz32(lanes); -} - -function laneToIndex(lane) { - return pickArbitraryLaneIndex(lane); -} - -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; -} -function intersectLanes(a, b) { - return a & b; -} // Seems redundant, but it changes the type from a single lane (used for -// updates) to a group of lanes (used for flushing work). - -function laneToLanes(lane) { - return lane; -} -function createLaneMap(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; // If there are any suspended transitions, it's possible this new update - // could unblock them. Clear the suspended lanes so that we can try rendering - // them again. - // - // TODO: We really only need to unsuspend only lanes that are in the - // `subtreeLanes` of the updated fiber, or the update lanes of the return - // path. This would exclude suspended updates in an unrelated sibling tree, - // since there's no way for this update to unblock it. - // - // We don't do this if the incoming update is idle, because we never process - // idle updates until after all the regular updates have finished; there's no - // way it could unblock a transition. - - if (updateLane !== IdleLane) { - root.suspendedLanes = NoLanes; - root.pingedLanes = NoLanes; - } - - 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. - - 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 markRootExpired(root, expiredLanes) { - root.expiredLanes |= expiredLanes & root.pendingLanes; -} -function hasDiscreteLanes(lanes) { - return (lanes & InputDiscreteLane) !== 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) { - // In addition to entangling each of the given lanes with each other, we also - // have to consider _transitive_ entanglements. For each lane that is already - // entangled with *any* of the given lanes, that lane is now transitively - // entangled with *all* the given lanes. - // - // Translated: If C is entangled with A, then entangling A with B also - // entangles C with B. - // - // If this is hard to grasp, it might help to intentionally break this - // function and look at the tests that fail in ReactTransition-test.js. Try - // commenting out one of the conditions below. - var rootEntangledLanes = (root.entangledLanes |= entangledLanes); - var entanglements = root.entanglements; - var lanes = rootEntangledLanes; - - while (lanes) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - - if ( - // Is this one of the newly entangled lanes? - (lane & entangledLanes) | // Is this lane transitively entangled with the newly entangled lanes? - (entanglements[index] & entangledLanes) - ) { - 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_now$1 = Scheduler.unstable_now; - -{ - // 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" - ); - } -} -var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. - // can re-export everything from this module. function shim() { @@ -5126,7 +4146,7 @@ function shouldSetTextContent(type, props) { // It's not clear to me which is better so I'm deferring for now. // More context @ github.com/facebook/react/pull/8560#discussion_r92111303 return false; -} +} // ------------------- function appendChild(parentInstance, child) { var childTag = typeof child === "number" ? child : child._nativeTag; var children = parentInstance._children; @@ -6061,47 +5081,953 @@ function onCommitUnmount(fiber) { } } -var NoFlags$1 = - /* */ - 0; // Represents whether effect should fire. +// Intentionally not named imports because Rollup would use dynamic dispatch for +var Scheduler_now = Scheduler.unstable_now; -var HasEffect = - /* */ - 1; // Represents the phase in which the effect (not the clean-up) fires. +{ + // 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" + ); + } +} +// ascending numbers so we can compare them like numbers. They start at 90 to +// avoid clashing with Scheduler's priorities. -var Layout = - /* */ +var ImmediatePriority = 99; +var UserBlockingPriority = 98; +var NormalPriority = 97; +var LowPriority = 96; +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 = 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 Passive$1 = - /* */ +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; + +function getHighestPriorityLanes(lanes) { + if ((SyncLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncLanePriority; + return SyncLane; + } + + if ((SyncBatchedLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncBatchedLanePriority; + return SyncBatchedLane; + } + + if ((InputDiscreteHydrationLane & lanes) !== NoLanes) { + return_highestLanePriority = InputDiscreteHydrationLanePriority; + return InputDiscreteHydrationLane; + } + + var inputDiscreteLanes = InputDiscreteLanes & lanes; + + if (inputDiscreteLanes !== NoLanes) { + return_highestLanePriority = InputDiscreteLanePriority; + return inputDiscreteLanes; + } + + if ((lanes & InputContinuousHydrationLane) !== NoLanes) { + return_highestLanePriority = InputContinuousHydrationLanePriority; + return InputContinuousHydrationLane; + } + + var inputContinuousLanes = InputContinuousLanes & lanes; + + if (inputContinuousLanes !== NoLanes) { + return_highestLanePriority = InputContinuousLanePriority; + return inputContinuousLanes; + } + + if ((lanes & DefaultHydrationLane) !== NoLanes) { + return_highestLanePriority = DefaultHydrationLanePriority; + return DefaultHydrationLane; + } + + var defaultLanes = DefaultLanes & lanes; + + if (defaultLanes !== NoLanes) { + return_highestLanePriority = DefaultLanePriority; + return defaultLanes; + } + + if ((lanes & TransitionHydrationLane) !== NoLanes) { + return_highestLanePriority = TransitionHydrationPriority; + return TransitionHydrationLane; + } + + var transitionLanes = TransitionLanes & lanes; + + if (transitionLanes !== NoLanes) { + return_highestLanePriority = TransitionPriority; + return transitionLanes; + } + + var retryLanes = RetryLanes & lanes; + + if (retryLanes !== NoLanes) { + return_highestLanePriority = RetryLanePriority; + return retryLanes; + } + + if (lanes & SelectiveHydrationLane) { + return_highestLanePriority = SelectiveHydrationLanePriority; + return SelectiveHydrationLane; + } + + if ((lanes & IdleHydrationLane) !== NoLanes) { + return_highestLanePriority = IdleHydrationLanePriority; + return IdleHydrationLane; + } + + var idleLanes = IdleLanes & lanes; + + if (idleLanes !== NoLanes) { + return_highestLanePriority = IdleLanePriority; + return idleLanes; + } + + if ((OffscreenLane & lanes) !== NoLanes) { + return_highestLanePriority = OffscreenLanePriority; + return OffscreenLane; + } + + { + 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_highestLanePriority = DefaultLanePriority; + return lanes; +} + +function schedulerPriorityToLanePriority(schedulerPriorityLevel) { + switch (schedulerPriorityLevel) { + case ImmediatePriority: + return SyncLanePriority; + + case UserBlockingPriority: + return InputContinuousLanePriority; + + case NormalPriority: + case LowPriority: + // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. + return DefaultLanePriority; + + case IdlePriority: + return IdleLanePriority; + + default: + return NoLanePriority; + } +} +function lanePriorityToSchedulerPriority(lanePriority) { + switch (lanePriority) { + case SyncLanePriority: + case SyncBatchedLanePriority: + return ImmediatePriority; + + case InputDiscreteHydrationLanePriority: + case InputDiscreteLanePriority: + case InputContinuousHydrationLanePriority: + case InputContinuousLanePriority: + return UserBlockingPriority; + + case DefaultHydrationLanePriority: + case DefaultLanePriority: + case TransitionHydrationPriority: + case TransitionPriority: + case SelectiveHydrationLanePriority: + case RetryLanePriority: + return NormalPriority; + + 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." + ); + } + } +} +function getNextLanes(root, wipLanes) { + // Early bailout if there's no pending work left. + var pendingLanes = root.pendingLanes; + + if (pendingLanes === NoLanes) { + return_highestLanePriority = NoLanePriority; + return NoLanes; + } + + var nextLanes = NoLanes; + var nextLanePriority = NoLanePriority; + var expiredLanes = root.expiredLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; // Check if any work has expired. + + 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 (nonIdlePendingLanes !== NoLanes) { + var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; + + 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; + + 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 ( + 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; + + 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. + + var entangledLanes = root.entangledLanes; + + 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; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + var eventTime = eventTimes[index]; + + if (eventTime > mostRecentEventTime) { + mostRecentEventTime = eventTime; + } + + lanes &= ~lane; + } + + return mostRecentEventTime; +} + +function computeExpirationTime(lane, currentTime) { + // TODO: Expiration heuristic is constant per lane, so could use a map. + getHighestPriorityLanes(lane); + var priority = return_highestLanePriority; + + 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; + + if (everythingButOffscreen !== NoLanes) { + return everythingButOffscreen; + } + + if (everythingButOffscreen & OffscreenLane) { + return OffscreenLane; + } + + return NoLanes; +} +function returnNextLanesPriority() { + return return_highestLanePriority; +} +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. + +function findUpdateLane(lanePriority, wipLanes) { + switch (lanePriority) { + case NoLanePriority: + break; + + case SyncLanePriority: + return SyncLane; + + case SyncBatchedLanePriority: + return SyncBatchedLane; + + case InputDiscreteLanePriority: { + var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes); + + if (_lane === NoLane) { + // Shift to the next priority level + return findUpdateLane(InputContinuousLanePriority, wipLanes); + } + + return _lane; + } + + case InputContinuousLanePriority: { + var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes); + + if (_lane2 === NoLane) { + // Shift to the next priority level + return findUpdateLane(DefaultLanePriority, wipLanes); + } + + return _lane2; + } + + case DefaultLanePriority: { + var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes); + + 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 (_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); + } + } + + return _lane3; + } + + case TransitionPriority: // Should be handled by findTransitionLane instead + + case RetryLanePriority: + // Should be handled by findRetryLane instead + break; + + case IdleLanePriority: + var lane = pickArbitraryLane(IdleLanes & ~wipLanes); + + if (lane === NoLane) { + lane = pickArbitraryLane(IdleLanes); + } + + return lane; + } + + { + 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. + +function findTransitionLane(wipLanes, pendingLanes) { + // First look for lanes that are completely unclaimed, i.e. have no + // pending work. + var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes); + + 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); + } + } + + 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. + +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); + + if (lane === NoLane) { + lane = pickArbitraryLane(RetryLanes); + } + + return lane; +} + +function getHighestPriorityLane(lanes) { + return lanes & -lanes; +} + +function getLowestPriorityLane(lanes) { + // This finds the most significant non-zero bit. + var index = 31 - clz32(lanes); + return index < 0 ? NoLanes : 1 << index; +} + +function getEqualOrHigherPriorityLanes(lanes) { + return (getLowestPriorityLane(lanes) << 1) - 1; +} + +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); +} + +function pickArbitraryLaneIndex(lanes) { + return 31 - clz32(lanes); +} + +function laneToIndex(lane) { + return pickArbitraryLaneIndex(lane); +} + +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). + +function laneToLanes(lane) { + return lane; +} +function createLaneMap(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 + // 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. + + var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111 + + 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. + + 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" + ); + } +} + +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. + +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. + +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 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; + + case Scheduler_UserBlockingPriority: + return UserBlockingPriority$1; + + case Scheduler_NormalPriority: + return NormalPriority$1; + + case Scheduler_LowPriority: + return LowPriority$1; + + case Scheduler_IdlePriority: + return IdlePriority$1; + + default: { + throw Error("Unknown priority level."); + } + } +} + +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case ImmediatePriority$1: + return Scheduler_ImmediatePriority; + + case UserBlockingPriority$1: + return Scheduler_UserBlockingPriority; + + case NormalPriority$1: + return Scheduler_NormalPriority; + + case LowPriority$1: + return Scheduler_LowPriority; + + case IdlePriority$1: + return Scheduler_IdlePriority; + + default: { + throw Error("Unknown priority level."); + } + } +} + +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. + + 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 fakeCallbackNode; +} +function cancelCallback(callbackNode) { + if (callbackNode !== fakeCallbackNode) { + Scheduler_cancelCallback(callbackNode); + } +} +function flushSyncCallbackQueue() { + if (immediateQueueCallbackNode !== null) { + var node = immediateQueueCallbackNode; + immediateQueueCallbackNode = null; + Scheduler_cancelCallback(node); + } + + flushSyncCallbackQueueImpl(); +} + +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; + } + } + } +} // TODO: this is special because it gets imported during build. -// -// TODO: 17.0.2 has not been released to NPM; -// It exists as a placeholder so that DevTools can support work tag changes between releases. -// When we next publish a release (either 17.0.2 or 17.1.0), update the matching TODO in backend/renderer.js -var ReactVersion = "17.0.2"; +var ReactVersion = "17.0.1-454c2211c"; -var NoMode = - /* */ - 0; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root tag instead +var NoMode = 0; +var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root +// tag instead -var BlockingMode = - /* */ - 1; -var ConcurrentMode = - /* */ - 2; -var ProfileMode = - /* */ - 4; -var DebugTracingMode = - /* */ - 8; -var StrictLegacyMode = - /* */ - 16; +var BlockingMode = 2; +var ConcurrentMode = 4; +var ProfileMode = 8; +var DebugTracingMode = 16; var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -6279,7 +6205,7 @@ var ReactStrictModeWarnings = { var node = fiber; while (node !== null) { - if (node.mode & StrictLegacyMode) { + if (node.mode & StrictMode) { maybeStrictRoot = node; } @@ -6310,7 +6236,7 @@ var ReactStrictModeWarnings = { fiber, instance ) { - // Dedupe strategy: Warn once per component. + // Dedup strategy: Warn once per component. if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { return; } @@ -6323,7 +6249,7 @@ var ReactStrictModeWarnings = { } if ( - fiber.mode & StrictLegacyMode && + fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === "function" ) { pendingUNSAFE_ComponentWillMountWarnings.push(fiber); @@ -6337,7 +6263,7 @@ var ReactStrictModeWarnings = { } if ( - fiber.mode & StrictLegacyMode && + fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === "function" ) { pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); @@ -6351,7 +6277,7 @@ var ReactStrictModeWarnings = { } if ( - fiber.mode & StrictLegacyMode && + fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === "function" ) { pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); @@ -6669,7 +6595,9 @@ function exitDisallowedContextReadInDEV() { isDisallowedContextReadInDEV = false; } } -function pushProvider(providerFiber, context, nextValue) { +function pushProvider(providerFiber, nextValue) { + var context = providerFiber.type._context; + { push(valueCursor, context._currentValue, providerFiber); context._currentValue = nextValue; @@ -6690,9 +6618,10 @@ function pushProvider(providerFiber, context, nextValue) { } } } -function popProvider(context, providerFiber) { +function popProvider(providerFiber) { var currentValue = valueCursor.current; pop(valueCursor, providerFiber); + var context = providerFiber.type._context; { context._currentValue = currentValue; @@ -6779,31 +6708,16 @@ function propagateContextChange( // Match! Schedule an update on this fiber. if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. - var lane = pickArbitraryLane(renderLanes); - var update = createUpdate(NoTimestamp, lane); + 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 // worth fixing. - // Inlined `enqueueUpdate` to remove interleaved update check - var updateQueue = fiber.updateQueue; - - if (updateQueue === null); - else { - var sharedQueue = updateQueue.shared; - var pending = sharedQueue.pending; - - if (pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = pending.next; - pending.next = update; - } - - sharedQueue.pending = update; - } + enqueueUpdate(fiber, update); } fiber.lanes = mergeLanes(fiber.lanes, renderLanes); @@ -6938,48 +6852,6 @@ function readContext(context, observedBits) { return context._currentValue; } -// An array of all update queues that received updates during the current -// render. When this render exits, either because it finishes or because it is -// interrupted, the interleaved updates will be transfered onto the main part -// of the queue. -var interleavedQueues = null; -function pushInterleavedQueue(queue) { - if (interleavedQueues === null) { - interleavedQueues = [queue]; - } else { - interleavedQueues.push(queue); - } -} -function enqueueInterleavedUpdates() { - // Transfer the interleaved updates onto the main queue. Each queue has a - // `pending` field and an `interleaved` field. When they are not null, they - // point to the last node in a circular linked list. We need to append the - // interleaved list to the end of the pending list by joining them into a - // single, circular list. - if (interleavedQueues !== null) { - for (var i = 0; i < interleavedQueues.length; i++) { - var queue = interleavedQueues[i]; - var lastInterleavedUpdate = queue.interleaved; - - if (lastInterleavedUpdate !== null) { - queue.interleaved = null; - var firstInterleavedUpdate = lastInterleavedUpdate.next; - var lastPendingUpdate = queue.pending; - - if (lastPendingUpdate !== null) { - var firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = firstInterleavedUpdate; - lastInterleavedUpdate.next = firstPendingUpdate; - } - - queue.pending = lastInterleavedUpdate; - } - } - - interleavedQueues = null; - } -} - var UpdateState = 0; var ReplaceState = 1; var ForceUpdate = 2; @@ -7002,9 +6874,7 @@ function initializeUpdateQueue(fiber) { firstBaseUpdate: null, lastBaseUpdate: null, shared: { - pending: null, - interleaved: null, - lanes: NoLanes + pending: null }, effects: null }; @@ -7037,7 +6907,7 @@ function createUpdate(eventTime, lane) { }; return update; } -function enqueueUpdate(fiber, update, lane) { +function enqueueUpdate(fiber, update) { var updateQueue = fiber.updateQueue; if (updateQueue === null) { @@ -7046,36 +6916,18 @@ function enqueueUpdate(fiber, update, lane) { } var sharedQueue = updateQueue.shared; + var pending = sharedQueue.pending; - if (isInterleavedUpdate(fiber)) { - var interleaved = sharedQueue.interleaved; - - if (interleaved === null) { - // This is the first update. Create a circular list. - update.next = update; // At the end of the current render, this queue's interleaved updates will - // be transfered to the pending queue. - - pushInterleavedQueue(sharedQueue); - } else { - update.next = interleaved.next; - interleaved.next = update; - } - - sharedQueue.interleaved = update; + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; } else { - var pending = sharedQueue.pending; - - if (pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = pending.next; - pending.next = update; - } - - sharedQueue.pending = update; + update.next = pending.next; + pending.next = update; } + sharedQueue.pending = update; + { if ( currentlyProcessingQueue === sharedQueue && @@ -7092,33 +6944,6 @@ function enqueueUpdate(fiber, update, lane) { } } } -function entangleTransitions(root, fiber, lane) { - var updateQueue = fiber.updateQueue; - - if (updateQueue === null) { - // Only occurs if the fiber has been unmounted. - return; - } - - var sharedQueue = updateQueue.shared; - - if (isTransitionLane(lane)) { - var queueLanes = sharedQueue.lanes; // If any entangled lanes are no longer pending on the root, then they must - // have finished. We can remove them from the shared queue, which represents - // a superset of the actually pending lanes. In some cases we may entangle - // more than we need to, but that's OK. In fact it's worse if we *don't* - // entangle when we should. - - queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes. - - var newQueueLanes = mergeLanes(queueLanes, lane); - sharedQueue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if - // the lane finished since the last time we entangled it. So we need to - // entangle it again, just to be sure. - - markRootEntangled(root, newQueueLanes); - } -} 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, @@ -7220,7 +7045,7 @@ function getStateFromUpdate( var nextState = payload.call(instance, prevState, nextProps); { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -7258,7 +7083,7 @@ function getStateFromUpdate( partialState = _payload.call(instance, prevState, nextProps); { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -7448,24 +7273,7 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { queue.baseState = newBaseState; queue.firstBaseUpdate = newFirstBaseUpdate; - queue.lastBaseUpdate = newLastBaseUpdate; // Interleaved updates are stored on a separate queue. We aren't going to - // process them during this render, but we do need to track which lanes - // are remaining. - - var lastInterleaved = queue.shared.interleaved; - - if (lastInterleaved !== null) { - var interleaved = lastInterleaved; - - do { - newLanes = mergeLanes(newLanes, interleaved.lane); - interleaved = interleaved.next; - } while (interleaved !== lastInterleaved); - } else if (firstBaseUpdate === null) { - // `queue.lanes` is used for entangling transitions. We can set it back to - // zero once the queue is empty. - queue.shared.lanes = NoLanes; - } // Set the remaining expiration time to be whatever is remaining in the queue. + 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 @@ -7606,7 +7414,7 @@ function applyDerivedStateFromProps( var prevState = workInProgress.memoizedState; { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -7655,11 +7463,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - - if (root !== null) { - entangleTransitions(root, fiber, lane); - } + scheduleUpdateOnFiber(fiber, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { var fiber = get(inst); @@ -7678,11 +7482,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - - if (root !== null) { - entangleTransitions(root, fiber, lane); - } + scheduleUpdateOnFiber(fiber, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); @@ -7700,11 +7500,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - - if (root !== null) { - entangleTransitions(root, fiber, lane); - } + scheduleUpdateOnFiber(fiber, lane, eventTime); } }; @@ -7721,7 +7517,7 @@ function checkShouldComponentUpdate( if (typeof instance.shouldComponentUpdate === "function") { { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -8057,7 +7853,7 @@ function constructClassInstance(workInProgress, ctor, props) { } // Instantiate twice to help detect side-effects. { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -8270,7 +8066,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } } - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { ReactStrictModeWarnings.recordLegacyContextWarning( workInProgress, instance @@ -8314,9 +8110,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } if (typeof instance.componentDidMount === "function") { - { - workInProgress.flags |= Update; - } + workInProgress.flags |= Update; } } @@ -8378,9 +8172,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.flags |= Update; - } + workInProgress.flags |= Update; } return false; @@ -8426,17 +8218,13 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { } if (typeof instance.componentDidMount === "function") { - { - workInProgress.flags |= 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.flags |= Update; - } + workInProgress.flags |= Update; } // If shouldComponentUpdate returned false, we should still update the // memoized state to indicate that this work can be reused. @@ -8686,7 +8474,7 @@ function coerceRef(returnFiber, current, element) { // TODO: Clean this up once we turn on the string ref warning for // everyone, because the strict mode case will no longer be relevant if ( - (returnFiber.mode & StrictLegacyMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs + (returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs // because these cannot be automatically converted to an arrow function // using a codemod. Therefore, we don't have to warn about string refs again. !( @@ -8788,14 +8576,12 @@ function coerceRef(returnFiber, current, element) { function throwOnInvalidObjectType(returnFiber, newChild) { if (returnFiber.type !== "textarea") { - var childString = Object.prototype.toString.call(newChild); - { throw Error( "Objects are not valid as a React child (found: " + - (childString === "[object Object]" + (Object.prototype.toString.call(newChild) === "[object Object]" ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : childString) + + : newChild) + "). If you meant to render a collection of children, use an array instead." ); } @@ -8818,7 +8604,7 @@ function warnOnFunctionType(returnFiber) { "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 // 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. @@ -8828,16 +8614,23 @@ function ChildReconciler(shouldTrackSideEffects) { if (!shouldTrackSideEffects) { // Noop. return; - } + } // Deletions are added in reversed order so we add it to the front. + // At this point, the return fiber's effect list is empty except for + // deletions, so we can just append the deletion to the list. The remaining + // effects aren't added until the complete phase. Once we implement + // resuming, this may not be true. - var deletions = returnFiber.deletions; + var last = returnFiber.lastEffect; - if (deletions === null) { - returnFiber.deletions = [childToDelete]; - returnFiber.flags |= ChildDeletion; + if (last !== null) { + last.nextEffect = childToDelete; + returnFiber.lastEffect = childToDelete; } else { - deletions.push(childToDelete); + returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; } + + childToDelete.nextEffect = null; + childToDelete.flags = Deletion; } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -8901,7 +8694,7 @@ function ChildReconciler(shouldTrackSideEffects) { if (oldIndex < lastPlacedIndex) { // This is a move. - newFiber.flags |= Placement; + newFiber.flags = Placement; return lastPlacedIndex; } else { // This item can stay in place. @@ -8909,7 +8702,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.flags |= Placement; + newFiber.flags = Placement; return lastPlacedIndex; } } @@ -8918,7 +8711,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.flags |= Placement; + newFiber.flags = Placement; } return newFiber; @@ -8939,26 +8732,10 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current, element, lanes) { - var elementType = element.type; - - if (elementType === REACT_FRAGMENT_TYPE) { - return updateFragment( - returnFiber, - current, - element.props.children, - lanes, - element.key - ); - } - if (current !== null) { if ( - current.elementType === elementType || // Keep this check inline so it only runs on the false path: - isCompatibleFamilyForHotReloading(current, element) || // Lazy types should reconcile their resolved type. - // We need to do this after the Hot Reloading check above, - // because hot reloading has different semantics than prod because - // it doesn't resuspend. So we can't let the call below suspend. - enableLazyElements + current.elementType === element.type || // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(current, element) ) { // Move based on index var existing = useFiber(current, element.props); @@ -9097,6 +8874,16 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: { if (newChild.key === key) { + if (newChild.type === REACT_FRAGMENT_TYPE) { + return updateFragment( + returnFiber, + oldFiber, + newChild.props.children, + lanes, + key + ); + } + return updateElement(returnFiber, oldFiber, newChild, lanes); } else { return null; @@ -9154,6 +8941,16 @@ function ChildReconciler(shouldTrackSideEffects) { newChild.key === null ? newIdx : newChild.key ) || null; + if (newChild.type === REACT_FRAGMENT_TYPE) { + return updateFragment( + returnFiber, + _matchedFiber, + newChild.props.children, + lanes, + newChild.key + ); + } + return updateElement(returnFiber, _matchedFiber, newChild, lanes); } @@ -9647,43 +9444,45 @@ function ChildReconciler(shouldTrackSideEffects) { // TODO: If key === null and child.key === null, then this only applies to // the first item in the list. if (child.key === key) { - var elementType = element.type; + switch (child.tag) { + case Fragment: { + if (element.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren(returnFiber, child.sibling); + var existing = useFiber(child, element.props.children); + existing.return = returnFiber; - if (elementType === REACT_FRAGMENT_TYPE) { - if (child.tag === Fragment) { - deleteRemainingChildren(returnFiber, child.sibling); - var existing = useFiber(child, element.props.children); - existing.return = returnFiber; + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } - { - existing._debugSource = element._source; - existing._debugOwner = element._owner; + return existing; } - return existing; + break; } - } else { - if ( - child.elementType === elementType || // Keep this check inline so it only runs on the false path: - isCompatibleFamilyForHotReloading(child, element) || // Lazy types should reconcile their resolved type. - // We need to do this after the Hot Reloading check above, - // because hot reloading has different semantics than prod because - // it doesn't resuspend. So we can't let the call below suspend. - enableLazyElements - ) { - deleteRemainingChildren(returnFiber, child.sibling); - var _existing = useFiber(child, element.props); + default: { + if ( + child.elementType === element.type || // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(child, element) + ) { + deleteRemainingChildren(returnFiber, child.sibling); - _existing.ref = coerceRef(returnFiber, child, element); - _existing.return = returnFiber; + var _existing = useFiber(child, element.props); - { - _existing._debugSource = element._source; - _existing._debugOwner = element._owner; + _existing.ref = coerceRef(returnFiber, child, element); + _existing.return = returnFiber; + + { + _existing._debugSource = element._source; + _existing._debugOwner = element._owner; + } + + return _existing; } - return _existing; + break; } } // Didn't match. @@ -10114,6 +9913,21 @@ function findFirstSuspended(row) { return null; } +var NoFlags$1 = + /* */ + 0; // Represents whether effect should fire. + +var HasEffect = + /* */ + 1; // Represents the phase in which the effect (not the clean-up) fires. + +var Layout = + /* */ + 2; +var Passive$1 = + /* */ + 4; + var isHydrating = false; function enterHydrationState(fiber) { @@ -10209,12 +10023,6 @@ function warnAboutMultipleRenderersDEV(mutableSource) { } } // Eager reads the version of a mutable source and stores it on the root. -function getSuspendedCachePool() { - { - return null; - } // We check the cache on the stack first, since that's the one any new Caches -} - var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; @@ -10500,20 +10308,7 @@ function renderWithHooks( { currentHookNameInDev = null; hookTypesDev = null; - hookTypesUpdateIndexDev = -1; // Confirm that a static flag was not added or removed since the last - // render. If this fires, it suggests that we incorrectly reset the static - // flags in some other part of the codebase. This has happened before, for - // example, in the SuspenseList implementation. - - if ( - current !== null && - (current.flags & PassiveStatic) !== (workInProgress.flags & PassiveStatic) - ) { - error( - "Internal React error: Expected static flag was missing. Please " + - "notify the React team." - ); - } + hookTypesUpdateIndexDev = -1; } didScheduleRenderPhaseUpdate = false; @@ -10527,13 +10322,8 @@ function renderWithHooks( return children; } function bailoutHooks(current, workInProgress, lanes) { - workInProgress.updateQueue = current.updateQueue; // TODO: Don't need to reset the flags here, because they're reset in the - // complete phase (bubbleProperties). - - { - workInProgress.flags &= ~(Passive | Update); - } - + workInProgress.updateQueue = current.updateQueue; + workInProgress.flags &= ~(Passive | Update); current.lanes = removeLanes(current.lanes, lanes); } function resetHooksAfterThrow() { @@ -10684,8 +10474,6 @@ function mountReducer(reducer, initialArg, init) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { pending: null, - interleaved: null, - lanes: NoLanes, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialState @@ -10823,28 +10611,6 @@ function updateReducer(reducer, initialArg, init) { hook.baseState = newBaseState; hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = newState; - } // Interleaved updates are stored on a separate queue. We aren't going to - // process them during this render, but we do need to track which lanes - // are remaining. - - var lastInterleaved = queue.interleaved; - - if (lastInterleaved !== null) { - var interleaved = lastInterleaved; - - do { - var interleavedLane = interleaved.lane; - currentlyRenderingFiber$1.lanes = mergeLanes( - currentlyRenderingFiber$1.lanes, - interleavedLane - ); - markSkippedUpdateLanes(interleavedLane); - interleaved = interleaved.next; - } while (interleaved !== lastInterleaved); - } else if (baseQueue === null) { - // `queue.lanes` is used for entangling transitions. We can set it back to - // zero once the queue is empty. - queue.lanes = NoLanes; } var dispatch = queue.dispatch; @@ -10972,48 +10738,11 @@ function readFromUnsubcribedMutableSource(root, source, getSnapshot) { // // 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); // Intentioally throw an error to force React to retry synchronously. During - // the synchronous retry, it will block interleaved mutations, so we should - // get a consistent read. Therefore, the following error should never be - // visible to the user. - // - // If it were to become visible to the user, it suggests one of two things: - // a bug in React, or (more likely), a mutation during the render phase that - // caused the second re-render attempt to be different from the first. - // - // We know it's the second case if the logs are currently disabled. So in - // dev, we can present a more accurate error message. - - { - // eslint-disable-next-line react-internal/no-production-logging - if (console.log.__reactDisabledLog) { - // If the logs are disabled, this is the dev-only double render. This is - // only reachable if there was a mutation during render. Show a helpful - // error message. - // - // Something interesting to note: because we only double render in - // development, this error will never happen during production. This is - // actually true of all errors that occur during a double render, - // because if the first render had thrown, we would have exited the - // begin phase without double rendering. We should consider suppressing - // any error from a double render (with a warning) to more closely match - // the production behavior. - var componentName = getComponentName(currentlyRenderingFiber$1.type); - - { - throw Error( - "A mutable source was mutated while the " + - componentName + - " component was rendering. This is not supported. Move any mutations into event handlers or effects." - ); - } - } - } // We expect this error not to be thrown during the synchronous retry, - // because we blocked interleaved mutations. + markSourceAsDirty(source); { throw Error( - "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." ); } } @@ -11149,8 +10878,6 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { // including any interleaving updates that occur. var newQueue = { pending: null, - interleaved: null, - lanes: NoLanes, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot @@ -11198,8 +10925,6 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; var queue = (hook.queue = { pending: null, - interleaved: null, - lanes: NoLanes, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -11293,7 +11018,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var prevDeps = prevEffect.deps; if (areHookInputsEqual(nextDeps, prevDeps)) { - hook.memoizedState = pushEffect(hookFlags, create, destroy, nextDeps); + pushEffect(hookFlags, create, destroy, nextDeps); return; } } @@ -11316,9 +11041,7 @@ function mountEffect(create, deps) { } } - { - return mountEffectImpl(Passive | PassiveStatic, Passive$1, create, deps); - } + return mountEffectImpl(Update | Passive, Passive$1, create, deps); } function updateEffect(create, deps) { @@ -11329,13 +11052,11 @@ function updateEffect(create, deps) { } } - return updateEffectImpl(Passive, Passive$1, create, deps); + return updateEffectImpl(Update | Passive, Passive$1, create, deps); } function mountLayoutEffect(create, deps) { - { - return mountEffectImpl(Update, Layout, create, deps); - } + return mountEffectImpl(Update, Layout, create, deps); } function updateLayoutEffect(create, deps) { @@ -11387,15 +11108,12 @@ function mountImperativeHandle(ref, create, deps) { var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; - - { - return mountEffectImpl( - Update, - Layout, - imperativeHandleEffect.bind(null, create, ref), - effectDeps - ); - } + return mountEffectImpl( + Update, + Layout, + imperativeHandleEffect.bind(null, create, ref), + effectDeps + ); } function updateImperativeHandle(ref, create, deps) { @@ -11550,15 +11268,15 @@ function startTransition(setPending, callback) { { runWithPriority( - priorityLevel < UserBlockingPriority - ? UserBlockingPriority + priorityLevel < UserBlockingPriority$1 + ? UserBlockingPriority$1 : priorityLevel, function() { setPending(true); } ); runWithPriority( - priorityLevel > NormalPriority ? NormalPriority : priorityLevel, + priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, function() { var prevTransition = ReactCurrentBatchConfig$1.transition; ReactCurrentBatchConfig$1.transition = 1; @@ -11670,7 +11388,19 @@ function dispatchAction(fiber, queue, action) { eagerReducer: null, eagerState: null, next: null - }; + }; // Append the update to the end of the list. + + var pending = queue.pending; + + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } + + queue.pending = update; var alternate = fiber.alternate; if ( @@ -11681,47 +11411,7 @@ function dispatchAction(fiber, queue, action) { // 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. didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; - var pending = queue.pending; - - if (pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = pending.next; - pending.next = update; - } - - queue.pending = update; } else { - if (isInterleavedUpdate(fiber)) { - var interleaved = queue.interleaved; - - if (interleaved === null) { - // This is the first update. Create a circular list. - update.next = update; // At the end of the current render, this queue's interleaved updates will - // be transfered to the pending queue. - - pushInterleavedQueue(queue); - } else { - update.next = interleaved.next; - interleaved.next = update; - } - - queue.interleaved = update; - } else { - var _pending = queue.pending; - - if (_pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = _pending.next; - _pending.next = update; - } - - queue.pending = update; - } - if ( fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes) @@ -11774,24 +11464,7 @@ function dispatchAction(fiber, queue, action) { } } - var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - - if (isTransitionLane(lane) && root !== null) { - var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they - // must have finished. We can remove them from the shared queue, which - // represents a superset of the actually pending lanes. In some cases we - // may entangle more than we need to, but that's OK. In fact it's worse if - // we *don't* entangle when we should. - - queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes. - - var newQueueLanes = mergeLanes(queueLanes, lane); - queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if - // the lane finished since the last time we entangled it. So we need to - // entangle it again, just to be sure. - - markRootEntangled(root, newQueueLanes); - } + scheduleUpdateOnFiber(fiber, lane, eventTime); } } @@ -11813,7 +11486,6 @@ var ContextOnlyDispatcher = { useOpaqueIdentifier: throwInvalidHookError, unstable_isNewReconciler: enableNewReconciler }; - var HooksDispatcherOnMountInDEV = null; var HooksDispatcherOnMountWithHookTypesInDEV = null; var HooksDispatcherOnUpdateInDEV = null; @@ -11943,7 +11615,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - HooksDispatcherOnMountWithHookTypesInDEV = { readContext: function(context, observedBits) { return readContext(context, observedBits); @@ -12041,7 +11712,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - HooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { return readContext(context, observedBits); @@ -12139,7 +11809,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - HooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { return readContext(context, observedBits); @@ -12237,7 +11906,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - InvalidNestedHooksDispatcherOnMountInDEV = { readContext: function(context, observedBits) { warnInvalidContextAccess(); @@ -12350,7 +12018,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - InvalidNestedHooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { warnInvalidContextAccess(); @@ -12463,7 +12130,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; }, unstable_isNewReconciler: enableNewReconciler }; - InvalidNestedHooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { warnInvalidContextAccess(); @@ -12753,7 +12419,7 @@ function updateForwardRef( renderLanes ); - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -12987,29 +12653,21 @@ function updateSimpleMemoComponent( function updateOffscreenComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var nextChildren = nextProps.children; - var prevState = current !== null ? current.memoizedState : null; // If this is not null, this is a cache pool that was carried over from the - // previous render. We will push this to the cache pool context so that we can - // resume in-flight requests. - - var spawnedCachePool = null; + var prevState = current !== null ? current.memoizedState : null; if ( nextProps.mode === "hidden" || nextProps.mode === "unstable-defer-without-hiding" ) { - // Rendering a hidden tree. 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, - cachePool: null + baseLanes: NoLanes }; workInProgress.memoizedState = nextState; pushRenderLanes(workInProgress, renderLanes); } else if (!includesSomeLane(renderLanes, OffscreenLane)) { - // We're hidden, and we're not rendering at Offscreen. We will bail out - // and resume this tree later. var nextBaseLanes; if (prevState !== null) { @@ -13027,19 +12685,17 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { OffscreenLane ); var _nextState = { - baseLanes: nextBaseLanes, - cachePool: spawnedCachePool + baseLanes: nextBaseLanes }; - workInProgress.memoizedState = _nextState; - workInProgress.updateQueue = null; // We're about to bail out, but we need to push this to the stack anyway + 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, - cachePool: null + baseLanes: NoLanes }; workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out. @@ -13048,12 +12704,10 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { pushRenderLanes(workInProgress, subtreeRenderLanes); } } else { - // Rendering a visible tree. var _subtreeRenderLanes; if (prevState !== null) { - // We're going from hidden -> visible. - _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); + _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state workInProgress.memoizedState = null; } else { @@ -13160,7 +12814,7 @@ function updateFunctionComponent( renderLanes ); - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -13335,7 +12989,7 @@ function finishClassComponent( setIsRendering(true); nextChildren = instance.render(); - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -13405,11 +13059,10 @@ function updateHostRoot(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; - var prevChildren = prevState.element; + var prevChildren = prevState !== null ? prevState.element : null; cloneUpdateQueue(current, workInProgress); processUpdateQueue(workInProgress, nextProps, null, renderLanes); - var nextState = workInProgress.memoizedState; - var root = workInProgress.stateNode; + var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". var nextChildren = nextState.element; @@ -13418,6 +13071,8 @@ function updateHostRoot(current, workInProgress, renderLanes) { return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } + var root = workInProgress.stateNode; + if (root.hydrate && enterHydrationState()) { var child = mountChildFibers( workInProgress, @@ -13698,7 +13353,7 @@ function mountIndeterminateComponent( } } - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); } @@ -13817,7 +13472,7 @@ function mountIndeterminateComponent( workInProgress.tag = FunctionComponent; { - if (workInProgress.mode & StrictLegacyMode) { + if (workInProgress.mode & StrictMode) { disableLogs(); try { @@ -13921,17 +13576,13 @@ var SUSPENDED_MARKER = { function mountSuspenseOffscreenState(renderLanes) { return { - baseLanes: renderLanes, - cachePool: getSuspendedCachePool() + baseLanes: renderLanes }; } function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { - var cachePool = null; - return { - baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes), - cachePool: cachePool + baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) }; } // TODO: Probably should inline this back @@ -14291,14 +13942,9 @@ function updateSuspensePrimaryChildren( if (currentFallbackChildFragment !== null) { // Delete the fallback child fragment - var deletions = workInProgress.deletions; - - if (deletions === null) { - workInProgress.deletions = [currentFallbackChildFragment]; - workInProgress.flags |= ChildDeletion; - } else { - deletions.push(currentFallbackChildFragment); - } + currentFallbackChildFragment.nextEffect = null; + currentFallbackChildFragment.flags = Deletion; + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; } workInProgress.child = primaryChildFragment; @@ -14348,21 +13994,28 @@ function updateSuspenseFallbackChildren( currentPrimaryChildFragment.selfBaseDuration; primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration; - } // The fallback fiber was added as a deletion during the first pass. + } // 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. + // 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. - workInProgress.deletions = null; + 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 - ); // Since we're reusing a current tree, we need to reuse the flags, too. - // (We don't do this in legacy mode, because in legacy mode we don't re-use - // the current tree; see previous branch.) - - primaryChildFragment.subtreeFlags = - currentPrimaryChildFragment.subtreeFlags & StaticMask; + ); } var fallbackChildFragment; @@ -14632,7 +14285,8 @@ function initSuspenseListRenderState( isBackwards, tail, lastContentRow, - tailMode + tailMode, + lastEffectBeforeRendering ) { var renderState = workInProgress.memoizedState; @@ -14643,7 +14297,8 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailMode: tailMode + tailMode: tailMode, + lastEffect: lastEffectBeforeRendering }; } else { // We can reuse the existing object from previous renders. @@ -14653,6 +14308,7 @@ function initSuspenseListRenderState( renderState.last = lastContentRow; renderState.tail = tail; renderState.tailMode = tailMode; + renderState.lastEffect = lastEffectBeforeRendering; } } // This can end up rendering this component multiple passes. // The first pass splits the children fibers into two sets. A head and tail. @@ -14730,7 +14386,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { false, // isBackwards tail, lastContentRow, - tailMode + tailMode, + workInProgress.lastEffect ); break; } @@ -14764,7 +14421,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { true, // isBackwards _tail, null, // last - tailMode + tailMode, + workInProgress.lastEffect ); break; } @@ -14775,7 +14433,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { false, // isBackwards null, // tail null, // last - undefined + undefined, + workInProgress.lastEffect ); break; } @@ -14841,7 +14500,7 @@ function updateContextProvider(current, workInProgress, renderLanes) { } } - pushProvider(workInProgress, context, newValue); + pushProvider(workInProgress, newValue); if (oldProps !== null) { var oldValue = oldProps.value; @@ -14997,15 +14656,17 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { } // Delete the old fiber and place the new one. // Since the old fiber is disconnected, we have to schedule it manually. - var deletions = returnFiber.deletions; + var last = returnFiber.lastEffect; - if (deletions === null) { - returnFiber.deletions = [current]; - returnFiber.flags |= ChildDeletion; + if (last !== null) { + last.nextEffect = current; + returnFiber.lastEffect = current; } else { - deletions.push(current); + returnFiber.firstEffect = returnFiber.lastEffect = current; } + current.nextEffect = null; + current.flags = Deletion; newWorkInProgress.flags |= Placement; // Restart work from the new fiber. return newWorkInProgress; @@ -15078,8 +14739,7 @@ function beginWork(current, workInProgress, renderLanes) { case ContextProvider: { var newValue = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - pushProvider(workInProgress, context, newValue); + pushProvider(workInProgress, newValue); break; } @@ -15413,6 +15073,10 @@ function beginWork(current, workInProgress, renderLanes) { return updateSuspenseListComponent(current, workInProgress, renderLanes); } + case FundamentalComponent: { + break; + } + case ScopeComponent: { break; } @@ -15489,7 +15153,7 @@ var updateHostText$1; } }; - updateHostContainer = function(current, workInProgress) { + updateHostContainer = function(workInProgress) { // Noop }; @@ -15606,115 +15270,6 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { } } -function bubbleProperties(completedWork) { - var didBailout = - completedWork.alternate !== null && - completedWork.alternate.child === completedWork.child; - var newChildLanes = NoLanes; - var subtreeFlags = NoFlags; - - if (!didBailout) { - // Bubble up the earliest expiration time. - if ((completedWork.mode & ProfileMode) !== NoMode) { - // In profiling mode, resetChildExpirationTime is also used to reset - // profiler durations. - var actualDuration = completedWork.actualDuration; - var treeBaseDuration = completedWork.selfBaseDuration; - var child = completedWork.child; - - while (child !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(child.lanes, child.childLanes) - ); - subtreeFlags |= child.subtreeFlags; - subtreeFlags |= child.flags; // 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. - - actualDuration += child.actualDuration; - treeBaseDuration += child.treeBaseDuration; - child = child.sibling; - } - - completedWork.actualDuration = actualDuration; - completedWork.treeBaseDuration = treeBaseDuration; - } else { - var _child = completedWork.child; - - while (_child !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(_child.lanes, _child.childLanes) - ); - subtreeFlags |= _child.subtreeFlags; - subtreeFlags |= _child.flags; // Update the return pointer so the tree is consistent. This is a code - // smell because it assumes the commit phase is never concurrent with - // the render phase. Will address during refactor to alternate model. - - _child.return = completedWork; - _child = _child.sibling; - } - } - - completedWork.subtreeFlags |= subtreeFlags; - } else { - // Bubble up the earliest expiration time. - if ((completedWork.mode & ProfileMode) !== NoMode) { - // In profiling mode, resetChildExpirationTime is also used to reset - // profiler durations. - var _treeBaseDuration = completedWork.selfBaseDuration; - var _child2 = completedWork.child; - - while (_child2 !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(_child2.lanes, _child2.childLanes) - ); // "Static" flags share the lifetime of the fiber/hook they belong to, - // so we should bubble those up even during a bailout. All the other - // flags have a lifetime only of a single render + commit, so we should - // ignore them. - - subtreeFlags |= _child2.subtreeFlags & StaticMask; - subtreeFlags |= _child2.flags & StaticMask; - _treeBaseDuration += _child2.treeBaseDuration; - _child2 = _child2.sibling; - } - - completedWork.treeBaseDuration = _treeBaseDuration; - } else { - var _child3 = completedWork.child; - - while (_child3 !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(_child3.lanes, _child3.childLanes) - ); // "Static" flags share the lifetime of the fiber/hook they belong to, - // so we should bubble those up even during a bailout. All the other - // flags have a lifetime only of a single render + commit, so we should - // ignore them. - - subtreeFlags |= _child3.subtreeFlags & StaticMask; - subtreeFlags |= _child3.flags & StaticMask; // Update the return pointer so the tree is consistent. This is a code - // smell because it assumes the commit phase is never concurrent with - // the render phase. Will address during refactor to alternate model. - - _child3.return = completedWork; - _child3 = _child3.sibling; - } - } - - completedWork.subtreeFlags |= subtreeFlags; - } - - completedWork.childLanes = newChildLanes; - return didBailout; -} - function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; @@ -15729,7 +15284,6 @@ function completeWork(current, workInProgress, renderLanes) { case Profiler: case ContextConsumer: case MemoComponent: - bubbleProperties(workInProgress); return null; case ClassComponent: { @@ -15739,16 +15293,14 @@ function completeWork(current, workInProgress, renderLanes) { popContext(workInProgress); } - bubbleProperties(workInProgress); return null; } case HostRoot: { - var fiberRoot = workInProgress.stateNode; - popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); resetWorkInProgressVersions(); + var fiberRoot = workInProgress.stateNode; if (fiberRoot.pendingContext) { fiberRoot.context = fiberRoot.pendingContext; @@ -15773,8 +15325,7 @@ function completeWork(current, workInProgress, renderLanes) { } } - updateHostContainer(current, workInProgress); - bubbleProperties(workInProgress); + updateHostContainer(workInProgress); return null; } @@ -15803,7 +15354,6 @@ function completeWork(current, workInProgress, renderLanes) { ); } // This can happen when we abort work. - bubbleProperties(workInProgress); return null; } @@ -15846,7 +15396,6 @@ function completeWork(current, workInProgress, renderLanes) { } } - bubbleProperties(workInProgress); return null; } @@ -15887,7 +15436,6 @@ function completeWork(current, workInProgress, renderLanes) { } } - bubbleProperties(workInProgress); return null; } @@ -15901,7 +15449,7 @@ function completeWork(current, workInProgress, renderLanes) { if ((workInProgress.mode & ProfileMode) !== NoMode) { transferActualDuration(workInProgress); - } // Don't bubble properties in this case. + } return workInProgress; } @@ -15917,7 +15465,7 @@ function completeWork(current, workInProgress, renderLanes) { } if (nextDidTimeout && !prevDidTimeout) { - // If this subtree is running in blocking mode we can suspend, + // If this subtreee is running in blocking mode we can suspend, // otherwise we won't suspend. // TODO: This will still suspend a synchronous tree if anything // in the concurrent tree already suspended during this render. @@ -15964,42 +15512,22 @@ function completeWork(current, workInProgress, renderLanes) { } } - bubbleProperties(workInProgress); - - { - if ((workInProgress.mode & ProfileMode) !== NoMode) { - if (nextDidTimeout) { - // Don't count time spent in a timed out Suspense subtree as part of the base duration. - var _primaryChildFragment2 = workInProgress.child; - - if (_primaryChildFragment2 !== null) { - // $FlowFixMe Flow doens't support type casting in combiation with the -= operator - workInProgress.treeBaseDuration -= - _primaryChildFragment2.treeBaseDuration; - } - } - } - } - return null; } case HostPortal: popHostContainer(workInProgress); - updateHostContainer(current, workInProgress); + updateHostContainer(workInProgress); if (current === null) { preparePortalMount(workInProgress.stateNode.containerInfo); } - bubbleProperties(workInProgress); return null; case ContextProvider: // Pop provider fiber - var context = workInProgress.type._context; - popProvider(context, workInProgress); - bubbleProperties(workInProgress); + popProvider(workInProgress); return null; case IncompleteClassComponent: { @@ -16011,7 +15539,6 @@ function completeWork(current, workInProgress, renderLanes) { popContext(workInProgress); } - bubbleProperties(workInProgress); return null; } @@ -16022,7 +15549,6 @@ function completeWork(current, workInProgress, renderLanes) { if (renderState === null) { // We're running in the default, "independent" mode. // We don't do anything in this mode. - bubbleProperties(workInProgress); return null; } @@ -16074,10 +15600,14 @@ function completeWork(current, workInProgress, renderLanes) { workInProgress.flags |= Update; } // Rerender the whole list, but this time, we'll force fallbacks // to stay in place. - // Reset the effect flags before doing the second pass since that's now invalid. - // Reset the child fibers to their original state. + // Reset the effect list before doing the second pass since that's now invalid. + + if (renderState.lastEffect === null) { + workInProgress.firstEffect = null; + } + + workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. - workInProgress.subtreeFlags = NoFlags; resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately // rerender the children. @@ -16087,8 +15617,7 @@ function completeWork(current, workInProgress, renderLanes) { suspenseStackCursor.current, ForceSuspenseFallback ) - ); // Don't bubble properties in this case. - + ); return workInProgress.child; } @@ -16145,8 +15674,16 @@ function completeWork(current, workInProgress, renderLanes) { !renderedTail.alternate && !getIsHydrating() // We don't cut it if we're hydrating. ) { - // We're done. - bubbleProperties(workInProgress); + // We need to delete the row we just rendered. + // Reset the effect list to what it was before we rendered this + // child. The nested children have already appended themselves. + var lastEffect = (workInProgress.lastEffect = + renderState.lastEffect); // Remove any effects that were appended after this point. + + if (lastEffect !== null) { + lastEffect.nextEffect = null; + } // We're done. + return null; } } else if ( @@ -16206,6 +15743,7 @@ function completeWork(current, workInProgress, renderLanes) { var next = renderState.tail; renderState.rendering = next; renderState.tail = next.sibling; + renderState.lastEffect = workInProgress.lastEffect; renderState.renderingStartTime = now(); next.sibling = null; // Restore the context. // TODO: We can probably just avoid popping it instead and only @@ -16223,15 +15761,17 @@ function completeWork(current, workInProgress, renderLanes) { } pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row. - // Don't bubble properties in this case. return next; } - bubbleProperties(workInProgress); return null; } + case FundamentalComponent: { + break; + } + case ScopeComponent: { break; } @@ -16239,12 +15779,12 @@ function completeWork(current, workInProgress, renderLanes) { case OffscreenComponent: case LegacyHiddenComponent: { popRenderLanes(workInProgress); - var _nextState = workInProgress.memoizedState; - var nextIsHidden = _nextState !== null; if (current !== null) { + var _nextState = workInProgress.memoizedState; var _prevState = current.memoizedState; var prevIsHidden = _prevState !== null; + var nextIsHidden = _nextState !== null; if ( prevIsHidden !== nextIsHidden && @@ -16252,14 +15792,6 @@ function completeWork(current, workInProgress, renderLanes) { ) { workInProgress.flags |= Update; } - } // Don't bubble properties for hidden children. - - if ( - !nextIsHidden || - includesSomeLane(subtreeRenderLanes, OffscreenLane) || - (workInProgress.mode & ConcurrentMode) === NoMode - ) { - bubbleProperties(workInProgress); } return null; @@ -16351,17 +15883,12 @@ function unwindWork(workInProgress, renderLanes) { return null; case ContextProvider: - var context = workInProgress.type._context; - popProvider(context, workInProgress); + popProvider(workInProgress); return null; case OffscreenComponent: case LegacyHiddenComponent: popRenderLanes(workInProgress); - - return null; - - case CacheComponent: return null; default: @@ -16369,7 +15896,7 @@ function unwindWork(workInProgress, renderLanes) { } } -function unwindInterruptedWork(interruptedWork, renderLanes) { +function unwindInterruptedWork(interruptedWork) { switch (interruptedWork.tag) { case ClassComponent: { var childContextTypes = interruptedWork.type.childContextTypes; @@ -16406,14 +15933,12 @@ function unwindInterruptedWork(interruptedWork, renderLanes) { break; case ContextProvider: - var context = interruptedWork.type._context; - popProvider(context, interruptedWork); + popProvider(interruptedWork); break; case OffscreenComponent: case LegacyHiddenComponent: popRenderLanes(interruptedWork); - break; } } @@ -16652,7 +16177,9 @@ function throwException( rootRenderLanes ) { // The source fiber did not complete. - sourceFiber.flags |= Incomplete; + sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. + + sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( value !== null && @@ -16661,16 +16188,10 @@ function throwException( ) { // This is a wakeable. var wakeable = value; - // A legacy mode Suspense quirk, only relevant to hook components. - var tag = sourceFiber.tag; - - if ( - (sourceFiber.mode & BlockingMode) === NoMode && - (tag === FunctionComponent || - tag === ForwardRef || - tag === SimpleMemoComponent) - ) { + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. var currentSource = sourceFiber.alternate; if (currentSource) { @@ -16714,16 +16235,8 @@ function throwException( // 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 the suspense boundary suspended itself suspended, we don't have to - // do this trick because nothing was partially started. We can just - // directly do a second pass over the fallback in this render and - // pretend we meant to render that directly. - if ( - (_workInProgress.mode & BlockingMode) === NoMode && - _workInProgress !== returnFiber - ) { + 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 @@ -16877,7 +16390,6 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null; } var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; -var nextEffect = null; var callComponentWillUnmountWithTimer = function(current, instance) { instance.props = current.memoizedProps; @@ -16888,11 +16400,7 @@ var callComponentWillUnmountWithTimer = function(current, instance) { } }; // Capture errors so they don't interrupt unmounting. -function safelyCallComponentWillUnmount( - current, - nearestMountedAncestor, - instance -) { +function safelyCallComponentWillUnmount(current, instance) { { invokeGuardedCallback( null, @@ -16904,12 +16412,12 @@ function safelyCallComponentWillUnmount( if (hasCaughtError()) { var unmountError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, unmountError); + captureCommitPhaseError(current, unmountError); } } } -function safelyDetachRef(current, nearestMountedAncestor) { +function safelyDetachRef(current) { var ref = current.ref; if (ref !== null) { @@ -16921,7 +16429,7 @@ function safelyDetachRef(current, nearestMountedAncestor) { if (hasCaughtError()) { var refError = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, refError); + captureCommitPhaseError(current, refError); } } } else { @@ -16930,117 +16438,27 @@ function safelyDetachRef(current, nearestMountedAncestor) { } } -function safelyCallDestroy(current, nearestMountedAncestor, destroy) { +function safelyCallDestroy(current, destroy) { { invokeGuardedCallback(null, destroy, null); if (hasCaughtError()) { var error = clearCaughtError(); - captureCommitPhaseError(current, nearestMountedAncestor, error); + captureCommitPhaseError(current, error); } } } -var focusedInstanceHandle = null; -var shouldFireAfterActiveInstanceBlur = false; -function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = prepareForCommit(root.containerInfo); - nextEffect = firstChild; - commitBeforeMutationEffects_begin(); // We no longer need to track the active instance fiber - - var shouldFire = shouldFireAfterActiveInstanceBlur; - shouldFireAfterActiveInstanceBlur = false; - focusedInstanceHandle = null; - return shouldFire; -} - -function commitBeforeMutationEffects_begin() { - while (nextEffect !== null) { - var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization - - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var deletion = deletions[i]; - commitBeforeMutationEffectsDeletion(deletion); - } - } - - var child = fiber.child; - - if ( - (fiber.subtreeFlags & BeforeMutationMask) !== NoFlags && - child !== null - ) { - ensureCorrectReturnPointer(child, fiber); - nextEffect = child; - } else { - commitBeforeMutationEffects_complete(); - } - } -} - -function commitBeforeMutationEffects_complete() { - while (nextEffect !== null) { - var fiber = nextEffect; - - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitBeforeMutationEffectsOnFiber, - null, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; +function commitBeforeMutationLifeCycles(current, finishedWork) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { return; } - nextEffect = fiber.return; - } -} - -function commitBeforeMutationEffectsOnFiber(finishedWork) { - var current = finishedWork.alternate; - var flags = finishedWork.flags; - - if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - // Check to see if the focused element was inside of a hidden (Suspense) subtree. - // TODO: Move this out of the hot path using a dedicated effect tag. - if ( - finishedWork.tag === SuspenseComponent && - isSuspenseBoundaryBeingHidden(current, finishedWork) && - doesFiberContain(finishedWork, focusedInstanceHandle) - ) { - shouldFireAfterActiveInstanceBlur = true; - } - } - - if ((flags & Snapshot) !== NoFlags) { - setCurrentFiber(finishedWork); - - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - break; - } - - case ClassComponent: { + case ClassComponent: { + if (finishedWork.flags & Snapshot) { if (current !== null) { var prevProps = current.memoizedProps; var prevState = current.memoizedState; @@ -17100,54 +16518,38 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { instance.__reactInternalSnapshotBeforeUpdate = snapshot; } - - break; } - case HostRoot: { - { + return; + } + + case HostRoot: { + { + if (finishedWork.flags & Snapshot) { var root = finishedWork.stateNode; clearContainer(root.containerInfo); } - - break; } - case HostComponent: - case HostText: - case HostPortal: - case IncompleteClassComponent: - // Nothing to do for these component types - break; - - default: { - { - 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." - ); - } - } + return; } - resetCurrentFiber(); + case HostComponent: + case HostText: + case HostPortal: + case IncompleteClassComponent: + // Nothing to do for these component types + 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 commitBeforeMutationEffectsDeletion(deletion) { - // TODO (effects) It would be nice to avoid calling doesFiberContain() - // Maybe we can repurpose one of the subtreeFlags positions for this instead? - // Use it to store which part of the tree the focused instance is in? - // This assumes we can safely determine that instance during the "render" phase. - if (doesFiberContain(deletion, focusedInstanceHandle)) { - shouldFireAfterActiveInstanceBlur = true; - } -} - -function commitHookEffectListUnmount( - flags, - finishedWork, - nearestMountedAncestor -) { +function commitHookEffectListUnmount(tag, finishedWork) { var updateQueue = finishedWork.updateQueue; var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; @@ -17156,13 +16558,13 @@ function commitHookEffectListUnmount( var effect = firstEffect; do { - if ((effect.tag & flags) === flags) { + if ((effect.tag & tag) === tag) { // Unmount var destroy = effect.destroy; effect.destroy = undefined; if (destroy !== undefined) { - safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy); + destroy(); } } @@ -17227,120 +16629,54 @@ function commitHookEffectListMount(tag, finishedWork) { } } -function commitLayoutEffectOnFiber( - finishedRoot, - current, - finishedWork, - committedLanes -) { - if ((finishedWork.flags & (Update | Callback)) !== NoFlags) { - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - // At this point layout effects have already been destroyed (during mutation phase). - // This is done to prevent 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. - { - commitHookEffectListMount(Layout | 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); } - case ClassComponent: { - var instance = finishedWork.stateNode; + effect = next; + } while (effect !== firstEffect); + } +} - 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. - // TODO: revisit this when we implement resuming. - { - if ( - finishedWork.type === finishedWork.elementType && - !didWarnAboutReassigningProps - ) { - if (instance.props !== finishedWork.memoizedProps) { - error( - "Expected %s props to match memoized props before " + - "componentDidMount. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ); - } +function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + // At this point layout effects have already been destroyed (during mutation phase). + // This is done to prevent 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. + { + commitHookEffectListMount(Layout | HasEffect, finishedWork); + } - if (instance.state !== finishedWork.memoizedState) { - error( - "Expected %s state to match memoized state before " + - "componentDidMount. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.state`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ); - } - } - } + schedulePassiveEffects(finishedWork); + return; + } - { - instance.componentDidMount(); - } - } else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps(finishedWork.type, current.memoizedProps); - 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. + case ClassComponent: { + var instance = finishedWork.stateNode; - { - if ( - finishedWork.type === finishedWork.elementType && - !didWarnAboutReassigningProps - ) { - if (instance.props !== finishedWork.memoizedProps) { - error( - "Expected %s props to match memoized props before " + - "componentDidUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ); - } - - if (instance.state !== finishedWork.memoizedState) { - error( - "Expected %s state to match memoized state before " + - "componentDidUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.state`. " + - "Please file an issue.", - getComponentName(finishedWork.type) || "instance" - ); - } - } - } - - { - instance.componentDidUpdate( - prevProps, - prevState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - } - } // 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) { + 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. + // TODO: revisit this when we implement resuming. { if ( finishedWork.type === finishedWork.elementType && @@ -17349,7 +16685,7 @@ function commitLayoutEffectOnFiber( if (instance.props !== finishedWork.memoizedProps) { error( "Expected %s props to match memoized props before " + - "processing the update queue. " + + "componentDidMount. " + "This might either be because of a bug in React, or because " + "a component reassigns its own `this.props`. " + "Please file an issue.", @@ -17360,7 +16696,7 @@ function commitLayoutEffectOnFiber( if (instance.state !== finishedWork.memoizedState) { error( "Expected %s state to match memoized state before " + - "processing the update queue. " + + "componentDidMount. " + "This might either be because of a bug in React, or because " + "a component reassigns its own `this.state`. " + "Please file an issue.", @@ -17368,116 +16704,193 @@ function commitLayoutEffectOnFiber( ); } } - } // We could update instance props and state here, + } + + { + instance.componentDidMount(); + } + } else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps(finishedWork.type, current.memoizedProps); + 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. - commitUpdateQueue(finishedWork, updateQueue, instance); - } + { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } - break; - } - - 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) { - var _instance = null; - - if (finishedWork.child !== null) { - switch (finishedWork.child.tag) { - case HostComponent: - _instance = getPublicInstance(finishedWork.child.stateNode); - break; - - case ClassComponent: - _instance = finishedWork.child.stateNode; - break; + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.state`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } } } - commitUpdateQueue(finishedWork, _updateQueue, _instance); + { + instance.componentDidUpdate( + prevProps, + prevState, + instance.__reactInternalSnapshotBeforeUpdate + ); + } } + } // TODO: I think this is now always non-null by the time it reaches the + // commit phase. Consider removing the type check. - break; - } + var updateQueue = finishedWork.updateQueue; - case HostComponent: { - var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted - // (eg DOM renderer may schedule auto-focus for inputs and form controls). - // These effects should only be committed when components are first mounted, - // aka when there is no current/alternate. - - if (current === null && finishedWork.flags & Update) { - var type = finishedWork.type; - var props = finishedWork.memoizedProps; - } - - break; - } - - case HostText: { - // We have no life-cycles associated with text. - break; - } - - case HostPortal: { - // We have no life-cycles associated with portals. - break; - } - - case Profiler: { + if (updateQueue !== null) { { - var _finishedWork$memoize2 = finishedWork.memoizedProps, - onCommit = _finishedWork$memoize2.onCommit, - onRender = _finishedWork$memoize2.onRender; - var effectDuration = finishedWork.stateNode.effectDuration; - var commitTime = getCommitTime(); - var phase = current === null ? "mount" : "update"; + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" + ); + } - if (typeof onRender === "function") { - { - onRender( - finishedWork.memoizedProps.id, - phase, - finishedWork.actualDuration, - finishedWork.treeBaseDuration, - finishedWork.actualStartTime, - commitTime, - finishedRoot.memoizedInteractions + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "processing the update queue. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.state`. " + + "Please file an issue.", + getComponentName(finishedWork.type) || "instance" ); } } + } // 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. + + commitUpdateQueue(finishedWork, updateQueue, instance); + } + + return; + } + + 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) { + var _instance = null; + + if (finishedWork.child !== null) { + switch (finishedWork.child.tag) { + case HostComponent: + _instance = getPublicInstance(finishedWork.child.stateNode); + break; + + case ClassComponent: + _instance = finishedWork.child.stateNode; + break; + } } - break; + commitUpdateQueue(finishedWork, _updateQueue, _instance); } - case SuspenseComponent: { - break; - } - - case SuspenseListComponent: - case IncompleteClassComponent: - case ScopeComponent: - case OffscreenComponent: - case LegacyHiddenComponent: - break; - - default: { - 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." - ); - } + return; } + + case HostComponent: { + var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted + // (eg DOM renderer may schedule auto-focus for inputs and form controls). + // These effects should only be committed when components are first mounted, + // aka when there is no current/alternate. + + if (current === null && finishedWork.flags & Update) { + var type = finishedWork.type; + var props = finishedWork.memoizedProps; + } + + return; + } + + case HostText: { + // We have no life-cycles associated with text. + return; + } + + case HostPortal: { + // We have no life-cycles associated with portals. + return; + } + + case Profiler: { + { + var _finishedWork$memoize2 = finishedWork.memoizedProps, + onCommit = _finishedWork$memoize2.onCommit, + onRender = _finishedWork$memoize2.onRender; + var effectDuration = finishedWork.stateNode.effectDuration; + var commitTime = getCommitTime(); + + if (typeof onRender === "function") { + { + onRender( + finishedWork.memoizedProps.id, + current === null ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + commitTime, + finishedRoot.memoizedInteractions + ); + } + } + } + + return; + } + + case SuspenseComponent: { + return; + } + + case SuspenseListComponent: + case IncompleteClassComponent: + case FundamentalComponent: + case ScopeComponent: + case OffscreenComponent: + case LegacyHiddenComponent: + return; } { - if (finishedWork.flags & Ref) { - commitAttachRef(finishedWork); - } + 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." + ); } } @@ -17586,12 +16999,7 @@ function commitDetachRef(current) { // deletion, so don't let them throw. Host-originating errors should // interrupt deletion, so it's okay -function commitUnmount( - finishedRoot, - current, - nearestMountedAncestor, - renderPriorityLevel -) { +function commitUnmount(finishedRoot, current, renderPriorityLevel) { onCommitUnmount(current); switch (current.tag) { @@ -17609,14 +17017,16 @@ function commitUnmount( var effect = firstEffect; do { - var _effect = effect, - destroy = _effect.destroy, - tag = _effect.tag; + var _effect2 = effect, + destroy = _effect2.destroy, + tag = _effect2.tag; if (destroy !== undefined) { - if ((tag & Layout) !== NoFlags$1) { + if ((tag & Passive$1) !== NoFlags$1) { + enqueuePendingPassiveHookEffectUnmount(current, effect); + } else { { - safelyCallDestroy(current, nearestMountedAncestor, destroy); + safelyCallDestroy(current, destroy); } } } @@ -17630,22 +17040,18 @@ function commitUnmount( } case ClassComponent: { - safelyDetachRef(current, nearestMountedAncestor); + safelyDetachRef(current); var instance = current.stateNode; if (typeof instance.componentWillUnmount === "function") { - safelyCallComponentWillUnmount( - current, - nearestMountedAncestor, - instance - ); + safelyCallComponentWillUnmount(current, instance); } return; } case HostComponent: { - safelyDetachRef(current, nearestMountedAncestor); + safelyDetachRef(current); return; } @@ -17654,12 +17060,16 @@ function commitUnmount( // We are also not using this parent because // the portal will get pushed immediately. { - unmountHostComponents(finishedRoot, current, nearestMountedAncestor); + unmountHostComponents(finishedRoot, current); } return; } + case FundamentalComponent: { + return; + } + case DehydratedFragment: { return; } @@ -17670,12 +17080,7 @@ function commitUnmount( } } -function commitNestedUnmounts( - finishedRoot, - root, - nearestMountedAncestor, - renderPriorityLevel -) { +function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { // While we're inside a removed host node we don't want to call // removeChild on the inner nodes because they're removed by the top // call anyway. We also want to call componentWillUnmount on all @@ -17684,7 +17089,7 @@ function commitNestedUnmounts( var node = root; while (true) { - commitUnmount(finishedRoot, node, nearestMountedAncestor); // 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 ( @@ -17715,37 +17120,28 @@ function commitNestedUnmounts( } function detachFiberMutation(fiber) { - // Cut off the return pointer to disconnect it from the tree. - // This enables us to detect and warn against state updates on an unmounted component. - // It also prevents events from bubbling from within disconnected components. - // - // Ideally, we should also clear the child pointer of the parent alternate to let this + // 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. + // 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. // - // Note that we can't clear child or sibling pointers yet. - // They're needed for passive effects and for findDOMNode. - // We defer those fields, and all other cleanup, to the passive phase (see detachFiberAfterEffects). - // - // Don't reset the alternate yet, either. We need that so we can detach the - // alternate's fields in the passive phase. Clearing the return pointer is - // sufficient for findDOMNode semantics. - fiber.return = null; -} - -function detachFiberAfterEffects(fiber) { - // Null out fields to improve GC for references that may be lingering (e.g. DevTools). - // Note that we already cleared the return pointer in detachFiberMutation(). + // 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.deletions = null; fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; + fiber.return = null; fiber.updateQueue = null; { @@ -17851,6 +17247,9 @@ function commitPlacement(finishedWork) { parent = parentStateNode.containerInfo; isContainer = true; break; + + case FundamentalComponent: + // eslint-disable-next-line-no-fallthrough default: { @@ -17878,7 +17277,7 @@ function insertOrAppendPlacementNodeIntoContainer(node, before, parent) { var tag = node.tag; var isHost = tag === HostComponent || tag === HostText; - if (isHost) { + if (isHost || enableFundamentalAPI) { var stateNode = isHost ? node.stateNode : node.stateNode.instance; if (before) { @@ -17906,7 +17305,7 @@ function insertOrAppendPlacementNode(node, before, parent) { var tag = node.tag; var isHost = tag === HostComponent || tag === HostText; - if (isHost) { + if (isHost || enableFundamentalAPI) { var stateNode = isHost ? node.stateNode : node.stateNode.instance; if (before) { @@ -17930,12 +17329,7 @@ function insertOrAppendPlacementNode(node, before, parent) { } } -function unmountHostComponents( - finishedRoot, - current, - nearestMountedAncestor, - renderPriorityLevel -) { +function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { // We only have the top Fiber that was deleted but we need to recurse down its // children to find all the terminal nodes. var node = current; // Each iteration, currentParent is populated with node's host parent if not @@ -17983,7 +17377,7 @@ function unmountHostComponents( } if (node.tag === HostComponent || node.tag === HostText) { - commitNestedUnmounts(finishedRoot, node, nearestMountedAncestor); // 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) { @@ -18003,7 +17397,7 @@ function unmountHostComponents( continue; } } else { - commitUnmount(finishedRoot, node, nearestMountedAncestor); // 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; @@ -18035,16 +17429,11 @@ function unmountHostComponents( } } -function commitDeletion( - finishedRoot, - current, - nearestMountedAncestor, - renderPriorityLevel -) { +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, nearestMountedAncestor); + unmountHostComponents(finishedRoot, current); } var alternate = current.alternate; @@ -18067,11 +17456,7 @@ function commitWork(current, finishedWork) { // 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, - finishedWork.return - ); + commitHookEffectListUnmount(Layout | HasEffect, finishedWork); } return; @@ -18144,6 +17529,10 @@ function commitWork(current, finishedWork) { return; } + case FundamentalComponent: { + break; + } + case ScopeComponent: { break; } @@ -18237,461 +17626,6 @@ function commitResetTextContent(current) { resetTextContent(current.stateNode); } -function commitMutationEffects(root, renderPriorityLevel, firstChild) { - nextEffect = firstChild; - commitMutationEffects_begin(root, renderPriorityLevel); -} - -function commitMutationEffects_begin(root, renderPriorityLevel) { - while (nextEffect !== null) { - var fiber = nextEffect; // TODO: Should wrap this in flags check, too, as optimization - - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var childToDelete = deletions[i]; - - { - invokeGuardedCallback( - null, - commitDeletion, - null, - root, - childToDelete, - fiber, - renderPriorityLevel - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(childToDelete, fiber, error); - } - } - } - } - - var child = fiber.child; - - if ((fiber.subtreeFlags & MutationMask) !== NoFlags && child !== null) { - ensureCorrectReturnPointer(child, fiber); - nextEffect = child; - } else { - commitMutationEffects_complete(root, renderPriorityLevel); - } - } -} - -function commitMutationEffects_complete(root, renderPriorityLevel) { - while (nextEffect !== null) { - var fiber = nextEffect; - - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitMutationEffectsOnFiber, - null, - fiber, - root, - renderPriorityLevel - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitMutationEffectsOnFiber(finishedWork, root, renderPriorityLevel) { - var flags = finishedWork.flags; - - if (flags & ContentReset) { - commitResetTextContent(finishedWork); - } - - if (flags & Ref) { - var current = finishedWork.alternate; - - 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 primaryFlags = flags & (Placement | Update | Hydrating); - - switch (primaryFlags) { - case Placement: { - commitPlacement(finishedWork); // 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. - - finishedWork.flags &= ~Placement; - break; - } - - case PlacementAndUpdate: { - // Placement - commitPlacement(finishedWork); // Clear the "placement" from effect tag so that we know that this is - // inserted, before any life-cycles like componentDidMount gets called. - - finishedWork.flags &= ~Placement; // Update - - var _current = finishedWork.alternate; - commitWork(_current, finishedWork); - break; - } - - case Hydrating: { - finishedWork.flags &= ~Hydrating; - break; - } - - case HydratingAndUpdate: { - finishedWork.flags &= ~Hydrating; // Update - - var _current2 = finishedWork.alternate; - commitWork(_current2, finishedWork); - break; - } - - case Update: { - var _current3 = finishedWork.alternate; - commitWork(_current3, finishedWork); - break; - } - } -} - -function commitLayoutEffects(finishedWork, root, committedLanes) { - nextEffect = finishedWork; - commitLayoutEffects_begin(finishedWork, root, committedLanes); -} - -function commitLayoutEffects_begin(subtreeRoot, root, committedLanes) { - while (nextEffect !== null) { - var fiber = nextEffect; - var firstChild = fiber.child; - - if ((fiber.subtreeFlags & LayoutMask) !== NoFlags && firstChild !== null) { - ensureCorrectReturnPointer(firstChild, fiber); - nextEffect = firstChild; - } else { - commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes); - } - } -} - -function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) { - while (nextEffect !== null) { - var fiber = nextEffect; - - if ((fiber.flags & LayoutMask) !== NoFlags) { - var current = fiber.alternate; - - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitLayoutEffectOnFiber, - null, - root, - current, - fiber, - committedLanes - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); - } - } - - if (fiber === subtreeRoot) { - nextEffect = null; - return; - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitPassiveMountEffects(root, finishedWork) { - nextEffect = finishedWork; - commitPassiveMountEffects_begin(finishedWork, root); -} - -function commitPassiveMountEffects_begin(subtreeRoot, root) { - while (nextEffect !== null) { - var fiber = nextEffect; - var firstChild = fiber.child; - - if ((fiber.subtreeFlags & PassiveMask) !== NoFlags && firstChild !== null) { - ensureCorrectReturnPointer(firstChild, fiber); - nextEffect = firstChild; - } else { - commitPassiveMountEffects_complete(subtreeRoot, root); - } - } -} - -function commitPassiveMountEffects_complete(subtreeRoot, root) { - while (nextEffect !== null) { - var fiber = nextEffect; - - if ((fiber.flags & Passive) !== NoFlags) { - { - setCurrentFiber(fiber); - invokeGuardedCallback( - null, - commitPassiveMountOnFiber, - null, - root, - fiber - ); - - if (hasCaughtError()) { - var error = clearCaughtError(); - captureCommitPhaseError(fiber, fiber.return, error); - } - - resetCurrentFiber(); - } - } - - if (fiber === subtreeRoot) { - nextEffect = null; - return; - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitPassiveMountOnFiber(finishedRoot, finishedWork) { - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - { - commitHookEffectListMount(Passive$1 | HasEffect, finishedWork); - } - - break; - } - } -} - -function commitPassiveUnmountEffects(firstChild) { - nextEffect = firstChild; - commitPassiveUnmountEffects_begin(); -} - -function commitPassiveUnmountEffects_begin() { - while (nextEffect !== null) { - var fiber = nextEffect; - var child = fiber.child; - - if ((nextEffect.flags & ChildDeletion) !== NoFlags) { - var deletions = fiber.deletions; - - if (deletions !== null) { - for (var i = 0; i < deletions.length; i++) { - var fiberToDelete = deletions[i]; - nextEffect = fiberToDelete; - commitPassiveUnmountEffectsInsideOfDeletedTree_begin( - fiberToDelete, - fiber - ); // Now that passive effects have been processed, it's safe to detach lingering pointers. - - var alternate = fiberToDelete.alternate; - detachFiberAfterEffects(fiberToDelete); - - if (alternate !== null) { - detachFiberAfterEffects(alternate); - } - } - - nextEffect = fiber; - } - } - - if ((fiber.subtreeFlags & PassiveMask) !== NoFlags && child !== null) { - ensureCorrectReturnPointer(child, fiber); - nextEffect = child; - } else { - commitPassiveUnmountEffects_complete(); - } - } -} - -function commitPassiveUnmountEffects_complete() { - while (nextEffect !== null) { - var fiber = nextEffect; - - if ((fiber.flags & Passive) !== NoFlags) { - setCurrentFiber(fiber); - commitPassiveUnmountOnFiber(fiber); - resetCurrentFiber(); - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitPassiveUnmountOnFiber(finishedWork) { - { - finishedWork.flags &= ~PassiveUnmountPendingDev; - var alternate = finishedWork.alternate; - - if (alternate !== null) { - alternate.flags &= ~PassiveUnmountPendingDev; - } - } - - switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - { - commitHookEffectListUnmount( - Passive$1 | HasEffect, - finishedWork, - finishedWork.return - ); - } - - break; - } - } -} - -function commitPassiveUnmountEffectsInsideOfDeletedTree_begin( - deletedSubtreeRoot, - nearestMountedAncestor -) { - while (nextEffect !== null) { - var fiber = nextEffect; // Deletion effects fire in parent -> child order - // TODO: Check if fiber has a PassiveStatic flag - - setCurrentFiber(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentFiber(); - var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag - - if (child !== null) { - ensureCorrectReturnPointer(child, fiber); - nextEffect = child; - } else { - commitPassiveUnmountEffectsInsideOfDeletedTree_complete( - deletedSubtreeRoot - ); - } - } -} - -function commitPassiveUnmountEffectsInsideOfDeletedTree_complete( - deletedSubtreeRoot -) { - while (nextEffect !== null) { - var fiber = nextEffect; - - if (fiber === deletedSubtreeRoot) { - nextEffect = null; - return; - } - - var sibling = fiber.sibling; - - if (sibling !== null) { - ensureCorrectReturnPointer(sibling, fiber.return); - nextEffect = sibling; - return; - } - - nextEffect = fiber.return; - } -} - -function commitPassiveUnmountInsideDeletedTreeOnFiber( - current, - nearestMountedAncestor -) { - switch (current.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - { - commitHookEffectListUnmount(Passive$1, current, nearestMountedAncestor); - } - - break; - } - } -} - -var didWarnWrongReturnPointer = false; - -function ensureCorrectReturnPointer(fiber, expectedReturnFiber) { - { - if (!didWarnWrongReturnPointer && fiber.return !== expectedReturnFiber) { - didWarnWrongReturnPointer = true; - - error( - "Internal React error: Return pointer is inconsistent " + "with parent." - ); - } - } // TODO: Remove this assignment once we're confident that it won't break - // anything, by checking the warning logs for the above invariant - - fiber.return = expectedReturnFiber; -} - var COMPONENT_TYPE = 0; var HAS_PSEUDO_CLASS_TYPE = 1; var ROLE_TYPE = 2; @@ -18771,7 +17705,8 @@ var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. -var workInProgressRootPingedLanes = NoLanes; // The most recent time we committed a fallback. This lets us ensure a train +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; @@ -18790,13 +17725,16 @@ function resetRenderTimer() { function getRenderTargetTime() { return workInProgressRootRenderTargetTime; } +var nextEffect = null; var hasUncaughtError = false; var firstUncaughtError = null; -var legacyErrorBoundariesThatAlreadyFailed = null; // Only used when enableProfilerNestedUpdateScheduledHook is true; +var legacyErrorBoundariesThatAlreadyFailed = null; var rootDoesHavePassiveEffects = false; var rootWithPendingPassiveEffects = null; -var pendingPassiveEffectsRenderPriority = NoPriority; +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; @@ -18814,10 +17752,13 @@ var spawnedWorkDuringRender = null; // If two updates are scheduled within the s // between the first and second call. var currentEventTime = NoTimestamp; -var currentEventTransitionLane = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed. +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; } @@ -18842,41 +17783,63 @@ function requestUpdateLane(fiber) { if ((mode & BlockingMode) === NoMode) { return SyncLane; } else if ((mode & ConcurrentMode) === NoMode) { - return getCurrentPriorityLevel() === ImmediatePriority + 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 (currentEventTransitionLane === NoLane) { - currentEventTransitionLane = claimNextTransitionLane(); + if (currentEventPendingLanes !== NoLanes) { + currentEventPendingLanes = + mostRecentlyUpdatedRoot !== null + ? mostRecentlyUpdatedRoot.pendingLanes + : NoLanes; } - return currentEventTransitionLane; + 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(); // Find the correct lane based on priorities. Ideally, this would just be - // the update lane priority, but for now we're also checking for discrete - // updates and falling back to the scheduler 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 + schedulerPriority === UserBlockingPriority$1 ) { - lane = findUpdateLane(InputDiscreteLanePriority); + lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes); } else { - { - var schedulerLanePriority = schedulerPriorityToLanePriority( - schedulerPriority - ); - lane = findUpdateLane(schedulerLanePriority); - } + var schedulerLanePriority = schedulerPriorityToLanePriority( + schedulerPriority + ); + + lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes); } return lane; @@ -18892,12 +17855,16 @@ function requestRetryLane(fiber) { if ((mode & BlockingMode) === NoMode) { return SyncLane; } else if ((mode & ConcurrentMode) === NoMode) { - return getCurrentPriorityLevel() === ImmediatePriority + return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane; } // See `requestUpdateLane` for explanation of `currentEventWipLanes` - return claimNextRetryLane(); + if (currentEventWipLanes === NoLanes) { + currentEventWipLanes = workInProgressRootIncludedLanes; + } + + return findRetryLane(currentEventWipLanes); } function scheduleUpdateOnFiber(fiber, lane, eventTime) { @@ -18970,8 +17937,8 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { if ( (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered // discrete, even inside a discrete event. - (priorityLevel === UserBlockingPriority || - priorityLevel === ImmediatePriority) + (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. @@ -18984,9 +17951,13 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { 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. - return root; + 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 @@ -19008,7 +17979,7 @@ function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { ) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } - } // Walk the parent path to the root and update the child lanes. + } // Walk the parent path to the root and update the child expiration time. var node = sourceFiber; var parent = sourceFiber.return; @@ -19037,20 +18008,6 @@ function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { } else { return null; } -} - -function isInterleavedUpdate(fiber, lane) { - return ( - // TODO: Optimize slightly by comparing to root that fiber belongs to. - // Requires some refactoring. Not a big deal though since it's rare for - // concurrent apps to have more than a single root. - workInProgressRoot !== null && - (fiber.mode & BlockingMode) !== NoMode && // If this is a render phase update (i.e. UNSAFE_componentWillReceiveProps), - // then don't treat this as an interleaved update. This pattern is - // accompanied by a warning but we haven't fully deprecated it yet. We can - // remove once the deferRenderPhaseUpdateToNextBatch flag is enabled. - deferRenderPhaseUpdateToNextBatch - ); } // 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 @@ -19074,36 +18031,22 @@ function ensureRootIsScheduled(root, currentTime) { // Special case: There's nothing to work on. if (existingCallbackNode !== null) { cancelCallback(existingCallbackNode); + root.callbackNode = null; + root.callbackPriority = NoLanePriority; } - root.callbackNode = null; - root.callbackPriority = NoLanePriority; return; } // Check if there's an existing task. We may be able to reuse it. - var existingCallbackPriority = root.callbackPriority; + if (existingCallbackNode !== null) { + var existingCallbackPriority = root.callbackPriority; - if (existingCallbackPriority === newCallbackPriority) { - { - // If we're going to re-use an existing task, it needs to exist. - // Assume that discrete update microtasks are non-cancellable and null. - // TODO: Temporary until we confirm this warning is not fired. - if ( - existingCallbackNode == null && - existingCallbackPriority !== InputDiscreteLanePriority && - existingCallbackPriority !== SyncLanePriority - ) { - error( - "Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue." - ); - } - } // The priority hasn't changed. We can reuse the existing task. Exit. + 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. - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. cancelCallback(existingCallbackNode); } // Schedule a new callback. @@ -19112,11 +18055,12 @@ function ensureRootIsScheduled(root, currentTime) { if (newCallbackPriority === SyncLanePriority) { // Special case: Sync React callbacks are scheduled on a special // internal queue - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - newCallbackNode = null; + newCallbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + ); } else if (newCallbackPriority === SyncBatchedLanePriority) { newCallbackNode = scheduleCallback( - ImmediatePriority, + ImmediatePriority$1, performSyncWorkOnRoot.bind(null, root) ); } else { @@ -19134,11 +18078,12 @@ 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; - currentEventTransitionLane = NoLanes; + currentEventWipLanes = NoLanes; + currentEventPendingLanes = NoLanes; if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { throw Error("Should not already be working."); @@ -19168,22 +18113,24 @@ 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 we're still investigating. 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); - if (exitStatus !== RootIncomplete) { + 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. @@ -19375,9 +18322,26 @@ function performSyncWorkOnRoot(root) { // rendering it before rendering the rest of the expired work. lanes = workInProgressRootRenderLanes; exitStatus = renderRootSync(root, lanes); - } else { - lanes = getNextLanes(root, NoLanes); // Because we don't cancel synchronous tasks, sometimes more than one + 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); } @@ -19455,7 +18419,7 @@ function flushSync(fn, a) { { try { if (fn) { - return runWithPriority(ImmediatePriority, fn.bind(null, a)); + return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); } else { return undefined; } @@ -19511,7 +18475,6 @@ function prepareFreshStack(root, lanes) { workInProgressRootSkippedLanes = NoLanes; workInProgressRootUpdatedLanes = NoLanes; workInProgressRootPingedLanes = NoLanes; - enqueueInterleavedUpdates(); { spawnedWorkDuringRender = null; @@ -19835,6 +18798,47 @@ function completeUnitOfWork(unitOfWork) { workInProgress = next; return; } + + resetChildLanes(completedWork); + + 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 (completedWork.lastEffect !== null) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = completedWork.firstEffect; + } + + 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 (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, @@ -19867,10 +18871,9 @@ function completeUnitOfWork(unitOfWork) { } if (returnFiber !== null) { - // Mark the parent fiber as incomplete and clear its subtree flags. + // Mark the parent fiber as incomplete and clear its effect list. + returnFiber.firstEffect = returnFiber.lastEffect = null; returnFiber.flags |= Incomplete; - returnFiber.subtreeFlags = NoFlags; - returnFiber.deletions = null; } } @@ -19892,10 +18895,88 @@ function completeUnitOfWork(unitOfWork) { } } +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; + } + + var newChildLanes = NoLanes; // Bubble up the earliest expiration time. + + 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 shouldBubbleActualDurations = + completedWork.alternate === null || + completedWork.child !== completedWork.alternate.child; + var child = completedWork.child; + + while (child !== null) { + newChildLanes = mergeLanes( + newChildLanes, + mergeLanes(child.lanes, child.childLanes) + ); + + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } + + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + + var isTimedOutSuspense = + completedWork.tag === SuspenseComponent && + completedWork.memoizedState !== null; + + 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 { + var _child = completedWork.child; + + while (_child !== null) { + newChildLanes = mergeLanes( + newChildLanes, + mergeLanes(_child.lanes, _child.childLanes) + ); + _child = _child.sibling; + } + } + + completedWork.childLanes = newChildLanes; +} + function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority( - ImmediatePriority, + ImmediatePriority$1, commitRootImpl.bind(null, root, renderPriorityLevel) ); return null; @@ -19935,8 +19016,7 @@ function commitRootImpl(root, renderPriorityLevel) { } // commitRoot never returns a continuation; it always finishes synchronously. // So we can clear these now to allow a new callback to be scheduled. - root.callbackNode = null; - root.callbackPriority = NoLanePriority; // Update the first and last pending times on this root. The new first + 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. var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes); @@ -19958,39 +19038,27 @@ function commitRootImpl(root, renderPriorityLevel) { workInProgressRoot = null; workInProgress = null; workInProgressRootRenderLanes = NoLanes; - } // If there are pending passive effects, schedule a callback to process them. - // Do this as early as possible, so it is queued before anything else that - // might get scheduled in the commit phase. (See #16714.) - // TODO: Delete all other places that schedule the passive effect callback - // They're redundant. + } // Get the list of effects. - if ( - (finishedWork.subtreeFlags & PassiveMask) !== NoFlags || - (finishedWork.flags & PassiveMask) !== NoFlags - ) { - if (!rootDoesHavePassiveEffects) { - rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority, function() { - flushPassiveEffects(); - return null; - }); + 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; } - } // Check if there are any effects in the whole tree. - // TODO: This is left over from the effect list implementation, where we had - // to check for the existence of `firstEffect` to satsify Flow. I think the - // only other reason this optimization exists is because it affects profiling. - // Reconsider whether this is necessary. + } else { + // There is no effect on the root. + firstEffect = finishedWork.firstEffect; + } - var subtreeHasEffects = - (finishedWork.subtreeFlags & - (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== - NoFlags; - var rootHasEffect = - (finishedWork.flags & - (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== - NoFlags; - - if (subtreeHasEffects || rootHasEffect) { + if (firstEffect !== null) { var prevExecutionContext = executionContext; executionContext |= CommitContext; var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles @@ -20002,18 +19070,58 @@ function commitRootImpl(root, renderPriorityLevel) { // state of the host tree right before we mutate it. This is where // getSnapshotBeforeUpdate is called. - var shouldFireAfterActiveInstanceBlur = commitBeforeMutationEffects( - root, - finishedWork - ); + focusedInstanceHandle = prepareForCommit(root.containerInfo); + shouldFireAfterActiveInstanceBlur = false; + nextEffect = firstEffect; + + do { + { + invokeGuardedCallback(null, commitBeforeMutationEffects, null); + + 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 + + focusedInstanceHandle = null; { // 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. - commitMutationEffects(root, renderPriorityLevel, finishedWork); + nextEffect = firstEffect; + + do { + { + invokeGuardedCallback( + null, + commitMutationEffects, + null, + root, + renderPriorityLevel + ); + + 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); 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 @@ -20021,8 +19129,29 @@ function commitRootImpl(root, renderPriorityLevel) { // work is current during componentDidMount/Update. 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. - commitLayoutEffects(finishedWork, root, lanes); + nextEffect = firstEffect; + + do { + { + invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes); + + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + throw Error("Should be working on an effect."); + } + + var _error2 = clearCaughtError(); + + captureCommitPhaseError(nextEffect, _error2); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + + nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an // opportunity to paint. requestPaint(); @@ -20052,6 +19181,22 @@ function commitRootImpl(root, renderPriorityLevel) { 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; + + while (nextEffect !== null) { + var nextNextEffect = nextEffect.nextEffect; + nextEffect.nextEffect = null; + + if (nextEffect.flags & Deletion) { + detachFiberAfterEffects(nextEffect); + } + + nextEffect = nextNextEffect; + } } // Read this again, since an effect might have updated it remainingLanes = root.pendingLanes; // Check if there's remaining work on this root @@ -20089,9 +19234,9 @@ function commitRootImpl(root, renderPriorityLevel) { } } - if (includesSomeLane(remainingLanes, SyncLane)) { + 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 { @@ -20109,9 +19254,9 @@ function commitRootImpl(root, renderPriorityLevel) { if (hasUncaughtError) { hasUncaughtError = false; - var error = firstUncaughtError; + var _error3 = firstUncaughtError; firstUncaughtError = null; - throw error; + throw _error3; } if ((executionContext & LegacyUnbatchedContext) !== NoContext) { @@ -20127,14 +19272,156 @@ function commitRootImpl(root, renderPriorityLevel) { return null; } +function commitBeforeMutationEffects() { + while (nextEffect !== null) { + var current = nextEffect.alternate; + + 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; + } + } + } + + var flags = nextEffect.flags; + + if ((flags & Snapshot) !== NoFlags) { + setCurrentFiber(nextEffect); + commitBeforeMutationLifeCycles(current, nextEffect); + resetCurrentFiber(); + } + + 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; + }); + } + } + + nextEffect = nextEffect.nextEffect; + } +} + +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 (flags & ContentReset) { + commitResetTextContent(nextEffect); + } + + if (flags & Ref) { + var current = nextEffect.alternate; + + 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 primaryFlags = flags & (Placement | Update | Deletion | Hydrating); + + 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.flags &= ~Placement; + break; + } + + 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. + + nextEffect.flags &= ~Placement; // Update + + var _current = nextEffect.alternate; + commitWork(_current, nextEffect); + break; + } + + case Hydrating: { + nextEffect.flags &= ~Hydrating; + break; + } + + case HydratingAndUpdate: { + nextEffect.flags &= ~Hydrating; // Update + + var _current2 = nextEffect.alternate; + commitWork(_current2, nextEffect); + break; + } + + case Update: { + var _current3 = nextEffect.alternate; + commitWork(_current3, nextEffect); + break; + } + + case Deletion: { + commitDeletion(root, nextEffect); + break; + } + } + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} + +function commitLayoutEffects(root, committedLanes) { + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + var flags = nextEffect.flags; + + if (flags & (Update | Callback)) { + var current = nextEffect.alternate; + commitLifeCycles(root, current, nextEffect); + } + + { + if (flags & Ref) { + commitAttachRef(nextEffect); + } + } + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} + function flushPassiveEffects() { // Returns whether passive effects were flushed. - if (pendingPassiveEffectsRenderPriority !== NoPriority) { + if (pendingPassiveEffectsRenderPriority !== NoPriority$1) { var priorityLevel = - pendingPassiveEffectsRenderPriority > NormalPriority - ? NormalPriority + pendingPassiveEffectsRenderPriority > NormalPriority$1 + ? NormalPriority$1 : pendingPassiveEffectsRenderPriority; - pendingPassiveEffectsRenderPriority = NoPriority; + pendingPassiveEffectsRenderPriority = NoPriority$1; { return runWithPriority(priorityLevel, flushPassiveEffectsImpl); @@ -20143,6 +19430,42 @@ function flushPassiveEffects() { return false; } +function enqueuePendingPassiveHookEffectMount(fiber, effect) { + pendingPassiveHookEffectsMount.push(effect, fiber); + + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); + } +} +function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { + pendingPassiveHookEffectsUnmount.push(effect, fiber); + + { + fiber.flags |= PassiveUnmountPendingDev; + var alternate = fiber.alternate; + + if (alternate !== null) { + alternate.flags |= PassiveUnmountPendingDev; + } + } + + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function() { + flushPassiveEffects(); + return null; + }); + } +} + +function invokePassiveEffectCreate(effect) { + var create = effect.create; + effect.destroy = create(); +} function flushPassiveEffectsImpl() { if (rootWithPendingPassiveEffects === null) { @@ -20164,9 +19487,97 @@ function flushPassiveEffectsImpl() { var prevExecutionContext = executionContext; executionContext |= CommitContext; - var prevInteractions = pushInteractions(root); - commitPassiveUnmountEffects(root.current); - commitPassiveMountEffects(root, root.current); // TODO: Move to commitPassiveMountEffects + 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; + + { + fiber.flags &= ~PassiveUnmountPendingDev; + var alternate = fiber.alternate; + + if (alternate !== null) { + alternate.flags &= ~PassiveUnmountPendingDev; + } + } + + if (typeof destroy === "function") { + { + setCurrentFiber(fiber); + + { + invokeGuardedCallback(null, destroy, null); + } + + if (hasCaughtError()) { + if (!(fiber !== null)) { + throw Error("Should be working on an effect."); + } + + var error = clearCaughtError(); + captureCommitPhaseError(fiber, error); + } + + resetCurrentFiber(); + } + } + } // Second pass: Create new passive effects. + + var mountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + + for (var _i = 0; _i < mountEffects.length; _i += 2) { + var _effect2 = mountEffects[_i]; + var _fiber = mountEffects[_i + 1]; + + { + setCurrentFiber(_fiber); + + { + invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2); + } + + if (hasCaughtError()) { + if (!(_fiber !== null)) { + throw Error("Should be working on an effect."); + } + + var _error4 = clearCaughtError(); + + captureCommitPhaseError(_fiber, _error4); + } + + 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. + + var effect = root.current.firstEffect; + + while (effect !== null) { + var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC + + effect.nextEffect = null; + + if (effect.flags & Deletion) { + detachFiberAfterEffects(effect); + } + + effect = nextNextEffect; + } { popInteractions(prevInteractions); @@ -20223,23 +19634,19 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { } } -function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { +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$1); + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); return; } - var fiber = null; - - { - fiber = sourceFiber.return; - } + var fiber = sourceFiber.return; while (fiber !== null) { if (fiber.tag === HostRoot) { - captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error$1); + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); return; } else if (fiber.tag === ClassComponent) { var ctor = fiber.type; @@ -20250,7 +19657,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { (typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) ) { - var errorInfo = createCapturedValue(error$1, sourceFiber); + var errorInfo = createCapturedValue(error, sourceFiber); var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); enqueueUpdate(fiber, update); var eventTime = requestEventTime(); @@ -20260,6 +19667,24 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { 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; @@ -20268,22 +19693,6 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { fiber = fiber.return; } - - { - // TODO: Until we re-land skipUnmountedBoundaries (see #20147), this warning - // will fire for errors that are thrown by destroy functions inside deleted - // trees. What it should instead do is propagate the error to the parent of - // the deleted tree. In the meantime, do not add this warning to the - // allowlist; this is only for our internal use. - error( - "Internal React error: Attempted to capture a commit phase error " + - "inside a detached tree. This indicates a bug in React. Likely " + - "causes include deleting the same fiber more than once, committing an " + - "already-finished tree, or an inconsistent return pointer.\n\n" + - "Error message:\n\n%s", - error$1 - ); - } } function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; @@ -20336,8 +19745,6 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { // 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) { - // TODO: Assign this to `suspenseState.retryLane`? to avoid - // unnecessary entanglement? retryLane = requestRetryLane(boundaryFiber); } // TODO: Special case idle priority? @@ -20506,29 +19913,11 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { ) { // 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 & PassiveStatic) !== NoFlags) { - var updateQueue = fiber.updateQueue; - - if (updateQueue !== null) { - var lastEffect = updateQueue.lastEffect; - - if (lastEffect !== null) { - var firstEffect = lastEffect.next; - var effect = firstEffect; - - do { - if (effect.destroy !== undefined) { - if ((effect.tag & Passive$1) !== NoFlags$1) { - return; - } - } - - effect = effect.next; - } while (effect !== firstEffect); - } - } + 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. @@ -20616,23 +20005,14 @@ var beginWork$1; invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes); if (hasCaughtError()) { - var replayError = clearCaughtError(); + var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. + // Rethrow this error instead of the original one. - if ( - typeof replayError === "object" && - replayError !== null && - replayError._suppressLogging && - typeof originalError === "object" && - originalError !== null && - !originalError._suppressLogging - ) { - // If suppressed, let the flag carry over to the original error which is the one we'll rethrow. - originalError._suppressLogging = true; - } - } // We always throw the original error in case the second render pass is not idempotent. - // This can happen if a memoized function or CommonJS module doesn't throw after first invokation. - - throw originalError; + throw replayError; + } else { + // This branch is reachable if the render phase is impure. + throw originalError; + } } }; } @@ -20721,7 +20101,7 @@ function warnIfNotScopedWithMatchingAct(fiber) { "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" + + "om react-test-renderer';\n" + "const {act} = TestRenderer;\n" + "// ...\n" + "act(() => ...);" @@ -20739,7 +20119,7 @@ function warnIfNotScopedWithMatchingAct(fiber) { function warnIfNotCurrentlyActingEffectsInDEV(fiber) { { if ( - (fiber.mode & StrictLegacyMode) !== NoMode && + (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { @@ -20919,7 +20299,7 @@ function startWorkOnPendingInteractions(root, lanes) { subscriber.onWorkStarted(interactions, threadID); } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { + scheduleCallback(ImmediatePriority$1, function() { throw error; }); } @@ -20941,7 +20321,7 @@ function finishPendingInteractions(root, committedLanes) { } } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { + scheduleCallback(ImmediatePriority$1, function() { throw error; }); } finally { @@ -20963,7 +20343,7 @@ function finishPendingInteractions(root, committedLanes) { subscriber.onInteractionScheduledWorkCompleted(interaction); } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority, function() { + scheduleCallback(ImmediatePriority$1, function() { throw error; }); } @@ -20982,6 +20362,11 @@ function shouldForceFlushFallbacksInDEV() { var actingUpdatesScopeDepth = 0; +function detachFiberAfterEffects(fiber) { + fiber.sibling = null; + fiber.stateNode = null; +} + var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. var failedBoundaries = null; @@ -21458,8 +20843,9 @@ function FiberNode(tag, pendingProps, key, mode) { this.mode = mode; // Effects this.flags = NoFlags; - this.subtreeFlags = NoFlags; - this.deletions = null; + this.nextEffect = null; + this.firstEffect = null; + this.lastEffect = null; this.lanes = NoLanes; this.childLanes = NoLanes; this.alternate = null; @@ -21586,10 +20972,11 @@ function createWorkInProgress(current, pendingProps) { workInProgress.type = current.type; // We already have an alternate. // Reset the effect tag. - workInProgress.flags = NoFlags; // The effects are no longer valid. + workInProgress.flags = NoFlags; // The effect list is no longer valid. - workInProgress.subtreeFlags = NoFlags; - workInProgress.deletions = null; + workInProgress.nextEffect = null; + workInProgress.firstEffect = null; + workInProgress.lastEffect = null; { // We intentionally reset, rather than copy, actualDuration & actualStartTime. @@ -21599,10 +20986,8 @@ function createWorkInProgress(current, pendingProps) { workInProgress.actualDuration = 0; workInProgress.actualStartTime = -1; } - } // Reset all effects except static ones. - // Static effects are not specific to a render. + } - workInProgress.flags = current.flags & StaticMask; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -21659,10 +21044,13 @@ function resetWorkInProgress(workInProgress, renderLanes) { // when they should be reading from current and writing to workInProgress. // We assume pendingProps, index, key, ref, return are still untouched to // avoid doing another reconciliation. - // Reset the effect flags but keep any Placement tags, since that's something + // Reset the effect tag but keep any Placement tags, since that's something // that child fiber is setting, not the reconciliation. - workInProgress.flags &= StaticMask | Placement; // The effects are no longer valid. + workInProgress.flags &= Placement; // The effect list is no longer valid. + workInProgress.nextEffect = null; + workInProgress.firstEffect = null; + workInProgress.lastEffect = null; var current = workInProgress.alternate; if (current === null) { @@ -21670,7 +21058,6 @@ function resetWorkInProgress(workInProgress, renderLanes) { workInProgress.childLanes = NoLanes; workInProgress.lanes = renderLanes; workInProgress.child = null; - workInProgress.subtreeFlags = NoFlags; workInProgress.memoizedProps = null; workInProgress.memoizedState = null; workInProgress.updateQueue = null; @@ -21687,12 +21074,7 @@ function resetWorkInProgress(workInProgress, renderLanes) { // Reset to the cloned values that createWorkInProgress would've. workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; - workInProgress.child = current.child; // TODO: `subtreeFlags` should be reset to NoFlags, like we do in - // `createWorkInProgress`. Nothing reads this until the complete phase, - // currently, but it might in the future, and we should be consistent. - - workInProgress.subtreeFlags = current.subtreeFlags; - workInProgress.deletions = null; + workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type. @@ -21719,33 +21101,13 @@ function resetWorkInProgress(workInProgress, renderLanes) { return workInProgress; } -function createHostRootFiber(tag, strictModeLevelOverride) { +function createHostRootFiber(tag) { var mode; if (tag === ConcurrentRoot) { - mode = ConcurrentMode | BlockingMode; - - if (strictModeLevelOverride !== null) { - if (strictModeLevelOverride >= 1) { - mode |= StrictLegacyMode; - } - } else { - { - mode |= StrictLegacyMode; - } - } + mode = ConcurrentMode | BlockingMode | StrictMode; } else if (tag === BlockingRoot) { - mode = BlockingMode; - - if (strictModeLevelOverride !== null) { - if (strictModeLevelOverride >= 1) { - mode |= StrictLegacyMode; - } - } else { - { - mode |= StrictLegacyMode; - } - } + mode = BlockingMode | StrictMode; } else { mode = NoMode; } @@ -21796,16 +21158,8 @@ function createFiberFromTypeAndProps( break; case REACT_STRICT_MODE_TYPE: - fiberTag = Mode; // Legacy strict mode ( without any level prop) defaults to level 1. - - var level = - pendingProps.unstable_level == null ? 1 : pendingProps.unstable_level; // Levels cascade; higher levels inherit all lower level modes. - // It is explicitly not supported to lower a mode with nesting, only to increase it. - - if (level >= 1) { - mode |= StrictLegacyMode; - } - + fiberTag = Mode; + mode |= StrictMode; break; case REACT_PROFILER_TYPE: @@ -21827,10 +21181,6 @@ function createFiberFromTypeAndProps( // eslint-disable-next-line no-fallthrough - case REACT_CACHE_TYPE: - - // eslint-disable-next-line no-fallthrough - default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -22059,8 +21409,9 @@ function assignFiberPropertiesInDEV(target, source) { target.dependencies = source.dependencies; target.mode = source.mode; target.flags = source.flags; - target.subtreeFlags = source.subtreeFlags; - target.deletions = source.deletions; + target.nextEffect = source.nextEffect; + target.firstEffect = source.firstEffect; + target.lastEffect = source.lastEffect; target.lanes = source.lanes; target.childLanes = source.childLanes; target.alternate = source.alternate; @@ -22127,27 +21478,13 @@ function FiberRootNode(containerInfo, tag, hydrate) { } } -function createFiberRoot( - containerInfo, - tag, - hydrate, - hydrationCallbacks, - strictModeLevelOverride -) { +function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { var root = new FiberRootNode(containerInfo, tag, hydrate); // stateNode is any. - var uninitializedFiber = createHostRootFiber(tag, strictModeLevelOverride); + var uninitializedFiber = createHostRootFiber(tag); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; - - { - var _initialState = { - element: null - }; - uninitializedFiber.memoizedState = _initialState; - } - initializeUpdateQueue(uninitializedFiber); return root; } @@ -22221,7 +21558,7 @@ function findHostInstanceWithWarning(component, methodName) { return null; } - if (hostFiber.mode & StrictLegacyMode) { + if (hostFiber.mode & StrictMode) { var componentName = getComponentName(fiber.type) || "Component"; if (!didWarnAboutFindNodeInStrictMode[componentName]) { @@ -22231,7 +21568,7 @@ function findHostInstanceWithWarning(component, methodName) { try { setCurrentFiber(hostFiber); - if (fiber.mode & StrictLegacyMode) { + if (fiber.mode & StrictMode) { error( "%s is deprecated in StrictMode. " + "%s was passed an instance of %s which is inside StrictMode. " + @@ -22270,20 +21607,8 @@ function findHostInstanceWithWarning(component, methodName) { } } -function createContainer( - containerInfo, - tag, - hydrate, - hydrationCallbacks, - strictModeLevelOverride -) { - return createFiberRoot( - containerInfo, - tag, - hydrate, - hydrationCallbacks, - strictModeLevelOverride - ); +function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { + return createFiberRoot(containerInfo, tag, hydrate); } function updateContainer(element, container, parentComponent, callback) { { @@ -22348,12 +21673,7 @@ function updateContainer(element, container, parentComponent, callback) { } enqueueUpdate(current$1, update); - var root = scheduleUpdateOnFiber(current$1, lane, eventTime); - - if (root !== null) { - entangleTransitions(root, current$1, lane); - } - + scheduleUpdateOnFiber(current$1, lane, eventTime); return lane; } function getPublicRootInstance(container) { @@ -23034,12 +22354,11 @@ function render(element, containerTag, callback) { if (!root) { // TODO (bvaughn): If we decide to keep the wrapper component, // We could create a wrapper for containerTag as well to reduce special casing. - root = createContainer(containerTag, LegacyRoot, false, null, null); + root = createContainer(containerTag, LegacyRoot, false); roots.set(containerTag, root); } - updateContainer(element, root, null, callback); // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN - + updateContainer(element, root, null, callback); return getPublicRootInstance(root); } diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 8d91437ab93..ccced617800 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_213 = { +var injectedNamesToPlugins$jscomp$inline_222 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -954,34 +954,34 @@ var injectedNamesToPlugins$jscomp$inline_213 = { } } }, - isOrderingDirty$jscomp$inline_214 = !1, - pluginName$jscomp$inline_215; -for (pluginName$jscomp$inline_215 in injectedNamesToPlugins$jscomp$inline_213) + isOrderingDirty$jscomp$inline_223 = !1, + pluginName$jscomp$inline_224; +for (pluginName$jscomp$inline_224 in injectedNamesToPlugins$jscomp$inline_222) if ( - injectedNamesToPlugins$jscomp$inline_213.hasOwnProperty( - pluginName$jscomp$inline_215 + injectedNamesToPlugins$jscomp$inline_222.hasOwnProperty( + pluginName$jscomp$inline_224 ) ) { - var pluginModule$jscomp$inline_216 = - injectedNamesToPlugins$jscomp$inline_213[pluginName$jscomp$inline_215]; + var pluginModule$jscomp$inline_225 = + injectedNamesToPlugins$jscomp$inline_222[pluginName$jscomp$inline_224]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_215) || - namesToPlugins[pluginName$jscomp$inline_215] !== - pluginModule$jscomp$inline_216 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_224) || + namesToPlugins[pluginName$jscomp$inline_224] !== + pluginModule$jscomp$inline_225 ) { - if (namesToPlugins[pluginName$jscomp$inline_215]) + if (namesToPlugins[pluginName$jscomp$inline_224]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_215 + + pluginName$jscomp$inline_224 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_215 - ] = pluginModule$jscomp$inline_216; - isOrderingDirty$jscomp$inline_214 = !0; + pluginName$jscomp$inline_224 + ] = pluginModule$jscomp$inline_225; + isOrderingDirty$jscomp$inline_223 = !0; } } -isOrderingDirty$jscomp$inline_214 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_223 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1139,8 +1139,7 @@ var ReactSharedInternals = REACT_LAZY_TYPE = 60116, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, - REACT_LEGACY_HIDDEN_TYPE = 60131, - REACT_CACHE_TYPE = 60132; + REACT_LEGACY_HIDDEN_TYPE = 60131; if ("function" === typeof Symbol && Symbol.for) { var symbolFor = Symbol.for; REACT_ELEMENT_TYPE = symbolFor("react.element"); @@ -1159,7 +1158,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); - REACT_CACHE_TYPE = symbolFor("react.cache"); } var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { @@ -1186,8 +1184,6 @@ function getComponentName(type) { return "Suspense"; case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList"; - case REACT_CACHE_TYPE: - return "Cache"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -1221,7 +1217,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.flags & 2050) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1309,14 +1305,19 @@ function findCurrentFiberUsingSlowPath(fiber) { } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); - return null !== parent ? findCurrentHostFiberImpl(parent) : null; -} -function findCurrentHostFiberImpl(node) { - if (5 === node.tag || 6 === node.tag) return node; - for (node = node.child; null !== node; ) { - var match = findCurrentHostFiberImpl(node); - if (null !== match) return match; - node = node.sibling; + if (!parent) return null; + for (var node = parent; ; ) { + if (5 === node.tag || 6 === node.tag) return node; + if (node.child) (node.child.return = node), (node = node.child); + else { + if (node === parent) break; + for (; !node.sibling; ) { + if (!node.return || node.return === parent) return null; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } } return null; } @@ -1566,382 +1567,60 @@ function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { }; } var ReactNativeFiberHostComponent = (function() { - function ReactNativeFiberHostComponent(tag, viewConfig) { - this._nativeTag = tag; - this._children = []; - this.viewConfig = viewConfig; - } - var _proto = ReactNativeFiberHostComponent.prototype; - _proto.blur = function() { - ReactNativePrivateInterface.TextInputState.blurTextInput(this); - }; - _proto.focus = function() { - ReactNativePrivateInterface.TextInputState.focusTextInput(this); - }; - _proto.measure = function(callback) { - ReactNativePrivateInterface.UIManager.measure( + function ReactNativeFiberHostComponent(tag, viewConfig) { + this._nativeTag = tag; + this._children = []; + this.viewConfig = viewConfig; + } + var _proto = ReactNativeFiberHostComponent.prototype; + _proto.blur = function() { + ReactNativePrivateInterface.TextInputState.blurTextInput(this); + }; + _proto.focus = function() { + ReactNativePrivateInterface.TextInputState.focusTextInput(this); + }; + _proto.measure = function(callback) { + ReactNativePrivateInterface.UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + _proto.measureInWindow = function(callback) { + ReactNativePrivateInterface.UIManager.measureInWindow( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + _proto.measureLayout = function(relativeToNativeNode, onSuccess, onFail) { + if ("number" === typeof relativeToNativeNode) + var relativeNode = relativeToNativeNode; + else + relativeToNativeNode._nativeTag && + (relativeNode = relativeToNativeNode._nativeTag); + null != relativeNode && + ReactNativePrivateInterface.UIManager.measureLayout( this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); - }; - _proto.measureInWindow = function(callback) { - ReactNativePrivateInterface.UIManager.measureInWindow( + }; + _proto.setNativeProps = function(nativeProps) { + nativeProps = diffProperties( + null, + emptyObject, + nativeProps, + this.viewConfig.validAttributes + ); + null != nativeProps && + ReactNativePrivateInterface.UIManager.updateView( this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) + this.viewConfig.uiViewClassName, + nativeProps ); - }; - _proto.measureLayout = function(relativeToNativeNode, onSuccess, onFail) { - if ("number" === typeof relativeToNativeNode) - var relativeNode = relativeToNativeNode; - else - relativeToNativeNode._nativeTag && - (relativeNode = relativeToNativeNode._nativeTag); - null != relativeNode && - ReactNativePrivateInterface.UIManager.measureLayout( - this._nativeTag, - relativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; - _proto.setNativeProps = function(nativeProps) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes - ); - null != nativeProps && - ReactNativePrivateInterface.UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps - ); - }; - return ReactNativeFiberHostComponent; - })(), - 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, - requestPaint = - void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, - syncQueue = null, - immediateQueueCallbackNode = null, - isFlushingSyncQueue = !1, - initialTimeMs = Scheduler_now(), - now = - 1e4 > initialTimeMs - ? Scheduler_now - : function() { - return Scheduler_now() - initialTimeMs; - }; -function getCurrentPriorityLevel() { - switch (Scheduler_getCurrentPriorityLevel()) { - case Scheduler_ImmediatePriority: - return 99; - case Scheduler_UserBlockingPriority: - return 98; - case Scheduler_NormalPriority: - return 97; - case Scheduler_LowPriority: - return 96; - case Scheduler_IdlePriority: - return 95; - default: - throw Error("Unknown priority level."); - } -} -function reactPriorityToSchedulerPriority(reactPriorityLevel) { - switch (reactPriorityLevel) { - case 99: - return Scheduler_ImmediatePriority; - case 98: - return Scheduler_UserBlockingPriority; - case 97: - return Scheduler_NormalPriority; - case 96: - return Scheduler_LowPriority; - case 95: - return Scheduler_IdlePriority; - default: - throw Error("Unknown priority level."); - } -} -function runWithPriority(reactPriorityLevel, fn) { - reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_runWithPriority(reactPriorityLevel, fn); -} -function scheduleCallback(reactPriorityLevel, callback, options) { - reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); -} -function flushSyncCallbackQueue() { - if (null !== immediateQueueCallbackNode) { - var node = immediateQueueCallbackNode; - immediateQueueCallbackNode = null; - Scheduler_cancelCallback(node); - } - flushSyncCallbackQueueImpl(); -} -function flushSyncCallbackQueueImpl() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var i = 0; - try { - var queue = syncQueue; - runWithPriority(99, function() { - for (; i < queue.length; i++) { - var callback = queue[i]; - do callback = callback(!0); - while (null !== callback); - } - }); - syncQueue = null; - } catch (error) { - throw (null !== syncQueue && (syncQueue = syncQueue.slice(i + 1)), - Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueue - ), - error); - } finally { - isFlushingSyncQueue = !1; - } - } -} -var nextTransitionLane = 512, - nextRetryLane = 8388608, - return_highestLanePriority = 8; -function getHighestPriorityLanes(lanes) { - switch (lanes & -lanes) { - case 1: - return (return_highestLanePriority = 15), 1; - case 2: - return (return_highestLanePriority = 14), 2; - case 4: - return (return_highestLanePriority = 13), 4; - case 8: - return (return_highestLanePriority = 12), 8; - case 16: - return (return_highestLanePriority = 11), 16; - case 32: - return (return_highestLanePriority = 10), 32; - case 64: - return (return_highestLanePriority = 9), 64; - case 128: - return (return_highestLanePriority = 8), 128; - case 256: - return (return_highestLanePriority = 7), 256; - case 512: - case 1024: - case 2048: - case 4096: - case 8192: - case 16384: - case 32768: - case 65536: - case 131072: - case 262144: - case 524288: - case 1048576: - case 2097152: - case 4194304: - return (return_highestLanePriority = 6), lanes & 8388096; - case 8388608: - case 16777216: - case 33554432: - case 67108864: - return (return_highestLanePriority = 5), lanes & 125829120; - case 134217728: - return (return_highestLanePriority = 4), 134217728; - case 268435456: - return (return_highestLanePriority = 3), 268435456; - case 536870912: - return (return_highestLanePriority = 2), 536870912; - case 1073741824: - return (return_highestLanePriority = 1), 1073741824; - default: - return (return_highestLanePriority = 8), 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; - 0 !== expiredLanes - ? ((nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 15)) - : ((expiredLanes = pendingLanes & 268435455), - 0 !== expiredLanes - ? ((pendingLanes = expiredLanes & ~suspendedLanes), - 0 !== pendingLanes - ? ((nextLanes = getHighestPriorityLanes(pendingLanes)), - (nextLanePriority = return_highestLanePriority)) - : ((pingedLanes &= expiredLanes), - 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)))) - : ((pendingLanes &= ~suspendedLanes), - 0 !== pendingLanes - ? ((nextLanes = getHighestPriorityLanes(pendingLanes)), - (nextLanePriority = return_highestLanePriority)) - : 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)))); - if (0 === nextLanes) return 0; - if ( - 0 !== wipLanes && - wipLanes !== nextLanes && - 0 === (wipLanes & suspendedLanes) - ) { - getHighestPriorityLanes(wipLanes); - suspendedLanes = return_highestLanePriority; - if ( - nextLanePriority <= suspendedLanes || - (8 === nextLanePriority && 6 === suspendedLanes) - ) - return wipLanes; - return_highestLanePriority = nextLanePriority; - } - wipLanes = root.entangledLanes; - if (0 !== wipLanes) - for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) - (nextLanePriority = 31 - clz32(wipLanes)), - (suspendedLanes = 1 << nextLanePriority), - (nextLanes |= root[nextLanePriority]), - (wipLanes &= ~suspendedLanes); - return nextLanes; -} -function getLanesToRetrySynchronouslyOnError(root) { - root = root.pendingLanes & -1073741825; - return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; -} -function findUpdateLane(lanePriority) { - switch (lanePriority) { - case 15: - return 1; - case 14: - return 2; - case 12: - return 8; - case 10: - return 32; - case 8: - return 128; - case 2: - return 536870912; - } - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); -} -function createLaneMap(initial) { - for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); - return laneMap; -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; - 536870912 !== updateLane && - ((root.suspendedLanes = 0), (root.pingedLanes = 0)); - root = root.eventTimes; - updateLane = 31 - clz32(updateLane); - root[updateLane] = eventTime; -} -function markRootFinished(root, remainingLanes) { - var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; - root.pendingLanes = remainingLanes; - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes; - root.mutableReadLanes &= remainingLanes; - root.entangledLanes &= remainingLanes; - remainingLanes = root.entanglements; - var eventTimes = root.eventTimes; - for (root = root.expirationTimes; 0 < noLongerPendingLanes; ) { - var index$8 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$8; - remainingLanes[index$8] = 0; - eventTimes[index$8] = -1; - root[index$8] = -1; - noLongerPendingLanes &= ~lane; - } -} -function markRootEntangled(root, entangledLanes) { - var rootEntangledLanes = (root.entangledLanes |= entangledLanes); - for (root = root.entanglements; rootEntangledLanes; ) { - var index$9 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$9; - (lane & entangledLanes) | (root[index$9] & entangledLanes) && - (root[index$9] |= entangledLanes); - rootEntangledLanes &= ~lane; - } -} -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_now$1 = Scheduler.unstable_now; -Scheduler_now$1(); + }; + return ReactNativeFiberHostComponent; +})(); function shim() { throw Error( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." @@ -2087,17 +1766,296 @@ function invalidateContextProvider(workInProgress, type, didChange) { push(didPerformWorkStackCursor, didChange); } var rendererID = null, - injectedHook = null; -function onCommitRoot(root) { - if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) - try { - injectedHook.onCommitFiberRoot( - rendererID, - root, - void 0, - 128 === (root.current.flags & 128) + 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." ); - } catch (err) {} + } +} +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$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, + fakeCallbackNode = {}, + requestPaint = + void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, + syncQueue = null, + immediateQueueCallbackNode = null, + isFlushingSyncQueue = !1, + initialTimeMs$1 = Scheduler_now$1(), + now = + 1e4 > initialTimeMs$1 + ? Scheduler_now$1 + : function() { + return Scheduler_now$1() - initialTimeMs$1; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return 99; + case Scheduler_UserBlockingPriority: + return 98; + case Scheduler_NormalPriority: + return 97; + case Scheduler_LowPriority: + return 96; + case Scheduler_IdlePriority: + return 95; + default: + throw Error("Unknown priority level."); + } +} +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case 99: + return Scheduler_ImmediatePriority; + case 98: + return Scheduler_UserBlockingPriority; + case 97: + return Scheduler_NormalPriority; + case 96: + return Scheduler_LowPriority; + case 95: + return Scheduler_IdlePriority; + default: + throw Error("Unknown priority level."); + } +} +function runWithPriority(reactPriorityLevel, fn) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(reactPriorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); +} +function flushSyncCallbackQueue() { + if (null !== immediateQueueCallbackNode) { + var node = immediateQueueCallbackNode; + immediateQueueCallbackNode = null; + Scheduler_cancelCallback(node); + } + flushSyncCallbackQueueImpl(); +} +function flushSyncCallbackQueueImpl() { + if (!isFlushingSyncQueue && null !== syncQueue) { + isFlushingSyncQueue = !0; + var i = 0; + try { + var queue = syncQueue; + runWithPriority(99, function() { + for (; i < queue.length; i++) { + var callback = queue[i]; + do callback = callback(!0); + while (null !== callback); + } + }); + syncQueue = null; + } catch (error) { + throw (null !== syncQueue && (syncQueue = syncQueue.slice(i + 1)), + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueue + ), + error); + } finally { + isFlushingSyncQueue = !1; + } + } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { @@ -2177,10 +2135,10 @@ var valueCursor = createCursor(null), function resetContextDependencies() { lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; } -function popProvider(context) { +function popProvider(providerFiber) { var currentValue = valueCursor.current; pop(valueCursor); - context._currentValue = currentValue; + providerFiber.type._context._currentValue = currentValue; } function scheduleWorkOnParentPath(parent, renderLanes) { for (; null !== parent; ) { @@ -2231,14 +2189,13 @@ function readContext(context, observedBits) { } return context._currentValue; } -var interleavedQueues = null, - hasForceUpdate = !1; +var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, firstBaseUpdate: null, lastBaseUpdate: null, - shared: { pending: null, interleaved: null, lanes: 0 }, + shared: { pending: null }, effects: null }; } @@ -2264,32 +2221,14 @@ function createUpdate(eventTime, lane) { }; } function enqueueUpdate(fiber, update) { - var updateQueue = fiber.updateQueue; - null !== updateQueue && - ((updateQueue = updateQueue.shared), - null !== workInProgressRoot && 0 !== (fiber.mode & 1) - ? ((fiber = updateQueue.interleaved), - null === fiber - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [updateQueue]) - : interleavedQueues.push(updateQueue)) - : ((update.next = fiber.next), (fiber.next = update)), - (updateQueue.interleaved = update)) - : ((fiber = updateQueue.pending), - null === fiber - ? (update.next = update) - : ((update.next = fiber.next), (fiber.next = update)), - (updateQueue.pending = update))); -} -function entangleTransitions(root, fiber, lane) { fiber = fiber.updateQueue; - if (null !== fiber && ((fiber = fiber.shared), 0 !== (lane & 8388096))) { - var queueLanes = fiber.lanes; - queueLanes &= root.pendingLanes; - lane |= queueLanes; - fiber.lanes = lane; - markRootEntangled(root, lane); + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; } } function enqueueCapturedUpdate(workInProgress, capturedUpdate) { @@ -2358,110 +2297,111 @@ function processUpdateQueue( : (lastBaseUpdate.next = firstPendingUpdate); lastBaseUpdate = lastPendingUpdate; var current = workInProgress$jscomp$0.alternate; - null !== current && - ((current = current.updateQueue), - (pendingQueue = current.lastBaseUpdate), - pendingQueue !== lastBaseUpdate && - (null === pendingQueue + if (null !== current) { + current = current.updateQueue; + var currentLastBaseUpdate = current.lastBaseUpdate; + currentLastBaseUpdate !== lastBaseUpdate && + (null === currentLastBaseUpdate ? (current.firstBaseUpdate = firstPendingUpdate) - : (pendingQueue.next = firstPendingUpdate), - (current.lastBaseUpdate = lastPendingUpdate))); + : (currentLastBaseUpdate.next = firstPendingUpdate), + (current.lastBaseUpdate = lastPendingUpdate)); + } } if (null !== firstBaseUpdate) { - var newState = queue.baseState; + currentLastBaseUpdate = queue.baseState; lastBaseUpdate = 0; current = firstPendingUpdate = lastPendingUpdate = null; - pendingQueue = firstBaseUpdate; do { - var updateLane = pendingQueue.lane, - updateEventTime = pendingQueue.eventTime; - if ((renderLanes & updateLane) === updateLane) { + pendingQueue = firstBaseUpdate.lane; + var updateEventTime = firstBaseUpdate.eventTime; + if ((renderLanes & pendingQueue) === pendingQueue) { null !== current && (current = current.next = { eventTime: updateEventTime, lane: 0, - tag: pendingQueue.tag, - payload: pendingQueue.payload, - callback: pendingQueue.callback, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null }); a: { var workInProgress = workInProgress$jscomp$0, - update = pendingQueue; - updateLane = props; + update = firstBaseUpdate; + pendingQueue = props; updateEventTime = instance; switch (update.tag) { case 1: workInProgress = update.payload; if ("function" === typeof workInProgress) { - newState = workInProgress.call( + currentLastBaseUpdate = workInProgress.call( updateEventTime, - newState, - updateLane + currentLastBaseUpdate, + pendingQueue ); break a; } - newState = workInProgress; + currentLastBaseUpdate = workInProgress; break a; case 3: - workInProgress.flags = (workInProgress.flags & -16385) | 128; + workInProgress.flags = (workInProgress.flags & -8193) | 64; case 0: workInProgress = update.payload; - updateLane = + pendingQueue = "function" === typeof workInProgress - ? workInProgress.call(updateEventTime, newState, updateLane) + ? workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ) : workInProgress; - if (null === updateLane || void 0 === updateLane) break a; - newState = Object.assign({}, newState, updateLane); + if (null === pendingQueue || void 0 === pendingQueue) break a; + currentLastBaseUpdate = Object.assign( + {}, + currentLastBaseUpdate, + pendingQueue + ); break a; case 2: hasForceUpdate = !0; } } - null !== pendingQueue.callback && - ((workInProgress$jscomp$0.flags |= 64), - (updateLane = queue.effects), - null === updateLane - ? (queue.effects = [pendingQueue]) - : updateLane.push(pendingQueue)); + null !== firstBaseUpdate.callback && + ((workInProgress$jscomp$0.flags |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [firstBaseUpdate]) + : pendingQueue.push(firstBaseUpdate)); } else (updateEventTime = { eventTime: updateEventTime, - lane: updateLane, - tag: pendingQueue.tag, - payload: pendingQueue.payload, - callback: pendingQueue.callback, + lane: pendingQueue, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null }), null === current ? ((firstPendingUpdate = current = updateEventTime), - (lastPendingUpdate = newState)) + (lastPendingUpdate = currentLastBaseUpdate)) : (current = current.next = updateEventTime), - (lastBaseUpdate |= updateLane); - pendingQueue = pendingQueue.next; - if (null === pendingQueue) + (lastBaseUpdate |= pendingQueue); + firstBaseUpdate = firstBaseUpdate.next; + if (null === firstBaseUpdate) if (((pendingQueue = queue.shared.pending), null === pendingQueue)) break; else - (updateLane = pendingQueue), - (pendingQueue = updateLane.next), - (updateLane.next = null), - (queue.lastBaseUpdate = updateLane), + (firstBaseUpdate = pendingQueue.next), + (pendingQueue.next = null), + (queue.lastBaseUpdate = pendingQueue), (queue.shared.pending = null); } while (1); - null === current && (lastPendingUpdate = newState); + null === current && (lastPendingUpdate = currentLastBaseUpdate); queue.baseState = lastPendingUpdate; queue.firstBaseUpdate = firstPendingUpdate; queue.lastBaseUpdate = current; - props = queue.shared.interleaved; - if (null !== props) { - queue = props; - do (lastBaseUpdate |= queue.lane), (queue = queue.next); - while (queue !== props); - } else null === firstBaseUpdate && (queue.shared.lanes = 0); workInProgressRootSkippedLanes |= lastBaseUpdate; workInProgress$jscomp$0.lanes = lastBaseUpdate; - workInProgress$jscomp$0.memoizedState = newState; + workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2517,8 +2457,7 @@ var classComponentUpdater = { update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - payload = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== payload && entangleTransitions(payload, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; @@ -2529,8 +2468,7 @@ var classComponentUpdater = { update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - payload = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== payload && entangleTransitions(payload, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternals; @@ -2540,8 +2478,7 @@ var classComponentUpdater = { update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - callback = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== callback && entangleTransitions(callback, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); } }; function checkShouldComponentUpdate( @@ -2689,22 +2626,24 @@ function coerceRef(returnFiber, current, element) { } function throwOnInvalidObjectType(returnFiber, newChild) { if ("textarea" !== returnFiber.type) - throw ((returnFiber = Object.prototype.toString.call(newChild)), - Error( + throw Error( "Objects are not valid as a React child (found: " + - ("[object Object]" === returnFiber + ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : returnFiber) + + : newChild) + "). If you meant to render a collection of children, use an array instead." - )); + ); } function ChildReconciler(shouldTrackSideEffects) { function deleteChild(returnFiber, childToDelete) { if (shouldTrackSideEffects) { - var deletions = returnFiber.deletions; - null === deletions - ? ((returnFiber.deletions = [childToDelete]), (returnFiber.flags |= 16)) - : deletions.push(childToDelete); + var last = returnFiber.lastEffect; + null !== last + ? ((last.nextEffect = childToDelete), + (returnFiber.lastEffect = childToDelete)) + : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); + childToDelete.nextEffect = null; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2736,16 +2675,16 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.flags |= 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.flags |= 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.flags |= 2); + (newFiber.flags = 2); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -2760,16 +2699,7 @@ function ChildReconciler(shouldTrackSideEffects) { return current; } function updateElement(returnFiber, current, element, lanes) { - var elementType = element.type; - if (elementType === REACT_FRAGMENT_TYPE) - return updateFragment( - returnFiber, - current, - element.props.children, - lanes, - element.key - ); - if (null !== current && current.elementType === elementType) + if (null !== current && current.elementType === element.type) return ( (lanes = useFiber(current, element.props)), (lanes.ref = coerceRef(returnFiber, current, element)), @@ -2883,7 +2813,15 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return newChild.key === key - ? updateElement(returnFiber, oldFiber, newChild, lanes) + ? newChild.type === REACT_FRAGMENT_TYPE + ? updateFragment( + returnFiber, + oldFiber, + newChild.props.children, + lanes, + key + ) + : updateElement(returnFiber, oldFiber, newChild, lanes) : null; case REACT_PORTAL_TYPE: return newChild.key === key @@ -2918,7 +2856,15 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updateElement(returnFiber, existingChildren, newChild, lanes) + newChild.type === REACT_FRAGMENT_TYPE + ? updateFragment( + returnFiber, + existingChildren, + newChild.props.children, + lanes, + newChild.key + ) + : updateElement(returnFiber, existingChildren, newChild, lanes) ); case REACT_PORTAL_TYPE: return ( @@ -3124,38 +3070,43 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) { - isObject = newChild.type; - if (isObject === REACT_FRAGMENT_TYPE) { - if (7 === isUnkeyedTopLevelFragment.tag) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props.children - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } - } else if (isUnkeyedTopLevelFragment.elementType === isObject) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); break; @@ -3333,7 +3284,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.flags & 128)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3485,11 +3436,10 @@ function updateReducer(reducer) { queue.pending = null; } if (null !== baseQueue) { - pendingQueue = baseQueue.next; + baseQueue = baseQueue.next; current = current.baseState; - var newBaseQueueFirst = (baseFirst = null), - newBaseQueueLast = null, - update = pendingQueue; + var newBaseQueueLast = (baseFirst = pendingQueue = null), + update = baseQueue; do { var updateLane = update.lane; if ((renderLanes & updateLane) === updateLane) @@ -3514,33 +3464,22 @@ function updateReducer(reducer) { next: null }; null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (baseFirst = current)) + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) : (newBaseQueueLast = newBaseQueueLast.next = clone); currentlyRenderingFiber$1.lanes |= updateLane; workInProgressRootSkippedLanes |= updateLane; } update = update.next; - } while (null !== update && update !== pendingQueue); + } while (null !== update && update !== baseQueue); null === newBaseQueueLast - ? (baseFirst = current) - : (newBaseQueueLast.next = newBaseQueueFirst); + ? (pendingQueue = current) + : (newBaseQueueLast.next = baseFirst); objectIs(current, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = current; - hook.baseState = baseFirst; + hook.baseState = pendingQueue; hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = current; } - reducer = queue.interleaved; - if (null !== reducer) { - baseQueue = reducer; - do - (pendingQueue = baseQueue.lane), - (currentlyRenderingFiber$1.lanes |= pendingQueue), - (workInProgressRootSkippedLanes |= pendingQueue), - (baseQueue = baseQueue.next); - while (baseQueue !== reducer); - } else null === baseQueue && (queue.lanes = 0); return [hook.memoizedState, queue.dispatch]; } function rerenderReducer(reducer) { @@ -3580,7 +3519,7 @@ function readFromUnsubcribedMutableSource(root, source, getSnapshot) { if (root) return getSnapshot(source._source); workInProgressSources.push(source); throw Error( - "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + "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) { @@ -3610,13 +3549,25 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { refs.getSnapshot = getSnapshot; refs.setSnapshot = setSnapshot; var maybeNewVersion = getVersion(source._source); - objectIs(version, maybeNewVersion) || - ((maybeNewVersion = getSnapshot(source._source)), + if (!objectIs(version, maybeNewVersion)) { + maybeNewVersion = getSnapshot(source._source); objectIs(snapshot, maybeNewVersion) || (setSnapshot(maybeNewVersion), (maybeNewVersion = requestUpdateLane(fiber)), - (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)), - markRootEntangled(root, root.mutableReadLanes)); + (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] ); @@ -3643,8 +3594,6 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { objectIs(memoizedState, subscribe)) || ((hook = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot @@ -3670,8 +3619,6 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3720,7 +3667,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - hook.memoizedState = pushEffect(hookFlags, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } @@ -3728,10 +3675,10 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(132096, 4, create, deps); + return mountEffectImpl(516, 4, create, deps); } function updateEffect(create, deps) { - return updateEffectImpl(1024, 4, create, deps); + return updateEffectImpl(516, 4, create, deps); } function updateLayoutEffect(create, deps) { return updateEffectImpl(4, 2, create, deps); @@ -3816,55 +3763,33 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }, - alternate = fiber.alternate; + pending = queue.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; + pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || - (null !== alternate && alternate === currentlyRenderingFiber$1) + (null !== pending && pending === currentlyRenderingFiber$1) ) - (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0), - (lane = queue.pending), - null === lane - ? (update.next = update) - : ((update.next = lane.next), (lane.next = update)), - (queue.pending = update); + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; else { - if (null !== workInProgressRoot && 0 !== (fiber.mode & 1)) { - var interleaved = queue.interleaved; - null === interleaved - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [queue]) - : interleavedQueues.push(queue)) - : ((update.next = interleaved.next), (interleaved.next = update)); - queue.interleaved = update; - } else - (interleaved = queue.pending), - null === interleaved - ? (update.next = update) - : ((update.next = interleaved.next), (interleaved.next = update)), - (queue.pending = update); if ( 0 === fiber.lanes && - (null === alternate || 0 === alternate.lanes) && - ((alternate = queue.lastRenderedReducer), null !== alternate) + (null === pending || 0 === pending.lanes) && + ((pending = queue.lastRenderedReducer), null !== pending) ) try { var currentState = queue.lastRenderedState, - eagerState = alternate(currentState, action); - update.eagerReducer = alternate; + eagerState = pending(currentState, action); + update.eagerReducer = pending; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - update = scheduleUpdateOnFiber(fiber, lane, eventTime); - 0 !== (lane & 8388096) && - null !== update && - ((fiber = queue.lanes), - (fiber &= update.pendingLanes), - (lane |= fiber), - (queue.lanes = lane), - markRootEntangled(update, lane)); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } var ContextOnlyDispatcher = { @@ -3921,8 +3846,6 @@ var ContextOnlyDispatcher = { hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -4098,7 +4021,7 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4174,15 +4097,14 @@ function updateSimpleMemoComponent( null !== current && shallowEqual(current.memoizedProps, nextProps) && current.ref === workInProgress.ref - ) { - didReceiveUpdate = !1; - if (0 === (renderLanes & updateLanes)) + ) + if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); + else return ( (workInProgress.lanes = current.lanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - 0 !== (current.flags & 65536) && (didReceiveUpdate = !0); - } return updateFunctionComponent( current, workInProgress, @@ -4199,39 +4121,30 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { "hidden" === nextProps.mode || "unstable-defer-without-hiding" === nextProps.mode ) - if (0 === (workInProgress.mode & 2)) - (workInProgress.memoizedState = { baseLanes: 0, cachePool: null }), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= renderLanes); - else { - if (0 === (renderLanes & 1073741824)) - return ( - (current = - null !== prevState - ? prevState.baseLanes | renderLanes - : renderLanes), - (workInProgress.lanes = workInProgress.childLanes = 1073741824), - (workInProgress.memoizedState = { - baseLanes: current, - cachePool: null - }), - (workInProgress.updateQueue = null), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= current), - null + 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 ); - workInProgress.memoizedState = { baseLanes: 0, cachePool: null }; - nextProps = null !== prevState ? prevState.baseLanes : renderLanes; - push(subtreeRenderLanesCursor, subtreeRenderLanes); - subtreeRenderLanes |= nextProps; - } + 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), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= nextProps); + pushRenderLanes(workInProgress, nextProps); reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -4241,7 +4154,7 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.flags |= 256; + workInProgress.flags |= 128; } function updateFunctionComponent( current, @@ -4266,7 +4179,7 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4441,7 +4354,7 @@ function updateClassComponent( "function" === typeof instance.componentDidUpdate && (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.flags |= 512)) + (workInProgress.flags |= 256)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || @@ -4449,7 +4362,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -4463,7 +4376,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 256), (nextProps = !1)); } return finishClassComponent( @@ -4484,7 +4397,7 @@ function finishClassComponent( renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.flags & 128); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), @@ -4528,21 +4441,18 @@ function pushHostRootContext(workInProgress) { pushHostContainer(workInProgress, root.containerInfo); } var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; -function mountSuspenseOffscreenState(renderLanes) { - return { baseLanes: renderLanes, cachePool: null }; -} function updateSuspenseComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.flags & 128)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = null !== current && null === current.memoizedState ? !1 : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.flags &= -129)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || @@ -4559,9 +4469,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext, renderLanes )), - (workInProgress.child.memoizedState = mountSuspenseOffscreenState( - renderLanes - )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), current ); @@ -4573,11 +4481,9 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext, renderLanes )), - (workInProgress.child.memoizedState = mountSuspenseOffscreenState( - renderLanes - )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), - (workInProgress.lanes = 8388608), + (workInProgress.lanes = 33554432), current ); renderLanes = createFiberFromOffscreen( @@ -4603,11 +4509,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (suspenseContext = current.child.memoizedState), (showFallback.memoizedState = null === suspenseContext - ? mountSuspenseOffscreenState(renderLanes) - : { - baseLanes: suspenseContext.baseLanes | renderLanes, - cachePool: null - }), + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps @@ -4634,11 +4537,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (suspenseContext = current.child.memoizedState), (showFallback.memoizedState = null === suspenseContext - ? mountSuspenseOffscreenState(renderLanes) - : { - baseLanes: suspenseContext.baseLanes | renderLanes, - cachePool: null - }), + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps @@ -4661,7 +4561,7 @@ function mountSuspenseFallbackChildren( var mode = workInProgress.mode, progressedPrimaryFragment = workInProgress.child; primaryChildren = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 1) && null !== progressedPrimaryFragment + 0 === (mode & 2) && null !== progressedPrimaryFragment ? ((progressedPrimaryFragment.childLanes = 0), (progressedPrimaryFragment.pendingProps = primaryChildren)) : (progressedPrimaryFragment = createFiberFromOffscreen( @@ -4694,14 +4594,13 @@ function updateSuspensePrimaryChildren( mode: "visible", children: primaryChildren }); - 0 === (workInProgress.mode & 1) && (primaryChildren.lanes = renderLanes); + 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); primaryChildren.return = workInProgress; primaryChildren.sibling = null; null !== current && - ((renderLanes = workInProgress.deletions), - null === renderLanes - ? ((workInProgress.deletions = [current]), (workInProgress.flags |= 16)) - : renderLanes.push(current)); + ((current.nextEffect = null), + (current.flags = 8), + (workInProgress.firstEffect = workInProgress.lastEffect = current)); return (workInProgress.child = primaryChildren); } function updateSuspenseFallbackChildren( @@ -4711,22 +4610,26 @@ function updateSuspenseFallbackChildren( fallbackChildren, renderLanes ) { - var mode = workInProgress.mode; - current = current.child; - var currentFallbackChildFragment = current.sibling, - primaryChildProps = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 1) && workInProgress.child !== current + 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.deletions = null)) - : ((primaryChildren = createWorkInProgress(current, primaryChildProps)), - (primaryChildren.subtreeFlags = current.subtreeFlags & 131072)); - null !== currentFallbackChildFragment - ? (fallbackChildren = createWorkInProgress( - currentFallbackChildFragment, - fallbackChildren - )) + (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, @@ -4751,7 +4654,8 @@ function initSuspenseListRenderState( isBackwards, tail, lastContentRow, - tailMode + tailMode, + lastEffectBeforeRendering ) { var renderState = workInProgress.memoizedState; null === renderState @@ -4761,14 +4665,16 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailMode: tailMode + tailMode: tailMode, + lastEffect: lastEffectBeforeRendering }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailMode = tailMode)); + (renderState.tailMode = tailMode), + (renderState.lastEffect = lastEffectBeforeRendering)); } function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, @@ -4777,9 +4683,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 128); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.flags & 128)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && @@ -4802,7 +4708,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { nextProps &= 1; } push(suspenseStackCursor, nextProps); - if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null; + if (0 === (workInProgress.mode & 2)) workInProgress.memoizedState = null; else switch (revealOrder) { case "forwards": @@ -4823,7 +4729,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { !1, revealOrder, renderLanes, - tailMode + tailMode, + workInProgress.lastEffect ); break; case "backwards": @@ -4845,11 +4752,19 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { !0, renderLanes, null, - tailMode + tailMode, + workInProgress.lastEffect ); break; case "together": - initSuspenseListRenderState(workInProgress, !1, null, null, void 0); + initSuspenseListRenderState( + workInProgress, + !1, + null, + null, + void 0, + workInProgress.lastEffect + ); break; default: workInProgress.memoizedState = null; @@ -4859,23 +4774,25 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { null !== current && (workInProgress.dependencies = current.dependencies); workInProgressRootSkippedLanes |= workInProgress.lanes; - if (0 === (renderLanes & workInProgress.childLanes)) return null; - 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; + 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, @@ -4922,40 +4839,16 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$62 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$62 = lastTailNode), + for (var lastTailNode$64 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$62 + null === lastTailNode$64 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$62.sibling = null); + : (lastTailNode$64.sibling = null); } } -function bubbleProperties(completedWork) { - var didBailout = - null !== completedWork.alternate && - completedWork.alternate.child === completedWork.child, - newChildLanes = 0, - subtreeFlags = 0; - if (didBailout) - for (var child$63 = completedWork.child; null !== child$63; ) - (newChildLanes |= child$63.lanes | child$63.childLanes), - (subtreeFlags |= child$63.subtreeFlags & 131072), - (subtreeFlags |= child$63.flags & 131072), - (child$63.return = completedWork), - (child$63 = child$63.sibling); - else - for (child$63 = completedWork.child; null !== child$63; ) - (newChildLanes |= child$63.lanes | child$63.childLanes), - (subtreeFlags |= child$63.subtreeFlags), - (subtreeFlags |= child$63.flags), - (child$63.return = completedWork), - (child$63 = child$63.sibling); - completedWork.subtreeFlags |= subtreeFlags; - completedWork.childLanes = newChildLanes; - return didBailout; -} function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { @@ -4969,80 +4862,76 @@ function completeWork(current, workInProgress, renderLanes) { case 12: case 9: case 14: - return bubbleProperties(workInProgress), null; + return null; case 1: - return ( - isContextProvider(workInProgress.type) && popContext(), - bubbleProperties(workInProgress), - null - ); + return isContextProvider(workInProgress.type) && popContext(), null; case 3: return ( - (newProps = workInProgress.stateNode), popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), resetWorkInProgressVersions(), + (newProps = workInProgress.stateNode), newProps.pendingContext && ((newProps.context = newProps.pendingContext), (newProps.pendingContext = null)), (null !== current && null !== current.child) || newProps.hydrate || - (workInProgress.flags |= 512), - updateHostContainer(current, workInProgress), - bubbleProperties(workInProgress), + (workInProgress.flags |= 256), + updateHostContainer(workInProgress), null ); case 5: popHostContext(workInProgress); - renderLanes = requiredContext(rootInstanceStackCursor.current); - var type = workInProgress.type; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ); + renderLanes = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - type, + renderLanes, newProps, - renderLanes + rootContainerInstance ), - current.ref !== workInProgress.ref && (workInProgress.flags |= 256); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); - bubbleProperties(workInProgress); return null; } requiredContext(contextStackCursor$1.current); current = allocateTag(); - type = getViewConfigForType(type); + renderLanes = getViewConfigForType(renderLanes); var updatePayload = diffProperties( null, emptyObject, newProps, - type.validAttributes + renderLanes.validAttributes ); ReactNativePrivateInterface.UIManager.createView( current, - type.uiViewClassName, - renderLanes, + renderLanes.uiViewClassName, + rootContainerInstance, updatePayload ); - renderLanes = new ReactNativeFiberHostComponent( + rootContainerInstance = new ReactNativeFiberHostComponent( current, - type, + renderLanes, workInProgress ); instanceCache.set(current, workInProgress); instanceProps.set(current, newProps); - appendAllChildren(renderLanes, workInProgress, !1, !1); - workInProgress.stateNode = renderLanes; - finalizeInitialChildren(renderLanes) && (workInProgress.flags |= 4); - null !== workInProgress.ref && (workInProgress.flags |= 256); + appendAllChildren(rootContainerInstance, workInProgress, !1, !1); + workInProgress.stateNode = rootContainerInstance; + finalizeInitialChildren(rootContainerInstance) && + (workInProgress.flags |= 4); + null !== workInProgress.ref && (workInProgress.flags |= 128); } - bubbleProperties(workInProgress); return null; case 6: if (current && null != workInProgress.stateNode) @@ -5062,27 +4951,27 @@ function completeWork(current, workInProgress, renderLanes) { throw Error( "Text strings must be rendered within a component." ); - renderLanes = allocateTag(); + rootContainerInstance = allocateTag(); ReactNativePrivateInterface.UIManager.createView( - renderLanes, + rootContainerInstance, "RCTRawText", current, { text: newProps } ); - instanceCache.set(renderLanes, workInProgress); - workInProgress.stateNode = renderLanes; + instanceCache.set(rootContainerInstance, workInProgress); + workInProgress.stateNode = rootContainerInstance; } - bubbleProperties(workInProgress); return null; case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.flags & 128)) + if (0 !== (workInProgress.flags & 64)) return (workInProgress.lanes = renderLanes), workInProgress; newProps = null !== newProps; - renderLanes = !1; - null !== current && (renderLanes = null !== current.memoizedState); - if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1)) + rootContainerInstance = !1; + null !== current && + (rootContainerInstance = null !== current.memoizedState); + if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || @@ -5097,92 +4986,82 @@ function completeWork(current, workInProgress, renderLanes) { ) workInProgressRootExitStatus = 4; null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootUpdatedLanes & 268435455)) || + (0 === (workInProgressRootSkippedLanes & 134217727) && + 0 === (workInProgressRootUpdatedLanes & 134217727)) || markRootSuspended$1( workInProgressRoot, workInProgressRootRenderLanes ); } - if (newProps || renderLanes) workInProgress.flags |= 4; - bubbleProperties(workInProgress); + if (newProps || rootContainerInstance) workInProgress.flags |= 4; return null; case 4: - return ( - popHostContainer(), - updateHostContainer(current, workInProgress), - bubbleProperties(workInProgress), - null - ); + return popHostContainer(), updateHostContainer(workInProgress), null; case 10: - return ( - popProvider(workInProgress.type._context), - bubbleProperties(workInProgress), - null - ); + return popProvider(workInProgress), null; case 17: - return ( - isContextProvider(workInProgress.type) && popContext(), - bubbleProperties(workInProgress), - null - ); + return isContextProvider(workInProgress.type) && popContext(), null; case 19: pop(suspenseStackCursor); - type = workInProgress.memoizedState; - if (null === type) return bubbleProperties(workInProgress), null; - newProps = 0 !== (workInProgress.flags & 128); - updatePayload = type.rendering; + newProps = workInProgress.memoizedState; + if (null === newProps) return null; + rootContainerInstance = 0 !== (workInProgress.flags & 64); + updatePayload = newProps.rendering; if (null === updatePayload) - if (newProps) cutOffTailIfNeeded(type, !1); + if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || - (null !== current && 0 !== (current.flags & 128)) + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.flags |= 128; - cutOffTailIfNeeded(type, !1); + workInProgress.flags |= 64; + cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), (workInProgress.flags |= 4)); - workInProgress.subtreeFlags = 0; + null === newProps.lastEffect && + (workInProgress.firstEffect = null); + workInProgress.lastEffect = newProps.lastEffect; current = renderLanes; for (newProps = workInProgress.child; null !== newProps; ) - (renderLanes = newProps), - (type = current), - (renderLanes.flags &= 131074), - (updatePayload = renderLanes.alternate), + (rootContainerInstance = newProps), + (renderLanes = current), + (rootContainerInstance.flags &= 2), + (rootContainerInstance.nextEffect = null), + (rootContainerInstance.firstEffect = null), + (rootContainerInstance.lastEffect = null), + (updatePayload = rootContainerInstance.alternate), null === updatePayload - ? ((renderLanes.childLanes = 0), - (renderLanes.lanes = type), - (renderLanes.child = null), - (renderLanes.subtreeFlags = 0), - (renderLanes.memoizedProps = null), - (renderLanes.memoizedState = null), - (renderLanes.updateQueue = null), - (renderLanes.dependencies = null), - (renderLanes.stateNode = null)) - : ((renderLanes.childLanes = updatePayload.childLanes), - (renderLanes.lanes = updatePayload.lanes), - (renderLanes.child = updatePayload.child), - (renderLanes.subtreeFlags = updatePayload.subtreeFlags), - (renderLanes.deletions = null), - (renderLanes.memoizedProps = + ? ((rootContainerInstance.childLanes = 0), + (rootContainerInstance.lanes = renderLanes), + (rootContainerInstance.child = null), + (rootContainerInstance.memoizedProps = null), + (rootContainerInstance.memoizedState = null), + (rootContainerInstance.updateQueue = null), + (rootContainerInstance.dependencies = null), + (rootContainerInstance.stateNode = null)) + : ((rootContainerInstance.childLanes = + updatePayload.childLanes), + (rootContainerInstance.lanes = updatePayload.lanes), + (rootContainerInstance.child = updatePayload.child), + (rootContainerInstance.memoizedProps = updatePayload.memoizedProps), - (renderLanes.memoizedState = + (rootContainerInstance.memoizedState = updatePayload.memoizedState), - (renderLanes.updateQueue = updatePayload.updateQueue), - (renderLanes.type = updatePayload.type), - (type = updatePayload.dependencies), - (renderLanes.dependencies = - null === type + (rootContainerInstance.updateQueue = + updatePayload.updateQueue), + (rootContainerInstance.type = updatePayload.type), + (renderLanes = updatePayload.dependencies), + (rootContainerInstance.dependencies = + null === renderLanes ? null : { - lanes: type.lanes, - firstContext: type.firstContext + lanes: renderLanes.lanes, + firstContext: renderLanes.firstContext })), (newProps = newProps.sibling); push( @@ -5193,74 +5072,78 @@ function completeWork(current, workInProgress, renderLanes) { } current = current.sibling; } - null !== type.tail && + null !== newProps.tail && now() > workInProgressRootRenderTargetTime && - ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), - (workInProgress.lanes = 8388608)); + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432)); } else { - if (!newProps) + if (!rootContainerInstance) if ( ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.flags |= 128), - (newProps = !0), + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), (workInProgress.flags |= 4)), - cutOffTailIfNeeded(type, !0), - null === type.tail && - "hidden" === type.tailMode && + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "hidden" === newProps.tailMode && !updatePayload.alternate) ) - return bubbleProperties(workInProgress), null; + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); } else - 2 * now() - type.renderingStartTime > + 2 * now() - newProps.renderingStartTime > workInProgressRootRenderTargetTime && 1073741824 !== renderLanes && - ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), - (workInProgress.lanes = 8388608)); - type.isBackwards + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432)); + newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) - : ((current = type.last), + : ((current = newProps.last), null !== current ? (current.sibling = updatePayload) : (workInProgress.child = updatePayload), - (type.last = updatePayload)); + (newProps.last = updatePayload)); } - if (null !== type.tail) - return ( - (workInProgress = type.tail), - (type.rendering = workInProgress), - (type.tail = workInProgress.sibling), - (type.renderingStartTime = now()), - (workInProgress.sibling = null), - (current = suspenseStackCursor.current), - push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1), - workInProgress - ); - bubbleProperties(workInProgress); - return null; + return null !== newProps.tail + ? ((current = newProps.tail), + (newProps.rendering = current), + (newProps.tail = current.sibling), + (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), + (current.sibling = null), + (workInProgress = suspenseStackCursor.current), + push( + suspenseStackCursor, + rootContainerInstance + ? (workInProgress & 1) | 2 + : workInProgress & 1 + ), + current) + : null; case 22: case 23: return ( popRenderLanes(), - (renderLanes = null !== workInProgress.memoizedState), null !== current && - (null !== current.memoizedState) !== renderLanes && + (null !== current.memoizedState) !== + (null !== workInProgress.memoizedState) && "unstable-defer-without-hiding" !== newProps.mode && (workInProgress.flags |= 4), - (renderLanes && - 0 === (subtreeRenderLanes & 1073741824) && - 0 !== (workInProgress.mode & 2)) || - bubbleProperties(workInProgress), null ); } @@ -5275,8 +5158,8 @@ function unwindWork(workInProgress) { case 1: isContextProvider(workInProgress.type) && popContext(); var flags = workInProgress.flags; - return flags & 16384 - ? ((workInProgress.flags = (flags & -16385) | 128), workInProgress) + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null; case 3: popHostContainer(); @@ -5284,11 +5167,11 @@ function unwindWork(workInProgress) { pop(contextStackCursor); resetWorkInProgressVersions(); flags = workInProgress.flags; - if (0 !== (flags & 128)) + 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.flags = (flags & -16385) | 128; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; @@ -5296,8 +5179,8 @@ function unwindWork(workInProgress) { return ( pop(suspenseStackCursor), (flags = workInProgress.flags), - flags & 16384 - ? ((workInProgress.flags = (flags & -16385) | 128), workInProgress) + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), workInProgress) : null ); case 19: @@ -5305,12 +5188,10 @@ function unwindWork(workInProgress) { case 4: return popHostContainer(), null; case 10: - return popProvider(workInProgress.type._context), null; + return popProvider(workInProgress), null; case 22: case 23: return popRenderLanes(), null; - case 24: - return null; default: return null; } @@ -5383,150 +5264,140 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { }); return lane; } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set, - nextEffect = null; -function safelyDetachRef(current, nearestMountedAncestor) { +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) if ("function" === typeof ref) try { ref(null); } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + captureCommitPhaseError(current, refError); } else ref.current = null; } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; -function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) - (firstChild.return = root), (nextEffect = firstChild); - else - for (; null !== nextEffect; ) { - root = nextEffect; - try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) - switch (root.tag) { - case 0: - case 11: - case 15: - break; - case 1: - if (null !== current) { - var prevProps = current.memoizedProps, - prevState = current.memoizedState, - instance = root.stateNode, - snapshot = instance.getSnapshotBeforeUpdate( - root.elementType === root.type - ? prevProps - : resolveDefaultProps(root.type, prevProps), - prevState - ); - instance.__reactInternalSnapshotBeforeUpdate = snapshot; - } - break; - case 3: - break; - case 5: - case 6: - case 4: - case 17: - break; - default: - 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." - ); - } - } catch (error) { - captureCommitPhaseError(root, root.return, error); - } - firstChild = root.sibling; - if (null !== firstChild) { - firstChild.return = root.return; - nextEffect = firstChild; - break; - } - nextEffect = root.return; +function commitBeforeMutationLifeCycles(current, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + return; + case 1: + if (finishedWork.flags & 256 && null !== current) { + var prevProps = current.memoizedProps, + prevState = current.memoizedState; + current = finishedWork.stateNode; + finishedWork = current.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); + current.__reactInternalSnapshotBeforeUpdate = finishedWork; } + return; + case 3: + return; + case 5: + case 6: + case 4: + case 17: + return; } - current = shouldFireAfterActiveInstanceBlur; - shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; - return current; + 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 commitHookEffectListUnmount( - flags, - finishedWork, - nearestMountedAncestor$jscomp$0 -) { - var updateQueue = finishedWork.updateQueue; - updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; - if (null !== updateQueue) { - var effect = (updateQueue = updateQueue.next); - do { - if ((effect.tag & flags) === flags) { - var destroy = effect.destroy; - effect.destroy = void 0; - if (void 0 !== destroy) { - var current = finishedWork, - nearestMountedAncestor = nearestMountedAncestor$jscomp$0; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(current, nearestMountedAncestor, error); +function commitLifeCycles(finishedRoot, current, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + 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); } - effect = effect.next; - } while (effect !== updateQueue); - } -} -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$80 = effect.create; - effect.destroy = create$80(); + 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); } - effect = effect.next; - } while (effect !== finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + 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); + return; + case 3: + current = finishedWork.updateQueue; + if (null !== current) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue(finishedWork, current, finishedRoot); + } + return; + case 5: + return; + case 6: + return; + case 4: + return; + case 12: + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + case 22: + case 23: + 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 hideOrUnhideAllChildren(finishedWork, isHidden) { for (var node = finishedWork; ; ) { @@ -5586,7 +5457,7 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { node = node.sibling; } } -function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) { +function commitUnmount(finishedRoot, current) { if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount) try { injectedHook.onCommitFiberUnmount(rendererID, current); @@ -5603,24 +5474,26 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) { ) { var effect = (finishedRoot = finishedRoot.next); do { - var _effect = effect, - destroy = _effect.destroy; - _effect = _effect.tag; - if (void 0 !== destroy && 0 !== (_effect & 2)) { - _effect = current; - var nearestMountedAncestor = nearestMountedAncestor$jscomp$0; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(_effect, nearestMountedAncestor, error); + 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 !== finishedRoot); } break; case 1: - safelyDetachRef(current, nearestMountedAncestor$jscomp$0); + safelyDetachRef(current); finishedRoot = current.stateNode; if ("function" === typeof finishedRoot.componentWillUnmount) try { @@ -5628,34 +5501,26 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) { (finishedRoot.state = current.memoizedState), finishedRoot.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError( - current, - nearestMountedAncestor$jscomp$0, - unmountError - ); + captureCommitPhaseError(current, unmountError); } break; case 5: - safelyDetachRef(current, nearestMountedAncestor$jscomp$0); + safelyDetachRef(current); break; case 4: - unmountHostComponents( - finishedRoot, - current, - nearestMountedAncestor$jscomp$0 - ); + unmountHostComponents(finishedRoot, current); } } -function detachFiberAfterEffects(fiber) { +function detachFiberMutation(fiber) { fiber.alternate = null; fiber.child = null; - fiber.deletions = null; fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; + fiber.return = null; fiber.updateQueue = null; } function isHostParent(fiber) { @@ -5690,7 +5555,7 @@ function commitPlacement(finishedWork) { "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } - parentFiber.flags & 32 && (parentFiber.flags &= -33); + parentFiber.flags & 16 && (parentFiber.flags &= -17); a: b: for (parentFiber = finishedWork; ; ) { for (; null === parentFiber.sibling; ) { if (null === parentFiber.return || isHostParent(parentFiber.return)) { @@ -5806,11 +5671,7 @@ function insertOrAppendPlacementNode(node, before, parent) { ) insertOrAppendPlacementNode(node, before, parent), (node = node.sibling); } -function unmountHostComponents( - finishedRoot$jscomp$0, - current, - nearestMountedAncestor$jscomp$0 -) { +function unmountHostComponents(finishedRoot$jscomp$0, current) { for ( var node = current, currentParentIsValid = !1, @@ -5848,13 +5709,12 @@ function unmountHostComponents( a: for ( var finishedRoot = finishedRoot$jscomp$0, root = node, - nearestMountedAncestor = nearestMountedAncestor$jscomp$0, node$jscomp$0 = root; ; ) if ( - (commitUnmount(finishedRoot, node$jscomp$0, nearestMountedAncestor), + (commitUnmount(finishedRoot, node$jscomp$0), null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), @@ -5881,18 +5741,18 @@ function unmountHostComponents( [0] )) : ((finishedRoot = currentParent), - (nearestMountedAncestor = node.stateNode), - recursivelyUncacheFiberNode(nearestMountedAncestor), + (node$jscomp$0 = node.stateNode), + recursivelyUncacheFiberNode(node$jscomp$0), (root = finishedRoot._children), - (nearestMountedAncestor = root.indexOf(nearestMountedAncestor)), - root.splice(nearestMountedAncestor, 1), + (node$jscomp$0 = root.indexOf(node$jscomp$0)), + root.splice(node$jscomp$0, 1), ReactNativePrivateInterface.UIManager.manageChildren( finishedRoot._nativeTag, [], [], [], [], - [nearestMountedAncestor] + [node$jscomp$0] )); } else if (4 === node.tag) { if (null !== node.child) { @@ -5903,12 +5763,7 @@ function unmountHostComponents( continue; } } else if ( - (commitUnmount( - finishedRoot$jscomp$0, - node, - nearestMountedAncestor$jscomp$0 - ), - null !== node.child) + (commitUnmount(finishedRoot$jscomp$0, node), null !== node.child) ) { node.child.return = node; node = node.child; @@ -5930,31 +5785,42 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - commitHookEffectListUnmount(3, finishedWork, finishedWork.return); + 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; @@ -6010,188 +5876,13 @@ function attachSuspenseRetryListeners(finishedWork) { }); } } -function commitMutationEffects(root, renderPriorityLevel, firstChild) { - for (nextEffect = firstChild; null !== nextEffect; ) { - renderPriorityLevel = nextEffect; - firstChild = renderPriorityLevel.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) { - var childToDelete = firstChild[i]; - try { - unmountHostComponents(root, childToDelete, renderPriorityLevel); - var alternate = childToDelete.alternate; - childToDelete.return = null; - null !== alternate && (alternate.return = null); - } catch (error) { - captureCommitPhaseError(childToDelete, renderPriorityLevel, error); - } - } - firstChild = renderPriorityLevel.child; - if (0 !== (renderPriorityLevel.subtreeFlags & 6454) && null !== firstChild) - (firstChild.return = renderPriorityLevel), (nextEffect = firstChild); - else - for (; null !== nextEffect; ) { - renderPriorityLevel = nextEffect; - try { - var flags = renderPriorityLevel.flags; - if (flags & 256) { - var current = renderPriorityLevel.alternate; - if (null !== current) { - var currentRef = current.ref; - null !== currentRef && - ("function" === typeof currentRef - ? currentRef(null) - : (currentRef.current = null)); - } - } - switch (flags & 2054) { - case 2: - commitPlacement(renderPriorityLevel); - renderPriorityLevel.flags &= -3; - break; - case 6: - commitPlacement(renderPriorityLevel); - renderPriorityLevel.flags &= -3; - commitWork(renderPriorityLevel.alternate, renderPriorityLevel); - break; - case 2048: - renderPriorityLevel.flags &= -2049; - break; - case 2052: - renderPriorityLevel.flags &= -2049; - commitWork(renderPriorityLevel.alternate, renderPriorityLevel); - break; - case 4: - commitWork(renderPriorityLevel.alternate, renderPriorityLevel); - } - } catch (error) { - captureCommitPhaseError( - renderPriorityLevel, - renderPriorityLevel.return, - error - ); - } - firstChild = renderPriorityLevel.sibling; - if (null !== firstChild) { - firstChild.return = renderPriorityLevel.return; - nextEffect = firstChild; - break; - } - nextEffect = renderPriorityLevel.return; - } - } -} -function commitLayoutEffects(finishedWork) { - for (nextEffect = finishedWork; null !== nextEffect; ) { - var fiber = nextEffect, - firstChild = fiber.child; - if (0 !== (fiber.subtreeFlags & 324) && null !== firstChild) - (firstChild.return = fiber), (nextEffect = firstChild); - else - for (fiber = finishedWork; null !== nextEffect; ) { - firstChild = nextEffect; - if (0 !== (firstChild.flags & 324)) { - var current = firstChild.alternate; - try { - if (0 !== (firstChild.flags & 68)) - switch (firstChild.tag) { - case 0: - case 11: - case 15: - commitHookEffectListMount(3, firstChild); - break; - case 1: - var instance = firstChild.stateNode; - if (firstChild.flags & 4) - if (null === current) instance.componentDidMount(); - else { - var prevProps = - firstChild.elementType === firstChild.type - ? current.memoizedProps - : resolveDefaultProps( - firstChild.type, - current.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = firstChild.updateQueue; - null !== updateQueue && - commitUpdateQueue(firstChild, updateQueue, instance); - break; - case 3: - var updateQueue$81 = firstChild.updateQueue; - if (null !== updateQueue$81) { - current = null; - if (null !== firstChild.child) - switch (firstChild.child.tag) { - case 5: - current = firstChild.child.stateNode; - break; - case 1: - current = firstChild.child.stateNode; - } - commitUpdateQueue(firstChild, updateQueue$81, current); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 19: - case 17: - case 21: - case 22: - case 23: - break; - default: - 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 (firstChild.flags & 256) { - current = void 0; - var ref = firstChild.ref; - if (null !== ref) { - var instance$jscomp$0 = firstChild.stateNode; - switch (firstChild.tag) { - case 5: - current = instance$jscomp$0; - break; - default: - current = instance$jscomp$0; - } - "function" === typeof ref - ? ref(current) - : (ref.current = current); - } - } - } catch (error) { - captureCommitPhaseError(firstChild, firstChild.return, error); - } - } - if (firstChild === fiber) { - nextEffect = null; - break; - } - current = firstChild.sibling; - if (null !== current) { - current.return = firstChild.return; - nextEffect = current; - break; - } - nextEffect = firstChild.return; - } - } +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$2 = ReactSharedInternals.ReactCurrentDispatcher, @@ -6204,22 +5895,30 @@ var ceil = Math.ceil, subtreeRenderLanesCursor = createCursor(0), workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, + workInProgressRootIncludedLanes = 0, workInProgressRootSkippedLanes = 0, workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, + mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, workInProgressRootRenderTargetTime = Infinity, + nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, legacyErrorBoundariesThatAlreadyFailed = null, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, + pendingPassiveHookEffectsMount = [], + pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, currentEventTime = -1, - currentEventTransitionLane = 0; + currentEventWipLanes = 0, + currentEventPendingLanes = 0, + focusedInstanceHandle = null, + shouldFireAfterActiveInstanceBlur = !1; function requestEventTime() { return 0 !== (executionContext & 48) ? now() @@ -6229,22 +5928,30 @@ function requestEventTime() { } function requestUpdateLane(fiber) { fiber = fiber.mode; - if (0 === (fiber & 1)) return 1; - if (0 === (fiber & 2)) return 99 === getCurrentPriorityLevel() ? 1 : 2; - if (0 !== ReactCurrentBatchConfig.transition) - return ( - 0 === currentEventTransitionLane && - ((fiber = nextTransitionLane), - (nextTransitionLane <<= 1), - 0 === (nextTransitionLane & 8388096) && (nextTransitionLane = 512), - (currentEventTransitionLane = fiber)), - currentEventTransitionLane - ); + 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)) + ? (fiber = findUpdateLane(12, currentEventWipLanes)) : ((fiber = schedulerPriorityToLanePriority(fiber)), - (fiber = findUpdateLane(fiber))); + (fiber = findUpdateLane(fiber, currentEventWipLanes))); return fiber; } function scheduleUpdateOnFiber(fiber, lane, eventTime) { @@ -6275,7 +5982,7 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) : rootsWithPendingDiscreteUpdates.add(fiber)), ensureRootIsScheduled(fiber, eventTime)); - return fiber; + mostRecentlyUpdatedRoot = fiber; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { sourceFiber.lanes |= lane; @@ -6300,15 +6007,15 @@ function ensureRootIsScheduled(root, currentTime) { 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6, - expirationTime = expirationTimes[index$6]; + 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$6] = + expirationTimes[index$7] = 10 <= priority ? expirationTime + 250 : 6 <= priority @@ -6323,42 +6030,45 @@ function ensureRootIsScheduled(root, currentTime) { root === workInProgressRoot ? workInProgressRootRenderLanes : 0 ); currentTime = return_highestLanePriority; - 0 === suspendedLanes - ? (null !== existingCallbackNode && + if (0 === suspendedLanes) + null !== existingCallbackNode && + (existingCallbackNode !== fakeCallbackNode && Scheduler_cancelCallback(existingCallbackNode), (root.callbackNode = null), - (root.callbackPriority = 0)) - : root.callbackPriority !== currentTime && - (null != existingCallbackNode && - Scheduler_cancelCallback(existingCallbackNode), - 15 === currentTime - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? ((syncQueue = [existingCallbackNode]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(existingCallbackNode), - (existingCallbackNode = null)) - : 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)); + (root.callbackPriority = 0)); + else { + 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) { +function performConcurrentWorkOnRoot(root) { currentEventTime = -1; - currentEventTransitionLane = 0; + currentEventPendingLanes = currentEventWipLanes = 0; if (0 !== (executionContext & 48)) throw Error("Should not already be working."); var originalCallbackNode = root.callbackNode; @@ -6369,22 +6079,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(); if ( workInProgressRoot !== root || - workInProgressRootRenderLanes !== didTimeout + workInProgressRootRenderLanes !== exitStatus ) (workInProgressRootRenderTargetTime = now() + 500), - prepareFreshStack(root, didTimeout); + prepareFreshStack(root, exitStatus); do try { workLoopConcurrent(); @@ -6397,17 +6101,19 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ReactCurrentDispatcher$2.current = prevDispatcher; executionContext = prevExecutionContext; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = 0) : ((workInProgressRoot = null), (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); - if (0 !== didTimeout) { - 2 === didTimeout && + (exitStatus = workInProgressRootExitStatus)); + 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 && (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), @@ -6415,7 +6121,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."); @@ -6425,9 +6131,9 @@ function performConcurrentWorkOnRoot(root, didTimeout) { case 3: markRootSuspended$1(root, lanes); if ( - (lanes & 125829120) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + (lanes & 62914560) === lanes && + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { if (0 !== getNextLanes(root, 0)) break; prevExecutionContext = root.suspendedLanes; @@ -6438,7 +6144,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + exitStatus ); break; } @@ -6446,13 +6152,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { break; case 4: markRootSuspended$1(root, lanes); - if ((lanes & 8388096) === lanes) break; - didTimeout = root.eventTimes; + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; for (prevExecutionContext = -1; 0 < lanes; ) { - var index$5 = 31 - clz32(lanes); - prevDispatcher = 1 << index$5; - index$5 = didTimeout[index$5]; - index$5 > prevExecutionContext && (prevExecutionContext = index$5); + var index$6 = 31 - clz32(lanes); + prevDispatcher = 1 << index$6; + index$6 = exitStatus[index$6]; + index$6 > prevExecutionContext && (prevExecutionContext = index$6); lanes &= ~prevDispatcher; } lanes = prevExecutionContext; @@ -6498,9 +6204,9 @@ function markRootSuspended$1(root, suspendedLanes) { root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$7 = 31 - clz32(suspendedLanes), - lane = 1 << index$7; - root[index$7] = -1; + var index$11 = 31 - clz32(suspendedLanes), + lane = 1 << index$11; + root[index$11] = -1; suspendedLanes &= ~lane; } } @@ -6508,12 +6214,17 @@ function performSyncWorkOnRoot(root) { if (0 !== (executionContext & 48)) throw Error("Should not already be working."); flushPassiveEffects(); - var lanes = + if ( root === workInProgressRoot && 0 !== (root.expiredLanes & workInProgressRootRenderLanes) - ? workInProgressRootRenderLanes - : getNextLanes(root, 0); - var exitStatus = renderRootSync(root, lanes); + ) { + 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 && 2 === exitStatus && ((executionContext |= 64), @@ -6532,6 +6243,11 @@ function performSyncWorkOnRoot(root) { ensureRootIsScheduled(root, now()); return null; } +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes); + subtreeRenderLanes |= lanes; + workInProgressRootIncludedLanes |= lanes; +} function popRenderLanes() { subtreeRenderLanes = subtreeRenderLanesCursor.current; pop(subtreeRenderLanesCursor); @@ -6571,7 +6287,7 @@ function prepareFreshStack(root, lanes) { pop(suspenseStackCursor); break; case 10: - popProvider(interruptedWork.type._context); + popProvider(interruptedWork); break; case 22: case 23: @@ -6581,29 +6297,10 @@ function prepareFreshStack(root, lanes) { } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = lanes; + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; - if (null !== interleavedQueues) { - for (root = 0; root < interleavedQueues.length; root++) - if ( - ((lanes = interleavedQueues[root]), - (timeoutHandle = lanes.interleaved), - null !== timeoutHandle) - ) { - lanes.interleaved = null; - interruptedWork = timeoutHandle.next; - var lastPendingUpdate = lanes.pending; - if (null !== lastPendingUpdate) { - var firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = interruptedWork; - timeoutHandle.next = firstPendingUpdate; - } - lanes.pending = timeoutHandle; - } - interleavedQueues = null; - } } function handleError(root$jscomp$0, thrownValue) { do { @@ -6639,18 +6336,15 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.flags |= 8192; + sourceFiber.flags |= 4096; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - var wakeable = value, - tag = sourceFiber.tag; - if ( - 0 === (sourceFiber.mode & 1) && - (0 === tag || 11 === tag || 15 === tag) - ) { + var wakeable = value; + if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), @@ -6661,15 +6355,15 @@ function handleError(root$jscomp$0, thrownValue) { } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - workInProgress$75 = returnFiber; + workInProgress$76 = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$75.tag)) { - var nextState = workInProgress$75.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$75.memoizedProps; + var props = workInProgress$76.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6681,19 +6375,16 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var wakeables = workInProgress$75.updateQueue; + var wakeables = workInProgress$76.updateQueue; if (null === wakeables) { var updateQueue = new Set(); updateQueue.add(wakeable); - workInProgress$75.updateQueue = updateQueue; + workInProgress$76.updateQueue = updateQueue; } else wakeables.add(wakeable); - if ( - 0 === (workInProgress$75.mode & 1) && - workInProgress$75 !== returnFiber - ) { - workInProgress$75.flags |= 128; - sourceFiber.flags |= 65536; - sourceFiber.flags &= -10053; + 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 { @@ -6724,12 +6415,12 @@ function handleError(root$jscomp$0, thrownValue) { ); wakeable.then(ping, ping); } - workInProgress$75.flags |= 16384; - workInProgress$75.lanes = thrownValue; + workInProgress$76.flags |= 8192; + workInProgress$76.lanes = thrownValue; break a; } - workInProgress$75 = workInProgress$75.return; - } while (null !== workInProgress$75); + 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." @@ -6738,47 +6429,47 @@ function handleError(root$jscomp$0, thrownValue) { 5 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - workInProgress$75 = returnFiber; + workInProgress$76 = returnFiber; do { - switch (workInProgress$75.tag) { + switch (workInProgress$76.tag) { case 3: root = value; - workInProgress$75.flags |= 16384; + workInProgress$76.flags |= 8192; thrownValue &= -thrownValue; - workInProgress$75.lanes |= thrownValue; - var update$76 = createRootErrorUpdate( - workInProgress$75, + workInProgress$76.lanes |= thrownValue; + var update$77 = createRootErrorUpdate( + workInProgress$76, root, thrownValue ); - enqueueCapturedUpdate(workInProgress$75, update$76); + enqueueCapturedUpdate(workInProgress$76, update$77); break a; case 1: root = value; - var ctor = workInProgress$75.type, - instance = workInProgress$75.stateNode; + var ctor = workInProgress$76.type, + instance = workInProgress$76.stateNode; if ( - 0 === (workInProgress$75.flags & 128) && + 0 === (workInProgress$76.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$75.flags |= 16384; + workInProgress$76.flags |= 8192; thrownValue &= -thrownValue; - workInProgress$75.lanes |= thrownValue; - var update$79 = createClassErrorUpdate( - workInProgress$75, + workInProgress$76.lanes |= thrownValue; + var update$80 = createClassErrorUpdate( + workInProgress$76, root, thrownValue ); - enqueueCapturedUpdate(workInProgress$75, update$79); + enqueueCapturedUpdate(workInProgress$76, update$80); break a; } } - workInProgress$75 = workInProgress$75.return; - } while (null !== workInProgress$75); + workInProgress$76 = workInProgress$76.return; + } while (null !== workInProgress$76); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { @@ -6839,25 +6530,47 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.flags & 8192)) { - if ( - ((current = completeWork(current, completedWork, subtreeRenderLanes)), - null !== current) - ) { + if (0 === (completedWork.flags & 4096)) { + current = completeWork(current, completedWork, subtreeRenderLanes); + if (null !== current) { workInProgress = current; return; } + current = completedWork; + if ( + (23 !== current.tag && 22 !== current.tag) || + null === current.memoizedState || + 0 !== (subtreeRenderLanes & 1073741824) || + 0 === (current.mode & 4) + ) { + for (var newChildLanes = 0, child = current.child; null !== child; ) + (newChildLanes |= child.lanes | child.childLanes), + (child = child.sibling); + current.childLanes = newChildLanes; + } + null !== unitOfWork && + 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.flags && + (null !== unitOfWork.lastEffect + ? (unitOfWork.lastEffect.nextEffect = completedWork) + : (unitOfWork.firstEffect = completedWork), + (unitOfWork.lastEffect = completedWork))); } else { current = unwindWork(completedWork); if (null !== current) { - current.flags &= 8191; + current.flags &= 4095; workInProgress = current; return; } null !== unitOfWork && - ((unitOfWork.flags |= 8192), - (unitOfWork.subtreeFlags = 0), - (unitOfWork.deletions = null)); + ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), + (unitOfWork.flags |= 4096)); } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -6878,8 +6591,7 @@ function commitRootImpl(root, renderPriorityLevel) { while (null !== rootWithPendingPassiveEffects); if (0 !== (executionContext & 48)) throw Error("Should not already be working."); - var finishedWork = root.finishedWork, - lanes = root.finishedLanes; + var finishedWork = root.finishedWork; if (null === finishedWork) return null; root.finishedWork = null; root.finishedLanes = 0; @@ -6888,48 +6600,174 @@ function commitRootImpl(root, renderPriorityLevel) { "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); root.callbackNode = null; - root.callbackPriority = 0; - var remainingLanes = finishedWork.lanes | finishedWork.childLanes; - markRootFinished(root, remainingLanes); + 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 & 8) && + 0 === (remainingLanes & 24) && rootsWithPendingDiscreteUpdates.has(root) && rootsWithPendingDiscreteUpdates.delete(root); root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - (0 === (finishedWork.subtreeFlags & 1040) && - 0 === (finishedWork.flags & 1040)) || - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); - remainingLanes = 0 !== (finishedWork.flags & 8054); - 0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes - ? ((remainingLanes = executionContext), - (executionContext |= 32), - (ReactCurrentOwner$2.current = null), - commitBeforeMutationEffects(root, finishedWork), - commitMutationEffects(root, renderPriorityLevel, finishedWork), - (root.current = finishedWork), - commitLayoutEffects(finishedWork, root, lanes), - requestPaint(), - (executionContext = remainingLanes)) - : (root.current = finishedWork); - rootDoesHavePassiveEffects && - ((rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel)); + 1 < finishedWork.flags + ? null !== finishedWork.lastEffect + ? ((finishedWork.lastEffect.nextEffect = finishedWork), + (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(); + } catch (error) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + focusedInstanceHandle = null; + nextEffect = remainingLanes; + do + try { + for (eventTimes = root; null !== nextEffect; ) { + var flags = nextEffect.flags; + if (flags & 128) { + var current = nextEffect.alternate; + if (null !== current) { + var currentRef = current.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (flags & 1038) { + case 2: + commitPlacement(nextEffect); + nextEffect.flags &= -3; + break; + case 6: + commitPlacement(nextEffect); + nextEffect.flags &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 1024: + nextEffect.flags &= -1025; + break; + case 1028: + nextEffect.flags &= -1025; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + expirationTimes = nextEffect; + unmountHostComponents(eventTimes, expirationTimes); + var alternate = expirationTimes.alternate; + detachFiberMutation(expirationTimes); + null !== alternate && detachFiberMutation(alternate); + } + nextEffect = nextEffect.nextEffect; + } + } catch (error$88) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error$88); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + root.current = finishedWork; + nextEffect = remainingLanes; + do + try { + 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; + switch (nextEffect.tag) { + case 5: + current = instance; + break; + default: + current = instance; + } + "function" === typeof ref + ? ref(current) + : (ref.current = current); + } + } + nextEffect = nextEffect.nextEffect; + } + } catch (error$89) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error$89); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + nextEffect = null; + requestPaint(); + executionContext = remainingLanes$jscomp$0; + } else root.current = finishedWork; + if (rootDoesHavePassiveEffects) + (rootDoesHavePassiveEffects = !1), + (rootWithPendingPassiveEffects = root), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel); + else + for (nextEffect = remainingLanes; null !== nextEffect; ) + (renderPriorityLevel = nextEffect.nextEffect), + (nextEffect.nextEffect = 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); - 0 !== (remainingLanes & 1) + 1 === remainingLanes ? root === rootWithNestedUpdates ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - onCommitRoot(finishedWork.stateNode, renderPriorityLevel); + 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), @@ -6940,6 +6778,30 @@ function commitRootImpl(root, renderPriorityLevel) { flushSyncCallbackQueue(); return null; } +function commitBeforeMutationEffects() { + for (; null !== nextEffect; ) { + 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() { + flushPassiveEffects(); + return null; + })); + nextEffect = nextEffect.nextEffect; + } +} function flushPassiveEffects() { if (90 !== pendingPassiveEffectsRenderPriority) { var priorityLevel = @@ -6951,6 +6813,24 @@ function flushPassiveEffects() { } 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; @@ -6959,103 +6839,40 @@ function flushPassiveEffectsImpl() { throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; executionContext |= 32; - for (nextEffect = root.current; null !== nextEffect; ) { - var fiber = nextEffect, - child = fiber.child; - if (0 !== (nextEffect.flags & 16)) { - var deletions = fiber.deletions; - if (null !== deletions) { - for (var i = 0; i < deletions.length; i++) { - var fiberToDelete = deletions[i]; - for (nextEffect = fiberToDelete; null !== nextEffect; ) { - var fiber$jscomp$0 = nextEffect; - switch (fiber$jscomp$0.tag) { - case 0: - case 11: - case 15: - commitHookEffectListUnmount(4, fiber$jscomp$0, fiber); - } - var child$jscomp$0 = fiber$jscomp$0.child; - if (null !== child$jscomp$0) - (child$jscomp$0.return = fiber$jscomp$0), - (nextEffect = child$jscomp$0); - else - for (; null !== nextEffect; ) { - fiber$jscomp$0 = nextEffect; - if (fiber$jscomp$0 === fiberToDelete) { - nextEffect = null; - break; - } - child$jscomp$0 = fiber$jscomp$0.sibling; - if (null !== child$jscomp$0) { - child$jscomp$0.return = fiber$jscomp$0.return; - nextEffect = child$jscomp$0; - break; - } - nextEffect = fiber$jscomp$0.return; - } - } - fiber$jscomp$0 = fiberToDelete.alternate; - detachFiberAfterEffects(fiberToDelete); - null !== fiber$jscomp$0 && detachFiberAfterEffects(fiber$jscomp$0); - } - nextEffect = fiber; - } - } - if (0 !== (fiber.subtreeFlags & 1040) && null !== child) - (child.return = fiber), (nextEffect = child); - else - a: for (; null !== nextEffect; ) { - fiber = nextEffect; - if (0 !== (fiber.flags & 1024)) - switch (fiber.tag) { - case 0: - case 11: - case 15: - commitHookEffectListUnmount(5, fiber, fiber.return); - } - child = fiber.sibling; - if (null !== child) { - child.return = fiber.return; - nextEffect = child; - break a; - } - nextEffect = fiber.return; + 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); } } - for (nextEffect = root = root.current; null !== nextEffect; ) - if ( - ((fiber = nextEffect), - (child = fiber.child), - 0 !== (fiber.subtreeFlags & 1040) && null !== child) - ) - (child.return = fiber), (nextEffect = child); - else - a: for (fiber = root; null !== nextEffect; ) { - child = nextEffect; - if (0 !== (child.flags & 1024)) - try { - switch (child.tag) { - case 0: - case 11: - case 15: - commitHookEffectListMount(5, child); - } - } catch (error) { - captureCommitPhaseError(child, child.return, error); - } - if (child === fiber) { - nextEffect = null; - break a; - } - deletions = child.sibling; - if (null !== deletions) { - deletions.return = child.return; - nextEffect = deletions; - break a; - } - nextEffect = child.return; - } + unmountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + for (i = 0; i < unmountEffects.length; i += 2) { + effect$94 = unmountEffects[i]; + fiber = unmountEffects[i + 1]; + try { + 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); + } + } + 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; @@ -7070,50 +6887,42 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { (markRootUpdated(rootFiber, 1, sourceFiber), ensureRootIsScheduled(rootFiber, sourceFiber)); } -function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { +function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); else - for ( - nearestMountedAncestor = sourceFiber.return; - null !== nearestMountedAncestor; - - ) { - if (3 === nearestMountedAncestor.tag) { - captureCommitPhaseErrorOnRoot( - nearestMountedAncestor, - sourceFiber, - error - ); + for (var fiber = sourceFiber.return; null !== fiber; ) { + if (3 === fiber.tag) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); break; - } else if (1 === nearestMountedAncestor.tag) { - var instance = nearestMountedAncestor.stateNode; + } else if (1 === fiber.tag) { + var instance = fiber.stateNode; if ( - "function" === - typeof nearestMountedAncestor.type.getDerivedStateFromError || + "function" === typeof fiber.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 1 - ); - enqueueUpdate(nearestMountedAncestor, sourceFiber); - sourceFiber = requestEventTime(); - nearestMountedAncestor = markUpdateLaneFromFiberToRoot( - nearestMountedAncestor, - 1 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 1, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + 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; } } - nearestMountedAncestor = nearestMountedAncestor.return; + fiber = fiber.return; } } function pingSuspendedRoot(root, wakeable, pingedLanes) { @@ -7125,7 +6934,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && (4 === workInProgressRootExitStatus || (3 === workInProgressRootExitStatus && - (workInProgressRootRenderLanes & 125829120) === + (workInProgressRootRenderLanes & 62914560) === workInProgressRootRenderLanes && 500 > now() - globalMostRecentFallbackTime) ? prepareFreshStack(root, 0) @@ -7138,13 +6947,14 @@ function resolveRetryWakeable(boundaryFiber, wakeable) { wakeable = 0; 0 === wakeable && ((wakeable = boundaryFiber.mode), - 0 === (wakeable & 1) + 0 === (wakeable & 2) ? (wakeable = 1) - : 0 === (wakeable & 2) + : 0 === (wakeable & 4) ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) - : ((wakeable = nextRetryLane), - (nextRetryLane <<= 1), - 0 === (nextRetryLane & 125829120) && (nextRetryLane = 8388608))); + : (0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes), + (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), + 0 === wakeable && (wakeable = 4194304))); retryCache = requestEventTime(); boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); null !== boundaryFiber && @@ -7160,83 +6970,78 @@ beginWork$1 = function(current, workInProgress, renderLanes) { didPerformWorkStackCursor.current ) didReceiveUpdate = !0; + else if (0 !== (renderLanes & updateLanes)) + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { - if (0 === (renderLanes & updateLanes)) { - 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.type._context; - var nextValue = workInProgress.memoizedProps.value; - push(valueCursor, updateLanes._currentValue); - updateLanes._currentValue = nextValue; - 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( + 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 ); - return null !== workInProgress ? workInProgress.sibling : null; - } push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.flags & 128)) { - if (updateLanes) - return updateSuspenseListComponent( - current, - workInProgress, - renderLanes - ); - workInProgress.flags |= 128; - } - nextValue = workInProgress.memoizedState; - null !== nextValue && - ((nextValue.rendering = null), - (nextValue.tail = null), - (nextValue.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (updateLanes) break; - else return null; - case 22: - case 23: - return ( - (workInProgress.lanes = 0), - updateOffscreenComponent(current, workInProgress, renderLanes) + workInProgress = bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderLanes ); - } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderLanes - ); + 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, + renderLanes + ); + 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 22: + case 23: + return ( + (workInProgress.lanes = 0), + updateOffscreenComponent(current, workInProgress, renderLanes) + ); } - didReceiveUpdate = 0 !== (current.flags & 65536) ? !0 : !1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else didReceiveUpdate = !1; workInProgress.lanes = 0; @@ -7248,22 +7053,22 @@ beginWork$1 = function(current, workInProgress, renderLanes) { (workInProgress.alternate = null), (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - nextValue = getMaskedContext(workInProgress, contextStackCursor.current); + context = getMaskedContext(workInProgress, contextStackCursor.current); prepareToReadContext(workInProgress, renderLanes); - nextValue = renderWithHooks( + context = renderWithHooks( null, workInProgress, updateLanes, current, - nextValue, + context, renderLanes ); workInProgress.flags |= 1; if ( - "object" === typeof nextValue && - null !== nextValue && - "function" === typeof nextValue.render && - void 0 === nextValue.$$typeof + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof ) { workInProgress.tag = 1; workInProgress.memoizedState = null; @@ -7273,8 +7078,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { pushContextProvider(workInProgress); } else hasContext = !1; workInProgress.memoizedState = - null !== nextValue.state && void 0 !== nextValue.state - ? nextValue.state + null !== context.state && void 0 !== context.state + ? context.state : null; initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; @@ -7285,9 +7090,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { getDerivedStateFromProps, current ); - nextValue.updater = classComponentUpdater; - workInProgress.stateNode = nextValue; - nextValue._reactInternals = workInProgress; + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternals = workInProgress; mountClassInstance(workInProgress, updateLanes, current, renderLanes); workInProgress = finishClassComponent( null, @@ -7299,28 +7104,28 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); } else (workInProgress.tag = 0), - reconcileChildren(null, workInProgress, nextValue, renderLanes), + reconcileChildren(null, workInProgress, context, renderLanes), (workInProgress = workInProgress.child); return workInProgress; case 16: - nextValue = workInProgress.elementType; + context = workInProgress.elementType; a: { null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - hasContext = nextValue._init; - nextValue = hasContext(nextValue._payload); - workInProgress.type = nextValue; - hasContext = workInProgress.tag = resolveLazyComponentTag(nextValue); - current = resolveDefaultProps(nextValue, current); + hasContext = context._init; + context = hasContext(context._payload); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current = resolveDefaultProps(context, current); switch (hasContext) { case 0: workInProgress = updateFunctionComponent( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7329,7 +7134,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateClassComponent( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7338,7 +7143,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateForwardRef( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7347,8 +7152,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateMemoComponent( null, workInProgress, - nextValue, - resolveDefaultProps(nextValue.type, current), + context, + resolveDefaultProps(context.type, current), updateLanes, renderLanes ); @@ -7356,7 +7161,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } throw Error( "Element type is invalid. Received a promise that resolves to: " + - nextValue + + context + ". Lazy element type must resolve to a class or function." ); } @@ -7364,32 +7169,32 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 0: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateFunctionComponent( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); case 1: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateClassComponent( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); @@ -7400,18 +7205,19 @@ beginWork$1 = function(current, workInProgress, renderLanes) { 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." ); - nextValue = workInProgress.pendingProps; - updateLanes = workInProgress.memoizedState.element; + updateLanes = workInProgress.pendingProps; + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, nextValue, null, renderLanes); - nextValue = workInProgress.memoizedState.element; - nextValue === updateLanes + processUpdateQueue(workInProgress, updateLanes, null, renderLanes); + updateLanes = workInProgress.memoizedState.element; + updateLanes === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, renderLanes )) - : (reconcileChildren(current, workInProgress, nextValue, renderLanes), + : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), (workInProgress = workInProgress.child)); return workInProgress; case 5: @@ -7451,16 +7257,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 11: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateForwardRef( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); @@ -7497,21 +7303,27 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 10: a: { updateLanes = workInProgress.type._context; - nextValue = workInProgress.pendingProps; + context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; - hasContext = nextValue.value; - push(valueCursor, updateLanes._currentValue); - updateLanes._currentValue = hasContext; - if (null !== getDerivedStateFromProps) { - var oldValue = getDerivedStateFromProps.value; - hasContext = objectIs(oldValue, hasContext) - ? 0 - : ("function" === typeof updateLanes._calculateChangedBits - ? updateLanes._calculateChangedBits(oldValue, hasContext) - : 1073741823) | 0; - if (0 === hasContext) { + hasContext = context.value; + var context$jscomp$0 = workInProgress.type._context; + push(valueCursor, context$jscomp$0._currentValue); + context$jscomp$0._currentValue = hasContext; + if (null !== getDerivedStateFromProps) + if ( + ((context$jscomp$0 = getDerivedStateFromProps.value), + (hasContext = objectIs(context$jscomp$0, hasContext) + ? 0 + : ("function" === typeof updateLanes._calculateChangedBits + ? updateLanes._calculateChangedBits( + context$jscomp$0, + hasContext + ) + : 1073741823) | 0), + 0 === hasContext) + ) { if ( - getDerivedStateFromProps.children === nextValue.children && + getDerivedStateFromProps.children === context.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -7523,14 +7335,15 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } } else for ( - oldValue = workInProgress.child, - null !== oldValue && (oldValue.return = workInProgress); - null !== oldValue; + context$jscomp$0 = workInProgress.child, + null !== context$jscomp$0 && + (context$jscomp$0.return = workInProgress); + null !== context$jscomp$0; ) { - var list = oldValue.dependencies; + var list = context$jscomp$0.dependencies; if (null !== list) { - getDerivedStateFromProps = oldValue.child; + getDerivedStateFromProps = context$jscomp$0.child; for ( var dependency = list.firstContext; null !== dependency; @@ -7540,24 +7353,20 @@ beginWork$1 = function(current, workInProgress, renderLanes) { dependency.context === updateLanes && 0 !== (dependency.observedBits & hasContext) ) { - if (1 === oldValue.tag) { - dependency = createUpdate(-1, renderLanes & -renderLanes); - dependency.tag = 2; - var updateQueue = oldValue.updateQueue; - if (null !== updateQueue) { - updateQueue = updateQueue.shared; - var pending = updateQueue.pending; - null === pending - ? (dependency.next = dependency) - : ((dependency.next = pending.next), - (pending.next = dependency)); - updateQueue.pending = dependency; - } - } - oldValue.lanes |= renderLanes; - dependency = oldValue.alternate; + 1 === context$jscomp$0.tag && + ((dependency = createUpdate( + -1, + renderLanes & -renderLanes + )), + (dependency.tag = 2), + enqueueUpdate(context$jscomp$0, dependency)); + context$jscomp$0.lanes |= renderLanes; + dependency = context$jscomp$0.alternate; null !== dependency && (dependency.lanes |= renderLanes); - scheduleWorkOnParentPath(oldValue.return, renderLanes); + scheduleWorkOnParentPath( + context$jscomp$0.return, + renderLanes + ); list.lanes |= renderLanes; break; } @@ -7565,16 +7374,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } } else getDerivedStateFromProps = - 10 === oldValue.tag - ? oldValue.type === workInProgress.type + 10 === context$jscomp$0.tag + ? context$jscomp$0.type === workInProgress.type ? null - : oldValue.child - : oldValue.child; + : context$jscomp$0.child + : context$jscomp$0.child; if (null !== getDerivedStateFromProps) - getDerivedStateFromProps.return = oldValue; + getDerivedStateFromProps.return = context$jscomp$0; else for ( - getDerivedStateFromProps = oldValue; + getDerivedStateFromProps = context$jscomp$0; null !== getDerivedStateFromProps; ) { @@ -7582,21 +7391,20 @@ beginWork$1 = function(current, workInProgress, renderLanes) { getDerivedStateFromProps = null; break; } - oldValue = getDerivedStateFromProps.sibling; - if (null !== oldValue) { - oldValue.return = getDerivedStateFromProps.return; - getDerivedStateFromProps = oldValue; + context$jscomp$0 = getDerivedStateFromProps.sibling; + if (null !== context$jscomp$0) { + context$jscomp$0.return = getDerivedStateFromProps.return; + getDerivedStateFromProps = context$jscomp$0; break; } getDerivedStateFromProps = getDerivedStateFromProps.return; } - oldValue = getDerivedStateFromProps; + context$jscomp$0 = getDerivedStateFromProps; } - } reconcileChildren( current, workInProgress, - nextValue.children, + context.children, renderLanes ); workInProgress = workInProgress.child; @@ -7604,28 +7412,28 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return workInProgress; case 9: return ( - (nextValue = workInProgress.type), + (context = workInProgress.type), (hasContext = workInProgress.pendingProps), (updateLanes = hasContext.children), prepareToReadContext(workInProgress, renderLanes), - (nextValue = readContext(nextValue, hasContext.unstable_observedBits)), - (updateLanes = updateLanes(nextValue)), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateLanes = updateLanes(context)), (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); case 14: return ( - (nextValue = workInProgress.type), + (context = workInProgress.type), (hasContext = resolveDefaultProps( - nextValue, + context, workInProgress.pendingProps )), - (hasContext = resolveDefaultProps(nextValue.type, hasContext)), + (hasContext = resolveDefaultProps(context.type, hasContext)), updateMemoComponent( current, workInProgress, - nextValue, + context, hasContext, updateLanes, renderLanes @@ -7643,11 +7451,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 17: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), @@ -7657,8 +7465,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), prepareToReadContext(workInProgress, renderLanes), - constructClassInstance(workInProgress, updateLanes, nextValue), - mountClassInstance(workInProgress, updateLanes, nextValue, renderLanes), + constructClassInstance(workInProgress, updateLanes, context), + mountClassInstance(workInProgress, updateLanes, context, renderLanes), finishClassComponent( null, workInProgress, @@ -7690,8 +7498,8 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.subtreeFlags = this.flags = 0; - this.deletions = null; + this.flags = 0; + this.lastEffect = this.firstEffect = this.nextEffect = null; this.childLanes = this.lanes = 0; this.alternate = null; } @@ -7729,9 +7537,9 @@ function createWorkInProgress(current, pendingProps) { : ((workInProgress.pendingProps = pendingProps), (workInProgress.type = current.type), (workInProgress.flags = 0), - (workInProgress.subtreeFlags = 0), - (workInProgress.deletions = null)); - workInProgress.flags = current.flags & 131072; + (workInProgress.nextEffect = null), + (workInProgress.firstEffect = null), + (workInProgress.lastEffect = null)); workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -7766,18 +7574,15 @@ function createFiberFromTypeAndProps( return createFiberFromFragment(pendingProps.children, mode, lanes, key); case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = 8; - mode |= 8; + mode |= 16; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; - 1 <= - (null == pendingProps.unstable_level - ? 1 - : pendingProps.unstable_level) && (mode |= 16); + mode |= 1; break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.lanes = lanes), @@ -7964,8 +7769,7 @@ function updateContainer(element, container, parentComponent, callback) { callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - element = scheduleUpdateOnFiber(current, lane, eventTime); - null !== element && entangleTransitions(element, current, lane); + scheduleUpdateOnFiber(current, lane, eventTime); return lane; } function emptyFindFiberByHostInstance() { @@ -8004,10 +7808,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_959 = { + devToolsConfig$jscomp$inline_908 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "17.0.2", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8022,11 +7826,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1242 = { - bundleType: devToolsConfig$jscomp$inline_959.bundleType, - version: devToolsConfig$jscomp$inline_959.version, - rendererPackageName: devToolsConfig$jscomp$inline_959.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_959.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, @@ -8041,7 +7845,7 @@ var internals$jscomp$inline_1242 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_959.findFiberByHostInstance || + devToolsConfig$jscomp$inline_908.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, @@ -8050,16 +7854,16 @@ var internals$jscomp$inline_1242 = { getCurrentFiber: null }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1243 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1116 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1243.isDisabled && - hook$jscomp$inline_1243.supportsFiber + !hook$jscomp$inline_1116.isDisabled && + hook$jscomp$inline_1116.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1243.inject( - internals$jscomp$inline_1242 + (rendererID = hook$jscomp$inline_1116.inject( + internals$jscomp$inline_1115 )), - (injectedHook = hook$jscomp$inline_1243); + (injectedHook = hook$jscomp$inline_1116); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { @@ -8108,11 +7912,10 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var JSCompiler_inline_result = createFiber(3, null, null, 0); - root.current = JSCompiler_inline_result; - JSCompiler_inline_result.stateNode = root; - JSCompiler_inline_result.memoizedState = { element: null }; - initializeUpdateQueue(JSCompiler_inline_result); + var uninitializedFiber = createFiber(3, null, null, 0); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 680b703d37e..7937b1e9222 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_219 = { +var injectedNamesToPlugins$jscomp$inline_226 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -955,34 +955,34 @@ var injectedNamesToPlugins$jscomp$inline_219 = { } } }, - isOrderingDirty$jscomp$inline_220 = !1, - pluginName$jscomp$inline_221; -for (pluginName$jscomp$inline_221 in injectedNamesToPlugins$jscomp$inline_219) + isOrderingDirty$jscomp$inline_227 = !1, + pluginName$jscomp$inline_228; +for (pluginName$jscomp$inline_228 in injectedNamesToPlugins$jscomp$inline_226) if ( - injectedNamesToPlugins$jscomp$inline_219.hasOwnProperty( - pluginName$jscomp$inline_221 + injectedNamesToPlugins$jscomp$inline_226.hasOwnProperty( + pluginName$jscomp$inline_228 ) ) { - var pluginModule$jscomp$inline_222 = - injectedNamesToPlugins$jscomp$inline_219[pluginName$jscomp$inline_221]; + var pluginModule$jscomp$inline_229 = + injectedNamesToPlugins$jscomp$inline_226[pluginName$jscomp$inline_228]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_221) || - namesToPlugins[pluginName$jscomp$inline_221] !== - pluginModule$jscomp$inline_222 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_228) || + namesToPlugins[pluginName$jscomp$inline_228] !== + pluginModule$jscomp$inline_229 ) { - if (namesToPlugins[pluginName$jscomp$inline_221]) + if (namesToPlugins[pluginName$jscomp$inline_228]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_221 + + pluginName$jscomp$inline_228 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_221 - ] = pluginModule$jscomp$inline_222; - isOrderingDirty$jscomp$inline_220 = !0; + pluginName$jscomp$inline_228 + ] = pluginModule$jscomp$inline_229; + isOrderingDirty$jscomp$inline_227 = !0; } } -isOrderingDirty$jscomp$inline_220 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_227 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1140,8 +1140,7 @@ var ReactSharedInternals = REACT_LAZY_TYPE = 60116, REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, - REACT_LEGACY_HIDDEN_TYPE = 60131, - REACT_CACHE_TYPE = 60132; + REACT_LEGACY_HIDDEN_TYPE = 60131; if ("function" === typeof Symbol && Symbol.for) { var symbolFor = Symbol.for; REACT_ELEMENT_TYPE = symbolFor("react.element"); @@ -1160,7 +1159,6 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); - REACT_CACHE_TYPE = symbolFor("react.cache"); } var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { @@ -1187,8 +1185,6 @@ function getComponentName(type) { return "Suspense"; case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList"; - case REACT_CACHE_TYPE: - return "Cache"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -1222,7 +1218,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.flags & 2050) && (nearestMounted = node.return), + 0 !== (node.flags & 1026) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -1310,14 +1306,19 @@ function findCurrentFiberUsingSlowPath(fiber) { } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); - return null !== parent ? findCurrentHostFiberImpl(parent) : null; -} -function findCurrentHostFiberImpl(node) { - if (5 === node.tag || 6 === node.tag) return node; - for (node = node.child; null !== node; ) { - var match = findCurrentHostFiberImpl(node); - if (null !== match) return match; - node = node.sibling; + if (!parent) return null; + for (var node = parent; ; ) { + if (5 === node.tag || 6 === node.tag) return node; + if (node.child) (node.child.return = node), (node = node.child); + else { + if (node === parent) break; + for (; !node.sibling; ) { + if (!node.return || node.return === parent) return null; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } } return null; } @@ -1567,396 +1568,60 @@ function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { }; } var ReactNativeFiberHostComponent = (function() { - function ReactNativeFiberHostComponent(tag, viewConfig) { - this._nativeTag = tag; - this._children = []; - this.viewConfig = viewConfig; - } - var _proto = ReactNativeFiberHostComponent.prototype; - _proto.blur = function() { - ReactNativePrivateInterface.TextInputState.blurTextInput(this); - }; - _proto.focus = function() { - ReactNativePrivateInterface.TextInputState.focusTextInput(this); - }; - _proto.measure = function(callback) { - ReactNativePrivateInterface.UIManager.measure( + function ReactNativeFiberHostComponent(tag, viewConfig) { + this._nativeTag = tag; + this._children = []; + this.viewConfig = viewConfig; + } + var _proto = ReactNativeFiberHostComponent.prototype; + _proto.blur = function() { + ReactNativePrivateInterface.TextInputState.blurTextInput(this); + }; + _proto.focus = function() { + ReactNativePrivateInterface.TextInputState.focusTextInput(this); + }; + _proto.measure = function(callback) { + ReactNativePrivateInterface.UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + _proto.measureInWindow = function(callback) { + ReactNativePrivateInterface.UIManager.measureInWindow( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + _proto.measureLayout = function(relativeToNativeNode, onSuccess, onFail) { + if ("number" === typeof relativeToNativeNode) + var relativeNode = relativeToNativeNode; + else + relativeToNativeNode._nativeTag && + (relativeNode = relativeToNativeNode._nativeTag); + null != relativeNode && + ReactNativePrivateInterface.UIManager.measureLayout( this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); - }; - _proto.measureInWindow = function(callback) { - ReactNativePrivateInterface.UIManager.measureInWindow( + }; + _proto.setNativeProps = function(nativeProps) { + nativeProps = diffProperties( + null, + emptyObject, + nativeProps, + this.viewConfig.validAttributes + ); + null != nativeProps && + ReactNativePrivateInterface.UIManager.updateView( this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) + this.viewConfig.uiViewClassName, + nativeProps ); - }; - _proto.measureLayout = function(relativeToNativeNode, onSuccess, onFail) { - if ("number" === typeof relativeToNativeNode) - var relativeNode = relativeToNativeNode; - else - relativeToNativeNode._nativeTag && - (relativeNode = relativeToNativeNode._nativeTag); - null != relativeNode && - ReactNativePrivateInterface.UIManager.measureLayout( - this._nativeTag, - relativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; - _proto.setNativeProps = function(nativeProps) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes - ); - null != nativeProps && - ReactNativePrivateInterface.UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps - ); - }; - return ReactNativeFiberHostComponent; - })(), - 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; -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" - ); -var requestPaint = - void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, - syncQueue = null, - immediateQueueCallbackNode = null, - isFlushingSyncQueue = !1, - initialTimeMs = Scheduler_now(), - now = - 1e4 > initialTimeMs - ? Scheduler_now - : function() { - return Scheduler_now() - initialTimeMs; - }; -function getCurrentPriorityLevel() { - switch (Scheduler_getCurrentPriorityLevel()) { - case Scheduler_ImmediatePriority: - return 99; - case Scheduler_UserBlockingPriority: - return 98; - case Scheduler_NormalPriority: - return 97; - case Scheduler_LowPriority: - return 96; - case Scheduler_IdlePriority: - return 95; - default: - throw Error("Unknown priority level."); - } -} -function reactPriorityToSchedulerPriority(reactPriorityLevel) { - switch (reactPriorityLevel) { - case 99: - return Scheduler_ImmediatePriority; - case 98: - return Scheduler_UserBlockingPriority; - case 97: - return Scheduler_NormalPriority; - case 96: - return Scheduler_LowPriority; - case 95: - return Scheduler_IdlePriority; - default: - throw Error("Unknown priority level."); - } -} -function runWithPriority(reactPriorityLevel, fn) { - reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_runWithPriority(reactPriorityLevel, fn); -} -function scheduleCallback(reactPriorityLevel, callback, options) { - reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); - return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); -} -function flushSyncCallbackQueue() { - if (null !== immediateQueueCallbackNode) { - var node = immediateQueueCallbackNode; - immediateQueueCallbackNode = null; - Scheduler_cancelCallback(node); - } - flushSyncCallbackQueueImpl(); -} -function flushSyncCallbackQueueImpl() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var i = 0; - try { - var queue = syncQueue; - runWithPriority(99, function() { - for (; i < queue.length; i++) { - var callback = queue[i]; - do callback = callback(!0); - while (null !== callback); - } - }); - syncQueue = null; - } catch (error) { - throw (null !== syncQueue && (syncQueue = syncQueue.slice(i + 1)), - Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueue - ), - error); - } finally { - isFlushingSyncQueue = !1; - } - } -} -var nextTransitionLane = 512, - nextRetryLane = 8388608, - return_highestLanePriority = 8; -function getHighestPriorityLanes(lanes) { - switch (lanes & -lanes) { - case 1: - return (return_highestLanePriority = 15), 1; - case 2: - return (return_highestLanePriority = 14), 2; - case 4: - return (return_highestLanePriority = 13), 4; - case 8: - return (return_highestLanePriority = 12), 8; - case 16: - return (return_highestLanePriority = 11), 16; - case 32: - return (return_highestLanePriority = 10), 32; - case 64: - return (return_highestLanePriority = 9), 64; - case 128: - return (return_highestLanePriority = 8), 128; - case 256: - return (return_highestLanePriority = 7), 256; - case 512: - case 1024: - case 2048: - case 4096: - case 8192: - case 16384: - case 32768: - case 65536: - case 131072: - case 262144: - case 524288: - case 1048576: - case 2097152: - case 4194304: - return (return_highestLanePriority = 6), lanes & 8388096; - case 8388608: - case 16777216: - case 33554432: - case 67108864: - return (return_highestLanePriority = 5), lanes & 125829120; - case 134217728: - return (return_highestLanePriority = 4), 134217728; - case 268435456: - return (return_highestLanePriority = 3), 268435456; - case 536870912: - return (return_highestLanePriority = 2), 536870912; - case 1073741824: - return (return_highestLanePriority = 1), 1073741824; - default: - return (return_highestLanePriority = 8), 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; - 0 !== expiredLanes - ? ((nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 15)) - : ((expiredLanes = pendingLanes & 268435455), - 0 !== expiredLanes - ? ((pendingLanes = expiredLanes & ~suspendedLanes), - 0 !== pendingLanes - ? ((nextLanes = getHighestPriorityLanes(pendingLanes)), - (nextLanePriority = return_highestLanePriority)) - : ((pingedLanes &= expiredLanes), - 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)))) - : ((pendingLanes &= ~suspendedLanes), - 0 !== pendingLanes - ? ((nextLanes = getHighestPriorityLanes(pendingLanes)), - (nextLanePriority = return_highestLanePriority)) - : 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)))); - if (0 === nextLanes) return 0; - if ( - 0 !== wipLanes && - wipLanes !== nextLanes && - 0 === (wipLanes & suspendedLanes) - ) { - getHighestPriorityLanes(wipLanes); - suspendedLanes = return_highestLanePriority; - if ( - nextLanePriority <= suspendedLanes || - (8 === nextLanePriority && 6 === suspendedLanes) - ) - return wipLanes; - return_highestLanePriority = nextLanePriority; - } - wipLanes = root.entangledLanes; - if (0 !== wipLanes) - for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) - (nextLanePriority = 31 - clz32(wipLanes)), - (suspendedLanes = 1 << nextLanePriority), - (nextLanes |= root[nextLanePriority]), - (wipLanes &= ~suspendedLanes); - return nextLanes; -} -function getLanesToRetrySynchronouslyOnError(root) { - root = root.pendingLanes & -1073741825; - return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; -} -function findUpdateLane(lanePriority) { - switch (lanePriority) { - case 15: - return 1; - case 14: - return 2; - case 12: - return 8; - case 10: - return 32; - case 8: - return 128; - case 2: - return 536870912; - } - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); -} -function createLaneMap(initial) { - for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial); - return laneMap; -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; - 536870912 !== updateLane && - ((root.suspendedLanes = 0), (root.pingedLanes = 0)); - root = root.eventTimes; - updateLane = 31 - clz32(updateLane); - root[updateLane] = eventTime; -} -function markRootFinished(root, remainingLanes) { - var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; - root.pendingLanes = remainingLanes; - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes; - root.mutableReadLanes &= remainingLanes; - root.entangledLanes &= remainingLanes; - remainingLanes = root.entanglements; - var eventTimes = root.eventTimes; - for (root = root.expirationTimes; 0 < noLongerPendingLanes; ) { - var index$8 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$8; - remainingLanes[index$8] = 0; - eventTimes[index$8] = -1; - root[index$8] = -1; - noLongerPendingLanes &= ~lane; - } -} -function markRootEntangled(root, entangledLanes) { - var rootEntangledLanes = (root.entangledLanes |= entangledLanes); - for (root = root.entanglements; rootEntangledLanes; ) { - var index$9 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$9; - (lane & entangledLanes) | (root[index$9] & entangledLanes) && - (root[index$9] |= entangledLanes); - rootEntangledLanes &= ~lane; - } -} -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_now$1 = 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$1(); + }; + return ReactNativeFiberHostComponent; +})(); function shim() { throw Error( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." @@ -2103,17 +1768,310 @@ function invalidateContextProvider(workInProgress, type, didChange) { } var rendererID = null, injectedHook = null, - isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__; -function onCommitRoot(root, priorityLevel) { - if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) - try { - injectedHook.onCommitFiberRoot( - rendererID, - root, - priorityLevel, - 128 === (root.current.flags & 128) + 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." ); - } catch (err) {} + } +} +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$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; +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" + ); +var fakeCallbackNode = {}, + requestPaint = + void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, + syncQueue = null, + immediateQueueCallbackNode = null, + isFlushingSyncQueue = !1, + initialTimeMs$1 = Scheduler_now$1(), + now = + 1e4 > initialTimeMs$1 + ? Scheduler_now$1 + : function() { + return Scheduler_now$1() - initialTimeMs$1; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return 99; + case Scheduler_UserBlockingPriority: + return 98; + case Scheduler_NormalPriority: + return 97; + case Scheduler_LowPriority: + return 96; + case Scheduler_IdlePriority: + return 95; + default: + throw Error("Unknown priority level."); + } +} +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case 99: + return Scheduler_ImmediatePriority; + case 98: + return Scheduler_UserBlockingPriority; + case 97: + return Scheduler_NormalPriority; + case 96: + return Scheduler_LowPriority; + case 95: + return Scheduler_IdlePriority; + default: + throw Error("Unknown priority level."); + } +} +function runWithPriority(reactPriorityLevel, fn) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(reactPriorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); +} +function flushSyncCallbackQueue() { + if (null !== immediateQueueCallbackNode) { + var node = immediateQueueCallbackNode; + immediateQueueCallbackNode = null; + Scheduler_cancelCallback(node); + } + flushSyncCallbackQueueImpl(); +} +function flushSyncCallbackQueueImpl() { + if (!isFlushingSyncQueue && null !== syncQueue) { + isFlushingSyncQueue = !0; + var i = 0; + try { + var queue = syncQueue; + runWithPriority(99, function() { + for (; i < queue.length; i++) { + var callback = queue[i]; + do callback = callback(!0); + while (null !== callback); + } + }); + syncQueue = null; + } catch (error) { + throw (null !== syncQueue && (syncQueue = syncQueue.slice(i + 1)), + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueue + ), + error); + } finally { + isFlushingSyncQueue = !1; + } + } } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function is(x, y) { @@ -2193,10 +2151,10 @@ var valueCursor = createCursor(null), function resetContextDependencies() { lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; } -function popProvider(context) { +function popProvider(providerFiber) { var currentValue = valueCursor.current; pop(valueCursor); - context._currentValue = currentValue; + providerFiber.type._context._currentValue = currentValue; } function scheduleWorkOnParentPath(parent, renderLanes) { for (; null !== parent; ) { @@ -2247,14 +2205,13 @@ function readContext(context, observedBits) { } return context._currentValue; } -var interleavedQueues = null, - hasForceUpdate = !1; +var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, firstBaseUpdate: null, lastBaseUpdate: null, - shared: { pending: null, interleaved: null, lanes: 0 }, + shared: { pending: null }, effects: null }; } @@ -2280,32 +2237,14 @@ function createUpdate(eventTime, lane) { }; } function enqueueUpdate(fiber, update) { - var updateQueue = fiber.updateQueue; - null !== updateQueue && - ((updateQueue = updateQueue.shared), - null !== workInProgressRoot && 0 !== (fiber.mode & 1) - ? ((fiber = updateQueue.interleaved), - null === fiber - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [updateQueue]) - : interleavedQueues.push(updateQueue)) - : ((update.next = fiber.next), (fiber.next = update)), - (updateQueue.interleaved = update)) - : ((fiber = updateQueue.pending), - null === fiber - ? (update.next = update) - : ((update.next = fiber.next), (fiber.next = update)), - (updateQueue.pending = update))); -} -function entangleTransitions(root, fiber, lane) { fiber = fiber.updateQueue; - if (null !== fiber && ((fiber = fiber.shared), 0 !== (lane & 8388096))) { - var queueLanes = fiber.lanes; - queueLanes &= root.pendingLanes; - lane |= queueLanes; - fiber.lanes = lane; - markRootEntangled(root, lane); + if (null !== fiber) { + fiber = fiber.shared; + var pending = fiber.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + fiber.pending = update; } } function enqueueCapturedUpdate(workInProgress, capturedUpdate) { @@ -2374,110 +2313,111 @@ function processUpdateQueue( : (lastBaseUpdate.next = firstPendingUpdate); lastBaseUpdate = lastPendingUpdate; var current = workInProgress$jscomp$0.alternate; - null !== current && - ((current = current.updateQueue), - (pendingQueue = current.lastBaseUpdate), - pendingQueue !== lastBaseUpdate && - (null === pendingQueue + if (null !== current) { + current = current.updateQueue; + var currentLastBaseUpdate = current.lastBaseUpdate; + currentLastBaseUpdate !== lastBaseUpdate && + (null === currentLastBaseUpdate ? (current.firstBaseUpdate = firstPendingUpdate) - : (pendingQueue.next = firstPendingUpdate), - (current.lastBaseUpdate = lastPendingUpdate))); + : (currentLastBaseUpdate.next = firstPendingUpdate), + (current.lastBaseUpdate = lastPendingUpdate)); + } } if (null !== firstBaseUpdate) { - var newState = queue.baseState; + currentLastBaseUpdate = queue.baseState; lastBaseUpdate = 0; current = firstPendingUpdate = lastPendingUpdate = null; - pendingQueue = firstBaseUpdate; do { - var updateLane = pendingQueue.lane, - updateEventTime = pendingQueue.eventTime; - if ((renderLanes & updateLane) === updateLane) { + pendingQueue = firstBaseUpdate.lane; + var updateEventTime = firstBaseUpdate.eventTime; + if ((renderLanes & pendingQueue) === pendingQueue) { null !== current && (current = current.next = { eventTime: updateEventTime, lane: 0, - tag: pendingQueue.tag, - payload: pendingQueue.payload, - callback: pendingQueue.callback, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null }); a: { var workInProgress = workInProgress$jscomp$0, - update = pendingQueue; - updateLane = props; + update = firstBaseUpdate; + pendingQueue = props; updateEventTime = instance; switch (update.tag) { case 1: workInProgress = update.payload; if ("function" === typeof workInProgress) { - newState = workInProgress.call( + currentLastBaseUpdate = workInProgress.call( updateEventTime, - newState, - updateLane + currentLastBaseUpdate, + pendingQueue ); break a; } - newState = workInProgress; + currentLastBaseUpdate = workInProgress; break a; case 3: - workInProgress.flags = (workInProgress.flags & -16385) | 128; + workInProgress.flags = (workInProgress.flags & -8193) | 64; case 0: workInProgress = update.payload; - updateLane = + pendingQueue = "function" === typeof workInProgress - ? workInProgress.call(updateEventTime, newState, updateLane) + ? workInProgress.call( + updateEventTime, + currentLastBaseUpdate, + pendingQueue + ) : workInProgress; - if (null === updateLane || void 0 === updateLane) break a; - newState = Object.assign({}, newState, updateLane); + if (null === pendingQueue || void 0 === pendingQueue) break a; + currentLastBaseUpdate = Object.assign( + {}, + currentLastBaseUpdate, + pendingQueue + ); break a; case 2: hasForceUpdate = !0; } } - null !== pendingQueue.callback && - ((workInProgress$jscomp$0.flags |= 64), - (updateLane = queue.effects), - null === updateLane - ? (queue.effects = [pendingQueue]) - : updateLane.push(pendingQueue)); + null !== firstBaseUpdate.callback && + ((workInProgress$jscomp$0.flags |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [firstBaseUpdate]) + : pendingQueue.push(firstBaseUpdate)); } else (updateEventTime = { eventTime: updateEventTime, - lane: updateLane, - tag: pendingQueue.tag, - payload: pendingQueue.payload, - callback: pendingQueue.callback, + lane: pendingQueue, + tag: firstBaseUpdate.tag, + payload: firstBaseUpdate.payload, + callback: firstBaseUpdate.callback, next: null }), null === current ? ((firstPendingUpdate = current = updateEventTime), - (lastPendingUpdate = newState)) + (lastPendingUpdate = currentLastBaseUpdate)) : (current = current.next = updateEventTime), - (lastBaseUpdate |= updateLane); - pendingQueue = pendingQueue.next; - if (null === pendingQueue) + (lastBaseUpdate |= pendingQueue); + firstBaseUpdate = firstBaseUpdate.next; + if (null === firstBaseUpdate) if (((pendingQueue = queue.shared.pending), null === pendingQueue)) break; else - (updateLane = pendingQueue), - (pendingQueue = updateLane.next), - (updateLane.next = null), - (queue.lastBaseUpdate = updateLane), + (firstBaseUpdate = pendingQueue.next), + (pendingQueue.next = null), + (queue.lastBaseUpdate = pendingQueue), (queue.shared.pending = null); } while (1); - null === current && (lastPendingUpdate = newState); + null === current && (lastPendingUpdate = currentLastBaseUpdate); queue.baseState = lastPendingUpdate; queue.firstBaseUpdate = firstPendingUpdate; queue.lastBaseUpdate = current; - props = queue.shared.interleaved; - if (null !== props) { - queue = props; - do (lastBaseUpdate |= queue.lane), (queue = queue.next); - while (queue !== props); - } else null === firstBaseUpdate && (queue.shared.lanes = 0); workInProgressRootSkippedLanes |= lastBaseUpdate; workInProgress$jscomp$0.lanes = lastBaseUpdate; - workInProgress$jscomp$0.memoizedState = newState; + workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2533,8 +2473,7 @@ var classComponentUpdater = { update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - payload = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== payload && entangleTransitions(payload, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; @@ -2545,8 +2484,7 @@ var classComponentUpdater = { update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - payload = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== payload && entangleTransitions(payload, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternals; @@ -2556,8 +2494,7 @@ var classComponentUpdater = { update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); enqueueUpdate(inst, update); - callback = scheduleUpdateOnFiber(inst, lane, eventTime); - null !== callback && entangleTransitions(callback, inst, lane); + scheduleUpdateOnFiber(inst, lane, eventTime); } }; function checkShouldComponentUpdate( @@ -2705,22 +2642,24 @@ function coerceRef(returnFiber, current, element) { } function throwOnInvalidObjectType(returnFiber, newChild) { if ("textarea" !== returnFiber.type) - throw ((returnFiber = Object.prototype.toString.call(newChild)), - Error( + throw Error( "Objects are not valid as a React child (found: " + - ("[object Object]" === returnFiber + ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : returnFiber) + + : newChild) + "). If you meant to render a collection of children, use an array instead." - )); + ); } function ChildReconciler(shouldTrackSideEffects) { function deleteChild(returnFiber, childToDelete) { if (shouldTrackSideEffects) { - var deletions = returnFiber.deletions; - null === deletions - ? ((returnFiber.deletions = [childToDelete]), (returnFiber.flags |= 16)) - : deletions.push(childToDelete); + var last = returnFiber.lastEffect; + null !== last + ? ((last.nextEffect = childToDelete), + (returnFiber.lastEffect = childToDelete)) + : (returnFiber.firstEffect = returnFiber.lastEffect = childToDelete); + childToDelete.nextEffect = null; + childToDelete.flags = 8; } } function deleteRemainingChildren(returnFiber, currentFirstChild) { @@ -2752,16 +2691,16 @@ function ChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.flags |= 2), lastPlacedIndex) + ? ((newFiber.flags = 2), lastPlacedIndex) : newIndex ); - newFiber.flags |= 2; + newFiber.flags = 2; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.flags |= 2); + (newFiber.flags = 2); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -2776,16 +2715,7 @@ function ChildReconciler(shouldTrackSideEffects) { return current; } function updateElement(returnFiber, current, element, lanes) { - var elementType = element.type; - if (elementType === REACT_FRAGMENT_TYPE) - return updateFragment( - returnFiber, - current, - element.props.children, - lanes, - element.key - ); - if (null !== current && current.elementType === elementType) + if (null !== current && current.elementType === element.type) return ( (lanes = useFiber(current, element.props)), (lanes.ref = coerceRef(returnFiber, current, element)), @@ -2899,7 +2829,15 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return newChild.key === key - ? updateElement(returnFiber, oldFiber, newChild, lanes) + ? newChild.type === REACT_FRAGMENT_TYPE + ? updateFragment( + returnFiber, + oldFiber, + newChild.props.children, + lanes, + key + ) + : updateElement(returnFiber, oldFiber, newChild, lanes) : null; case REACT_PORTAL_TYPE: return newChild.key === key @@ -2934,7 +2872,15 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updateElement(returnFiber, existingChildren, newChild, lanes) + newChild.type === REACT_FRAGMENT_TYPE + ? updateFragment( + returnFiber, + existingChildren, + newChild.props.children, + lanes, + newChild.key + ) + : updateElement(returnFiber, existingChildren, newChild, lanes) ); case REACT_PORTAL_TYPE: return ( @@ -3140,38 +3086,43 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) { - isObject = newChild.type; - if (isObject === REACT_FRAGMENT_TYPE) { - if (7 === isUnkeyedTopLevelFragment.tag) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props.children - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; - } - } else if (isUnkeyedTopLevelFragment.elementType === isObject) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props - ); - currentFirstChild.ref = coerceRef( - returnFiber, - isUnkeyedTopLevelFragment, - newChild - ); - currentFirstChild.return = returnFiber; - returnFiber = currentFirstChild; - break a; + switch (isUnkeyedTopLevelFragment.tag) { + case 7: + if (newChild.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props.children + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } + break; + default: + if ( + isUnkeyedTopLevelFragment.elementType === newChild.type + ) { + deleteRemainingChildren( + returnFiber, + isUnkeyedTopLevelFragment.sibling + ); + currentFirstChild = useFiber( + isUnkeyedTopLevelFragment, + newChild.props + ); + currentFirstChild.ref = coerceRef( + returnFiber, + isUnkeyedTopLevelFragment, + newChild + ); + currentFirstChild.return = returnFiber; + returnFiber = currentFirstChild; + break a; + } } deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); break; @@ -3349,7 +3300,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.flags & 128)) return node; + if (0 !== (node.flags & 64)) return node; } else if (null !== node.child) { node.child.return = node; node = node.child; @@ -3501,11 +3452,10 @@ function updateReducer(reducer) { queue.pending = null; } if (null !== baseQueue) { - pendingQueue = baseQueue.next; + baseQueue = baseQueue.next; current = current.baseState; - var newBaseQueueFirst = (baseFirst = null), - newBaseQueueLast = null, - update = pendingQueue; + var newBaseQueueLast = (baseFirst = pendingQueue = null), + update = baseQueue; do { var updateLane = update.lane; if ((renderLanes & updateLane) === updateLane) @@ -3530,33 +3480,22 @@ function updateReducer(reducer) { next: null }; null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (baseFirst = current)) + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) : (newBaseQueueLast = newBaseQueueLast.next = clone); currentlyRenderingFiber$1.lanes |= updateLane; workInProgressRootSkippedLanes |= updateLane; } update = update.next; - } while (null !== update && update !== pendingQueue); + } while (null !== update && update !== baseQueue); null === newBaseQueueLast - ? (baseFirst = current) - : (newBaseQueueLast.next = newBaseQueueFirst); + ? (pendingQueue = current) + : (newBaseQueueLast.next = baseFirst); objectIs(current, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = current; - hook.baseState = baseFirst; + hook.baseState = pendingQueue; hook.baseQueue = newBaseQueueLast; queue.lastRenderedState = current; } - reducer = queue.interleaved; - if (null !== reducer) { - baseQueue = reducer; - do - (pendingQueue = baseQueue.lane), - (currentlyRenderingFiber$1.lanes |= pendingQueue), - (workInProgressRootSkippedLanes |= pendingQueue), - (baseQueue = baseQueue.next); - while (baseQueue !== reducer); - } else null === baseQueue && (queue.lanes = 0); return [hook.memoizedState, queue.dispatch]; } function rerenderReducer(reducer) { @@ -3596,7 +3535,7 @@ function readFromUnsubcribedMutableSource(root, source, getSnapshot) { if (root) return getSnapshot(source._source); workInProgressSources.push(source); throw Error( - "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + "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) { @@ -3626,13 +3565,25 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { refs.getSnapshot = getSnapshot; refs.setSnapshot = setSnapshot; var maybeNewVersion = getVersion(source._source); - objectIs(version, maybeNewVersion) || - ((maybeNewVersion = getSnapshot(source._source)), + if (!objectIs(version, maybeNewVersion)) { + maybeNewVersion = getSnapshot(source._source); objectIs(snapshot, maybeNewVersion) || (setSnapshot(maybeNewVersion), (maybeNewVersion = requestUpdateLane(fiber)), - (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)), - markRootEntangled(root, root.mutableReadLanes)); + (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] ); @@ -3659,8 +3610,6 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { objectIs(memoizedState, subscribe)) || ((hook = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot @@ -3686,8 +3635,6 @@ function mountState(initialState) { hook.memoizedState = hook.baseState = initialState; initialState = hook.queue = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: basicStateReducer, lastRenderedState: initialState @@ -3736,7 +3683,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - hook.memoizedState = pushEffect(hookFlags, create, destroy, deps); + pushEffect(hookFlags, create, destroy, deps); return; } } @@ -3744,10 +3691,10 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(132096, 4, create, deps); + return mountEffectImpl(516, 4, create, deps); } function updateEffect(create, deps) { - return updateEffectImpl(1024, 4, create, deps); + return updateEffectImpl(516, 4, create, deps); } function updateLayoutEffect(create, deps) { return updateEffectImpl(4, 2, create, deps); @@ -3832,55 +3779,33 @@ function dispatchAction(fiber, queue, action) { eagerState: null, next: null }, - alternate = fiber.alternate; + pending = queue.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; + pending = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || - (null !== alternate && alternate === currentlyRenderingFiber$1) + (null !== pending && pending === currentlyRenderingFiber$1) ) - (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0), - (lane = queue.pending), - null === lane - ? (update.next = update) - : ((update.next = lane.next), (lane.next = update)), - (queue.pending = update); + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; else { - if (null !== workInProgressRoot && 0 !== (fiber.mode & 1)) { - var interleaved = queue.interleaved; - null === interleaved - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [queue]) - : interleavedQueues.push(queue)) - : ((update.next = interleaved.next), (interleaved.next = update)); - queue.interleaved = update; - } else - (interleaved = queue.pending), - null === interleaved - ? (update.next = update) - : ((update.next = interleaved.next), (interleaved.next = update)), - (queue.pending = update); if ( 0 === fiber.lanes && - (null === alternate || 0 === alternate.lanes) && - ((alternate = queue.lastRenderedReducer), null !== alternate) + (null === pending || 0 === pending.lanes) && + ((pending = queue.lastRenderedReducer), null !== pending) ) try { var currentState = queue.lastRenderedState, - eagerState = alternate(currentState, action); - update.eagerReducer = alternate; + eagerState = pending(currentState, action); + update.eagerReducer = pending; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - update = scheduleUpdateOnFiber(fiber, lane, eventTime); - 0 !== (lane & 8388096) && - null !== update && - ((fiber = queue.lanes), - (fiber &= update.pendingLanes), - (lane |= fiber), - (queue.lanes = lane), - markRootEntangled(update, lane)); + scheduleUpdateOnFiber(fiber, lane, eventTime); } } var ContextOnlyDispatcher = { @@ -3937,8 +3862,6 @@ var ContextOnlyDispatcher = { hook.memoizedState = hook.baseState = initialArg; reducer = hook.queue = { pending: null, - interleaved: null, - lanes: 0, dispatch: null, lastRenderedReducer: reducer, lastRenderedState: initialArg @@ -4129,7 +4052,7 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4205,15 +4128,14 @@ function updateSimpleMemoComponent( null !== current && shallowEqual(current.memoizedProps, nextProps) && current.ref === workInProgress.ref - ) { - didReceiveUpdate = !1; - if (0 === (renderLanes & updateLanes)) + ) + if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) + 0 !== (current.flags & 32768) && (didReceiveUpdate = !0); + else return ( (workInProgress.lanes = current.lanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); - 0 !== (current.flags & 65536) && (didReceiveUpdate = !0); - } return updateFunctionComponent( current, workInProgress, @@ -4230,40 +4152,31 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { "hidden" === nextProps.mode || "unstable-defer-without-hiding" === nextProps.mode ) - if (0 === (workInProgress.mode & 2)) - (workInProgress.memoizedState = { baseLanes: 0, cachePool: null }), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= renderLanes); - else { - if (0 === (renderLanes & 1073741824)) - return ( - (current = - null !== prevState - ? prevState.baseLanes | renderLanes - : renderLanes), - markSpawnedWork(1073741824), - (workInProgress.lanes = workInProgress.childLanes = 1073741824), - (workInProgress.memoizedState = { - baseLanes: current, - cachePool: null - }), - (workInProgress.updateQueue = null), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= current), - null + 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 ); - workInProgress.memoizedState = { baseLanes: 0, cachePool: null }; - nextProps = null !== prevState ? prevState.baseLanes : renderLanes; - push(subtreeRenderLanesCursor, subtreeRenderLanes); - subtreeRenderLanes |= nextProps; - } + 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), - push(subtreeRenderLanesCursor, subtreeRenderLanes), - (subtreeRenderLanes |= nextProps); + pushRenderLanes(workInProgress, nextProps); reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -4273,7 +4186,7 @@ function markRef(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.flags |= 256; + workInProgress.flags |= 128; } function updateFunctionComponent( current, @@ -4298,7 +4211,7 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -517), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4473,7 +4386,7 @@ function updateClassComponent( "function" === typeof instance.componentDidUpdate && (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.flags |= 512)) + (workInProgress.flags |= 256)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || @@ -4481,7 +4394,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -4495,7 +4408,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 256), (nextProps = !1)); } return finishClassComponent( @@ -4516,7 +4429,7 @@ function finishClassComponent( renderLanes ) { markRef(current, workInProgress); - var didCaptureError = 0 !== (workInProgress.flags & 128); + var didCaptureError = 0 !== (workInProgress.flags & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), @@ -4564,21 +4477,18 @@ function pushHostRootContext(workInProgress) { pushHostContainer(workInProgress, root.containerInfo); } var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; -function mountSuspenseOffscreenState(renderLanes) { - return { baseLanes: renderLanes, cachePool: null }; -} function updateSuspenseComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, showFallback = !1, JSCompiler_temp; - (JSCompiler_temp = 0 !== (workInProgress.flags & 128)) || + (JSCompiler_temp = 0 !== (workInProgress.flags & 64)) || (JSCompiler_temp = null !== current && null === current.memoizedState ? !1 : 0 !== (suspenseContext & 2)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.flags &= -129)) + ? ((showFallback = !0), (workInProgress.flags &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || @@ -4595,9 +4505,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext, renderLanes )), - (workInProgress.child.memoizedState = mountSuspenseOffscreenState( - renderLanes - )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), current ); @@ -4609,12 +4517,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { suspenseContext, renderLanes )), - (workInProgress.child.memoizedState = mountSuspenseOffscreenState( - renderLanes - )), + (workInProgress.child.memoizedState = { baseLanes: renderLanes }), (workInProgress.memoizedState = SUSPENDED_MARKER), - (workInProgress.lanes = 8388608), - markSpawnedWork(8388608), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432), current ); renderLanes = createFiberFromOffscreen( @@ -4640,11 +4546,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (suspenseContext = current.child.memoizedState), (showFallback.memoizedState = null === suspenseContext - ? mountSuspenseOffscreenState(renderLanes) - : { - baseLanes: suspenseContext.baseLanes | renderLanes, - cachePool: null - }), + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps @@ -4671,11 +4574,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (suspenseContext = current.child.memoizedState), (showFallback.memoizedState = null === suspenseContext - ? mountSuspenseOffscreenState(renderLanes) - : { - baseLanes: suspenseContext.baseLanes | renderLanes, - cachePool: null - }), + ? { baseLanes: renderLanes } + : { baseLanes: suspenseContext.baseLanes | renderLanes }), (showFallback.childLanes = current.childLanes & ~renderLanes), (workInProgress.memoizedState = SUSPENDED_MARKER), nextProps @@ -4698,10 +4598,10 @@ function mountSuspenseFallbackChildren( var mode = workInProgress.mode, progressedPrimaryFragment = workInProgress.child; primaryChildren = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 1) && null !== progressedPrimaryFragment + 0 === (mode & 2) && null !== progressedPrimaryFragment ? ((progressedPrimaryFragment.childLanes = 0), (progressedPrimaryFragment.pendingProps = primaryChildren), - workInProgress.mode & 4 && + workInProgress.mode & 8 && ((progressedPrimaryFragment.actualDuration = 0), (progressedPrimaryFragment.actualStartTime = -1), (progressedPrimaryFragment.selfBaseDuration = 0), @@ -4736,14 +4636,13 @@ function updateSuspensePrimaryChildren( mode: "visible", children: primaryChildren }); - 0 === (workInProgress.mode & 1) && (primaryChildren.lanes = renderLanes); + 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); primaryChildren.return = workInProgress; primaryChildren.sibling = null; null !== current && - ((renderLanes = workInProgress.deletions), - null === renderLanes - ? ((workInProgress.deletions = [current]), (workInProgress.flags |= 16)) - : renderLanes.push(current)); + ((current.nextEffect = null), + (current.flags = 8), + (workInProgress.firstEffect = workInProgress.lastEffect = current)); return (workInProgress.child = primaryChildren); } function updateSuspenseFallbackChildren( @@ -4753,27 +4652,33 @@ function updateSuspenseFallbackChildren( fallbackChildren, renderLanes ) { - var mode = workInProgress.mode; - current = current.child; - var currentFallbackChildFragment = current.sibling, - primaryChildProps = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 1) && workInProgress.child !== current + 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 & 4 && + workInProgress.mode & 8 && ((primaryChildren.actualDuration = 0), (primaryChildren.actualStartTime = -1), - (primaryChildren.selfBaseDuration = current.selfBaseDuration), - (primaryChildren.treeBaseDuration = current.treeBaseDuration)), - (workInProgress.deletions = null)) - : ((primaryChildren = createWorkInProgress(current, primaryChildProps)), - (primaryChildren.subtreeFlags = current.subtreeFlags & 131072)); - null !== currentFallbackChildFragment - ? (fallbackChildren = createWorkInProgress( - currentFallbackChildFragment, - fallbackChildren - )) + (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, @@ -4798,7 +4703,8 @@ function initSuspenseListRenderState( isBackwards, tail, lastContentRow, - tailMode + tailMode, + lastEffectBeforeRendering ) { var renderState = workInProgress.memoizedState; null === renderState @@ -4808,14 +4714,16 @@ function initSuspenseListRenderState( renderingStartTime: 0, last: lastContentRow, tail: tail, - tailMode: tailMode + tailMode: tailMode, + lastEffect: lastEffectBeforeRendering }) : ((renderState.isBackwards = isBackwards), (renderState.rendering = null), (renderState.renderingStartTime = 0), (renderState.last = lastContentRow), (renderState.tail = tail), - (renderState.tailMode = tailMode)); + (renderState.tailMode = tailMode), + (renderState.lastEffect = lastEffectBeforeRendering)); } function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, @@ -4824,9 +4732,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { reconcileChildren(current, workInProgress, nextProps.children, renderLanes); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) - (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 128); + (nextProps = (nextProps & 1) | 2), (workInProgress.flags |= 64); else { - if (null !== current && 0 !== (current.flags & 128)) + if (null !== current && 0 !== (current.flags & 64)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && @@ -4849,7 +4757,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { nextProps &= 1; } push(suspenseStackCursor, nextProps); - if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null; + if (0 === (workInProgress.mode & 2)) workInProgress.memoizedState = null; else switch (revealOrder) { case "forwards": @@ -4870,7 +4778,8 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { !1, revealOrder, renderLanes, - tailMode + tailMode, + workInProgress.lastEffect ); break; case "backwards": @@ -4892,11 +4801,19 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { !0, renderLanes, null, - tailMode + tailMode, + workInProgress.lastEffect ); break; case "together": - initSuspenseListRenderState(workInProgress, !1, null, null, void 0); + initSuspenseListRenderState( + workInProgress, + !1, + null, + null, + void 0, + workInProgress.lastEffect + ); break; default: workInProgress.memoizedState = null; @@ -4907,23 +4824,25 @@ function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { null !== current && (workInProgress.dependencies = current.dependencies); profilerStartTime = -1; workInProgressRootSkippedLanes |= workInProgress.lanes; - if (0 === (renderLanes & workInProgress.childLanes)) return null; - 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; + 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, @@ -4970,76 +4889,16 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$63 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$63 = lastTailNode), + for (var lastTailNode$65 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$65 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$63 + null === lastTailNode$65 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$63.sibling = null); + : (lastTailNode$65.sibling = null); } } -function bubbleProperties(completedWork) { - var didBailout = - null !== completedWork.alternate && - completedWork.alternate.child === completedWork.child, - newChildLanes = 0, - subtreeFlags = 0; - if (didBailout) - if (0 !== (completedWork.mode & 4)) { - for ( - var treeBaseDuration$65 = completedWork.selfBaseDuration, - child$66 = completedWork.child; - null !== child$66; - - ) - (newChildLanes |= child$66.lanes | child$66.childLanes), - (subtreeFlags |= child$66.subtreeFlags & 131072), - (subtreeFlags |= child$66.flags & 131072), - (treeBaseDuration$65 += child$66.treeBaseDuration), - (child$66 = child$66.sibling); - completedWork.treeBaseDuration = treeBaseDuration$65; - } else - for ( - treeBaseDuration$65 = completedWork.child; - null !== treeBaseDuration$65; - - ) - (newChildLanes |= - treeBaseDuration$65.lanes | treeBaseDuration$65.childLanes), - (subtreeFlags |= treeBaseDuration$65.subtreeFlags & 131072), - (subtreeFlags |= treeBaseDuration$65.flags & 131072), - (treeBaseDuration$65.return = completedWork), - (treeBaseDuration$65 = treeBaseDuration$65.sibling); - else if (0 !== (completedWork.mode & 4)) { - treeBaseDuration$65 = completedWork.actualDuration; - child$66 = completedWork.selfBaseDuration; - for (var child = completedWork.child; null !== child; ) - (newChildLanes |= child.lanes | child.childLanes), - (subtreeFlags |= child.subtreeFlags), - (subtreeFlags |= child.flags), - (treeBaseDuration$65 += child.actualDuration), - (child$66 += child.treeBaseDuration), - (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$65; - completedWork.treeBaseDuration = child$66; - } else - for ( - treeBaseDuration$65 = completedWork.child; - null !== treeBaseDuration$65; - - ) - (newChildLanes |= - treeBaseDuration$65.lanes | treeBaseDuration$65.childLanes), - (subtreeFlags |= treeBaseDuration$65.subtreeFlags), - (subtreeFlags |= treeBaseDuration$65.flags), - (treeBaseDuration$65.return = completedWork), - (treeBaseDuration$65 = treeBaseDuration$65.sibling); - completedWork.subtreeFlags |= subtreeFlags; - completedWork.childLanes = newChildLanes; - return didBailout; -} function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { @@ -5053,80 +4912,76 @@ function completeWork(current, workInProgress, renderLanes) { case 12: case 9: case 14: - return bubbleProperties(workInProgress), null; + return null; case 1: - return ( - isContextProvider(workInProgress.type) && popContext(), - bubbleProperties(workInProgress), - null - ); + return isContextProvider(workInProgress.type) && popContext(), null; case 3: return ( - (newProps = workInProgress.stateNode), popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), resetWorkInProgressVersions(), + (newProps = workInProgress.stateNode), newProps.pendingContext && ((newProps.context = newProps.pendingContext), (newProps.pendingContext = null)), (null !== current && null !== current.child) || newProps.hydrate || - (workInProgress.flags |= 512), - updateHostContainer(current, workInProgress), - bubbleProperties(workInProgress), + (workInProgress.flags |= 256), + updateHostContainer(workInProgress), null ); case 5: popHostContext(workInProgress); - renderLanes = requiredContext(rootInstanceStackCursor.current); - var type = workInProgress.type; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ); + renderLanes = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - type, + renderLanes, newProps, - renderLanes + rootContainerInstance ), - current.ref !== workInProgress.ref && (workInProgress.flags |= 256); + current.ref !== workInProgress.ref && (workInProgress.flags |= 128); else { if (!newProps) { if (null === workInProgress.stateNode) throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); - bubbleProperties(workInProgress); return null; } requiredContext(contextStackCursor$1.current); current = allocateTag(); - type = getViewConfigForType(type); + renderLanes = getViewConfigForType(renderLanes); var updatePayload = diffProperties( null, emptyObject, newProps, - type.validAttributes + renderLanes.validAttributes ); ReactNativePrivateInterface.UIManager.createView( current, - type.uiViewClassName, - renderLanes, + renderLanes.uiViewClassName, + rootContainerInstance, updatePayload ); - renderLanes = new ReactNativeFiberHostComponent( + rootContainerInstance = new ReactNativeFiberHostComponent( current, - type, + renderLanes, workInProgress ); instanceCache.set(current, workInProgress); instanceProps.set(current, newProps); - appendAllChildren(renderLanes, workInProgress, !1, !1); - workInProgress.stateNode = renderLanes; - finalizeInitialChildren(renderLanes) && (workInProgress.flags |= 4); - null !== workInProgress.ref && (workInProgress.flags |= 256); + appendAllChildren(rootContainerInstance, workInProgress, !1, !1); + workInProgress.stateNode = rootContainerInstance; + finalizeInitialChildren(rootContainerInstance) && + (workInProgress.flags |= 4); + null !== workInProgress.ref && (workInProgress.flags |= 128); } - bubbleProperties(workInProgress); return null; case 6: if (current && null != workInProgress.stateNode) @@ -5146,32 +5001,32 @@ function completeWork(current, workInProgress, renderLanes) { throw Error( "Text strings must be rendered within a component." ); - renderLanes = allocateTag(); + rootContainerInstance = allocateTag(); ReactNativePrivateInterface.UIManager.createView( - renderLanes, + rootContainerInstance, "RCTRawText", current, { text: newProps } ); - instanceCache.set(renderLanes, workInProgress); - workInProgress.stateNode = renderLanes; + instanceCache.set(rootContainerInstance, workInProgress); + workInProgress.stateNode = rootContainerInstance; } - bubbleProperties(workInProgress); return null; case 13: pop(suspenseStackCursor); newProps = workInProgress.memoizedState; - if (0 !== (workInProgress.flags & 128)) + if (0 !== (workInProgress.flags & 64)) return ( (workInProgress.lanes = renderLanes), - 0 !== (workInProgress.mode & 4) && + 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress ); newProps = null !== newProps; - renderLanes = !1; - null !== current && (renderLanes = null !== current.memoizedState); - if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1)) + rootContainerInstance = !1; + null !== current && + (rootContainerInstance = null !== current.memoizedState); + if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || @@ -5186,100 +5041,89 @@ function completeWork(current, workInProgress, renderLanes) { ) workInProgressRootExitStatus = 4; null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootUpdatedLanes & 268435455)) || + (0 === (workInProgressRootSkippedLanes & 134217727) && + 0 === (workInProgressRootUpdatedLanes & 134217727)) || markRootSuspended$1( workInProgressRoot, workInProgressRootRenderLanes ); } - if (newProps || renderLanes) workInProgress.flags |= 4; - bubbleProperties(workInProgress); - 0 !== (workInProgress.mode & 4) && - newProps && - ((current = workInProgress.child), - null !== current && - (workInProgress.treeBaseDuration -= current.treeBaseDuration)); + if (newProps || rootContainerInstance) workInProgress.flags |= 4; return null; case 4: - return ( - popHostContainer(), - updateHostContainer(current, workInProgress), - bubbleProperties(workInProgress), - null - ); + return popHostContainer(), updateHostContainer(workInProgress), null; case 10: - return ( - popProvider(workInProgress.type._context), - bubbleProperties(workInProgress), - null - ); + return popProvider(workInProgress), null; case 17: - return ( - isContextProvider(workInProgress.type) && popContext(), - bubbleProperties(workInProgress), - null - ); + return isContextProvider(workInProgress.type) && popContext(), null; case 19: pop(suspenseStackCursor); - type = workInProgress.memoizedState; - if (null === type) return bubbleProperties(workInProgress), null; - newProps = 0 !== (workInProgress.flags & 128); - updatePayload = type.rendering; + newProps = workInProgress.memoizedState; + if (null === newProps) return null; + rootContainerInstance = 0 !== (workInProgress.flags & 64); + updatePayload = newProps.rendering; if (null === updatePayload) - if (newProps) cutOffTailIfNeeded(type, !1); + if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || - (null !== current && 0 !== (current.flags & 128)) + (null !== current && 0 !== (current.flags & 64)) ) for (current = workInProgress.child; null !== current; ) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { - workInProgress.flags |= 128; - cutOffTailIfNeeded(type, !1); + workInProgress.flags |= 64; + cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; null !== current && ((workInProgress.updateQueue = current), (workInProgress.flags |= 4)); - workInProgress.subtreeFlags = 0; + null === newProps.lastEffect && + (workInProgress.firstEffect = null); + workInProgress.lastEffect = newProps.lastEffect; current = renderLanes; for (newProps = workInProgress.child; null !== newProps; ) - (renderLanes = newProps), + (rootContainerInstance = newProps), (updatePayload = current), - (renderLanes.flags &= 131074), - (type = renderLanes.alternate), - null === type - ? ((renderLanes.childLanes = 0), - (renderLanes.lanes = updatePayload), - (renderLanes.child = null), - (renderLanes.subtreeFlags = 0), - (renderLanes.memoizedProps = null), - (renderLanes.memoizedState = null), - (renderLanes.updateQueue = null), - (renderLanes.dependencies = null), - (renderLanes.stateNode = null), - (renderLanes.selfBaseDuration = 0), - (renderLanes.treeBaseDuration = 0)) - : ((renderLanes.childLanes = type.childLanes), - (renderLanes.lanes = type.lanes), - (renderLanes.child = type.child), - (renderLanes.subtreeFlags = type.subtreeFlags), - (renderLanes.deletions = null), - (renderLanes.memoizedProps = type.memoizedProps), - (renderLanes.memoizedState = type.memoizedState), - (renderLanes.updateQueue = type.updateQueue), - (renderLanes.type = type.type), - (updatePayload = type.dependencies), - (renderLanes.dependencies = + (rootContainerInstance.flags &= 2), + (rootContainerInstance.nextEffect = null), + (rootContainerInstance.firstEffect = null), + (rootContainerInstance.lastEffect = null), + (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.childLanes = + renderLanes.childLanes), + (rootContainerInstance.lanes = renderLanes.lanes), + (rootContainerInstance.child = renderLanes.child), + (rootContainerInstance.memoizedProps = + renderLanes.memoizedProps), + (rootContainerInstance.memoizedState = + renderLanes.memoizedState), + (rootContainerInstance.updateQueue = + renderLanes.updateQueue), + (rootContainerInstance.type = renderLanes.type), + (updatePayload = renderLanes.dependencies), + (rootContainerInstance.dependencies = null === updatePayload ? null : { lanes: updatePayload.lanes, firstContext: updatePayload.firstContext }), - (renderLanes.selfBaseDuration = type.selfBaseDuration), - (renderLanes.treeBaseDuration = type.treeBaseDuration)), + (rootContainerInstance.selfBaseDuration = + renderLanes.selfBaseDuration), + (rootContainerInstance.treeBaseDuration = + renderLanes.treeBaseDuration)), (newProps = newProps.sibling); push( suspenseStackCursor, @@ -5289,76 +5133,80 @@ function completeWork(current, workInProgress, renderLanes) { } current = current.sibling; } - null !== type.tail && + null !== newProps.tail && now() > workInProgressRootRenderTargetTime && - ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), - (workInProgress.lanes = 8388608), - markSpawnedWork(8388608)); + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); } else { - if (!newProps) + if (!rootContainerInstance) if ( ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( - ((workInProgress.flags |= 128), - (newProps = !0), + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), (current = current.updateQueue), null !== current && ((workInProgress.updateQueue = current), (workInProgress.flags |= 4)), - cutOffTailIfNeeded(type, !0), - null === type.tail && - "hidden" === type.tailMode && + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "hidden" === newProps.tailMode && !updatePayload.alternate) ) - return bubbleProperties(workInProgress), null; + return ( + (workInProgress = workInProgress.lastEffect = + newProps.lastEffect), + null !== workInProgress && (workInProgress.nextEffect = null), + null + ); } else - 2 * now() - type.renderingStartTime > + 2 * now() - newProps.renderingStartTime > workInProgressRootRenderTargetTime && 1073741824 !== renderLanes && - ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), - (workInProgress.lanes = 8388608), - markSpawnedWork(8388608)); - type.isBackwards + ((workInProgress.flags |= 64), + (rootContainerInstance = !0), + cutOffTailIfNeeded(newProps, !1), + (workInProgress.lanes = 33554432), + markSpawnedWork(33554432)); + newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) - : ((current = type.last), + : ((current = newProps.last), null !== current ? (current.sibling = updatePayload) : (workInProgress.child = updatePayload), - (type.last = updatePayload)); + (newProps.last = updatePayload)); } - if (null !== type.tail) - return ( - (workInProgress = type.tail), - (type.rendering = workInProgress), - (type.tail = workInProgress.sibling), - (type.renderingStartTime = now()), - (workInProgress.sibling = null), - (current = suspenseStackCursor.current), - push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1), - workInProgress - ); - bubbleProperties(workInProgress); - return null; + return null !== newProps.tail + ? ((current = newProps.tail), + (newProps.rendering = current), + (newProps.tail = current.sibling), + (newProps.lastEffect = workInProgress.lastEffect), + (newProps.renderingStartTime = now()), + (current.sibling = null), + (workInProgress = suspenseStackCursor.current), + push( + suspenseStackCursor, + rootContainerInstance + ? (workInProgress & 1) | 2 + : workInProgress & 1 + ), + current) + : null; case 22: case 23: return ( popRenderLanes(), - (renderLanes = null !== workInProgress.memoizedState), null !== current && - (null !== current.memoizedState) !== renderLanes && + (null !== current.memoizedState) !== + (null !== workInProgress.memoizedState) && "unstable-defer-without-hiding" !== newProps.mode && (workInProgress.flags |= 4), - (renderLanes && - 0 === (subtreeRenderLanes & 1073741824) && - 0 !== (workInProgress.mode & 2)) || - bubbleProperties(workInProgress), null ); } @@ -5373,9 +5221,9 @@ function unwindWork(workInProgress) { case 1: isContextProvider(workInProgress.type) && popContext(); var flags = workInProgress.flags; - return flags & 16384 - ? ((workInProgress.flags = (flags & -16385) | 128), - 0 !== (workInProgress.mode & 4) && + return flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), + 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress) : null; @@ -5385,11 +5233,11 @@ function unwindWork(workInProgress) { pop(contextStackCursor); resetWorkInProgressVersions(); flags = workInProgress.flags; - if (0 !== (flags & 128)) + 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.flags = (flags & -16385) | 128; + workInProgress.flags = (flags & -8193) | 64; return workInProgress; case 5: return popHostContext(workInProgress), null; @@ -5397,9 +5245,9 @@ function unwindWork(workInProgress) { return ( pop(suspenseStackCursor), (flags = workInProgress.flags), - flags & 16384 - ? ((workInProgress.flags = (flags & -16385) | 128), - 0 !== (workInProgress.mode & 4) && + flags & 8192 + ? ((workInProgress.flags = (flags & -8193) | 64), + 0 !== (workInProgress.mode & 8) && transferActualDuration(workInProgress), workInProgress) : null @@ -5409,12 +5257,10 @@ function unwindWork(workInProgress) { case 4: return popHostContainer(), null; case 10: - return popProvider(workInProgress.type._context), null; + return popProvider(workInProgress), null; case 22: case 23: return popRenderLanes(), null; - case 24: - return null; default: return null; } @@ -5487,150 +5333,152 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { }); return lane; } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set, - nextEffect = null; -function safelyDetachRef(current, nearestMountedAncestor) { +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) if ("function" === typeof ref) try { ref(null); } catch (refError) { - captureCommitPhaseError(current, nearestMountedAncestor, refError); + captureCommitPhaseError(current, refError); } else ref.current = null; } -var focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; -function commitBeforeMutationEffects(root, firstChild) { - focusedInstanceHandle = null; - for (nextEffect = firstChild; null !== nextEffect; ) { - root = nextEffect; - firstChild = root.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) - doesFiberContain(firstChild[i], focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - firstChild = root.child; - if (0 !== (root.subtreeFlags & 516) && null !== firstChild) - (firstChild.return = root), (nextEffect = firstChild); - else - for (; null !== nextEffect; ) { - root = nextEffect; - try { - var current = root.alternate, - flags = root.flags; - if ( - !shouldFireAfterActiveInstanceBlur && - null !== focusedInstanceHandle - ) { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === root.tag)) - a: { - if (null !== current) { - var oldState = current.memoizedState; - if (null === oldState || null !== oldState.dehydrated) { - var newState = root.memoizedState; - JSCompiler_temp = - null !== newState && null === newState.dehydrated; - break a; - } - } - JSCompiler_temp = !1; - } - JSCompiler_temp && - doesFiberContain(root, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0); - } - if (0 !== (flags & 512)) - switch (root.tag) { - case 0: - case 11: - case 15: - break; - case 1: - if (null !== current) { - var prevProps = current.memoizedProps, - prevState = current.memoizedState, - instance = root.stateNode, - snapshot = instance.getSnapshotBeforeUpdate( - root.elementType === root.type - ? prevProps - : resolveDefaultProps(root.type, prevProps), - prevState - ); - instance.__reactInternalSnapshotBeforeUpdate = snapshot; - } - break; - case 3: - break; - case 5: - case 6: - case 4: - case 17: - break; - default: - 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." - ); - } - } catch (error) { - captureCommitPhaseError(root, root.return, error); - } - firstChild = root.sibling; - if (null !== firstChild) { - firstChild.return = root.return; - nextEffect = firstChild; - break; - } - nextEffect = root.return; +function commitBeforeMutationLifeCycles(current, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + return; + case 1: + if (finishedWork.flags & 256 && null !== current) { + var prevProps = current.memoizedProps, + prevState = current.memoizedState; + current = finishedWork.stateNode; + finishedWork = current.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); + current.__reactInternalSnapshotBeforeUpdate = finishedWork; } + return; + case 3: + return; + case 5: + case 6: + case 4: + case 17: + return; } - current = shouldFireAfterActiveInstanceBlur; - shouldFireAfterActiveInstanceBlur = !1; - focusedInstanceHandle = null; - return current; + 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 commitHookEffectListUnmount( - flags, - finishedWork, - nearestMountedAncestor$jscomp$0 -) { - var updateQueue = finishedWork.updateQueue; - updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; - if (null !== updateQueue) { - var effect = (updateQueue = updateQueue.next); - do { - if ((effect.tag & flags) === flags) { - var destroy = effect.destroy; - effect.destroy = void 0; - if (void 0 !== destroy) { - var current = finishedWork, - nearestMountedAncestor = nearestMountedAncestor$jscomp$0; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(current, nearestMountedAncestor, error); +function commitLifeCycles(finishedRoot, current, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + 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); } - effect = effect.next; - } while (effect !== updateQueue); - } -} -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$84 = effect.create; - effect.destroy = create$84(); + 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); } - effect = effect.next; - } while (effect !== finishedWork); + return; + case 1: + finishedRoot = finishedWork.stateNode; + 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); + return; + case 3: + current = finishedWork.updateQueue; + if (null !== current) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 5: + finishedRoot = finishedWork.child.stateNode; + break; + case 1: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue(finishedWork, current, finishedRoot); + } + return; + case 5: + return; + case 6: + return; + case 4: + return; + case 12: + 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, + _effect, + finishedRoot.memoizedInteractions + ); + return; + case 13: + return; + case 19: + case 17: + case 20: + case 21: + case 22: + case 23: + 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 hideOrUnhideAllChildren(finishedWork, isHidden) { for (var node = finishedWork; ; ) { @@ -5690,7 +5538,7 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { node = node.sibling; } } -function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) { +function commitUnmount(finishedRoot, current) { if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount) try { injectedHook.onCommitFiberUnmount(rendererID, current); @@ -5707,24 +5555,26 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) { ) { var effect = (finishedRoot = finishedRoot.next); do { - var _effect = effect, - destroy = _effect.destroy; - _effect = _effect.tag; - if (void 0 !== destroy && 0 !== (_effect & 2)) { - _effect = current; - var nearestMountedAncestor = nearestMountedAncestor$jscomp$0; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(_effect, nearestMountedAncestor, error); + 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 !== finishedRoot); } break; case 1: - safelyDetachRef(current, nearestMountedAncestor$jscomp$0); + safelyDetachRef(current); finishedRoot = current.stateNode; if ("function" === typeof finishedRoot.componentWillUnmount) try { @@ -5732,34 +5582,26 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) { (finishedRoot.state = current.memoizedState), finishedRoot.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError( - current, - nearestMountedAncestor$jscomp$0, - unmountError - ); + captureCommitPhaseError(current, unmountError); } break; case 5: - safelyDetachRef(current, nearestMountedAncestor$jscomp$0); + safelyDetachRef(current); break; case 4: - unmountHostComponents( - finishedRoot, - current, - nearestMountedAncestor$jscomp$0 - ); + unmountHostComponents(finishedRoot, current); } } -function detachFiberAfterEffects(fiber) { +function detachFiberMutation(fiber) { fiber.alternate = null; fiber.child = null; - fiber.deletions = null; fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; fiber.memoizedProps = null; fiber.memoizedState = null; fiber.pendingProps = null; - fiber.sibling = null; - fiber.stateNode = null; + fiber.return = null; fiber.updateQueue = null; } function isHostParent(fiber) { @@ -5794,7 +5636,7 @@ function commitPlacement(finishedWork) { "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } - parentFiber.flags & 32 && (parentFiber.flags &= -33); + parentFiber.flags & 16 && (parentFiber.flags &= -17); a: b: for (parentFiber = finishedWork; ; ) { for (; null === parentFiber.sibling; ) { if (null === parentFiber.return || isHostParent(parentFiber.return)) { @@ -5910,11 +5752,7 @@ function insertOrAppendPlacementNode(node, before, parent) { ) insertOrAppendPlacementNode(node, before, parent), (node = node.sibling); } -function unmountHostComponents( - finishedRoot$jscomp$0, - current, - nearestMountedAncestor$jscomp$0 -) { +function unmountHostComponents(finishedRoot$jscomp$0, current) { for ( var node = current, currentParentIsValid = !1, @@ -5952,13 +5790,12 @@ function unmountHostComponents( a: for ( var finishedRoot = finishedRoot$jscomp$0, root = node, - nearestMountedAncestor = nearestMountedAncestor$jscomp$0, node$jscomp$0 = root; ; ) if ( - (commitUnmount(finishedRoot, node$jscomp$0, nearestMountedAncestor), + (commitUnmount(finishedRoot, node$jscomp$0), null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), @@ -5985,18 +5822,18 @@ function unmountHostComponents( [0] )) : ((finishedRoot = currentParent), - (nearestMountedAncestor = node.stateNode), - recursivelyUncacheFiberNode(nearestMountedAncestor), + (node$jscomp$0 = node.stateNode), + recursivelyUncacheFiberNode(node$jscomp$0), (root = finishedRoot._children), - (nearestMountedAncestor = root.indexOf(nearestMountedAncestor)), - root.splice(nearestMountedAncestor, 1), + (node$jscomp$0 = root.indexOf(node$jscomp$0)), + root.splice(node$jscomp$0, 1), ReactNativePrivateInterface.UIManager.manageChildren( finishedRoot._nativeTag, [], [], [], [], - [nearestMountedAncestor] + [node$jscomp$0] )); } else if (4 === node.tag) { if (null !== node.child) { @@ -6007,12 +5844,7 @@ function unmountHostComponents( continue; } } else if ( - (commitUnmount( - finishedRoot$jscomp$0, - node, - nearestMountedAncestor$jscomp$0 - ), - null !== node.child) + (commitUnmount(finishedRoot$jscomp$0, node), null !== node.child) ) { node.child.return = node; node = node.child; @@ -6034,31 +5866,42 @@ function commitWork(current, finishedWork) { case 11: case 14: case 15: - commitHookEffectListUnmount(3, finishedWork, finishedWork.return); + 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; @@ -6117,210 +5960,13 @@ function attachSuspenseRetryListeners(finishedWork) { }); } } -function commitMutationEffects(root, renderPriorityLevel, firstChild) { - for (nextEffect = firstChild; null !== nextEffect; ) { - renderPriorityLevel = nextEffect; - firstChild = renderPriorityLevel.deletions; - if (null !== firstChild) - for (var i = 0; i < firstChild.length; i++) { - var childToDelete = firstChild[i]; - try { - unmountHostComponents(root, childToDelete, renderPriorityLevel); - var alternate = childToDelete.alternate; - childToDelete.return = null; - null !== alternate && (alternate.return = null); - } catch (error) { - captureCommitPhaseError(childToDelete, renderPriorityLevel, error); - } - } - firstChild = renderPriorityLevel.child; - if (0 !== (renderPriorityLevel.subtreeFlags & 6454) && null !== firstChild) - (firstChild.return = renderPriorityLevel), (nextEffect = firstChild); - else - for (; null !== nextEffect; ) { - renderPriorityLevel = nextEffect; - try { - var flags = renderPriorityLevel.flags; - if (flags & 256) { - var current = renderPriorityLevel.alternate; - if (null !== current) { - var currentRef = current.ref; - null !== currentRef && - ("function" === typeof currentRef - ? currentRef(null) - : (currentRef.current = null)); - } - } - switch (flags & 2054) { - case 2: - commitPlacement(renderPriorityLevel); - renderPriorityLevel.flags &= -3; - break; - case 6: - commitPlacement(renderPriorityLevel); - renderPriorityLevel.flags &= -3; - commitWork(renderPriorityLevel.alternate, renderPriorityLevel); - break; - case 2048: - renderPriorityLevel.flags &= -2049; - break; - case 2052: - renderPriorityLevel.flags &= -2049; - commitWork(renderPriorityLevel.alternate, renderPriorityLevel); - break; - case 4: - commitWork(renderPriorityLevel.alternate, renderPriorityLevel); - } - } catch (error) { - captureCommitPhaseError( - renderPriorityLevel, - renderPriorityLevel.return, - error - ); - } - firstChild = renderPriorityLevel.sibling; - if (null !== firstChild) { - firstChild.return = renderPriorityLevel.return; - nextEffect = firstChild; - break; - } - nextEffect = renderPriorityLevel.return; - } - } -} -function commitLayoutEffects(finishedWork, root) { - for (nextEffect = finishedWork; null !== nextEffect; ) { - var fiber = nextEffect, - firstChild = fiber.child; - if (0 !== (fiber.subtreeFlags & 324) && null !== firstChild) - (firstChild.return = fiber), (nextEffect = firstChild); - else - for (fiber = finishedWork, firstChild = root; null !== nextEffect; ) { - var fiber$jscomp$0 = nextEffect; - if (0 !== (fiber$jscomp$0.flags & 324)) { - var current = fiber$jscomp$0.alternate; - try { - var finishedRoot = firstChild; - if (0 !== (fiber$jscomp$0.flags & 68)) - switch (fiber$jscomp$0.tag) { - case 0: - case 11: - case 15: - commitHookEffectListMount(3, fiber$jscomp$0); - break; - case 1: - var instance = fiber$jscomp$0.stateNode; - if (fiber$jscomp$0.flags & 4) - if (null === current) instance.componentDidMount(); - else { - var prevProps = - fiber$jscomp$0.elementType === fiber$jscomp$0.type - ? current.memoizedProps - : resolveDefaultProps( - fiber$jscomp$0.type, - current.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = fiber$jscomp$0.updateQueue; - null !== updateQueue && - commitUpdateQueue(fiber$jscomp$0, updateQueue, instance); - break; - case 3: - var updateQueue$85 = fiber$jscomp$0.updateQueue; - if (null !== updateQueue$85) { - finishedRoot = null; - if (null !== fiber$jscomp$0.child) - switch (fiber$jscomp$0.child.tag) { - case 5: - finishedRoot = fiber$jscomp$0.child.stateNode; - break; - case 1: - finishedRoot = fiber$jscomp$0.child.stateNode; - } - commitUpdateQueue( - fiber$jscomp$0, - updateQueue$85, - finishedRoot - ); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 12: - var onRender = fiber$jscomp$0.memoizedProps.onRender, - commitTime$88 = commitTime; - current = null === current ? "mount" : "update"; - "function" === typeof onRender && - onRender( - fiber$jscomp$0.memoizedProps.id, - current, - fiber$jscomp$0.actualDuration, - fiber$jscomp$0.treeBaseDuration, - fiber$jscomp$0.actualStartTime, - commitTime$88, - finishedRoot.memoizedInteractions - ); - break; - case 13: - break; - case 19: - case 17: - case 21: - case 22: - case 23: - break; - default: - 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 (fiber$jscomp$0.flags & 256) { - finishedRoot = void 0; - var ref = fiber$jscomp$0.ref; - if (null !== ref) { - var instance$jscomp$0 = fiber$jscomp$0.stateNode; - switch (fiber$jscomp$0.tag) { - case 5: - finishedRoot = instance$jscomp$0; - break; - default: - finishedRoot = instance$jscomp$0; - } - "function" === typeof ref - ? ref(finishedRoot) - : (ref.current = finishedRoot); - } - } - } catch (error) { - captureCommitPhaseError( - fiber$jscomp$0, - fiber$jscomp$0.return, - error - ); - } - } - if (fiber$jscomp$0 === fiber) { - nextEffect = null; - break; - } - finishedRoot = fiber$jscomp$0.sibling; - if (null !== finishedRoot) { - finishedRoot.return = fiber$jscomp$0.return; - nextEffect = finishedRoot; - break; - } - nextEffect = fiber$jscomp$0.return; - } - } +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$2 = ReactSharedInternals.ReactCurrentDispatcher, @@ -6333,11 +5979,14 @@ var ceil = Math.ceil, subtreeRenderLanesCursor = createCursor(0), workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, + workInProgressRootIncludedLanes = 0, workInProgressRootSkippedLanes = 0, workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, + mostRecentlyUpdatedRoot = null, globalMostRecentFallbackTime = 0, workInProgressRootRenderTargetTime = Infinity, + nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, legacyErrorBoundariesThatAlreadyFailed = null, @@ -6345,12 +5994,17 @@ var ceil = Math.ceil, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, pendingPassiveEffectsLanes = 0, + pendingPassiveHookEffectsMount = [], + pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, spawnedWorkDuringRender = null, currentEventTime = -1, - currentEventTransitionLane = 0; + currentEventWipLanes = 0, + currentEventPendingLanes = 0, + focusedInstanceHandle = null, + shouldFireAfterActiveInstanceBlur = !1; function requestEventTime() { return 0 !== (executionContext & 48) ? now() @@ -6360,22 +6014,30 @@ function requestEventTime() { } function requestUpdateLane(fiber) { fiber = fiber.mode; - if (0 === (fiber & 1)) return 1; - if (0 === (fiber & 2)) return 99 === getCurrentPriorityLevel() ? 1 : 2; - if (0 !== ReactCurrentBatchConfig.transition) - return ( - 0 === currentEventTransitionLane && - ((fiber = nextTransitionLane), - (nextTransitionLane <<= 1), - 0 === (nextTransitionLane & 8388096) && (nextTransitionLane = 512), - (currentEventTransitionLane = fiber)), - currentEventTransitionLane - ); + 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)) + ? (fiber = findUpdateLane(12, currentEventWipLanes)) : ((fiber = schedulerPriorityToLanePriority(fiber)), - (fiber = findUpdateLane(fiber))); + (fiber = findUpdateLane(fiber, currentEventWipLanes))); return fiber; } function scheduleUpdateOnFiber(fiber, lane, eventTime) { @@ -6408,7 +6070,7 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { : rootsWithPendingDiscreteUpdates.add(fiber)), ensureRootIsScheduled(fiber, eventTime), schedulePendingInteractions(fiber, lane)); - return fiber; + mostRecentlyUpdatedRoot = fiber; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { sourceFiber.lanes |= lane; @@ -6433,15 +6095,15 @@ function ensureRootIsScheduled(root, currentTime) { 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6, - expirationTime = expirationTimes[index$6]; + 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$6] = + expirationTimes[index$7] = 10 <= priority ? expirationTime + 250 : 6 <= priority @@ -6456,42 +6118,45 @@ function ensureRootIsScheduled(root, currentTime) { root === workInProgressRoot ? workInProgressRootRenderLanes : 0 ); currentTime = return_highestLanePriority; - 0 === suspendedLanes - ? (null !== existingCallbackNode && + if (0 === suspendedLanes) + null !== existingCallbackNode && + (existingCallbackNode !== fakeCallbackNode && Scheduler_cancelCallback(existingCallbackNode), (root.callbackNode = null), - (root.callbackPriority = 0)) - : root.callbackPriority !== currentTime && - (null != existingCallbackNode && - Scheduler_cancelCallback(existingCallbackNode), - 15 === currentTime - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? ((syncQueue = [existingCallbackNode]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(existingCallbackNode), - (existingCallbackNode = null)) - : 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)); + (root.callbackPriority = 0)); + else { + 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) { +function performConcurrentWorkOnRoot(root) { currentEventTime = -1; - currentEventTransitionLane = 0; + currentEventPendingLanes = currentEventWipLanes = 0; if (0 !== (executionContext & 48)) throw Error("Should not already be working."); var originalCallbackNode = root.callbackNode; @@ -6502,14 +6167,8 @@ 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 ( @@ -6531,19 +6190,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)); - if (0 !== didTimeout) { - 2 === didTimeout && + (exitStatus = workInProgressRootExitStatus)); + 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 && (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), @@ -6551,7 +6212,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."); @@ -6561,9 +6222,9 @@ function performConcurrentWorkOnRoot(root, didTimeout) { case 3: markRootSuspended$1(root, lanes); if ( - (lanes & 125829120) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + (lanes & 62914560) === lanes && + ((exitStatus = globalMostRecentFallbackTime + 500 - now()), + 10 < exitStatus) ) { if (0 !== getNextLanes(root, 0)) break; prevDispatcher = root.suspendedLanes; @@ -6574,7 +6235,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + exitStatus ); break; } @@ -6582,13 +6243,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { break; case 4: markRootSuspended$1(root, lanes); - if ((lanes & 8388096) === lanes) break; - didTimeout = root.eventTimes; + if ((lanes & 4186112) === lanes) break; + exitStatus = root.eventTimes; for (prevDispatcher = -1; 0 < lanes; ) { - var index$5 = 31 - clz32(lanes); - lanes$jscomp$0 = 1 << index$5; - index$5 = didTimeout[index$5]; - index$5 > prevDispatcher && (prevDispatcher = index$5); + 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 = prevDispatcher; @@ -6634,9 +6295,9 @@ function markRootSuspended$1(root, suspendedLanes) { root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$7 = 31 - clz32(suspendedLanes), - lane = 1 << index$7; - root[index$7] = -1; + var index$11 = 31 - clz32(suspendedLanes), + lane = 1 << index$11; + root[index$11] = -1; suspendedLanes &= ~lane; } } @@ -6644,12 +6305,17 @@ function performSyncWorkOnRoot(root) { if (0 !== (executionContext & 48)) throw Error("Should not already be working."); flushPassiveEffects(); - var lanes = + if ( root === workInProgressRoot && 0 !== (root.expiredLanes & workInProgressRootRenderLanes) - ? workInProgressRootRenderLanes - : getNextLanes(root, 0); - var exitStatus = renderRootSync(root, lanes); + ) { + 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 && 2 === exitStatus && ((executionContext |= 64), @@ -6668,6 +6334,11 @@ function performSyncWorkOnRoot(root) { ensureRootIsScheduled(root, now()); return null; } +function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes); + subtreeRenderLanes |= lanes; + workInProgressRootIncludedLanes |= lanes; +} function popRenderLanes() { subtreeRenderLanes = subtreeRenderLanesCursor.current; pop(subtreeRenderLanesCursor); @@ -6707,7 +6378,7 @@ function prepareFreshStack(root, lanes) { pop(suspenseStackCursor); break; case 10: - popProvider(interruptedWork.type._context); + popProvider(interruptedWork); break; case 22: case 23: @@ -6717,29 +6388,10 @@ function prepareFreshStack(root, lanes) { } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = lanes; + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; - if (null !== interleavedQueues) { - for (root = 0; root < interleavedQueues.length; root++) - if ( - ((lanes = interleavedQueues[root]), - (timeoutHandle = lanes.interleaved), - null !== timeoutHandle) - ) { - lanes.interleaved = null; - interruptedWork = timeoutHandle.next; - var lastPendingUpdate = lanes.pending; - if (null !== lastPendingUpdate) { - var firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = interruptedWork; - timeoutHandle.next = firstPendingUpdate; - } - lanes.pending = timeoutHandle; - } - interleavedQueues = null; - } spawnedWorkDuringRender = null; } function handleError(root$jscomp$0, thrownValue) { @@ -6770,7 +6422,7 @@ function handleError(root$jscomp$0, thrownValue) { workInProgress = null; break; } - erroredWork.mode & 4 && + erroredWork.mode & 8 && stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0); a: { var root = root$jscomp$0, @@ -6778,18 +6430,15 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.flags |= 8192; + sourceFiber.flags |= 4096; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - var wakeable = value, - tag = sourceFiber.tag; - if ( - 0 === (sourceFiber.mode & 1) && - (0 === tag || 11 === tag || 15 === tag) - ) { + var wakeable = value; + if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), @@ -6800,15 +6449,15 @@ function handleError(root$jscomp$0, thrownValue) { } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - workInProgress$79 = returnFiber; + workInProgress$77 = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$79.tag)) { - var nextState = workInProgress$79.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$79.memoizedProps; + var props = workInProgress$77.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6820,19 +6469,16 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var wakeables = workInProgress$79.updateQueue; + var wakeables = workInProgress$77.updateQueue; if (null === wakeables) { var updateQueue = new Set(); updateQueue.add(wakeable); - workInProgress$79.updateQueue = updateQueue; + workInProgress$77.updateQueue = updateQueue; } else wakeables.add(wakeable); - if ( - 0 === (workInProgress$79.mode & 1) && - workInProgress$79 !== returnFiber - ) { - workInProgress$79.flags |= 128; - sourceFiber.flags |= 65536; - sourceFiber.flags &= -10053; + 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 { @@ -6863,12 +6509,12 @@ function handleError(root$jscomp$0, thrownValue) { ); wakeable.then(ping, ping); } - workInProgress$79.flags |= 16384; - workInProgress$79.lanes = thrownValue; + workInProgress$77.flags |= 8192; + workInProgress$77.lanes = thrownValue; break a; } - workInProgress$79 = workInProgress$79.return; - } while (null !== workInProgress$79); + 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." @@ -6877,47 +6523,47 @@ function handleError(root$jscomp$0, thrownValue) { 5 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - workInProgress$79 = returnFiber; + workInProgress$77 = returnFiber; do { - switch (workInProgress$79.tag) { + switch (workInProgress$77.tag) { case 3: root = value; - workInProgress$79.flags |= 16384; + workInProgress$77.flags |= 8192; thrownValue &= -thrownValue; - workInProgress$79.lanes |= thrownValue; - var update$80 = createRootErrorUpdate( - workInProgress$79, + workInProgress$77.lanes |= thrownValue; + var update$78 = createRootErrorUpdate( + workInProgress$77, root, thrownValue ); - enqueueCapturedUpdate(workInProgress$79, update$80); + enqueueCapturedUpdate(workInProgress$77, update$78); break a; case 1: root = value; - var ctor = workInProgress$79.type, - instance = workInProgress$79.stateNode; + var ctor = workInProgress$77.type, + instance = workInProgress$77.stateNode; if ( - 0 === (workInProgress$79.flags & 128) && + 0 === (workInProgress$77.flags & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$79.flags |= 16384; + workInProgress$77.flags |= 8192; thrownValue &= -thrownValue; - workInProgress$79.lanes |= thrownValue; - var update$83 = createClassErrorUpdate( - workInProgress$79, + workInProgress$77.lanes |= thrownValue; + var update$81 = createClassErrorUpdate( + workInProgress$77, root, thrownValue ); - enqueueCapturedUpdate(workInProgress$79, update$83); + enqueueCapturedUpdate(workInProgress$77, update$81); break a; } } - workInProgress$79 = workInProgress$79.return; - } while (null !== workInProgress$79); + workInProgress$77 = workInProgress$77.return; + } while (null !== workInProgress$77); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { @@ -6976,7 +6622,7 @@ function workLoopConcurrent() { } function performUnitOfWork(unitOfWork) { var current = unitOfWork.alternate; - 0 !== (unitOfWork.mode & 4) + 0 !== (unitOfWork.mode & 8) ? ((profilerStartTime = now$1()), 0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()), (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)), @@ -6993,8 +6639,8 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.flags & 8192)) { - if (0 === (completedWork.mode & 4)) + if (0 === (completedWork.flags & 4096)) { + if (0 === (completedWork.mode & 8)) current = completeWork(current, completedWork, subtreeRenderLanes); else { var fiber = completedWork; @@ -7007,14 +6653,65 @@ function completeUnitOfWork(unitOfWork) { workInProgress = current; return; } + current = completedWork; + if ( + (23 !== current.tag && 22 !== current.tag) || + null === current.memoizedState || + 0 !== (subtreeRenderLanes & 1073741824) || + 0 === (current.mode & 4) + ) { + fiber = 0; + if (0 !== (current.mode & 8)) { + for ( + var actualDuration = current.actualDuration, + treeBaseDuration = current.selfBaseDuration, + shouldBubbleActualDurations = + null === current.alternate || + current.child !== current.alternate.child, + child = current.child; + null !== child; + + ) + (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 = current.child; null !== actualDuration; ) + (fiber |= actualDuration.lanes | actualDuration.childLanes), + (actualDuration = actualDuration.sibling); + current.childLanes = fiber; + } + null !== unitOfWork && + 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.flags && + (null !== unitOfWork.lastEffect + ? (unitOfWork.lastEffect.nextEffect = completedWork) + : (unitOfWork.firstEffect = completedWork), + (unitOfWork.lastEffect = completedWork))); } else { current = unwindWork(completedWork); if (null !== current) { - current.flags &= 8191; + current.flags &= 4095; workInProgress = current; return; } - if (0 !== (completedWork.mode & 4)) { + if (0 !== (completedWork.mode & 8)) { stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); current = completedWork.actualDuration; for (fiber = completedWork.child; null !== fiber; ) @@ -7022,9 +6719,8 @@ function completeUnitOfWork(unitOfWork) { completedWork.actualDuration = current; } null !== unitOfWork && - ((unitOfWork.flags |= 8192), - (unitOfWork.subtreeFlags = 0), - (unitOfWork.deletions = null)); + ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), + (unitOfWork.flags |= 4096)); } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -7055,65 +6751,190 @@ function commitRootImpl(root, renderPriorityLevel) { "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); root.callbackNode = null; - root.callbackPriority = 0; - var remainingLanes = finishedWork.lanes | finishedWork.childLanes; - markRootFinished(root, remainingLanes); + 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 & 8) && + 0 === (remainingLanes & 24) && rootsWithPendingDiscreteUpdates.has(root) && rootsWithPendingDiscreteUpdates.delete(root); root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - (0 === (finishedWork.subtreeFlags & 1040) && - 0 === (finishedWork.flags & 1040)) || - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); - remainingLanes = 0 !== (finishedWork.flags & 8054); - if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) { - remainingLanes = executionContext; + 1 < finishedWork.flags + ? null !== finishedWork.lastEffect + ? ((finishedWork.lastEffect.nextEffect = finishedWork), + (remainingLanes = finishedWork.firstEffect)) + : (remainingLanes = finishedWork) + : (remainingLanes = finishedWork.firstEffect); + if (null !== remainingLanes) { + remainingLanes$jscomp$0 = executionContext; executionContext |= 32; - var prevInteractions = pushInteractions(root); - ReactCurrentOwner$2.current = null; - commitBeforeMutationEffects(root, finishedWork); + eventTimes = pushInteractions(root); + focusedInstanceHandle = ReactCurrentOwner$2.current = null; + shouldFireAfterActiveInstanceBlur = !1; + nextEffect = remainingLanes; + do + try { + commitBeforeMutationEffects(); + } catch (error) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + focusedInstanceHandle = null; commitTime = now$1(); - commitMutationEffects(root, renderPriorityLevel, finishedWork); + nextEffect = remainingLanes; + do + try { + for (expirationTimes = root; null !== nextEffect; ) { + var flags = nextEffect.flags; + if (flags & 128) { + var current = nextEffect.alternate; + if (null !== current) { + var currentRef = current.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (flags & 1038) { + case 2: + commitPlacement(nextEffect); + nextEffect.flags &= -3; + break; + case 6: + commitPlacement(nextEffect); + nextEffect.flags &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 1024: + nextEffect.flags &= -1025; + break; + case 1028: + nextEffect.flags &= -1025; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + noLongerPendingLanes = nextEffect; + unmountHostComponents(expirationTimes, noLongerPendingLanes); + var alternate = noLongerPendingLanes.alternate; + detachFiberMutation(noLongerPendingLanes); + null !== alternate && detachFiberMutation(alternate); + } + nextEffect = nextEffect.nextEffect; + } + } catch (error$91) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error$91); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); root.current = finishedWork; - commitLayoutEffects(finishedWork, root, lanes); + nextEffect = remainingLanes; + do + try { + 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; + switch (nextEffect.tag) { + case 5: + current = instance; + break; + default: + current = instance; + } + "function" === typeof ref + ? ref(current) + : (ref.current = current); + } + } + nextEffect = nextEffect.nextEffect; + } + } catch (error$92) { + if (null === nextEffect) throw Error("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error$92); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + nextEffect = null; requestPaint(); - tracing.__interactionsRef.current = prevInteractions; - executionContext = remainingLanes; + tracing.__interactionsRef.current = eventTimes; + executionContext = remainingLanes$jscomp$0; } else (root.current = finishedWork), (commitTime = now$1()); - if ((prevInteractions = rootDoesHavePassiveEffects)) + if ((flags$jscomp$0 = rootDoesHavePassiveEffects)) (rootDoesHavePassiveEffects = !1), (rootWithPendingPassiveEffects = root), (pendingPassiveEffectsLanes = lanes), (pendingPassiveEffectsRenderPriority = renderPriorityLevel); + else + for (nextEffect = remainingLanes; null !== nextEffect; ) + (ref = nextEffect.nextEffect), + (nextEffect.nextEffect = null), + nextEffect.flags & 8 && + ((instance = nextEffect), + (instance.sibling = null), + (instance.stateNode = null)), + (nextEffect = ref); remainingLanes = root.pendingLanes; if (0 !== remainingLanes) { - if (null !== spawnedWorkDuringRender) { - var expirationTimes = spawnedWorkDuringRender; - spawnedWorkDuringRender = null; - for (var i = 0; i < expirationTimes.length; i++) - scheduleInteractions( - root, - expirationTimes[i], - root.memoizedInteractions - ); - } + if (null !== spawnedWorkDuringRender) + for ( + ref = spawnedWorkDuringRender, + spawnedWorkDuringRender = null, + instance = 0; + instance < ref.length; + instance++ + ) + scheduleInteractions(root, ref[instance], root.memoizedInteractions); schedulePendingInteractions(root, remainingLanes); } else legacyErrorBoundariesThatAlreadyFailed = null; - prevInteractions || finishPendingInteractions(root, lanes); - 0 !== (remainingLanes & 1) + flags$jscomp$0 || finishPendingInteractions(root, lanes); + 1 === remainingLanes ? root === rootWithNestedUpdates ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - onCommitRoot(finishedWork.stateNode, renderPriorityLevel); + 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), @@ -7124,6 +6945,30 @@ function commitRootImpl(root, renderPriorityLevel) { flushSyncCallbackQueue(); return null; } +function commitBeforeMutationEffects() { + for (; null !== nextEffect; ) { + 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() { + flushPassiveEffects(); + return null; + })); + nextEffect = nextEffect.nextEffect; + } +} function flushPassiveEffects() { if (90 !== pendingPassiveEffectsRenderPriority) { var priorityLevel = @@ -7135,6 +6980,24 @@ function flushPassiveEffects() { } 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, @@ -7145,104 +7008,41 @@ function flushPassiveEffectsImpl() { throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; executionContext |= 32; - var prevInteractions = pushInteractions(root); - for (nextEffect = root.current; null !== nextEffect; ) { - var fiber = nextEffect, - child = fiber.child; - if (0 !== (nextEffect.flags & 16)) { - var deletions = fiber.deletions; - if (null !== deletions) { - for (var i = 0; i < deletions.length; i++) { - var fiberToDelete = deletions[i]; - for (nextEffect = fiberToDelete; null !== nextEffect; ) { - var fiber$jscomp$0 = nextEffect; - switch (fiber$jscomp$0.tag) { - case 0: - case 11: - case 15: - commitHookEffectListUnmount(4, fiber$jscomp$0, fiber); - } - var child$jscomp$0 = fiber$jscomp$0.child; - if (null !== child$jscomp$0) - (child$jscomp$0.return = fiber$jscomp$0), - (nextEffect = child$jscomp$0); - else - for (; null !== nextEffect; ) { - fiber$jscomp$0 = nextEffect; - if (fiber$jscomp$0 === fiberToDelete) { - nextEffect = null; - break; - } - child$jscomp$0 = fiber$jscomp$0.sibling; - if (null !== child$jscomp$0) { - child$jscomp$0.return = fiber$jscomp$0.return; - nextEffect = child$jscomp$0; - break; - } - nextEffect = fiber$jscomp$0.return; - } - } - fiber$jscomp$0 = fiberToDelete.alternate; - detachFiberAfterEffects(fiberToDelete); - null !== fiber$jscomp$0 && detachFiberAfterEffects(fiber$jscomp$0); - } - nextEffect = fiber; - } - } - if (0 !== (fiber.subtreeFlags & 1040) && null !== child) - (child.return = fiber), (nextEffect = child); - else - a: for (; null !== nextEffect; ) { - fiber = nextEffect; - if (0 !== (fiber.flags & 1024)) - switch (fiber.tag) { - case 0: - case 11: - case 15: - commitHookEffectListUnmount(5, fiber, fiber.return); - } - child = fiber.sibling; - if (null !== child) { - child.return = fiber.return; - nextEffect = child; - break a; - } - nextEffect = fiber.return; + 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); } } - for (nextEffect = fiber = root.current; null !== nextEffect; ) - if ( - ((child = nextEffect), - (deletions = child.child), - 0 !== (child.subtreeFlags & 1040) && null !== deletions) - ) - (deletions.return = child), (nextEffect = deletions); - else - a: for (child = fiber; null !== nextEffect; ) { - deletions = nextEffect; - if (0 !== (deletions.flags & 1024)) - try { - switch (deletions.tag) { - case 0: - case 11: - case 15: - commitHookEffectListMount(5, deletions); - } - } catch (error) { - captureCommitPhaseError(deletions, deletions.return, error); - } - if (deletions === child) { - nextEffect = null; - break a; - } - i = deletions.sibling; - if (null !== i) { - i.return = deletions.return; - nextEffect = i; - break a; - } - nextEffect = deletions.return; - } + unmountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + for (i = 0; i < unmountEffects.length; i += 2) { + effect$97 = unmountEffects[i]; + fiber = unmountEffects[i + 1]; + try { + 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); + } + } + 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, lanes); executionContext = prevExecutionContext; @@ -7260,51 +7060,43 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { ensureRootIsScheduled(rootFiber, sourceFiber), schedulePendingInteractions(rootFiber, 1)); } -function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { +function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); else - for ( - nearestMountedAncestor = sourceFiber.return; - null !== nearestMountedAncestor; - - ) { - if (3 === nearestMountedAncestor.tag) { - captureCommitPhaseErrorOnRoot( - nearestMountedAncestor, - sourceFiber, - error - ); + for (var fiber = sourceFiber.return; null !== fiber; ) { + if (3 === fiber.tag) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); break; - } else if (1 === nearestMountedAncestor.tag) { - var instance = nearestMountedAncestor.stateNode; + } else if (1 === fiber.tag) { + var instance = fiber.stateNode; if ( - "function" === - typeof nearestMountedAncestor.type.getDerivedStateFromError || + "function" === typeof fiber.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 1 - ); - enqueueUpdate(nearestMountedAncestor, sourceFiber); - sourceFiber = requestEventTime(); - nearestMountedAncestor = markUpdateLaneFromFiberToRoot( - nearestMountedAncestor, - 1 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 1, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber), - schedulePendingInteractions(nearestMountedAncestor, 1)); + 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; } } - nearestMountedAncestor = nearestMountedAncestor.return; + fiber = fiber.return; } } function pingSuspendedRoot(root, wakeable, pingedLanes) { @@ -7316,7 +7108,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && (4 === workInProgressRootExitStatus || (3 === workInProgressRootExitStatus && - (workInProgressRootRenderLanes & 125829120) === + (workInProgressRootRenderLanes & 62914560) === workInProgressRootRenderLanes && 500 > now() - globalMostRecentFallbackTime) ? prepareFreshStack(root, 0) @@ -7330,13 +7122,14 @@ function resolveRetryWakeable(boundaryFiber, wakeable) { wakeable = 0; 0 === wakeable && ((wakeable = boundaryFiber.mode), - 0 === (wakeable & 1) + 0 === (wakeable & 2) ? (wakeable = 1) - : 0 === (wakeable & 2) + : 0 === (wakeable & 4) ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) - : ((wakeable = nextRetryLane), - (nextRetryLane <<= 1), - 0 === (nextRetryLane & 125829120) && (nextRetryLane = 8388608))); + : (0 === currentEventWipLanes && + (currentEventWipLanes = workInProgressRootIncludedLanes), + (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), + 0 === wakeable && (wakeable = 4194304))); retryCache = requestEventTime(); boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); null !== boundaryFiber && @@ -7353,90 +7146,85 @@ beginWork$1 = function(current, workInProgress, renderLanes) { didPerformWorkStackCursor.current ) didReceiveUpdate = !0; + else if (0 !== (renderLanes & updateLanes)) + didReceiveUpdate = 0 !== (current.flags & 32768) ? !0 : !1; else { - if (0 === (renderLanes & updateLanes)) { - 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.type._context; - var nextValue = workInProgress.memoizedProps.value; - push(valueCursor, updateLanes._currentValue); - updateLanes._currentValue = nextValue; - 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( + 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 ); - return null !== workInProgress ? workInProgress.sibling : null; - } push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.flags & 128)) { - if (updateLanes) - return updateSuspenseListComponent( - current, - workInProgress, - renderLanes - ); - workInProgress.flags |= 128; - } - nextValue = workInProgress.memoizedState; - null !== nextValue && - ((nextValue.rendering = null), - (nextValue.tail = null), - (nextValue.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (updateLanes) break; - else return null; - case 22: - case 23: - return ( - (workInProgress.lanes = 0), - updateOffscreenComponent(current, workInProgress, renderLanes) + workInProgress = bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderLanes ); - } - return bailoutOnAlreadyFinishedWork( - current, - workInProgress, - renderLanes - ); + 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, + renderLanes + ); + 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 22: + case 23: + return ( + (workInProgress.lanes = 0), + updateOffscreenComponent(current, workInProgress, renderLanes) + ); } - didReceiveUpdate = 0 !== (current.flags & 65536) ? !0 : !1; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else didReceiveUpdate = !1; workInProgress.lanes = 0; @@ -7448,22 +7236,22 @@ beginWork$1 = function(current, workInProgress, renderLanes) { (workInProgress.alternate = null), (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - nextValue = getMaskedContext(workInProgress, contextStackCursor.current); + context = getMaskedContext(workInProgress, contextStackCursor.current); prepareToReadContext(workInProgress, renderLanes); - nextValue = renderWithHooks( + context = renderWithHooks( null, workInProgress, updateLanes, current, - nextValue, + context, renderLanes ); workInProgress.flags |= 1; if ( - "object" === typeof nextValue && - null !== nextValue && - "function" === typeof nextValue.render && - void 0 === nextValue.$$typeof + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof ) { workInProgress.tag = 1; workInProgress.memoizedState = null; @@ -7473,8 +7261,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { pushContextProvider(workInProgress); } else hasContext = !1; workInProgress.memoizedState = - null !== nextValue.state && void 0 !== nextValue.state - ? nextValue.state + null !== context.state && void 0 !== context.state + ? context.state : null; initializeUpdateQueue(workInProgress); var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; @@ -7485,9 +7273,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { getDerivedStateFromProps, current ); - nextValue.updater = classComponentUpdater; - workInProgress.stateNode = nextValue; - nextValue._reactInternals = workInProgress; + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternals = workInProgress; mountClassInstance(workInProgress, updateLanes, current, renderLanes); workInProgress = finishClassComponent( null, @@ -7499,28 +7287,28 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ); } else (workInProgress.tag = 0), - reconcileChildren(null, workInProgress, nextValue, renderLanes), + reconcileChildren(null, workInProgress, context, renderLanes), (workInProgress = workInProgress.child); return workInProgress; case 16: - nextValue = workInProgress.elementType; + context = workInProgress.elementType; a: { null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.flags |= 2)); current = workInProgress.pendingProps; - hasContext = nextValue._init; - nextValue = hasContext(nextValue._payload); - workInProgress.type = nextValue; - hasContext = workInProgress.tag = resolveLazyComponentTag(nextValue); - current = resolveDefaultProps(nextValue, current); + hasContext = context._init; + context = hasContext(context._payload); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current = resolveDefaultProps(context, current); switch (hasContext) { case 0: workInProgress = updateFunctionComponent( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7529,7 +7317,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateClassComponent( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7538,7 +7326,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateForwardRef( null, workInProgress, - nextValue, + context, current, renderLanes ); @@ -7547,8 +7335,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = updateMemoComponent( null, workInProgress, - nextValue, - resolveDefaultProps(nextValue.type, current), + context, + resolveDefaultProps(context.type, current), updateLanes, renderLanes ); @@ -7556,7 +7344,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } throw Error( "Element type is invalid. Received a promise that resolves to: " + - nextValue + + context + ". Lazy element type must resolve to a class or function." ); } @@ -7564,32 +7352,32 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 0: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateFunctionComponent( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); case 1: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateClassComponent( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); @@ -7600,18 +7388,19 @@ beginWork$1 = function(current, workInProgress, renderLanes) { 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." ); - nextValue = workInProgress.pendingProps; - updateLanes = workInProgress.memoizedState.element; + updateLanes = workInProgress.pendingProps; + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, nextValue, null, renderLanes); - nextValue = workInProgress.memoizedState.element; - nextValue === updateLanes + processUpdateQueue(workInProgress, updateLanes, null, renderLanes); + updateLanes = workInProgress.memoizedState.element; + updateLanes === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, renderLanes )) - : (reconcileChildren(current, workInProgress, nextValue, renderLanes), + : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), (workInProgress = workInProgress.child)); return workInProgress; case 5: @@ -7651,16 +7440,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 11: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), updateForwardRef( current, workInProgress, updateLanes, - nextValue, + context, renderLanes ) ); @@ -7701,21 +7490,27 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 10: a: { updateLanes = workInProgress.type._context; - nextValue = workInProgress.pendingProps; + context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; - hasContext = nextValue.value; - push(valueCursor, updateLanes._currentValue); - updateLanes._currentValue = hasContext; - if (null !== getDerivedStateFromProps) { - var oldValue = getDerivedStateFromProps.value; - hasContext = objectIs(oldValue, hasContext) - ? 0 - : ("function" === typeof updateLanes._calculateChangedBits - ? updateLanes._calculateChangedBits(oldValue, hasContext) - : 1073741823) | 0; - if (0 === hasContext) { + hasContext = context.value; + var context$jscomp$0 = workInProgress.type._context; + push(valueCursor, context$jscomp$0._currentValue); + context$jscomp$0._currentValue = hasContext; + if (null !== getDerivedStateFromProps) + if ( + ((context$jscomp$0 = getDerivedStateFromProps.value), + (hasContext = objectIs(context$jscomp$0, hasContext) + ? 0 + : ("function" === typeof updateLanes._calculateChangedBits + ? updateLanes._calculateChangedBits( + context$jscomp$0, + hasContext + ) + : 1073741823) | 0), + 0 === hasContext) + ) { if ( - getDerivedStateFromProps.children === nextValue.children && + getDerivedStateFromProps.children === context.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -7727,14 +7522,15 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } } else for ( - oldValue = workInProgress.child, - null !== oldValue && (oldValue.return = workInProgress); - null !== oldValue; + context$jscomp$0 = workInProgress.child, + null !== context$jscomp$0 && + (context$jscomp$0.return = workInProgress); + null !== context$jscomp$0; ) { - var list = oldValue.dependencies; + var list = context$jscomp$0.dependencies; if (null !== list) { - getDerivedStateFromProps = oldValue.child; + getDerivedStateFromProps = context$jscomp$0.child; for ( var dependency = list.firstContext; null !== dependency; @@ -7744,24 +7540,20 @@ beginWork$1 = function(current, workInProgress, renderLanes) { dependency.context === updateLanes && 0 !== (dependency.observedBits & hasContext) ) { - if (1 === oldValue.tag) { - dependency = createUpdate(-1, renderLanes & -renderLanes); - dependency.tag = 2; - var updateQueue = oldValue.updateQueue; - if (null !== updateQueue) { - updateQueue = updateQueue.shared; - var pending = updateQueue.pending; - null === pending - ? (dependency.next = dependency) - : ((dependency.next = pending.next), - (pending.next = dependency)); - updateQueue.pending = dependency; - } - } - oldValue.lanes |= renderLanes; - dependency = oldValue.alternate; + 1 === context$jscomp$0.tag && + ((dependency = createUpdate( + -1, + renderLanes & -renderLanes + )), + (dependency.tag = 2), + enqueueUpdate(context$jscomp$0, dependency)); + context$jscomp$0.lanes |= renderLanes; + dependency = context$jscomp$0.alternate; null !== dependency && (dependency.lanes |= renderLanes); - scheduleWorkOnParentPath(oldValue.return, renderLanes); + scheduleWorkOnParentPath( + context$jscomp$0.return, + renderLanes + ); list.lanes |= renderLanes; break; } @@ -7769,16 +7561,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { } } else getDerivedStateFromProps = - 10 === oldValue.tag - ? oldValue.type === workInProgress.type + 10 === context$jscomp$0.tag + ? context$jscomp$0.type === workInProgress.type ? null - : oldValue.child - : oldValue.child; + : context$jscomp$0.child + : context$jscomp$0.child; if (null !== getDerivedStateFromProps) - getDerivedStateFromProps.return = oldValue; + getDerivedStateFromProps.return = context$jscomp$0; else for ( - getDerivedStateFromProps = oldValue; + getDerivedStateFromProps = context$jscomp$0; null !== getDerivedStateFromProps; ) { @@ -7786,21 +7578,20 @@ beginWork$1 = function(current, workInProgress, renderLanes) { getDerivedStateFromProps = null; break; } - oldValue = getDerivedStateFromProps.sibling; - if (null !== oldValue) { - oldValue.return = getDerivedStateFromProps.return; - getDerivedStateFromProps = oldValue; + context$jscomp$0 = getDerivedStateFromProps.sibling; + if (null !== context$jscomp$0) { + context$jscomp$0.return = getDerivedStateFromProps.return; + getDerivedStateFromProps = context$jscomp$0; break; } getDerivedStateFromProps = getDerivedStateFromProps.return; } - oldValue = getDerivedStateFromProps; + context$jscomp$0 = getDerivedStateFromProps; } - } reconcileChildren( current, workInProgress, - nextValue.children, + context.children, renderLanes ); workInProgress = workInProgress.child; @@ -7808,28 +7599,28 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return workInProgress; case 9: return ( - (nextValue = workInProgress.type), + (context = workInProgress.type), (hasContext = workInProgress.pendingProps), (updateLanes = hasContext.children), prepareToReadContext(workInProgress, renderLanes), - (nextValue = readContext(nextValue, hasContext.unstable_observedBits)), - (updateLanes = updateLanes(nextValue)), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateLanes = updateLanes(context)), (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, updateLanes, renderLanes), workInProgress.child ); case 14: return ( - (nextValue = workInProgress.type), + (context = workInProgress.type), (hasContext = resolveDefaultProps( - nextValue, + context, workInProgress.pendingProps )), - (hasContext = resolveDefaultProps(nextValue.type, hasContext)), + (hasContext = resolveDefaultProps(context.type, hasContext)), updateMemoComponent( current, workInProgress, - nextValue, + context, hasContext, updateLanes, renderLanes @@ -7847,11 +7638,11 @@ beginWork$1 = function(current, workInProgress, renderLanes) { case 17: return ( (updateLanes = workInProgress.type), - (nextValue = workInProgress.pendingProps), - (nextValue = + (context = workInProgress.pendingProps), + (context = workInProgress.elementType === updateLanes - ? nextValue - : resolveDefaultProps(updateLanes, nextValue)), + ? context + : resolveDefaultProps(updateLanes, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), @@ -7861,8 +7652,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), prepareToReadContext(workInProgress, renderLanes), - constructClassInstance(workInProgress, updateLanes, nextValue), - mountClassInstance(workInProgress, updateLanes, nextValue, renderLanes), + constructClassInstance(workInProgress, updateLanes, context), + mountClassInstance(workInProgress, updateLanes, context, renderLanes), finishClassComponent( null, workInProgress, @@ -7963,9 +7754,9 @@ function finishPendingInteractions(root, committedLanes) { if (null !== subscriber && 0 === interaction.__count) try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error$96) { + } catch (error$103) { scheduleCallback(99, function() { - throw error$96; + throw error$103; }); } })); @@ -7981,8 +7772,8 @@ function FiberNode(tag, pendingProps, key, mode) { this.pendingProps = pendingProps; this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null; this.mode = mode; - this.subtreeFlags = this.flags = 0; - this.deletions = null; + this.flags = 0; + this.lastEffect = this.firstEffect = this.nextEffect = null; this.childLanes = this.lanes = 0; this.alternate = null; this.actualDuration = 0; @@ -8023,11 +7814,11 @@ function createWorkInProgress(current, pendingProps) { : ((workInProgress.pendingProps = pendingProps), (workInProgress.type = current.type), (workInProgress.flags = 0), - (workInProgress.subtreeFlags = 0), - (workInProgress.deletions = null), + (workInProgress.nextEffect = null), + (workInProgress.firstEffect = null), + (workInProgress.lastEffect = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.flags = current.flags & 131072; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -8064,18 +7855,15 @@ function createFiberFromTypeAndProps( return createFiberFromFragment(pendingProps.children, mode, lanes, key); case REACT_DEBUG_TRACING_MODE_TYPE: fiberTag = 8; - mode |= 8; + mode |= 16; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; - 1 <= - (null == pendingProps.unstable_level - ? 1 - : pendingProps.unstable_level) && (mode |= 16); + mode |= 1; break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.lanes = lanes), @@ -8266,8 +8054,7 @@ function updateContainer(element, container, parentComponent, callback) { callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - element = scheduleUpdateOnFiber(current, lane, eventTime); - null !== element && entangleTransitions(element, current, lane); + scheduleUpdateOnFiber(current, lane, eventTime); return lane; } function emptyFindFiberByHostInstance() { @@ -8306,10 +8093,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_986 = { + devToolsConfig$jscomp$inline_930 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "17.0.2", + version: "17.0.1-454c2211c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8324,11 +8111,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1282 = { - bundleType: devToolsConfig$jscomp$inline_986.bundleType, - version: devToolsConfig$jscomp$inline_986.version, - rendererPackageName: devToolsConfig$jscomp$inline_986.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_986.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, @@ -8343,7 +8130,7 @@ var internals$jscomp$inline_1282 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_986.findFiberByHostInstance || + devToolsConfig$jscomp$inline_930.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, @@ -8352,16 +8139,16 @@ var internals$jscomp$inline_1282 = { getCurrentFiber: null }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1283 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1149 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1283.isDisabled && - hook$jscomp$inline_1283.supportsFiber + !hook$jscomp$inline_1149.isDisabled && + hook$jscomp$inline_1149.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1283.inject( - internals$jscomp$inline_1282 + (rendererID = hook$jscomp$inline_1149.inject( + internals$jscomp$inline_1148 )), - (injectedHook = hook$jscomp$inline_1283); + (injectedHook = hook$jscomp$inline_1149); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { @@ -8411,7 +8198,7 @@ exports.render = function(element, containerTag, callback) { if (!root) { root = new FiberRootNode(containerTag, 0, !1); var JSCompiler_inline_result = 0; - isDevToolsPresent && (JSCompiler_inline_result |= 4); + isDevToolsPresent && (JSCompiler_inline_result |= 8); JSCompiler_inline_result = createFiber( 3, null, @@ -8420,7 +8207,6 @@ exports.render = function(element, containerTag, callback) { ); root.current = JSCompiler_inline_result; JSCompiler_inline_result.stateNode = root; - JSCompiler_inline_result.memoizedState = { element: null }; initializeUpdateQueue(JSCompiler_inline_result); roots.set(containerTag, root); } diff --git a/Libraries/Renderer/shims/ReactFabric.js b/Libraries/Renderer/shims/ReactFabric.js index 536ce9a6f30..31edc17fd5e 100644 --- a/Libraries/Renderer/shims/ReactFabric.js +++ b/Libraries/Renderer/shims/ReactFabric.js @@ -8,8 +8,6 @@ * @flow */ -'use strict'; - import {BatchedBridge} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'; // TODO @sema: Adjust types diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 462abeac94b..552b118556a 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -8,7 +8,12 @@ * @flow strict */ -import type {ElementRef, ElementType, Element, AbstractComponent} from 'react'; +import type { + ElementRef, + ElementType, + MixedElement, + AbstractComponent, +} from 'react'; export type MeasureOnSuccessCallback = ( x: number, @@ -44,7 +49,7 @@ type AttributeType = // or we allow them to define specific types and use this hack type AnyAttributeType = AttributeType<$FlowFixMe, $FlowFixMe>; -export type AttributeConfiguration = $ReadOnly<{ +type AttributeConfiguration = $ReadOnly<{ [propName: string]: AnyAttributeType, style: $ReadOnly<{ [propName: string]: AnyAttributeType, @@ -180,7 +185,7 @@ export type ReactNativeType = { eventType: string, ): void, render( - element: Element, + element: MixedElement, containerTag: number, callback: ?() => void, ): ?ElementRef, @@ -208,7 +213,7 @@ export type ReactFabricType = { eventType: string, ): void, render( - element: Element, + element: MixedElement, containerTag: number, callback: ?() => void, ): ?ElementRef, diff --git a/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js b/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js index 5f219fea652..0b3b8cc3d01 100644 --- a/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +++ b/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js @@ -8,10 +8,6 @@ * @flow strict-local */ -/* eslint-disable react-internal/invariant-args */ - -'use strict'; - import {type ViewConfig} from './ReactNativeTypes'; import invariant from 'invariant'; diff --git a/Libraries/Renderer/shims/createReactNativeComponentClass.js b/Libraries/Renderer/shims/createReactNativeComponentClass.js index f8f4c9284e4..0f893dfd24a 100644 --- a/Libraries/Renderer/shims/createReactNativeComponentClass.js +++ b/Libraries/Renderer/shims/createReactNativeComponentClass.js @@ -8,8 +8,6 @@ * @flow strict-local */ -'use strict'; - import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'; import {type ViewConfig} from './ReactNativeTypes';