diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 0da603692c..a46a1ce4f8 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -8310854cebba4d1f404e65ff2064825ee76d78e2 +09c8d2563300621dc91258a4c2839210e2fbdf0e diff --git a/compiled/facebook-www/React-dev.modern.js b/compiled/facebook-www/React-dev.modern.js index 460b81fda5..5cdb2bb2ad 100644 --- a/compiled/facebook-www/React-dev.modern.js +++ b/compiled/facebook-www/React-dev.modern.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-www-modern-0aab03f8"; +var ReactVersion = "18.3.0-www-modern-4b52f385"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled/facebook-www/ReactART-dev.classic.js b/compiled/facebook-www/ReactART-dev.classic.js index c0a6a6630b..e84cfc38a6 100644 --- a/compiled/facebook-www/ReactART-dev.classic.js +++ b/compiled/facebook-www/ReactART-dev.classic.js @@ -69,7 +69,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = "18.3.0-www-classic-2881d527"; +var ReactVersion = "18.3.0-www-classic-d364e70a"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -174,8 +174,9 @@ var revertRemovalOfSiblingPrerendering = enableLazyContextPropagation = dynamicFeatureFlags.enableLazyContextPropagation, enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane, - enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing; -// On WWW, false is used for a new modern build. + enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask; // On WWW, false is used for a new modern build. var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableProfilerNestedUpdatePhase = true; @@ -947,7 +948,7 @@ function childrenAsString(children) { } // This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback; +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback; var cancelCallback$1 = Scheduler.unstable_cancelCallback; var shouldYield = Scheduler.unstable_shouldYield; var requestPaint = Scheduler.unstable_requestPaint; @@ -3642,102 +3643,6 @@ function is(x, y) { var objectIs = typeof Object.is === "function" ? Object.is : is; // $FlowFixMe[method-unbinding] -var syncQueue = null; -var includesLegacySyncCallbacks = false; -var isFlushingSyncQueue = false; -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]; - } 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 scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = true; - scheduleSyncCallback(callback); -} -function flushSyncCallbacksOnlyInLegacyMode() { - // Only flushes the queue if there's a legacy sync callback scheduled. - // TODO: There's only a single type of callback: performSyncOnWorkOnRoot. So - // it might make more sense for the queue to be a list of roots instead of a - // list of generic callbacks. Then we can have two: one for legacy roots, one - // for concurrent roots. And this method would only flush the legacy ones. - if (includesLegacySyncCallbacks) { - flushSyncCallbacks(); - } -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrance. - isFlushingSyncQueue = true; // Set the event priority to discrete - // TODO: Is this necessary anymore? The only user code that runs in this - // queue is in the render or commit phases, which already set the - // event priority. Should be able to remove. - - var previousUpdatePriority = getCurrentUpdatePriority(); - setCurrentUpdatePriority(DiscreteEventPriority); - var errors = null; - var queue = syncQueue; // $FlowFixMe[incompatible-use] found when upgrading Flow - - for (var i = 0; i < queue.length; i++) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - var callback = queue[i]; - - try { - do { - var isSync = true; // $FlowFixMe[incompatible-type] we bail out when we get a null - - callback = callback(isSync); - } while (callback !== null); - } catch (error) { - // Collect errors so we can rethrow them at the end - if (errors === null) { - errors = [error]; - } else { - errors.push(error); - } - } - } - - syncQueue = null; - includesLegacySyncCallbacks = false; - setCurrentUpdatePriority(previousUpdatePriority); - isFlushingSyncQueue = false; - - if (errors !== null) { - if (errors.length > 1) { - if (typeof AggregateError === "function") { - // eslint-disable-next-line no-undef - throw new AggregateError(errors); - } else { - for (var _i = 1; _i < errors.length; _i++) { - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[_i]) - ); - } - - var firstError = errors[0]; - throw firstError; - } - } else { - var error = errors[0]; - throw error; - } - } - } - - return null; -} - -function throwError(error) { - throw error; -} - var nativeConsole = console; var nativeConsoleLog = null; var pendingGroupArgs = []; @@ -5453,7 +5358,7 @@ function checkPropStringCoercion(value, propName) { } } -var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we +var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we // detect this is caught by userspace, we'll log a warning in development. var SuspenseException = new Error( @@ -5489,8 +5394,8 @@ function isThenableResolved(thenable) { function noop() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactCurrentActQueue$2.current !== null) { - ReactCurrentActQueue$2.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var previous = thenableState[index]; @@ -17196,7 +17101,7 @@ var AbortControllerLocal = }; // Intentionally not named imports because Rollup would // use dynamic dispatch for CommonJS interop named imports. -var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority; var CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -17252,7 +17157,7 @@ function releaseCache(cache) { } if (cache.refCount === 0) { - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -23171,7 +23076,7 @@ if (typeof Symbol === "function" && Symbol.for) { symbolFor("selector.text"); } -var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; +var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -23194,7 +23099,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -23207,6 +23112,376 @@ function isConcurrentActEnvironment() { } } +var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, +// there's only a single root, but we do support multi root apps, hence this +// extra complexity. But this module is optimized for the single root case. + +var firstScheduledRoot = null; +var lastScheduledRoot = null; // Used to prevent redundant mircotasks from being scheduled. + +var didScheduleMicrotask = false; // `act` "microtasks" are scheduled on the `act` queue instead of an actual +// microtask, so we have to dedupe those separately. This wouldn't be an issue +// if we required all `act` calls to be awaited, which we might in the future. + +var didScheduleMicrotask_act = false; // Used to quickly bail out of flushSync if there's no sync work to do. + +var mightHavePendingSyncWork = false; +var isFlushingWork = false; +function ensureRootIsScheduled(root) { + // This function is called whenever a root receives an update. It does two + // things 1) it ensures the root is in the root schedule, and 2) it ensures + // there's a pending microtask to process the root schedule. + // + // Most of the actual scheduling logic does not happen until + // `scheduleTaskForRootDuringMicrotask` runs. + // Add the root to the schedule + if (root === lastScheduledRoot || root.next !== null); + else { + if (lastScheduledRoot === null) { + firstScheduledRoot = lastScheduledRoot = root; + } else { + lastScheduledRoot.next = root; + lastScheduledRoot = root; + } + } // Any time a root received an update, we set this to true until the next time + // we process the schedule. If it's false, then we can quickly exit flushSync + // without consulting the schedule. + + mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure + // there's a task scheduled for each one at the correct priority. + + if (ReactCurrentActQueue$1.current !== null) { + // We're inside an `act` scope. + if (!didScheduleMicrotask_act) { + didScheduleMicrotask_act = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } else { + if (!didScheduleMicrotask) { + didScheduleMicrotask = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } + + if (!enableDeferRootSchedulingToMicrotask) { + // While this flag is disabled, we schedule the render task immediately + // instead of waiting a microtask. + // TODO: We need to land enableDeferRootSchedulingToMicrotask ASAP to + // unblock additional features we have planned. + scheduleTaskForRootDuringMicrotask(root, now$1()); + } +} +function flushSyncWorkOnAllRoots() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(false); +} +function flushSyncWorkOnLegacyRootsOnly() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(true); +} + +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (isFlushingWork) { + // Prevent reentrancy. + // TODO: Is this overly defensive? The callers must check the execution + // context first regardless. + return; + } + + if (!mightHavePendingSyncWork) { + // Fast path. There's no sync work to do. + return; + } + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); // There may or may not be synchronous work scheduled. Let's check. + + var didPerformSomeWork; + var errors = null; + isFlushingWork = true; + + do { + didPerformSomeWork = false; + var root = firstScheduledRoot; + + while (root !== null) { + if (onlyLegacy && root.tag !== LegacyRoot); + else { + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + + if (includesSyncLane(nextLanes)) { + // This root has pending sync work. Flush it now. + try { + // TODO: Pass nextLanes as an argument instead of computing it again + // inside performSyncWorkOnRoot. + didPerformSomeWork = true; + performSyncWorkOnRoot(root); + } catch (error) { + // Collect errors so we can rethrow them at the end + if (errors === null) { + errors = [error]; + } else { + errors.push(error); + } + } + } + } + + root = root.next; + } + } while (didPerformSomeWork); + + isFlushingWork = false; // If any errors were thrown, rethrow them right before exiting. + // TODO: Consider returning these to the caller, to allow them to decide + // how/when to rethrow. + + if (errors !== null) { + if (errors.length > 1) { + if (typeof AggregateError === "function") { + // eslint-disable-next-line no-undef + throw new AggregateError(errors); + } else { + for (var i = 1; i < errors.length; i++) { + scheduleImmediateTask(throwError.bind(null, errors[i])); + } + + var firstError = errors[0]; + throw firstError; + } + } else { + var error = errors[0]; + throw error; + } + } +} + +function throwError(error) { + throw error; +} + +function processRootScheduleInMicrotask() { + // This function is always called inside a microtask. It should never be + // called synchronously. + didScheduleMicrotask = false; + + { + didScheduleMicrotask_act = false; + } // We'll recompute this as we iterate through all the roots and schedule them. + + mightHavePendingSyncWork = false; + var currentTime = now$1(); + var prev = null; + var root = firstScheduledRoot; + + while (root !== null) { + var next = root.next; + var nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + + if (nextLanes === NoLane) { + // This root has no more pending work. Remove it from the schedule. To + // guard against subtle reentrancy bugs, this microtask is the only place + // we do this — you can add roots to the schedule whenever, but you can + // only remove them here. + // Null this out so we know it's been removed from the schedule. + root.next = null; + + if (prev === null) { + // This is the new head of the list + firstScheduledRoot = next; + } else { + prev.next = next; + } + + if (next === null) { + // This is the new tail of the list + lastScheduledRoot = prev; + } + } else { + // This root still has work. Keep it in the list. + prev = root; + + if (includesSyncLane(nextLanes)) { + mightHavePendingSyncWork = true; + } + } + + root = next; + } // At the end of the microtask, flush any pending synchronous work. This has + // to come at the end, because it does actual rendering work that might throw. + + flushSyncWorkOnAllRoots(); +} + +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + // This function is always called inside a microtask, or at the very end of a + // rendering task right before we yield to the main thread. It should never be + // called synchronously. + // + // TODO: Unless enableDeferRootSchedulingToMicrotask is off. We need to land + // that ASAP to unblock additional features we have planned. + // + // This function also never performs React work synchronously; it should + // only schedule work to be performed later, in a separate task or microtask. + // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + var existingCallbackNode = root.callbackNode; + + if ( + nextLanes === NoLanes || // If this root is currently suspended and waiting for data to resolve, don't + // schedule a task to render it. We'll either wait for a ping, or wait to + // receive an update. + (isWorkLoopSuspendedOnData() && root === workInProgressRoot) || // We should only interrupt a pending commit if the new update + // is urgent. + (root.cancelPendingCommit !== null && includesOnlyNonUrgentLanes(nextLanes)) + ) { + // Fast path: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackNode = null; + root.callbackPriority = NoLane; + return NoLane; + } // Schedule a new callback in the host environment. + + if (includesSyncLane(nextLanes)) { + // Synchronous work is always flushed at the end of the microtask, so we + // don't need to schedule an additional task. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackPriority = SyncLane; + root.callbackNode = null; + return SyncLane; + } else { + // We use the highest priority lane to represent the priority of the callback. + var existingCallbackPriority = root.callbackPriority; + var newCallbackPriority = getHighestPriorityLane(nextLanes); + + if ( + newCallbackPriority === existingCallbackPriority && // Special case related to `act`. If the currently scheduled task is a + // Scheduler task, rather than an `act` task, cancel it and re-schedule + // on the `act` queue. + !( + ReactCurrentActQueue$1.current !== null && + existingCallbackNode !== fakeActCallbackNode$1 + ) + ) { + // The priority hasn't changed. We can reuse the existing task. + return newCallbackPriority; + } else { + // Cancel the existing callback. We'll schedule a new one below. + cancelCallback(existingCallbackNode); + } + + var schedulerPriorityLevel; + + switch (lanesToEventPriority(nextLanes)) { + case DiscreteEventPriority: + schedulerPriorityLevel = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriorityLevel = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriorityLevel = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority$1; + break; + } + + var newCallbackNode = scheduleCallback$1( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) + ); + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; + return newCallbackPriority; + } +} + +function getContinuationForRoot(root, originalCallbackNode) { + // This is called at the end of `performConcurrentWorkOnRoot` to determine + // if we need to schedule a continuation task. + // + // Usually `scheduleTaskForRootDuringMicrotask` only runs inside a microtask; + // however, since most of the logic for determining if we need a continuation + // versus a new task is the same, we cheat a bit and call it here. This is + // only safe to do because we know we're at the end of the browser task. + // So although it's not an actual microtask, it might as well be. + scheduleTaskForRootDuringMicrotask(root, now$1()); + + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } + + return null; +} +var fakeActCallbackNode$1 = {}; + +function scheduleCallback$1(priorityLevel, callback) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: We're inside an `act` scope (a testing utility). + // Instead of scheduling work in the host environment, add it to a + // fake internal queue that's managed by the `act` implementation. + ReactCurrentActQueue$1.current.push(callback); + return fakeActCallbackNode$1; + } else { + return scheduleCallback$3(priorityLevel, callback); + } +} + +function cancelCallback(callbackNode) { + if (callbackNode === fakeActCallbackNode$1); + else if (callbackNode !== null) { + cancelCallback$1(callbackNode); + } +} + +function scheduleImmediateTask(cb) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: Inside an `act` scope, we push microtasks to the fake `act` + // callback queue. This is because we currently support calling `act` + // without awaiting the result. The plan is to deprecate that, and require + // that you always await the result so that the microtasks have a chance to + // run. But it hasn't happened yet. + ReactCurrentActQueue$1.current.push(function () { + cb(); + return null; + }); + } // TODO: Can we land supportsMicrotasks? Which environments don't support it? + // Alternatively, can we move this check to the host config? + + { + // If microtasks are not supported, use Scheduler. + scheduleCallback$3(ImmediatePriority, cb); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -23485,6 +23760,9 @@ function getWorkInProgressRoot() { function getWorkInProgressRootRenderLanes() { return workInProgressRootRenderLanes; } +function isWorkLoopSuspendedOnData() { + return workInProgressSuspendedReason === SuspendedOnData; +} function requestEventTime() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. @@ -23688,21 +23966,25 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); if ( lane === SyncLane && executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue.isBatchingLegacy + (fiber.mode & ConcurrentMode) === NoMode ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + if (ReactCurrentActQueue.isBatchingLegacy) { + // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } else { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncWorkOnLegacyRootsOnly(); + } } } } @@ -23710,147 +23992,6 @@ function isUnsafeClassRenderPhaseUpdate(fiber) { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return (executionContext & RenderContext) !== NoContext; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. - -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. - - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. - - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. - if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); - } - - root.callbackNode = null; - root.callbackPriority = NoLane; - return; - } // If this root is currently suspended and waiting for data to resolve, don't - // schedule a task to render it. We'll either wait for a ping, or wait to - // receive an update. - - if ( - workInProgressSuspendedReason === SuspendedOnData && - workInProgressRoot === root - ) { - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - - var cancelPendingCommit = root.cancelPendingCommit; - - if (cancelPendingCommit !== null) { - // We should only interrupt a pending commit if the new update - // is urgent. - if (includesOnlyNonUrgentLanes(nextLanes)) { - // The new update is not urgent. Don't interrupt the pending commit. - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - } // We use the highest priority lane to represent the priority of the callback. - - var newCallbackPriority = getHighestPriorityLane(nextLanes); // Check if there's an existing task. We may be able to reuse it. - - var existingCallbackPriority = root.callbackPriority; - - if ( - existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a - // Scheduler task, rather than an `act` task, cancel it and re-scheduled - // on the `act` queue. - !( - ReactCurrentActQueue.current !== null && - existingCallbackNode !== fakeActCallbackNode - ) - ) { - { - // 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 && - !includesSyncLane(existingCallbackPriority) - ) { - 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. - - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. - cancelCallback(existingCallbackNode); - } // Schedule a new callback. - - var newCallbackNode; - - if (includesSyncLane(newCallbackPriority)) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue.isBatchingLegacy !== null) { - ReactCurrentActQueue.didScheduleLegacyUpdate = true; - } - - scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } - - { - // Flush the queue in an Immediate task. - scheduleCallback(ImmediatePriority, flushSyncCallbacks); - } - - newCallbackNode = null; - } else { - var schedulerPriorityLevel; - - switch (lanesToEventPriority(nextLanes)) { - case DiscreteEventPriority: - schedulerPriorityLevel = ImmediatePriority; - break; - - case ContinuousEventPriority: - schedulerPriorityLevel = UserBlockingPriority; - break; - - case DefaultEventPriority: - schedulerPriorityLevel = NormalPriority$1; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority$1; - break; - } - - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. @@ -23882,6 +24023,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } // Determine the next lanes to work on, using the fields stored // on the root. + // TODO: This was already computed in the caller. Pass it as an argument. var lanes = getNextLanes( root, @@ -23932,7 +24074,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -23982,7 +24124,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var _fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw _fatalError; } // FIXME: Need to check for RootDidNotComplete again. The factoring here // isn't ideal. @@ -23995,15 +24137,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } - ensureRootIsScheduled(root, now$1()); - - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); - } - - return null; + ensureRootIsScheduled(root); + return getContinuationForRoot(root, originalCallbackNode); } function recoverFromConcurrentError( @@ -24361,12 +24496,13 @@ function performSyncWorkOnRoot(root) { throw new Error("Should not already be working."); } - flushPassiveEffects(); + flushPassiveEffects(); // TODO: This was already computed in the caller. Pass it as an argument. + var lanes = getNextLanes(root, NoLanes); if (!includesSyncLane(lanes)) { // There's no remaining sync work left. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } @@ -24397,7 +24533,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -24406,7 +24542,7 @@ function performSyncWorkOnRoot(root) { // cases where need to exit the current render without producing a // consistent tree or committing. markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -24421,7 +24557,7 @@ function performSyncWorkOnRoot(root) { ); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } function getExecutionContext() { @@ -24465,7 +24601,7 @@ function flushSync(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -25016,7 +25152,7 @@ function renderRootConcurrent(root, lanes) { // currently working on a different root, so that we resume // rendering later. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; thenable.then(onResolution, onResolution); @@ -25828,7 +25964,7 @@ function commitRootImpl( } // additional work on this root is scheduled. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without @@ -25881,7 +26017,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { if (enableDebugTracing) { @@ -26049,7 +26185,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks; @@ -26133,7 +26269,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -26172,7 +26308,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -26248,7 +26384,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -26284,7 +26419,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -26303,7 +26438,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -26691,19 +26826,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } } } -function cancelCallback(callbackNode) { - if (callbackNode === fakeActCallbackNode) { - return; - } // In production, always call Scheduler. This function will be stripped out. - - return cancelCallback$1(callbackNode); -} - function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. return ReactCurrentActQueue.current !== null; @@ -27960,6 +28087,7 @@ function FiberRootNode( this.cancelPendingCommit = null; this.context = null; this.pendingContext = null; + this.next = null; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); diff --git a/compiled/facebook-www/ReactART-dev.modern.js b/compiled/facebook-www/ReactART-dev.modern.js index 735c980789..049f13e9f4 100644 --- a/compiled/facebook-www/ReactART-dev.modern.js +++ b/compiled/facebook-www/ReactART-dev.modern.js @@ -69,7 +69,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = "18.3.0-www-modern-0c2f7392"; +var ReactVersion = "18.3.0-www-modern-bbc3e63c"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -174,8 +174,9 @@ var revertRemovalOfSiblingPrerendering = enableLazyContextPropagation = dynamicFeatureFlags.enableLazyContextPropagation, enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane, - enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing; -// On WWW, true is used for a new modern build. + enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask; // On WWW, true is used for a new modern build. var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableProfilerNestedUpdatePhase = true; @@ -944,7 +945,7 @@ function childrenAsString(children) { } // This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback; +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback; var cancelCallback$1 = Scheduler.unstable_cancelCallback; var shouldYield = Scheduler.unstable_shouldYield; var requestPaint = Scheduler.unstable_requestPaint; @@ -3398,102 +3399,6 @@ function is(x, y) { var objectIs = typeof Object.is === "function" ? Object.is : is; // $FlowFixMe[method-unbinding] -var syncQueue = null; -var includesLegacySyncCallbacks = false; -var isFlushingSyncQueue = false; -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]; - } 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 scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = true; - scheduleSyncCallback(callback); -} -function flushSyncCallbacksOnlyInLegacyMode() { - // Only flushes the queue if there's a legacy sync callback scheduled. - // TODO: There's only a single type of callback: performSyncOnWorkOnRoot. So - // it might make more sense for the queue to be a list of roots instead of a - // list of generic callbacks. Then we can have two: one for legacy roots, one - // for concurrent roots. And this method would only flush the legacy ones. - if (includesLegacySyncCallbacks) { - flushSyncCallbacks(); - } -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrance. - isFlushingSyncQueue = true; // Set the event priority to discrete - // TODO: Is this necessary anymore? The only user code that runs in this - // queue is in the render or commit phases, which already set the - // event priority. Should be able to remove. - - var previousUpdatePriority = getCurrentUpdatePriority(); - setCurrentUpdatePriority(DiscreteEventPriority); - var errors = null; - var queue = syncQueue; // $FlowFixMe[incompatible-use] found when upgrading Flow - - for (var i = 0; i < queue.length; i++) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - var callback = queue[i]; - - try { - do { - var isSync = true; // $FlowFixMe[incompatible-type] we bail out when we get a null - - callback = callback(isSync); - } while (callback !== null); - } catch (error) { - // Collect errors so we can rethrow them at the end - if (errors === null) { - errors = [error]; - } else { - errors.push(error); - } - } - } - - syncQueue = null; - includesLegacySyncCallbacks = false; - setCurrentUpdatePriority(previousUpdatePriority); - isFlushingSyncQueue = false; - - if (errors !== null) { - if (errors.length > 1) { - if (typeof AggregateError === "function") { - // eslint-disable-next-line no-undef - throw new AggregateError(errors); - } else { - for (var _i = 1; _i < errors.length; _i++) { - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[_i]) - ); - } - - var firstError = errors[0]; - throw firstError; - } - } else { - var error = errors[0]; - throw error; - } - } - } - - return null; -} - -function throwError(error) { - throw error; -} - var nativeConsole = console; var nativeConsoleLog = null; var pendingGroupArgs = []; @@ -5209,7 +5114,7 @@ function checkPropStringCoercion(value, propName) { } } -var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we +var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we // detect this is caught by userspace, we'll log a warning in development. var SuspenseException = new Error( @@ -5245,8 +5150,8 @@ function isThenableResolved(thenable) { function noop() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactCurrentActQueue$2.current !== null) { - ReactCurrentActQueue$2.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var previous = thenableState[index]; @@ -16885,7 +16790,7 @@ var AbortControllerLocal = }; // Intentionally not named imports because Rollup would // use dynamic dispatch for CommonJS interop named imports. -var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority; var CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -16941,7 +16846,7 @@ function releaseCache(cache) { } if (cache.refCount === 0) { - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -22831,7 +22736,7 @@ if (typeof Symbol === "function" && Symbol.for) { symbolFor("selector.text"); } -var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; +var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -22854,7 +22759,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -22867,6 +22772,376 @@ function isConcurrentActEnvironment() { } } +var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, +// there's only a single root, but we do support multi root apps, hence this +// extra complexity. But this module is optimized for the single root case. + +var firstScheduledRoot = null; +var lastScheduledRoot = null; // Used to prevent redundant mircotasks from being scheduled. + +var didScheduleMicrotask = false; // `act` "microtasks" are scheduled on the `act` queue instead of an actual +// microtask, so we have to dedupe those separately. This wouldn't be an issue +// if we required all `act` calls to be awaited, which we might in the future. + +var didScheduleMicrotask_act = false; // Used to quickly bail out of flushSync if there's no sync work to do. + +var mightHavePendingSyncWork = false; +var isFlushingWork = false; +function ensureRootIsScheduled(root) { + // This function is called whenever a root receives an update. It does two + // things 1) it ensures the root is in the root schedule, and 2) it ensures + // there's a pending microtask to process the root schedule. + // + // Most of the actual scheduling logic does not happen until + // `scheduleTaskForRootDuringMicrotask` runs. + // Add the root to the schedule + if (root === lastScheduledRoot || root.next !== null); + else { + if (lastScheduledRoot === null) { + firstScheduledRoot = lastScheduledRoot = root; + } else { + lastScheduledRoot.next = root; + lastScheduledRoot = root; + } + } // Any time a root received an update, we set this to true until the next time + // we process the schedule. If it's false, then we can quickly exit flushSync + // without consulting the schedule. + + mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure + // there's a task scheduled for each one at the correct priority. + + if (ReactCurrentActQueue$1.current !== null) { + // We're inside an `act` scope. + if (!didScheduleMicrotask_act) { + didScheduleMicrotask_act = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } else { + if (!didScheduleMicrotask) { + didScheduleMicrotask = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } + + if (!enableDeferRootSchedulingToMicrotask) { + // While this flag is disabled, we schedule the render task immediately + // instead of waiting a microtask. + // TODO: We need to land enableDeferRootSchedulingToMicrotask ASAP to + // unblock additional features we have planned. + scheduleTaskForRootDuringMicrotask(root, now$1()); + } +} +function flushSyncWorkOnAllRoots() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(false); +} +function flushSyncWorkOnLegacyRootsOnly() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(true); +} + +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (isFlushingWork) { + // Prevent reentrancy. + // TODO: Is this overly defensive? The callers must check the execution + // context first regardless. + return; + } + + if (!mightHavePendingSyncWork) { + // Fast path. There's no sync work to do. + return; + } + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); // There may or may not be synchronous work scheduled. Let's check. + + var didPerformSomeWork; + var errors = null; + isFlushingWork = true; + + do { + didPerformSomeWork = false; + var root = firstScheduledRoot; + + while (root !== null) { + if (onlyLegacy && root.tag !== LegacyRoot); + else { + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + + if (includesSyncLane(nextLanes)) { + // This root has pending sync work. Flush it now. + try { + // TODO: Pass nextLanes as an argument instead of computing it again + // inside performSyncWorkOnRoot. + didPerformSomeWork = true; + performSyncWorkOnRoot(root); + } catch (error) { + // Collect errors so we can rethrow them at the end + if (errors === null) { + errors = [error]; + } else { + errors.push(error); + } + } + } + } + + root = root.next; + } + } while (didPerformSomeWork); + + isFlushingWork = false; // If any errors were thrown, rethrow them right before exiting. + // TODO: Consider returning these to the caller, to allow them to decide + // how/when to rethrow. + + if (errors !== null) { + if (errors.length > 1) { + if (typeof AggregateError === "function") { + // eslint-disable-next-line no-undef + throw new AggregateError(errors); + } else { + for (var i = 1; i < errors.length; i++) { + scheduleImmediateTask(throwError.bind(null, errors[i])); + } + + var firstError = errors[0]; + throw firstError; + } + } else { + var error = errors[0]; + throw error; + } + } +} + +function throwError(error) { + throw error; +} + +function processRootScheduleInMicrotask() { + // This function is always called inside a microtask. It should never be + // called synchronously. + didScheduleMicrotask = false; + + { + didScheduleMicrotask_act = false; + } // We'll recompute this as we iterate through all the roots and schedule them. + + mightHavePendingSyncWork = false; + var currentTime = now$1(); + var prev = null; + var root = firstScheduledRoot; + + while (root !== null) { + var next = root.next; + var nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + + if (nextLanes === NoLane) { + // This root has no more pending work. Remove it from the schedule. To + // guard against subtle reentrancy bugs, this microtask is the only place + // we do this — you can add roots to the schedule whenever, but you can + // only remove them here. + // Null this out so we know it's been removed from the schedule. + root.next = null; + + if (prev === null) { + // This is the new head of the list + firstScheduledRoot = next; + } else { + prev.next = next; + } + + if (next === null) { + // This is the new tail of the list + lastScheduledRoot = prev; + } + } else { + // This root still has work. Keep it in the list. + prev = root; + + if (includesSyncLane(nextLanes)) { + mightHavePendingSyncWork = true; + } + } + + root = next; + } // At the end of the microtask, flush any pending synchronous work. This has + // to come at the end, because it does actual rendering work that might throw. + + flushSyncWorkOnAllRoots(); +} + +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + // This function is always called inside a microtask, or at the very end of a + // rendering task right before we yield to the main thread. It should never be + // called synchronously. + // + // TODO: Unless enableDeferRootSchedulingToMicrotask is off. We need to land + // that ASAP to unblock additional features we have planned. + // + // This function also never performs React work synchronously; it should + // only schedule work to be performed later, in a separate task or microtask. + // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + var existingCallbackNode = root.callbackNode; + + if ( + nextLanes === NoLanes || // If this root is currently suspended and waiting for data to resolve, don't + // schedule a task to render it. We'll either wait for a ping, or wait to + // receive an update. + (isWorkLoopSuspendedOnData() && root === workInProgressRoot) || // We should only interrupt a pending commit if the new update + // is urgent. + (root.cancelPendingCommit !== null && includesOnlyNonUrgentLanes(nextLanes)) + ) { + // Fast path: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackNode = null; + root.callbackPriority = NoLane; + return NoLane; + } // Schedule a new callback in the host environment. + + if (includesSyncLane(nextLanes)) { + // Synchronous work is always flushed at the end of the microtask, so we + // don't need to schedule an additional task. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackPriority = SyncLane; + root.callbackNode = null; + return SyncLane; + } else { + // We use the highest priority lane to represent the priority of the callback. + var existingCallbackPriority = root.callbackPriority; + var newCallbackPriority = getHighestPriorityLane(nextLanes); + + if ( + newCallbackPriority === existingCallbackPriority && // Special case related to `act`. If the currently scheduled task is a + // Scheduler task, rather than an `act` task, cancel it and re-schedule + // on the `act` queue. + !( + ReactCurrentActQueue$1.current !== null && + existingCallbackNode !== fakeActCallbackNode$1 + ) + ) { + // The priority hasn't changed. We can reuse the existing task. + return newCallbackPriority; + } else { + // Cancel the existing callback. We'll schedule a new one below. + cancelCallback(existingCallbackNode); + } + + var schedulerPriorityLevel; + + switch (lanesToEventPriority(nextLanes)) { + case DiscreteEventPriority: + schedulerPriorityLevel = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriorityLevel = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriorityLevel = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority$1; + break; + } + + var newCallbackNode = scheduleCallback$1( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) + ); + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; + return newCallbackPriority; + } +} + +function getContinuationForRoot(root, originalCallbackNode) { + // This is called at the end of `performConcurrentWorkOnRoot` to determine + // if we need to schedule a continuation task. + // + // Usually `scheduleTaskForRootDuringMicrotask` only runs inside a microtask; + // however, since most of the logic for determining if we need a continuation + // versus a new task is the same, we cheat a bit and call it here. This is + // only safe to do because we know we're at the end of the browser task. + // So although it's not an actual microtask, it might as well be. + scheduleTaskForRootDuringMicrotask(root, now$1()); + + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } + + return null; +} +var fakeActCallbackNode$1 = {}; + +function scheduleCallback$1(priorityLevel, callback) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: We're inside an `act` scope (a testing utility). + // Instead of scheduling work in the host environment, add it to a + // fake internal queue that's managed by the `act` implementation. + ReactCurrentActQueue$1.current.push(callback); + return fakeActCallbackNode$1; + } else { + return scheduleCallback$3(priorityLevel, callback); + } +} + +function cancelCallback(callbackNode) { + if (callbackNode === fakeActCallbackNode$1); + else if (callbackNode !== null) { + cancelCallback$1(callbackNode); + } +} + +function scheduleImmediateTask(cb) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: Inside an `act` scope, we push microtasks to the fake `act` + // callback queue. This is because we currently support calling `act` + // without awaiting the result. The plan is to deprecate that, and require + // that you always await the result so that the microtasks have a chance to + // run. But it hasn't happened yet. + ReactCurrentActQueue$1.current.push(function () { + cb(); + return null; + }); + } // TODO: Can we land supportsMicrotasks? Which environments don't support it? + // Alternatively, can we move this check to the host config? + + { + // If microtasks are not supported, use Scheduler. + scheduleCallback$3(ImmediatePriority, cb); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -23145,6 +23420,9 @@ function getWorkInProgressRoot() { function getWorkInProgressRootRenderLanes() { return workInProgressRootRenderLanes; } +function isWorkLoopSuspendedOnData() { + return workInProgressSuspendedReason === SuspendedOnData; +} function requestEventTime() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. @@ -23348,21 +23626,25 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); if ( lane === SyncLane && executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue.isBatchingLegacy + (fiber.mode & ConcurrentMode) === NoMode ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + if (ReactCurrentActQueue.isBatchingLegacy) { + // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } else { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncWorkOnLegacyRootsOnly(); + } } } } @@ -23370,147 +23652,6 @@ function isUnsafeClassRenderPhaseUpdate(fiber) { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return (executionContext & RenderContext) !== NoContext; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. - -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. - - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. - - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. - if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); - } - - root.callbackNode = null; - root.callbackPriority = NoLane; - return; - } // If this root is currently suspended and waiting for data to resolve, don't - // schedule a task to render it. We'll either wait for a ping, or wait to - // receive an update. - - if ( - workInProgressSuspendedReason === SuspendedOnData && - workInProgressRoot === root - ) { - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - - var cancelPendingCommit = root.cancelPendingCommit; - - if (cancelPendingCommit !== null) { - // We should only interrupt a pending commit if the new update - // is urgent. - if (includesOnlyNonUrgentLanes(nextLanes)) { - // The new update is not urgent. Don't interrupt the pending commit. - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - } // We use the highest priority lane to represent the priority of the callback. - - var newCallbackPriority = getHighestPriorityLane(nextLanes); // Check if there's an existing task. We may be able to reuse it. - - var existingCallbackPriority = root.callbackPriority; - - if ( - existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a - // Scheduler task, rather than an `act` task, cancel it and re-scheduled - // on the `act` queue. - !( - ReactCurrentActQueue.current !== null && - existingCallbackNode !== fakeActCallbackNode - ) - ) { - { - // 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 && - !includesSyncLane(existingCallbackPriority) - ) { - 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. - - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. - cancelCallback(existingCallbackNode); - } // Schedule a new callback. - - var newCallbackNode; - - if (includesSyncLane(newCallbackPriority)) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue.isBatchingLegacy !== null) { - ReactCurrentActQueue.didScheduleLegacyUpdate = true; - } - - scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } - - { - // Flush the queue in an Immediate task. - scheduleCallback(ImmediatePriority, flushSyncCallbacks); - } - - newCallbackNode = null; - } else { - var schedulerPriorityLevel; - - switch (lanesToEventPriority(nextLanes)) { - case DiscreteEventPriority: - schedulerPriorityLevel = ImmediatePriority; - break; - - case ContinuousEventPriority: - schedulerPriorityLevel = UserBlockingPriority; - break; - - case DefaultEventPriority: - schedulerPriorityLevel = NormalPriority$1; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority$1; - break; - } - - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. @@ -23542,6 +23683,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } // Determine the next lanes to work on, using the fields stored // on the root. + // TODO: This was already computed in the caller. Pass it as an argument. var lanes = getNextLanes( root, @@ -23592,7 +23734,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -23642,7 +23784,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var _fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw _fatalError; } // FIXME: Need to check for RootDidNotComplete again. The factoring here // isn't ideal. @@ -23655,15 +23797,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } - ensureRootIsScheduled(root, now$1()); - - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); - } - - return null; + ensureRootIsScheduled(root); + return getContinuationForRoot(root, originalCallbackNode); } function recoverFromConcurrentError( @@ -24021,12 +24156,13 @@ function performSyncWorkOnRoot(root) { throw new Error("Should not already be working."); } - flushPassiveEffects(); + flushPassiveEffects(); // TODO: This was already computed in the caller. Pass it as an argument. + var lanes = getNextLanes(root, NoLanes); if (!includesSyncLane(lanes)) { // There's no remaining sync work left. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } @@ -24057,7 +24193,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -24066,7 +24202,7 @@ function performSyncWorkOnRoot(root) { // cases where need to exit the current render without producing a // consistent tree or committing. markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -24081,7 +24217,7 @@ function performSyncWorkOnRoot(root) { ); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } function getExecutionContext() { @@ -24125,7 +24261,7 @@ function flushSync(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -24676,7 +24812,7 @@ function renderRootConcurrent(root, lanes) { // currently working on a different root, so that we resume // rendering later. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; thenable.then(onResolution, onResolution); @@ -25488,7 +25624,7 @@ function commitRootImpl( } // additional work on this root is scheduled. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without @@ -25541,7 +25677,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { if (enableDebugTracing) { @@ -25709,7 +25845,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks; @@ -25793,7 +25929,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -25832,7 +25968,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -25908,7 +26044,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -25944,7 +26079,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -25963,7 +26098,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -26351,19 +26486,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } } } -function cancelCallback(callbackNode) { - if (callbackNode === fakeActCallbackNode) { - return; - } // In production, always call Scheduler. This function will be stripped out. - - return cancelCallback$1(callbackNode); -} - function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. return ReactCurrentActQueue.current !== null; @@ -27620,6 +27747,7 @@ function FiberRootNode( this.cancelPendingCommit = null; this.context = null; this.pendingContext = null; + this.next = null; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); diff --git a/compiled/facebook-www/ReactART-prod.classic.js b/compiled/facebook-www/ReactART-prod.classic.js index 1faf108c4d..de51112ac7 100644 --- a/compiled/facebook-www/ReactART-prod.classic.js +++ b/compiled/facebook-www/ReactART-prod.classic.js @@ -71,6 +71,8 @@ var ReactSharedInternals = dynamicFeatureFlags.enableLazyContextPropagation, enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane, enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask, REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -358,7 +360,7 @@ function childrenAsString(children) { : "" : ""; } -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -987,50 +989,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - syncQueue = null, - includesLegacySyncCallbacks = !1, - isFlushingSyncQueue = !1; -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var previousUpdatePriority = currentUpdatePriority; - currentUpdatePriority = 2; - for (var errors = null, queue = syncQueue, i = 0; i < queue.length; i++) { - var callback = queue[i]; - try { - do callback = callback(!0); - while (null !== callback); - } catch (error) { - null === errors ? (errors = [error]) : errors.push(error); - } - } - syncQueue = null; - includesLegacySyncCallbacks = !1; - currentUpdatePriority = previousUpdatePriority; - isFlushingSyncQueue = !1; - if (null !== errors) { - if (1 < errors.length) { - if ("function" === typeof AggregateError) - throw new AggregateError(errors); - for ( - previousUpdatePriority = 1; - previousUpdatePriority < errors.length; - previousUpdatePriority++ - ) - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[previousUpdatePriority]) - ); - } - throw errors[0]; - } - } - return null; -} -function throwError(error) { - throw error; -} -var contextStackCursor = createCursor(null), + contextStackCursor = createCursor(null), contextFiberStackCursor = createCursor(null), rootInstanceStackCursor = createCursor(null); function pushHostContainer(fiber, nextRootInstance) { @@ -2461,10 +2420,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$30 = thenableIndexCounter; + var index$28 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$30); + usable = trackUsedThenable(thenableState, usable, index$28); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -5130,7 +5089,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -5152,7 +5111,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -5310,14 +5269,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$75 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$75 = lastTailNode), + for (var lastTailNode$73 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$73 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$75 + null === lastTailNode$73 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$75.sibling = null); + : (lastTailNode$73.sibling = null); } } function bubbleProperties(completedWork) { @@ -5327,19 +5286,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$76 = completedWork.child; null !== child$76; ) - (newChildLanes |= child$76.lanes | child$76.childLanes), - (subtreeFlags |= child$76.subtreeFlags & 31457280), - (subtreeFlags |= child$76.flags & 31457280), - (child$76.return = completedWork), - (child$76 = child$76.sibling); + for (var child$74 = completedWork.child; null !== child$74; ) + (newChildLanes |= child$74.lanes | child$74.childLanes), + (subtreeFlags |= child$74.subtreeFlags & 31457280), + (subtreeFlags |= child$74.flags & 31457280), + (child$74.return = completedWork), + (child$74 = child$74.sibling); else - for (child$76 = completedWork.child; null !== child$76; ) - (newChildLanes |= child$76.lanes | child$76.childLanes), - (subtreeFlags |= child$76.subtreeFlags), - (subtreeFlags |= child$76.flags), - (child$76.return = completedWork), - (child$76 = child$76.sibling); + for (child$74 = completedWork.child; null !== child$74; ) + (newChildLanes |= child$74.lanes | child$74.childLanes), + (subtreeFlags |= child$74.subtreeFlags), + (subtreeFlags |= child$74.flags), + (child$74.return = completedWork), + (child$74 = child$74.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -5519,11 +5478,11 @@ function completeWork(current, workInProgress, renderLanes) { null !== newProps.alternate.memoizedState && null !== newProps.alternate.memoizedState.cachePool && (instance = newProps.alternate.memoizedState.cachePool.pool); - var cache$80 = null; + var cache$78 = null; null !== newProps.memoizedState && null !== newProps.memoizedState.cachePool && - (cache$80 = newProps.memoizedState.cachePool.pool); - cache$80 !== instance && (newProps.flags |= 2048); + (cache$78 = newProps.memoizedState.cachePool.pool); + cache$78 !== instance && (newProps.flags |= 2048); } renderLanes !== current && (enableTransitionTracing && (workInProgress.child.flags |= 2048), @@ -5553,8 +5512,8 @@ function completeWork(current, workInProgress, renderLanes) { instance = workInProgress.memoizedState; if (null === instance) return bubbleProperties(workInProgress), null; newProps = 0 !== (workInProgress.flags & 128); - cache$80 = instance.rendering; - if (null === cache$80) + cache$78 = instance.rendering; + if (null === cache$78) if (newProps) cutOffTailIfNeeded(instance, !1); else { if ( @@ -5562,11 +5521,11 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current && 0 !== (current.flags & 128)) ) for (current = workInProgress.child; null !== current; ) { - cache$80 = findFirstSuspended(current); - if (null !== cache$80) { + cache$78 = findFirstSuspended(current); + if (null !== cache$78) { workInProgress.flags |= 128; cutOffTailIfNeeded(instance, !1); - current = cache$80.updateQueue; + current = cache$78.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); workInProgress.subtreeFlags = 0; @@ -5591,7 +5550,7 @@ function completeWork(current, workInProgress, renderLanes) { } else { if (!newProps) - if (((current = findFirstSuspended(cache$80)), null !== current)) { + if (((current = findFirstSuspended(cache$78)), null !== current)) { if ( ((workInProgress.flags |= 128), (newProps = !0), @@ -5601,7 +5560,7 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(instance, !0), null === instance.tail && "hidden" === instance.tailMode && - !cache$80.alternate) + !cache$78.alternate) ) return bubbleProperties(workInProgress), null; } else @@ -5613,13 +5572,13 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(instance, !1), (workInProgress.lanes = 8388608)); instance.isBackwards - ? ((cache$80.sibling = workInProgress.child), - (workInProgress.child = cache$80)) + ? ((cache$78.sibling = workInProgress.child), + (workInProgress.child = cache$78)) : ((current = instance.last), null !== current - ? (current.sibling = cache$80) - : (workInProgress.child = cache$80), - (instance.last = cache$80)); + ? (current.sibling = cache$78) + : (workInProgress.child = cache$78), + (instance.last = cache$78)); } if (null !== instance.tail) return ( @@ -5879,8 +5838,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$98) { - captureCommitPhaseError(current, nearestMountedAncestor, error$98); + } catch (error$96) { + captureCommitPhaseError(current, nearestMountedAncestor, error$96); } else ref.current = null; } @@ -6079,11 +6038,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$99) { + } catch (error$97) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$99 + error$97 ); } } @@ -6670,8 +6629,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$107) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$107); + } catch (error$105) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$105); } } break; @@ -6707,11 +6666,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null !== updatePayload) try { flags._applyProps(flags, newProps, current); - } catch (error$110) { + } catch (error$108) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$110 + error$108 ); } } @@ -6748,8 +6707,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$112) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$112); + } catch (error$110) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$110); } flags = finishedWork.updateQueue; null !== flags && @@ -6889,12 +6848,12 @@ function commitReconciliationEffects(finishedWork) { break; case 3: case 4: - var parent$102 = JSCompiler_inline_result.stateNode.containerInfo, - before$103 = getHostSibling(finishedWork); + var parent$100 = JSCompiler_inline_result.stateNode.containerInfo, + before$101 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$103, - parent$102 + before$101, + parent$100 ); break; default: @@ -7355,9 +7314,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$121 = finishedWork.stateNode; + var instance$119 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$121._visibility & 4 + ? instance$119._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -7370,7 +7329,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$121._visibility |= 4), + : ((instance$119._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -7378,7 +7337,7 @@ function recursivelyTraverseReconnectPassiveEffects( committedTransitions, includeWorkInProgressEffects )) - : ((instance$121._visibility |= 4), + : ((instance$119._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -7391,7 +7350,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$121 + instance$119 ); break; case 24: @@ -7700,7 +7659,203 @@ var DefaultCacheDispatcher = { return cacheForType; } }, - ceil = Math.ceil, + firstScheduledRoot = null, + lastScheduledRoot = null, + didScheduleMicrotask = !1, + mightHavePendingSyncWork = !1, + isFlushingWork = !1; +function ensureRootIsScheduled(root) { + root !== lastScheduledRoot && + null === root.next && + (null === lastScheduledRoot + ? (firstScheduledRoot = lastScheduledRoot = root) + : (lastScheduledRoot = lastScheduledRoot.next = root)); + mightHavePendingSyncWork = !0; + didScheduleMicrotask || + ((didScheduleMicrotask = !0), + scheduleCallback$3(ImmediatePriority, processRootScheduleInMicrotask)); + enableDeferRootSchedulingToMicrotask || + scheduleTaskForRootDuringMicrotask(root, now()); +} +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (!isFlushingWork && mightHavePendingSyncWork) { + var workInProgressRoot$jscomp$0 = workInProgressRoot, + workInProgressRootRenderLanes$jscomp$0 = workInProgressRootRenderLanes, + errors = null; + isFlushingWork = !0; + do { + var didPerformSomeWork = !1; + for (var root = firstScheduledRoot; null !== root; ) { + if ( + (!onlyLegacy || 0 === root.tag) && + 0 !== + (getNextLanes( + root, + root === workInProgressRoot$jscomp$0 + ? workInProgressRootRenderLanes$jscomp$0 + : 0 + ) & + 3) + ) + try { + didPerformSomeWork = !0; + var root$jscomp$0 = root; + if (0 !== (executionContext & 6)) + throw Error(formatProdErrorMessage(327)); + flushPassiveEffects(); + var lanes = getNextLanes(root$jscomp$0, 0); + if (0 !== (lanes & 3)) { + var exitStatus = renderRootSync(root$jscomp$0, lanes); + if (0 !== root$jscomp$0.tag && 2 === exitStatus) { + var originallyAttemptedLanes = lanes, + errorRetryLanes = getLanesToRetrySynchronouslyOnError( + root$jscomp$0, + originallyAttemptedLanes + ); + 0 !== errorRetryLanes && + ((lanes = errorRetryLanes), + (exitStatus = recoverFromConcurrentError( + root$jscomp$0, + originallyAttemptedLanes, + errorRetryLanes + ))); + } + if (1 === exitStatus) + throw ( + ((originallyAttemptedLanes = workInProgressRootFatalError), + prepareFreshStack(root$jscomp$0, 0), + markRootSuspended(root$jscomp$0, lanes), + ensureRootIsScheduled(root$jscomp$0), + originallyAttemptedLanes) + ); + 6 === exitStatus + ? markRootSuspended(root$jscomp$0, lanes) + : ((root$jscomp$0.finishedWork = + root$jscomp$0.current.alternate), + (root$jscomp$0.finishedLanes = lanes), + commitRoot( + root$jscomp$0, + workInProgressRootRecoverableErrors, + workInProgressTransitions + )); + } + ensureRootIsScheduled(root$jscomp$0); + } catch (error) { + null === errors ? (errors = [error]) : errors.push(error); + } + root = root.next; + } + } while (didPerformSomeWork); + isFlushingWork = !1; + if (null !== errors) { + if (1 < errors.length) { + if ("function" === typeof AggregateError) + throw new AggregateError(errors); + for (onlyLegacy = 1; onlyLegacy < errors.length; onlyLegacy++) + (workInProgressRoot$jscomp$0 = throwError.bind( + null, + errors[onlyLegacy] + )), + scheduleCallback$3(ImmediatePriority, workInProgressRoot$jscomp$0); + } + throw errors[0]; + } + } +} +function throwError(error) { + throw error; +} +function processRootScheduleInMicrotask() { + mightHavePendingSyncWork = didScheduleMicrotask = !1; + for ( + var currentTime = now(), prev = null, root = firstScheduledRoot; + null !== root; + + ) { + var next = root.next, + nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + 0 === nextLanes + ? ((root.next = null), + null === prev ? (firstScheduledRoot = next) : (prev.next = next), + null === next && (lastScheduledRoot = prev)) + : ((prev = root), + 0 !== (nextLanes & 3) && (mightHavePendingSyncWork = !0)); + root = next; + } + flushSyncWorkAcrossRoots_impl(!1); +} +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + for ( + var suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes & -125829121; + 0 < lanes; + + ) { + var index$3 = 31 - clz32(lanes), + lane = 1 << index$3, + expirationTime = expirationTimes[index$3]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$3] = computeExpirationTime(lane, currentTime); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + currentTime = workInProgressRoot; + suspendedLanes = workInProgressRootRenderLanes; + suspendedLanes = getNextLanes( + root, + root === currentTime ? suspendedLanes : 0 + ); + pingedLanes = root.callbackNode; + if ( + 0 === suspendedLanes || + (2 === workInProgressSuspendedReason && root === currentTime) || + (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) + ) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackNode = null), + (root.callbackPriority = 0) + ); + if (0 !== (suspendedLanes & 3)) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackPriority = 2), + (root.callbackNode = null), + 2 + ); + currentTime = suspendedLanes & -suspendedLanes; + if (currentTime === root.callbackPriority) return currentTime; + null !== pingedLanes && cancelCallback$1(pingedLanes); + switch (lanesToEventPriority(suspendedLanes)) { + case 2: + suspendedLanes = ImmediatePriority; + break; + case 8: + suspendedLanes = UserBlockingPriority; + break; + case 32: + suspendedLanes = NormalPriority$1; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority$1; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$3(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} +var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentCache = ReactSharedInternals.ReactCurrentCache, @@ -7826,108 +7981,32 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { markRootSuspended(root, workInProgressRootRenderLanes)); markRootUpdated(root, lane, eventTime); if (0 === (executionContext & 2) || root !== workInProgressRoot) { - if (enableTransitionTracing) { - var transition = ReactCurrentBatchConfig.transition; - if ( - null !== transition && - null != transition.name && - (-1 === transition.startTime && (transition.startTime = now()), - enableTransitionTracing) - ) { - var transitionLanesMap = root.transitionLanes, - index$7 = 31 - clz32(lane), - transitions = transitionLanesMap[index$7]; - null === transitions && (transitions = new Set()); - transitions.add(transition); - transitionLanesMap[index$7] = transitions; - } + if ( + enableTransitionTracing && + ((eventTime = ReactCurrentBatchConfig.transition), + null !== eventTime && + null != eventTime.name && + (-1 === eventTime.startTime && (eventTime.startTime = now()), + enableTransitionTracing)) + ) { + var transitionLanesMap = root.transitionLanes, + index$7 = 31 - clz32(lane), + transitions = transitionLanesMap[index$7]; + null === transitions && (transitions = new Set()); + transitions.add(eventTime); + transitionLanesMap[index$7] = transitions; } root === workInProgressRoot && (0 === (executionContext & 2) && (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended(root, workInProgressRootRenderLanes)); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); 2 === lane && 0 === executionContext && 0 === (fiber.mode & 1) && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); - } -} -function ensureRootIsScheduled(root, currentTime) { - for ( - var existingCallbackNode = root.callbackNode, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$3 = 31 - clz32(lanes), - lane = 1 << index$3, - expirationTime = expirationTimes[index$3]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$3] = computeExpirationTime(lane, currentTime); - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; - } - suspendedLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === suspendedLanes) - null !== existingCallbackNode && cancelCallback$1(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0); - else if (2 === workInProgressSuspendedReason && workInProgressRoot === root) - (root.callbackPriority = 0), (root.callbackNode = null); - else if (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) - (root.callbackPriority = 0), (root.callbackNode = null); - else if ( - ((currentTime = suspendedLanes & -suspendedLanes), - root.callbackPriority !== currentTime) - ) { - null != existingCallbackNode && cancelCallback$1(existingCallbackNode); - if (0 !== (currentTime & 3)) - 0 === root.tag - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - (includesLegacySyncCallbacks = !0), - null === syncQueue - ? (syncQueue = [existingCallbackNode]) - : syncQueue.push(existingCallbackNode)) - : ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? (syncQueue = [existingCallbackNode]) - : syncQueue.push(existingCallbackNode)), - scheduleCallback$2(ImmediatePriority, flushSyncCallbacks), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(suspendedLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority$1; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority$1; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; + flushSyncWorkAcrossRoots_impl(!0)); } } function performConcurrentWorkOnRoot(root, didTimeout) { @@ -7968,7 +8047,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); if (6 === exitStatus) markRootSuspended(root, lanes); @@ -7982,16 +8061,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { exitStatus = renderRootSync(root, lanes); if (2 === exitStatus) { errorRetryLanes = lanes; - var errorRetryLanes$130 = getLanesToRetrySynchronouslyOnError( + var errorRetryLanes$129 = getLanesToRetrySynchronouslyOnError( root, errorRetryLanes ); - 0 !== errorRetryLanes$130 && - ((lanes = errorRetryLanes$130), + 0 !== errorRetryLanes$129 && + ((lanes = errorRetryLanes$129), (exitStatus = recoverFromConcurrentError( root, errorRetryLanes, - errorRetryLanes$130 + errorRetryLanes$129 ))); } if (1 === exitStatus) @@ -7999,7 +8078,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -8052,14 +8131,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if ((lanes & 8388480) === lanes) break; exitStatus = lanes; errorRetryLanes = root.eventTimes; - for (errorRetryLanes$130 = -1; 0 < exitStatus; ) { + for (errorRetryLanes$129 = -1; 0 < exitStatus; ) { var index$2 = 31 - clz32(exitStatus), lane = 1 << index$2; index$2 = errorRetryLanes[index$2]; - index$2 > errorRetryLanes$130 && (errorRetryLanes$130 = index$2); + index$2 > errorRetryLanes$129 && (errorRetryLanes$129 = index$2); exitStatus &= ~lane; } - exitStatus = errorRetryLanes$130; + exitStatus = errorRetryLanes$129; exitStatus = now() - exitStatus; exitStatus = (120 > exitStatus @@ -8111,10 +8190,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode - ? performConcurrentWorkOnRoot.bind(null, root) - : null; + ensureRootIsScheduled(root); + scheduleTaskForRootDuringMicrotask(root, now()); + root = + root.callbackNode === originalCallbackNode + ? performConcurrentWorkOnRoot.bind(null, root) + : null; + return root; } function recoverFromConcurrentError( root, @@ -8207,48 +8289,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 6)) throw Error(formatProdErrorMessage(327)); - flushPassiveEffects(); - var lanes = getNextLanes(root, 0); - if (0 === (lanes & 3)) return ensureRootIsScheduled(root, now()), null; - var exitStatus = renderRootSync(root, lanes); - if (0 !== root.tag && 2 === exitStatus) { - var originallyAttemptedLanes = lanes, - errorRetryLanes = getLanesToRetrySynchronouslyOnError( - root, - originallyAttemptedLanes - ); - 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError( - root, - originallyAttemptedLanes, - errorRetryLanes - ))); - } - if (1 === exitStatus) - throw ( - ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), - exitStatus) - ); - if (6 === exitStatus) - return ( - markRootSuspended(root, lanes), ensureRootIsScheduled(root, now()), null - ); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - commitRoot( - root, - workInProgressRootRecoverableErrors, - workInProgressTransitions - ); - ensureRootIsScheduled(root, now()); - return null; -} function resetWorkInProgressStack() { if (null !== workInProgress) { if (0 === workInProgressSuspendedReason) @@ -8373,8 +8413,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$133) { - handleThrow(root, thrownValue$133); + } catch (thrownValue$132) { + handleThrow(root, thrownValue$132); } while (1); resetContextDependencies(); @@ -8421,7 +8461,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -8478,8 +8518,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$135) { - handleThrow(root, thrownValue$135); + } catch (thrownValue$134) { + handleThrow(root, thrownValue$134); } while (1); resetContextDependencies(); @@ -8644,10 +8684,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$37 = offscreenQueue.retryQueue; - null === retryQueue$37 + var retryQueue$35 = offscreenQueue.retryQueue; + null === retryQueue$35 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$37.add(wakeable); + : retryQueue$35.add(wakeable); } } break; @@ -8850,7 +8890,7 @@ function commitRootImpl( remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(finishedWork.stateNode, renderPriorityLevel); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, finishedWork = 0; @@ -8879,7 +8919,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); return null; } function releaseRootPooledCache(root, remainingLanes) { @@ -8925,7 +8965,7 @@ function flushPassiveEffectsImpl() { commitPassiveUnmountOnFiber(root.current); commitPassiveMountOnFiber(root, root.current, lanes, transitions); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks, prevRootTransitionCallbacks = root.transitionCallbacks, @@ -8955,7 +8995,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = requestEventTime(); null !== rootFiber && (markRootUpdated(rootFiber, 2, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + ensureRootIsScheduled(rootFiber)); } function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) @@ -8992,7 +9032,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -9018,7 +9058,6 @@ function attachPingListener(root, wakeable, lanes) { function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); root.pingedLanes |= root.suspendedLanes & pingedLanes; workInProgressRoot === root && (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && @@ -9029,7 +9068,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { 500 > now() - globalMostRecentFallbackTime) ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { 0 === retryLane && @@ -9038,7 +9077,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { boundaryFiber = enqueueConcurrentRenderForLane(boundaryFiber, retryLane); null !== boundaryFiber && (markRootUpdated(boundaryFiber, retryLane, eventTime), - ensureRootIsScheduled(boundaryFiber, eventTime)); + ensureRootIsScheduled(boundaryFiber)); } function retryDehydratedSuspenseBoundary(boundaryFiber) { var suspenseState = boundaryFiber.memoizedState, @@ -9494,7 +9533,7 @@ beginWork = function (current, workInProgress, renderLanes) { throw Error(formatProdErrorMessage(156, workInProgress.tag)); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -9801,6 +9840,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -10011,19 +10051,19 @@ var slice = Array.prototype.slice, }; return Text; })(React.Component), - devToolsConfig$jscomp$inline_1146 = { + devToolsConfig$jscomp$inline_1168 = { findFiberByHostInstance: function () { return null; }, bundleType: 0, - version: "18.3.0-www-classic-0c778728", + version: "18.3.0-www-classic-01a75bbd", rendererPackageName: "react-art" }; -var internals$jscomp$inline_1324 = { - bundleType: devToolsConfig$jscomp$inline_1146.bundleType, - version: devToolsConfig$jscomp$inline_1146.version, - rendererPackageName: devToolsConfig$jscomp$inline_1146.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1146.rendererConfig, +var internals$jscomp$inline_1342 = { + bundleType: devToolsConfig$jscomp$inline_1168.bundleType, + version: devToolsConfig$jscomp$inline_1168.version, + rendererPackageName: devToolsConfig$jscomp$inline_1168.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1168.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10040,26 +10080,26 @@ var internals$jscomp$inline_1324 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1146.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1168.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-0c778728" + reconcilerVersion: "18.3.0-www-classic-01a75bbd" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1325 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1343 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1325.isDisabled && - hook$jscomp$inline_1325.supportsFiber + !hook$jscomp$inline_1343.isDisabled && + hook$jscomp$inline_1343.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1325.inject( - internals$jscomp$inline_1324 + (rendererID = hook$jscomp$inline_1343.inject( + internals$jscomp$inline_1342 )), - (injectedHook = hook$jscomp$inline_1325); + (injectedHook = hook$jscomp$inline_1343); } catch (err) {} } var Path = Mode$1.Path; diff --git a/compiled/facebook-www/ReactART-prod.modern.js b/compiled/facebook-www/ReactART-prod.modern.js index 73db6cb2f7..2dc5aed4ac 100644 --- a/compiled/facebook-www/ReactART-prod.modern.js +++ b/compiled/facebook-www/ReactART-prod.modern.js @@ -71,6 +71,8 @@ var ReactSharedInternals = dynamicFeatureFlags.enableLazyContextPropagation, enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane, enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask, REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -242,7 +244,7 @@ function childrenAsString(children) { : "" : ""; } -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -793,50 +795,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - syncQueue = null, - includesLegacySyncCallbacks = !1, - isFlushingSyncQueue = !1; -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var previousUpdatePriority = currentUpdatePriority; - currentUpdatePriority = 2; - for (var errors = null, queue = syncQueue, i = 0; i < queue.length; i++) { - var callback = queue[i]; - try { - do callback = callback(!0); - while (null !== callback); - } catch (error) { - null === errors ? (errors = [error]) : errors.push(error); - } - } - syncQueue = null; - includesLegacySyncCallbacks = !1; - currentUpdatePriority = previousUpdatePriority; - isFlushingSyncQueue = !1; - if (null !== errors) { - if (1 < errors.length) { - if ("function" === typeof AggregateError) - throw new AggregateError(errors); - for ( - previousUpdatePriority = 1; - previousUpdatePriority < errors.length; - previousUpdatePriority++ - ) - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[previousUpdatePriority]) - ); - } - throw errors[0]; - } - } - return null; -} -function throwError(error) { - throw error; -} -var contextStackCursor = createCursor(null), + contextStackCursor = createCursor(null), contextFiberStackCursor = createCursor(null), rootInstanceStackCursor = createCursor(null); function pushHostContainer(fiber, nextRootInstance) { @@ -2267,10 +2226,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$30 = thenableIndexCounter; + var index$28 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$30); + usable = trackUsedThenable(thenableState, usable, index$28); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -4881,7 +4840,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -4903,7 +4862,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -5061,14 +5020,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$75 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$75 = lastTailNode), + for (var lastTailNode$73 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$73 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$75 + null === lastTailNode$73 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$75.sibling = null); + : (lastTailNode$73.sibling = null); } } function bubbleProperties(completedWork) { @@ -5078,19 +5037,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$76 = completedWork.child; null !== child$76; ) - (newChildLanes |= child$76.lanes | child$76.childLanes), - (subtreeFlags |= child$76.subtreeFlags & 31457280), - (subtreeFlags |= child$76.flags & 31457280), - (child$76.return = completedWork), - (child$76 = child$76.sibling); + for (var child$74 = completedWork.child; null !== child$74; ) + (newChildLanes |= child$74.lanes | child$74.childLanes), + (subtreeFlags |= child$74.subtreeFlags & 31457280), + (subtreeFlags |= child$74.flags & 31457280), + (child$74.return = completedWork), + (child$74 = child$74.sibling); else - for (child$76 = completedWork.child; null !== child$76; ) - (newChildLanes |= child$76.lanes | child$76.childLanes), - (subtreeFlags |= child$76.subtreeFlags), - (subtreeFlags |= child$76.flags), - (child$76.return = completedWork), - (child$76 = child$76.sibling); + for (child$74 = completedWork.child; null !== child$74; ) + (newChildLanes |= child$74.lanes | child$74.childLanes), + (subtreeFlags |= child$74.subtreeFlags), + (subtreeFlags |= child$74.flags), + (child$74.return = completedWork), + (child$74 = child$74.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -5264,11 +5223,11 @@ function completeWork(current, workInProgress, renderLanes) { null !== newProps.alternate.memoizedState && null !== newProps.alternate.memoizedState.cachePool && (instance = newProps.alternate.memoizedState.cachePool.pool); - var cache$80 = null; + var cache$78 = null; null !== newProps.memoizedState && null !== newProps.memoizedState.cachePool && - (cache$80 = newProps.memoizedState.cachePool.pool); - cache$80 !== instance && (newProps.flags |= 2048); + (cache$78 = newProps.memoizedState.cachePool.pool); + cache$78 !== instance && (newProps.flags |= 2048); } renderLanes !== current && (enableTransitionTracing && (workInProgress.child.flags |= 2048), @@ -5294,8 +5253,8 @@ function completeWork(current, workInProgress, renderLanes) { instance = workInProgress.memoizedState; if (null === instance) return bubbleProperties(workInProgress), null; newProps = 0 !== (workInProgress.flags & 128); - cache$80 = instance.rendering; - if (null === cache$80) + cache$78 = instance.rendering; + if (null === cache$78) if (newProps) cutOffTailIfNeeded(instance, !1); else { if ( @@ -5303,11 +5262,11 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current && 0 !== (current.flags & 128)) ) for (current = workInProgress.child; null !== current; ) { - cache$80 = findFirstSuspended(current); - if (null !== cache$80) { + cache$78 = findFirstSuspended(current); + if (null !== cache$78) { workInProgress.flags |= 128; cutOffTailIfNeeded(instance, !1); - current = cache$80.updateQueue; + current = cache$78.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); workInProgress.subtreeFlags = 0; @@ -5332,7 +5291,7 @@ function completeWork(current, workInProgress, renderLanes) { } else { if (!newProps) - if (((current = findFirstSuspended(cache$80)), null !== current)) { + if (((current = findFirstSuspended(cache$78)), null !== current)) { if ( ((workInProgress.flags |= 128), (newProps = !0), @@ -5342,7 +5301,7 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(instance, !0), null === instance.tail && "hidden" === instance.tailMode && - !cache$80.alternate) + !cache$78.alternate) ) return bubbleProperties(workInProgress), null; } else @@ -5354,13 +5313,13 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(instance, !1), (workInProgress.lanes = 8388608)); instance.isBackwards - ? ((cache$80.sibling = workInProgress.child), - (workInProgress.child = cache$80)) + ? ((cache$78.sibling = workInProgress.child), + (workInProgress.child = cache$78)) : ((current = instance.last), null !== current - ? (current.sibling = cache$80) - : (workInProgress.child = cache$80), - (instance.last = cache$80)); + ? (current.sibling = cache$78) + : (workInProgress.child = cache$78), + (instance.last = cache$78)); } if (null !== instance.tail) return ( @@ -5611,8 +5570,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$97) { - captureCommitPhaseError(current, nearestMountedAncestor, error$97); + } catch (error$95) { + captureCommitPhaseError(current, nearestMountedAncestor, error$95); } else ref.current = null; } @@ -5811,11 +5770,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$98) { + } catch (error$96) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$98 + error$96 ); } } @@ -6402,8 +6361,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$106) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$106); + } catch (error$104) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$104); } } break; @@ -6439,11 +6398,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null !== updatePayload) try { flags._applyProps(flags, newProps, current); - } catch (error$109) { + } catch (error$107) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$109 + error$107 ); } } @@ -6480,8 +6439,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$111) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$111); + } catch (error$109) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$109); } flags = finishedWork.updateQueue; null !== flags && @@ -6621,12 +6580,12 @@ function commitReconciliationEffects(finishedWork) { break; case 3: case 4: - var parent$101 = JSCompiler_inline_result.stateNode.containerInfo, - before$102 = getHostSibling(finishedWork); + var parent$99 = JSCompiler_inline_result.stateNode.containerInfo, + before$100 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$102, - parent$101 + before$100, + parent$99 ); break; default: @@ -7087,9 +7046,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$120 = finishedWork.stateNode; + var instance$118 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$120._visibility & 4 + ? instance$118._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -7102,7 +7061,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$120._visibility |= 4), + : ((instance$118._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -7110,7 +7069,7 @@ function recursivelyTraverseReconnectPassiveEffects( committedTransitions, includeWorkInProgressEffects )) - : ((instance$120._visibility |= 4), + : ((instance$118._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -7123,7 +7082,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$120 + instance$118 ); break; case 24: @@ -7432,7 +7391,203 @@ var DefaultCacheDispatcher = { return cacheForType; } }, - ceil = Math.ceil, + firstScheduledRoot = null, + lastScheduledRoot = null, + didScheduleMicrotask = !1, + mightHavePendingSyncWork = !1, + isFlushingWork = !1; +function ensureRootIsScheduled(root) { + root !== lastScheduledRoot && + null === root.next && + (null === lastScheduledRoot + ? (firstScheduledRoot = lastScheduledRoot = root) + : (lastScheduledRoot = lastScheduledRoot.next = root)); + mightHavePendingSyncWork = !0; + didScheduleMicrotask || + ((didScheduleMicrotask = !0), + scheduleCallback$3(ImmediatePriority, processRootScheduleInMicrotask)); + enableDeferRootSchedulingToMicrotask || + scheduleTaskForRootDuringMicrotask(root, now()); +} +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (!isFlushingWork && mightHavePendingSyncWork) { + var workInProgressRoot$jscomp$0 = workInProgressRoot, + workInProgressRootRenderLanes$jscomp$0 = workInProgressRootRenderLanes, + errors = null; + isFlushingWork = !0; + do { + var didPerformSomeWork = !1; + for (var root = firstScheduledRoot; null !== root; ) { + if ( + (!onlyLegacy || 0 === root.tag) && + 0 !== + (getNextLanes( + root, + root === workInProgressRoot$jscomp$0 + ? workInProgressRootRenderLanes$jscomp$0 + : 0 + ) & + 3) + ) + try { + didPerformSomeWork = !0; + var root$jscomp$0 = root; + if (0 !== (executionContext & 6)) + throw Error(formatProdErrorMessage(327)); + flushPassiveEffects(); + var lanes = getNextLanes(root$jscomp$0, 0); + if (0 !== (lanes & 3)) { + var exitStatus = renderRootSync(root$jscomp$0, lanes); + if (0 !== root$jscomp$0.tag && 2 === exitStatus) { + var originallyAttemptedLanes = lanes, + errorRetryLanes = getLanesToRetrySynchronouslyOnError( + root$jscomp$0, + originallyAttemptedLanes + ); + 0 !== errorRetryLanes && + ((lanes = errorRetryLanes), + (exitStatus = recoverFromConcurrentError( + root$jscomp$0, + originallyAttemptedLanes, + errorRetryLanes + ))); + } + if (1 === exitStatus) + throw ( + ((originallyAttemptedLanes = workInProgressRootFatalError), + prepareFreshStack(root$jscomp$0, 0), + markRootSuspended(root$jscomp$0, lanes), + ensureRootIsScheduled(root$jscomp$0), + originallyAttemptedLanes) + ); + 6 === exitStatus + ? markRootSuspended(root$jscomp$0, lanes) + : ((root$jscomp$0.finishedWork = + root$jscomp$0.current.alternate), + (root$jscomp$0.finishedLanes = lanes), + commitRoot( + root$jscomp$0, + workInProgressRootRecoverableErrors, + workInProgressTransitions + )); + } + ensureRootIsScheduled(root$jscomp$0); + } catch (error) { + null === errors ? (errors = [error]) : errors.push(error); + } + root = root.next; + } + } while (didPerformSomeWork); + isFlushingWork = !1; + if (null !== errors) { + if (1 < errors.length) { + if ("function" === typeof AggregateError) + throw new AggregateError(errors); + for (onlyLegacy = 1; onlyLegacy < errors.length; onlyLegacy++) + (workInProgressRoot$jscomp$0 = throwError.bind( + null, + errors[onlyLegacy] + )), + scheduleCallback$3(ImmediatePriority, workInProgressRoot$jscomp$0); + } + throw errors[0]; + } + } +} +function throwError(error) { + throw error; +} +function processRootScheduleInMicrotask() { + mightHavePendingSyncWork = didScheduleMicrotask = !1; + for ( + var currentTime = now(), prev = null, root = firstScheduledRoot; + null !== root; + + ) { + var next = root.next, + nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + 0 === nextLanes + ? ((root.next = null), + null === prev ? (firstScheduledRoot = next) : (prev.next = next), + null === next && (lastScheduledRoot = prev)) + : ((prev = root), + 0 !== (nextLanes & 3) && (mightHavePendingSyncWork = !0)); + root = next; + } + flushSyncWorkAcrossRoots_impl(!1); +} +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + for ( + var suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes & -125829121; + 0 < lanes; + + ) { + var index$3 = 31 - clz32(lanes), + lane = 1 << index$3, + expirationTime = expirationTimes[index$3]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$3] = computeExpirationTime(lane, currentTime); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + currentTime = workInProgressRoot; + suspendedLanes = workInProgressRootRenderLanes; + suspendedLanes = getNextLanes( + root, + root === currentTime ? suspendedLanes : 0 + ); + pingedLanes = root.callbackNode; + if ( + 0 === suspendedLanes || + (2 === workInProgressSuspendedReason && root === currentTime) || + (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) + ) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackNode = null), + (root.callbackPriority = 0) + ); + if (0 !== (suspendedLanes & 3)) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackPriority = 2), + (root.callbackNode = null), + 2 + ); + currentTime = suspendedLanes & -suspendedLanes; + if (currentTime === root.callbackPriority) return currentTime; + null !== pingedLanes && cancelCallback$1(pingedLanes); + switch (lanesToEventPriority(suspendedLanes)) { + case 2: + suspendedLanes = ImmediatePriority; + break; + case 8: + suspendedLanes = UserBlockingPriority; + break; + case 32: + suspendedLanes = NormalPriority$1; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority$1; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$3(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} +var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentCache = ReactSharedInternals.ReactCurrentCache, @@ -7558,108 +7713,32 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { markRootSuspended(root, workInProgressRootRenderLanes)); markRootUpdated(root, lane, eventTime); if (0 === (executionContext & 2) || root !== workInProgressRoot) { - if (enableTransitionTracing) { - var transition = ReactCurrentBatchConfig.transition; - if ( - null !== transition && - null != transition.name && - (-1 === transition.startTime && (transition.startTime = now()), - enableTransitionTracing) - ) { - var transitionLanesMap = root.transitionLanes, - index$7 = 31 - clz32(lane), - transitions = transitionLanesMap[index$7]; - null === transitions && (transitions = new Set()); - transitions.add(transition); - transitionLanesMap[index$7] = transitions; - } + if ( + enableTransitionTracing && + ((eventTime = ReactCurrentBatchConfig.transition), + null !== eventTime && + null != eventTime.name && + (-1 === eventTime.startTime && (eventTime.startTime = now()), + enableTransitionTracing)) + ) { + var transitionLanesMap = root.transitionLanes, + index$7 = 31 - clz32(lane), + transitions = transitionLanesMap[index$7]; + null === transitions && (transitions = new Set()); + transitions.add(eventTime); + transitionLanesMap[index$7] = transitions; } root === workInProgressRoot && (0 === (executionContext & 2) && (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended(root, workInProgressRootRenderLanes)); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); 2 === lane && 0 === executionContext && 0 === (fiber.mode & 1) && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); - } -} -function ensureRootIsScheduled(root, currentTime) { - for ( - var existingCallbackNode = root.callbackNode, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$3 = 31 - clz32(lanes), - lane = 1 << index$3, - expirationTime = expirationTimes[index$3]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$3] = computeExpirationTime(lane, currentTime); - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; - } - suspendedLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === suspendedLanes) - null !== existingCallbackNode && cancelCallback$1(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0); - else if (2 === workInProgressSuspendedReason && workInProgressRoot === root) - (root.callbackPriority = 0), (root.callbackNode = null); - else if (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) - (root.callbackPriority = 0), (root.callbackNode = null); - else if ( - ((currentTime = suspendedLanes & -suspendedLanes), - root.callbackPriority !== currentTime) - ) { - null != existingCallbackNode && cancelCallback$1(existingCallbackNode); - if (0 !== (currentTime & 3)) - 0 === root.tag - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - (includesLegacySyncCallbacks = !0), - null === syncQueue - ? (syncQueue = [existingCallbackNode]) - : syncQueue.push(existingCallbackNode)) - : ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? (syncQueue = [existingCallbackNode]) - : syncQueue.push(existingCallbackNode)), - scheduleCallback$2(ImmediatePriority, flushSyncCallbacks), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(suspendedLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority$1; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority$1; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; + flushSyncWorkAcrossRoots_impl(!0)); } } function performConcurrentWorkOnRoot(root, didTimeout) { @@ -7700,7 +7779,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); if (6 === exitStatus) markRootSuspended(root, lanes); @@ -7714,16 +7793,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { exitStatus = renderRootSync(root, lanes); if (2 === exitStatus) { errorRetryLanes = lanes; - var errorRetryLanes$129 = getLanesToRetrySynchronouslyOnError( + var errorRetryLanes$128 = getLanesToRetrySynchronouslyOnError( root, errorRetryLanes ); - 0 !== errorRetryLanes$129 && - ((lanes = errorRetryLanes$129), + 0 !== errorRetryLanes$128 && + ((lanes = errorRetryLanes$128), (exitStatus = recoverFromConcurrentError( root, errorRetryLanes, - errorRetryLanes$129 + errorRetryLanes$128 ))); } if (1 === exitStatus) @@ -7731,7 +7810,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -7784,14 +7863,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if ((lanes & 8388480) === lanes) break; exitStatus = lanes; errorRetryLanes = root.eventTimes; - for (errorRetryLanes$129 = -1; 0 < exitStatus; ) { + for (errorRetryLanes$128 = -1; 0 < exitStatus; ) { var index$2 = 31 - clz32(exitStatus), lane = 1 << index$2; index$2 = errorRetryLanes[index$2]; - index$2 > errorRetryLanes$129 && (errorRetryLanes$129 = index$2); + index$2 > errorRetryLanes$128 && (errorRetryLanes$128 = index$2); exitStatus &= ~lane; } - exitStatus = errorRetryLanes$129; + exitStatus = errorRetryLanes$128; exitStatus = now() - exitStatus; exitStatus = (120 > exitStatus @@ -7843,10 +7922,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode - ? performConcurrentWorkOnRoot.bind(null, root) - : null; + ensureRootIsScheduled(root); + scheduleTaskForRootDuringMicrotask(root, now()); + root = + root.callbackNode === originalCallbackNode + ? performConcurrentWorkOnRoot.bind(null, root) + : null; + return root; } function recoverFromConcurrentError( root, @@ -7939,48 +8021,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 6)) throw Error(formatProdErrorMessage(327)); - flushPassiveEffects(); - var lanes = getNextLanes(root, 0); - if (0 === (lanes & 3)) return ensureRootIsScheduled(root, now()), null; - var exitStatus = renderRootSync(root, lanes); - if (0 !== root.tag && 2 === exitStatus) { - var originallyAttemptedLanes = lanes, - errorRetryLanes = getLanesToRetrySynchronouslyOnError( - root, - originallyAttemptedLanes - ); - 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError( - root, - originallyAttemptedLanes, - errorRetryLanes - ))); - } - if (1 === exitStatus) - throw ( - ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), - exitStatus) - ); - if (6 === exitStatus) - return ( - markRootSuspended(root, lanes), ensureRootIsScheduled(root, now()), null - ); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - commitRoot( - root, - workInProgressRootRecoverableErrors, - workInProgressTransitions - ); - ensureRootIsScheduled(root, now()); - return null; -} function resetWorkInProgressStack() { if (null !== workInProgress) { if (0 === workInProgressSuspendedReason) @@ -8105,8 +8145,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$132) { - handleThrow(root, thrownValue$132); + } catch (thrownValue$131) { + handleThrow(root, thrownValue$131); } while (1); resetContextDependencies(); @@ -8153,7 +8193,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -8210,8 +8250,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$134) { - handleThrow(root, thrownValue$134); + } catch (thrownValue$133) { + handleThrow(root, thrownValue$133); } while (1); resetContextDependencies(); @@ -8376,10 +8416,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$37 = offscreenQueue.retryQueue; - null === retryQueue$37 + var retryQueue$35 = offscreenQueue.retryQueue; + null === retryQueue$35 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$37.add(wakeable); + : retryQueue$35.add(wakeable); } } break; @@ -8582,7 +8622,7 @@ function commitRootImpl( remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(finishedWork.stateNode, renderPriorityLevel); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, finishedWork = 0; @@ -8611,7 +8651,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); return null; } function releaseRootPooledCache(root, remainingLanes) { @@ -8657,7 +8697,7 @@ function flushPassiveEffectsImpl() { commitPassiveUnmountOnFiber(root.current); commitPassiveMountOnFiber(root, root.current, lanes, transitions); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks, prevRootTransitionCallbacks = root.transitionCallbacks, @@ -8687,7 +8727,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = requestEventTime(); null !== rootFiber && (markRootUpdated(rootFiber, 2, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + ensureRootIsScheduled(rootFiber)); } function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) @@ -8724,7 +8764,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -8750,7 +8790,6 @@ function attachPingListener(root, wakeable, lanes) { function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); root.pingedLanes |= root.suspendedLanes & pingedLanes; workInProgressRoot === root && (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && @@ -8761,7 +8800,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { 500 > now() - globalMostRecentFallbackTime) ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { 0 === retryLane && @@ -8770,7 +8809,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { boundaryFiber = enqueueConcurrentRenderForLane(boundaryFiber, retryLane); null !== boundaryFiber && (markRootUpdated(boundaryFiber, retryLane, eventTime), - ensureRootIsScheduled(boundaryFiber, eventTime)); + ensureRootIsScheduled(boundaryFiber)); } function retryDehydratedSuspenseBoundary(boundaryFiber) { var suspenseState = boundaryFiber.memoizedState, @@ -9199,7 +9238,7 @@ beginWork = function (current, workInProgress, renderLanes) { throw Error(formatProdErrorMessage(156, workInProgress.tag)); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -9506,6 +9545,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -9676,19 +9716,19 @@ var slice = Array.prototype.slice, }; return Text; })(React.Component), - devToolsConfig$jscomp$inline_1126 = { + devToolsConfig$jscomp$inline_1148 = { findFiberByHostInstance: function () { return null; }, bundleType: 0, - version: "18.3.0-www-modern-1f93a1ad", + version: "18.3.0-www-modern-53d54e9c", rendererPackageName: "react-art" }; -var internals$jscomp$inline_1304 = { - bundleType: devToolsConfig$jscomp$inline_1126.bundleType, - version: devToolsConfig$jscomp$inline_1126.version, - rendererPackageName: devToolsConfig$jscomp$inline_1126.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1126.rendererConfig, +var internals$jscomp$inline_1322 = { + bundleType: devToolsConfig$jscomp$inline_1148.bundleType, + version: devToolsConfig$jscomp$inline_1148.version, + rendererPackageName: devToolsConfig$jscomp$inline_1148.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1148.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9705,26 +9745,26 @@ var internals$jscomp$inline_1304 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1126.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1148.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-1f93a1ad" + reconcilerVersion: "18.3.0-www-modern-53d54e9c" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1305 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1323 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1305.isDisabled && - hook$jscomp$inline_1305.supportsFiber + !hook$jscomp$inline_1323.isDisabled && + hook$jscomp$inline_1323.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1305.inject( - internals$jscomp$inline_1304 + (rendererID = hook$jscomp$inline_1323.inject( + internals$jscomp$inline_1322 )), - (injectedHook = hook$jscomp$inline_1305); + (injectedHook = hook$jscomp$inline_1323); } catch (err) {} } var Path = Mode$1.Path; diff --git a/compiled/facebook-www/ReactDOM-dev.classic.js b/compiled/facebook-www/ReactDOM-dev.classic.js index 0ffa581136..ed0d3494b7 100644 --- a/compiled/facebook-www/ReactDOM-dev.classic.js +++ b/compiled/facebook-www/ReactDOM-dev.classic.js @@ -141,7 +141,9 @@ var disableInputAttributeSyncing = enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane, enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = - dynamicFeatureFlags.enableCustomElementPropertySupport; // On WWW, false is used for a new modern build. + dynamicFeatureFlags.enableCustomElementPropertySupport, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask; // On WWW, false is used for a new modern build. var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableProfilerNestedUpdatePhase = true; @@ -1104,7 +1106,7 @@ function popHostContext(fiber) { } // This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback; +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback; var cancelCallback$1 = Scheduler.unstable_cancelCallback; var shouldYield = Scheduler.unstable_shouldYield; var requestPaint = Scheduler.unstable_requestPaint; @@ -7439,102 +7441,6 @@ function is(x, y) { var objectIs = typeof Object.is === "function" ? Object.is : is; // $FlowFixMe[method-unbinding] -var syncQueue = null; -var includesLegacySyncCallbacks = false; -var isFlushingSyncQueue = false; -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]; - } 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 scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = true; - scheduleSyncCallback(callback); -} -function flushSyncCallbacksOnlyInLegacyMode() { - // Only flushes the queue if there's a legacy sync callback scheduled. - // TODO: There's only a single type of callback: performSyncOnWorkOnRoot. So - // it might make more sense for the queue to be a list of roots instead of a - // list of generic callbacks. Then we can have two: one for legacy roots, one - // for concurrent roots. And this method would only flush the legacy ones. - if (includesLegacySyncCallbacks) { - flushSyncCallbacks(); - } -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrance. - isFlushingSyncQueue = true; // Set the event priority to discrete - // TODO: Is this necessary anymore? The only user code that runs in this - // queue is in the render or commit phases, which already set the - // event priority. Should be able to remove. - - var previousUpdatePriority = getCurrentUpdatePriority(); - setCurrentUpdatePriority(DiscreteEventPriority); - var errors = null; - var queue = syncQueue; // $FlowFixMe[incompatible-use] found when upgrading Flow - - for (var i = 0; i < queue.length; i++) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - var callback = queue[i]; - - try { - do { - var isSync = true; // $FlowFixMe[incompatible-type] we bail out when we get a null - - callback = callback(isSync); - } while (callback !== null); - } catch (error) { - // Collect errors so we can rethrow them at the end - if (errors === null) { - errors = [error]; - } else { - errors.push(error); - } - } - } - - syncQueue = null; - includesLegacySyncCallbacks = false; - setCurrentUpdatePriority(previousUpdatePriority); - isFlushingSyncQueue = false; - - if (errors !== null) { - if (errors.length > 1) { - if (typeof AggregateError === "function") { - // eslint-disable-next-line no-undef - throw new AggregateError(errors); - } else { - for (var _i = 1; _i < errors.length; _i++) { - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[_i]) - ); - } - - var firstError = errors[0]; - throw firstError; - } - } else { - var error = errors[0]; - throw error; - } - } - } - - return null; -} - -function throwError(error) { - throw error; -} - var nativeConsole = console; var nativeConsoleLog = null; var pendingGroupArgs = []; @@ -9923,7 +9829,7 @@ var ReactStrictModeWarnings = { }; } -var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we +var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we // detect this is caught by userspace, we'll log a warning in development. var SuspenseException = new Error( @@ -9959,8 +9865,8 @@ function isThenableResolved(thenable) { function noop$2() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactCurrentActQueue$2.current !== null) { - ReactCurrentActQueue$2.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var previous = thenableState[index]; @@ -22096,7 +22002,7 @@ var AbortControllerLocal = }; // Intentionally not named imports because Rollup would // use dynamic dispatch for CommonJS interop named imports. -var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority; var CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -22152,7 +22058,7 @@ function releaseCache(cache) { } if (cache.refCount === 0) { - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -28663,7 +28569,7 @@ function onCommitRoot() { } } -var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; +var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -28688,7 +28594,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -28719,6 +28625,394 @@ function schedulePostPaintCallback(callback) { } } +var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, +// there's only a single root, but we do support multi root apps, hence this +// extra complexity. But this module is optimized for the single root case. + +var firstScheduledRoot = null; +var lastScheduledRoot = null; // Used to prevent redundant mircotasks from being scheduled. + +var didScheduleMicrotask = false; // `act` "microtasks" are scheduled on the `act` queue instead of an actual +// microtask, so we have to dedupe those separately. This wouldn't be an issue +// if we required all `act` calls to be awaited, which we might in the future. + +var didScheduleMicrotask_act = false; // Used to quickly bail out of flushSync if there's no sync work to do. + +var mightHavePendingSyncWork = false; +var isFlushingWork = false; +function ensureRootIsScheduled(root) { + // This function is called whenever a root receives an update. It does two + // things 1) it ensures the root is in the root schedule, and 2) it ensures + // there's a pending microtask to process the root schedule. + // + // Most of the actual scheduling logic does not happen until + // `scheduleTaskForRootDuringMicrotask` runs. + // Add the root to the schedule + if (root === lastScheduledRoot || root.next !== null); + else { + if (lastScheduledRoot === null) { + firstScheduledRoot = lastScheduledRoot = root; + } else { + lastScheduledRoot.next = root; + lastScheduledRoot = root; + } + } // Any time a root received an update, we set this to true until the next time + // we process the schedule. If it's false, then we can quickly exit flushSync + // without consulting the schedule. + + mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure + // there's a task scheduled for each one at the correct priority. + + if (ReactCurrentActQueue$1.current !== null) { + // We're inside an `act` scope. + if (!didScheduleMicrotask_act) { + didScheduleMicrotask_act = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } else { + if (!didScheduleMicrotask) { + didScheduleMicrotask = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } + + if (!enableDeferRootSchedulingToMicrotask) { + // While this flag is disabled, we schedule the render task immediately + // instead of waiting a microtask. + // TODO: We need to land enableDeferRootSchedulingToMicrotask ASAP to + // unblock additional features we have planned. + scheduleTaskForRootDuringMicrotask(root, now$1()); + } +} +function flushSyncWorkOnAllRoots() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(false); +} +function flushSyncWorkOnLegacyRootsOnly() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(true); +} + +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (isFlushingWork) { + // Prevent reentrancy. + // TODO: Is this overly defensive? The callers must check the execution + // context first regardless. + return; + } + + if (!mightHavePendingSyncWork) { + // Fast path. There's no sync work to do. + return; + } + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); // There may or may not be synchronous work scheduled. Let's check. + + var didPerformSomeWork; + var errors = null; + isFlushingWork = true; + + do { + didPerformSomeWork = false; + var root = firstScheduledRoot; + + while (root !== null) { + if (onlyLegacy && root.tag !== LegacyRoot); + else { + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + + if (includesSyncLane(nextLanes)) { + // This root has pending sync work. Flush it now. + try { + // TODO: Pass nextLanes as an argument instead of computing it again + // inside performSyncWorkOnRoot. + didPerformSomeWork = true; + performSyncWorkOnRoot(root); + } catch (error) { + // Collect errors so we can rethrow them at the end + if (errors === null) { + errors = [error]; + } else { + errors.push(error); + } + } + } + } + + root = root.next; + } + } while (didPerformSomeWork); + + isFlushingWork = false; // If any errors were thrown, rethrow them right before exiting. + // TODO: Consider returning these to the caller, to allow them to decide + // how/when to rethrow. + + if (errors !== null) { + if (errors.length > 1) { + if (typeof AggregateError === "function") { + // eslint-disable-next-line no-undef + throw new AggregateError(errors); + } else { + for (var i = 1; i < errors.length; i++) { + scheduleImmediateTask(throwError.bind(null, errors[i])); + } + + var firstError = errors[0]; + throw firstError; + } + } else { + var error = errors[0]; + throw error; + } + } +} + +function throwError(error) { + throw error; +} + +function processRootScheduleInMicrotask() { + // This function is always called inside a microtask. It should never be + // called synchronously. + didScheduleMicrotask = false; + + { + didScheduleMicrotask_act = false; + } // We'll recompute this as we iterate through all the roots and schedule them. + + mightHavePendingSyncWork = false; + var currentTime = now$1(); + var prev = null; + var root = firstScheduledRoot; + + while (root !== null) { + var next = root.next; + var nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + + if (nextLanes === NoLane) { + // This root has no more pending work. Remove it from the schedule. To + // guard against subtle reentrancy bugs, this microtask is the only place + // we do this — you can add roots to the schedule whenever, but you can + // only remove them here. + // Null this out so we know it's been removed from the schedule. + root.next = null; + + if (prev === null) { + // This is the new head of the list + firstScheduledRoot = next; + } else { + prev.next = next; + } + + if (next === null) { + // This is the new tail of the list + lastScheduledRoot = prev; + } + } else { + // This root still has work. Keep it in the list. + prev = root; + + if (includesSyncLane(nextLanes)) { + mightHavePendingSyncWork = true; + } + } + + root = next; + } // At the end of the microtask, flush any pending synchronous work. This has + // to come at the end, because it does actual rendering work that might throw. + + flushSyncWorkOnAllRoots(); +} + +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + // This function is always called inside a microtask, or at the very end of a + // rendering task right before we yield to the main thread. It should never be + // called synchronously. + // + // TODO: Unless enableDeferRootSchedulingToMicrotask is off. We need to land + // that ASAP to unblock additional features we have planned. + // + // This function also never performs React work synchronously; it should + // only schedule work to be performed later, in a separate task or microtask. + // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + var existingCallbackNode = root.callbackNode; + + if ( + nextLanes === NoLanes || // If this root is currently suspended and waiting for data to resolve, don't + // schedule a task to render it. We'll either wait for a ping, or wait to + // receive an update. + (isWorkLoopSuspendedOnData() && root === workInProgressRoot) || // We should only interrupt a pending commit if the new update + // is urgent. + (root.cancelPendingCommit !== null && includesOnlyNonUrgentLanes(nextLanes)) + ) { + // Fast path: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackNode = null; + root.callbackPriority = NoLane; + return NoLane; + } // Schedule a new callback in the host environment. + + if (includesSyncLane(nextLanes)) { + // Synchronous work is always flushed at the end of the microtask, so we + // don't need to schedule an additional task. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackPriority = SyncLane; + root.callbackNode = null; + return SyncLane; + } else { + // We use the highest priority lane to represent the priority of the callback. + var existingCallbackPriority = root.callbackPriority; + var newCallbackPriority = getHighestPriorityLane(nextLanes); + + if ( + newCallbackPriority === existingCallbackPriority && // Special case related to `act`. If the currently scheduled task is a + // Scheduler task, rather than an `act` task, cancel it and re-schedule + // on the `act` queue. + !( + ReactCurrentActQueue$1.current !== null && + existingCallbackNode !== fakeActCallbackNode$1 + ) + ) { + // The priority hasn't changed. We can reuse the existing task. + return newCallbackPriority; + } else { + // Cancel the existing callback. We'll schedule a new one below. + cancelCallback(existingCallbackNode); + } + + var schedulerPriorityLevel; + + switch (lanesToEventPriority(nextLanes)) { + case DiscreteEventPriority: + schedulerPriorityLevel = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriorityLevel = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriorityLevel = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority$1; + break; + } + + var newCallbackNode = scheduleCallback$1( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) + ); + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; + return newCallbackPriority; + } +} + +function getContinuationForRoot(root, originalCallbackNode) { + // This is called at the end of `performConcurrentWorkOnRoot` to determine + // if we need to schedule a continuation task. + // + // Usually `scheduleTaskForRootDuringMicrotask` only runs inside a microtask; + // however, since most of the logic for determining if we need a continuation + // versus a new task is the same, we cheat a bit and call it here. This is + // only safe to do because we know we're at the end of the browser task. + // So although it's not an actual microtask, it might as well be. + scheduleTaskForRootDuringMicrotask(root, now$1()); + + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } + + return null; +} +var fakeActCallbackNode$1 = {}; + +function scheduleCallback$1(priorityLevel, callback) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: We're inside an `act` scope (a testing utility). + // Instead of scheduling work in the host environment, add it to a + // fake internal queue that's managed by the `act` implementation. + ReactCurrentActQueue$1.current.push(callback); + return fakeActCallbackNode$1; + } else { + return scheduleCallback$3(priorityLevel, callback); + } +} + +function cancelCallback(callbackNode) { + if (callbackNode === fakeActCallbackNode$1); + else if (callbackNode !== null) { + cancelCallback$1(callbackNode); + } +} + +function scheduleImmediateTask(cb) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: Inside an `act` scope, we push microtasks to the fake `act` + // callback queue. This is because we currently support calling `act` + // without awaiting the result. The plan is to deprecate that, and require + // that you always await the result so that the microtasks have a chance to + // run. But it hasn't happened yet. + ReactCurrentActQueue$1.current.push(function () { + cb(); + return null; + }); + } // TODO: Can we land supportsMicrotasks? Which environments don't support it? + // Alternatively, can we move this check to the host config? + + { + scheduleMicrotask(function () { + // In Safari, appending an iframe forces microtasks to run. + // https://github.com/facebook/react/issues/22459 + // We don't support running callbacks in the middle of render + // or commit so we need to check against that. + var executionContext = getExecutionContext(); + + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + // Note that this would still prematurely flush the callbacks + // if this happens outside render or commit phase (e.g. in an event). + // Intentionally using a macrotask instead of a microtask here. This is + // wrong semantically but it prevents an infinite loop. The bug is + // Safari's, not ours, so we just do our best to not crash even though + // the behavior isn't completely correct. + scheduleCallback$3(ImmediatePriority, cb); + return; + } + + cb(); + }); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -28997,6 +29291,9 @@ function getWorkInProgressRoot() { function getWorkInProgressRootRenderLanes() { return workInProgressRootRenderLanes; } +function isWorkLoopSuspendedOnData() { + return workInProgressSuspendedReason === SuspendedOnData; +} function requestEventTime() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. @@ -29200,21 +29497,25 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); if ( lane === SyncLane && executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue.isBatchingLegacy + (fiber.mode & ConcurrentMode) === NoMode ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + if (ReactCurrentActQueue.isBatchingLegacy) { + // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } else { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncWorkOnLegacyRootsOnly(); + } } } } @@ -29231,173 +29532,12 @@ function scheduleInitialHydrationOnRoot(root, lane, eventTime) { var current = root.current; current.lanes = lane; markRootUpdated(root, lane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function isUnsafeClassRenderPhaseUpdate(fiber) { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return (executionContext & RenderContext) !== NoContext; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. - -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. - - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. - - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. - if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); - } - - root.callbackNode = null; - root.callbackPriority = NoLane; - return; - } // If this root is currently suspended and waiting for data to resolve, don't - // schedule a task to render it. We'll either wait for a ping, or wait to - // receive an update. - - if ( - workInProgressSuspendedReason === SuspendedOnData && - workInProgressRoot === root - ) { - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - - var cancelPendingCommit = root.cancelPendingCommit; - - if (cancelPendingCommit !== null) { - // We should only interrupt a pending commit if the new update - // is urgent. - if (includesOnlyNonUrgentLanes(nextLanes)) { - // The new update is not urgent. Don't interrupt the pending commit. - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - } // We use the highest priority lane to represent the priority of the callback. - - var newCallbackPriority = getHighestPriorityLane(nextLanes); // Check if there's an existing task. We may be able to reuse it. - - var existingCallbackPriority = root.callbackPriority; - - if ( - existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a - // Scheduler task, rather than an `act` task, cancel it and re-scheduled - // on the `act` queue. - !( - ReactCurrentActQueue.current !== null && - existingCallbackNode !== fakeActCallbackNode - ) - ) { - { - // 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 && - !includesSyncLane(existingCallbackPriority) - ) { - 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. - - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. - cancelCallback(existingCallbackNode); - } // Schedule a new callback. - - var newCallbackNode; - - if (includesSyncLane(newCallbackPriority)) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue.isBatchingLegacy !== null) { - ReactCurrentActQueue.didScheduleLegacyUpdate = true; - } - - scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } - - { - // Flush the queue in a microtask. - if (ReactCurrentActQueue.current !== null) { - // Inside `act`, use our internal `act` queue so that these get flushed - // at the end of the current scope even when using the sync version - // of `act`. - ReactCurrentActQueue.current.push(flushSyncCallbacks); - } else { - scheduleMicrotask(function () { - // In Safari, appending an iframe forces microtasks to run. - // https://github.com/facebook/react/issues/22459 - // We don't support running callbacks in the middle of render - // or commit so we need to check against that. - if ( - (executionContext & (RenderContext | CommitContext)) === - NoContext - ) { - // Note that this would still prematurely flush the callbacks - // if this happens outside render or commit phase (e.g. in an event). - flushSyncCallbacks(); - } - }); - } - } - - newCallbackNode = null; - } else { - var schedulerPriorityLevel; - - switch (lanesToEventPriority(nextLanes)) { - case DiscreteEventPriority: - schedulerPriorityLevel = ImmediatePriority; - break; - - case ContinuousEventPriority: - schedulerPriorityLevel = UserBlockingPriority; - break; - - case DefaultEventPriority: - schedulerPriorityLevel = NormalPriority$1; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority$1; - break; - } - - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. @@ -29429,6 +29569,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } // Determine the next lanes to work on, using the fields stored // on the root. + // TODO: This was already computed in the caller. Pass it as an argument. var lanes = getNextLanes( root, @@ -29479,7 +29620,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -29529,7 +29670,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var _fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw _fatalError; } // FIXME: Need to check for RootDidNotComplete again. The factoring here // isn't ideal. @@ -29542,15 +29683,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } - ensureRootIsScheduled(root, now$1()); - - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); - } - - return null; + ensureRootIsScheduled(root); + return getContinuationForRoot(root, originalCallbackNode); } function recoverFromConcurrentError( @@ -29911,12 +30045,13 @@ function performSyncWorkOnRoot(root) { throw new Error("Should not already be working."); } - flushPassiveEffects(); + flushPassiveEffects(); // TODO: This was already computed in the caller. Pass it as an argument. + var lanes = getNextLanes(root, NoLanes); if (!includesSyncLane(lanes)) { // There's no remaining sync work left. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } @@ -29947,7 +30082,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -29956,7 +30091,7 @@ function performSyncWorkOnRoot(root) { // cases where need to exit the current render without producing a // consistent tree or committing. markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -29971,18 +30106,20 @@ function performSyncWorkOnRoot(root) { ); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } - function flushRoot(root, lanes) { if (lanes !== NoLanes) { markRootEntangled(root, mergeLanes(lanes, SyncLane)); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - resetRenderTimer(); - flushSyncCallbacks(); + resetRenderTimer(); // TODO: For historical reasons this flushes all sync work across all + // roots. It shouldn't really matter either way, but we could change this + // to only flush the given root. + + flushSyncWorkOnAllRoots(); } } } @@ -30004,7 +30141,7 @@ function batchedUpdates$1(fn, a) { !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + flushSyncWorkOnLegacyRootsOnly(); } } } @@ -30046,7 +30183,7 @@ function flushSync$1(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -30604,7 +30741,7 @@ function renderRootConcurrent(root, lanes) { // currently working on a different root, so that we resume // rendering later. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; thenable.then(onResolution, onResolution); @@ -31431,7 +31568,7 @@ function commitRootImpl( } // Always call this before exiting `commitRoot`, to ensure that any // additional work on this root is scheduled. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without @@ -31484,7 +31621,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { if (enableDebugTracing) { @@ -31684,7 +31821,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks; @@ -31768,7 +31905,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -31807,7 +31944,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -31883,7 +32020,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -31919,7 +32055,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -31938,7 +32074,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -32326,19 +32462,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } } } -function cancelCallback(callbackNode) { - if (callbackNode === fakeActCallbackNode) { - return; - } // In production, always call Scheduler. This function will be stripped out. - - return cancelCallback$1(callbackNode); -} - function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. return ReactCurrentActQueue.current !== null; @@ -33614,6 +33742,7 @@ function FiberRootNode( this.cancelPendingCommit = null; this.context = null; this.pendingContext = null; + this.next = null; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); @@ -33747,7 +33876,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-6cf00fe7"; +var ReactVersion = "18.3.0-www-classic-9fb6c326"; function createPortal$1( children, diff --git a/compiled/facebook-www/ReactDOM-dev.modern.js b/compiled/facebook-www/ReactDOM-dev.modern.js index 3848f1311c..d9c917a744 100644 --- a/compiled/facebook-www/ReactDOM-dev.modern.js +++ b/compiled/facebook-www/ReactDOM-dev.modern.js @@ -258,7 +258,9 @@ var disableInputAttributeSyncing = enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane, enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = - dynamicFeatureFlags.enableCustomElementPropertySupport; // On WWW, true is used for a new modern build. + dynamicFeatureFlags.enableCustomElementPropertySupport, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask; // On WWW, true is used for a new modern build. var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableProfilerNestedUpdatePhase = true; @@ -406,7 +408,7 @@ var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; // This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback; +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback; var cancelCallback$1 = Scheduler.unstable_cancelCallback; var shouldYield = Scheduler.unstable_shouldYield; var requestPaint = Scheduler.unstable_requestPaint; @@ -7374,102 +7376,6 @@ function is(x, y) { var objectIs = typeof Object.is === "function" ? Object.is : is; // $FlowFixMe[method-unbinding] -var syncQueue = null; -var includesLegacySyncCallbacks = false; -var isFlushingSyncQueue = false; -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]; - } 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 scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = true; - scheduleSyncCallback(callback); -} -function flushSyncCallbacksOnlyInLegacyMode() { - // Only flushes the queue if there's a legacy sync callback scheduled. - // TODO: There's only a single type of callback: performSyncOnWorkOnRoot. So - // it might make more sense for the queue to be a list of roots instead of a - // list of generic callbacks. Then we can have two: one for legacy roots, one - // for concurrent roots. And this method would only flush the legacy ones. - if (includesLegacySyncCallbacks) { - flushSyncCallbacks(); - } -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrance. - isFlushingSyncQueue = true; // Set the event priority to discrete - // TODO: Is this necessary anymore? The only user code that runs in this - // queue is in the render or commit phases, which already set the - // event priority. Should be able to remove. - - var previousUpdatePriority = getCurrentUpdatePriority(); - setCurrentUpdatePriority(DiscreteEventPriority); - var errors = null; - var queue = syncQueue; // $FlowFixMe[incompatible-use] found when upgrading Flow - - for (var i = 0; i < queue.length; i++) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - var callback = queue[i]; - - try { - do { - var isSync = true; // $FlowFixMe[incompatible-type] we bail out when we get a null - - callback = callback(isSync); - } while (callback !== null); - } catch (error) { - // Collect errors so we can rethrow them at the end - if (errors === null) { - errors = [error]; - } else { - errors.push(error); - } - } - } - - syncQueue = null; - includesLegacySyncCallbacks = false; - setCurrentUpdatePriority(previousUpdatePriority); - isFlushingSyncQueue = false; - - if (errors !== null) { - if (errors.length > 1) { - if (typeof AggregateError === "function") { - // eslint-disable-next-line no-undef - throw new AggregateError(errors); - } else { - for (var _i = 1; _i < errors.length; _i++) { - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[_i]) - ); - } - - var firstError = errors[0]; - throw firstError; - } - } else { - var error = errors[0]; - throw error; - } - } - } - - return null; -} - -function throwError(error) { - throw error; -} - var nativeConsole = console; var nativeConsoleLog = null; var pendingGroupArgs = []; @@ -9858,7 +9764,7 @@ var ReactStrictModeWarnings = { }; } -var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we +var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we // detect this is caught by userspace, we'll log a warning in development. var SuspenseException = new Error( @@ -9894,8 +9800,8 @@ function isThenableResolved(thenable) { function noop$2() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactCurrentActQueue$2.current !== null) { - ReactCurrentActQueue$2.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var previous = thenableState[index]; @@ -21964,7 +21870,7 @@ var AbortControllerLocal = }; // Intentionally not named imports because Rollup would // use dynamic dispatch for CommonJS interop named imports. -var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority; var CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -22020,7 +21926,7 @@ function releaseCache(cache) { } if (cache.refCount === 0) { - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -28502,7 +28408,7 @@ function onCommitRoot() { } } -var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; +var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -28527,7 +28433,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -28558,6 +28464,394 @@ function schedulePostPaintCallback(callback) { } } +var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, +// there's only a single root, but we do support multi root apps, hence this +// extra complexity. But this module is optimized for the single root case. + +var firstScheduledRoot = null; +var lastScheduledRoot = null; // Used to prevent redundant mircotasks from being scheduled. + +var didScheduleMicrotask = false; // `act` "microtasks" are scheduled on the `act` queue instead of an actual +// microtask, so we have to dedupe those separately. This wouldn't be an issue +// if we required all `act` calls to be awaited, which we might in the future. + +var didScheduleMicrotask_act = false; // Used to quickly bail out of flushSync if there's no sync work to do. + +var mightHavePendingSyncWork = false; +var isFlushingWork = false; +function ensureRootIsScheduled(root) { + // This function is called whenever a root receives an update. It does two + // things 1) it ensures the root is in the root schedule, and 2) it ensures + // there's a pending microtask to process the root schedule. + // + // Most of the actual scheduling logic does not happen until + // `scheduleTaskForRootDuringMicrotask` runs. + // Add the root to the schedule + if (root === lastScheduledRoot || root.next !== null); + else { + if (lastScheduledRoot === null) { + firstScheduledRoot = lastScheduledRoot = root; + } else { + lastScheduledRoot.next = root; + lastScheduledRoot = root; + } + } // Any time a root received an update, we set this to true until the next time + // we process the schedule. If it's false, then we can quickly exit flushSync + // without consulting the schedule. + + mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure + // there's a task scheduled for each one at the correct priority. + + if (ReactCurrentActQueue$1.current !== null) { + // We're inside an `act` scope. + if (!didScheduleMicrotask_act) { + didScheduleMicrotask_act = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } else { + if (!didScheduleMicrotask) { + didScheduleMicrotask = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } + + if (!enableDeferRootSchedulingToMicrotask) { + // While this flag is disabled, we schedule the render task immediately + // instead of waiting a microtask. + // TODO: We need to land enableDeferRootSchedulingToMicrotask ASAP to + // unblock additional features we have planned. + scheduleTaskForRootDuringMicrotask(root, now$1()); + } +} +function flushSyncWorkOnAllRoots() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(false); +} +function flushSyncWorkOnLegacyRootsOnly() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(true); +} + +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (isFlushingWork) { + // Prevent reentrancy. + // TODO: Is this overly defensive? The callers must check the execution + // context first regardless. + return; + } + + if (!mightHavePendingSyncWork) { + // Fast path. There's no sync work to do. + return; + } + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); // There may or may not be synchronous work scheduled. Let's check. + + var didPerformSomeWork; + var errors = null; + isFlushingWork = true; + + do { + didPerformSomeWork = false; + var root = firstScheduledRoot; + + while (root !== null) { + if (onlyLegacy && root.tag !== LegacyRoot); + else { + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + + if (includesSyncLane(nextLanes)) { + // This root has pending sync work. Flush it now. + try { + // TODO: Pass nextLanes as an argument instead of computing it again + // inside performSyncWorkOnRoot. + didPerformSomeWork = true; + performSyncWorkOnRoot(root); + } catch (error) { + // Collect errors so we can rethrow them at the end + if (errors === null) { + errors = [error]; + } else { + errors.push(error); + } + } + } + } + + root = root.next; + } + } while (didPerformSomeWork); + + isFlushingWork = false; // If any errors were thrown, rethrow them right before exiting. + // TODO: Consider returning these to the caller, to allow them to decide + // how/when to rethrow. + + if (errors !== null) { + if (errors.length > 1) { + if (typeof AggregateError === "function") { + // eslint-disable-next-line no-undef + throw new AggregateError(errors); + } else { + for (var i = 1; i < errors.length; i++) { + scheduleImmediateTask(throwError.bind(null, errors[i])); + } + + var firstError = errors[0]; + throw firstError; + } + } else { + var error = errors[0]; + throw error; + } + } +} + +function throwError(error) { + throw error; +} + +function processRootScheduleInMicrotask() { + // This function is always called inside a microtask. It should never be + // called synchronously. + didScheduleMicrotask = false; + + { + didScheduleMicrotask_act = false; + } // We'll recompute this as we iterate through all the roots and schedule them. + + mightHavePendingSyncWork = false; + var currentTime = now$1(); + var prev = null; + var root = firstScheduledRoot; + + while (root !== null) { + var next = root.next; + var nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + + if (nextLanes === NoLane) { + // This root has no more pending work. Remove it from the schedule. To + // guard against subtle reentrancy bugs, this microtask is the only place + // we do this — you can add roots to the schedule whenever, but you can + // only remove them here. + // Null this out so we know it's been removed from the schedule. + root.next = null; + + if (prev === null) { + // This is the new head of the list + firstScheduledRoot = next; + } else { + prev.next = next; + } + + if (next === null) { + // This is the new tail of the list + lastScheduledRoot = prev; + } + } else { + // This root still has work. Keep it in the list. + prev = root; + + if (includesSyncLane(nextLanes)) { + mightHavePendingSyncWork = true; + } + } + + root = next; + } // At the end of the microtask, flush any pending synchronous work. This has + // to come at the end, because it does actual rendering work that might throw. + + flushSyncWorkOnAllRoots(); +} + +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + // This function is always called inside a microtask, or at the very end of a + // rendering task right before we yield to the main thread. It should never be + // called synchronously. + // + // TODO: Unless enableDeferRootSchedulingToMicrotask is off. We need to land + // that ASAP to unblock additional features we have planned. + // + // This function also never performs React work synchronously; it should + // only schedule work to be performed later, in a separate task or microtask. + // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + var existingCallbackNode = root.callbackNode; + + if ( + nextLanes === NoLanes || // If this root is currently suspended and waiting for data to resolve, don't + // schedule a task to render it. We'll either wait for a ping, or wait to + // receive an update. + (isWorkLoopSuspendedOnData() && root === workInProgressRoot) || // We should only interrupt a pending commit if the new update + // is urgent. + (root.cancelPendingCommit !== null && includesOnlyNonUrgentLanes(nextLanes)) + ) { + // Fast path: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackNode = null; + root.callbackPriority = NoLane; + return NoLane; + } // Schedule a new callback in the host environment. + + if (includesSyncLane(nextLanes)) { + // Synchronous work is always flushed at the end of the microtask, so we + // don't need to schedule an additional task. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackPriority = SyncLane; + root.callbackNode = null; + return SyncLane; + } else { + // We use the highest priority lane to represent the priority of the callback. + var existingCallbackPriority = root.callbackPriority; + var newCallbackPriority = getHighestPriorityLane(nextLanes); + + if ( + newCallbackPriority === existingCallbackPriority && // Special case related to `act`. If the currently scheduled task is a + // Scheduler task, rather than an `act` task, cancel it and re-schedule + // on the `act` queue. + !( + ReactCurrentActQueue$1.current !== null && + existingCallbackNode !== fakeActCallbackNode$1 + ) + ) { + // The priority hasn't changed. We can reuse the existing task. + return newCallbackPriority; + } else { + // Cancel the existing callback. We'll schedule a new one below. + cancelCallback(existingCallbackNode); + } + + var schedulerPriorityLevel; + + switch (lanesToEventPriority(nextLanes)) { + case DiscreteEventPriority: + schedulerPriorityLevel = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriorityLevel = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriorityLevel = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority$1; + break; + } + + var newCallbackNode = scheduleCallback$1( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) + ); + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; + return newCallbackPriority; + } +} + +function getContinuationForRoot(root, originalCallbackNode) { + // This is called at the end of `performConcurrentWorkOnRoot` to determine + // if we need to schedule a continuation task. + // + // Usually `scheduleTaskForRootDuringMicrotask` only runs inside a microtask; + // however, since most of the logic for determining if we need a continuation + // versus a new task is the same, we cheat a bit and call it here. This is + // only safe to do because we know we're at the end of the browser task. + // So although it's not an actual microtask, it might as well be. + scheduleTaskForRootDuringMicrotask(root, now$1()); + + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } + + return null; +} +var fakeActCallbackNode$1 = {}; + +function scheduleCallback$1(priorityLevel, callback) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: We're inside an `act` scope (a testing utility). + // Instead of scheduling work in the host environment, add it to a + // fake internal queue that's managed by the `act` implementation. + ReactCurrentActQueue$1.current.push(callback); + return fakeActCallbackNode$1; + } else { + return scheduleCallback$3(priorityLevel, callback); + } +} + +function cancelCallback(callbackNode) { + if (callbackNode === fakeActCallbackNode$1); + else if (callbackNode !== null) { + cancelCallback$1(callbackNode); + } +} + +function scheduleImmediateTask(cb) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: Inside an `act` scope, we push microtasks to the fake `act` + // callback queue. This is because we currently support calling `act` + // without awaiting the result. The plan is to deprecate that, and require + // that you always await the result so that the microtasks have a chance to + // run. But it hasn't happened yet. + ReactCurrentActQueue$1.current.push(function () { + cb(); + return null; + }); + } // TODO: Can we land supportsMicrotasks? Which environments don't support it? + // Alternatively, can we move this check to the host config? + + { + scheduleMicrotask(function () { + // In Safari, appending an iframe forces microtasks to run. + // https://github.com/facebook/react/issues/22459 + // We don't support running callbacks in the middle of render + // or commit so we need to check against that. + var executionContext = getExecutionContext(); + + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + // Note that this would still prematurely flush the callbacks + // if this happens outside render or commit phase (e.g. in an event). + // Intentionally using a macrotask instead of a microtask here. This is + // wrong semantically but it prevents an infinite loop. The bug is + // Safari's, not ours, so we just do our best to not crash even though + // the behavior isn't completely correct. + scheduleCallback$3(ImmediatePriority, cb); + return; + } + + cb(); + }); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -28836,6 +29130,9 @@ function getWorkInProgressRoot() { function getWorkInProgressRootRenderLanes() { return workInProgressRootRenderLanes; } +function isWorkLoopSuspendedOnData() { + return workInProgressSuspendedReason === SuspendedOnData; +} function requestEventTime() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. @@ -29039,21 +29336,25 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); if ( lane === SyncLane && executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue.isBatchingLegacy + (fiber.mode & ConcurrentMode) === NoMode ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + if (ReactCurrentActQueue.isBatchingLegacy) { + // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } else { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncWorkOnLegacyRootsOnly(); + } } } } @@ -29070,173 +29371,12 @@ function scheduleInitialHydrationOnRoot(root, lane, eventTime) { var current = root.current; current.lanes = lane; markRootUpdated(root, lane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function isUnsafeClassRenderPhaseUpdate(fiber) { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return (executionContext & RenderContext) !== NoContext; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. - -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. - - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. - - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. - if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); - } - - root.callbackNode = null; - root.callbackPriority = NoLane; - return; - } // If this root is currently suspended and waiting for data to resolve, don't - // schedule a task to render it. We'll either wait for a ping, or wait to - // receive an update. - - if ( - workInProgressSuspendedReason === SuspendedOnData && - workInProgressRoot === root - ) { - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - - var cancelPendingCommit = root.cancelPendingCommit; - - if (cancelPendingCommit !== null) { - // We should only interrupt a pending commit if the new update - // is urgent. - if (includesOnlyNonUrgentLanes(nextLanes)) { - // The new update is not urgent. Don't interrupt the pending commit. - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - } // We use the highest priority lane to represent the priority of the callback. - - var newCallbackPriority = getHighestPriorityLane(nextLanes); // Check if there's an existing task. We may be able to reuse it. - - var existingCallbackPriority = root.callbackPriority; - - if ( - existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a - // Scheduler task, rather than an `act` task, cancel it and re-scheduled - // on the `act` queue. - !( - ReactCurrentActQueue.current !== null && - existingCallbackNode !== fakeActCallbackNode - ) - ) { - { - // 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 && - !includesSyncLane(existingCallbackPriority) - ) { - 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. - - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. - cancelCallback(existingCallbackNode); - } // Schedule a new callback. - - var newCallbackNode; - - if (includesSyncLane(newCallbackPriority)) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue.isBatchingLegacy !== null) { - ReactCurrentActQueue.didScheduleLegacyUpdate = true; - } - - scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } - - { - // Flush the queue in a microtask. - if (ReactCurrentActQueue.current !== null) { - // Inside `act`, use our internal `act` queue so that these get flushed - // at the end of the current scope even when using the sync version - // of `act`. - ReactCurrentActQueue.current.push(flushSyncCallbacks); - } else { - scheduleMicrotask(function () { - // In Safari, appending an iframe forces microtasks to run. - // https://github.com/facebook/react/issues/22459 - // We don't support running callbacks in the middle of render - // or commit so we need to check against that. - if ( - (executionContext & (RenderContext | CommitContext)) === - NoContext - ) { - // Note that this would still prematurely flush the callbacks - // if this happens outside render or commit phase (e.g. in an event). - flushSyncCallbacks(); - } - }); - } - } - - newCallbackNode = null; - } else { - var schedulerPriorityLevel; - - switch (lanesToEventPriority(nextLanes)) { - case DiscreteEventPriority: - schedulerPriorityLevel = ImmediatePriority; - break; - - case ContinuousEventPriority: - schedulerPriorityLevel = UserBlockingPriority; - break; - - case DefaultEventPriority: - schedulerPriorityLevel = NormalPriority$1; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority$1; - break; - } - - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. @@ -29268,6 +29408,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } // Determine the next lanes to work on, using the fields stored // on the root. + // TODO: This was already computed in the caller. Pass it as an argument. var lanes = getNextLanes( root, @@ -29318,7 +29459,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -29368,7 +29509,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var _fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw _fatalError; } // FIXME: Need to check for RootDidNotComplete again. The factoring here // isn't ideal. @@ -29381,15 +29522,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } - ensureRootIsScheduled(root, now$1()); - - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); - } - - return null; + ensureRootIsScheduled(root); + return getContinuationForRoot(root, originalCallbackNode); } function recoverFromConcurrentError( @@ -29750,12 +29884,13 @@ function performSyncWorkOnRoot(root) { throw new Error("Should not already be working."); } - flushPassiveEffects(); + flushPassiveEffects(); // TODO: This was already computed in the caller. Pass it as an argument. + var lanes = getNextLanes(root, NoLanes); if (!includesSyncLane(lanes)) { // There's no remaining sync work left. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } @@ -29786,7 +29921,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -29795,7 +29930,7 @@ function performSyncWorkOnRoot(root) { // cases where need to exit the current render without producing a // consistent tree or committing. markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -29810,18 +29945,20 @@ function performSyncWorkOnRoot(root) { ); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } - function flushRoot(root, lanes) { if (lanes !== NoLanes) { markRootEntangled(root, mergeLanes(lanes, SyncLane)); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - resetRenderTimer(); - flushSyncCallbacks(); + resetRenderTimer(); // TODO: For historical reasons this flushes all sync work across all + // roots. It shouldn't really matter either way, but we could change this + // to only flush the given root. + + flushSyncWorkOnAllRoots(); } } } @@ -29843,7 +29980,7 @@ function batchedUpdates$1(fn, a) { !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + flushSyncWorkOnLegacyRootsOnly(); } } } @@ -29885,7 +30022,7 @@ function flushSync$1(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -30443,7 +30580,7 @@ function renderRootConcurrent(root, lanes) { // currently working on a different root, so that we resume // rendering later. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; thenable.then(onResolution, onResolution); @@ -31270,7 +31407,7 @@ function commitRootImpl( } // Always call this before exiting `commitRoot`, to ensure that any // additional work on this root is scheduled. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without @@ -31323,7 +31460,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { if (enableDebugTracing) { @@ -31523,7 +31660,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks; @@ -31607,7 +31744,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -31646,7 +31783,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -31722,7 +31859,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -31758,7 +31894,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -31777,7 +31913,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -32165,19 +32301,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } } } -function cancelCallback(callbackNode) { - if (callbackNode === fakeActCallbackNode) { - return; - } // In production, always call Scheduler. This function will be stripped out. - - return cancelCallback$1(callbackNode); -} - function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. return ReactCurrentActQueue.current !== null; @@ -33453,6 +33581,7 @@ function FiberRootNode( this.cancelPendingCommit = null; this.context = null; this.pendingContext = null; + this.next = null; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); @@ -33586,7 +33715,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-1f93a1ad"; +var ReactVersion = "18.3.0-www-modern-53d54e9c"; function createPortal$1( children, diff --git a/compiled/facebook-www/ReactDOM-prod.classic.js b/compiled/facebook-www/ReactDOM-prod.classic.js index 45bfff59a1..35a3e6e4ec 100644 --- a/compiled/facebook-www/ReactDOM-prod.classic.js +++ b/compiled/facebook-www/ReactDOM-prod.classic.js @@ -52,6 +52,8 @@ var ReactSharedInternals = enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = dynamicFeatureFlags.enableCustomElementPropertySupport, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask, REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -384,7 +386,7 @@ function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -555,25 +557,6 @@ function computeExpirationTime(lane, currentTime) { return -1; } } -function markStarvedLanesAsExpired(root, currentTime) { - for ( - var suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$3 = 31 - clz32(lanes), - lane = 1 << index$3, - expirationTime = expirationTimes[index$3]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$3] = computeExpirationTime(lane, currentTime); - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; - } -} function getLanesToRetrySynchronouslyOnError(root, originallyAttemptedLanes) { if (root.errorRecoveryDisabledLanes & originallyAttemptedLanes) return 0; root = root.pendingLanes & -1073741825; @@ -1466,57 +1449,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - syncQueue = null, - includesLegacySyncCallbacks = !1, - isFlushingSyncQueue = !1; -function scheduleSyncCallback(callback) { - null === syncQueue ? (syncQueue = [callback]) : syncQueue.push(callback); -} -function scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = !0; - scheduleSyncCallback(callback); -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var previousUpdatePriority = currentUpdatePriority; - currentUpdatePriority = 2; - for (var errors = null, queue = syncQueue, i = 0; i < queue.length; i++) { - var callback = queue[i]; - try { - do callback = callback(!0); - while (null !== callback); - } catch (error) { - null === errors ? (errors = [error]) : errors.push(error); - } - } - syncQueue = null; - includesLegacySyncCallbacks = !1; - currentUpdatePriority = previousUpdatePriority; - isFlushingSyncQueue = !1; - if (null !== errors) { - if (1 < errors.length) { - if ("function" === typeof AggregateError) - throw new AggregateError(errors); - for ( - previousUpdatePriority = 1; - previousUpdatePriority < errors.length; - previousUpdatePriority++ - ) - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[previousUpdatePriority]) - ); - } - throw errors[0]; - } - } - return null; -} -function throwError(error) { - throw error; -} -var forkStack = [], + forkStack = [], forkStackIndex = 0, treeForkProvider = null, treeForkCount = 0, @@ -3217,10 +3150,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$43 = thenableIndexCounter; + var index$41 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$43); + usable = trackUsedThenable(thenableState, usable, index$41); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -3712,16 +3645,16 @@ function refreshCache(fiber, seedKey, seedValue) { case 3: var lane = requestUpdateLane(provider); fiber = createUpdate(lane); - var root$49 = enqueueUpdate(provider, fiber, lane); - if (null !== root$49) { + var root$47 = enqueueUpdate(provider, fiber, lane); + if (null !== root$47) { var eventTime = requestEventTime(); - scheduleUpdateOnFiber(root$49, provider, lane, eventTime); - entangleTransitions(root$49, provider, lane); + scheduleUpdateOnFiber(root$47, provider, lane, eventTime); + entangleTransitions(root$47, provider, lane); } provider = createCache(); null !== seedKey && void 0 !== seedKey && - null !== root$49 && + null !== root$47 && provider.data.set(seedKey, seedValue); fiber.payload = { cache: provider }; return; @@ -3928,15 +3861,15 @@ var HooksDispatcherOnMount = { getServerSnapshot = getServerSnapshot(); } else { getServerSnapshot = getSnapshot(); - var root$45 = workInProgressRoot; - if (null === root$45) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(root$45, renderLanes$1) || + var root$43 = workInProgressRoot; + if (null === root$43) throw Error(formatProdErrorMessage(349)); + includesBlockingLane(root$43, renderLanes$1) || pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } hook.memoizedState = getServerSnapshot; - root$45 = { value: getServerSnapshot, getSnapshot: getSnapshot }; - hook.queue = root$45; - mountEffect(subscribeToStore.bind(null, fiber, root$45, subscribe), [ + root$43 = { value: getServerSnapshot, getSnapshot: getSnapshot }; + hook.queue = root$43; + mountEffect(subscribeToStore.bind(null, fiber, root$43, subscribe), [ subscribe ]); fiber.flags |= 2048; @@ -3945,7 +3878,7 @@ var HooksDispatcherOnMount = { updateStoreInstance.bind( null, fiber, - root$45, + root$43, getServerSnapshot, getSnapshot ), @@ -4444,10 +4377,10 @@ var markerInstanceStack = createCursor(null); function pushRootMarkerInstance(workInProgress) { if (enableTransitionTracing) { var transitions = workInProgressTransitions, - root$60 = workInProgress.stateNode; + root$58 = workInProgress.stateNode; null !== transitions && transitions.forEach(function (transition) { - if (!root$60.incompleteTransitions.has(transition)) { + if (!root$58.incompleteTransitions.has(transition)) { var markerInstance = { tag: 0, transitions: new Set([transition]), @@ -4455,11 +4388,11 @@ function pushRootMarkerInstance(workInProgress) { aborts: null, name: null }; - root$60.incompleteTransitions.set(transition, markerInstance); + root$58.incompleteTransitions.set(transition, markerInstance); } }); var markerInstances = []; - root$60.incompleteTransitions.forEach(function (markerInstance) { + root$58.incompleteTransitions.forEach(function (markerInstance) { markerInstances.push(markerInstance); }); push(markerInstanceStack, markerInstances); @@ -5159,14 +5092,14 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } JSCompiler_temp = current.memoizedState; if (null !== JSCompiler_temp) { - var dehydrated$67 = JSCompiler_temp.dehydrated; - if (null !== dehydrated$67) + var dehydrated$65 = JSCompiler_temp.dehydrated; + if (null !== dehydrated$65) return updateDehydratedSuspenseComponent( current, workInProgress, didSuspend, nextProps, - dehydrated$67, + dehydrated$65, JSCompiler_temp, renderLanes ); @@ -5176,7 +5109,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { showFallback = nextProps.fallback; didSuspend = workInProgress.mode; JSCompiler_temp = current.child; - dehydrated$67 = JSCompiler_temp.sibling; + dehydrated$65 = JSCompiler_temp.sibling; var primaryChildProps = { mode: "hidden", children: nextProps.children }; 0 === (didSuspend & 1) && workInProgress.child !== JSCompiler_temp ? ((nextProps = workInProgress.child), @@ -5185,8 +5118,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (workInProgress.deletions = null)) : ((nextProps = createWorkInProgress(JSCompiler_temp, primaryChildProps)), (nextProps.subtreeFlags = JSCompiler_temp.subtreeFlags & 31457280)); - null !== dehydrated$67 - ? (showFallback = createWorkInProgress(dehydrated$67, showFallback)) + null !== dehydrated$65 + ? (showFallback = createWorkInProgress(dehydrated$65, showFallback)) : ((showFallback = createFiberFromFragment( showFallback, didSuspend, @@ -5205,10 +5138,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ? (didSuspend = mountSuspenseOffscreenState(renderLanes)) : ((JSCompiler_temp = didSuspend.cachePool), null !== JSCompiler_temp - ? ((dehydrated$67 = CacheContext._currentValue), + ? ((dehydrated$65 = CacheContext._currentValue), (JSCompiler_temp = - JSCompiler_temp.parent !== dehydrated$67 - ? { parent: dehydrated$67, pool: dehydrated$67 } + JSCompiler_temp.parent !== dehydrated$65 + ? { parent: dehydrated$65, pool: dehydrated$65 } : JSCompiler_temp)) : (JSCompiler_temp = getSuspendedCache()), (didSuspend = { @@ -5222,23 +5155,23 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ((JSCompiler_temp = enableTransitionTracing ? markerInstanceStack.current : null), - (dehydrated$67 = showFallback.updateQueue), + (dehydrated$65 = showFallback.updateQueue), (primaryChildProps = current.updateQueue), - null === dehydrated$67 + null === dehydrated$65 ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null }) - : dehydrated$67 === primaryChildProps + : dehydrated$65 === primaryChildProps ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null !== primaryChildProps ? primaryChildProps.retryQueue : null }) - : ((dehydrated$67.transitions = didSuspend), - (dehydrated$67.markerInstances = JSCompiler_temp)))); + : ((dehydrated$65.transitions = didSuspend), + (dehydrated$65.markerInstances = JSCompiler_temp)))); showFallback.childLanes = current.childLanes & ~renderLanes; workInProgress.memoizedState = SUSPENDED_MARKER; return nextProps; @@ -6031,7 +5964,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -6053,7 +5986,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -6300,14 +6233,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$98 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$98 = lastTailNode), + for (var lastTailNode$96 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$96 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$98 + null === lastTailNode$96 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$98.sibling = null); + : (lastTailNode$96.sibling = null); } } function bubbleProperties(completedWork) { @@ -6317,19 +6250,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$99 = completedWork.child; null !== child$99; ) - (newChildLanes |= child$99.lanes | child$99.childLanes), - (subtreeFlags |= child$99.subtreeFlags & 31457280), - (subtreeFlags |= child$99.flags & 31457280), - (child$99.return = completedWork), - (child$99 = child$99.sibling); + for (var child$97 = completedWork.child; null !== child$97; ) + (newChildLanes |= child$97.lanes | child$97.childLanes), + (subtreeFlags |= child$97.subtreeFlags & 31457280), + (subtreeFlags |= child$97.flags & 31457280), + (child$97.return = completedWork), + (child$97 = child$97.sibling); else - for (child$99 = completedWork.child; null !== child$99; ) - (newChildLanes |= child$99.lanes | child$99.childLanes), - (subtreeFlags |= child$99.subtreeFlags), - (subtreeFlags |= child$99.flags), - (child$99.return = completedWork), - (child$99 = child$99.sibling); + for (child$97 = completedWork.child; null !== child$97; ) + (newChildLanes |= child$97.lanes | child$97.childLanes), + (subtreeFlags |= child$97.subtreeFlags), + (subtreeFlags |= child$97.flags), + (child$97.return = completedWork), + (child$97 = child$97.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -7067,8 +7000,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$129) { - captureCommitPhaseError(current, nearestMountedAncestor, error$129); + } catch (error$127) { + captureCommitPhaseError(current, nearestMountedAncestor, error$127); } else ref.current = null; } @@ -7368,11 +7301,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$131) { + } catch (error$129) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$131 + error$129 ); } } @@ -8046,8 +7979,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$144) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$144); + } catch (error$142) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$142); } } break; @@ -8225,11 +8158,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { newProps ); domElement[internalPropsKey] = newProps; - } catch (error$145) { + } catch (error$143) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$145 + error$143 ); } break; @@ -8265,8 +8198,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { root = finishedWork.stateNode; try { setTextContent(root, ""); - } catch (error$146) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$146); + } catch (error$144) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$144); } } if ( @@ -8283,8 +8216,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { updateProperties(flags, maybeNodes, hoistableRoot, current, root), (flags[internalPropsKey] = root); - } catch (error$149) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$149); + } catch (error$147) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$147); } break; case 6: @@ -8297,8 +8230,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { flags = finishedWork.memoizedProps; try { current.nodeValue = flags; - } catch (error$150) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$150); + } catch (error$148) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$148); } } break; @@ -8312,8 +8245,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (flags & 4 && null !== current && current.memoizedState.isDehydrated) try { retryIfBlockedOn(root.containerInfo); - } catch (error$151) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$151); + } catch (error$149) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$149); } break; case 4: @@ -8343,8 +8276,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$153) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$153); + } catch (error$151) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$151); } current = finishedWork.updateQueue; null !== current && @@ -8422,11 +8355,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { root.stateNode.nodeValue = domElement ? "" : root.memoizedProps; - } catch (error$134) { + } catch (error$132) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$134 + error$132 ); } } else if ( @@ -8501,21 +8434,21 @@ function commitReconciliationEffects(finishedWork) { insertOrAppendPlacementNode(finishedWork, before, parent$jscomp$0); break; case 5: - var parent$135 = JSCompiler_inline_result.stateNode; + var parent$133 = JSCompiler_inline_result.stateNode; JSCompiler_inline_result.flags & 32 && - (setTextContent(parent$135, ""), + (setTextContent(parent$133, ""), (JSCompiler_inline_result.flags &= -33)); - var before$136 = getHostSibling(finishedWork); - insertOrAppendPlacementNode(finishedWork, before$136, parent$135); + var before$134 = getHostSibling(finishedWork); + insertOrAppendPlacementNode(finishedWork, before$134, parent$133); break; case 3: case 4: - var parent$137 = JSCompiler_inline_result.stateNode.containerInfo, - before$138 = getHostSibling(finishedWork); + var parent$135 = JSCompiler_inline_result.stateNode.containerInfo, + before$136 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$138, - parent$137 + before$136, + parent$135 ); break; default: @@ -8985,9 +8918,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$163 = finishedWork.stateNode; + var instance$161 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$163._visibility & 4 + ? instance$161._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9000,7 +8933,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$163._visibility |= 4), + : ((instance$161._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9008,7 +8941,7 @@ function recursivelyTraverseReconnectPassiveEffects( committedTransitions, includeWorkInProgressEffects )) - : ((instance$163._visibility |= 4), + : ((instance$161._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9021,7 +8954,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$163 + instance$161 ); break; case 24: @@ -9350,6 +9283,204 @@ function schedulePostPaintCallback(callback) { callbacks = []; })); } +var firstScheduledRoot = null, + lastScheduledRoot = null, + didScheduleMicrotask = !1, + mightHavePendingSyncWork = !1, + isFlushingWork = !1; +function ensureRootIsScheduled(root) { + root !== lastScheduledRoot && + null === root.next && + (null === lastScheduledRoot + ? (firstScheduledRoot = lastScheduledRoot = root) + : (lastScheduledRoot = lastScheduledRoot.next = root)); + mightHavePendingSyncWork = !0; + didScheduleMicrotask || + ((didScheduleMicrotask = !0), + scheduleImmediateTask(processRootScheduleInMicrotask)); + enableDeferRootSchedulingToMicrotask || + scheduleTaskForRootDuringMicrotask(root, now()); +} +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (!isFlushingWork && mightHavePendingSyncWork) { + var workInProgressRoot$jscomp$0 = workInProgressRoot, + workInProgressRootRenderLanes$jscomp$0 = workInProgressRootRenderLanes, + errors = null; + isFlushingWork = !0; + do { + var didPerformSomeWork = !1; + for (var root$169 = firstScheduledRoot; null !== root$169; ) { + if ( + (!onlyLegacy || 0 === root$169.tag) && + 0 !== + (getNextLanes( + root$169, + root$169 === workInProgressRoot$jscomp$0 + ? workInProgressRootRenderLanes$jscomp$0 + : 0 + ) & + 3) + ) + try { + didPerformSomeWork = !0; + var root = root$169; + if (0 !== (executionContext & 6)) + throw Error(formatProdErrorMessage(327)); + flushPassiveEffects(); + var lanes = getNextLanes(root, 0); + if (0 !== (lanes & 3)) { + var exitStatus = renderRootSync(root, lanes); + if (0 !== root.tag && 2 === exitStatus) { + var originallyAttemptedLanes = lanes, + errorRetryLanes = getLanesToRetrySynchronouslyOnError( + root, + originallyAttemptedLanes + ); + 0 !== errorRetryLanes && + ((lanes = errorRetryLanes), + (exitStatus = recoverFromConcurrentError( + root, + originallyAttemptedLanes, + errorRetryLanes + ))); + } + if (1 === exitStatus) + throw ( + ((originallyAttemptedLanes = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended(root, lanes), + ensureRootIsScheduled(root), + originallyAttemptedLanes) + ); + 6 === exitStatus + ? markRootSuspended(root, lanes) + : ((root.finishedWork = root.current.alternate), + (root.finishedLanes = lanes), + commitRoot( + root, + workInProgressRootRecoverableErrors, + workInProgressTransitions + )); + } + ensureRootIsScheduled(root); + } catch (error) { + null === errors ? (errors = [error]) : errors.push(error); + } + root$169 = root$169.next; + } + } while (didPerformSomeWork); + isFlushingWork = !1; + if (null !== errors) { + if (1 < errors.length) { + if ("function" === typeof AggregateError) + throw new AggregateError(errors); + for (onlyLegacy = 1; onlyLegacy < errors.length; onlyLegacy++) + scheduleImmediateTask(throwError.bind(null, errors[onlyLegacy])); + } + throw errors[0]; + } + } +} +function throwError(error) { + throw error; +} +function processRootScheduleInMicrotask() { + mightHavePendingSyncWork = didScheduleMicrotask = !1; + for ( + var currentTime = now(), prev = null, root = firstScheduledRoot; + null !== root; + + ) { + var next = root.next, + nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + 0 === nextLanes + ? ((root.next = null), + null === prev ? (firstScheduledRoot = next) : (prev.next = next), + null === next && (lastScheduledRoot = prev)) + : ((prev = root), + 0 !== (nextLanes & 3) && (mightHavePendingSyncWork = !0)); + root = next; + } + flushSyncWorkAcrossRoots_impl(!1); +} +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + for ( + var suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes & -125829121; + 0 < lanes; + + ) { + var index$3 = 31 - clz32(lanes), + lane = 1 << index$3, + expirationTime = expirationTimes[index$3]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$3] = computeExpirationTime(lane, currentTime); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + currentTime = workInProgressRoot; + suspendedLanes = workInProgressRootRenderLanes; + suspendedLanes = getNextLanes( + root, + root === currentTime ? suspendedLanes : 0 + ); + pingedLanes = root.callbackNode; + if ( + 0 === suspendedLanes || + (2 === workInProgressSuspendedReason && root === currentTime) || + (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) + ) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackNode = null), + (root.callbackPriority = 0) + ); + if (0 !== (suspendedLanes & 3)) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackPriority = 2), + (root.callbackNode = null), + 2 + ); + currentTime = suspendedLanes & -suspendedLanes; + if (currentTime === root.callbackPriority) return currentTime; + null !== pingedLanes && cancelCallback$1(pingedLanes); + switch (lanesToEventPriority(suspendedLanes)) { + case 2: + suspendedLanes = ImmediatePriority; + break; + case 8: + suspendedLanes = UserBlockingPriority; + break; + case 32: + suspendedLanes = NormalPriority$1; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority$1; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$3(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} +function scheduleImmediateTask(cb) { + scheduleMicrotask(function () { + 0 !== (executionContext & 6) + ? scheduleCallback$3(ImmediatePriority, cb) + : cb(); + }); +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -9479,87 +9610,32 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { markRootSuspended(root, workInProgressRootRenderLanes)); markRootUpdated(root, lane, eventTime); if (0 === (executionContext & 2) || root !== workInProgressRoot) { - if (enableTransitionTracing) { - var transition = ReactCurrentBatchConfig$1.transition; - if ( - null !== transition && - null != transition.name && - (-1 === transition.startTime && (transition.startTime = now()), - enableTransitionTracing) - ) { - var transitionLanesMap = root.transitionLanes, - index$7 = 31 - clz32(lane), - transitions = transitionLanesMap[index$7]; - null === transitions && (transitions = new Set()); - transitions.add(transition); - transitionLanesMap[index$7] = transitions; - } + if ( + enableTransitionTracing && + ((eventTime = ReactCurrentBatchConfig$1.transition), + null !== eventTime && + null != eventTime.name && + (-1 === eventTime.startTime && (eventTime.startTime = now()), + enableTransitionTracing)) + ) { + var transitionLanesMap = root.transitionLanes, + index$7 = 31 - clz32(lane), + transitions = transitionLanesMap[index$7]; + null === transitions && (transitions = new Set()); + transitions.add(eventTime); + transitionLanesMap[index$7] = transitions; } root === workInProgressRoot && (0 === (executionContext & 2) && (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended(root, workInProgressRootRenderLanes)); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); 2 === lane && 0 === executionContext && 0 === (fiber.mode & 1) && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); - } -} -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; - markStarvedLanesAsExpired(root, currentTime); - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === nextLanes) - null !== existingCallbackNode && cancelCallback$1(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0); - else if (2 === workInProgressSuspendedReason && workInProgressRoot === root) - (root.callbackPriority = 0), (root.callbackNode = null); - else if (null !== root.cancelPendingCommit && 0 === (nextLanes & 42)) - (root.callbackPriority = 0), (root.callbackNode = null); - else if ( - ((currentTime = nextLanes & -nextLanes), - root.callbackPriority !== currentTime) - ) { - null != existingCallbackNode && cancelCallback$1(existingCallbackNode); - if (0 !== (currentTime & 3)) - 0 === root.tag - ? scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)), - scheduleMicrotask(function () { - 0 === (executionContext & 6) && flushSyncCallbacks(); - }), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(nextLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority$1; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority$1; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; + flushSyncWorkAcrossRoots_impl(!0)); } } function performConcurrentWorkOnRoot(root, didTimeout) { @@ -9600,7 +9676,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); if (6 === exitStatus) markRootSuspended(root, lanes); @@ -9631,7 +9707,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -9743,10 +9819,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode - ? performConcurrentWorkOnRoot.bind(null, root) - : null; + ensureRootIsScheduled(root); + scheduleTaskForRootDuringMicrotask(root, now()); + root = + root.callbackNode === originalCallbackNode + ? performConcurrentWorkOnRoot.bind(null, root) + : null; + return root; } function recoverFromConcurrentError( root, @@ -9854,48 +9933,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 6)) throw Error(formatProdErrorMessage(327)); - flushPassiveEffects(); - var lanes = getNextLanes(root, 0); - if (0 === (lanes & 3)) return ensureRootIsScheduled(root, now()), null; - var exitStatus = renderRootSync(root, lanes); - if (0 !== root.tag && 2 === exitStatus) { - var originallyAttemptedLanes = lanes, - errorRetryLanes = getLanesToRetrySynchronouslyOnError( - root, - originallyAttemptedLanes - ); - 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError( - root, - originallyAttemptedLanes, - errorRetryLanes - ))); - } - if (1 === exitStatus) - throw ( - ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), - exitStatus) - ); - if (6 === exitStatus) - return ( - markRootSuspended(root, lanes), ensureRootIsScheduled(root, now()), null - ); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - commitRoot( - root, - workInProgressRootRecoverableErrors, - workInProgressTransitions - ); - ensureRootIsScheduled(root, now()); - return null; -} function batchedUpdates$1(fn, a) { var prevExecutionContext = executionContext; executionContext |= 1; @@ -9905,7 +9942,7 @@ function batchedUpdates$1(fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } } function flushSync$1(fn) { @@ -9928,7 +9965,7 @@ function flushSync$1(fn) { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$1.transition = prevTransition), (executionContext = prevExecutionContext), - 0 === (executionContext & 6) && flushSyncCallbacks(); + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); } } function resetWorkInProgressStack() { @@ -10112,7 +10149,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -10325,10 +10362,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$55 = offscreenQueue.retryQueue; - null === retryQueue$55 + var retryQueue$53 = offscreenQueue.retryQueue; + null === retryQueue$53 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$55.add(wakeable); + : retryQueue$53.add(wakeable); } } break; @@ -10552,7 +10589,7 @@ function commitRootImpl( remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(finishedWork.stateNode, renderPriorityLevel); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, finishedWork = 0; @@ -10581,7 +10618,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevRootTransitionCallbacks = root.transitionCallbacks; null !== prevRootTransitionCallbacks && @@ -10644,7 +10681,7 @@ function flushPassiveEffectsImpl() { commitPassiveUnmountOnFiber(root.current); commitPassiveMountOnFiber(root, root.current, lanes, transitions); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks, prevRootTransitionCallbacks = root.transitionCallbacks, @@ -10674,7 +10711,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = requestEventTime(); null !== rootFiber && (markRootUpdated(rootFiber, 2, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + ensureRootIsScheduled(rootFiber)); } function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) @@ -10711,7 +10748,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -10737,7 +10774,6 @@ function attachPingListener(root, wakeable, lanes) { function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); root.pingedLanes |= root.suspendedLanes & pingedLanes; workInProgressRoot === root && (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && @@ -10748,7 +10784,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { 500 > now() - globalMostRecentFallbackTime) ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { 0 === retryLane && @@ -10757,7 +10793,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { boundaryFiber = enqueueConcurrentRenderForLane(boundaryFiber, retryLane); null !== boundaryFiber && (markRootUpdated(boundaryFiber, retryLane, eventTime), - ensureRootIsScheduled(boundaryFiber, eventTime)); + ensureRootIsScheduled(boundaryFiber)); } function retryDehydratedSuspenseBoundary(boundaryFiber) { var suspenseState = boundaryFiber.memoizedState, @@ -11415,7 +11451,7 @@ beginWork = function (current, workInProgress, renderLanes) { throw Error(formatProdErrorMessage(156, workInProgress.tag)); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -11731,6 +11767,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -11890,7 +11927,7 @@ function createHydrationContainer( enqueueUpdate(containerInfo, hydrationCallbacks, tag); initialChildren.current.lanes = tag; markRootUpdated(initialChildren, tag, callback); - ensureRootIsScheduled(initialChildren, callback); + ensureRootIsScheduled(initialChildren); return initialChildren; } function updateContainer(element, container, parentComponent, callback) { @@ -11930,10 +11967,10 @@ function attemptSynchronousHydration(fiber) { var lanes = getHighestPriorityLanes(root$182.pendingLanes); 0 !== lanes && (markRootEntangled(root$182, lanes | 2), - ensureRootIsScheduled(root$182, now()), + ensureRootIsScheduled(root$182), 0 === (executionContext & 6) && ((workInProgressRootRenderTargetTime = now() + 500), - flushSyncCallbacks())); + flushSyncWorkAcrossRoots_impl(!1))); } break; case 13: @@ -12502,19 +12539,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$325; + var JSCompiler_inline_result$jscomp$327; if (canUseDOM) { - var isSupported$jscomp$inline_1526 = "oninput" in document; - if (!isSupported$jscomp$inline_1526) { - var element$jscomp$inline_1527 = document.createElement("div"); - element$jscomp$inline_1527.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1526 = - "function" === typeof element$jscomp$inline_1527.oninput; + var isSupported$jscomp$inline_1555 = "oninput" in document; + if (!isSupported$jscomp$inline_1555) { + var element$jscomp$inline_1556 = document.createElement("div"); + element$jscomp$inline_1556.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1555 = + "function" === typeof element$jscomp$inline_1556.oninput; } - JSCompiler_inline_result$jscomp$325 = isSupported$jscomp$inline_1526; - } else JSCompiler_inline_result$jscomp$325 = !1; + JSCompiler_inline_result$jscomp$327 = isSupported$jscomp$inline_1555; + } else JSCompiler_inline_result$jscomp$327 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$325 && + JSCompiler_inline_result$jscomp$327 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -12823,20 +12860,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1567 = 0; - i$jscomp$inline_1567 < simpleEventPluginEvents.length; - i$jscomp$inline_1567++ + var i$jscomp$inline_1596 = 0; + i$jscomp$inline_1596 < simpleEventPluginEvents.length; + i$jscomp$inline_1596++ ) { - var eventName$jscomp$inline_1568 = - simpleEventPluginEvents[i$jscomp$inline_1567], - domEventName$jscomp$inline_1569 = - eventName$jscomp$inline_1568.toLowerCase(), - capitalizedEvent$jscomp$inline_1570 = - eventName$jscomp$inline_1568[0].toUpperCase() + - eventName$jscomp$inline_1568.slice(1); + var eventName$jscomp$inline_1597 = + simpleEventPluginEvents[i$jscomp$inline_1596], + domEventName$jscomp$inline_1598 = + eventName$jscomp$inline_1597.toLowerCase(), + capitalizedEvent$jscomp$inline_1599 = + eventName$jscomp$inline_1597[0].toUpperCase() + + eventName$jscomp$inline_1597.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1569, - "on" + capitalizedEvent$jscomp$inline_1570 + domEventName$jscomp$inline_1598, + "on" + capitalizedEvent$jscomp$inline_1599 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -15916,17 +15953,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1781 = { +var devToolsConfig$jscomp$inline_1810 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-863e04d5", + version: "18.3.0-www-classic-5232be82", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2171 = { - bundleType: devToolsConfig$jscomp$inline_1781.bundleType, - version: devToolsConfig$jscomp$inline_1781.version, - rendererPackageName: devToolsConfig$jscomp$inline_1781.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1781.rendererConfig, +var internals$jscomp$inline_2206 = { + bundleType: devToolsConfig$jscomp$inline_1810.bundleType, + version: devToolsConfig$jscomp$inline_1810.version, + rendererPackageName: devToolsConfig$jscomp$inline_1810.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1810.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -15942,26 +15979,26 @@ var internals$jscomp$inline_2171 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1781.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1810.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-863e04d5" + reconcilerVersion: "18.3.0-www-classic-5232be82" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2172 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2207 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2172.isDisabled && - hook$jscomp$inline_2172.supportsFiber + !hook$jscomp$inline_2207.isDisabled && + hook$jscomp$inline_2207.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2172.inject( - internals$jscomp$inline_2171 + (rendererID = hook$jscomp$inline_2207.inject( + internals$jscomp$inline_2206 )), - (injectedHook = hook$jscomp$inline_2172); + (injectedHook = hook$jscomp$inline_2207); } catch (err) {} } assign(Internals, { @@ -16189,4 +16226,4 @@ exports.unstable_renderSubtreeIntoContainer = function ( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-classic-863e04d5"; +exports.version = "18.3.0-www-classic-5232be82"; diff --git a/compiled/facebook-www/ReactDOM-prod.modern.js b/compiled/facebook-www/ReactDOM-prod.modern.js index 5743ead1eb..1f74748944 100644 --- a/compiled/facebook-www/ReactDOM-prod.modern.js +++ b/compiled/facebook-www/ReactDOM-prod.modern.js @@ -109,7 +109,9 @@ var dynamicFeatureFlags = require("ReactFeatureFlags"), enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = dynamicFeatureFlags.enableCustomElementPropertySupport, - scheduleCallback$2 = Scheduler.unstable_scheduleCallback, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask, + scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -282,25 +284,6 @@ function computeExpirationTime(lane, currentTime) { return -1; } } -function markStarvedLanesAsExpired(root, currentTime) { - for ( - var suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$2 = 31 - clz32(lanes), - lane = 1 << index$2, - expirationTime = expirationTimes[index$2]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$2] = computeExpirationTime(lane, currentTime); - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; - } -} function getLanesToRetrySynchronouslyOnError(root, originallyAttemptedLanes) { if (root.errorRecoveryDisabledLanes & originallyAttemptedLanes) return 0; root = root.pendingLanes & -1073741825; @@ -1354,57 +1337,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - syncQueue = null, - includesLegacySyncCallbacks = !1, - isFlushingSyncQueue = !1; -function scheduleSyncCallback(callback) { - null === syncQueue ? (syncQueue = [callback]) : syncQueue.push(callback); -} -function scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = !0; - scheduleSyncCallback(callback); -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var previousUpdatePriority = currentUpdatePriority; - currentUpdatePriority = 2; - for (var errors = null, queue = syncQueue, i = 0; i < queue.length; i++) { - var callback = queue[i]; - try { - do callback = callback(!0); - while (null !== callback); - } catch (error) { - null === errors ? (errors = [error]) : errors.push(error); - } - } - syncQueue = null; - includesLegacySyncCallbacks = !1; - currentUpdatePriority = previousUpdatePriority; - isFlushingSyncQueue = !1; - if (null !== errors) { - if (1 < errors.length) { - if ("function" === typeof AggregateError) - throw new AggregateError(errors); - for ( - previousUpdatePriority = 1; - previousUpdatePriority < errors.length; - previousUpdatePriority++ - ) - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[previousUpdatePriority]) - ); - } - throw errors[0]; - } - } - return null; -} -function throwError(error) { - throw error; -} -var forkStack = [], + forkStack = [], forkStackIndex = 0, treeForkProvider = null, treeForkCount = 0, @@ -3105,10 +3038,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$43 = thenableIndexCounter; + var index$41 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$43); + usable = trackUsedThenable(thenableState, usable, index$41); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -3600,16 +3533,16 @@ function refreshCache(fiber, seedKey, seedValue) { case 3: var lane = requestUpdateLane(provider); fiber = createUpdate(lane); - var root$49 = enqueueUpdate(provider, fiber, lane); - if (null !== root$49) { + var root$47 = enqueueUpdate(provider, fiber, lane); + if (null !== root$47) { var eventTime = requestEventTime(); - scheduleUpdateOnFiber(root$49, provider, lane, eventTime); - entangleTransitions(root$49, provider, lane); + scheduleUpdateOnFiber(root$47, provider, lane, eventTime); + entangleTransitions(root$47, provider, lane); } provider = createCache(); null !== seedKey && void 0 !== seedKey && - null !== root$49 && + null !== root$47 && provider.data.set(seedKey, seedValue); fiber.payload = { cache: provider }; return; @@ -3816,15 +3749,15 @@ var HooksDispatcherOnMount = { getServerSnapshot = getServerSnapshot(); } else { getServerSnapshot = getSnapshot(); - var root$45 = workInProgressRoot; - if (null === root$45) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(root$45, renderLanes$1) || + var root$43 = workInProgressRoot; + if (null === root$43) throw Error(formatProdErrorMessage(349)); + includesBlockingLane(root$43, renderLanes$1) || pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } hook.memoizedState = getServerSnapshot; - root$45 = { value: getServerSnapshot, getSnapshot: getSnapshot }; - hook.queue = root$45; - mountEffect(subscribeToStore.bind(null, fiber, root$45, subscribe), [ + root$43 = { value: getServerSnapshot, getSnapshot: getSnapshot }; + hook.queue = root$43; + mountEffect(subscribeToStore.bind(null, fiber, root$43, subscribe), [ subscribe ]); fiber.flags |= 2048; @@ -3833,7 +3766,7 @@ var HooksDispatcherOnMount = { updateStoreInstance.bind( null, fiber, - root$45, + root$43, getServerSnapshot, getSnapshot ), @@ -4317,10 +4250,10 @@ var markerInstanceStack = createCursor(null); function pushRootMarkerInstance(workInProgress) { if (enableTransitionTracing) { var transitions = workInProgressTransitions, - root$60 = workInProgress.stateNode; + root$58 = workInProgress.stateNode; null !== transitions && transitions.forEach(function (transition) { - if (!root$60.incompleteTransitions.has(transition)) { + if (!root$58.incompleteTransitions.has(transition)) { var markerInstance = { tag: 0, transitions: new Set([transition]), @@ -4328,11 +4261,11 @@ function pushRootMarkerInstance(workInProgress) { aborts: null, name: null }; - root$60.incompleteTransitions.set(transition, markerInstance); + root$58.incompleteTransitions.set(transition, markerInstance); } }); var markerInstances = []; - root$60.incompleteTransitions.forEach(function (markerInstance) { + root$58.incompleteTransitions.forEach(function (markerInstance) { markerInstances.push(markerInstance); }); push(markerInstanceStack, markerInstances); @@ -4996,14 +4929,14 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } JSCompiler_temp = current.memoizedState; if (null !== JSCompiler_temp) { - var dehydrated$67 = JSCompiler_temp.dehydrated; - if (null !== dehydrated$67) + var dehydrated$65 = JSCompiler_temp.dehydrated; + if (null !== dehydrated$65) return updateDehydratedSuspenseComponent( current, workInProgress, didSuspend, nextProps, - dehydrated$67, + dehydrated$65, JSCompiler_temp, renderLanes ); @@ -5013,7 +4946,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { showFallback = nextProps.fallback; didSuspend = workInProgress.mode; JSCompiler_temp = current.child; - dehydrated$67 = JSCompiler_temp.sibling; + dehydrated$65 = JSCompiler_temp.sibling; var primaryChildProps = { mode: "hidden", children: nextProps.children }; 0 === (didSuspend & 1) && workInProgress.child !== JSCompiler_temp ? ((nextProps = workInProgress.child), @@ -5022,8 +4955,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (workInProgress.deletions = null)) : ((nextProps = createWorkInProgress(JSCompiler_temp, primaryChildProps)), (nextProps.subtreeFlags = JSCompiler_temp.subtreeFlags & 31457280)); - null !== dehydrated$67 - ? (showFallback = createWorkInProgress(dehydrated$67, showFallback)) + null !== dehydrated$65 + ? (showFallback = createWorkInProgress(dehydrated$65, showFallback)) : ((showFallback = createFiberFromFragment( showFallback, didSuspend, @@ -5042,10 +4975,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ? (didSuspend = mountSuspenseOffscreenState(renderLanes)) : ((JSCompiler_temp = didSuspend.cachePool), null !== JSCompiler_temp - ? ((dehydrated$67 = CacheContext._currentValue), + ? ((dehydrated$65 = CacheContext._currentValue), (JSCompiler_temp = - JSCompiler_temp.parent !== dehydrated$67 - ? { parent: dehydrated$67, pool: dehydrated$67 } + JSCompiler_temp.parent !== dehydrated$65 + ? { parent: dehydrated$65, pool: dehydrated$65 } : JSCompiler_temp)) : (JSCompiler_temp = getSuspendedCache()), (didSuspend = { @@ -5059,23 +4992,23 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ((JSCompiler_temp = enableTransitionTracing ? markerInstanceStack.current : null), - (dehydrated$67 = showFallback.updateQueue), + (dehydrated$65 = showFallback.updateQueue), (primaryChildProps = current.updateQueue), - null === dehydrated$67 + null === dehydrated$65 ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null }) - : dehydrated$67 === primaryChildProps + : dehydrated$65 === primaryChildProps ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null !== primaryChildProps ? primaryChildProps.retryQueue : null }) - : ((dehydrated$67.transitions = didSuspend), - (dehydrated$67.markerInstances = JSCompiler_temp)))); + : ((dehydrated$65.transitions = didSuspend), + (dehydrated$65.markerInstances = JSCompiler_temp)))); showFallback.childLanes = current.childLanes & ~renderLanes; workInProgress.memoizedState = SUSPENDED_MARKER; return nextProps; @@ -5864,7 +5797,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -5886,7 +5819,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -6133,14 +6066,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$98 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$98 = lastTailNode), + for (var lastTailNode$96 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$96 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$98 + null === lastTailNode$96 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$98.sibling = null); + : (lastTailNode$96.sibling = null); } } function bubbleProperties(completedWork) { @@ -6150,19 +6083,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$99 = completedWork.child; null !== child$99; ) - (newChildLanes |= child$99.lanes | child$99.childLanes), - (subtreeFlags |= child$99.subtreeFlags & 31457280), - (subtreeFlags |= child$99.flags & 31457280), - (child$99.return = completedWork), - (child$99 = child$99.sibling); + for (var child$97 = completedWork.child; null !== child$97; ) + (newChildLanes |= child$97.lanes | child$97.childLanes), + (subtreeFlags |= child$97.subtreeFlags & 31457280), + (subtreeFlags |= child$97.flags & 31457280), + (child$97.return = completedWork), + (child$97 = child$97.sibling); else - for (child$99 = completedWork.child; null !== child$99; ) - (newChildLanes |= child$99.lanes | child$99.childLanes), - (subtreeFlags |= child$99.subtreeFlags), - (subtreeFlags |= child$99.flags), - (child$99.return = completedWork), - (child$99 = child$99.sibling); + for (child$97 = completedWork.child; null !== child$97; ) + (newChildLanes |= child$97.lanes | child$97.childLanes), + (subtreeFlags |= child$97.subtreeFlags), + (subtreeFlags |= child$97.flags), + (child$97.return = completedWork), + (child$97 = child$97.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6881,8 +6814,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$128) { - captureCommitPhaseError(current, nearestMountedAncestor, error$128); + } catch (error$126) { + captureCommitPhaseError(current, nearestMountedAncestor, error$126); } else ref.current = null; } @@ -7195,11 +7128,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$130) { + } catch (error$128) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$130 + error$128 ); } } @@ -7873,8 +7806,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$143) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$143); + } catch (error$141) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$141); } } break; @@ -8052,11 +7985,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { newProps ); domElement[internalPropsKey] = newProps; - } catch (error$144) { + } catch (error$142) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$144 + error$142 ); } break; @@ -8092,8 +8025,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { root = finishedWork.stateNode; try { setTextContent(root, ""); - } catch (error$145) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$145); + } catch (error$143) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$143); } } if ( @@ -8110,8 +8043,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { updateProperties(flags, maybeNodes, hoistableRoot, current, root), (flags[internalPropsKey] = root); - } catch (error$148) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$148); + } catch (error$146) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$146); } break; case 6: @@ -8124,8 +8057,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { flags = finishedWork.memoizedProps; try { current.nodeValue = flags; - } catch (error$149) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$149); + } catch (error$147) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$147); } } break; @@ -8139,8 +8072,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (flags & 4 && null !== current && current.memoizedState.isDehydrated) try { retryIfBlockedOn(root.containerInfo); - } catch (error$150) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$150); + } catch (error$148) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$148); } break; case 4: @@ -8170,8 +8103,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$152) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$152); + } catch (error$150) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$150); } current = finishedWork.updateQueue; null !== current && @@ -8249,11 +8182,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { root.stateNode.nodeValue = domElement ? "" : root.memoizedProps; - } catch (error$133) { + } catch (error$131) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$133 + error$131 ); } } else if ( @@ -8328,21 +8261,21 @@ function commitReconciliationEffects(finishedWork) { insertOrAppendPlacementNode(finishedWork, before, parent$jscomp$0); break; case 5: - var parent$134 = JSCompiler_inline_result.stateNode; + var parent$132 = JSCompiler_inline_result.stateNode; JSCompiler_inline_result.flags & 32 && - (setTextContent(parent$134, ""), + (setTextContent(parent$132, ""), (JSCompiler_inline_result.flags &= -33)); - var before$135 = getHostSibling(finishedWork); - insertOrAppendPlacementNode(finishedWork, before$135, parent$134); + var before$133 = getHostSibling(finishedWork); + insertOrAppendPlacementNode(finishedWork, before$133, parent$132); break; case 3: case 4: - var parent$136 = JSCompiler_inline_result.stateNode.containerInfo, - before$137 = getHostSibling(finishedWork); + var parent$134 = JSCompiler_inline_result.stateNode.containerInfo, + before$135 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$137, - parent$136 + before$135, + parent$134 ); break; default: @@ -8812,9 +8745,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$162 = finishedWork.stateNode; + var instance$160 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$162._visibility & 4 + ? instance$160._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8827,7 +8760,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$162._visibility |= 4), + : ((instance$160._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8835,7 +8768,7 @@ function recursivelyTraverseReconnectPassiveEffects( committedTransitions, includeWorkInProgressEffects )) - : ((instance$162._visibility |= 4), + : ((instance$160._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8848,7 +8781,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$162 + instance$160 ); break; case 24: @@ -9177,6 +9110,204 @@ function schedulePostPaintCallback(callback) { callbacks = []; })); } +var firstScheduledRoot = null, + lastScheduledRoot = null, + didScheduleMicrotask = !1, + mightHavePendingSyncWork = !1, + isFlushingWork = !1; +function ensureRootIsScheduled(root) { + root !== lastScheduledRoot && + null === root.next && + (null === lastScheduledRoot + ? (firstScheduledRoot = lastScheduledRoot = root) + : (lastScheduledRoot = lastScheduledRoot.next = root)); + mightHavePendingSyncWork = !0; + didScheduleMicrotask || + ((didScheduleMicrotask = !0), + scheduleImmediateTask(processRootScheduleInMicrotask)); + enableDeferRootSchedulingToMicrotask || + scheduleTaskForRootDuringMicrotask(root, now()); +} +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (!isFlushingWork && mightHavePendingSyncWork) { + var workInProgressRoot$jscomp$0 = workInProgressRoot, + workInProgressRootRenderLanes$jscomp$0 = workInProgressRootRenderLanes, + errors = null; + isFlushingWork = !0; + do { + var didPerformSomeWork = !1; + for (var root$168 = firstScheduledRoot; null !== root$168; ) { + if ( + (!onlyLegacy || 0 === root$168.tag) && + 0 !== + (getNextLanes( + root$168, + root$168 === workInProgressRoot$jscomp$0 + ? workInProgressRootRenderLanes$jscomp$0 + : 0 + ) & + 3) + ) + try { + didPerformSomeWork = !0; + var root = root$168; + if (0 !== (executionContext & 6)) + throw Error(formatProdErrorMessage(327)); + flushPassiveEffects(); + var lanes = getNextLanes(root, 0); + if (0 !== (lanes & 3)) { + var exitStatus = renderRootSync(root, lanes); + if (0 !== root.tag && 2 === exitStatus) { + var originallyAttemptedLanes = lanes, + errorRetryLanes = getLanesToRetrySynchronouslyOnError( + root, + originallyAttemptedLanes + ); + 0 !== errorRetryLanes && + ((lanes = errorRetryLanes), + (exitStatus = recoverFromConcurrentError( + root, + originallyAttemptedLanes, + errorRetryLanes + ))); + } + if (1 === exitStatus) + throw ( + ((originallyAttemptedLanes = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended(root, lanes), + ensureRootIsScheduled(root), + originallyAttemptedLanes) + ); + 6 === exitStatus + ? markRootSuspended(root, lanes) + : ((root.finishedWork = root.current.alternate), + (root.finishedLanes = lanes), + commitRoot( + root, + workInProgressRootRecoverableErrors, + workInProgressTransitions + )); + } + ensureRootIsScheduled(root); + } catch (error) { + null === errors ? (errors = [error]) : errors.push(error); + } + root$168 = root$168.next; + } + } while (didPerformSomeWork); + isFlushingWork = !1; + if (null !== errors) { + if (1 < errors.length) { + if ("function" === typeof AggregateError) + throw new AggregateError(errors); + for (onlyLegacy = 1; onlyLegacy < errors.length; onlyLegacy++) + scheduleImmediateTask(throwError.bind(null, errors[onlyLegacy])); + } + throw errors[0]; + } + } +} +function throwError(error) { + throw error; +} +function processRootScheduleInMicrotask() { + mightHavePendingSyncWork = didScheduleMicrotask = !1; + for ( + var currentTime = now(), prev = null, root = firstScheduledRoot; + null !== root; + + ) { + var next = root.next, + nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + 0 === nextLanes + ? ((root.next = null), + null === prev ? (firstScheduledRoot = next) : (prev.next = next), + null === next && (lastScheduledRoot = prev)) + : ((prev = root), + 0 !== (nextLanes & 3) && (mightHavePendingSyncWork = !0)); + root = next; + } + flushSyncWorkAcrossRoots_impl(!1); +} +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + for ( + var suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes & -125829121; + 0 < lanes; + + ) { + var index$2 = 31 - clz32(lanes), + lane = 1 << index$2, + expirationTime = expirationTimes[index$2]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$2] = computeExpirationTime(lane, currentTime); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + currentTime = workInProgressRoot; + suspendedLanes = workInProgressRootRenderLanes; + suspendedLanes = getNextLanes( + root, + root === currentTime ? suspendedLanes : 0 + ); + pingedLanes = root.callbackNode; + if ( + 0 === suspendedLanes || + (2 === workInProgressSuspendedReason && root === currentTime) || + (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) + ) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackNode = null), + (root.callbackPriority = 0) + ); + if (0 !== (suspendedLanes & 3)) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackPriority = 2), + (root.callbackNode = null), + 2 + ); + currentTime = suspendedLanes & -suspendedLanes; + if (currentTime === root.callbackPriority) return currentTime; + null !== pingedLanes && cancelCallback$1(pingedLanes); + switch (lanesToEventPriority(suspendedLanes)) { + case 2: + suspendedLanes = ImmediatePriority; + break; + case 8: + suspendedLanes = UserBlockingPriority; + break; + case 32: + suspendedLanes = NormalPriority$1; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority$1; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$3(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} +function scheduleImmediateTask(cb) { + scheduleMicrotask(function () { + 0 !== (executionContext & 6) + ? scheduleCallback$3(ImmediatePriority, cb) + : cb(); + }); +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -9306,87 +9437,32 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { markRootSuspended(root, workInProgressRootRenderLanes)); markRootUpdated(root, lane, eventTime); if (0 === (executionContext & 2) || root !== workInProgressRoot) { - if (enableTransitionTracing) { - var transition = ReactCurrentBatchConfig$1.transition; - if ( - null !== transition && - null != transition.name && - (-1 === transition.startTime && (transition.startTime = now()), - enableTransitionTracing) - ) { - var transitionLanesMap = root.transitionLanes, - index$6 = 31 - clz32(lane), - transitions = transitionLanesMap[index$6]; - null === transitions && (transitions = new Set()); - transitions.add(transition); - transitionLanesMap[index$6] = transitions; - } + if ( + enableTransitionTracing && + ((eventTime = ReactCurrentBatchConfig$1.transition), + null !== eventTime && + null != eventTime.name && + (-1 === eventTime.startTime && (eventTime.startTime = now()), + enableTransitionTracing)) + ) { + var transitionLanesMap = root.transitionLanes, + index$6 = 31 - clz32(lane), + transitions = transitionLanesMap[index$6]; + null === transitions && (transitions = new Set()); + transitions.add(eventTime); + transitionLanesMap[index$6] = transitions; } root === workInProgressRoot && (0 === (executionContext & 2) && (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended(root, workInProgressRootRenderLanes)); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); 2 === lane && 0 === executionContext && 0 === (fiber.mode & 1) && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); - } -} -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; - markStarvedLanesAsExpired(root, currentTime); - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === nextLanes) - null !== existingCallbackNode && cancelCallback$1(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0); - else if (2 === workInProgressSuspendedReason && workInProgressRoot === root) - (root.callbackPriority = 0), (root.callbackNode = null); - else if (null !== root.cancelPendingCommit && 0 === (nextLanes & 42)) - (root.callbackPriority = 0), (root.callbackNode = null); - else if ( - ((currentTime = nextLanes & -nextLanes), - root.callbackPriority !== currentTime) - ) { - null != existingCallbackNode && cancelCallback$1(existingCallbackNode); - if (0 !== (currentTime & 3)) - 0 === root.tag - ? scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)), - scheduleMicrotask(function () { - 0 === (executionContext & 6) && flushSyncCallbacks(); - }), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(nextLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority$1; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority$1; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; + flushSyncWorkAcrossRoots_impl(!0)); } } function performConcurrentWorkOnRoot(root, didTimeout) { @@ -9427,7 +9503,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); if (6 === exitStatus) markRootSuspended(root, lanes); @@ -9458,7 +9534,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -9570,10 +9646,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode - ? performConcurrentWorkOnRoot.bind(null, root) - : null; + ensureRootIsScheduled(root); + scheduleTaskForRootDuringMicrotask(root, now()); + root = + root.callbackNode === originalCallbackNode + ? performConcurrentWorkOnRoot.bind(null, root) + : null; + return root; } function recoverFromConcurrentError( root, @@ -9681,48 +9760,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 6)) throw Error(formatProdErrorMessage(327)); - flushPassiveEffects(); - var lanes = getNextLanes(root, 0); - if (0 === (lanes & 3)) return ensureRootIsScheduled(root, now()), null; - var exitStatus = renderRootSync(root, lanes); - if (0 !== root.tag && 2 === exitStatus) { - var originallyAttemptedLanes = lanes, - errorRetryLanes = getLanesToRetrySynchronouslyOnError( - root, - originallyAttemptedLanes - ); - 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError( - root, - originallyAttemptedLanes, - errorRetryLanes - ))); - } - if (1 === exitStatus) - throw ( - ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), - exitStatus) - ); - if (6 === exitStatus) - return ( - markRootSuspended(root, lanes), ensureRootIsScheduled(root, now()), null - ); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - commitRoot( - root, - workInProgressRootRecoverableErrors, - workInProgressTransitions - ); - ensureRootIsScheduled(root, now()); - return null; -} function batchedUpdates$1(fn, a) { var prevExecutionContext = executionContext; executionContext |= 1; @@ -9732,7 +9769,7 @@ function batchedUpdates$1(fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } } function flushSync$1(fn) { @@ -9755,7 +9792,7 @@ function flushSync$1(fn) { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$1.transition = prevTransition), (executionContext = prevExecutionContext), - 0 === (executionContext & 6) && flushSyncCallbacks(); + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); } } function resetWorkInProgressStack() { @@ -9939,7 +9976,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -10152,10 +10189,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$55 = offscreenQueue.retryQueue; - null === retryQueue$55 + var retryQueue$53 = offscreenQueue.retryQueue; + null === retryQueue$53 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$55.add(wakeable); + : retryQueue$53.add(wakeable); } } break; @@ -10379,7 +10416,7 @@ function commitRootImpl( remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(finishedWork.stateNode, renderPriorityLevel); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, finishedWork = 0; @@ -10408,7 +10445,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevRootTransitionCallbacks = root.transitionCallbacks; null !== prevRootTransitionCallbacks && @@ -10471,7 +10508,7 @@ function flushPassiveEffectsImpl() { commitPassiveUnmountOnFiber(root.current); commitPassiveMountOnFiber(root, root.current, lanes, transitions); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks, prevRootTransitionCallbacks = root.transitionCallbacks, @@ -10501,7 +10538,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = requestEventTime(); null !== rootFiber && (markRootUpdated(rootFiber, 2, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + ensureRootIsScheduled(rootFiber)); } function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) @@ -10538,7 +10575,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -10564,7 +10601,6 @@ function attachPingListener(root, wakeable, lanes) { function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); root.pingedLanes |= root.suspendedLanes & pingedLanes; workInProgressRoot === root && (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && @@ -10575,7 +10611,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { 500 > now() - globalMostRecentFallbackTime) ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { 0 === retryLane && @@ -10584,7 +10620,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { boundaryFiber = enqueueConcurrentRenderForLane(boundaryFiber, retryLane); null !== boundaryFiber && (markRootUpdated(boundaryFiber, retryLane, eventTime), - ensureRootIsScheduled(boundaryFiber, eventTime)); + ensureRootIsScheduled(boundaryFiber)); } function retryDehydratedSuspenseBoundary(boundaryFiber) { var suspenseState = boundaryFiber.memoizedState, @@ -11215,7 +11251,7 @@ beginWork = function (current, workInProgress, renderLanes) { throw Error(formatProdErrorMessage(156, workInProgress.tag)); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -11531,6 +11567,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -11643,10 +11680,10 @@ function attemptSynchronousHydration(fiber) { var lanes = getHighestPriorityLanes(root$181.pendingLanes); 0 !== lanes && (markRootEntangled(root$181, lanes | 2), - ensureRootIsScheduled(root$181, now()), + ensureRootIsScheduled(root$181), 0 === (executionContext & 6) && ((workInProgressRootRenderTargetTime = now() + 500), - flushSyncCallbacks())); + flushSyncWorkAcrossRoots_impl(!1))); } break; case 13: @@ -12765,19 +12802,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$322; + var JSCompiler_inline_result$jscomp$324; if (canUseDOM) { - var isSupported$jscomp$inline_1518 = "oninput" in document; - if (!isSupported$jscomp$inline_1518) { - var element$jscomp$inline_1519 = document.createElement("div"); - element$jscomp$inline_1519.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1518 = - "function" === typeof element$jscomp$inline_1519.oninput; + var isSupported$jscomp$inline_1547 = "oninput" in document; + if (!isSupported$jscomp$inline_1547) { + var element$jscomp$inline_1548 = document.createElement("div"); + element$jscomp$inline_1548.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1547 = + "function" === typeof element$jscomp$inline_1548.oninput; } - JSCompiler_inline_result$jscomp$322 = isSupported$jscomp$inline_1518; - } else JSCompiler_inline_result$jscomp$322 = !1; + JSCompiler_inline_result$jscomp$324 = isSupported$jscomp$inline_1547; + } else JSCompiler_inline_result$jscomp$324 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$322 && + JSCompiler_inline_result$jscomp$324 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13086,20 +13123,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1559 = 0; - i$jscomp$inline_1559 < simpleEventPluginEvents.length; - i$jscomp$inline_1559++ + var i$jscomp$inline_1588 = 0; + i$jscomp$inline_1588 < simpleEventPluginEvents.length; + i$jscomp$inline_1588++ ) { - var eventName$jscomp$inline_1560 = - simpleEventPluginEvents[i$jscomp$inline_1559], - domEventName$jscomp$inline_1561 = - eventName$jscomp$inline_1560.toLowerCase(), - capitalizedEvent$jscomp$inline_1562 = - eventName$jscomp$inline_1560[0].toUpperCase() + - eventName$jscomp$inline_1560.slice(1); + var eventName$jscomp$inline_1589 = + simpleEventPluginEvents[i$jscomp$inline_1588], + domEventName$jscomp$inline_1590 = + eventName$jscomp$inline_1589.toLowerCase(), + capitalizedEvent$jscomp$inline_1591 = + eventName$jscomp$inline_1589[0].toUpperCase() + + eventName$jscomp$inline_1589.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1561, - "on" + capitalizedEvent$jscomp$inline_1562 + domEventName$jscomp$inline_1590, + "on" + capitalizedEvent$jscomp$inline_1591 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -15443,17 +15480,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1739 = { +var devToolsConfig$jscomp$inline_1768 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-9671399e", + version: "18.3.0-www-modern-e611fbd0", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2134 = { - bundleType: devToolsConfig$jscomp$inline_1739.bundleType, - version: devToolsConfig$jscomp$inline_1739.version, - rendererPackageName: devToolsConfig$jscomp$inline_1739.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1739.rendererConfig, +var internals$jscomp$inline_2169 = { + bundleType: devToolsConfig$jscomp$inline_1768.bundleType, + version: devToolsConfig$jscomp$inline_1768.version, + rendererPackageName: devToolsConfig$jscomp$inline_1768.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1768.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -15470,26 +15507,26 @@ var internals$jscomp$inline_2134 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1739.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1768.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-9671399e" + reconcilerVersion: "18.3.0-www-modern-e611fbd0" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2135 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2170 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2135.isDisabled && - hook$jscomp$inline_2135.supportsFiber + !hook$jscomp$inline_2170.isDisabled && + hook$jscomp$inline_2170.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2135.inject( - internals$jscomp$inline_2134 + (rendererID = hook$jscomp$inline_2170.inject( + internals$jscomp$inline_2169 )), - (injectedHook = hook$jscomp$inline_2135); + (injectedHook = hook$jscomp$inline_2170); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; @@ -15579,7 +15616,7 @@ exports.hydrateRoot = function (container, initialChildren, options) { enqueueUpdate(options, concurrentUpdatesByDefaultOverride, isStrictMode); initialChildren.current.lanes = isStrictMode; markRootUpdated(initialChildren, isStrictMode, identifierPrefix); - ensureRootIsScheduled(initialChildren, identifierPrefix); + ensureRootIsScheduled(initialChildren); container[internalContainerInstanceKey] = initialChildren.current; Dispatcher.current = ReactDOMClientDispatcher; listenToAllSupportedEvents(container); @@ -15646,4 +15683,4 @@ exports.unstable_createEventHandle = function (type, options) { return eventHandle; }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-modern-9671399e"; +exports.version = "18.3.0-www-modern-e611fbd0"; diff --git a/compiled/facebook-www/ReactDOM-profiling.classic.js b/compiled/facebook-www/ReactDOM-profiling.classic.js index 96cf33ceb9..a1a84954dd 100644 --- a/compiled/facebook-www/ReactDOM-profiling.classic.js +++ b/compiled/facebook-www/ReactDOM-profiling.classic.js @@ -63,6 +63,8 @@ var ReactSharedInternals = enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = dynamicFeatureFlags.enableCustomElementPropertySupport, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask, enableProfilerNestedUpdateScheduledHook = dynamicFeatureFlags.enableProfilerNestedUpdateScheduledHook, enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler, @@ -398,7 +400,7 @@ function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -669,25 +671,6 @@ function computeExpirationTime(lane, currentTime) { return -1; } } -function markStarvedLanesAsExpired(root, currentTime) { - for ( - var suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$4 = 31 - clz32(lanes), - lane = 1 << index$4, - expirationTime = expirationTimes[index$4]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$4] = computeExpirationTime(lane, currentTime); - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; - } -} function getLanesToRetrySynchronouslyOnError(root, originallyAttemptedLanes) { if (root.errorRecoveryDisabledLanes & originallyAttemptedLanes) return 0; root = root.pendingLanes & -1073741825; @@ -1610,57 +1593,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - syncQueue = null, - includesLegacySyncCallbacks = !1, - isFlushingSyncQueue = !1; -function scheduleSyncCallback(callback) { - null === syncQueue ? (syncQueue = [callback]) : syncQueue.push(callback); -} -function scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = !0; - scheduleSyncCallback(callback); -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var previousUpdatePriority = currentUpdatePriority; - currentUpdatePriority = 2; - for (var errors = null, queue = syncQueue, i = 0; i < queue.length; i++) { - var callback = queue[i]; - try { - do callback = callback(!0); - while (null !== callback); - } catch (error) { - null === errors ? (errors = [error]) : errors.push(error); - } - } - syncQueue = null; - includesLegacySyncCallbacks = !1; - currentUpdatePriority = previousUpdatePriority; - isFlushingSyncQueue = !1; - if (null !== errors) { - if (1 < errors.length) { - if ("function" === typeof AggregateError) - throw new AggregateError(errors); - for ( - previousUpdatePriority = 1; - previousUpdatePriority < errors.length; - previousUpdatePriority++ - ) - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[previousUpdatePriority]) - ); - } - throw errors[0]; - } - } - return null; -} -function throwError(error) { - throw error; -} -var forkStack = [], + forkStack = [], forkStackIndex = 0, treeForkProvider = null, treeForkCount = 0, @@ -3361,10 +3294,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$46 = thenableIndexCounter; + var index$44 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$46); + usable = trackUsedThenable(thenableState, usable, index$44); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -3856,16 +3789,16 @@ function refreshCache(fiber, seedKey, seedValue) { case 3: var lane = requestUpdateLane(provider); fiber = createUpdate(lane); - var root$52 = enqueueUpdate(provider, fiber, lane); - if (null !== root$52) { + var root$50 = enqueueUpdate(provider, fiber, lane); + if (null !== root$50) { var eventTime = requestEventTime(); - scheduleUpdateOnFiber(root$52, provider, lane, eventTime); - entangleTransitions(root$52, provider, lane); + scheduleUpdateOnFiber(root$50, provider, lane, eventTime); + entangleTransitions(root$50, provider, lane); } provider = createCache(); null !== seedKey && void 0 !== seedKey && - null !== root$52 && + null !== root$50 && provider.data.set(seedKey, seedValue); fiber.payload = { cache: provider }; return; @@ -4074,15 +4007,15 @@ var HooksDispatcherOnMount = { getServerSnapshot = getServerSnapshot(); } else { getServerSnapshot = getSnapshot(); - var root$48 = workInProgressRoot; - if (null === root$48) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(root$48, renderLanes$1) || + var root$46 = workInProgressRoot; + if (null === root$46) throw Error(formatProdErrorMessage(349)); + includesBlockingLane(root$46, renderLanes$1) || pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } hook.memoizedState = getServerSnapshot; - root$48 = { value: getServerSnapshot, getSnapshot: getSnapshot }; - hook.queue = root$48; - mountEffect(subscribeToStore.bind(null, fiber, root$48, subscribe), [ + root$46 = { value: getServerSnapshot, getSnapshot: getSnapshot }; + hook.queue = root$46; + mountEffect(subscribeToStore.bind(null, fiber, root$46, subscribe), [ subscribe ]); fiber.flags |= 2048; @@ -4091,7 +4024,7 @@ var HooksDispatcherOnMount = { updateStoreInstance.bind( null, fiber, - root$48, + root$46, getServerSnapshot, getSnapshot ), @@ -4659,10 +4592,10 @@ var markerInstanceStack = createCursor(null); function pushRootMarkerInstance(workInProgress) { if (enableTransitionTracing) { var transitions = workInProgressTransitions, - root$65 = workInProgress.stateNode; + root$63 = workInProgress.stateNode; null !== transitions && transitions.forEach(function (transition) { - if (!root$65.incompleteTransitions.has(transition)) { + if (!root$63.incompleteTransitions.has(transition)) { var markerInstance = { tag: 0, transitions: new Set([transition]), @@ -4670,11 +4603,11 @@ function pushRootMarkerInstance(workInProgress) { aborts: null, name: null }; - root$65.incompleteTransitions.set(transition, markerInstance); + root$63.incompleteTransitions.set(transition, markerInstance); } }); var markerInstances = []; - root$65.incompleteTransitions.forEach(function (markerInstance) { + root$63.incompleteTransitions.forEach(function (markerInstance) { markerInstances.push(markerInstance); }); push(markerInstanceStack, markerInstances); @@ -5387,14 +5320,14 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } JSCompiler_temp = current.memoizedState; if (null !== JSCompiler_temp) { - var dehydrated$72 = JSCompiler_temp.dehydrated; - if (null !== dehydrated$72) + var dehydrated$70 = JSCompiler_temp.dehydrated; + if (null !== dehydrated$70) return updateDehydratedSuspenseComponent( current, workInProgress, didSuspend, nextProps, - dehydrated$72, + dehydrated$70, JSCompiler_temp, renderLanes ); @@ -5404,7 +5337,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { showFallback = nextProps.fallback; didSuspend = workInProgress.mode; JSCompiler_temp = current.child; - dehydrated$72 = JSCompiler_temp.sibling; + dehydrated$70 = JSCompiler_temp.sibling; var primaryChildProps = { mode: "hidden", children: nextProps.children }; 0 === (didSuspend & 1) && workInProgress.child !== JSCompiler_temp ? ((nextProps = workInProgress.child), @@ -5418,8 +5351,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (workInProgress.deletions = null)) : ((nextProps = createWorkInProgress(JSCompiler_temp, primaryChildProps)), (nextProps.subtreeFlags = JSCompiler_temp.subtreeFlags & 31457280)); - null !== dehydrated$72 - ? (showFallback = createWorkInProgress(dehydrated$72, showFallback)) + null !== dehydrated$70 + ? (showFallback = createWorkInProgress(dehydrated$70, showFallback)) : ((showFallback = createFiberFromFragment( showFallback, didSuspend, @@ -5438,10 +5371,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ? (didSuspend = mountSuspenseOffscreenState(renderLanes)) : ((JSCompiler_temp = didSuspend.cachePool), null !== JSCompiler_temp - ? ((dehydrated$72 = CacheContext._currentValue), + ? ((dehydrated$70 = CacheContext._currentValue), (JSCompiler_temp = - JSCompiler_temp.parent !== dehydrated$72 - ? { parent: dehydrated$72, pool: dehydrated$72 } + JSCompiler_temp.parent !== dehydrated$70 + ? { parent: dehydrated$70, pool: dehydrated$70 } : JSCompiler_temp)) : (JSCompiler_temp = getSuspendedCache()), (didSuspend = { @@ -5455,23 +5388,23 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ((JSCompiler_temp = enableTransitionTracing ? markerInstanceStack.current : null), - (dehydrated$72 = showFallback.updateQueue), + (dehydrated$70 = showFallback.updateQueue), (primaryChildProps = current.updateQueue), - null === dehydrated$72 + null === dehydrated$70 ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null }) - : dehydrated$72 === primaryChildProps + : dehydrated$70 === primaryChildProps ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null !== primaryChildProps ? primaryChildProps.retryQueue : null }) - : ((dehydrated$72.transitions = didSuspend), - (dehydrated$72.markerInstances = JSCompiler_temp)))); + : ((dehydrated$70.transitions = didSuspend), + (dehydrated$70.markerInstances = JSCompiler_temp)))); showFallback.childLanes = current.childLanes & ~renderLanes; workInProgress.memoizedState = SUSPENDED_MARKER; return nextProps; @@ -6277,7 +6210,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -6299,7 +6232,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -6546,14 +6479,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$104 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$104 = lastTailNode), + for (var lastTailNode$102 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$102 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$104 + null === lastTailNode$102 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$104.sibling = null); + : (lastTailNode$102.sibling = null); } } function bubbleProperties(completedWork) { @@ -6565,53 +6498,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$106 = completedWork.selfBaseDuration, - child$107 = completedWork.child; - null !== child$107; + var treeBaseDuration$104 = completedWork.selfBaseDuration, + child$105 = completedWork.child; + null !== child$105; ) - (newChildLanes |= child$107.lanes | child$107.childLanes), - (subtreeFlags |= child$107.subtreeFlags & 31457280), - (subtreeFlags |= child$107.flags & 31457280), - (treeBaseDuration$106 += child$107.treeBaseDuration), - (child$107 = child$107.sibling); - completedWork.treeBaseDuration = treeBaseDuration$106; + (newChildLanes |= child$105.lanes | child$105.childLanes), + (subtreeFlags |= child$105.subtreeFlags & 31457280), + (subtreeFlags |= child$105.flags & 31457280), + (treeBaseDuration$104 += child$105.treeBaseDuration), + (child$105 = child$105.sibling); + completedWork.treeBaseDuration = treeBaseDuration$104; } else for ( - treeBaseDuration$106 = completedWork.child; - null !== treeBaseDuration$106; + treeBaseDuration$104 = completedWork.child; + null !== treeBaseDuration$104; ) (newChildLanes |= - treeBaseDuration$106.lanes | treeBaseDuration$106.childLanes), - (subtreeFlags |= treeBaseDuration$106.subtreeFlags & 31457280), - (subtreeFlags |= treeBaseDuration$106.flags & 31457280), - (treeBaseDuration$106.return = completedWork), - (treeBaseDuration$106 = treeBaseDuration$106.sibling); + treeBaseDuration$104.lanes | treeBaseDuration$104.childLanes), + (subtreeFlags |= treeBaseDuration$104.subtreeFlags & 31457280), + (subtreeFlags |= treeBaseDuration$104.flags & 31457280), + (treeBaseDuration$104.return = completedWork), + (treeBaseDuration$104 = treeBaseDuration$104.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$106 = completedWork.actualDuration; - child$107 = completedWork.selfBaseDuration; + treeBaseDuration$104 = completedWork.actualDuration; + child$105 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$106 += child.actualDuration), - (child$107 += child.treeBaseDuration), + (treeBaseDuration$104 += child.actualDuration), + (child$105 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$106; - completedWork.treeBaseDuration = child$107; + completedWork.actualDuration = treeBaseDuration$104; + completedWork.treeBaseDuration = child$105; } else for ( - treeBaseDuration$106 = completedWork.child; - null !== treeBaseDuration$106; + treeBaseDuration$104 = completedWork.child; + null !== treeBaseDuration$104; ) (newChildLanes |= - treeBaseDuration$106.lanes | treeBaseDuration$106.childLanes), - (subtreeFlags |= treeBaseDuration$106.subtreeFlags), - (subtreeFlags |= treeBaseDuration$106.flags), - (treeBaseDuration$106.return = completedWork), - (treeBaseDuration$106 = treeBaseDuration$106.sibling); + treeBaseDuration$104.lanes | treeBaseDuration$104.childLanes), + (subtreeFlags |= treeBaseDuration$104.subtreeFlags), + (subtreeFlags |= treeBaseDuration$104.flags), + (treeBaseDuration$104.return = completedWork), + (treeBaseDuration$104 = treeBaseDuration$104.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -7415,8 +7348,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (error$140) { - captureCommitPhaseError(current, nearestMountedAncestor, error$140); + } catch (error$138) { + captureCommitPhaseError(current, nearestMountedAncestor, error$138); } else ref.current = null; } @@ -7707,11 +7640,11 @@ function commitPassiveEffectDurations(finishedRoot, finishedWork) { var _finishedWork$memoize = finishedWork.memoizedProps, id = _finishedWork$memoize.id; _finishedWork$memoize = _finishedWork$memoize.onPostCommit; - var commitTime$142 = commitTime, + var commitTime$140 = commitTime, phase = null === finishedWork.alternate ? "mount" : "update"; currentUpdateIsNested && (phase = "nested-update"); "function" === typeof _finishedWork$memoize && - _finishedWork$memoize(id, phase, finishedRoot, commitTime$142); + _finishedWork$memoize(id, phase, finishedRoot, commitTime$140); finishedWork = finishedWork.return; a: for (; null !== finishedWork; ) { switch (finishedWork.tag) { @@ -7738,8 +7671,8 @@ function commitHookLayoutEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$144) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$144); + } catch (error$142) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$142); } } function commitClassCallbacks(finishedWork) { @@ -7838,11 +7771,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { } else try { finishedRoot.componentDidMount(); - } catch (error$145) { + } catch (error$143) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$145 + error$143 ); } else { @@ -7859,11 +7792,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$146) { + } catch (error$144) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$146 + error$144 ); } recordLayoutEffectDuration(finishedWork); @@ -7874,11 +7807,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$147) { + } catch (error$145) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$147 + error$145 ); } } @@ -8577,22 +8510,22 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { startLayoutEffectTimer(), commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$162) { + } catch (error$160) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$162 + error$160 ); } recordLayoutEffectDuration(finishedWork); } else try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$163) { + } catch (error$161) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$163 + error$161 ); } } @@ -8771,11 +8704,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { newProps ); domElement[internalPropsKey] = newProps; - } catch (error$164) { + } catch (error$162) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$164 + error$162 ); } break; @@ -8811,8 +8744,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { root = finishedWork.stateNode; try { setTextContent(root, ""); - } catch (error$165) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$165); + } catch (error$163) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$163); } } if ( @@ -8829,8 +8762,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { updateProperties(flags, maybeNodes, hoistableRoot, current, root), (flags[internalPropsKey] = root); - } catch (error$168) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$168); + } catch (error$166) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$166); } break; case 6: @@ -8843,8 +8776,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { flags = finishedWork.memoizedProps; try { current.nodeValue = flags; - } catch (error$169) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$169); + } catch (error$167) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$167); } } break; @@ -8858,8 +8791,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (flags & 4 && null !== current && current.memoizedState.isDehydrated) try { retryIfBlockedOn(root.containerInfo); - } catch (error$170) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$170); + } catch (error$168) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$168); } break; case 4: @@ -8889,8 +8822,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$172) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$172); + } catch (error$170) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$170); } current = finishedWork.updateQueue; null !== current && @@ -8968,11 +8901,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { root.stateNode.nodeValue = domElement ? "" : root.memoizedProps; - } catch (error$152) { + } catch (error$150) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$152 + error$150 ); } } else if ( @@ -9047,21 +8980,21 @@ function commitReconciliationEffects(finishedWork) { insertOrAppendPlacementNode(finishedWork, before, parent$jscomp$0); break; case 5: - var parent$153 = JSCompiler_inline_result.stateNode; + var parent$151 = JSCompiler_inline_result.stateNode; JSCompiler_inline_result.flags & 32 && - (setTextContent(parent$153, ""), + (setTextContent(parent$151, ""), (JSCompiler_inline_result.flags &= -33)); - var before$154 = getHostSibling(finishedWork); - insertOrAppendPlacementNode(finishedWork, before$154, parent$153); + var before$152 = getHostSibling(finishedWork); + insertOrAppendPlacementNode(finishedWork, before$152, parent$151); break; case 3: case 4: - var parent$155 = JSCompiler_inline_result.stateNode.containerInfo, - before$156 = getHostSibling(finishedWork); + var parent$153 = JSCompiler_inline_result.stateNode.containerInfo, + before$154 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$156, - parent$155 + before$154, + parent$153 ); break; default: @@ -9253,8 +9186,8 @@ function commitHookPassiveMountEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$178) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$178); + } catch (error$176) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$176); } } function commitOffscreenPassiveMountEffects(current, finishedWork, instance) { @@ -9553,9 +9486,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$183 = finishedWork.stateNode; + var instance$181 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$183._visibility & 4 + ? instance$181._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9568,7 +9501,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$183._visibility |= 4), + : ((instance$181._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9576,7 +9509,7 @@ function recursivelyTraverseReconnectPassiveEffects( committedTransitions, includeWorkInProgressEffects )) - : ((instance$183._visibility |= 4), + : ((instance$181._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9589,7 +9522,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$183 + instance$181 ); break; case 24: @@ -9937,6 +9870,206 @@ function schedulePostPaintCallback(callback) { callbacks = []; })); } +var firstScheduledRoot = null, + lastScheduledRoot = null, + didScheduleMicrotask = !1, + mightHavePendingSyncWork = !1, + isFlushingWork = !1; +function ensureRootIsScheduled(root) { + root !== lastScheduledRoot && + null === root.next && + (null === lastScheduledRoot + ? (firstScheduledRoot = lastScheduledRoot = root) + : (lastScheduledRoot = lastScheduledRoot.next = root)); + mightHavePendingSyncWork = !0; + didScheduleMicrotask || + ((didScheduleMicrotask = !0), + scheduleImmediateTask(processRootScheduleInMicrotask)); + enableDeferRootSchedulingToMicrotask || + scheduleTaskForRootDuringMicrotask(root, now$1()); +} +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (!isFlushingWork && mightHavePendingSyncWork) { + var workInProgressRoot$jscomp$0 = workInProgressRoot, + workInProgressRootRenderLanes$jscomp$0 = workInProgressRootRenderLanes, + errors = null; + isFlushingWork = !0; + do { + var didPerformSomeWork = !1; + for (var root$189 = firstScheduledRoot; null !== root$189; ) { + if ( + (!onlyLegacy || 0 === root$189.tag) && + 0 !== + (getNextLanes( + root$189, + root$189 === workInProgressRoot$jscomp$0 + ? workInProgressRootRenderLanes$jscomp$0 + : 0 + ) & + 3) + ) + try { + didPerformSomeWork = !0; + var root = root$189; + currentUpdateIsNested = nestedUpdateScheduled; + nestedUpdateScheduled = !1; + if (0 !== (executionContext & 6)) + throw Error(formatProdErrorMessage(327)); + flushPassiveEffects(); + var lanes = getNextLanes(root, 0); + if (0 !== (lanes & 3)) { + var exitStatus = renderRootSync(root, lanes); + if (0 !== root.tag && 2 === exitStatus) { + var originallyAttemptedLanes = lanes, + errorRetryLanes = getLanesToRetrySynchronouslyOnError( + root, + originallyAttemptedLanes + ); + 0 !== errorRetryLanes && + ((lanes = errorRetryLanes), + (exitStatus = recoverFromConcurrentError( + root, + originallyAttemptedLanes, + errorRetryLanes + ))); + } + if (1 === exitStatus) + throw ( + ((originallyAttemptedLanes = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended(root, lanes), + ensureRootIsScheduled(root), + originallyAttemptedLanes) + ); + 6 === exitStatus + ? markRootSuspended(root, lanes) + : ((root.finishedWork = root.current.alternate), + (root.finishedLanes = lanes), + commitRoot( + root, + workInProgressRootRecoverableErrors, + workInProgressTransitions + )); + } + ensureRootIsScheduled(root); + } catch (error) { + null === errors ? (errors = [error]) : errors.push(error); + } + root$189 = root$189.next; + } + } while (didPerformSomeWork); + isFlushingWork = !1; + if (null !== errors) { + if (1 < errors.length) { + if ("function" === typeof AggregateError) + throw new AggregateError(errors); + for (onlyLegacy = 1; onlyLegacy < errors.length; onlyLegacy++) + scheduleImmediateTask(throwError.bind(null, errors[onlyLegacy])); + } + throw errors[0]; + } + } +} +function throwError(error) { + throw error; +} +function processRootScheduleInMicrotask() { + mightHavePendingSyncWork = didScheduleMicrotask = !1; + for ( + var currentTime = now$1(), prev = null, root = firstScheduledRoot; + null !== root; + + ) { + var next = root.next, + nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + 0 === nextLanes + ? ((root.next = null), + null === prev ? (firstScheduledRoot = next) : (prev.next = next), + null === next && (lastScheduledRoot = prev)) + : ((prev = root), + 0 !== (nextLanes & 3) && (mightHavePendingSyncWork = !0)); + root = next; + } + flushSyncWorkAcrossRoots_impl(!1); +} +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + for ( + var suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes & -125829121; + 0 < lanes; + + ) { + var index$4 = 31 - clz32(lanes), + lane = 1 << index$4, + expirationTime = expirationTimes[index$4]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$4] = computeExpirationTime(lane, currentTime); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + currentTime = workInProgressRoot; + suspendedLanes = workInProgressRootRenderLanes; + suspendedLanes = getNextLanes( + root, + root === currentTime ? suspendedLanes : 0 + ); + pingedLanes = root.callbackNode; + if ( + 0 === suspendedLanes || + (2 === workInProgressSuspendedReason && root === currentTime) || + (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) + ) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackNode = null), + (root.callbackPriority = 0) + ); + if (0 !== (suspendedLanes & 3)) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackPriority = 2), + (root.callbackNode = null), + 2 + ); + currentTime = suspendedLanes & -suspendedLanes; + if (currentTime === root.callbackPriority) return currentTime; + null !== pingedLanes && cancelCallback$1(pingedLanes); + switch (lanesToEventPriority(suspendedLanes)) { + case 2: + suspendedLanes = ImmediatePriority; + break; + case 8: + suspendedLanes = UserBlockingPriority; + break; + case 32: + suspendedLanes = NormalPriority$1; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority$1; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$3(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} +function scheduleImmediateTask(cb) { + scheduleMicrotask(function () { + 0 !== (executionContext & 6) + ? scheduleCallback$3(ImmediatePriority, cb) + : cb(); + }); +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -10075,29 +10208,29 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { root === rootCommittingMutationOrLayoutEffects && fiber.mode & 2 ) - for (var current = fiber; null !== current; ) { - if (12 === current.tag) { - var _current$memoizedProp = current.memoizedProps, + for (eventTime = fiber; null !== eventTime; ) { + if (12 === eventTime.tag) { + var _current$memoizedProp = eventTime.memoizedProps, id = _current$memoizedProp.id; _current$memoizedProp = _current$memoizedProp.onNestedUpdateScheduled; "function" === typeof _current$memoizedProp && _current$memoizedProp(id); } - current = current.return; + eventTime = eventTime.return; } if ( enableTransitionTracing && - ((current = ReactCurrentBatchConfig$1.transition), - null !== current && - null != current.name && - (-1 === current.startTime && (current.startTime = now$1()), + ((eventTime = ReactCurrentBatchConfig$1.transition), + null !== eventTime && + null != eventTime.name && + (-1 === eventTime.startTime && (eventTime.startTime = now$1()), enableTransitionTracing)) ) { id = root.transitionLanes; _current$memoizedProp = 31 - clz32(lane); var transitions = id[_current$memoizedProp]; null === transitions && (transitions = new Set()); - transitions.add(current); + transitions.add(eventTime); id[_current$memoizedProp] = transitions; } root === workInProgressRoot && @@ -10105,66 +10238,12 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended(root, workInProgressRootRenderLanes)); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); 2 === lane && 0 === executionContext && 0 === (fiber.mode & 1) && ((workInProgressRootRenderTargetTime = now$1() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); - } -} -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; - markStarvedLanesAsExpired(root, currentTime); - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === nextLanes) - null !== existingCallbackNode && cancelCallback$1(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0); - else if (2 === workInProgressSuspendedReason && workInProgressRoot === root) - (root.callbackPriority = 0), (root.callbackNode = null); - else if (null !== root.cancelPendingCommit && 0 === (nextLanes & 42)) - (root.callbackPriority = 0), (root.callbackNode = null); - else if ( - ((currentTime = nextLanes & -nextLanes), - root.callbackPriority !== currentTime) - ) { - null != existingCallbackNode && cancelCallback$1(existingCallbackNode); - if (0 !== (currentTime & 3)) - 0 === root.tag - ? scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)), - scheduleMicrotask(function () { - 0 === (executionContext & 6) && flushSyncCallbacks(); - }), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(nextLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority$1; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority$1; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; + flushSyncWorkAcrossRoots_impl(!0)); } } function performConcurrentWorkOnRoot(root, didTimeout) { @@ -10206,7 +10285,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now$1()), + ensureRootIsScheduled(root), originalCallbackNode) ); if (6 === exitStatus) markRootSuspended(root, lanes); @@ -10237,7 +10316,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now$1()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -10349,10 +10428,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } } - ensureRootIsScheduled(root, now$1()); - return root.callbackNode === originalCallbackNode - ? performConcurrentWorkOnRoot.bind(null, root) - : null; + ensureRootIsScheduled(root); + scheduleTaskForRootDuringMicrotask(root, now$1()); + root = + root.callbackNode === originalCallbackNode + ? performConcurrentWorkOnRoot.bind(null, root) + : null; + return root; } function recoverFromConcurrentError( root, @@ -10460,50 +10542,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - currentUpdateIsNested = nestedUpdateScheduled; - nestedUpdateScheduled = !1; - if (0 !== (executionContext & 6)) throw Error(formatProdErrorMessage(327)); - flushPassiveEffects(); - var lanes = getNextLanes(root, 0); - if (0 === (lanes & 3)) return ensureRootIsScheduled(root, now$1()), null; - var exitStatus = renderRootSync(root, lanes); - if (0 !== root.tag && 2 === exitStatus) { - var originallyAttemptedLanes = lanes, - errorRetryLanes = getLanesToRetrySynchronouslyOnError( - root, - originallyAttemptedLanes - ); - 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError( - root, - originallyAttemptedLanes, - errorRetryLanes - ))); - } - if (1 === exitStatus) - throw ( - ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now$1()), - exitStatus) - ); - if (6 === exitStatus) - return ( - markRootSuspended(root, lanes), ensureRootIsScheduled(root, now$1()), null - ); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - commitRoot( - root, - workInProgressRootRecoverableErrors, - workInProgressTransitions - ); - ensureRootIsScheduled(root, now$1()); - return null; -} function batchedUpdates$1(fn, a) { var prevExecutionContext = executionContext; executionContext |= 1; @@ -10513,7 +10551,7 @@ function batchedUpdates$1(fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now$1() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } } function flushSync$1(fn) { @@ -10536,7 +10574,7 @@ function flushSync$1(fn) { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$1.transition = prevTransition), (executionContext = prevExecutionContext), - 0 === (executionContext & 6) && flushSyncCallbacks(); + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); } } function resetWorkInProgressStack() { @@ -10771,7 +10809,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; memoizedUpdaters.then(lanes, lanes); break a; @@ -11003,10 +11041,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$60 = offscreenQueue.retryQueue; - null === retryQueue$60 + var retryQueue$58 = offscreenQueue.retryQueue; + null === retryQueue$58 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$60.add(wakeable); + : retryQueue$58.add(wakeable); } } break; @@ -11260,7 +11298,7 @@ function commitRootImpl( 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(finishedWork.stateNode, renderPriorityLevel); isDevToolsPresent && root.memoizedUpdaters.clear(); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, finishedWork = 0; @@ -11290,7 +11328,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); enableSchedulingProfiler && markCommitStopped(); if (enableTransitionTracing) { var prevRootTransitionCallbacks = root.transitionCallbacks; @@ -11377,7 +11415,7 @@ function flushPassiveEffectsImpl() { "function" === typeof injectedProfilingHooks.markPassiveEffectsStopped && injectedProfilingHooks.markPassiveEffectsStopped(); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks, prevRootTransitionCallbacks = root.transitionCallbacks, @@ -11410,7 +11448,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = requestEventTime(); null !== rootFiber && (markRootUpdated(rootFiber, 2, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + ensureRootIsScheduled(rootFiber)); } function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) @@ -11447,7 +11485,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -11474,7 +11512,6 @@ function attachPingListener(root, wakeable, lanes) { function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); root.pingedLanes |= root.suspendedLanes & pingedLanes; workInProgressRoot === root && (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && @@ -11485,7 +11522,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { 500 > now$1() - globalMostRecentFallbackTime) ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { 0 === retryLane && @@ -11494,7 +11531,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { boundaryFiber = enqueueConcurrentRenderForLane(boundaryFiber, retryLane); null !== boundaryFiber && (markRootUpdated(boundaryFiber, retryLane, eventTime), - ensureRootIsScheduled(boundaryFiber, eventTime)); + ensureRootIsScheduled(boundaryFiber)); } function retryDehydratedSuspenseBoundary(boundaryFiber) { var suspenseState = boundaryFiber.memoizedState, @@ -12166,7 +12203,7 @@ function restorePendingUpdaters(root, lanes) { }); } function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -12494,6 +12531,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -12658,7 +12696,7 @@ function createHydrationContainer( enqueueUpdate(containerInfo, hydrationCallbacks, tag); initialChildren.current.lanes = tag; markRootUpdated(initialChildren, tag, callback); - ensureRootIsScheduled(initialChildren, callback); + ensureRootIsScheduled(initialChildren); return initialChildren; } function updateContainer(element, container, parentComponent, callback) { @@ -12703,10 +12741,10 @@ function attemptSynchronousHydration(fiber) { var lanes = getHighestPriorityLanes(root$203.pendingLanes); 0 !== lanes && (markRootEntangled(root$203, lanes | 2), - ensureRootIsScheduled(root$203, now$1()), + ensureRootIsScheduled(root$203), 0 === (executionContext & 6) && ((workInProgressRootRenderTargetTime = now$1() + 500), - flushSyncCallbacks())); + flushSyncWorkAcrossRoots_impl(!1))); } break; case 13: @@ -13275,19 +13313,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$346; + var JSCompiler_inline_result$jscomp$348; if (canUseDOM) { - var isSupported$jscomp$inline_1606 = "oninput" in document; - if (!isSupported$jscomp$inline_1606) { - var element$jscomp$inline_1607 = document.createElement("div"); - element$jscomp$inline_1607.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1606 = - "function" === typeof element$jscomp$inline_1607.oninput; + var isSupported$jscomp$inline_1634 = "oninput" in document; + if (!isSupported$jscomp$inline_1634) { + var element$jscomp$inline_1635 = document.createElement("div"); + element$jscomp$inline_1635.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1634 = + "function" === typeof element$jscomp$inline_1635.oninput; } - JSCompiler_inline_result$jscomp$346 = isSupported$jscomp$inline_1606; - } else JSCompiler_inline_result$jscomp$346 = !1; + JSCompiler_inline_result$jscomp$348 = isSupported$jscomp$inline_1634; + } else JSCompiler_inline_result$jscomp$348 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$346 && + JSCompiler_inline_result$jscomp$348 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13596,20 +13634,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1647 = 0; - i$jscomp$inline_1647 < simpleEventPluginEvents.length; - i$jscomp$inline_1647++ + var i$jscomp$inline_1675 = 0; + i$jscomp$inline_1675 < simpleEventPluginEvents.length; + i$jscomp$inline_1675++ ) { - var eventName$jscomp$inline_1648 = - simpleEventPluginEvents[i$jscomp$inline_1647], - domEventName$jscomp$inline_1649 = - eventName$jscomp$inline_1648.toLowerCase(), - capitalizedEvent$jscomp$inline_1650 = - eventName$jscomp$inline_1648[0].toUpperCase() + - eventName$jscomp$inline_1648.slice(1); + var eventName$jscomp$inline_1676 = + simpleEventPluginEvents[i$jscomp$inline_1675], + domEventName$jscomp$inline_1677 = + eventName$jscomp$inline_1676.toLowerCase(), + capitalizedEvent$jscomp$inline_1678 = + eventName$jscomp$inline_1676[0].toUpperCase() + + eventName$jscomp$inline_1676.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1649, - "on" + capitalizedEvent$jscomp$inline_1650 + domEventName$jscomp$inline_1677, + "on" + capitalizedEvent$jscomp$inline_1678 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -16689,10 +16727,10 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1861 = { +var devToolsConfig$jscomp$inline_1889 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-64cba185", + version: "18.3.0-www-classic-77bbb098", rendererPackageName: "react-dom" }; (function (internals) { @@ -16710,10 +16748,10 @@ var devToolsConfig$jscomp$inline_1861 = { } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1861.bundleType, - version: devToolsConfig$jscomp$inline_1861.version, - rendererPackageName: devToolsConfig$jscomp$inline_1861.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1861.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1889.bundleType, + version: devToolsConfig$jscomp$inline_1889.version, + rendererPackageName: devToolsConfig$jscomp$inline_1889.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1889.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -16729,14 +16767,14 @@ var devToolsConfig$jscomp$inline_1861 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1861.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1889.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-64cba185" + reconcilerVersion: "18.3.0-www-classic-77bbb098" }); assign(Internals, { ReactBrowserEventEmitter: { @@ -16963,7 +17001,7 @@ exports.unstable_renderSubtreeIntoContainer = function ( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-classic-64cba185"; +exports.version = "18.3.0-www-classic-77bbb098"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOM-profiling.modern.js b/compiled/facebook-www/ReactDOM-profiling.modern.js index 034cb79087..8e61095f26 100644 --- a/compiled/facebook-www/ReactDOM-profiling.modern.js +++ b/compiled/facebook-www/ReactDOM-profiling.modern.js @@ -120,10 +120,12 @@ var dynamicFeatureFlags = require("ReactFeatureFlags"), enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = dynamicFeatureFlags.enableCustomElementPropertySupport, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask, enableProfilerNestedUpdateScheduledHook = dynamicFeatureFlags.enableProfilerNestedUpdateScheduledHook, enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler, - scheduleCallback$2 = Scheduler.unstable_scheduleCallback, + scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -396,25 +398,6 @@ function computeExpirationTime(lane, currentTime) { return -1; } } -function markStarvedLanesAsExpired(root, currentTime) { - for ( - var suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$3 = 31 - clz32(lanes), - lane = 1 << index$3, - expirationTime = expirationTimes[index$3]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$3] = computeExpirationTime(lane, currentTime); - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; - } -} function getLanesToRetrySynchronouslyOnError(root, originallyAttemptedLanes) { if (root.errorRecoveryDisabledLanes & originallyAttemptedLanes) return 0; root = root.pendingLanes & -1073741825; @@ -1498,57 +1481,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - syncQueue = null, - includesLegacySyncCallbacks = !1, - isFlushingSyncQueue = !1; -function scheduleSyncCallback(callback) { - null === syncQueue ? (syncQueue = [callback]) : syncQueue.push(callback); -} -function scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = !0; - scheduleSyncCallback(callback); -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var previousUpdatePriority = currentUpdatePriority; - currentUpdatePriority = 2; - for (var errors = null, queue = syncQueue, i = 0; i < queue.length; i++) { - var callback = queue[i]; - try { - do callback = callback(!0); - while (null !== callback); - } catch (error) { - null === errors ? (errors = [error]) : errors.push(error); - } - } - syncQueue = null; - includesLegacySyncCallbacks = !1; - currentUpdatePriority = previousUpdatePriority; - isFlushingSyncQueue = !1; - if (null !== errors) { - if (1 < errors.length) { - if ("function" === typeof AggregateError) - throw new AggregateError(errors); - for ( - previousUpdatePriority = 1; - previousUpdatePriority < errors.length; - previousUpdatePriority++ - ) - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[previousUpdatePriority]) - ); - } - throw errors[0]; - } - } - return null; -} -function throwError(error) { - throw error; -} -var forkStack = [], + forkStack = [], forkStackIndex = 0, treeForkProvider = null, treeForkCount = 0, @@ -3249,10 +3182,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$46 = thenableIndexCounter; + var index$44 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$46); + usable = trackUsedThenable(thenableState, usable, index$44); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -3744,16 +3677,16 @@ function refreshCache(fiber, seedKey, seedValue) { case 3: var lane = requestUpdateLane(provider); fiber = createUpdate(lane); - var root$52 = enqueueUpdate(provider, fiber, lane); - if (null !== root$52) { + var root$50 = enqueueUpdate(provider, fiber, lane); + if (null !== root$50) { var eventTime = requestEventTime(); - scheduleUpdateOnFiber(root$52, provider, lane, eventTime); - entangleTransitions(root$52, provider, lane); + scheduleUpdateOnFiber(root$50, provider, lane, eventTime); + entangleTransitions(root$50, provider, lane); } provider = createCache(); null !== seedKey && void 0 !== seedKey && - null !== root$52 && + null !== root$50 && provider.data.set(seedKey, seedValue); fiber.payload = { cache: provider }; return; @@ -3962,15 +3895,15 @@ var HooksDispatcherOnMount = { getServerSnapshot = getServerSnapshot(); } else { getServerSnapshot = getSnapshot(); - var root$48 = workInProgressRoot; - if (null === root$48) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(root$48, renderLanes$1) || + var root$46 = workInProgressRoot; + if (null === root$46) throw Error(formatProdErrorMessage(349)); + includesBlockingLane(root$46, renderLanes$1) || pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } hook.memoizedState = getServerSnapshot; - root$48 = { value: getServerSnapshot, getSnapshot: getSnapshot }; - hook.queue = root$48; - mountEffect(subscribeToStore.bind(null, fiber, root$48, subscribe), [ + root$46 = { value: getServerSnapshot, getSnapshot: getSnapshot }; + hook.queue = root$46; + mountEffect(subscribeToStore.bind(null, fiber, root$46, subscribe), [ subscribe ]); fiber.flags |= 2048; @@ -3979,7 +3912,7 @@ var HooksDispatcherOnMount = { updateStoreInstance.bind( null, fiber, - root$48, + root$46, getServerSnapshot, getSnapshot ), @@ -4532,10 +4465,10 @@ var markerInstanceStack = createCursor(null); function pushRootMarkerInstance(workInProgress) { if (enableTransitionTracing) { var transitions = workInProgressTransitions, - root$65 = workInProgress.stateNode; + root$63 = workInProgress.stateNode; null !== transitions && transitions.forEach(function (transition) { - if (!root$65.incompleteTransitions.has(transition)) { + if (!root$63.incompleteTransitions.has(transition)) { var markerInstance = { tag: 0, transitions: new Set([transition]), @@ -4543,11 +4476,11 @@ function pushRootMarkerInstance(workInProgress) { aborts: null, name: null }; - root$65.incompleteTransitions.set(transition, markerInstance); + root$63.incompleteTransitions.set(transition, markerInstance); } }); var markerInstances = []; - root$65.incompleteTransitions.forEach(function (markerInstance) { + root$63.incompleteTransitions.forEach(function (markerInstance) { markerInstances.push(markerInstance); }); push(markerInstanceStack, markerInstances); @@ -5218,14 +5151,14 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } JSCompiler_temp = current.memoizedState; if (null !== JSCompiler_temp) { - var dehydrated$72 = JSCompiler_temp.dehydrated; - if (null !== dehydrated$72) + var dehydrated$70 = JSCompiler_temp.dehydrated; + if (null !== dehydrated$70) return updateDehydratedSuspenseComponent( current, workInProgress, didSuspend, nextProps, - dehydrated$72, + dehydrated$70, JSCompiler_temp, renderLanes ); @@ -5235,7 +5168,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { showFallback = nextProps.fallback; didSuspend = workInProgress.mode; JSCompiler_temp = current.child; - dehydrated$72 = JSCompiler_temp.sibling; + dehydrated$70 = JSCompiler_temp.sibling; var primaryChildProps = { mode: "hidden", children: nextProps.children }; 0 === (didSuspend & 1) && workInProgress.child !== JSCompiler_temp ? ((nextProps = workInProgress.child), @@ -5249,8 +5182,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (workInProgress.deletions = null)) : ((nextProps = createWorkInProgress(JSCompiler_temp, primaryChildProps)), (nextProps.subtreeFlags = JSCompiler_temp.subtreeFlags & 31457280)); - null !== dehydrated$72 - ? (showFallback = createWorkInProgress(dehydrated$72, showFallback)) + null !== dehydrated$70 + ? (showFallback = createWorkInProgress(dehydrated$70, showFallback)) : ((showFallback = createFiberFromFragment( showFallback, didSuspend, @@ -5269,10 +5202,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ? (didSuspend = mountSuspenseOffscreenState(renderLanes)) : ((JSCompiler_temp = didSuspend.cachePool), null !== JSCompiler_temp - ? ((dehydrated$72 = CacheContext._currentValue), + ? ((dehydrated$70 = CacheContext._currentValue), (JSCompiler_temp = - JSCompiler_temp.parent !== dehydrated$72 - ? { parent: dehydrated$72, pool: dehydrated$72 } + JSCompiler_temp.parent !== dehydrated$70 + ? { parent: dehydrated$70, pool: dehydrated$70 } : JSCompiler_temp)) : (JSCompiler_temp = getSuspendedCache()), (didSuspend = { @@ -5286,23 +5219,23 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ((JSCompiler_temp = enableTransitionTracing ? markerInstanceStack.current : null), - (dehydrated$72 = showFallback.updateQueue), + (dehydrated$70 = showFallback.updateQueue), (primaryChildProps = current.updateQueue), - null === dehydrated$72 + null === dehydrated$70 ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null }) - : dehydrated$72 === primaryChildProps + : dehydrated$70 === primaryChildProps ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null !== primaryChildProps ? primaryChildProps.retryQueue : null }) - : ((dehydrated$72.transitions = didSuspend), - (dehydrated$72.markerInstances = JSCompiler_temp)))); + : ((dehydrated$70.transitions = didSuspend), + (dehydrated$70.markerInstances = JSCompiler_temp)))); showFallback.childLanes = current.childLanes & ~renderLanes; workInProgress.memoizedState = SUSPENDED_MARKER; return nextProps; @@ -6104,7 +6037,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -6126,7 +6059,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -6373,14 +6306,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$104 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$104 = lastTailNode), + for (var lastTailNode$102 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$102 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$104 + null === lastTailNode$102 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$104.sibling = null); + : (lastTailNode$102.sibling = null); } } function bubbleProperties(completedWork) { @@ -6392,53 +6325,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$106 = completedWork.selfBaseDuration, - child$107 = completedWork.child; - null !== child$107; + var treeBaseDuration$104 = completedWork.selfBaseDuration, + child$105 = completedWork.child; + null !== child$105; ) - (newChildLanes |= child$107.lanes | child$107.childLanes), - (subtreeFlags |= child$107.subtreeFlags & 31457280), - (subtreeFlags |= child$107.flags & 31457280), - (treeBaseDuration$106 += child$107.treeBaseDuration), - (child$107 = child$107.sibling); - completedWork.treeBaseDuration = treeBaseDuration$106; + (newChildLanes |= child$105.lanes | child$105.childLanes), + (subtreeFlags |= child$105.subtreeFlags & 31457280), + (subtreeFlags |= child$105.flags & 31457280), + (treeBaseDuration$104 += child$105.treeBaseDuration), + (child$105 = child$105.sibling); + completedWork.treeBaseDuration = treeBaseDuration$104; } else for ( - treeBaseDuration$106 = completedWork.child; - null !== treeBaseDuration$106; + treeBaseDuration$104 = completedWork.child; + null !== treeBaseDuration$104; ) (newChildLanes |= - treeBaseDuration$106.lanes | treeBaseDuration$106.childLanes), - (subtreeFlags |= treeBaseDuration$106.subtreeFlags & 31457280), - (subtreeFlags |= treeBaseDuration$106.flags & 31457280), - (treeBaseDuration$106.return = completedWork), - (treeBaseDuration$106 = treeBaseDuration$106.sibling); + treeBaseDuration$104.lanes | treeBaseDuration$104.childLanes), + (subtreeFlags |= treeBaseDuration$104.subtreeFlags & 31457280), + (subtreeFlags |= treeBaseDuration$104.flags & 31457280), + (treeBaseDuration$104.return = completedWork), + (treeBaseDuration$104 = treeBaseDuration$104.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$106 = completedWork.actualDuration; - child$107 = completedWork.selfBaseDuration; + treeBaseDuration$104 = completedWork.actualDuration; + child$105 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$106 += child.actualDuration), - (child$107 += child.treeBaseDuration), + (treeBaseDuration$104 += child.actualDuration), + (child$105 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$106; - completedWork.treeBaseDuration = child$107; + completedWork.actualDuration = treeBaseDuration$104; + completedWork.treeBaseDuration = child$105; } else for ( - treeBaseDuration$106 = completedWork.child; - null !== treeBaseDuration$106; + treeBaseDuration$104 = completedWork.child; + null !== treeBaseDuration$104; ) (newChildLanes |= - treeBaseDuration$106.lanes | treeBaseDuration$106.childLanes), - (subtreeFlags |= treeBaseDuration$106.subtreeFlags), - (subtreeFlags |= treeBaseDuration$106.flags), - (treeBaseDuration$106.return = completedWork), - (treeBaseDuration$106 = treeBaseDuration$106.sibling); + treeBaseDuration$104.lanes | treeBaseDuration$104.childLanes), + (subtreeFlags |= treeBaseDuration$104.subtreeFlags), + (subtreeFlags |= treeBaseDuration$104.flags), + (treeBaseDuration$104.return = completedWork), + (treeBaseDuration$104 = treeBaseDuration$104.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -7223,8 +7156,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (error$139) { - captureCommitPhaseError(current, nearestMountedAncestor, error$139); + } catch (error$137) { + captureCommitPhaseError(current, nearestMountedAncestor, error$137); } else ref.current = null; } @@ -7528,11 +7461,11 @@ function commitPassiveEffectDurations(finishedRoot, finishedWork) { var _finishedWork$memoize = finishedWork.memoizedProps, id = _finishedWork$memoize.id; _finishedWork$memoize = _finishedWork$memoize.onPostCommit; - var commitTime$141 = commitTime, + var commitTime$139 = commitTime, phase = null === finishedWork.alternate ? "mount" : "update"; currentUpdateIsNested && (phase = "nested-update"); "function" === typeof _finishedWork$memoize && - _finishedWork$memoize(id, phase, finishedRoot, commitTime$141); + _finishedWork$memoize(id, phase, finishedRoot, commitTime$139); finishedWork = finishedWork.return; a: for (; null !== finishedWork; ) { switch (finishedWork.tag) { @@ -7559,8 +7492,8 @@ function commitHookLayoutEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$143) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$143); + } catch (error$141) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$141); } } function commitClassCallbacks(finishedWork) { @@ -7659,11 +7592,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { } else try { finishedRoot.componentDidMount(); - } catch (error$144) { + } catch (error$142) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$144 + error$142 ); } else { @@ -7680,11 +7613,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$145) { + } catch (error$143) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$145 + error$143 ); } recordLayoutEffectDuration(finishedWork); @@ -7695,11 +7628,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$146) { + } catch (error$144) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$146 + error$144 ); } } @@ -8398,22 +8331,22 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { startLayoutEffectTimer(), commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$161) { + } catch (error$159) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$161 + error$159 ); } recordLayoutEffectDuration(finishedWork); } else try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$162) { + } catch (error$160) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$162 + error$160 ); } } @@ -8592,11 +8525,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { newProps ); domElement[internalPropsKey] = newProps; - } catch (error$163) { + } catch (error$161) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$163 + error$161 ); } break; @@ -8632,8 +8565,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { root = finishedWork.stateNode; try { setTextContent(root, ""); - } catch (error$164) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$164); + } catch (error$162) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$162); } } if ( @@ -8650,8 +8583,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { updateProperties(flags, maybeNodes, hoistableRoot, current, root), (flags[internalPropsKey] = root); - } catch (error$167) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$167); + } catch (error$165) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$165); } break; case 6: @@ -8664,8 +8597,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { flags = finishedWork.memoizedProps; try { current.nodeValue = flags; - } catch (error$168) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$168); + } catch (error$166) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$166); } } break; @@ -8679,8 +8612,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (flags & 4 && null !== current && current.memoizedState.isDehydrated) try { retryIfBlockedOn(root.containerInfo); - } catch (error$169) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$169); + } catch (error$167) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$167); } break; case 4: @@ -8710,8 +8643,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$171) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$171); + } catch (error$169) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$169); } current = finishedWork.updateQueue; null !== current && @@ -8789,11 +8722,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { root.stateNode.nodeValue = domElement ? "" : root.memoizedProps; - } catch (error$151) { + } catch (error$149) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$151 + error$149 ); } } else if ( @@ -8868,21 +8801,21 @@ function commitReconciliationEffects(finishedWork) { insertOrAppendPlacementNode(finishedWork, before, parent$jscomp$0); break; case 5: - var parent$152 = JSCompiler_inline_result.stateNode; + var parent$150 = JSCompiler_inline_result.stateNode; JSCompiler_inline_result.flags & 32 && - (setTextContent(parent$152, ""), + (setTextContent(parent$150, ""), (JSCompiler_inline_result.flags &= -33)); - var before$153 = getHostSibling(finishedWork); - insertOrAppendPlacementNode(finishedWork, before$153, parent$152); + var before$151 = getHostSibling(finishedWork); + insertOrAppendPlacementNode(finishedWork, before$151, parent$150); break; case 3: case 4: - var parent$154 = JSCompiler_inline_result.stateNode.containerInfo, - before$155 = getHostSibling(finishedWork); + var parent$152 = JSCompiler_inline_result.stateNode.containerInfo, + before$153 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$155, - parent$154 + before$153, + parent$152 ); break; default: @@ -9074,8 +9007,8 @@ function commitHookPassiveMountEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$177) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$177); + } catch (error$175) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$175); } } function commitOffscreenPassiveMountEffects(current, finishedWork, instance) { @@ -9374,9 +9307,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$182 = finishedWork.stateNode; + var instance$180 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$182._visibility & 4 + ? instance$180._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9389,7 +9322,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$182._visibility |= 4), + : ((instance$180._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9397,7 +9330,7 @@ function recursivelyTraverseReconnectPassiveEffects( committedTransitions, includeWorkInProgressEffects )) - : ((instance$182._visibility |= 4), + : ((instance$180._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9410,7 +9343,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$182 + instance$180 ); break; case 24: @@ -9758,6 +9691,206 @@ function schedulePostPaintCallback(callback) { callbacks = []; })); } +var firstScheduledRoot = null, + lastScheduledRoot = null, + didScheduleMicrotask = !1, + mightHavePendingSyncWork = !1, + isFlushingWork = !1; +function ensureRootIsScheduled(root) { + root !== lastScheduledRoot && + null === root.next && + (null === lastScheduledRoot + ? (firstScheduledRoot = lastScheduledRoot = root) + : (lastScheduledRoot = lastScheduledRoot.next = root)); + mightHavePendingSyncWork = !0; + didScheduleMicrotask || + ((didScheduleMicrotask = !0), + scheduleImmediateTask(processRootScheduleInMicrotask)); + enableDeferRootSchedulingToMicrotask || + scheduleTaskForRootDuringMicrotask(root, now$1()); +} +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (!isFlushingWork && mightHavePendingSyncWork) { + var workInProgressRoot$jscomp$0 = workInProgressRoot, + workInProgressRootRenderLanes$jscomp$0 = workInProgressRootRenderLanes, + errors = null; + isFlushingWork = !0; + do { + var didPerformSomeWork = !1; + for (var root$188 = firstScheduledRoot; null !== root$188; ) { + if ( + (!onlyLegacy || 0 === root$188.tag) && + 0 !== + (getNextLanes( + root$188, + root$188 === workInProgressRoot$jscomp$0 + ? workInProgressRootRenderLanes$jscomp$0 + : 0 + ) & + 3) + ) + try { + didPerformSomeWork = !0; + var root = root$188; + currentUpdateIsNested = nestedUpdateScheduled; + nestedUpdateScheduled = !1; + if (0 !== (executionContext & 6)) + throw Error(formatProdErrorMessage(327)); + flushPassiveEffects(); + var lanes = getNextLanes(root, 0); + if (0 !== (lanes & 3)) { + var exitStatus = renderRootSync(root, lanes); + if (0 !== root.tag && 2 === exitStatus) { + var originallyAttemptedLanes = lanes, + errorRetryLanes = getLanesToRetrySynchronouslyOnError( + root, + originallyAttemptedLanes + ); + 0 !== errorRetryLanes && + ((lanes = errorRetryLanes), + (exitStatus = recoverFromConcurrentError( + root, + originallyAttemptedLanes, + errorRetryLanes + ))); + } + if (1 === exitStatus) + throw ( + ((originallyAttemptedLanes = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended(root, lanes), + ensureRootIsScheduled(root), + originallyAttemptedLanes) + ); + 6 === exitStatus + ? markRootSuspended(root, lanes) + : ((root.finishedWork = root.current.alternate), + (root.finishedLanes = lanes), + commitRoot( + root, + workInProgressRootRecoverableErrors, + workInProgressTransitions + )); + } + ensureRootIsScheduled(root); + } catch (error) { + null === errors ? (errors = [error]) : errors.push(error); + } + root$188 = root$188.next; + } + } while (didPerformSomeWork); + isFlushingWork = !1; + if (null !== errors) { + if (1 < errors.length) { + if ("function" === typeof AggregateError) + throw new AggregateError(errors); + for (onlyLegacy = 1; onlyLegacy < errors.length; onlyLegacy++) + scheduleImmediateTask(throwError.bind(null, errors[onlyLegacy])); + } + throw errors[0]; + } + } +} +function throwError(error) { + throw error; +} +function processRootScheduleInMicrotask() { + mightHavePendingSyncWork = didScheduleMicrotask = !1; + for ( + var currentTime = now$1(), prev = null, root = firstScheduledRoot; + null !== root; + + ) { + var next = root.next, + nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + 0 === nextLanes + ? ((root.next = null), + null === prev ? (firstScheduledRoot = next) : (prev.next = next), + null === next && (lastScheduledRoot = prev)) + : ((prev = root), + 0 !== (nextLanes & 3) && (mightHavePendingSyncWork = !0)); + root = next; + } + flushSyncWorkAcrossRoots_impl(!1); +} +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + for ( + var suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes & -125829121; + 0 < lanes; + + ) { + var index$3 = 31 - clz32(lanes), + lane = 1 << index$3, + expirationTime = expirationTimes[index$3]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$3] = computeExpirationTime(lane, currentTime); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + currentTime = workInProgressRoot; + suspendedLanes = workInProgressRootRenderLanes; + suspendedLanes = getNextLanes( + root, + root === currentTime ? suspendedLanes : 0 + ); + pingedLanes = root.callbackNode; + if ( + 0 === suspendedLanes || + (2 === workInProgressSuspendedReason && root === currentTime) || + (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) + ) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackNode = null), + (root.callbackPriority = 0) + ); + if (0 !== (suspendedLanes & 3)) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackPriority = 2), + (root.callbackNode = null), + 2 + ); + currentTime = suspendedLanes & -suspendedLanes; + if (currentTime === root.callbackPriority) return currentTime; + null !== pingedLanes && cancelCallback$1(pingedLanes); + switch (lanesToEventPriority(suspendedLanes)) { + case 2: + suspendedLanes = ImmediatePriority; + break; + case 8: + suspendedLanes = UserBlockingPriority; + break; + case 32: + suspendedLanes = NormalPriority$1; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority$1; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$3(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} +function scheduleImmediateTask(cb) { + scheduleMicrotask(function () { + 0 !== (executionContext & 6) + ? scheduleCallback$3(ImmediatePriority, cb) + : cb(); + }); +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -9896,29 +10029,29 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { root === rootCommittingMutationOrLayoutEffects && fiber.mode & 2 ) - for (var current = fiber; null !== current; ) { - if (12 === current.tag) { - var _current$memoizedProp = current.memoizedProps, + for (eventTime = fiber; null !== eventTime; ) { + if (12 === eventTime.tag) { + var _current$memoizedProp = eventTime.memoizedProps, id = _current$memoizedProp.id; _current$memoizedProp = _current$memoizedProp.onNestedUpdateScheduled; "function" === typeof _current$memoizedProp && _current$memoizedProp(id); } - current = current.return; + eventTime = eventTime.return; } if ( enableTransitionTracing && - ((current = ReactCurrentBatchConfig$1.transition), - null !== current && - null != current.name && - (-1 === current.startTime && (current.startTime = now$1()), + ((eventTime = ReactCurrentBatchConfig$1.transition), + null !== eventTime && + null != eventTime.name && + (-1 === eventTime.startTime && (eventTime.startTime = now$1()), enableTransitionTracing)) ) { id = root.transitionLanes; _current$memoizedProp = 31 - clz32(lane); var transitions = id[_current$memoizedProp]; null === transitions && (transitions = new Set()); - transitions.add(current); + transitions.add(eventTime); id[_current$memoizedProp] = transitions; } root === workInProgressRoot && @@ -9926,66 +10059,12 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended(root, workInProgressRootRenderLanes)); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); 2 === lane && 0 === executionContext && 0 === (fiber.mode & 1) && ((workInProgressRootRenderTargetTime = now$1() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); - } -} -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; - markStarvedLanesAsExpired(root, currentTime); - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === nextLanes) - null !== existingCallbackNode && cancelCallback$1(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0); - else if (2 === workInProgressSuspendedReason && workInProgressRoot === root) - (root.callbackPriority = 0), (root.callbackNode = null); - else if (null !== root.cancelPendingCommit && 0 === (nextLanes & 42)) - (root.callbackPriority = 0), (root.callbackNode = null); - else if ( - ((currentTime = nextLanes & -nextLanes), - root.callbackPriority !== currentTime) - ) { - null != existingCallbackNode && cancelCallback$1(existingCallbackNode); - if (0 !== (currentTime & 3)) - 0 === root.tag - ? scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)), - scheduleMicrotask(function () { - 0 === (executionContext & 6) && flushSyncCallbacks(); - }), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(nextLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority$1; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority$1; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; + flushSyncWorkAcrossRoots_impl(!0)); } } function performConcurrentWorkOnRoot(root, didTimeout) { @@ -10027,7 +10106,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now$1()), + ensureRootIsScheduled(root), originalCallbackNode) ); if (6 === exitStatus) markRootSuspended(root, lanes); @@ -10058,7 +10137,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now$1()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -10170,10 +10249,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } } - ensureRootIsScheduled(root, now$1()); - return root.callbackNode === originalCallbackNode - ? performConcurrentWorkOnRoot.bind(null, root) - : null; + ensureRootIsScheduled(root); + scheduleTaskForRootDuringMicrotask(root, now$1()); + root = + root.callbackNode === originalCallbackNode + ? performConcurrentWorkOnRoot.bind(null, root) + : null; + return root; } function recoverFromConcurrentError( root, @@ -10281,50 +10363,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - currentUpdateIsNested = nestedUpdateScheduled; - nestedUpdateScheduled = !1; - if (0 !== (executionContext & 6)) throw Error(formatProdErrorMessage(327)); - flushPassiveEffects(); - var lanes = getNextLanes(root, 0); - if (0 === (lanes & 3)) return ensureRootIsScheduled(root, now$1()), null; - var exitStatus = renderRootSync(root, lanes); - if (0 !== root.tag && 2 === exitStatus) { - var originallyAttemptedLanes = lanes, - errorRetryLanes = getLanesToRetrySynchronouslyOnError( - root, - originallyAttemptedLanes - ); - 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError( - root, - originallyAttemptedLanes, - errorRetryLanes - ))); - } - if (1 === exitStatus) - throw ( - ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now$1()), - exitStatus) - ); - if (6 === exitStatus) - return ( - markRootSuspended(root, lanes), ensureRootIsScheduled(root, now$1()), null - ); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - commitRoot( - root, - workInProgressRootRecoverableErrors, - workInProgressTransitions - ); - ensureRootIsScheduled(root, now$1()); - return null; -} function batchedUpdates$1(fn, a) { var prevExecutionContext = executionContext; executionContext |= 1; @@ -10334,7 +10372,7 @@ function batchedUpdates$1(fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now$1() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } } function flushSync$1(fn) { @@ -10357,7 +10395,7 @@ function flushSync$1(fn) { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$1.transition = prevTransition), (executionContext = prevExecutionContext), - 0 === (executionContext & 6) && flushSyncCallbacks(); + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); } } function resetWorkInProgressStack() { @@ -10592,7 +10630,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; memoizedUpdaters.then(lanes, lanes); break a; @@ -10824,10 +10862,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$60 = offscreenQueue.retryQueue; - null === retryQueue$60 + var retryQueue$58 = offscreenQueue.retryQueue; + null === retryQueue$58 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$60.add(wakeable); + : retryQueue$58.add(wakeable); } } break; @@ -11081,7 +11119,7 @@ function commitRootImpl( 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(finishedWork.stateNode, renderPriorityLevel); isDevToolsPresent && root.memoizedUpdaters.clear(); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, finishedWork = 0; @@ -11111,7 +11149,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); enableSchedulingProfiler && markCommitStopped(); if (enableTransitionTracing) { var prevRootTransitionCallbacks = root.transitionCallbacks; @@ -11198,7 +11236,7 @@ function flushPassiveEffectsImpl() { "function" === typeof injectedProfilingHooks.markPassiveEffectsStopped && injectedProfilingHooks.markPassiveEffectsStopped(); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks, prevRootTransitionCallbacks = root.transitionCallbacks, @@ -11231,7 +11269,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = requestEventTime(); null !== rootFiber && (markRootUpdated(rootFiber, 2, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + ensureRootIsScheduled(rootFiber)); } function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) @@ -11268,7 +11306,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -11295,7 +11333,6 @@ function attachPingListener(root, wakeable, lanes) { function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); root.pingedLanes |= root.suspendedLanes & pingedLanes; workInProgressRoot === root && (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && @@ -11306,7 +11343,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { 500 > now$1() - globalMostRecentFallbackTime) ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { 0 === retryLane && @@ -11315,7 +11352,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { boundaryFiber = enqueueConcurrentRenderForLane(boundaryFiber, retryLane); null !== boundaryFiber && (markRootUpdated(boundaryFiber, retryLane, eventTime), - ensureRootIsScheduled(boundaryFiber, eventTime)); + ensureRootIsScheduled(boundaryFiber)); } function retryDehydratedSuspenseBoundary(boundaryFiber) { var suspenseState = boundaryFiber.memoizedState, @@ -11960,7 +11997,7 @@ function restorePendingUpdaters(root, lanes) { }); } function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -12288,6 +12325,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -12410,10 +12448,10 @@ function attemptSynchronousHydration(fiber) { var lanes = getHighestPriorityLanes(root$202.pendingLanes); 0 !== lanes && (markRootEntangled(root$202, lanes | 2), - ensureRootIsScheduled(root$202, now$1()), + ensureRootIsScheduled(root$202), 0 === (executionContext & 6) && ((workInProgressRootRenderTargetTime = now$1() + 500), - flushSyncCallbacks())); + flushSyncWorkAcrossRoots_impl(!1))); } break; case 13: @@ -13532,19 +13570,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$343; + var JSCompiler_inline_result$jscomp$345; if (canUseDOM) { - var isSupported$jscomp$inline_1598 = "oninput" in document; - if (!isSupported$jscomp$inline_1598) { - var element$jscomp$inline_1599 = document.createElement("div"); - element$jscomp$inline_1599.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1598 = - "function" === typeof element$jscomp$inline_1599.oninput; + var isSupported$jscomp$inline_1626 = "oninput" in document; + if (!isSupported$jscomp$inline_1626) { + var element$jscomp$inline_1627 = document.createElement("div"); + element$jscomp$inline_1627.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1626 = + "function" === typeof element$jscomp$inline_1627.oninput; } - JSCompiler_inline_result$jscomp$343 = isSupported$jscomp$inline_1598; - } else JSCompiler_inline_result$jscomp$343 = !1; + JSCompiler_inline_result$jscomp$345 = isSupported$jscomp$inline_1626; + } else JSCompiler_inline_result$jscomp$345 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$343 && + JSCompiler_inline_result$jscomp$345 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13853,20 +13891,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1639 = 0; - i$jscomp$inline_1639 < simpleEventPluginEvents.length; - i$jscomp$inline_1639++ + var i$jscomp$inline_1667 = 0; + i$jscomp$inline_1667 < simpleEventPluginEvents.length; + i$jscomp$inline_1667++ ) { - var eventName$jscomp$inline_1640 = - simpleEventPluginEvents[i$jscomp$inline_1639], - domEventName$jscomp$inline_1641 = - eventName$jscomp$inline_1640.toLowerCase(), - capitalizedEvent$jscomp$inline_1642 = - eventName$jscomp$inline_1640[0].toUpperCase() + - eventName$jscomp$inline_1640.slice(1); + var eventName$jscomp$inline_1668 = + simpleEventPluginEvents[i$jscomp$inline_1667], + domEventName$jscomp$inline_1669 = + eventName$jscomp$inline_1668.toLowerCase(), + capitalizedEvent$jscomp$inline_1670 = + eventName$jscomp$inline_1668[0].toUpperCase() + + eventName$jscomp$inline_1668.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1641, - "on" + capitalizedEvent$jscomp$inline_1642 + domEventName$jscomp$inline_1669, + "on" + capitalizedEvent$jscomp$inline_1670 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -16210,10 +16248,10 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1819 = { +var devToolsConfig$jscomp$inline_1847 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-3e7718a8", + version: "18.3.0-www-modern-7959f3f4", rendererPackageName: "react-dom" }; (function (internals) { @@ -16231,10 +16269,10 @@ var devToolsConfig$jscomp$inline_1819 = { } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1819.bundleType, - version: devToolsConfig$jscomp$inline_1819.version, - rendererPackageName: devToolsConfig$jscomp$inline_1819.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1819.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1847.bundleType, + version: devToolsConfig$jscomp$inline_1847.version, + rendererPackageName: devToolsConfig$jscomp$inline_1847.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1847.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -16251,14 +16289,14 @@ var devToolsConfig$jscomp$inline_1819 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1819.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1847.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-3e7718a8" + reconcilerVersion: "18.3.0-www-modern-7959f3f4" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; exports.createPortal = function (children, container) { @@ -16347,7 +16385,7 @@ exports.hydrateRoot = function (container, initialChildren, options) { enqueueUpdate(options, concurrentUpdatesByDefaultOverride, isStrictMode); initialChildren.current.lanes = isStrictMode; markRootUpdated(initialChildren, isStrictMode, identifierPrefix); - ensureRootIsScheduled(initialChildren, identifierPrefix); + ensureRootIsScheduled(initialChildren); container[internalContainerInstanceKey] = initialChildren.current; Dispatcher.current = ReactDOMClientDispatcher; listenToAllSupportedEvents(container); @@ -16414,7 +16452,7 @@ exports.unstable_createEventHandle = function (type, options) { return eventHandle; }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-modern-3e7718a8"; +exports.version = "18.3.0-www-modern-7959f3f4"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOMServer-dev.classic.js b/compiled/facebook-www/ReactDOMServer-dev.classic.js index c2c1af8904..6faebb23d4 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.classic.js +++ b/compiled/facebook-www/ReactDOMServer-dev.classic.js @@ -19,7 +19,7 @@ if (__DEV__) { var React = require("react"); var ReactDOM = require("react-dom"); -var ReactVersion = "18.3.0-www-classic-c522cd08"; +var ReactVersion = "18.3.0-www-classic-81d2f28c"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -234,7 +234,8 @@ var dynamicFeatureFlags = require("ReactFeatureFlags"); var enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = - dynamicFeatureFlags.enableCustomElementPropertySupport; // On WWW, false is used for a new modern build. + dynamicFeatureFlags.enableCustomElementPropertySupport; +// On WWW, false is used for a new modern build. var enableFloat = true; // $FlowFixMe[method-unbinding] diff --git a/compiled/facebook-www/ReactDOMServer-dev.modern.js b/compiled/facebook-www/ReactDOMServer-dev.modern.js index cae439ab22..c17cb6b64d 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServer-dev.modern.js @@ -19,7 +19,7 @@ if (__DEV__) { var React = require("react"); var ReactDOM = require("react-dom"); -var ReactVersion = "18.3.0-www-modern-518590c9"; +var ReactVersion = "18.3.0-www-modern-4e6bdd84"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -234,7 +234,8 @@ var dynamicFeatureFlags = require("ReactFeatureFlags"); var enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = - dynamicFeatureFlags.enableCustomElementPropertySupport; // On WWW, true is used for a new modern build. + dynamicFeatureFlags.enableCustomElementPropertySupport; +// On WWW, true is used for a new modern build. var enableFloat = true; // $FlowFixMe[method-unbinding] diff --git a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js index 05203ede01..551189f46f 100644 --- a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js @@ -231,7 +231,8 @@ var dynamicFeatureFlags = require("ReactFeatureFlags"); var enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = - dynamicFeatureFlags.enableCustomElementPropertySupport; // On WWW, true is used for a new modern build. + dynamicFeatureFlags.enableCustomElementPropertySupport; +// On WWW, true is used for a new modern build. var enableFloat = true; // $FlowFixMe[method-unbinding] diff --git a/compiled/facebook-www/ReactDOMTesting-dev.classic.js b/compiled/facebook-www/ReactDOMTesting-dev.classic.js index 251879c796..251d445b08 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.classic.js @@ -130,7 +130,9 @@ var disableInputAttributeSyncing = enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane, enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = - dynamicFeatureFlags.enableCustomElementPropertySupport; // On WWW, false is used for a new modern build. + dynamicFeatureFlags.enableCustomElementPropertySupport, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask; // On WWW, false is used for a new modern build. var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableProfilerNestedUpdatePhase = true; @@ -1093,7 +1095,7 @@ function popHostContext(fiber) { } // This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback; +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback; var cancelCallback$1 = Scheduler.unstable_cancelCallback; var shouldYield = Scheduler.unstable_shouldYield; var requestPaint = Scheduler.unstable_requestPaint; @@ -9010,102 +9012,6 @@ function is(x, y) { var objectIs = typeof Object.is === "function" ? Object.is : is; // $FlowFixMe[method-unbinding] -var syncQueue = null; -var includesLegacySyncCallbacks = false; -var isFlushingSyncQueue = false; -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]; - } 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 scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = true; - scheduleSyncCallback(callback); -} -function flushSyncCallbacksOnlyInLegacyMode() { - // Only flushes the queue if there's a legacy sync callback scheduled. - // TODO: There's only a single type of callback: performSyncOnWorkOnRoot. So - // it might make more sense for the queue to be a list of roots instead of a - // list of generic callbacks. Then we can have two: one for legacy roots, one - // for concurrent roots. And this method would only flush the legacy ones. - if (includesLegacySyncCallbacks) { - flushSyncCallbacks(); - } -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrance. - isFlushingSyncQueue = true; // Set the event priority to discrete - // TODO: Is this necessary anymore? The only user code that runs in this - // queue is in the render or commit phases, which already set the - // event priority. Should be able to remove. - - var previousUpdatePriority = getCurrentUpdatePriority(); - setCurrentUpdatePriority(DiscreteEventPriority); - var errors = null; - var queue = syncQueue; // $FlowFixMe[incompatible-use] found when upgrading Flow - - for (var i = 0; i < queue.length; i++) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - var callback = queue[i]; - - try { - do { - var isSync = true; // $FlowFixMe[incompatible-type] we bail out when we get a null - - callback = callback(isSync); - } while (callback !== null); - } catch (error) { - // Collect errors so we can rethrow them at the end - if (errors === null) { - errors = [error]; - } else { - errors.push(error); - } - } - } - - syncQueue = null; - includesLegacySyncCallbacks = false; - setCurrentUpdatePriority(previousUpdatePriority); - isFlushingSyncQueue = false; - - if (errors !== null) { - if (errors.length > 1) { - if (typeof AggregateError === "function") { - // eslint-disable-next-line no-undef - throw new AggregateError(errors); - } else { - for (var _i = 1; _i < errors.length; _i++) { - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[_i]) - ); - } - - var firstError = errors[0]; - throw firstError; - } - } else { - var error = errors[0]; - throw error; - } - } - } - - return null; -} - -function throwError(error) { - throw error; -} - var nativeConsole = console; var nativeConsoleLog = null; var pendingGroupArgs = []; @@ -11494,7 +11400,7 @@ var ReactStrictModeWarnings = { }; } -var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we +var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we // detect this is caught by userspace, we'll log a warning in development. var SuspenseException = new Error( @@ -11530,8 +11436,8 @@ function isThenableResolved(thenable) { function noop$1() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactCurrentActQueue$2.current !== null) { - ReactCurrentActQueue$2.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var previous = thenableState[index]; @@ -23667,7 +23573,7 @@ var AbortControllerLocal = }; // Intentionally not named imports because Rollup would // use dynamic dispatch for CommonJS interop named imports. -var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority; var CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -23723,7 +23629,7 @@ function releaseCache(cache) { } if (cache.refCount === 0) { - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -30717,7 +30623,7 @@ function observeVisibleRects(hostRoot, selectors, callback, options) { }; } -var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; +var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -30742,7 +30648,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -30773,6 +30679,394 @@ function schedulePostPaintCallback(callback) { } } +var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, +// there's only a single root, but we do support multi root apps, hence this +// extra complexity. But this module is optimized for the single root case. + +var firstScheduledRoot = null; +var lastScheduledRoot = null; // Used to prevent redundant mircotasks from being scheduled. + +var didScheduleMicrotask = false; // `act` "microtasks" are scheduled on the `act` queue instead of an actual +// microtask, so we have to dedupe those separately. This wouldn't be an issue +// if we required all `act` calls to be awaited, which we might in the future. + +var didScheduleMicrotask_act = false; // Used to quickly bail out of flushSync if there's no sync work to do. + +var mightHavePendingSyncWork = false; +var isFlushingWork = false; +function ensureRootIsScheduled(root) { + // This function is called whenever a root receives an update. It does two + // things 1) it ensures the root is in the root schedule, and 2) it ensures + // there's a pending microtask to process the root schedule. + // + // Most of the actual scheduling logic does not happen until + // `scheduleTaskForRootDuringMicrotask` runs. + // Add the root to the schedule + if (root === lastScheduledRoot || root.next !== null); + else { + if (lastScheduledRoot === null) { + firstScheduledRoot = lastScheduledRoot = root; + } else { + lastScheduledRoot.next = root; + lastScheduledRoot = root; + } + } // Any time a root received an update, we set this to true until the next time + // we process the schedule. If it's false, then we can quickly exit flushSync + // without consulting the schedule. + + mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure + // there's a task scheduled for each one at the correct priority. + + if (ReactCurrentActQueue$1.current !== null) { + // We're inside an `act` scope. + if (!didScheduleMicrotask_act) { + didScheduleMicrotask_act = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } else { + if (!didScheduleMicrotask) { + didScheduleMicrotask = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } + + if (!enableDeferRootSchedulingToMicrotask) { + // While this flag is disabled, we schedule the render task immediately + // instead of waiting a microtask. + // TODO: We need to land enableDeferRootSchedulingToMicrotask ASAP to + // unblock additional features we have planned. + scheduleTaskForRootDuringMicrotask(root, now$1()); + } +} +function flushSyncWorkOnAllRoots() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(false); +} +function flushSyncWorkOnLegacyRootsOnly() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(true); +} + +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (isFlushingWork) { + // Prevent reentrancy. + // TODO: Is this overly defensive? The callers must check the execution + // context first regardless. + return; + } + + if (!mightHavePendingSyncWork) { + // Fast path. There's no sync work to do. + return; + } + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); // There may or may not be synchronous work scheduled. Let's check. + + var didPerformSomeWork; + var errors = null; + isFlushingWork = true; + + do { + didPerformSomeWork = false; + var root = firstScheduledRoot; + + while (root !== null) { + if (onlyLegacy && root.tag !== LegacyRoot); + else { + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + + if (includesSyncLane(nextLanes)) { + // This root has pending sync work. Flush it now. + try { + // TODO: Pass nextLanes as an argument instead of computing it again + // inside performSyncWorkOnRoot. + didPerformSomeWork = true; + performSyncWorkOnRoot(root); + } catch (error) { + // Collect errors so we can rethrow them at the end + if (errors === null) { + errors = [error]; + } else { + errors.push(error); + } + } + } + } + + root = root.next; + } + } while (didPerformSomeWork); + + isFlushingWork = false; // If any errors were thrown, rethrow them right before exiting. + // TODO: Consider returning these to the caller, to allow them to decide + // how/when to rethrow. + + if (errors !== null) { + if (errors.length > 1) { + if (typeof AggregateError === "function") { + // eslint-disable-next-line no-undef + throw new AggregateError(errors); + } else { + for (var i = 1; i < errors.length; i++) { + scheduleImmediateTask(throwError.bind(null, errors[i])); + } + + var firstError = errors[0]; + throw firstError; + } + } else { + var error = errors[0]; + throw error; + } + } +} + +function throwError(error) { + throw error; +} + +function processRootScheduleInMicrotask() { + // This function is always called inside a microtask. It should never be + // called synchronously. + didScheduleMicrotask = false; + + { + didScheduleMicrotask_act = false; + } // We'll recompute this as we iterate through all the roots and schedule them. + + mightHavePendingSyncWork = false; + var currentTime = now$1(); + var prev = null; + var root = firstScheduledRoot; + + while (root !== null) { + var next = root.next; + var nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + + if (nextLanes === NoLane) { + // This root has no more pending work. Remove it from the schedule. To + // guard against subtle reentrancy bugs, this microtask is the only place + // we do this — you can add roots to the schedule whenever, but you can + // only remove them here. + // Null this out so we know it's been removed from the schedule. + root.next = null; + + if (prev === null) { + // This is the new head of the list + firstScheduledRoot = next; + } else { + prev.next = next; + } + + if (next === null) { + // This is the new tail of the list + lastScheduledRoot = prev; + } + } else { + // This root still has work. Keep it in the list. + prev = root; + + if (includesSyncLane(nextLanes)) { + mightHavePendingSyncWork = true; + } + } + + root = next; + } // At the end of the microtask, flush any pending synchronous work. This has + // to come at the end, because it does actual rendering work that might throw. + + flushSyncWorkOnAllRoots(); +} + +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + // This function is always called inside a microtask, or at the very end of a + // rendering task right before we yield to the main thread. It should never be + // called synchronously. + // + // TODO: Unless enableDeferRootSchedulingToMicrotask is off. We need to land + // that ASAP to unblock additional features we have planned. + // + // This function also never performs React work synchronously; it should + // only schedule work to be performed later, in a separate task or microtask. + // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + var existingCallbackNode = root.callbackNode; + + if ( + nextLanes === NoLanes || // If this root is currently suspended and waiting for data to resolve, don't + // schedule a task to render it. We'll either wait for a ping, or wait to + // receive an update. + (isWorkLoopSuspendedOnData() && root === workInProgressRoot) || // We should only interrupt a pending commit if the new update + // is urgent. + (root.cancelPendingCommit !== null && includesOnlyNonUrgentLanes(nextLanes)) + ) { + // Fast path: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackNode = null; + root.callbackPriority = NoLane; + return NoLane; + } // Schedule a new callback in the host environment. + + if (includesSyncLane(nextLanes)) { + // Synchronous work is always flushed at the end of the microtask, so we + // don't need to schedule an additional task. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackPriority = SyncLane; + root.callbackNode = null; + return SyncLane; + } else { + // We use the highest priority lane to represent the priority of the callback. + var existingCallbackPriority = root.callbackPriority; + var newCallbackPriority = getHighestPriorityLane(nextLanes); + + if ( + newCallbackPriority === existingCallbackPriority && // Special case related to `act`. If the currently scheduled task is a + // Scheduler task, rather than an `act` task, cancel it and re-schedule + // on the `act` queue. + !( + ReactCurrentActQueue$1.current !== null && + existingCallbackNode !== fakeActCallbackNode$1 + ) + ) { + // The priority hasn't changed. We can reuse the existing task. + return newCallbackPriority; + } else { + // Cancel the existing callback. We'll schedule a new one below. + cancelCallback(existingCallbackNode); + } + + var schedulerPriorityLevel; + + switch (lanesToEventPriority(nextLanes)) { + case DiscreteEventPriority: + schedulerPriorityLevel = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriorityLevel = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriorityLevel = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority$1; + break; + } + + var newCallbackNode = scheduleCallback$1( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) + ); + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; + return newCallbackPriority; + } +} + +function getContinuationForRoot(root, originalCallbackNode) { + // This is called at the end of `performConcurrentWorkOnRoot` to determine + // if we need to schedule a continuation task. + // + // Usually `scheduleTaskForRootDuringMicrotask` only runs inside a microtask; + // however, since most of the logic for determining if we need a continuation + // versus a new task is the same, we cheat a bit and call it here. This is + // only safe to do because we know we're at the end of the browser task. + // So although it's not an actual microtask, it might as well be. + scheduleTaskForRootDuringMicrotask(root, now$1()); + + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } + + return null; +} +var fakeActCallbackNode$1 = {}; + +function scheduleCallback$1(priorityLevel, callback) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: We're inside an `act` scope (a testing utility). + // Instead of scheduling work in the host environment, add it to a + // fake internal queue that's managed by the `act` implementation. + ReactCurrentActQueue$1.current.push(callback); + return fakeActCallbackNode$1; + } else { + return scheduleCallback$3(priorityLevel, callback); + } +} + +function cancelCallback(callbackNode) { + if (callbackNode === fakeActCallbackNode$1); + else if (callbackNode !== null) { + cancelCallback$1(callbackNode); + } +} + +function scheduleImmediateTask(cb) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: Inside an `act` scope, we push microtasks to the fake `act` + // callback queue. This is because we currently support calling `act` + // without awaiting the result. The plan is to deprecate that, and require + // that you always await the result so that the microtasks have a chance to + // run. But it hasn't happened yet. + ReactCurrentActQueue$1.current.push(function () { + cb(); + return null; + }); + } // TODO: Can we land supportsMicrotasks? Which environments don't support it? + // Alternatively, can we move this check to the host config? + + { + scheduleMicrotask(function () { + // In Safari, appending an iframe forces microtasks to run. + // https://github.com/facebook/react/issues/22459 + // We don't support running callbacks in the middle of render + // or commit so we need to check against that. + var executionContext = getExecutionContext(); + + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + // Note that this would still prematurely flush the callbacks + // if this happens outside render or commit phase (e.g. in an event). + // Intentionally using a macrotask instead of a microtask here. This is + // wrong semantically but it prevents an infinite loop. The bug is + // Safari's, not ours, so we just do our best to not crash even though + // the behavior isn't completely correct. + scheduleCallback$3(ImmediatePriority, cb); + return; + } + + cb(); + }); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -31051,6 +31345,9 @@ function getWorkInProgressRoot() { function getWorkInProgressRootRenderLanes() { return workInProgressRootRenderLanes; } +function isWorkLoopSuspendedOnData() { + return workInProgressSuspendedReason === SuspendedOnData; +} function requestEventTime() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. @@ -31254,21 +31551,25 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); if ( lane === SyncLane && executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue.isBatchingLegacy + (fiber.mode & ConcurrentMode) === NoMode ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + if (ReactCurrentActQueue.isBatchingLegacy) { + // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } else { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncWorkOnLegacyRootsOnly(); + } } } } @@ -31285,173 +31586,12 @@ function scheduleInitialHydrationOnRoot(root, lane, eventTime) { var current = root.current; current.lanes = lane; markRootUpdated(root, lane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function isUnsafeClassRenderPhaseUpdate(fiber) { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return (executionContext & RenderContext) !== NoContext; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. - -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. - - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. - - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. - if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); - } - - root.callbackNode = null; - root.callbackPriority = NoLane; - return; - } // If this root is currently suspended and waiting for data to resolve, don't - // schedule a task to render it. We'll either wait for a ping, or wait to - // receive an update. - - if ( - workInProgressSuspendedReason === SuspendedOnData && - workInProgressRoot === root - ) { - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - - var cancelPendingCommit = root.cancelPendingCommit; - - if (cancelPendingCommit !== null) { - // We should only interrupt a pending commit if the new update - // is urgent. - if (includesOnlyNonUrgentLanes(nextLanes)) { - // The new update is not urgent. Don't interrupt the pending commit. - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - } // We use the highest priority lane to represent the priority of the callback. - - var newCallbackPriority = getHighestPriorityLane(nextLanes); // Check if there's an existing task. We may be able to reuse it. - - var existingCallbackPriority = root.callbackPriority; - - if ( - existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a - // Scheduler task, rather than an `act` task, cancel it and re-scheduled - // on the `act` queue. - !( - ReactCurrentActQueue.current !== null && - existingCallbackNode !== fakeActCallbackNode - ) - ) { - { - // 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 && - !includesSyncLane(existingCallbackPriority) - ) { - 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. - - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. - cancelCallback(existingCallbackNode); - } // Schedule a new callback. - - var newCallbackNode; - - if (includesSyncLane(newCallbackPriority)) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue.isBatchingLegacy !== null) { - ReactCurrentActQueue.didScheduleLegacyUpdate = true; - } - - scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } - - { - // Flush the queue in a microtask. - if (ReactCurrentActQueue.current !== null) { - // Inside `act`, use our internal `act` queue so that these get flushed - // at the end of the current scope even when using the sync version - // of `act`. - ReactCurrentActQueue.current.push(flushSyncCallbacks); - } else { - scheduleMicrotask(function () { - // In Safari, appending an iframe forces microtasks to run. - // https://github.com/facebook/react/issues/22459 - // We don't support running callbacks in the middle of render - // or commit so we need to check against that. - if ( - (executionContext & (RenderContext | CommitContext)) === - NoContext - ) { - // Note that this would still prematurely flush the callbacks - // if this happens outside render or commit phase (e.g. in an event). - flushSyncCallbacks(); - } - }); - } - } - - newCallbackNode = null; - } else { - var schedulerPriorityLevel; - - switch (lanesToEventPriority(nextLanes)) { - case DiscreteEventPriority: - schedulerPriorityLevel = ImmediatePriority; - break; - - case ContinuousEventPriority: - schedulerPriorityLevel = UserBlockingPriority; - break; - - case DefaultEventPriority: - schedulerPriorityLevel = NormalPriority$1; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority$1; - break; - } - - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. @@ -31483,6 +31623,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } // Determine the next lanes to work on, using the fields stored // on the root. + // TODO: This was already computed in the caller. Pass it as an argument. var lanes = getNextLanes( root, @@ -31533,7 +31674,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -31583,7 +31724,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var _fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw _fatalError; } // FIXME: Need to check for RootDidNotComplete again. The factoring here // isn't ideal. @@ -31596,15 +31737,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } - ensureRootIsScheduled(root, now$1()); - - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); - } - - return null; + ensureRootIsScheduled(root); + return getContinuationForRoot(root, originalCallbackNode); } function recoverFromConcurrentError( @@ -31965,12 +32099,13 @@ function performSyncWorkOnRoot(root) { throw new Error("Should not already be working."); } - flushPassiveEffects(); + flushPassiveEffects(); // TODO: This was already computed in the caller. Pass it as an argument. + var lanes = getNextLanes(root, NoLanes); if (!includesSyncLane(lanes)) { // There's no remaining sync work left. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } @@ -32001,7 +32136,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -32010,7 +32145,7 @@ function performSyncWorkOnRoot(root) { // cases where need to exit the current render without producing a // consistent tree or committing. markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -32025,18 +32160,20 @@ function performSyncWorkOnRoot(root) { ); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } - function flushRoot(root, lanes) { if (lanes !== NoLanes) { markRootEntangled(root, mergeLanes(lanes, SyncLane)); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - resetRenderTimer(); - flushSyncCallbacks(); + resetRenderTimer(); // TODO: For historical reasons this flushes all sync work across all + // roots. It shouldn't really matter either way, but we could change this + // to only flush the given root. + + flushSyncWorkOnAllRoots(); } } } @@ -32058,7 +32195,7 @@ function batchedUpdates$1(fn, a) { !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + flushSyncWorkOnLegacyRootsOnly(); } } } @@ -32100,7 +32237,7 @@ function flushSync$1(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -32658,7 +32795,7 @@ function renderRootConcurrent(root, lanes) { // currently working on a different root, so that we resume // rendering later. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; thenable.then(onResolution, onResolution); @@ -33485,7 +33622,7 @@ function commitRootImpl( } // Always call this before exiting `commitRoot`, to ensure that any // additional work on this root is scheduled. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without @@ -33538,7 +33675,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { if (enableDebugTracing) { @@ -33738,7 +33875,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks; @@ -33822,7 +33959,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -33861,7 +33998,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -33937,7 +34074,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -33973,7 +34109,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -33992,7 +34128,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -34380,19 +34516,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } } } -function cancelCallback(callbackNode) { - if (callbackNode === fakeActCallbackNode) { - return; - } // In production, always call Scheduler. This function will be stripped out. - - return cancelCallback$1(callbackNode); -} - function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. return ReactCurrentActQueue.current !== null; @@ -35668,6 +35796,7 @@ function FiberRootNode( this.cancelPendingCommit = null; this.context = null; this.pendingContext = null; + this.next = null; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); @@ -35801,7 +35930,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-6b57d67b"; +var ReactVersion = "18.3.0-www-classic-2f1dd864"; function createPortal$1( children, diff --git a/compiled/facebook-www/ReactDOMTesting-dev.modern.js b/compiled/facebook-www/ReactDOMTesting-dev.modern.js index b9ec6b4c2c..a8831b6f54 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.modern.js @@ -247,7 +247,9 @@ var disableInputAttributeSyncing = enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane, enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = - dynamicFeatureFlags.enableCustomElementPropertySupport; // On WWW, true is used for a new modern build. + dynamicFeatureFlags.enableCustomElementPropertySupport, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask; // On WWW, true is used for a new modern build. var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableProfilerNestedUpdatePhase = true; @@ -395,7 +397,7 @@ var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; // This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback; +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback; var cancelCallback$1 = Scheduler.unstable_cancelCallback; var shouldYield = Scheduler.unstable_shouldYield; var requestPaint = Scheduler.unstable_requestPaint; @@ -7510,102 +7512,6 @@ function is(x, y) { var objectIs = typeof Object.is === "function" ? Object.is : is; // $FlowFixMe[method-unbinding] -var syncQueue = null; -var includesLegacySyncCallbacks = false; -var isFlushingSyncQueue = false; -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]; - } 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 scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = true; - scheduleSyncCallback(callback); -} -function flushSyncCallbacksOnlyInLegacyMode() { - // Only flushes the queue if there's a legacy sync callback scheduled. - // TODO: There's only a single type of callback: performSyncOnWorkOnRoot. So - // it might make more sense for the queue to be a list of roots instead of a - // list of generic callbacks. Then we can have two: one for legacy roots, one - // for concurrent roots. And this method would only flush the legacy ones. - if (includesLegacySyncCallbacks) { - flushSyncCallbacks(); - } -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrance. - isFlushingSyncQueue = true; // Set the event priority to discrete - // TODO: Is this necessary anymore? The only user code that runs in this - // queue is in the render or commit phases, which already set the - // event priority. Should be able to remove. - - var previousUpdatePriority = getCurrentUpdatePriority(); - setCurrentUpdatePriority(DiscreteEventPriority); - var errors = null; - var queue = syncQueue; // $FlowFixMe[incompatible-use] found when upgrading Flow - - for (var i = 0; i < queue.length; i++) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - var callback = queue[i]; - - try { - do { - var isSync = true; // $FlowFixMe[incompatible-type] we bail out when we get a null - - callback = callback(isSync); - } while (callback !== null); - } catch (error) { - // Collect errors so we can rethrow them at the end - if (errors === null) { - errors = [error]; - } else { - errors.push(error); - } - } - } - - syncQueue = null; - includesLegacySyncCallbacks = false; - setCurrentUpdatePriority(previousUpdatePriority); - isFlushingSyncQueue = false; - - if (errors !== null) { - if (errors.length > 1) { - if (typeof AggregateError === "function") { - // eslint-disable-next-line no-undef - throw new AggregateError(errors); - } else { - for (var _i = 1; _i < errors.length; _i++) { - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[_i]) - ); - } - - var firstError = errors[0]; - throw firstError; - } - } else { - var error = errors[0]; - throw error; - } - } - } - - return null; -} - -function throwError(error) { - throw error; -} - var nativeConsole = console; var nativeConsoleLog = null; var pendingGroupArgs = []; @@ -9994,7 +9900,7 @@ var ReactStrictModeWarnings = { }; } -var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we +var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we // detect this is caught by userspace, we'll log a warning in development. var SuspenseException = new Error( @@ -10030,8 +9936,8 @@ function isThenableResolved(thenable) { function noop$2() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactCurrentActQueue$2.current !== null) { - ReactCurrentActQueue$2.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var previous = thenableState[index]; @@ -22100,7 +22006,7 @@ var AbortControllerLocal = }; // Intentionally not named imports because Rollup would // use dynamic dispatch for CommonJS interop named imports. -var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority; var CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -22156,7 +22062,7 @@ function releaseCache(cache) { } if (cache.refCount === 0) { - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -29121,7 +29027,7 @@ function observeVisibleRects(hostRoot, selectors, callback, options) { }; } -var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; +var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -29146,7 +29052,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -29177,6 +29083,394 @@ function schedulePostPaintCallback(callback) { } } +var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, +// there's only a single root, but we do support multi root apps, hence this +// extra complexity. But this module is optimized for the single root case. + +var firstScheduledRoot = null; +var lastScheduledRoot = null; // Used to prevent redundant mircotasks from being scheduled. + +var didScheduleMicrotask = false; // `act` "microtasks" are scheduled on the `act` queue instead of an actual +// microtask, so we have to dedupe those separately. This wouldn't be an issue +// if we required all `act` calls to be awaited, which we might in the future. + +var didScheduleMicrotask_act = false; // Used to quickly bail out of flushSync if there's no sync work to do. + +var mightHavePendingSyncWork = false; +var isFlushingWork = false; +function ensureRootIsScheduled(root) { + // This function is called whenever a root receives an update. It does two + // things 1) it ensures the root is in the root schedule, and 2) it ensures + // there's a pending microtask to process the root schedule. + // + // Most of the actual scheduling logic does not happen until + // `scheduleTaskForRootDuringMicrotask` runs. + // Add the root to the schedule + if (root === lastScheduledRoot || root.next !== null); + else { + if (lastScheduledRoot === null) { + firstScheduledRoot = lastScheduledRoot = root; + } else { + lastScheduledRoot.next = root; + lastScheduledRoot = root; + } + } // Any time a root received an update, we set this to true until the next time + // we process the schedule. If it's false, then we can quickly exit flushSync + // without consulting the schedule. + + mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure + // there's a task scheduled for each one at the correct priority. + + if (ReactCurrentActQueue$1.current !== null) { + // We're inside an `act` scope. + if (!didScheduleMicrotask_act) { + didScheduleMicrotask_act = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } else { + if (!didScheduleMicrotask) { + didScheduleMicrotask = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } + + if (!enableDeferRootSchedulingToMicrotask) { + // While this flag is disabled, we schedule the render task immediately + // instead of waiting a microtask. + // TODO: We need to land enableDeferRootSchedulingToMicrotask ASAP to + // unblock additional features we have planned. + scheduleTaskForRootDuringMicrotask(root, now$1()); + } +} +function flushSyncWorkOnAllRoots() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(false); +} +function flushSyncWorkOnLegacyRootsOnly() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(true); +} + +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (isFlushingWork) { + // Prevent reentrancy. + // TODO: Is this overly defensive? The callers must check the execution + // context first regardless. + return; + } + + if (!mightHavePendingSyncWork) { + // Fast path. There's no sync work to do. + return; + } + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); // There may or may not be synchronous work scheduled. Let's check. + + var didPerformSomeWork; + var errors = null; + isFlushingWork = true; + + do { + didPerformSomeWork = false; + var root = firstScheduledRoot; + + while (root !== null) { + if (onlyLegacy && root.tag !== LegacyRoot); + else { + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + + if (includesSyncLane(nextLanes)) { + // This root has pending sync work. Flush it now. + try { + // TODO: Pass nextLanes as an argument instead of computing it again + // inside performSyncWorkOnRoot. + didPerformSomeWork = true; + performSyncWorkOnRoot(root); + } catch (error) { + // Collect errors so we can rethrow them at the end + if (errors === null) { + errors = [error]; + } else { + errors.push(error); + } + } + } + } + + root = root.next; + } + } while (didPerformSomeWork); + + isFlushingWork = false; // If any errors were thrown, rethrow them right before exiting. + // TODO: Consider returning these to the caller, to allow them to decide + // how/when to rethrow. + + if (errors !== null) { + if (errors.length > 1) { + if (typeof AggregateError === "function") { + // eslint-disable-next-line no-undef + throw new AggregateError(errors); + } else { + for (var i = 1; i < errors.length; i++) { + scheduleImmediateTask(throwError.bind(null, errors[i])); + } + + var firstError = errors[0]; + throw firstError; + } + } else { + var error = errors[0]; + throw error; + } + } +} + +function throwError(error) { + throw error; +} + +function processRootScheduleInMicrotask() { + // This function is always called inside a microtask. It should never be + // called synchronously. + didScheduleMicrotask = false; + + { + didScheduleMicrotask_act = false; + } // We'll recompute this as we iterate through all the roots and schedule them. + + mightHavePendingSyncWork = false; + var currentTime = now$1(); + var prev = null; + var root = firstScheduledRoot; + + while (root !== null) { + var next = root.next; + var nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + + if (nextLanes === NoLane) { + // This root has no more pending work. Remove it from the schedule. To + // guard against subtle reentrancy bugs, this microtask is the only place + // we do this — you can add roots to the schedule whenever, but you can + // only remove them here. + // Null this out so we know it's been removed from the schedule. + root.next = null; + + if (prev === null) { + // This is the new head of the list + firstScheduledRoot = next; + } else { + prev.next = next; + } + + if (next === null) { + // This is the new tail of the list + lastScheduledRoot = prev; + } + } else { + // This root still has work. Keep it in the list. + prev = root; + + if (includesSyncLane(nextLanes)) { + mightHavePendingSyncWork = true; + } + } + + root = next; + } // At the end of the microtask, flush any pending synchronous work. This has + // to come at the end, because it does actual rendering work that might throw. + + flushSyncWorkOnAllRoots(); +} + +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + // This function is always called inside a microtask, or at the very end of a + // rendering task right before we yield to the main thread. It should never be + // called synchronously. + // + // TODO: Unless enableDeferRootSchedulingToMicrotask is off. We need to land + // that ASAP to unblock additional features we have planned. + // + // This function also never performs React work synchronously; it should + // only schedule work to be performed later, in a separate task or microtask. + // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + var existingCallbackNode = root.callbackNode; + + if ( + nextLanes === NoLanes || // If this root is currently suspended and waiting for data to resolve, don't + // schedule a task to render it. We'll either wait for a ping, or wait to + // receive an update. + (isWorkLoopSuspendedOnData() && root === workInProgressRoot) || // We should only interrupt a pending commit if the new update + // is urgent. + (root.cancelPendingCommit !== null && includesOnlyNonUrgentLanes(nextLanes)) + ) { + // Fast path: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackNode = null; + root.callbackPriority = NoLane; + return NoLane; + } // Schedule a new callback in the host environment. + + if (includesSyncLane(nextLanes)) { + // Synchronous work is always flushed at the end of the microtask, so we + // don't need to schedule an additional task. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackPriority = SyncLane; + root.callbackNode = null; + return SyncLane; + } else { + // We use the highest priority lane to represent the priority of the callback. + var existingCallbackPriority = root.callbackPriority; + var newCallbackPriority = getHighestPriorityLane(nextLanes); + + if ( + newCallbackPriority === existingCallbackPriority && // Special case related to `act`. If the currently scheduled task is a + // Scheduler task, rather than an `act` task, cancel it and re-schedule + // on the `act` queue. + !( + ReactCurrentActQueue$1.current !== null && + existingCallbackNode !== fakeActCallbackNode$1 + ) + ) { + // The priority hasn't changed. We can reuse the existing task. + return newCallbackPriority; + } else { + // Cancel the existing callback. We'll schedule a new one below. + cancelCallback(existingCallbackNode); + } + + var schedulerPriorityLevel; + + switch (lanesToEventPriority(nextLanes)) { + case DiscreteEventPriority: + schedulerPriorityLevel = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriorityLevel = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriorityLevel = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority$1; + break; + } + + var newCallbackNode = scheduleCallback$1( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) + ); + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; + return newCallbackPriority; + } +} + +function getContinuationForRoot(root, originalCallbackNode) { + // This is called at the end of `performConcurrentWorkOnRoot` to determine + // if we need to schedule a continuation task. + // + // Usually `scheduleTaskForRootDuringMicrotask` only runs inside a microtask; + // however, since most of the logic for determining if we need a continuation + // versus a new task is the same, we cheat a bit and call it here. This is + // only safe to do because we know we're at the end of the browser task. + // So although it's not an actual microtask, it might as well be. + scheduleTaskForRootDuringMicrotask(root, now$1()); + + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } + + return null; +} +var fakeActCallbackNode$1 = {}; + +function scheduleCallback$1(priorityLevel, callback) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: We're inside an `act` scope (a testing utility). + // Instead of scheduling work in the host environment, add it to a + // fake internal queue that's managed by the `act` implementation. + ReactCurrentActQueue$1.current.push(callback); + return fakeActCallbackNode$1; + } else { + return scheduleCallback$3(priorityLevel, callback); + } +} + +function cancelCallback(callbackNode) { + if (callbackNode === fakeActCallbackNode$1); + else if (callbackNode !== null) { + cancelCallback$1(callbackNode); + } +} + +function scheduleImmediateTask(cb) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: Inside an `act` scope, we push microtasks to the fake `act` + // callback queue. This is because we currently support calling `act` + // without awaiting the result. The plan is to deprecate that, and require + // that you always await the result so that the microtasks have a chance to + // run. But it hasn't happened yet. + ReactCurrentActQueue$1.current.push(function () { + cb(); + return null; + }); + } // TODO: Can we land supportsMicrotasks? Which environments don't support it? + // Alternatively, can we move this check to the host config? + + { + scheduleMicrotask(function () { + // In Safari, appending an iframe forces microtasks to run. + // https://github.com/facebook/react/issues/22459 + // We don't support running callbacks in the middle of render + // or commit so we need to check against that. + var executionContext = getExecutionContext(); + + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + // Note that this would still prematurely flush the callbacks + // if this happens outside render or commit phase (e.g. in an event). + // Intentionally using a macrotask instead of a microtask here. This is + // wrong semantically but it prevents an infinite loop. The bug is + // Safari's, not ours, so we just do our best to not crash even though + // the behavior isn't completely correct. + scheduleCallback$3(ImmediatePriority, cb); + return; + } + + cb(); + }); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -29455,6 +29749,9 @@ function getWorkInProgressRoot() { function getWorkInProgressRootRenderLanes() { return workInProgressRootRenderLanes; } +function isWorkLoopSuspendedOnData() { + return workInProgressSuspendedReason === SuspendedOnData; +} function requestEventTime() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. @@ -29658,21 +29955,25 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); if ( lane === SyncLane && executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue.isBatchingLegacy + (fiber.mode & ConcurrentMode) === NoMode ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + if (ReactCurrentActQueue.isBatchingLegacy) { + // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } else { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncWorkOnLegacyRootsOnly(); + } } } } @@ -29689,173 +29990,12 @@ function scheduleInitialHydrationOnRoot(root, lane, eventTime) { var current = root.current; current.lanes = lane; markRootUpdated(root, lane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function isUnsafeClassRenderPhaseUpdate(fiber) { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return (executionContext & RenderContext) !== NoContext; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. - -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. - - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. - - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. - if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); - } - - root.callbackNode = null; - root.callbackPriority = NoLane; - return; - } // If this root is currently suspended and waiting for data to resolve, don't - // schedule a task to render it. We'll either wait for a ping, or wait to - // receive an update. - - if ( - workInProgressSuspendedReason === SuspendedOnData && - workInProgressRoot === root - ) { - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - - var cancelPendingCommit = root.cancelPendingCommit; - - if (cancelPendingCommit !== null) { - // We should only interrupt a pending commit if the new update - // is urgent. - if (includesOnlyNonUrgentLanes(nextLanes)) { - // The new update is not urgent. Don't interrupt the pending commit. - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - } // We use the highest priority lane to represent the priority of the callback. - - var newCallbackPriority = getHighestPriorityLane(nextLanes); // Check if there's an existing task. We may be able to reuse it. - - var existingCallbackPriority = root.callbackPriority; - - if ( - existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a - // Scheduler task, rather than an `act` task, cancel it and re-scheduled - // on the `act` queue. - !( - ReactCurrentActQueue.current !== null && - existingCallbackNode !== fakeActCallbackNode - ) - ) { - { - // 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 && - !includesSyncLane(existingCallbackPriority) - ) { - 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. - - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. - cancelCallback(existingCallbackNode); - } // Schedule a new callback. - - var newCallbackNode; - - if (includesSyncLane(newCallbackPriority)) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue.isBatchingLegacy !== null) { - ReactCurrentActQueue.didScheduleLegacyUpdate = true; - } - - scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } - - { - // Flush the queue in a microtask. - if (ReactCurrentActQueue.current !== null) { - // Inside `act`, use our internal `act` queue so that these get flushed - // at the end of the current scope even when using the sync version - // of `act`. - ReactCurrentActQueue.current.push(flushSyncCallbacks); - } else { - scheduleMicrotask(function () { - // In Safari, appending an iframe forces microtasks to run. - // https://github.com/facebook/react/issues/22459 - // We don't support running callbacks in the middle of render - // or commit so we need to check against that. - if ( - (executionContext & (RenderContext | CommitContext)) === - NoContext - ) { - // Note that this would still prematurely flush the callbacks - // if this happens outside render or commit phase (e.g. in an event). - flushSyncCallbacks(); - } - }); - } - } - - newCallbackNode = null; - } else { - var schedulerPriorityLevel; - - switch (lanesToEventPriority(nextLanes)) { - case DiscreteEventPriority: - schedulerPriorityLevel = ImmediatePriority; - break; - - case ContinuousEventPriority: - schedulerPriorityLevel = UserBlockingPriority; - break; - - case DefaultEventPriority: - schedulerPriorityLevel = NormalPriority$1; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority$1; - break; - } - - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. @@ -29887,6 +30027,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } // Determine the next lanes to work on, using the fields stored // on the root. + // TODO: This was already computed in the caller. Pass it as an argument. var lanes = getNextLanes( root, @@ -29937,7 +30078,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -29987,7 +30128,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var _fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw _fatalError; } // FIXME: Need to check for RootDidNotComplete again. The factoring here // isn't ideal. @@ -30000,15 +30141,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } - ensureRootIsScheduled(root, now$1()); - - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); - } - - return null; + ensureRootIsScheduled(root); + return getContinuationForRoot(root, originalCallbackNode); } function recoverFromConcurrentError( @@ -30369,12 +30503,13 @@ function performSyncWorkOnRoot(root) { throw new Error("Should not already be working."); } - flushPassiveEffects(); + flushPassiveEffects(); // TODO: This was already computed in the caller. Pass it as an argument. + var lanes = getNextLanes(root, NoLanes); if (!includesSyncLane(lanes)) { // There's no remaining sync work left. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } @@ -30405,7 +30540,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -30414,7 +30549,7 @@ function performSyncWorkOnRoot(root) { // cases where need to exit the current render without producing a // consistent tree or committing. markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -30429,18 +30564,20 @@ function performSyncWorkOnRoot(root) { ); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } - function flushRoot(root, lanes) { if (lanes !== NoLanes) { markRootEntangled(root, mergeLanes(lanes, SyncLane)); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - resetRenderTimer(); - flushSyncCallbacks(); + resetRenderTimer(); // TODO: For historical reasons this flushes all sync work across all + // roots. It shouldn't really matter either way, but we could change this + // to only flush the given root. + + flushSyncWorkOnAllRoots(); } } } @@ -30462,7 +30599,7 @@ function batchedUpdates$1(fn, a) { !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + flushSyncWorkOnLegacyRootsOnly(); } } } @@ -30504,7 +30641,7 @@ function flushSync$1(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -31062,7 +31199,7 @@ function renderRootConcurrent(root, lanes) { // currently working on a different root, so that we resume // rendering later. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; thenable.then(onResolution, onResolution); @@ -31889,7 +32026,7 @@ function commitRootImpl( } // Always call this before exiting `commitRoot`, to ensure that any // additional work on this root is scheduled. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without @@ -31942,7 +32079,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { if (enableDebugTracing) { @@ -32142,7 +32279,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks; @@ -32226,7 +32363,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -32265,7 +32402,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -32341,7 +32478,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -32377,7 +32513,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -32396,7 +32532,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -32784,19 +32920,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } } } -function cancelCallback(callbackNode) { - if (callbackNode === fakeActCallbackNode) { - return; - } // In production, always call Scheduler. This function will be stripped out. - - return cancelCallback$1(callbackNode); -} - function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. return ReactCurrentActQueue.current !== null; @@ -34072,6 +34200,7 @@ function FiberRootNode( this.cancelPendingCommit = null; this.context = null; this.pendingContext = null; + this.next = null; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); @@ -34205,7 +34334,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-e73a2157"; +var ReactVersion = "18.3.0-www-modern-0d847e2d"; function createPortal$1( children, diff --git a/compiled/facebook-www/ReactDOMTesting-prod.classic.js b/compiled/facebook-www/ReactDOMTesting-prod.classic.js index 7311ac5950..eab0f6871d 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.classic.js @@ -52,6 +52,8 @@ var ReactSharedInternals = enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = dynamicFeatureFlags.enableCustomElementPropertySupport, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask, REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -384,7 +386,7 @@ function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var scheduleCallback$2 = Scheduler.unstable_scheduleCallback, +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -555,25 +557,6 @@ function computeExpirationTime(lane, currentTime) { return -1; } } -function markStarvedLanesAsExpired(root, currentTime) { - for ( - var suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$3 = 31 - clz32(lanes), - lane = 1 << index$3, - expirationTime = expirationTimes[index$3]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$3] = computeExpirationTime(lane, currentTime); - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; - } -} function getLanesToRetrySynchronouslyOnError(root, originallyAttemptedLanes) { if (root.errorRecoveryDisabledLanes & originallyAttemptedLanes) return 0; root = root.pendingLanes & -1073741825; @@ -2034,57 +2017,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - syncQueue = null, - includesLegacySyncCallbacks = !1, - isFlushingSyncQueue = !1; -function scheduleSyncCallback(callback) { - null === syncQueue ? (syncQueue = [callback]) : syncQueue.push(callback); -} -function scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = !0; - scheduleSyncCallback(callback); -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var previousUpdatePriority = currentUpdatePriority; - currentUpdatePriority = 2; - for (var errors = null, queue = syncQueue, i = 0; i < queue.length; i++) { - var callback = queue[i]; - try { - do callback = callback(!0); - while (null !== callback); - } catch (error) { - null === errors ? (errors = [error]) : errors.push(error); - } - } - syncQueue = null; - includesLegacySyncCallbacks = !1; - currentUpdatePriority = previousUpdatePriority; - isFlushingSyncQueue = !1; - if (null !== errors) { - if (1 < errors.length) { - if ("function" === typeof AggregateError) - throw new AggregateError(errors); - for ( - previousUpdatePriority = 1; - previousUpdatePriority < errors.length; - previousUpdatePriority++ - ) - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[previousUpdatePriority]) - ); - } - throw errors[0]; - } - } - return null; -} -function throwError(error) { - throw error; -} -var forkStack = [], + forkStack = [], forkStackIndex = 0, treeForkProvider = null, treeForkCount = 0, @@ -3785,10 +3718,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$69 = thenableIndexCounter; + var index$67 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$69); + usable = trackUsedThenable(thenableState, usable, index$67); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -4280,16 +4213,16 @@ function refreshCache(fiber, seedKey, seedValue) { case 3: var lane = requestUpdateLane(provider); fiber = createUpdate(lane); - var root$75 = enqueueUpdate(provider, fiber, lane); - if (null !== root$75) { + var root$73 = enqueueUpdate(provider, fiber, lane); + if (null !== root$73) { var eventTime = requestEventTime(); - scheduleUpdateOnFiber(root$75, provider, lane, eventTime); - entangleTransitions(root$75, provider, lane); + scheduleUpdateOnFiber(root$73, provider, lane, eventTime); + entangleTransitions(root$73, provider, lane); } provider = createCache(); null !== seedKey && void 0 !== seedKey && - null !== root$75 && + null !== root$73 && provider.data.set(seedKey, seedValue); fiber.payload = { cache: provider }; return; @@ -4496,15 +4429,15 @@ var HooksDispatcherOnMount = { getServerSnapshot = getServerSnapshot(); } else { getServerSnapshot = getSnapshot(); - var root$71 = workInProgressRoot; - if (null === root$71) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(root$71, renderLanes$1) || + var root$69 = workInProgressRoot; + if (null === root$69) throw Error(formatProdErrorMessage(349)); + includesBlockingLane(root$69, renderLanes$1) || pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } hook.memoizedState = getServerSnapshot; - root$71 = { value: getServerSnapshot, getSnapshot: getSnapshot }; - hook.queue = root$71; - mountEffect(subscribeToStore.bind(null, fiber, root$71, subscribe), [ + root$69 = { value: getServerSnapshot, getSnapshot: getSnapshot }; + hook.queue = root$69; + mountEffect(subscribeToStore.bind(null, fiber, root$69, subscribe), [ subscribe ]); fiber.flags |= 2048; @@ -4513,7 +4446,7 @@ var HooksDispatcherOnMount = { updateStoreInstance.bind( null, fiber, - root$71, + root$69, getServerSnapshot, getSnapshot ), @@ -5012,10 +4945,10 @@ var markerInstanceStack = createCursor(null); function pushRootMarkerInstance(workInProgress) { if (enableTransitionTracing) { var transitions = workInProgressTransitions, - root$86 = workInProgress.stateNode; + root$84 = workInProgress.stateNode; null !== transitions && transitions.forEach(function (transition) { - if (!root$86.incompleteTransitions.has(transition)) { + if (!root$84.incompleteTransitions.has(transition)) { var markerInstance = { tag: 0, transitions: new Set([transition]), @@ -5023,11 +4956,11 @@ function pushRootMarkerInstance(workInProgress) { aborts: null, name: null }; - root$86.incompleteTransitions.set(transition, markerInstance); + root$84.incompleteTransitions.set(transition, markerInstance); } }); var markerInstances = []; - root$86.incompleteTransitions.forEach(function (markerInstance) { + root$84.incompleteTransitions.forEach(function (markerInstance) { markerInstances.push(markerInstance); }); push(markerInstanceStack, markerInstances); @@ -5727,14 +5660,14 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } JSCompiler_temp = current.memoizedState; if (null !== JSCompiler_temp) { - var dehydrated$93 = JSCompiler_temp.dehydrated; - if (null !== dehydrated$93) + var dehydrated$91 = JSCompiler_temp.dehydrated; + if (null !== dehydrated$91) return updateDehydratedSuspenseComponent( current, workInProgress, didSuspend, nextProps, - dehydrated$93, + dehydrated$91, JSCompiler_temp, renderLanes ); @@ -5744,7 +5677,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { showFallback = nextProps.fallback; didSuspend = workInProgress.mode; JSCompiler_temp = current.child; - dehydrated$93 = JSCompiler_temp.sibling; + dehydrated$91 = JSCompiler_temp.sibling; var primaryChildProps = { mode: "hidden", children: nextProps.children }; 0 === (didSuspend & 1) && workInProgress.child !== JSCompiler_temp ? ((nextProps = workInProgress.child), @@ -5753,8 +5686,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (workInProgress.deletions = null)) : ((nextProps = createWorkInProgress(JSCompiler_temp, primaryChildProps)), (nextProps.subtreeFlags = JSCompiler_temp.subtreeFlags & 31457280)); - null !== dehydrated$93 - ? (showFallback = createWorkInProgress(dehydrated$93, showFallback)) + null !== dehydrated$91 + ? (showFallback = createWorkInProgress(dehydrated$91, showFallback)) : ((showFallback = createFiberFromFragment( showFallback, didSuspend, @@ -5773,10 +5706,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ? (didSuspend = mountSuspenseOffscreenState(renderLanes)) : ((JSCompiler_temp = didSuspend.cachePool), null !== JSCompiler_temp - ? ((dehydrated$93 = CacheContext._currentValue), + ? ((dehydrated$91 = CacheContext._currentValue), (JSCompiler_temp = - JSCompiler_temp.parent !== dehydrated$93 - ? { parent: dehydrated$93, pool: dehydrated$93 } + JSCompiler_temp.parent !== dehydrated$91 + ? { parent: dehydrated$91, pool: dehydrated$91 } : JSCompiler_temp)) : (JSCompiler_temp = getSuspendedCache()), (didSuspend = { @@ -5790,23 +5723,23 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ((JSCompiler_temp = enableTransitionTracing ? markerInstanceStack.current : null), - (dehydrated$93 = showFallback.updateQueue), + (dehydrated$91 = showFallback.updateQueue), (primaryChildProps = current.updateQueue), - null === dehydrated$93 + null === dehydrated$91 ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null }) - : dehydrated$93 === primaryChildProps + : dehydrated$91 === primaryChildProps ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null !== primaryChildProps ? primaryChildProps.retryQueue : null }) - : ((dehydrated$93.transitions = didSuspend), - (dehydrated$93.markerInstances = JSCompiler_temp)))); + : ((dehydrated$91.transitions = didSuspend), + (dehydrated$91.markerInstances = JSCompiler_temp)))); showFallback.childLanes = current.childLanes & ~renderLanes; workInProgress.memoizedState = SUSPENDED_MARKER; return nextProps; @@ -6599,7 +6532,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -6621,7 +6554,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -6868,14 +6801,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$124 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$124 = lastTailNode), + for (var lastTailNode$122 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$122 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$124 + null === lastTailNode$122 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$124.sibling = null); + : (lastTailNode$122.sibling = null); } } function bubbleProperties(completedWork) { @@ -6885,19 +6818,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$125 = completedWork.child; null !== child$125; ) - (newChildLanes |= child$125.lanes | child$125.childLanes), - (subtreeFlags |= child$125.subtreeFlags & 31457280), - (subtreeFlags |= child$125.flags & 31457280), - (child$125.return = completedWork), - (child$125 = child$125.sibling); + for (var child$123 = completedWork.child; null !== child$123; ) + (newChildLanes |= child$123.lanes | child$123.childLanes), + (subtreeFlags |= child$123.subtreeFlags & 31457280), + (subtreeFlags |= child$123.flags & 31457280), + (child$123.return = completedWork), + (child$123 = child$123.sibling); else - for (child$125 = completedWork.child; null !== child$125; ) - (newChildLanes |= child$125.lanes | child$125.childLanes), - (subtreeFlags |= child$125.subtreeFlags), - (subtreeFlags |= child$125.flags), - (child$125.return = completedWork), - (child$125 = child$125.sibling); + for (child$123 = completedWork.child; null !== child$123; ) + (newChildLanes |= child$123.lanes | child$123.childLanes), + (subtreeFlags |= child$123.subtreeFlags), + (subtreeFlags |= child$123.flags), + (child$123.return = completedWork), + (child$123 = child$123.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -7635,8 +7568,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$155) { - captureCommitPhaseError(current, nearestMountedAncestor, error$155); + } catch (error$153) { + captureCommitPhaseError(current, nearestMountedAncestor, error$153); } else ref.current = null; } @@ -7936,11 +7869,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$157) { + } catch (error$155) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$157 + error$155 ); } } @@ -8614,8 +8547,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$170) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$170); + } catch (error$168) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$168); } } break; @@ -8793,11 +8726,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { newProps ); domElement[internalPropsKey] = newProps; - } catch (error$171) { + } catch (error$169) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$171 + error$169 ); } break; @@ -8833,8 +8766,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { root = finishedWork.stateNode; try { setTextContent(root, ""); - } catch (error$172) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$172); + } catch (error$170) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$170); } } if ( @@ -8851,8 +8784,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { updateProperties(flags, maybeNodes, hoistableRoot, current, root), (flags[internalPropsKey] = root); - } catch (error$175) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$175); + } catch (error$173) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$173); } break; case 6: @@ -8865,8 +8798,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { flags = finishedWork.memoizedProps; try { current.nodeValue = flags; - } catch (error$176) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$176); + } catch (error$174) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$174); } } break; @@ -8880,8 +8813,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (flags & 4 && null !== current && current.memoizedState.isDehydrated) try { retryIfBlockedOn(root.containerInfo); - } catch (error$177) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$177); + } catch (error$175) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$175); } break; case 4: @@ -8911,8 +8844,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$179) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$179); + } catch (error$177) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$177); } current = finishedWork.updateQueue; null !== current && @@ -8990,11 +8923,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { root.stateNode.nodeValue = domElement ? "" : root.memoizedProps; - } catch (error$160) { + } catch (error$158) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$160 + error$158 ); } } else if ( @@ -9069,21 +9002,21 @@ function commitReconciliationEffects(finishedWork) { insertOrAppendPlacementNode(finishedWork, before, parent$jscomp$0); break; case 5: - var parent$161 = JSCompiler_inline_result.stateNode; + var parent$159 = JSCompiler_inline_result.stateNode; JSCompiler_inline_result.flags & 32 && - (setTextContent(parent$161, ""), + (setTextContent(parent$159, ""), (JSCompiler_inline_result.flags &= -33)); - var before$162 = getHostSibling(finishedWork); - insertOrAppendPlacementNode(finishedWork, before$162, parent$161); + var before$160 = getHostSibling(finishedWork); + insertOrAppendPlacementNode(finishedWork, before$160, parent$159); break; case 3: case 4: - var parent$163 = JSCompiler_inline_result.stateNode.containerInfo, - before$164 = getHostSibling(finishedWork); + var parent$161 = JSCompiler_inline_result.stateNode.containerInfo, + before$162 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$164, - parent$163 + before$162, + parent$161 ); break; default: @@ -9553,9 +9486,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$189 = finishedWork.stateNode; + var instance$187 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$189._visibility & 4 + ? instance$187._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9568,7 +9501,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$189._visibility |= 4), + : ((instance$187._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9576,7 +9509,7 @@ function recursivelyTraverseReconnectPassiveEffects( committedTransitions, includeWorkInProgressEffects )) - : ((instance$189._visibility |= 4), + : ((instance$187._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -9589,7 +9522,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$189 + instance$187 ); break; case 24: @@ -10104,6 +10037,204 @@ function schedulePostPaintCallback(callback) { callbacks = []; })); } +var firstScheduledRoot = null, + lastScheduledRoot = null, + didScheduleMicrotask = !1, + mightHavePendingSyncWork = !1, + isFlushingWork = !1; +function ensureRootIsScheduled(root) { + root !== lastScheduledRoot && + null === root.next && + (null === lastScheduledRoot + ? (firstScheduledRoot = lastScheduledRoot = root) + : (lastScheduledRoot = lastScheduledRoot.next = root)); + mightHavePendingSyncWork = !0; + didScheduleMicrotask || + ((didScheduleMicrotask = !0), + scheduleImmediateTask(processRootScheduleInMicrotask)); + enableDeferRootSchedulingToMicrotask || + scheduleTaskForRootDuringMicrotask(root, now()); +} +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (!isFlushingWork && mightHavePendingSyncWork) { + var workInProgressRoot$jscomp$0 = workInProgressRoot, + workInProgressRootRenderLanes$jscomp$0 = workInProgressRootRenderLanes, + errors = null; + isFlushingWork = !0; + do { + var didPerformSomeWork = !1; + for (var root$196 = firstScheduledRoot; null !== root$196; ) { + if ( + (!onlyLegacy || 0 === root$196.tag) && + 0 !== + (getNextLanes( + root$196, + root$196 === workInProgressRoot$jscomp$0 + ? workInProgressRootRenderLanes$jscomp$0 + : 0 + ) & + 3) + ) + try { + didPerformSomeWork = !0; + var root = root$196; + if (0 !== (executionContext & 6)) + throw Error(formatProdErrorMessage(327)); + flushPassiveEffects(); + var lanes = getNextLanes(root, 0); + if (0 !== (lanes & 3)) { + var exitStatus = renderRootSync(root, lanes); + if (0 !== root.tag && 2 === exitStatus) { + var originallyAttemptedLanes = lanes, + errorRetryLanes = getLanesToRetrySynchronouslyOnError( + root, + originallyAttemptedLanes + ); + 0 !== errorRetryLanes && + ((lanes = errorRetryLanes), + (exitStatus = recoverFromConcurrentError( + root, + originallyAttemptedLanes, + errorRetryLanes + ))); + } + if (1 === exitStatus) + throw ( + ((originallyAttemptedLanes = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended(root, lanes), + ensureRootIsScheduled(root), + originallyAttemptedLanes) + ); + 6 === exitStatus + ? markRootSuspended(root, lanes) + : ((root.finishedWork = root.current.alternate), + (root.finishedLanes = lanes), + commitRoot( + root, + workInProgressRootRecoverableErrors, + workInProgressTransitions + )); + } + ensureRootIsScheduled(root); + } catch (error) { + null === errors ? (errors = [error]) : errors.push(error); + } + root$196 = root$196.next; + } + } while (didPerformSomeWork); + isFlushingWork = !1; + if (null !== errors) { + if (1 < errors.length) { + if ("function" === typeof AggregateError) + throw new AggregateError(errors); + for (onlyLegacy = 1; onlyLegacy < errors.length; onlyLegacy++) + scheduleImmediateTask(throwError.bind(null, errors[onlyLegacy])); + } + throw errors[0]; + } + } +} +function throwError(error) { + throw error; +} +function processRootScheduleInMicrotask() { + mightHavePendingSyncWork = didScheduleMicrotask = !1; + for ( + var currentTime = now(), prev = null, root = firstScheduledRoot; + null !== root; + + ) { + var next = root.next, + nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + 0 === nextLanes + ? ((root.next = null), + null === prev ? (firstScheduledRoot = next) : (prev.next = next), + null === next && (lastScheduledRoot = prev)) + : ((prev = root), + 0 !== (nextLanes & 3) && (mightHavePendingSyncWork = !0)); + root = next; + } + flushSyncWorkAcrossRoots_impl(!1); +} +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + for ( + var suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes & -125829121; + 0 < lanes; + + ) { + var index$3 = 31 - clz32(lanes), + lane = 1 << index$3, + expirationTime = expirationTimes[index$3]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$3] = computeExpirationTime(lane, currentTime); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + currentTime = workInProgressRoot; + suspendedLanes = workInProgressRootRenderLanes; + suspendedLanes = getNextLanes( + root, + root === currentTime ? suspendedLanes : 0 + ); + pingedLanes = root.callbackNode; + if ( + 0 === suspendedLanes || + (2 === workInProgressSuspendedReason && root === currentTime) || + (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) + ) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackNode = null), + (root.callbackPriority = 0) + ); + if (0 !== (suspendedLanes & 3)) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackPriority = 2), + (root.callbackNode = null), + 2 + ); + currentTime = suspendedLanes & -suspendedLanes; + if (currentTime === root.callbackPriority) return currentTime; + null !== pingedLanes && cancelCallback$1(pingedLanes); + switch (lanesToEventPriority(suspendedLanes)) { + case 2: + suspendedLanes = ImmediatePriority; + break; + case 8: + suspendedLanes = UserBlockingPriority; + break; + case 32: + suspendedLanes = NormalPriority$1; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority$1; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$3(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} +function scheduleImmediateTask(cb) { + scheduleMicrotask(function () { + 0 !== (executionContext & 6) + ? scheduleCallback$3(ImmediatePriority, cb) + : cb(); + }); +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -10233,87 +10364,32 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { markRootSuspended(root, workInProgressRootRenderLanes)); markRootUpdated(root, lane, eventTime); if (0 === (executionContext & 2) || root !== workInProgressRoot) { - if (enableTransitionTracing) { - var transition = ReactCurrentBatchConfig$1.transition; - if ( - null !== transition && - null != transition.name && - (-1 === transition.startTime && (transition.startTime = now()), - enableTransitionTracing) - ) { - var transitionLanesMap = root.transitionLanes, - index$7 = 31 - clz32(lane), - transitions = transitionLanesMap[index$7]; - null === transitions && (transitions = new Set()); - transitions.add(transition); - transitionLanesMap[index$7] = transitions; - } + if ( + enableTransitionTracing && + ((eventTime = ReactCurrentBatchConfig$1.transition), + null !== eventTime && + null != eventTime.name && + (-1 === eventTime.startTime && (eventTime.startTime = now()), + enableTransitionTracing)) + ) { + var transitionLanesMap = root.transitionLanes, + index$7 = 31 - clz32(lane), + transitions = transitionLanesMap[index$7]; + null === transitions && (transitions = new Set()); + transitions.add(eventTime); + transitionLanesMap[index$7] = transitions; } root === workInProgressRoot && (0 === (executionContext & 2) && (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended(root, workInProgressRootRenderLanes)); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); 2 === lane && 0 === executionContext && 0 === (fiber.mode & 1) && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); - } -} -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; - markStarvedLanesAsExpired(root, currentTime); - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === nextLanes) - null !== existingCallbackNode && cancelCallback$1(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0); - else if (2 === workInProgressSuspendedReason && workInProgressRoot === root) - (root.callbackPriority = 0), (root.callbackNode = null); - else if (null !== root.cancelPendingCommit && 0 === (nextLanes & 42)) - (root.callbackPriority = 0), (root.callbackNode = null); - else if ( - ((currentTime = nextLanes & -nextLanes), - root.callbackPriority !== currentTime) - ) { - null != existingCallbackNode && cancelCallback$1(existingCallbackNode); - if (0 !== (currentTime & 3)) - 0 === root.tag - ? scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)), - scheduleMicrotask(function () { - 0 === (executionContext & 6) && flushSyncCallbacks(); - }), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(nextLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority$1; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority$1; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; + flushSyncWorkAcrossRoots_impl(!0)); } } function performConcurrentWorkOnRoot(root, didTimeout) { @@ -10354,7 +10430,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); if (6 === exitStatus) markRootSuspended(root, lanes); @@ -10385,7 +10461,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -10497,10 +10573,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode - ? performConcurrentWorkOnRoot.bind(null, root) - : null; + ensureRootIsScheduled(root); + scheduleTaskForRootDuringMicrotask(root, now()); + root = + root.callbackNode === originalCallbackNode + ? performConcurrentWorkOnRoot.bind(null, root) + : null; + return root; } function recoverFromConcurrentError( root, @@ -10608,48 +10687,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 6)) throw Error(formatProdErrorMessage(327)); - flushPassiveEffects(); - var lanes = getNextLanes(root, 0); - if (0 === (lanes & 3)) return ensureRootIsScheduled(root, now()), null; - var exitStatus = renderRootSync(root, lanes); - if (0 !== root.tag && 2 === exitStatus) { - var originallyAttemptedLanes = lanes, - errorRetryLanes = getLanesToRetrySynchronouslyOnError( - root, - originallyAttemptedLanes - ); - 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError( - root, - originallyAttemptedLanes, - errorRetryLanes - ))); - } - if (1 === exitStatus) - throw ( - ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), - exitStatus) - ); - if (6 === exitStatus) - return ( - markRootSuspended(root, lanes), ensureRootIsScheduled(root, now()), null - ); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - commitRoot( - root, - workInProgressRootRecoverableErrors, - workInProgressTransitions - ); - ensureRootIsScheduled(root, now()); - return null; -} function batchedUpdates$1(fn, a) { var prevExecutionContext = executionContext; executionContext |= 1; @@ -10659,7 +10696,7 @@ function batchedUpdates$1(fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } } function flushSync$1(fn) { @@ -10682,7 +10719,7 @@ function flushSync$1(fn) { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$1.transition = prevTransition), (executionContext = prevExecutionContext), - 0 === (executionContext & 6) && flushSyncCallbacks(); + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); } } function resetWorkInProgressStack() { @@ -10866,7 +10903,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -11079,10 +11116,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$81 = offscreenQueue.retryQueue; - null === retryQueue$81 + var retryQueue$79 = offscreenQueue.retryQueue; + null === retryQueue$79 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$81.add(wakeable); + : retryQueue$79.add(wakeable); } } break; @@ -11306,7 +11343,7 @@ function commitRootImpl( remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(finishedWork.stateNode, renderPriorityLevel); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, finishedWork = 0; @@ -11335,7 +11372,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevRootTransitionCallbacks = root.transitionCallbacks; null !== prevRootTransitionCallbacks && @@ -11398,7 +11435,7 @@ function flushPassiveEffectsImpl() { commitPassiveUnmountOnFiber(root.current); commitPassiveMountOnFiber(root, root.current, lanes, transitions); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks, prevRootTransitionCallbacks = root.transitionCallbacks, @@ -11428,7 +11465,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = requestEventTime(); null !== rootFiber && (markRootUpdated(rootFiber, 2, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + ensureRootIsScheduled(rootFiber)); } function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) @@ -11465,7 +11502,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -11491,7 +11528,6 @@ function attachPingListener(root, wakeable, lanes) { function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); root.pingedLanes |= root.suspendedLanes & pingedLanes; workInProgressRoot === root && (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && @@ -11502,7 +11538,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { 500 > now() - globalMostRecentFallbackTime) ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { 0 === retryLane && @@ -11511,7 +11547,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { boundaryFiber = enqueueConcurrentRenderForLane(boundaryFiber, retryLane); null !== boundaryFiber && (markRootUpdated(boundaryFiber, retryLane, eventTime), - ensureRootIsScheduled(boundaryFiber, eventTime)); + ensureRootIsScheduled(boundaryFiber)); } function retryDehydratedSuspenseBoundary(boundaryFiber) { var suspenseState = boundaryFiber.memoizedState, @@ -12169,7 +12205,7 @@ beginWork = function (current, workInProgress, renderLanes) { throw Error(formatProdErrorMessage(156, workInProgress.tag)); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -12485,6 +12521,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -12644,7 +12681,7 @@ function createHydrationContainer( enqueueUpdate(containerInfo, hydrationCallbacks, tag); initialChildren.current.lanes = tag; markRootUpdated(initialChildren, tag, callback); - ensureRootIsScheduled(initialChildren, callback); + ensureRootIsScheduled(initialChildren); return initialChildren; } function updateContainer(element, container, parentComponent, callback) { @@ -12684,10 +12721,10 @@ function attemptSynchronousHydration(fiber) { var lanes = getHighestPriorityLanes(root$209.pendingLanes); 0 !== lanes && (markRootEntangled(root$209, lanes | 2), - ensureRootIsScheduled(root$209, now()), + ensureRootIsScheduled(root$209), 0 === (executionContext & 6) && ((workInProgressRootRenderTargetTime = now() + 500), - flushSyncCallbacks())); + flushSyncWorkAcrossRoots_impl(!1))); } break; case 13: @@ -13256,19 +13293,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$328; + var JSCompiler_inline_result$jscomp$330; if (canUseDOM) { - var isSupported$jscomp$inline_1583 = "oninput" in document; - if (!isSupported$jscomp$inline_1583) { - var element$jscomp$inline_1584 = document.createElement("div"); - element$jscomp$inline_1584.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1583 = - "function" === typeof element$jscomp$inline_1584.oninput; + var isSupported$jscomp$inline_1612 = "oninput" in document; + if (!isSupported$jscomp$inline_1612) { + var element$jscomp$inline_1613 = document.createElement("div"); + element$jscomp$inline_1613.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1612 = + "function" === typeof element$jscomp$inline_1613.oninput; } - JSCompiler_inline_result$jscomp$328 = isSupported$jscomp$inline_1583; - } else JSCompiler_inline_result$jscomp$328 = !1; + JSCompiler_inline_result$jscomp$330 = isSupported$jscomp$inline_1612; + } else JSCompiler_inline_result$jscomp$330 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$328 && + JSCompiler_inline_result$jscomp$330 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13577,20 +13614,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1624 = 0; - i$jscomp$inline_1624 < simpleEventPluginEvents.length; - i$jscomp$inline_1624++ + var i$jscomp$inline_1653 = 0; + i$jscomp$inline_1653 < simpleEventPluginEvents.length; + i$jscomp$inline_1653++ ) { - var eventName$jscomp$inline_1625 = - simpleEventPluginEvents[i$jscomp$inline_1624], - domEventName$jscomp$inline_1626 = - eventName$jscomp$inline_1625.toLowerCase(), - capitalizedEvent$jscomp$inline_1627 = - eventName$jscomp$inline_1625[0].toUpperCase() + - eventName$jscomp$inline_1625.slice(1); + var eventName$jscomp$inline_1654 = + simpleEventPluginEvents[i$jscomp$inline_1653], + domEventName$jscomp$inline_1655 = + eventName$jscomp$inline_1654.toLowerCase(), + capitalizedEvent$jscomp$inline_1656 = + eventName$jscomp$inline_1654[0].toUpperCase() + + eventName$jscomp$inline_1654.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1626, - "on" + capitalizedEvent$jscomp$inline_1627 + domEventName$jscomp$inline_1655, + "on" + capitalizedEvent$jscomp$inline_1656 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -14603,17 +14640,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1738 = { +var devToolsConfig$jscomp$inline_1767 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-2881d527", + version: "18.3.0-www-classic-d364e70a", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2201 = { - bundleType: devToolsConfig$jscomp$inline_1738.bundleType, - version: devToolsConfig$jscomp$inline_1738.version, - rendererPackageName: devToolsConfig$jscomp$inline_1738.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1738.rendererConfig, +var internals$jscomp$inline_2236 = { + bundleType: devToolsConfig$jscomp$inline_1767.bundleType, + version: devToolsConfig$jscomp$inline_1767.version, + rendererPackageName: devToolsConfig$jscomp$inline_1767.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1767.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -14629,26 +14666,26 @@ var internals$jscomp$inline_2201 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1738.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1767.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-2881d527" + reconcilerVersion: "18.3.0-www-classic-d364e70a" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2202 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2237 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2202.isDisabled && - hook$jscomp$inline_2202.supportsFiber + !hook$jscomp$inline_2237.isDisabled && + hook$jscomp$inline_2237.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2202.inject( - internals$jscomp$inline_2201 + (rendererID = hook$jscomp$inline_2237.inject( + internals$jscomp$inline_2236 )), - (injectedHook = hook$jscomp$inline_2202); + (injectedHook = hook$jscomp$inline_2237); } catch (err) {} } var tagToRoleMappings = { @@ -16669,4 +16706,4 @@ exports.unstable_renderSubtreeIntoContainer = function ( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-classic-2881d527"; +exports.version = "18.3.0-www-classic-d364e70a"; diff --git a/compiled/facebook-www/ReactDOMTesting-prod.modern.js b/compiled/facebook-www/ReactDOMTesting-prod.modern.js index 71529514ca..30c4c7687a 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.modern.js @@ -109,7 +109,9 @@ var dynamicFeatureFlags = require("ReactFeatureFlags"), enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, enableCustomElementPropertySupport = dynamicFeatureFlags.enableCustomElementPropertySupport, - scheduleCallback$2 = Scheduler.unstable_scheduleCallback, + enableDeferRootSchedulingToMicrotask = + dynamicFeatureFlags.enableDeferRootSchedulingToMicrotask, + scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -282,25 +284,6 @@ function computeExpirationTime(lane, currentTime) { return -1; } } -function markStarvedLanesAsExpired(root, currentTime) { - for ( - var suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$2 = 31 - clz32(lanes), - lane = 1 << index$2, - expirationTime = expirationTimes[index$2]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$2] = computeExpirationTime(lane, currentTime); - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; - } -} function getLanesToRetrySynchronouslyOnError(root, originallyAttemptedLanes) { if (root.errorRecoveryDisabledLanes & originallyAttemptedLanes) return 0; root = root.pendingLanes & -1073741825; @@ -1495,57 +1478,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - syncQueue = null, - includesLegacySyncCallbacks = !1, - isFlushingSyncQueue = !1; -function scheduleSyncCallback(callback) { - null === syncQueue ? (syncQueue = [callback]) : syncQueue.push(callback); -} -function scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = !0; - scheduleSyncCallback(callback); -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && null !== syncQueue) { - isFlushingSyncQueue = !0; - var previousUpdatePriority = currentUpdatePriority; - currentUpdatePriority = 2; - for (var errors = null, queue = syncQueue, i = 0; i < queue.length; i++) { - var callback = queue[i]; - try { - do callback = callback(!0); - while (null !== callback); - } catch (error) { - null === errors ? (errors = [error]) : errors.push(error); - } - } - syncQueue = null; - includesLegacySyncCallbacks = !1; - currentUpdatePriority = previousUpdatePriority; - isFlushingSyncQueue = !1; - if (null !== errors) { - if (1 < errors.length) { - if ("function" === typeof AggregateError) - throw new AggregateError(errors); - for ( - previousUpdatePriority = 1; - previousUpdatePriority < errors.length; - previousUpdatePriority++ - ) - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[previousUpdatePriority]) - ); - } - throw errors[0]; - } - } - return null; -} -function throwError(error) { - throw error; -} -var forkStack = [], + forkStack = [], forkStackIndex = 0, treeForkProvider = null, treeForkCount = 0, @@ -3246,10 +3179,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$43 = thenableIndexCounter; + var index$41 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$43); + usable = trackUsedThenable(thenableState, usable, index$41); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -3741,16 +3674,16 @@ function refreshCache(fiber, seedKey, seedValue) { case 3: var lane = requestUpdateLane(provider); fiber = createUpdate(lane); - var root$49 = enqueueUpdate(provider, fiber, lane); - if (null !== root$49) { + var root$47 = enqueueUpdate(provider, fiber, lane); + if (null !== root$47) { var eventTime = requestEventTime(); - scheduleUpdateOnFiber(root$49, provider, lane, eventTime); - entangleTransitions(root$49, provider, lane); + scheduleUpdateOnFiber(root$47, provider, lane, eventTime); + entangleTransitions(root$47, provider, lane); } provider = createCache(); null !== seedKey && void 0 !== seedKey && - null !== root$49 && + null !== root$47 && provider.data.set(seedKey, seedValue); fiber.payload = { cache: provider }; return; @@ -3957,15 +3890,15 @@ var HooksDispatcherOnMount = { getServerSnapshot = getServerSnapshot(); } else { getServerSnapshot = getSnapshot(); - var root$45 = workInProgressRoot; - if (null === root$45) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(root$45, renderLanes$1) || + var root$43 = workInProgressRoot; + if (null === root$43) throw Error(formatProdErrorMessage(349)); + includesBlockingLane(root$43, renderLanes$1) || pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } hook.memoizedState = getServerSnapshot; - root$45 = { value: getServerSnapshot, getSnapshot: getSnapshot }; - hook.queue = root$45; - mountEffect(subscribeToStore.bind(null, fiber, root$45, subscribe), [ + root$43 = { value: getServerSnapshot, getSnapshot: getSnapshot }; + hook.queue = root$43; + mountEffect(subscribeToStore.bind(null, fiber, root$43, subscribe), [ subscribe ]); fiber.flags |= 2048; @@ -3974,7 +3907,7 @@ var HooksDispatcherOnMount = { updateStoreInstance.bind( null, fiber, - root$45, + root$43, getServerSnapshot, getSnapshot ), @@ -4458,10 +4391,10 @@ var markerInstanceStack = createCursor(null); function pushRootMarkerInstance(workInProgress) { if (enableTransitionTracing) { var transitions = workInProgressTransitions, - root$60 = workInProgress.stateNode; + root$58 = workInProgress.stateNode; null !== transitions && transitions.forEach(function (transition) { - if (!root$60.incompleteTransitions.has(transition)) { + if (!root$58.incompleteTransitions.has(transition)) { var markerInstance = { tag: 0, transitions: new Set([transition]), @@ -4469,11 +4402,11 @@ function pushRootMarkerInstance(workInProgress) { aborts: null, name: null }; - root$60.incompleteTransitions.set(transition, markerInstance); + root$58.incompleteTransitions.set(transition, markerInstance); } }); var markerInstances = []; - root$60.incompleteTransitions.forEach(function (markerInstance) { + root$58.incompleteTransitions.forEach(function (markerInstance) { markerInstances.push(markerInstance); }); push(markerInstanceStack, markerInstances); @@ -5137,14 +5070,14 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } JSCompiler_temp = current.memoizedState; if (null !== JSCompiler_temp) { - var dehydrated$67 = JSCompiler_temp.dehydrated; - if (null !== dehydrated$67) + var dehydrated$65 = JSCompiler_temp.dehydrated; + if (null !== dehydrated$65) return updateDehydratedSuspenseComponent( current, workInProgress, didSuspend, nextProps, - dehydrated$67, + dehydrated$65, JSCompiler_temp, renderLanes ); @@ -5154,7 +5087,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { showFallback = nextProps.fallback; didSuspend = workInProgress.mode; JSCompiler_temp = current.child; - dehydrated$67 = JSCompiler_temp.sibling; + dehydrated$65 = JSCompiler_temp.sibling; var primaryChildProps = { mode: "hidden", children: nextProps.children }; 0 === (didSuspend & 1) && workInProgress.child !== JSCompiler_temp ? ((nextProps = workInProgress.child), @@ -5163,8 +5096,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { (workInProgress.deletions = null)) : ((nextProps = createWorkInProgress(JSCompiler_temp, primaryChildProps)), (nextProps.subtreeFlags = JSCompiler_temp.subtreeFlags & 31457280)); - null !== dehydrated$67 - ? (showFallback = createWorkInProgress(dehydrated$67, showFallback)) + null !== dehydrated$65 + ? (showFallback = createWorkInProgress(dehydrated$65, showFallback)) : ((showFallback = createFiberFromFragment( showFallback, didSuspend, @@ -5183,10 +5116,10 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ? (didSuspend = mountSuspenseOffscreenState(renderLanes)) : ((JSCompiler_temp = didSuspend.cachePool), null !== JSCompiler_temp - ? ((dehydrated$67 = CacheContext._currentValue), + ? ((dehydrated$65 = CacheContext._currentValue), (JSCompiler_temp = - JSCompiler_temp.parent !== dehydrated$67 - ? { parent: dehydrated$67, pool: dehydrated$67 } + JSCompiler_temp.parent !== dehydrated$65 + ? { parent: dehydrated$65, pool: dehydrated$65 } : JSCompiler_temp)) : (JSCompiler_temp = getSuspendedCache()), (didSuspend = { @@ -5200,23 +5133,23 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { ((JSCompiler_temp = enableTransitionTracing ? markerInstanceStack.current : null), - (dehydrated$67 = showFallback.updateQueue), + (dehydrated$65 = showFallback.updateQueue), (primaryChildProps = current.updateQueue), - null === dehydrated$67 + null === dehydrated$65 ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null }) - : dehydrated$67 === primaryChildProps + : dehydrated$65 === primaryChildProps ? (showFallback.updateQueue = { transitions: didSuspend, markerInstances: JSCompiler_temp, retryQueue: null !== primaryChildProps ? primaryChildProps.retryQueue : null }) - : ((dehydrated$67.transitions = didSuspend), - (dehydrated$67.markerInstances = JSCompiler_temp)))); + : ((dehydrated$65.transitions = didSuspend), + (dehydrated$65.markerInstances = JSCompiler_temp)))); showFallback.childLanes = current.childLanes & ~renderLanes; workInProgress.memoizedState = SUSPENDED_MARKER; return nextProps; @@ -6005,7 +5938,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, NormalPriority = Scheduler.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -6027,7 +5960,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -6274,14 +6207,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$98 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$98 = lastTailNode), + for (var lastTailNode$96 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$96 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$98 + null === lastTailNode$96 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$98.sibling = null); + : (lastTailNode$96.sibling = null); } } function bubbleProperties(completedWork) { @@ -6291,19 +6224,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$99 = completedWork.child; null !== child$99; ) - (newChildLanes |= child$99.lanes | child$99.childLanes), - (subtreeFlags |= child$99.subtreeFlags & 31457280), - (subtreeFlags |= child$99.flags & 31457280), - (child$99.return = completedWork), - (child$99 = child$99.sibling); + for (var child$97 = completedWork.child; null !== child$97; ) + (newChildLanes |= child$97.lanes | child$97.childLanes), + (subtreeFlags |= child$97.subtreeFlags & 31457280), + (subtreeFlags |= child$97.flags & 31457280), + (child$97.return = completedWork), + (child$97 = child$97.sibling); else - for (child$99 = completedWork.child; null !== child$99; ) - (newChildLanes |= child$99.lanes | child$99.childLanes), - (subtreeFlags |= child$99.subtreeFlags), - (subtreeFlags |= child$99.flags), - (child$99.return = completedWork), - (child$99 = child$99.sibling); + for (child$97 = completedWork.child; null !== child$97; ) + (newChildLanes |= child$97.lanes | child$97.childLanes), + (subtreeFlags |= child$97.subtreeFlags), + (subtreeFlags |= child$97.flags), + (child$97.return = completedWork), + (child$97 = child$97.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -7022,8 +6955,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$128) { - captureCommitPhaseError(current, nearestMountedAncestor, error$128); + } catch (error$126) { + captureCommitPhaseError(current, nearestMountedAncestor, error$126); } else ref.current = null; } @@ -7336,11 +7269,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$130) { + } catch (error$128) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$130 + error$128 ); } } @@ -8014,8 +7947,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$143) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$143); + } catch (error$141) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$141); } } break; @@ -8193,11 +8126,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { newProps ); domElement[internalPropsKey] = newProps; - } catch (error$144) { + } catch (error$142) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$144 + error$142 ); } break; @@ -8233,8 +8166,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { root = finishedWork.stateNode; try { setTextContent(root, ""); - } catch (error$145) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$145); + } catch (error$143) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$143); } } if ( @@ -8251,8 +8184,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { updateProperties(flags, maybeNodes, hoistableRoot, current, root), (flags[internalPropsKey] = root); - } catch (error$148) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$148); + } catch (error$146) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$146); } break; case 6: @@ -8265,8 +8198,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { flags = finishedWork.memoizedProps; try { current.nodeValue = flags; - } catch (error$149) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$149); + } catch (error$147) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$147); } } break; @@ -8280,8 +8213,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (flags & 4 && null !== current && current.memoizedState.isDehydrated) try { retryIfBlockedOn(root.containerInfo); - } catch (error$150) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$150); + } catch (error$148) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$148); } break; case 4: @@ -8311,8 +8244,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$152) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$152); + } catch (error$150) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$150); } current = finishedWork.updateQueue; null !== current && @@ -8390,11 +8323,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { root.stateNode.nodeValue = domElement ? "" : root.memoizedProps; - } catch (error$133) { + } catch (error$131) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$133 + error$131 ); } } else if ( @@ -8469,21 +8402,21 @@ function commitReconciliationEffects(finishedWork) { insertOrAppendPlacementNode(finishedWork, before, parent$jscomp$0); break; case 5: - var parent$134 = JSCompiler_inline_result.stateNode; + var parent$132 = JSCompiler_inline_result.stateNode; JSCompiler_inline_result.flags & 32 && - (setTextContent(parent$134, ""), + (setTextContent(parent$132, ""), (JSCompiler_inline_result.flags &= -33)); - var before$135 = getHostSibling(finishedWork); - insertOrAppendPlacementNode(finishedWork, before$135, parent$134); + var before$133 = getHostSibling(finishedWork); + insertOrAppendPlacementNode(finishedWork, before$133, parent$132); break; case 3: case 4: - var parent$136 = JSCompiler_inline_result.stateNode.containerInfo, - before$137 = getHostSibling(finishedWork); + var parent$134 = JSCompiler_inline_result.stateNode.containerInfo, + before$135 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$137, - parent$136 + before$135, + parent$134 ); break; default: @@ -8953,9 +8886,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$162 = finishedWork.stateNode; + var instance$160 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$162._visibility & 4 + ? instance$160._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8968,7 +8901,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$162._visibility |= 4), + : ((instance$160._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8976,7 +8909,7 @@ function recursivelyTraverseReconnectPassiveEffects( committedTransitions, includeWorkInProgressEffects )) - : ((instance$162._visibility |= 4), + : ((instance$160._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8989,7 +8922,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$162 + instance$160 ); break; case 24: @@ -9504,6 +9437,204 @@ function schedulePostPaintCallback(callback) { callbacks = []; })); } +var firstScheduledRoot = null, + lastScheduledRoot = null, + didScheduleMicrotask = !1, + mightHavePendingSyncWork = !1, + isFlushingWork = !1; +function ensureRootIsScheduled(root) { + root !== lastScheduledRoot && + null === root.next && + (null === lastScheduledRoot + ? (firstScheduledRoot = lastScheduledRoot = root) + : (lastScheduledRoot = lastScheduledRoot.next = root)); + mightHavePendingSyncWork = !0; + didScheduleMicrotask || + ((didScheduleMicrotask = !0), + scheduleImmediateTask(processRootScheduleInMicrotask)); + enableDeferRootSchedulingToMicrotask || + scheduleTaskForRootDuringMicrotask(root, now()); +} +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (!isFlushingWork && mightHavePendingSyncWork) { + var workInProgressRoot$jscomp$0 = workInProgressRoot, + workInProgressRootRenderLanes$jscomp$0 = workInProgressRootRenderLanes, + errors = null; + isFlushingWork = !0; + do { + var didPerformSomeWork = !1; + for (var root$169 = firstScheduledRoot; null !== root$169; ) { + if ( + (!onlyLegacy || 0 === root$169.tag) && + 0 !== + (getNextLanes( + root$169, + root$169 === workInProgressRoot$jscomp$0 + ? workInProgressRootRenderLanes$jscomp$0 + : 0 + ) & + 3) + ) + try { + didPerformSomeWork = !0; + var root = root$169; + if (0 !== (executionContext & 6)) + throw Error(formatProdErrorMessage(327)); + flushPassiveEffects(); + var lanes = getNextLanes(root, 0); + if (0 !== (lanes & 3)) { + var exitStatus = renderRootSync(root, lanes); + if (0 !== root.tag && 2 === exitStatus) { + var originallyAttemptedLanes = lanes, + errorRetryLanes = getLanesToRetrySynchronouslyOnError( + root, + originallyAttemptedLanes + ); + 0 !== errorRetryLanes && + ((lanes = errorRetryLanes), + (exitStatus = recoverFromConcurrentError( + root, + originallyAttemptedLanes, + errorRetryLanes + ))); + } + if (1 === exitStatus) + throw ( + ((originallyAttemptedLanes = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended(root, lanes), + ensureRootIsScheduled(root), + originallyAttemptedLanes) + ); + 6 === exitStatus + ? markRootSuspended(root, lanes) + : ((root.finishedWork = root.current.alternate), + (root.finishedLanes = lanes), + commitRoot( + root, + workInProgressRootRecoverableErrors, + workInProgressTransitions + )); + } + ensureRootIsScheduled(root); + } catch (error) { + null === errors ? (errors = [error]) : errors.push(error); + } + root$169 = root$169.next; + } + } while (didPerformSomeWork); + isFlushingWork = !1; + if (null !== errors) { + if (1 < errors.length) { + if ("function" === typeof AggregateError) + throw new AggregateError(errors); + for (onlyLegacy = 1; onlyLegacy < errors.length; onlyLegacy++) + scheduleImmediateTask(throwError.bind(null, errors[onlyLegacy])); + } + throw errors[0]; + } + } +} +function throwError(error) { + throw error; +} +function processRootScheduleInMicrotask() { + mightHavePendingSyncWork = didScheduleMicrotask = !1; + for ( + var currentTime = now(), prev = null, root = firstScheduledRoot; + null !== root; + + ) { + var next = root.next, + nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + 0 === nextLanes + ? ((root.next = null), + null === prev ? (firstScheduledRoot = next) : (prev.next = next), + null === next && (lastScheduledRoot = prev)) + : ((prev = root), + 0 !== (nextLanes & 3) && (mightHavePendingSyncWork = !0)); + root = next; + } + flushSyncWorkAcrossRoots_impl(!1); +} +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + for ( + var suspendedLanes = root.suspendedLanes, + pingedLanes = root.pingedLanes, + expirationTimes = root.expirationTimes, + lanes = root.pendingLanes & -125829121; + 0 < lanes; + + ) { + var index$2 = 31 - clz32(lanes), + lane = 1 << index$2, + expirationTime = expirationTimes[index$2]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$2] = computeExpirationTime(lane, currentTime); + } else expirationTime <= currentTime && (root.expiredLanes |= lane); + lanes &= ~lane; + } + currentTime = workInProgressRoot; + suspendedLanes = workInProgressRootRenderLanes; + suspendedLanes = getNextLanes( + root, + root === currentTime ? suspendedLanes : 0 + ); + pingedLanes = root.callbackNode; + if ( + 0 === suspendedLanes || + (2 === workInProgressSuspendedReason && root === currentTime) || + (null !== root.cancelPendingCommit && 0 === (suspendedLanes & 42)) + ) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackNode = null), + (root.callbackPriority = 0) + ); + if (0 !== (suspendedLanes & 3)) + return ( + null !== pingedLanes && + null !== pingedLanes && + cancelCallback$1(pingedLanes), + (root.callbackPriority = 2), + (root.callbackNode = null), + 2 + ); + currentTime = suspendedLanes & -suspendedLanes; + if (currentTime === root.callbackPriority) return currentTime; + null !== pingedLanes && cancelCallback$1(pingedLanes); + switch (lanesToEventPriority(suspendedLanes)) { + case 2: + suspendedLanes = ImmediatePriority; + break; + case 8: + suspendedLanes = UserBlockingPriority; + break; + case 32: + suspendedLanes = NormalPriority$1; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority$1; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$3(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} +function scheduleImmediateTask(cb) { + scheduleMicrotask(function () { + 0 !== (executionContext & 6) + ? scheduleCallback$3(ImmediatePriority, cb) + : cb(); + }); +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -9633,87 +9764,32 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { markRootSuspended(root, workInProgressRootRenderLanes)); markRootUpdated(root, lane, eventTime); if (0 === (executionContext & 2) || root !== workInProgressRoot) { - if (enableTransitionTracing) { - var transition = ReactCurrentBatchConfig$1.transition; - if ( - null !== transition && - null != transition.name && - (-1 === transition.startTime && (transition.startTime = now()), - enableTransitionTracing) - ) { - var transitionLanesMap = root.transitionLanes, - index$6 = 31 - clz32(lane), - transitions = transitionLanesMap[index$6]; - null === transitions && (transitions = new Set()); - transitions.add(transition); - transitionLanesMap[index$6] = transitions; - } + if ( + enableTransitionTracing && + ((eventTime = ReactCurrentBatchConfig$1.transition), + null !== eventTime && + null != eventTime.name && + (-1 === eventTime.startTime && (eventTime.startTime = now()), + enableTransitionTracing)) + ) { + var transitionLanesMap = root.transitionLanes, + index$6 = 31 - clz32(lane), + transitions = transitionLanesMap[index$6]; + null === transitions && (transitions = new Set()); + transitions.add(eventTime); + transitionLanesMap[index$6] = transitions; } root === workInProgressRoot && (0 === (executionContext & 2) && (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended(root, workInProgressRootRenderLanes)); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); 2 === lane && 0 === executionContext && 0 === (fiber.mode & 1) && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); - } -} -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; - markStarvedLanesAsExpired(root, currentTime); - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === nextLanes) - null !== existingCallbackNode && cancelCallback$1(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0); - else if (2 === workInProgressSuspendedReason && workInProgressRoot === root) - (root.callbackPriority = 0), (root.callbackNode = null); - else if (null !== root.cancelPendingCommit && 0 === (nextLanes & 42)) - (root.callbackPriority = 0), (root.callbackNode = null); - else if ( - ((currentTime = nextLanes & -nextLanes), - root.callbackPriority !== currentTime) - ) { - null != existingCallbackNode && cancelCallback$1(existingCallbackNode); - if (0 !== (currentTime & 3)) - 0 === root.tag - ? scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)) - : scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)), - scheduleMicrotask(function () { - 0 === (executionContext & 6) && flushSyncCallbacks(); - }), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(nextLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority$1; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority$1; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; + flushSyncWorkAcrossRoots_impl(!0)); } } function performConcurrentWorkOnRoot(root, didTimeout) { @@ -9754,7 +9830,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); if (6 === exitStatus) markRootSuspended(root, lanes); @@ -9785,7 +9861,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -9897,10 +9973,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode - ? performConcurrentWorkOnRoot.bind(null, root) - : null; + ensureRootIsScheduled(root); + scheduleTaskForRootDuringMicrotask(root, now()); + root = + root.callbackNode === originalCallbackNode + ? performConcurrentWorkOnRoot.bind(null, root) + : null; + return root; } function recoverFromConcurrentError( root, @@ -10008,48 +10087,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 6)) throw Error(formatProdErrorMessage(327)); - flushPassiveEffects(); - var lanes = getNextLanes(root, 0); - if (0 === (lanes & 3)) return ensureRootIsScheduled(root, now()), null; - var exitStatus = renderRootSync(root, lanes); - if (0 !== root.tag && 2 === exitStatus) { - var originallyAttemptedLanes = lanes, - errorRetryLanes = getLanesToRetrySynchronouslyOnError( - root, - originallyAttemptedLanes - ); - 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError( - root, - originallyAttemptedLanes, - errorRetryLanes - ))); - } - if (1 === exitStatus) - throw ( - ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), - exitStatus) - ); - if (6 === exitStatus) - return ( - markRootSuspended(root, lanes), ensureRootIsScheduled(root, now()), null - ); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - commitRoot( - root, - workInProgressRootRecoverableErrors, - workInProgressTransitions - ); - ensureRootIsScheduled(root, now()); - return null; -} function batchedUpdates$1(fn, a) { var prevExecutionContext = executionContext; executionContext |= 1; @@ -10059,7 +10096,7 @@ function batchedUpdates$1(fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } } function flushSync$1(fn) { @@ -10082,7 +10119,7 @@ function flushSync$1(fn) { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$1.transition = prevTransition), (executionContext = prevExecutionContext), - 0 === (executionContext & 6) && flushSyncCallbacks(); + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); } } function resetWorkInProgressStack() { @@ -10266,7 +10303,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -10479,10 +10516,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$55 = offscreenQueue.retryQueue; - null === retryQueue$55 + var retryQueue$53 = offscreenQueue.retryQueue; + null === retryQueue$53 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$55.add(wakeable); + : retryQueue$53.add(wakeable); } } break; @@ -10706,7 +10743,7 @@ function commitRootImpl( remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(finishedWork.stateNode, renderPriorityLevel); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, finishedWork = 0; @@ -10735,7 +10772,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevRootTransitionCallbacks = root.transitionCallbacks; null !== prevRootTransitionCallbacks && @@ -10798,7 +10835,7 @@ function flushPassiveEffectsImpl() { commitPassiveUnmountOnFiber(root.current); commitPassiveMountOnFiber(root, root.current, lanes, transitions); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if (enableTransitionTracing) { var prevPendingTransitionCallbacks = currentPendingTransitionCallbacks, prevRootTransitionCallbacks = root.transitionCallbacks, @@ -10828,7 +10865,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = requestEventTime(); null !== rootFiber && (markRootUpdated(rootFiber, 2, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + ensureRootIsScheduled(rootFiber)); } function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) @@ -10865,7 +10902,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -10891,7 +10928,6 @@ function attachPingListener(root, wakeable, lanes) { function pingSuspendedRoot(root, wakeable, pingedLanes) { var pingCache = root.pingCache; null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); root.pingedLanes |= root.suspendedLanes & pingedLanes; workInProgressRoot === root && (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && @@ -10902,7 +10938,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { 500 > now() - globalMostRecentFallbackTime) ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { 0 === retryLane && @@ -10911,7 +10947,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { boundaryFiber = enqueueConcurrentRenderForLane(boundaryFiber, retryLane); null !== boundaryFiber && (markRootUpdated(boundaryFiber, retryLane, eventTime), - ensureRootIsScheduled(boundaryFiber, eventTime)); + ensureRootIsScheduled(boundaryFiber)); } function retryDehydratedSuspenseBoundary(boundaryFiber) { var suspenseState = boundaryFiber.memoizedState, @@ -11542,7 +11578,7 @@ beginWork = function (current, workInProgress, renderLanes) { throw Error(formatProdErrorMessage(156, workInProgress.tag)); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -11858,6 +11894,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -11970,10 +12007,10 @@ function attemptSynchronousHydration(fiber) { var lanes = getHighestPriorityLanes(root$182.pendingLanes); 0 !== lanes && (markRootEntangled(root$182, lanes | 2), - ensureRootIsScheduled(root$182, now()), + ensureRootIsScheduled(root$182), 0 === (executionContext & 6) && ((workInProgressRootRenderTargetTime = now() + 500), - flushSyncCallbacks())); + flushSyncWorkAcrossRoots_impl(!1))); } break; case 13: @@ -13092,19 +13129,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$324; + var JSCompiler_inline_result$jscomp$326; if (canUseDOM) { - var isSupported$jscomp$inline_1547 = "oninput" in document; - if (!isSupported$jscomp$inline_1547) { - var element$jscomp$inline_1548 = document.createElement("div"); - element$jscomp$inline_1548.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1547 = - "function" === typeof element$jscomp$inline_1548.oninput; + var isSupported$jscomp$inline_1576 = "oninput" in document; + if (!isSupported$jscomp$inline_1576) { + var element$jscomp$inline_1577 = document.createElement("div"); + element$jscomp$inline_1577.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1576 = + "function" === typeof element$jscomp$inline_1577.oninput; } - JSCompiler_inline_result$jscomp$324 = isSupported$jscomp$inline_1547; - } else JSCompiler_inline_result$jscomp$324 = !1; + JSCompiler_inline_result$jscomp$326 = isSupported$jscomp$inline_1576; + } else JSCompiler_inline_result$jscomp$326 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$324 && + JSCompiler_inline_result$jscomp$326 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13413,20 +13450,20 @@ function registerSimpleEvent(domEventName, reactName) { registerTwoPhaseEvent(reactName, [domEventName]); } for ( - var i$jscomp$inline_1588 = 0; - i$jscomp$inline_1588 < simpleEventPluginEvents.length; - i$jscomp$inline_1588++ + var i$jscomp$inline_1617 = 0; + i$jscomp$inline_1617 < simpleEventPluginEvents.length; + i$jscomp$inline_1617++ ) { - var eventName$jscomp$inline_1589 = - simpleEventPluginEvents[i$jscomp$inline_1588], - domEventName$jscomp$inline_1590 = - eventName$jscomp$inline_1589.toLowerCase(), - capitalizedEvent$jscomp$inline_1591 = - eventName$jscomp$inline_1589[0].toUpperCase() + - eventName$jscomp$inline_1589.slice(1); + var eventName$jscomp$inline_1618 = + simpleEventPluginEvents[i$jscomp$inline_1617], + domEventName$jscomp$inline_1619 = + eventName$jscomp$inline_1618.toLowerCase(), + capitalizedEvent$jscomp$inline_1620 = + eventName$jscomp$inline_1618[0].toUpperCase() + + eventName$jscomp$inline_1618.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1590, - "on" + capitalizedEvent$jscomp$inline_1591 + domEventName$jscomp$inline_1619, + "on" + capitalizedEvent$jscomp$inline_1620 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -15827,17 +15864,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1768 = { +var devToolsConfig$jscomp$inline_1797 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-0aab03f8", + version: "18.3.0-www-modern-4b52f385", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2168 = { - bundleType: devToolsConfig$jscomp$inline_1768.bundleType, - version: devToolsConfig$jscomp$inline_1768.version, - rendererPackageName: devToolsConfig$jscomp$inline_1768.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1768.rendererConfig, +var internals$jscomp$inline_2203 = { + bundleType: devToolsConfig$jscomp$inline_1797.bundleType, + version: devToolsConfig$jscomp$inline_1797.version, + rendererPackageName: devToolsConfig$jscomp$inline_1797.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1797.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -15854,26 +15891,26 @@ var internals$jscomp$inline_2168 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1768.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1797.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-0aab03f8" + reconcilerVersion: "18.3.0-www-modern-4b52f385" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2169 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2204 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2169.isDisabled && - hook$jscomp$inline_2169.supportsFiber + !hook$jscomp$inline_2204.isDisabled && + hook$jscomp$inline_2204.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2169.inject( - internals$jscomp$inline_2168 + (rendererID = hook$jscomp$inline_2204.inject( + internals$jscomp$inline_2203 )), - (injectedHook = hook$jscomp$inline_2169); + (injectedHook = hook$jscomp$inline_2204); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; @@ -16096,7 +16133,7 @@ exports.hydrateRoot = function (container, initialChildren, options) { enqueueUpdate(options, concurrentUpdatesByDefaultOverride, isStrictMode); initialChildren.current.lanes = isStrictMode; markRootUpdated(initialChildren, isStrictMode, identifierPrefix); - ensureRootIsScheduled(initialChildren, identifierPrefix); + ensureRootIsScheduled(initialChildren); container[internalContainerInstanceKey] = initialChildren.current; Dispatcher.current = ReactDOMClientDispatcher; listenToAllSupportedEvents(container); @@ -16181,4 +16218,4 @@ exports.unstable_createEventHandle = function (type, options) { return eventHandle; }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-modern-0aab03f8"; +exports.version = "18.3.0-www-modern-4b52f385"; diff --git a/compiled/facebook-www/ReactTestRenderer-dev.classic.js b/compiled/facebook-www/ReactTestRenderer-dev.classic.js index fa4824bcd1..fb11a2a948 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.classic.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.classic.js @@ -840,7 +840,7 @@ function isArray(a) { } // This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$2 = Scheduler$1.unstable_scheduleCallback; +var scheduleCallback$3 = Scheduler$1.unstable_scheduleCallback; var cancelCallback$1 = Scheduler$1.unstable_cancelCallback; var shouldYield = Scheduler$1.unstable_shouldYield; var requestPaint = Scheduler$1.unstable_requestPaint; @@ -2861,102 +2861,6 @@ function is(x, y) { var objectIs = typeof Object.is === "function" ? Object.is : is; // $FlowFixMe[method-unbinding] -var syncQueue = null; -var includesLegacySyncCallbacks = false; -var isFlushingSyncQueue = false; -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]; - } 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 scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = true; - scheduleSyncCallback(callback); -} -function flushSyncCallbacksOnlyInLegacyMode() { - // Only flushes the queue if there's a legacy sync callback scheduled. - // TODO: There's only a single type of callback: performSyncOnWorkOnRoot. So - // it might make more sense for the queue to be a list of roots instead of a - // list of generic callbacks. Then we can have two: one for legacy roots, one - // for concurrent roots. And this method would only flush the legacy ones. - if (includesLegacySyncCallbacks) { - flushSyncCallbacks(); - } -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrance. - isFlushingSyncQueue = true; // Set the event priority to discrete - // TODO: Is this necessary anymore? The only user code that runs in this - // queue is in the render or commit phases, which already set the - // event priority. Should be able to remove. - - var previousUpdatePriority = getCurrentUpdatePriority(); - setCurrentUpdatePriority(DiscreteEventPriority); - var errors = null; - var queue = syncQueue; // $FlowFixMe[incompatible-use] found when upgrading Flow - - for (var i = 0; i < queue.length; i++) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - var callback = queue[i]; - - try { - do { - var isSync = true; // $FlowFixMe[incompatible-type] we bail out when we get a null - - callback = callback(isSync); - } while (callback !== null); - } catch (error) { - // Collect errors so we can rethrow them at the end - if (errors === null) { - errors = [error]; - } else { - errors.push(error); - } - } - } - - syncQueue = null; - includesLegacySyncCallbacks = false; - setCurrentUpdatePriority(previousUpdatePriority); - isFlushingSyncQueue = false; - - if (errors !== null) { - if (errors.length > 1) { - if (typeof AggregateError === "function") { - // eslint-disable-next-line no-undef - throw new AggregateError(errors); - } else { - for (var _i = 1; _i < errors.length; _i++) { - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[_i]) - ); - } - - var firstError = errors[0]; - throw firstError; - } - } else { - var error = errors[0]; - throw error; - } - } - } - - return null; -} - -function throwError(error) { - throw error; -} - // This is imported by the event replaying implementation in React DOM. It's // in a separate file to break a circular dependency between the renderer and // the reconciler. @@ -4427,7 +4331,7 @@ function checkPropStringCoercion(value, propName) { } } -var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we +var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we // detect this is caught by userspace, we'll log a warning in development. var SuspenseException = new Error( @@ -4463,8 +4367,8 @@ function isThenableResolved(thenable) { function noop() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactCurrentActQueue$2.current !== null) { - ReactCurrentActQueue$2.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var previous = thenableState[index]; @@ -14850,7 +14754,7 @@ var AbortControllerLocal = }; // Intentionally not named imports because Rollup would // use dynamic dispatch for CommonJS interop named imports. -var scheduleCallback$1 = Scheduler$1.unstable_scheduleCallback, +var scheduleCallback$2 = Scheduler$1.unstable_scheduleCallback, NormalPriority = Scheduler$1.unstable_NormalPriority; var CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -14906,7 +14810,7 @@ function releaseCache(cache) { } if (cache.refCount === 0) { - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -20069,7 +19973,7 @@ if (typeof Symbol === "function" && Symbol.for) { symbolFor("selector.text"); } -var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; +var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -20094,7 +19998,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -20107,6 +20011,368 @@ function isConcurrentActEnvironment() { } } +var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, +// there's only a single root, but we do support multi root apps, hence this +// extra complexity. But this module is optimized for the single root case. + +var firstScheduledRoot = null; +var lastScheduledRoot = null; // Used to prevent redundant mircotasks from being scheduled. + +var didScheduleMicrotask = false; // `act` "microtasks" are scheduled on the `act` queue instead of an actual +// microtask, so we have to dedupe those separately. This wouldn't be an issue +// if we required all `act` calls to be awaited, which we might in the future. + +var didScheduleMicrotask_act = false; // Used to quickly bail out of flushSync if there's no sync work to do. + +var mightHavePendingSyncWork = false; +var isFlushingWork = false; +function ensureRootIsScheduled(root) { + // This function is called whenever a root receives an update. It does two + // things 1) it ensures the root is in the root schedule, and 2) it ensures + // there's a pending microtask to process the root schedule. + // + // Most of the actual scheduling logic does not happen until + // `scheduleTaskForRootDuringMicrotask` runs. + // Add the root to the schedule + if (root === lastScheduledRoot || root.next !== null); + else { + if (lastScheduledRoot === null) { + firstScheduledRoot = lastScheduledRoot = root; + } else { + lastScheduledRoot.next = root; + lastScheduledRoot = root; + } + } // Any time a root received an update, we set this to true until the next time + // we process the schedule. If it's false, then we can quickly exit flushSync + // without consulting the schedule. + + mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure + // there's a task scheduled for each one at the correct priority. + + if (ReactCurrentActQueue$1.current !== null) { + // We're inside an `act` scope. + if (!didScheduleMicrotask_act) { + didScheduleMicrotask_act = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } else { + if (!didScheduleMicrotask) { + didScheduleMicrotask = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } +} +function flushSyncWorkOnAllRoots() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(false); +} +function flushSyncWorkOnLegacyRootsOnly() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(true); +} + +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (isFlushingWork) { + // Prevent reentrancy. + // TODO: Is this overly defensive? The callers must check the execution + // context first regardless. + return; + } + + if (!mightHavePendingSyncWork) { + // Fast path. There's no sync work to do. + return; + } + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); // There may or may not be synchronous work scheduled. Let's check. + + var didPerformSomeWork; + var errors = null; + isFlushingWork = true; + + do { + didPerformSomeWork = false; + var root = firstScheduledRoot; + + while (root !== null) { + if (onlyLegacy && root.tag !== LegacyRoot); + else { + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + + if (includesSyncLane(nextLanes)) { + // This root has pending sync work. Flush it now. + try { + // TODO: Pass nextLanes as an argument instead of computing it again + // inside performSyncWorkOnRoot. + didPerformSomeWork = true; + performSyncWorkOnRoot(root); + } catch (error) { + // Collect errors so we can rethrow them at the end + if (errors === null) { + errors = [error]; + } else { + errors.push(error); + } + } + } + } + + root = root.next; + } + } while (didPerformSomeWork); + + isFlushingWork = false; // If any errors were thrown, rethrow them right before exiting. + // TODO: Consider returning these to the caller, to allow them to decide + // how/when to rethrow. + + if (errors !== null) { + if (errors.length > 1) { + if (typeof AggregateError === "function") { + // eslint-disable-next-line no-undef + throw new AggregateError(errors); + } else { + for (var i = 1; i < errors.length; i++) { + scheduleImmediateTask(throwError.bind(null, errors[i])); + } + + var firstError = errors[0]; + throw firstError; + } + } else { + var error = errors[0]; + throw error; + } + } +} + +function throwError(error) { + throw error; +} + +function processRootScheduleInMicrotask() { + // This function is always called inside a microtask. It should never be + // called synchronously. + didScheduleMicrotask = false; + + { + didScheduleMicrotask_act = false; + } // We'll recompute this as we iterate through all the roots and schedule them. + + mightHavePendingSyncWork = false; + var currentTime = now$1(); + var prev = null; + var root = firstScheduledRoot; + + while (root !== null) { + var next = root.next; + var nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + + if (nextLanes === NoLane) { + // This root has no more pending work. Remove it from the schedule. To + // guard against subtle reentrancy bugs, this microtask is the only place + // we do this — you can add roots to the schedule whenever, but you can + // only remove them here. + // Null this out so we know it's been removed from the schedule. + root.next = null; + + if (prev === null) { + // This is the new head of the list + firstScheduledRoot = next; + } else { + prev.next = next; + } + + if (next === null) { + // This is the new tail of the list + lastScheduledRoot = prev; + } + } else { + // This root still has work. Keep it in the list. + prev = root; + + if (includesSyncLane(nextLanes)) { + mightHavePendingSyncWork = true; + } + } + + root = next; + } // At the end of the microtask, flush any pending synchronous work. This has + // to come at the end, because it does actual rendering work that might throw. + + flushSyncWorkOnAllRoots(); +} + +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + // This function is always called inside a microtask, or at the very end of a + // rendering task right before we yield to the main thread. It should never be + // called synchronously. + // + // TODO: Unless enableDeferRootSchedulingToMicrotask is off. We need to land + // that ASAP to unblock additional features we have planned. + // + // This function also never performs React work synchronously; it should + // only schedule work to be performed later, in a separate task or microtask. + // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + var existingCallbackNode = root.callbackNode; + + if ( + nextLanes === NoLanes || // If this root is currently suspended and waiting for data to resolve, don't + // schedule a task to render it. We'll either wait for a ping, or wait to + // receive an update. + (isWorkLoopSuspendedOnData() && root === workInProgressRoot) || // We should only interrupt a pending commit if the new update + // is urgent. + (root.cancelPendingCommit !== null && includesOnlyNonUrgentLanes(nextLanes)) + ) { + // Fast path: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackNode = null; + root.callbackPriority = NoLane; + return NoLane; + } // Schedule a new callback in the host environment. + + if (includesSyncLane(nextLanes)) { + // Synchronous work is always flushed at the end of the microtask, so we + // don't need to schedule an additional task. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackPriority = SyncLane; + root.callbackNode = null; + return SyncLane; + } else { + // We use the highest priority lane to represent the priority of the callback. + var existingCallbackPriority = root.callbackPriority; + var newCallbackPriority = getHighestPriorityLane(nextLanes); + + if ( + newCallbackPriority === existingCallbackPriority && // Special case related to `act`. If the currently scheduled task is a + // Scheduler task, rather than an `act` task, cancel it and re-schedule + // on the `act` queue. + !( + ReactCurrentActQueue$1.current !== null && + existingCallbackNode !== fakeActCallbackNode$1 + ) + ) { + // The priority hasn't changed. We can reuse the existing task. + return newCallbackPriority; + } else { + // Cancel the existing callback. We'll schedule a new one below. + cancelCallback(existingCallbackNode); + } + + var schedulerPriorityLevel; + + switch (lanesToEventPriority(nextLanes)) { + case DiscreteEventPriority: + schedulerPriorityLevel = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriorityLevel = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriorityLevel = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority$1; + break; + } + + var newCallbackNode = scheduleCallback$1( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) + ); + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; + return newCallbackPriority; + } +} + +function getContinuationForRoot(root, originalCallbackNode) { + // This is called at the end of `performConcurrentWorkOnRoot` to determine + // if we need to schedule a continuation task. + // + // Usually `scheduleTaskForRootDuringMicrotask` only runs inside a microtask; + // however, since most of the logic for determining if we need a continuation + // versus a new task is the same, we cheat a bit and call it here. This is + // only safe to do because we know we're at the end of the browser task. + // So although it's not an actual microtask, it might as well be. + scheduleTaskForRootDuringMicrotask(root, now$1()); + + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } + + return null; +} +var fakeActCallbackNode$1 = {}; + +function scheduleCallback$1(priorityLevel, callback) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: We're inside an `act` scope (a testing utility). + // Instead of scheduling work in the host environment, add it to a + // fake internal queue that's managed by the `act` implementation. + ReactCurrentActQueue$1.current.push(callback); + return fakeActCallbackNode$1; + } else { + return scheduleCallback$3(priorityLevel, callback); + } +} + +function cancelCallback(callbackNode) { + if (callbackNode === fakeActCallbackNode$1); + else if (callbackNode !== null) { + cancelCallback$1(callbackNode); + } +} + +function scheduleImmediateTask(cb) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: Inside an `act` scope, we push microtasks to the fake `act` + // callback queue. This is because we currently support calling `act` + // without awaiting the result. The plan is to deprecate that, and require + // that you always await the result so that the microtasks have a chance to + // run. But it hasn't happened yet. + ReactCurrentActQueue$1.current.push(function () { + cb(); + return null; + }); + } // TODO: Can we land supportsMicrotasks? Which environments don't support it? + // Alternatively, can we move this check to the host config? + + { + // If microtasks are not supported, use Scheduler. + scheduleCallback$3(ImmediatePriority, cb); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -20234,6 +20500,9 @@ function getWorkInProgressRoot() { function getWorkInProgressRootRenderLanes() { return workInProgressRootRenderLanes; } +function isWorkLoopSuspendedOnData() { + return workInProgressSuspendedReason === SuspendedOnData; +} function requestEventTime() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. @@ -20391,21 +20660,25 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); if ( lane === SyncLane && executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue.isBatchingLegacy + (fiber.mode & ConcurrentMode) === NoMode ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + if (ReactCurrentActQueue.isBatchingLegacy) { + // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } else { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncWorkOnLegacyRootsOnly(); + } } } } @@ -20413,147 +20686,6 @@ function isUnsafeClassRenderPhaseUpdate(fiber) { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return (executionContext & RenderContext) !== NoContext; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. - -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. - - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. - - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. - if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); - } - - root.callbackNode = null; - root.callbackPriority = NoLane; - return; - } // If this root is currently suspended and waiting for data to resolve, don't - // schedule a task to render it. We'll either wait for a ping, or wait to - // receive an update. - - if ( - workInProgressSuspendedReason === SuspendedOnData && - workInProgressRoot === root - ) { - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - - var cancelPendingCommit = root.cancelPendingCommit; - - if (cancelPendingCommit !== null) { - // We should only interrupt a pending commit if the new update - // is urgent. - if (includesOnlyNonUrgentLanes(nextLanes)) { - // The new update is not urgent. Don't interrupt the pending commit. - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - } // We use the highest priority lane to represent the priority of the callback. - - var newCallbackPriority = getHighestPriorityLane(nextLanes); // Check if there's an existing task. We may be able to reuse it. - - var existingCallbackPriority = root.callbackPriority; - - if ( - existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a - // Scheduler task, rather than an `act` task, cancel it and re-scheduled - // on the `act` queue. - !( - ReactCurrentActQueue.current !== null && - existingCallbackNode !== fakeActCallbackNode - ) - ) { - { - // 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 && - !includesSyncLane(existingCallbackPriority) - ) { - 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. - - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. - cancelCallback(existingCallbackNode); - } // Schedule a new callback. - - var newCallbackNode; - - if (includesSyncLane(newCallbackPriority)) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue.isBatchingLegacy !== null) { - ReactCurrentActQueue.didScheduleLegacyUpdate = true; - } - - scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } - - { - // Flush the queue in an Immediate task. - scheduleCallback(ImmediatePriority, flushSyncCallbacks); - } - - newCallbackNode = null; - } else { - var schedulerPriorityLevel; - - switch (lanesToEventPriority(nextLanes)) { - case DiscreteEventPriority: - schedulerPriorityLevel = ImmediatePriority; - break; - - case ContinuousEventPriority: - schedulerPriorityLevel = UserBlockingPriority; - break; - - case DefaultEventPriority: - schedulerPriorityLevel = NormalPriority$1; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority$1; - break; - } - - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. @@ -20585,6 +20717,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } // Determine the next lanes to work on, using the fields stored // on the root. + // TODO: This was already computed in the caller. Pass it as an argument. var lanes = getNextLanes( root, @@ -20635,7 +20768,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -20685,7 +20818,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var _fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw _fatalError; } // FIXME: Need to check for RootDidNotComplete again. The factoring here // isn't ideal. @@ -20698,15 +20831,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } - ensureRootIsScheduled(root, now$1()); - - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); - } - - return null; + ensureRootIsScheduled(root); + return getContinuationForRoot(root, originalCallbackNode); } function recoverFromConcurrentError( @@ -21064,12 +21190,13 @@ function performSyncWorkOnRoot(root) { throw new Error("Should not already be working."); } - flushPassiveEffects(); + flushPassiveEffects(); // TODO: This was already computed in the caller. Pass it as an argument. + var lanes = getNextLanes(root, NoLanes); if (!includesSyncLane(lanes)) { // There's no remaining sync work left. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } @@ -21100,7 +21227,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -21109,7 +21236,7 @@ function performSyncWorkOnRoot(root) { // cases where need to exit the current render without producing a // consistent tree or committing. markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -21124,7 +21251,7 @@ function performSyncWorkOnRoot(root) { ); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } function getExecutionContext() { @@ -21145,7 +21272,7 @@ function batchedUpdates(fn, a) { !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + flushSyncWorkOnLegacyRootsOnly(); } } } @@ -21187,7 +21314,7 @@ function flushSync(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -21644,7 +21771,7 @@ function renderRootConcurrent(root, lanes) { // currently working on a different root, so that we resume // rendering later. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; thenable.then(onResolution, onResolution); @@ -22354,7 +22481,7 @@ function commitRootImpl( onCommitRoot(finishedWork.stateNode, renderPriorityLevel); // additional work on this root is scheduled. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without @@ -22407,7 +22534,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); return null; } @@ -22547,7 +22674,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { // If additional passive effects were scheduled, increment a counter. If this @@ -22609,7 +22736,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -22648,7 +22775,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -22717,7 +22844,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -22753,7 +22879,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -22772,7 +22898,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -23076,19 +23202,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } } } -function cancelCallback(callbackNode) { - if (callbackNode === fakeActCallbackNode) { - return; - } // In production, always call Scheduler. This function will be stripped out. - - return cancelCallback$1(callbackNode); -} - function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. return ReactCurrentActQueue.current !== null; @@ -24249,6 +24367,7 @@ function FiberRootNode( this.cancelPendingCommit = null; this.context = null; this.pendingContext = null; + this.next = null; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); @@ -24356,7 +24475,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-5850fc2e"; +var ReactVersion = "18.3.0-www-classic-23a94cba"; // Might add PROFILE later. diff --git a/compiled/facebook-www/ReactTestRenderer-dev.modern.js b/compiled/facebook-www/ReactTestRenderer-dev.modern.js index a7c965bb58..228e97c19c 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.modern.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.modern.js @@ -840,7 +840,7 @@ function isArray(a) { } // This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$2 = Scheduler$1.unstable_scheduleCallback; +var scheduleCallback$3 = Scheduler$1.unstable_scheduleCallback; var cancelCallback$1 = Scheduler$1.unstable_cancelCallback; var shouldYield = Scheduler$1.unstable_shouldYield; var requestPaint = Scheduler$1.unstable_requestPaint; @@ -2861,102 +2861,6 @@ function is(x, y) { var objectIs = typeof Object.is === "function" ? Object.is : is; // $FlowFixMe[method-unbinding] -var syncQueue = null; -var includesLegacySyncCallbacks = false; -var isFlushingSyncQueue = false; -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]; - } 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 scheduleLegacySyncCallback(callback) { - includesLegacySyncCallbacks = true; - scheduleSyncCallback(callback); -} -function flushSyncCallbacksOnlyInLegacyMode() { - // Only flushes the queue if there's a legacy sync callback scheduled. - // TODO: There's only a single type of callback: performSyncOnWorkOnRoot. So - // it might make more sense for the queue to be a list of roots instead of a - // list of generic callbacks. Then we can have two: one for legacy roots, one - // for concurrent roots. And this method would only flush the legacy ones. - if (includesLegacySyncCallbacks) { - flushSyncCallbacks(); - } -} -function flushSyncCallbacks() { - if (!isFlushingSyncQueue && syncQueue !== null) { - // Prevent re-entrance. - isFlushingSyncQueue = true; // Set the event priority to discrete - // TODO: Is this necessary anymore? The only user code that runs in this - // queue is in the render or commit phases, which already set the - // event priority. Should be able to remove. - - var previousUpdatePriority = getCurrentUpdatePriority(); - setCurrentUpdatePriority(DiscreteEventPriority); - var errors = null; - var queue = syncQueue; // $FlowFixMe[incompatible-use] found when upgrading Flow - - for (var i = 0; i < queue.length; i++) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - var callback = queue[i]; - - try { - do { - var isSync = true; // $FlowFixMe[incompatible-type] we bail out when we get a null - - callback = callback(isSync); - } while (callback !== null); - } catch (error) { - // Collect errors so we can rethrow them at the end - if (errors === null) { - errors = [error]; - } else { - errors.push(error); - } - } - } - - syncQueue = null; - includesLegacySyncCallbacks = false; - setCurrentUpdatePriority(previousUpdatePriority); - isFlushingSyncQueue = false; - - if (errors !== null) { - if (errors.length > 1) { - if (typeof AggregateError === "function") { - // eslint-disable-next-line no-undef - throw new AggregateError(errors); - } else { - for (var _i = 1; _i < errors.length; _i++) { - scheduleCallback$2( - ImmediatePriority, - throwError.bind(null, errors[_i]) - ); - } - - var firstError = errors[0]; - throw firstError; - } - } else { - var error = errors[0]; - throw error; - } - } - } - - return null; -} - -function throwError(error) { - throw error; -} - // This is imported by the event replaying implementation in React DOM. It's // in a separate file to break a circular dependency between the renderer and // the reconciler. @@ -4427,7 +4331,7 @@ function checkPropStringCoercion(value, propName) { } } -var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we +var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; // An error that is thrown (e.g. by `use`) to trigger Suspense. If we // detect this is caught by userspace, we'll log a warning in development. var SuspenseException = new Error( @@ -4463,8 +4367,8 @@ function isThenableResolved(thenable) { function noop() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactCurrentActQueue$2.current !== null) { - ReactCurrentActQueue$2.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var previous = thenableState[index]; @@ -14850,7 +14754,7 @@ var AbortControllerLocal = }; // Intentionally not named imports because Rollup would // use dynamic dispatch for CommonJS interop named imports. -var scheduleCallback$1 = Scheduler$1.unstable_scheduleCallback, +var scheduleCallback$2 = Scheduler$1.unstable_scheduleCallback, NormalPriority = Scheduler$1.unstable_NormalPriority; var CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -14906,7 +14810,7 @@ function releaseCache(cache) { } if (cache.refCount === 0) { - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -20069,7 +19973,7 @@ if (typeof Symbol === "function" && Symbol.for) { symbolFor("selector.text"); } -var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; +var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -20094,7 +19998,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -20107,6 +20011,368 @@ function isConcurrentActEnvironment() { } } +var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, +// there's only a single root, but we do support multi root apps, hence this +// extra complexity. But this module is optimized for the single root case. + +var firstScheduledRoot = null; +var lastScheduledRoot = null; // Used to prevent redundant mircotasks from being scheduled. + +var didScheduleMicrotask = false; // `act` "microtasks" are scheduled on the `act` queue instead of an actual +// microtask, so we have to dedupe those separately. This wouldn't be an issue +// if we required all `act` calls to be awaited, which we might in the future. + +var didScheduleMicrotask_act = false; // Used to quickly bail out of flushSync if there's no sync work to do. + +var mightHavePendingSyncWork = false; +var isFlushingWork = false; +function ensureRootIsScheduled(root) { + // This function is called whenever a root receives an update. It does two + // things 1) it ensures the root is in the root schedule, and 2) it ensures + // there's a pending microtask to process the root schedule. + // + // Most of the actual scheduling logic does not happen until + // `scheduleTaskForRootDuringMicrotask` runs. + // Add the root to the schedule + if (root === lastScheduledRoot || root.next !== null); + else { + if (lastScheduledRoot === null) { + firstScheduledRoot = lastScheduledRoot = root; + } else { + lastScheduledRoot.next = root; + lastScheduledRoot = root; + } + } // Any time a root received an update, we set this to true until the next time + // we process the schedule. If it's false, then we can quickly exit flushSync + // without consulting the schedule. + + mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure + // there's a task scheduled for each one at the correct priority. + + if (ReactCurrentActQueue$1.current !== null) { + // We're inside an `act` scope. + if (!didScheduleMicrotask_act) { + didScheduleMicrotask_act = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } else { + if (!didScheduleMicrotask) { + didScheduleMicrotask = true; + scheduleImmediateTask(processRootScheduleInMicrotask); + } + } +} +function flushSyncWorkOnAllRoots() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(false); +} +function flushSyncWorkOnLegacyRootsOnly() { + // This is allowed to be called synchronously, but the caller should check + // the execution context first. + flushSyncWorkAcrossRoots_impl(true); +} + +function flushSyncWorkAcrossRoots_impl(onlyLegacy) { + if (isFlushingWork) { + // Prevent reentrancy. + // TODO: Is this overly defensive? The callers must check the execution + // context first regardless. + return; + } + + if (!mightHavePendingSyncWork) { + // Fast path. There's no sync work to do. + return; + } + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); // There may or may not be synchronous work scheduled. Let's check. + + var didPerformSomeWork; + var errors = null; + isFlushingWork = true; + + do { + didPerformSomeWork = false; + var root = firstScheduledRoot; + + while (root !== null) { + if (onlyLegacy && root.tag !== LegacyRoot); + else { + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + + if (includesSyncLane(nextLanes)) { + // This root has pending sync work. Flush it now. + try { + // TODO: Pass nextLanes as an argument instead of computing it again + // inside performSyncWorkOnRoot. + didPerformSomeWork = true; + performSyncWorkOnRoot(root); + } catch (error) { + // Collect errors so we can rethrow them at the end + if (errors === null) { + errors = [error]; + } else { + errors.push(error); + } + } + } + } + + root = root.next; + } + } while (didPerformSomeWork); + + isFlushingWork = false; // If any errors were thrown, rethrow them right before exiting. + // TODO: Consider returning these to the caller, to allow them to decide + // how/when to rethrow. + + if (errors !== null) { + if (errors.length > 1) { + if (typeof AggregateError === "function") { + // eslint-disable-next-line no-undef + throw new AggregateError(errors); + } else { + for (var i = 1; i < errors.length; i++) { + scheduleImmediateTask(throwError.bind(null, errors[i])); + } + + var firstError = errors[0]; + throw firstError; + } + } else { + var error = errors[0]; + throw error; + } + } +} + +function throwError(error) { + throw error; +} + +function processRootScheduleInMicrotask() { + // This function is always called inside a microtask. It should never be + // called synchronously. + didScheduleMicrotask = false; + + { + didScheduleMicrotask_act = false; + } // We'll recompute this as we iterate through all the roots and schedule them. + + mightHavePendingSyncWork = false; + var currentTime = now$1(); + var prev = null; + var root = firstScheduledRoot; + + while (root !== null) { + var next = root.next; + var nextLanes = scheduleTaskForRootDuringMicrotask(root, currentTime); + + if (nextLanes === NoLane) { + // This root has no more pending work. Remove it from the schedule. To + // guard against subtle reentrancy bugs, this microtask is the only place + // we do this — you can add roots to the schedule whenever, but you can + // only remove them here. + // Null this out so we know it's been removed from the schedule. + root.next = null; + + if (prev === null) { + // This is the new head of the list + firstScheduledRoot = next; + } else { + prev.next = next; + } + + if (next === null) { + // This is the new tail of the list + lastScheduledRoot = prev; + } + } else { + // This root still has work. Keep it in the list. + prev = root; + + if (includesSyncLane(nextLanes)) { + mightHavePendingSyncWork = true; + } + } + + root = next; + } // At the end of the microtask, flush any pending synchronous work. This has + // to come at the end, because it does actual rendering work that might throw. + + flushSyncWorkOnAllRoots(); +} + +function scheduleTaskForRootDuringMicrotask(root, currentTime) { + // This function is always called inside a microtask, or at the very end of a + // rendering task right before we yield to the main thread. It should never be + // called synchronously. + // + // TODO: Unless enableDeferRootSchedulingToMicrotask is off. We need to land + // that ASAP to unblock additional features we have planned. + // + // This function also never performs React work synchronously; it should + // only schedule work to be performed later, in a separate task or microtask. + // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var workInProgressRoot = getWorkInProgressRoot(); + var workInProgressRootRenderLanes = getWorkInProgressRootRenderLanes(); + var nextLanes = getNextLanes( + root, + root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes + ); + var existingCallbackNode = root.callbackNode; + + if ( + nextLanes === NoLanes || // If this root is currently suspended and waiting for data to resolve, don't + // schedule a task to render it. We'll either wait for a ping, or wait to + // receive an update. + (isWorkLoopSuspendedOnData() && root === workInProgressRoot) || // We should only interrupt a pending commit if the new update + // is urgent. + (root.cancelPendingCommit !== null && includesOnlyNonUrgentLanes(nextLanes)) + ) { + // Fast path: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackNode = null; + root.callbackPriority = NoLane; + return NoLane; + } // Schedule a new callback in the host environment. + + if (includesSyncLane(nextLanes)) { + // Synchronous work is always flushed at the end of the microtask, so we + // don't need to schedule an additional task. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + + root.callbackPriority = SyncLane; + root.callbackNode = null; + return SyncLane; + } else { + // We use the highest priority lane to represent the priority of the callback. + var existingCallbackPriority = root.callbackPriority; + var newCallbackPriority = getHighestPriorityLane(nextLanes); + + if ( + newCallbackPriority === existingCallbackPriority && // Special case related to `act`. If the currently scheduled task is a + // Scheduler task, rather than an `act` task, cancel it and re-schedule + // on the `act` queue. + !( + ReactCurrentActQueue$1.current !== null && + existingCallbackNode !== fakeActCallbackNode$1 + ) + ) { + // The priority hasn't changed. We can reuse the existing task. + return newCallbackPriority; + } else { + // Cancel the existing callback. We'll schedule a new one below. + cancelCallback(existingCallbackNode); + } + + var schedulerPriorityLevel; + + switch (lanesToEventPriority(nextLanes)) { + case DiscreteEventPriority: + schedulerPriorityLevel = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriorityLevel = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriorityLevel = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority$1; + break; + } + + var newCallbackNode = scheduleCallback$1( + schedulerPriorityLevel, + performConcurrentWorkOnRoot.bind(null, root) + ); + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; + return newCallbackPriority; + } +} + +function getContinuationForRoot(root, originalCallbackNode) { + // This is called at the end of `performConcurrentWorkOnRoot` to determine + // if we need to schedule a continuation task. + // + // Usually `scheduleTaskForRootDuringMicrotask` only runs inside a microtask; + // however, since most of the logic for determining if we need a continuation + // versus a new task is the same, we cheat a bit and call it here. This is + // only safe to do because we know we're at the end of the browser task. + // So although it's not an actual microtask, it might as well be. + scheduleTaskForRootDuringMicrotask(root, now$1()); + + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } + + return null; +} +var fakeActCallbackNode$1 = {}; + +function scheduleCallback$1(priorityLevel, callback) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: We're inside an `act` scope (a testing utility). + // Instead of scheduling work in the host environment, add it to a + // fake internal queue that's managed by the `act` implementation. + ReactCurrentActQueue$1.current.push(callback); + return fakeActCallbackNode$1; + } else { + return scheduleCallback$3(priorityLevel, callback); + } +} + +function cancelCallback(callbackNode) { + if (callbackNode === fakeActCallbackNode$1); + else if (callbackNode !== null) { + cancelCallback$1(callbackNode); + } +} + +function scheduleImmediateTask(cb) { + if (ReactCurrentActQueue$1.current !== null) { + // Special case: Inside an `act` scope, we push microtasks to the fake `act` + // callback queue. This is because we currently support calling `act` + // without awaiting the result. The plan is to deprecate that, and require + // that you always await the result so that the microtasks have a chance to + // run. But it hasn't happened yet. + ReactCurrentActQueue$1.current.push(function () { + cb(); + return null; + }); + } // TODO: Can we land supportsMicrotasks? Which environments don't support it? + // Alternatively, can we move this check to the host config? + + { + // If microtasks are not supported, use Scheduler. + scheduleCallback$3(ImmediatePriority, cb); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -20234,6 +20500,9 @@ function getWorkInProgressRoot() { function getWorkInProgressRootRenderLanes() { return workInProgressRootRenderLanes; } +function isWorkLoopSuspendedOnData() { + return workInProgressSuspendedReason === SuspendedOnData; +} function requestEventTime() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. @@ -20391,21 +20660,25 @@ function scheduleUpdateOnFiber(root, fiber, lane, eventTime) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); if ( lane === SyncLane && executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue.isBatchingLegacy + (fiber.mode & ConcurrentMode) === NoMode ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + if (ReactCurrentActQueue.isBatchingLegacy) { + // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } else { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncWorkOnLegacyRootsOnly(); + } } } } @@ -20413,147 +20686,6 @@ function isUnsafeClassRenderPhaseUpdate(fiber) { // Check if this is a render phase update. Only called by class components, // which special (deprecated) behavior for UNSAFE_componentWillReceive props. return (executionContext & RenderContext) !== NoContext; -} // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. - -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. - - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. - - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. - if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); - } - - root.callbackNode = null; - root.callbackPriority = NoLane; - return; - } // If this root is currently suspended and waiting for data to resolve, don't - // schedule a task to render it. We'll either wait for a ping, or wait to - // receive an update. - - if ( - workInProgressSuspendedReason === SuspendedOnData && - workInProgressRoot === root - ) { - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - - var cancelPendingCommit = root.cancelPendingCommit; - - if (cancelPendingCommit !== null) { - // We should only interrupt a pending commit if the new update - // is urgent. - if (includesOnlyNonUrgentLanes(nextLanes)) { - // The new update is not urgent. Don't interrupt the pending commit. - root.callbackPriority = NoLane; - root.callbackNode = null; - return; - } - } // We use the highest priority lane to represent the priority of the callback. - - var newCallbackPriority = getHighestPriorityLane(nextLanes); // Check if there's an existing task. We may be able to reuse it. - - var existingCallbackPriority = root.callbackPriority; - - if ( - existingCallbackPriority === newCallbackPriority && // Special case related to `act`. If the currently scheduled task is a - // Scheduler task, rather than an `act` task, cancel it and re-scheduled - // on the `act` queue. - !( - ReactCurrentActQueue.current !== null && - existingCallbackNode !== fakeActCallbackNode - ) - ) { - { - // 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 && - !includesSyncLane(existingCallbackPriority) - ) { - 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. - - return; - } - - if (existingCallbackNode != null) { - // Cancel the existing callback. We'll schedule a new one below. - cancelCallback(existingCallbackNode); - } // Schedule a new callback. - - var newCallbackNode; - - if (includesSyncLane(newCallbackPriority)) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue.isBatchingLegacy !== null) { - ReactCurrentActQueue.didScheduleLegacyUpdate = true; - } - - scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); - } else { - scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); - } - - { - // Flush the queue in an Immediate task. - scheduleCallback(ImmediatePriority, flushSyncCallbacks); - } - - newCallbackNode = null; - } else { - var schedulerPriorityLevel; - - switch (lanesToEventPriority(nextLanes)) { - case DiscreteEventPriority: - schedulerPriorityLevel = ImmediatePriority; - break; - - case ContinuousEventPriority: - schedulerPriorityLevel = UserBlockingPriority; - break; - - case DefaultEventPriority: - schedulerPriorityLevel = NormalPriority$1; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority$1; - break; - } - - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. @@ -20585,6 +20717,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } // Determine the next lanes to work on, using the fields stored // on the root. + // TODO: This was already computed in the caller. Pass it as an argument. var lanes = getNextLanes( root, @@ -20635,7 +20768,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -20685,7 +20818,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var _fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw _fatalError; } // FIXME: Need to check for RootDidNotComplete again. The factoring here // isn't ideal. @@ -20698,15 +20831,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } } - ensureRootIsScheduled(root, now$1()); - - if (root.callbackNode === originalCallbackNode) { - // The task node scheduled for this root is the same one that's - // currently executed. Need to return a continuation. - return performConcurrentWorkOnRoot.bind(null, root); - } - - return null; + ensureRootIsScheduled(root); + return getContinuationForRoot(root, originalCallbackNode); } function recoverFromConcurrentError( @@ -21064,12 +21190,13 @@ function performSyncWorkOnRoot(root) { throw new Error("Should not already be working."); } - flushPassiveEffects(); + flushPassiveEffects(); // TODO: This was already computed in the caller. Pass it as an argument. + var lanes = getNextLanes(root, NoLanes); if (!includesSyncLane(lanes)) { // There's no remaining sync work left. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } @@ -21100,7 +21227,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -21109,7 +21236,7 @@ function performSyncWorkOnRoot(root) { // cases where need to exit the current render without producing a // consistent tree or committing. markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -21124,7 +21251,7 @@ function performSyncWorkOnRoot(root) { ); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); return null; } function getExecutionContext() { @@ -21145,7 +21272,7 @@ function batchedUpdates(fn, a) { !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + flushSyncWorkOnLegacyRootsOnly(); } } } @@ -21187,7 +21314,7 @@ function flushSync(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -21644,7 +21771,7 @@ function renderRootConcurrent(root, lanes) { // currently working on a different root, so that we resume // rendering later. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; thenable.then(onResolution, onResolution); @@ -22354,7 +22481,7 @@ function commitRootImpl( onCommitRoot(finishedWork.stateNode, renderPriorityLevel); // additional work on this root is scheduled. - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without @@ -22407,7 +22534,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); return null; } @@ -22547,7 +22674,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { // If additional passive effects were scheduled, increment a counter. If this @@ -22609,7 +22736,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -22648,7 +22775,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -22717,7 +22844,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -22753,7 +22879,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -22772,7 +22898,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -23076,19 +23202,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } } } -function cancelCallback(callbackNode) { - if (callbackNode === fakeActCallbackNode) { - return; - } // In production, always call Scheduler. This function will be stripped out. - - return cancelCallback$1(callbackNode); -} - function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. return ReactCurrentActQueue.current !== null; @@ -24249,6 +24367,7 @@ function FiberRootNode( this.cancelPendingCommit = null; this.context = null; this.pendingContext = null; + this.next = null; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); @@ -24356,7 +24475,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-0aab03f8"; +var ReactVersion = "18.3.0-www-modern-4b52f385"; // Might add PROFILE later. diff --git a/compiled/facebook-www/WARNINGS b/compiled/facebook-www/WARNINGS index 28c479ee44..8761170ba0 100644 --- a/compiled/facebook-www/WARNINGS +++ b/compiled/facebook-www/WARNINGS @@ -145,7 +145,6 @@ "Expected currently replaying event to be null. This error is likely caused by a bug in React. Please file an issue." "Expected currently replaying event to not be null. This error is likely caused by a bug in React. Please file an issue." "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." -"Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue." "Expected server HTML to contain a matching <%s> in <%s>." "Expected server HTML to contain a matching text node for \"%s\" in <%s>." "Expected to be hydrating. This is a bug in React. Please file an issue."