From ee546aa020d51649d088c1934790800401e47614 Mon Sep 17 00:00:00 2001 From: acdlite Date: Fri, 31 Mar 2023 17:09:09 +0000 Subject: [PATCH] Move update scheduling to microtask (#26512) When React receives new input (via `setState`, a Suspense promise resolution, and so on), it needs to ensure there's a rendering task associated with the update. Most of this happens `ensureRootIsScheduled`. If a single event contains multiple updates, we end up running the scheduling code once per update. But this is wasteful because we really only need to run it once, at the end of the event (or in the case of flushSync, at the end of the scope function's execution). So this PR moves the scheduling logic to happen in a microtask instead. In some cases, we will force it run earlier than that, like for `flushSync`, but since updates are batched by default, it will almost always happen in the microtask. Even for discrete updates. In production, this should have no observable behavior difference. In a testing environment that uses `act`, this should also not have a behavior difference because React will push these tasks to an internal `act` queue. However, tests that do not use `act` and do not simulate an actual production environment (like an e2e test) may be affected. For example, before this change, if a test were to call `setState` outside of `act` and then immediately call `jest.runAllTimers()`, the update would be synchronously applied. After this change, that will no longer work because the rendering task (a timer, in this case) isn't scheduled until after the microtask queue has run. I don't expect this to be an issue in practice because most people do not write their tests this way. They either use `act`, or they write e2e-style tests. The biggest exception has been... our own internal test suite. Until recently, many of our tests were written in a way that accidentally relied on the updates being scheduled synchronously. Over the past few weeks, @tyao1 and I have gradually converted the test suite to use a new set of testing helpers that are resilient to this implementation detail. (There are also some old Relay tests that were written in the style of React's internal test suite. Those will need to be fixed, too.) The larger motivation behind this change, aside from a minor performance improvement, is we intend to use this new microtask to perform additional logic that doesn't yet exist. Like inferring the priority of a custom event. DiffTrain build for commit https://github.com/facebook/react/commit/09c8d2563300621dc91258a4c2839210e2fbdf0e. --- .../cjs/ReactTestRenderer-dev.js | 703 ++++++++++------- .../cjs/ReactTestRenderer-prod.js | 618 ++++++++------- .../cjs/ReactTestRenderer-profiling.js | 680 +++++++++-------- .../RKJSModules/vendor/react/cjs/React-dev.js | 2 +- .../vendor/react/cjs/React-prod.js | 2 +- .../vendor/react/cjs/React-profiling.js | 2 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 711 +++++++++++------- .../implementations/ReactFabric-prod.fb.js | 566 +++++++------- .../ReactFabric-profiling.fb.js | 614 ++++++++------- .../ReactNativeRenderer-dev.fb.js | 711 +++++++++++------- .../ReactNativeRenderer-prod.fb.js | 568 +++++++------- .../ReactNativeRenderer-profiling.fb.js | 616 ++++++++------- 13 files changed, 3202 insertions(+), 2593 deletions(-) diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js index c4d9a6e6ca..046ac02cc9 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -835,7 +835,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; @@ -2611,102 +2611,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. @@ -4180,7 +4084,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( @@ -4216,8 +4120,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]; @@ -14341,7 +14245,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, @@ -14397,7 +14301,7 @@ function releaseCache(cache) { } if (cache.refCount === 0) { - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -19477,7 +19381,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 @@ -19502,7 +19406,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -19515,6 +19419,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, @@ -19642,6 +19908,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. @@ -19799,21 +20068,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(); + } } } } @@ -19821,147 +20094,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. @@ -19993,6 +20125,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, @@ -20043,7 +20176,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -20093,7 +20226,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. @@ -20106,15 +20239,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( @@ -20472,12 +20598,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; } @@ -20508,7 +20635,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -20517,7 +20644,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. @@ -20532,7 +20659,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() { @@ -20553,7 +20680,7 @@ function batchedUpdates(fn, a) { !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + flushSyncWorkOnLegacyRootsOnly(); } } } @@ -20595,7 +20722,7 @@ function flushSync(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -21052,7 +21179,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); @@ -21762,7 +21889,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 @@ -21815,7 +21942,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); return null; } @@ -21955,7 +22082,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { // If additional passive effects were scheduled, increment a counter. If this @@ -22017,7 +22144,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -22056,7 +22183,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -22125,7 +22252,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -22161,7 +22287,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -22180,7 +22306,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -22484,19 +22610,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; @@ -23647,6 +23765,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); @@ -23746,7 +23865,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-8310854ce-20230331"; +var ReactVersion = "18.3.0-next-09c8d2563-20230331"; // Might add PROFILE later. diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js index 499b94bc9f..37ead37c28 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -277,7 +277,7 @@ function findCurrentHostFiberImpl(node) { return null; } var isArrayImpl = Array.isArray, - scheduleCallback$2 = Scheduler$1.unstable_scheduleCallback, + scheduleCallback$3 = Scheduler$1.unstable_scheduleCallback, cancelCallback$1 = Scheduler$1.unstable_cancelCallback, shouldYield = Scheduler$1.unstable_shouldYield, requestPaint = Scheduler$1.unstable_requestPaint, @@ -672,50 +672,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) { @@ -2170,10 +2127,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$25 = thenableIndexCounter; + var index$23 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$25); + usable = trackUsedThenable(thenableState, usable, index$23); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -4267,7 +4224,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler$1.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler$1.unstable_scheduleCallback, NormalPriority = Scheduler$1.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -4289,7 +4246,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -4334,14 +4291,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$61 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$61 = lastTailNode), + for (var lastTailNode$59 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$59 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$61 + null === lastTailNode$59 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$61.sibling = null); + : (lastTailNode$59.sibling = null); } } function bubbleProperties(completedWork) { @@ -4351,19 +4308,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$62 = completedWork.child; null !== child$62; ) - (newChildLanes |= child$62.lanes | child$62.childLanes), - (subtreeFlags |= child$62.subtreeFlags & 31457280), - (subtreeFlags |= child$62.flags & 31457280), - (child$62.return = completedWork), - (child$62 = child$62.sibling); + for (var child$60 = completedWork.child; null !== child$60; ) + (newChildLanes |= child$60.lanes | child$60.childLanes), + (subtreeFlags |= child$60.subtreeFlags & 31457280), + (subtreeFlags |= child$60.flags & 31457280), + (child$60.return = completedWork), + (child$60 = child$60.sibling); else - for (child$62 = completedWork.child; null !== child$62; ) - (newChildLanes |= child$62.lanes | child$62.childLanes), - (subtreeFlags |= child$62.subtreeFlags), - (subtreeFlags |= child$62.flags), - (child$62.return = completedWork), - (child$62 = child$62.sibling); + for (child$60 = completedWork.child; null !== child$60; ) + (newChildLanes |= child$60.lanes | child$60.childLanes), + (subtreeFlags |= child$60.subtreeFlags), + (subtreeFlags |= child$60.flags), + (child$60.return = completedWork), + (child$60 = child$60.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -4527,11 +4484,11 @@ function completeWork(current, workInProgress, renderLanes) { null !== newProps.alternate.memoizedState && null !== newProps.alternate.memoizedState.cachePool && (index = newProps.alternate.memoizedState.cachePool.pool); - var cache$66 = null; + var cache$64 = null; null !== newProps.memoizedState && null !== newProps.memoizedState.cachePool && - (cache$66 = newProps.memoizedState.cachePool.pool); - cache$66 !== index && (newProps.flags |= 2048); + (cache$64 = newProps.memoizedState.cachePool.pool); + cache$64 !== index && (newProps.flags |= 2048); } renderLanes !== current && renderLanes && @@ -4558,8 +4515,8 @@ function completeWork(current, workInProgress, renderLanes) { index = workInProgress.memoizedState; if (null === index) return bubbleProperties(workInProgress), null; newProps = 0 !== (workInProgress.flags & 128); - cache$66 = index.rendering; - if (null === cache$66) + cache$64 = index.rendering; + if (null === cache$64) if (newProps) cutOffTailIfNeeded(index, !1); else { if ( @@ -4567,11 +4524,11 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current && 0 !== (current.flags & 128)) ) for (current = workInProgress.child; null !== current; ) { - cache$66 = findFirstSuspended(current); - if (null !== cache$66) { + cache$64 = findFirstSuspended(current); + if (null !== cache$64) { workInProgress.flags |= 128; cutOffTailIfNeeded(index, !1); - current = cache$66.updateQueue; + current = cache$64.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); workInProgress.subtreeFlags = 0; @@ -4596,7 +4553,7 @@ function completeWork(current, workInProgress, renderLanes) { } else { if (!newProps) - if (((current = findFirstSuspended(cache$66)), null !== current)) { + if (((current = findFirstSuspended(cache$64)), null !== current)) { if ( ((workInProgress.flags |= 128), (newProps = !0), @@ -4606,7 +4563,7 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(index, !0), null === index.tail && "hidden" === index.tailMode && - !cache$66.alternate) + !cache$64.alternate) ) return bubbleProperties(workInProgress), null; } else @@ -4618,13 +4575,13 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(index, !1), (workInProgress.lanes = 8388608)); index.isBackwards - ? ((cache$66.sibling = workInProgress.child), - (workInProgress.child = cache$66)) + ? ((cache$64.sibling = workInProgress.child), + (workInProgress.child = cache$64)) : ((current = index.last), null !== current - ? (current.sibling = cache$66) - : (workInProgress.child = cache$66), - (index.last = cache$66)); + ? (current.sibling = cache$64) + : (workInProgress.child = cache$64), + (index.last = cache$64)); } if (null !== index.tail) return ( @@ -4839,8 +4796,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$82) { - captureCommitPhaseError(current, nearestMountedAncestor, error$82); + } catch (error$80) { + captureCommitPhaseError(current, nearestMountedAncestor, error$80); } else ref.current = null; } @@ -4945,8 +4902,8 @@ function commitHookEffectListMount(flags, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & flags) === flags) { - var create$83 = effect.create; - effect.destroy = create$83(); + var create$81 = effect.create; + effect.destroy = create$81(); } effect = effect.next; } while (effect !== finishedWork); @@ -5000,11 +4957,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$84) { + } catch (error$82) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$84 + error$82 ); } } @@ -5375,8 +5332,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$92) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$92); + } catch (error$90) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$90); } } break; @@ -5416,11 +5373,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null !== current) try { (flags.type = type), (flags.props = existingHiddenCallbacks); - } catch (error$95) { + } catch (error$93) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$95 + error$93 ); } } @@ -5437,8 +5394,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { existingHiddenCallbacks = finishedWork.memoizedProps; try { flags.text = existingHiddenCallbacks; - } catch (error$96) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$96); + } catch (error$94) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$94); } } break; @@ -5470,14 +5427,14 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== current && safelyDetachRef(current, current.return); existingHiddenCallbacks = null !== finishedWork.memoizedState; - var wasHidden$100 = null !== current && null !== current.memoizedState; + var wasHidden$98 = null !== current && null !== current.memoizedState; if (finishedWork.mode & 1) { var prevOffscreenSubtreeIsHidden = offscreenSubtreeIsHidden, prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || existingHiddenCallbacks; offscreenSubtreeWasHidden = - prevOffscreenSubtreeWasHidden || wasHidden$100; + prevOffscreenSubtreeWasHidden || wasHidden$98; recursivelyTraverseMutationEffects(root, finishedWork); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; @@ -5495,22 +5452,22 @@ function commitMutationEffectsOnFiber(finishedWork, root) { existingHiddenCallbacks && ((root = offscreenSubtreeIsHidden || offscreenSubtreeWasHidden), null === current || - wasHidden$100 || + wasHidden$98 || root || (0 !== (finishedWork.mode & 1) && recursivelyTraverseDisappearLayoutEffects(finishedWork))), null === finishedWork.memoizedProps || "manual" !== finishedWork.memoizedProps.mode) ) - a: for (current = null, wasHidden$100 = finishedWork; ; ) { - if (5 === wasHidden$100.tag) { + a: for (current = null, wasHidden$98 = finishedWork; ; ) { + if (5 === wasHidden$98.tag) { if (null === current) { - current = wasHidden$100; + current = wasHidden$98; try { - (type = wasHidden$100.stateNode), + (type = wasHidden$98.stateNode), existingHiddenCallbacks ? (type.isHidden = !0) - : (wasHidden$100.stateNode.isHidden = !1); + : (wasHidden$98.stateNode.isHidden = !1); } catch (error) { captureCommitPhaseError( finishedWork, @@ -5519,42 +5476,42 @@ function commitMutationEffectsOnFiber(finishedWork, root) { ); } } - } else if (6 === wasHidden$100.tag) { + } else if (6 === wasHidden$98.tag) { if (null === current) try { - wasHidden$100.stateNode.isHidden = existingHiddenCallbacks + wasHidden$98.stateNode.isHidden = existingHiddenCallbacks ? !0 : !1; - } catch (error$86) { + } catch (error$84) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$86 + error$84 ); } } else if ( - ((22 !== wasHidden$100.tag && 23 !== wasHidden$100.tag) || - null === wasHidden$100.memoizedState || - wasHidden$100 === finishedWork) && - null !== wasHidden$100.child + ((22 !== wasHidden$98.tag && 23 !== wasHidden$98.tag) || + null === wasHidden$98.memoizedState || + wasHidden$98 === finishedWork) && + null !== wasHidden$98.child ) { - wasHidden$100.child.return = wasHidden$100; - wasHidden$100 = wasHidden$100.child; + wasHidden$98.child.return = wasHidden$98; + wasHidden$98 = wasHidden$98.child; continue; } - if (wasHidden$100 === finishedWork) break a; - for (; null === wasHidden$100.sibling; ) { + if (wasHidden$98 === finishedWork) break a; + for (; null === wasHidden$98.sibling; ) { if ( - null === wasHidden$100.return || - wasHidden$100.return === finishedWork + null === wasHidden$98.return || + wasHidden$98.return === finishedWork ) break a; - current === wasHidden$100 && (current = null); - wasHidden$100 = wasHidden$100.return; + current === wasHidden$98 && (current = null); + wasHidden$98 = wasHidden$98.return; } - current === wasHidden$100 && (current = null); - wasHidden$100.sibling.return = wasHidden$100.return; - wasHidden$100 = wasHidden$100.sibling; + current === wasHidden$98 && (current = null); + wasHidden$98.sibling.return = wasHidden$98.return; + wasHidden$98 = wasHidden$98.sibling; } flags & 4 && ((flags = finishedWork.updateQueue), @@ -5610,12 +5567,12 @@ function commitReconciliationEffects(finishedWork) { break; case 3: case 4: - var parent$87 = JSCompiler_inline_result.stateNode.containerInfo, - before$88 = getHostSibling(finishedWork); + var parent$85 = JSCompiler_inline_result.stateNode.containerInfo, + before$86 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$88, - parent$87 + before$86, + parent$85 ); break; default: @@ -6225,7 +6182,201 @@ 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)); +} +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("Should not already be working."); + 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, @@ -6293,87 +6444,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() + 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) { currentEventTime = -1; @@ -6414,7 +6490,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); @@ -6428,16 +6504,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { exitStatus = renderRootSync(root, lanes); if (2 === exitStatus) { errorRetryLanes = lanes; - var errorRetryLanes$108 = getLanesToRetrySynchronouslyOnError( + var errorRetryLanes$107 = getLanesToRetrySynchronouslyOnError( root, errorRetryLanes ); - 0 !== errorRetryLanes$108 && - ((lanes = errorRetryLanes$108), + 0 !== errorRetryLanes$107 && + ((lanes = errorRetryLanes$107), (exitStatus = recoverFromConcurrentError( root, errorRetryLanes, - errorRetryLanes$108 + errorRetryLanes$107 ))); } if (1 === exitStatus) @@ -6445,7 +6521,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -6498,14 +6574,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if ((lanes & 8388480) === lanes) break; exitStatus = lanes; errorRetryLanes = root.eventTimes; - for (errorRetryLanes$108 = -1; 0 < exitStatus; ) { + for (errorRetryLanes$107 = -1; 0 < exitStatus; ) { var index$2 = 31 - clz32(exitStatus), lane = 1 << index$2; index$2 = errorRetryLanes[index$2]; - index$2 > errorRetryLanes$108 && (errorRetryLanes$108 = index$2); + index$2 > errorRetryLanes$107 && (errorRetryLanes$107 = index$2); exitStatus &= ~lane; } - exitStatus = errorRetryLanes$108; + exitStatus = errorRetryLanes$107; exitStatus = now() - exitStatus; exitStatus = (120 > exitStatus @@ -6557,10 +6633,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, @@ -6653,49 +6732,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 6)) - throw Error("Should not already be working."); - 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 flushSync(fn) { null !== rootWithPendingPassiveEffects && 0 === rootWithPendingPassiveEffects.tag && @@ -6716,7 +6752,7 @@ function flushSync(fn) { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig.transition = prevTransition), (executionContext = prevExecutionContext), - 0 === (executionContext & 6) && flushSyncCallbacks(); + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); } } function resetWorkInProgressStack() { @@ -6842,8 +6878,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$111) { - handleThrow(root, thrownValue$111); + } catch (thrownValue$110) { + handleThrow(root, thrownValue$110); } while (1); resetContextDependencies(); @@ -6893,7 +6929,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -6950,8 +6986,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$113) { - handleThrow(root, thrownValue$113); + } catch (thrownValue$112) { + handleThrow(root, thrownValue$112); } while (1); resetContextDependencies(); @@ -7106,10 +7142,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$31 = offscreenQueue.retryQueue; - null === retryQueue$31 + var retryQueue$29 = offscreenQueue.retryQueue; + null === retryQueue$29 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$31.add(wakeable); + : retryQueue$29.add(wakeable); } } break; @@ -7306,7 +7342,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; @@ -7335,7 +7371,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); return null; } function releaseRootPooledCache(root, remainingLanes) { @@ -7377,7 +7413,7 @@ function flushPassiveEffects() { priority ); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if ( injectedHook && "function" === typeof injectedHook.onPostCommitFiberRoot @@ -7403,7 +7439,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) @@ -7440,7 +7476,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -7466,7 +7502,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 && @@ -7477,7 +7512,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 && @@ -7486,7 +7521,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, @@ -7930,7 +7965,7 @@ beginWork = function (current, workInProgress, renderLanes) { ); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -8208,6 +8243,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -8631,19 +8667,19 @@ function wrapFiber(fiber) { fiberToWrapper.set(fiber, wrapper)); return wrapper; } -var devToolsConfig$jscomp$inline_1007 = { +var devToolsConfig$jscomp$inline_1026 = { findFiberByHostInstance: function () { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-next-8310854ce-20230331", + version: "18.3.0-next-09c8d2563-20230331", rendererPackageName: "react-test-renderer" }; -var internals$jscomp$inline_1198 = { - bundleType: devToolsConfig$jscomp$inline_1007.bundleType, - version: devToolsConfig$jscomp$inline_1007.version, - rendererPackageName: devToolsConfig$jscomp$inline_1007.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1007.rendererConfig, +var internals$jscomp$inline_1218 = { + bundleType: devToolsConfig$jscomp$inline_1026.bundleType, + version: devToolsConfig$jscomp$inline_1026.version, + rendererPackageName: devToolsConfig$jscomp$inline_1026.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1026.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8660,26 +8696,26 @@ var internals$jscomp$inline_1198 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1007.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1026.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-8310854ce-20230331" + reconcilerVersion: "18.3.0-next-09c8d2563-20230331" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1199 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1219 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1199.isDisabled && - hook$jscomp$inline_1199.supportsFiber + !hook$jscomp$inline_1219.isDisabled && + hook$jscomp$inline_1219.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1199.inject( - internals$jscomp$inline_1198 + (rendererID = hook$jscomp$inline_1219.inject( + internals$jscomp$inline_1218 )), - (injectedHook = hook$jscomp$inline_1199); + (injectedHook = hook$jscomp$inline_1219); } catch (err) {} } exports._Scheduler = Scheduler; @@ -8801,6 +8837,6 @@ exports.unstable_batchedUpdates = function (fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } }; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js index 4325af29d6..767e6edf26 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -277,7 +277,7 @@ function findCurrentHostFiberImpl(node) { return null; } var isArrayImpl = Array.isArray, - scheduleCallback$2 = Scheduler$1.unstable_scheduleCallback, + scheduleCallback$3 = Scheduler$1.unstable_scheduleCallback, cancelCallback$1 = Scheduler$1.unstable_cancelCallback, shouldYield = Scheduler$1.unstable_shouldYield, requestPaint = Scheduler$1.unstable_requestPaint, @@ -690,50 +690,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) { @@ -2188,10 +2145,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$25 = thenableIndexCounter; + var index$23 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$25); + usable = trackUsedThenable(thenableState, usable, index$23); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -4369,7 +4326,7 @@ var AbortControllerLocal = }); }; }, - scheduleCallback$1 = Scheduler$1.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler$1.unstable_scheduleCallback, NormalPriority = Scheduler$1.unstable_NormalPriority, CacheContext = { $$typeof: REACT_CONTEXT_TYPE, @@ -4391,7 +4348,7 @@ function createCache() { function releaseCache(cache) { cache.refCount--; 0 === cache.refCount && - scheduleCallback$1(NormalPriority, function () { + scheduleCallback$2(NormalPriority, function () { cache.controller.abort(); }); } @@ -4436,14 +4393,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$62 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$62 = lastTailNode), + for (var lastTailNode$60 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$60 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$62 + null === lastTailNode$60 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$62.sibling = null); + : (lastTailNode$60.sibling = null); } } function bubbleProperties(completedWork) { @@ -4455,53 +4412,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$64 = completedWork.selfBaseDuration, - child$65 = completedWork.child; - null !== child$65; + var treeBaseDuration$62 = completedWork.selfBaseDuration, + child$63 = completedWork.child; + null !== child$63; ) - (newChildLanes |= child$65.lanes | child$65.childLanes), - (subtreeFlags |= child$65.subtreeFlags & 31457280), - (subtreeFlags |= child$65.flags & 31457280), - (treeBaseDuration$64 += child$65.treeBaseDuration), - (child$65 = child$65.sibling); - completedWork.treeBaseDuration = treeBaseDuration$64; + (newChildLanes |= child$63.lanes | child$63.childLanes), + (subtreeFlags |= child$63.subtreeFlags & 31457280), + (subtreeFlags |= child$63.flags & 31457280), + (treeBaseDuration$62 += child$63.treeBaseDuration), + (child$63 = child$63.sibling); + completedWork.treeBaseDuration = treeBaseDuration$62; } else for ( - treeBaseDuration$64 = completedWork.child; - null !== treeBaseDuration$64; + treeBaseDuration$62 = completedWork.child; + null !== treeBaseDuration$62; ) (newChildLanes |= - treeBaseDuration$64.lanes | treeBaseDuration$64.childLanes), - (subtreeFlags |= treeBaseDuration$64.subtreeFlags & 31457280), - (subtreeFlags |= treeBaseDuration$64.flags & 31457280), - (treeBaseDuration$64.return = completedWork), - (treeBaseDuration$64 = treeBaseDuration$64.sibling); + treeBaseDuration$62.lanes | treeBaseDuration$62.childLanes), + (subtreeFlags |= treeBaseDuration$62.subtreeFlags & 31457280), + (subtreeFlags |= treeBaseDuration$62.flags & 31457280), + (treeBaseDuration$62.return = completedWork), + (treeBaseDuration$62 = treeBaseDuration$62.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$64 = completedWork.actualDuration; - child$65 = completedWork.selfBaseDuration; + treeBaseDuration$62 = completedWork.actualDuration; + child$63 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$64 += child.actualDuration), - (child$65 += child.treeBaseDuration), + (treeBaseDuration$62 += child.actualDuration), + (child$63 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$64; - completedWork.treeBaseDuration = child$65; + completedWork.actualDuration = treeBaseDuration$62; + completedWork.treeBaseDuration = child$63; } else for ( - treeBaseDuration$64 = completedWork.child; - null !== treeBaseDuration$64; + treeBaseDuration$62 = completedWork.child; + null !== treeBaseDuration$62; ) (newChildLanes |= - treeBaseDuration$64.lanes | treeBaseDuration$64.childLanes), - (subtreeFlags |= treeBaseDuration$64.subtreeFlags), - (subtreeFlags |= treeBaseDuration$64.flags), - (treeBaseDuration$64.return = completedWork), - (treeBaseDuration$64 = treeBaseDuration$64.sibling); + treeBaseDuration$62.lanes | treeBaseDuration$62.childLanes), + (subtreeFlags |= treeBaseDuration$62.subtreeFlags), + (subtreeFlags |= treeBaseDuration$62.flags), + (treeBaseDuration$62.return = completedWork), + (treeBaseDuration$62 = treeBaseDuration$62.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -4675,11 +4632,11 @@ function completeWork(current, workInProgress, renderLanes) { null !== newProps.alternate.memoizedState && null !== newProps.alternate.memoizedState.cachePool && (index = newProps.alternate.memoizedState.cachePool.pool); - var cache$72 = null; + var cache$70 = null; null !== newProps.memoizedState && null !== newProps.memoizedState.cachePool && - (cache$72 = newProps.memoizedState.cachePool.pool); - cache$72 !== index && (newProps.flags |= 2048); + (cache$70 = newProps.memoizedState.cachePool.pool); + cache$70 !== index && (newProps.flags |= 2048); } renderLanes !== current && renderLanes && @@ -4711,8 +4668,8 @@ function completeWork(current, workInProgress, renderLanes) { index = workInProgress.memoizedState; if (null === index) return bubbleProperties(workInProgress), null; newProps = 0 !== (workInProgress.flags & 128); - cache$72 = index.rendering; - if (null === cache$72) + cache$70 = index.rendering; + if (null === cache$70) if (newProps) cutOffTailIfNeeded(index, !1); else { if ( @@ -4720,11 +4677,11 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current && 0 !== (current.flags & 128)) ) for (current = workInProgress.child; null !== current; ) { - cache$72 = findFirstSuspended(current); - if (null !== cache$72) { + cache$70 = findFirstSuspended(current); + if (null !== cache$70) { workInProgress.flags |= 128; cutOffTailIfNeeded(index, !1); - current = cache$72.updateQueue; + current = cache$70.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); workInProgress.subtreeFlags = 0; @@ -4749,7 +4706,7 @@ function completeWork(current, workInProgress, renderLanes) { } else { if (!newProps) - if (((current = findFirstSuspended(cache$72)), null !== current)) { + if (((current = findFirstSuspended(cache$70)), null !== current)) { if ( ((workInProgress.flags |= 128), (newProps = !0), @@ -4759,7 +4716,7 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(index, !0), null === index.tail && "hidden" === index.tailMode && - !cache$72.alternate) + !cache$70.alternate) ) return bubbleProperties(workInProgress), null; } else @@ -4771,13 +4728,13 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(index, !1), (workInProgress.lanes = 8388608)); index.isBackwards - ? ((cache$72.sibling = workInProgress.child), - (workInProgress.child = cache$72)) + ? ((cache$70.sibling = workInProgress.child), + (workInProgress.child = cache$70)) : ((current = index.last), null !== current - ? (current.sibling = cache$72) - : (workInProgress.child = cache$72), - (index.last = cache$72)); + ? (current.sibling = cache$70) + : (workInProgress.child = cache$70), + (index.last = cache$70)); } if (null !== index.tail) return ( @@ -5033,8 +4990,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (error$88) { - captureCommitPhaseError(current, nearestMountedAncestor, error$88); + } catch (error$86) { + captureCommitPhaseError(current, nearestMountedAncestor, error$86); } else ref.current = null; } @@ -5139,8 +5096,8 @@ function commitHookEffectListMount(flags, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & flags) === flags) { - var create$89 = effect.create; - effect.destroy = create$89(); + var create$87 = effect.create; + effect.destroy = create$87(); } effect = effect.next; } while (effect !== finishedWork); @@ -5158,8 +5115,8 @@ function commitHookLayoutEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$91) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$91); + } catch (error$89) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$89); } } function commitClassCallbacks(finishedWork) { @@ -5239,11 +5196,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { } else try { finishedRoot.componentDidMount(); - } catch (error$92) { + } catch (error$90) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$92 + error$90 ); } else { @@ -5260,11 +5217,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$93) { + } catch (error$91) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$93 + error$91 ); } recordLayoutEffectDuration(finishedWork); @@ -5275,11 +5232,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$94) { + } catch (error$92) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$94 + error$92 ); } } @@ -5659,22 +5616,22 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { startLayoutEffectTimer(), commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$103) { + } catch (error$101) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$103 + error$101 ); } recordLayoutEffectDuration(finishedWork); } else try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$104) { + } catch (error$102) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$104 + error$102 ); } } @@ -5715,11 +5672,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null !== current) try { (flags.type = type), (flags.props = existingHiddenCallbacks); - } catch (error$107) { + } catch (error$105) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$107 + error$105 ); } } @@ -5736,8 +5693,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { existingHiddenCallbacks = finishedWork.memoizedProps; try { flags.text = existingHiddenCallbacks; - } catch (error$108) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$108); + } catch (error$106) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$106); } } break; @@ -5769,14 +5726,14 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== current && safelyDetachRef(current, current.return); existingHiddenCallbacks = null !== finishedWork.memoizedState; - var wasHidden$112 = null !== current && null !== current.memoizedState; + var wasHidden$110 = null !== current && null !== current.memoizedState; if (finishedWork.mode & 1) { var prevOffscreenSubtreeIsHidden = offscreenSubtreeIsHidden, prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || existingHiddenCallbacks; offscreenSubtreeWasHidden = - prevOffscreenSubtreeWasHidden || wasHidden$112; + prevOffscreenSubtreeWasHidden || wasHidden$110; recursivelyTraverseMutationEffects(root, finishedWork); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; @@ -5794,22 +5751,22 @@ function commitMutationEffectsOnFiber(finishedWork, root) { existingHiddenCallbacks && ((root = offscreenSubtreeIsHidden || offscreenSubtreeWasHidden), null === current || - wasHidden$112 || + wasHidden$110 || root || (0 !== (finishedWork.mode & 1) && recursivelyTraverseDisappearLayoutEffects(finishedWork))), null === finishedWork.memoizedProps || "manual" !== finishedWork.memoizedProps.mode) ) - a: for (current = null, wasHidden$112 = finishedWork; ; ) { - if (5 === wasHidden$112.tag) { + a: for (current = null, wasHidden$110 = finishedWork; ; ) { + if (5 === wasHidden$110.tag) { if (null === current) { - current = wasHidden$112; + current = wasHidden$110; try { - (type = wasHidden$112.stateNode), + (type = wasHidden$110.stateNode), existingHiddenCallbacks ? (type.isHidden = !0) - : (wasHidden$112.stateNode.isHidden = !1); + : (wasHidden$110.stateNode.isHidden = !1); } catch (error) { captureCommitPhaseError( finishedWork, @@ -5818,42 +5775,42 @@ function commitMutationEffectsOnFiber(finishedWork, root) { ); } } - } else if (6 === wasHidden$112.tag) { + } else if (6 === wasHidden$110.tag) { if (null === current) try { - wasHidden$112.stateNode.isHidden = existingHiddenCallbacks + wasHidden$110.stateNode.isHidden = existingHiddenCallbacks ? !0 : !1; - } catch (error$97) { + } catch (error$95) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$97 + error$95 ); } } else if ( - ((22 !== wasHidden$112.tag && 23 !== wasHidden$112.tag) || - null === wasHidden$112.memoizedState || - wasHidden$112 === finishedWork) && - null !== wasHidden$112.child + ((22 !== wasHidden$110.tag && 23 !== wasHidden$110.tag) || + null === wasHidden$110.memoizedState || + wasHidden$110 === finishedWork) && + null !== wasHidden$110.child ) { - wasHidden$112.child.return = wasHidden$112; - wasHidden$112 = wasHidden$112.child; + wasHidden$110.child.return = wasHidden$110; + wasHidden$110 = wasHidden$110.child; continue; } - if (wasHidden$112 === finishedWork) break a; - for (; null === wasHidden$112.sibling; ) { + if (wasHidden$110 === finishedWork) break a; + for (; null === wasHidden$110.sibling; ) { if ( - null === wasHidden$112.return || - wasHidden$112.return === finishedWork + null === wasHidden$110.return || + wasHidden$110.return === finishedWork ) break a; - current === wasHidden$112 && (current = null); - wasHidden$112 = wasHidden$112.return; + current === wasHidden$110 && (current = null); + wasHidden$110 = wasHidden$110.return; } - current === wasHidden$112 && (current = null); - wasHidden$112.sibling.return = wasHidden$112.return; - wasHidden$112 = wasHidden$112.sibling; + current === wasHidden$110 && (current = null); + wasHidden$110.sibling.return = wasHidden$110.return; + wasHidden$110 = wasHidden$110.sibling; } flags & 4 && ((flags = finishedWork.updateQueue), @@ -5909,12 +5866,12 @@ function commitReconciliationEffects(finishedWork) { break; case 3: case 4: - var parent$98 = JSCompiler_inline_result.stateNode.containerInfo, - before$99 = getHostSibling(finishedWork); + var parent$96 = JSCompiler_inline_result.stateNode.containerInfo, + before$97 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$99, - parent$98 + before$97, + parent$96 ); break; default: @@ -6094,8 +6051,8 @@ function commitHookPassiveMountEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$115) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$115); + } catch (error$113) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$113); } } function commitOffscreenPassiveMountEffects(current, finishedWork) { @@ -6560,7 +6517,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)); +} +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; + currentUpdateIsNested = nestedUpdateScheduled; + nestedUpdateScheduled = !1; + if (0 !== (executionContext & 6)) + throw Error("Should not already be working."); + 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$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; +} +var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentCache = ReactSharedInternals.ReactCurrentCache, @@ -6629,87 +6782,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) { - 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) { nestedUpdateScheduled = currentUpdateIsNested = !1; @@ -6751,7 +6829,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); @@ -6765,16 +6843,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { exitStatus = renderRootSync(root, lanes); if (2 === exitStatus) { errorRetryLanes = lanes; - var errorRetryLanes$121 = getLanesToRetrySynchronouslyOnError( + var errorRetryLanes$120 = getLanesToRetrySynchronouslyOnError( root, errorRetryLanes ); - 0 !== errorRetryLanes$121 && - ((lanes = errorRetryLanes$121), + 0 !== errorRetryLanes$120 && + ((lanes = errorRetryLanes$120), (exitStatus = recoverFromConcurrentError( root, errorRetryLanes, - errorRetryLanes$121 + errorRetryLanes$120 ))); } if (1 === exitStatus) @@ -6782,7 +6860,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now$1()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -6835,14 +6913,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if ((lanes & 8388480) === lanes) break; exitStatus = lanes; errorRetryLanes = root.eventTimes; - for (errorRetryLanes$121 = -1; 0 < exitStatus; ) { + for (errorRetryLanes$120 = -1; 0 < exitStatus; ) { var index$2 = 31 - clz32(exitStatus), lane = 1 << index$2; index$2 = errorRetryLanes[index$2]; - index$2 > errorRetryLanes$121 && (errorRetryLanes$121 = index$2); + index$2 > errorRetryLanes$120 && (errorRetryLanes$120 = index$2); exitStatus &= ~lane; } - exitStatus = errorRetryLanes$121; + exitStatus = errorRetryLanes$120; exitStatus = now$1() - exitStatus; exitStatus = (120 > exitStatus @@ -6894,10 +6972,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, @@ -6990,51 +7071,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - currentUpdateIsNested = nestedUpdateScheduled; - nestedUpdateScheduled = !1; - if (0 !== (executionContext & 6)) - throw Error("Should not already be working."); - 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 flushSync(fn) { null !== rootWithPendingPassiveEffects && 0 === rootWithPendingPassiveEffects.tag && @@ -7055,7 +7091,7 @@ function flushSync(fn) { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig.transition = prevTransition), (executionContext = prevExecutionContext), - 0 === (executionContext & 6) && flushSyncCallbacks(); + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); } } function resetWorkInProgressStack() { @@ -7183,8 +7219,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$124) { - handleThrow(root, thrownValue$124); + } catch (thrownValue$123) { + handleThrow(root, thrownValue$123); } while (1); resetContextDependencies(); @@ -7234,7 +7270,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -7291,8 +7327,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$126) { - handleThrow(root, thrownValue$126); + } catch (thrownValue$125) { + handleThrow(root, thrownValue$125); } while (1); resetContextDependencies(); @@ -7457,10 +7493,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$31 = offscreenQueue.retryQueue; - null === retryQueue$31 + var retryQueue$29 = offscreenQueue.retryQueue; + null === retryQueue$29 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$31.add(wakeable); + : retryQueue$29.add(wakeable); } } break; @@ -7667,7 +7703,7 @@ function commitRootImpl( remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(finishedWork.stateNode, renderPriorityLevel); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, finishedWork = 0; @@ -7697,7 +7733,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); return null; } function releaseRootPooledCache(root, remainingLanes) { @@ -7750,11 +7786,11 @@ function flushPassiveEffects() { _finishedWork$memoize = finishedWork.memoizedProps, id = _finishedWork$memoize.id, onPostCommit = _finishedWork$memoize.onPostCommit, - commitTime$90 = commitTime, + commitTime$88 = commitTime, phase = null === finishedWork.alternate ? "mount" : "update"; currentUpdateIsNested && (phase = "nested-update"); "function" === typeof onPostCommit && - onPostCommit(id, phase, passiveEffectDuration, commitTime$90); + onPostCommit(id, phase, passiveEffectDuration, commitTime$88); var parentFiber = finishedWork.return; b: for (; null !== parentFiber; ) { switch (parentFiber.tag) { @@ -7772,7 +7808,7 @@ function flushPassiveEffects() { } } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if ( injectedHook && "function" === typeof injectedHook.onPostCommitFiberRoot @@ -7810,7 +7846,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) @@ -7847,7 +7883,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -7873,7 +7909,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 && @@ -7884,7 +7919,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 && @@ -7893,7 +7928,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, @@ -8341,7 +8376,7 @@ beginWork = function (current, workInProgress, renderLanes) { ); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$2(priorityLevel, callback); + return scheduleCallback$3(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -8631,6 +8666,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -9056,19 +9092,19 @@ function wrapFiber(fiber) { fiberToWrapper.set(fiber, wrapper)); return wrapper; } -var devToolsConfig$jscomp$inline_1050 = { +var devToolsConfig$jscomp$inline_1068 = { findFiberByHostInstance: function () { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-next-8310854ce-20230331", + version: "18.3.0-next-09c8d2563-20230331", rendererPackageName: "react-test-renderer" }; -var internals$jscomp$inline_1239 = { - bundleType: devToolsConfig$jscomp$inline_1050.bundleType, - version: devToolsConfig$jscomp$inline_1050.version, - rendererPackageName: devToolsConfig$jscomp$inline_1050.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1050.rendererConfig, +var internals$jscomp$inline_1259 = { + bundleType: devToolsConfig$jscomp$inline_1068.bundleType, + version: devToolsConfig$jscomp$inline_1068.version, + rendererPackageName: devToolsConfig$jscomp$inline_1068.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1068.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9085,26 +9121,26 @@ var internals$jscomp$inline_1239 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1050.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1068.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-8310854ce-20230331" + reconcilerVersion: "18.3.0-next-09c8d2563-20230331" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1240 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1260 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1240.isDisabled && - hook$jscomp$inline_1240.supportsFiber + !hook$jscomp$inline_1260.isDisabled && + hook$jscomp$inline_1260.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1240.inject( - internals$jscomp$inline_1239 + (rendererID = hook$jscomp$inline_1260.inject( + internals$jscomp$inline_1259 )), - (injectedHook = hook$jscomp$inline_1240); + (injectedHook = hook$jscomp$inline_1260); } catch (err) {} } exports._Scheduler = Scheduler; @@ -9226,6 +9262,6 @@ exports.unstable_batchedUpdates = function (fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now$1() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } }; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js index f52b4aa164..4adf6ab644 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-next-8310854ce-20230331"; +var ReactVersion = "18.3.0-next-09c8d2563-20230331"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js index fe26d15643..581cd2e7c2 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js @@ -639,4 +639,4 @@ exports.useSyncExternalStore = function ( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-next-8310854ce-20230331"; +exports.version = "18.3.0-next-09c8d2563-20230331"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js index 1281c20485..b43970e6c5 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js @@ -642,7 +642,7 @@ exports.useSyncExternalStore = function ( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-next-8310854ce-20230331"; +exports.version = "18.3.0-next-09c8d2563-20230331"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index 0da603692c..a46a1ce4f8 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -8310854cebba4d1f404e65ff2064825ee76d78e2 +09c8d2563300621dc91258a4c2839210e2fbdf0e diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 5974d17077..ec16c5ab5f 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -3196,7 +3196,9 @@ function dispatchEvent(target, topLevelType, nativeEvent) { // NOTE: There are no flags, currently. Uncomment the stuff below if we add one. // the exports object every time a flag is read. -var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning; // The rest of the flags are static for better dead code elimination. +var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, + enableDeferRootSchedulingToMicrotask = + dynamicFlags.enableDeferRootSchedulingToMicrotask; // The rest of the flags are static for better dead code elimination. var enableSchedulingProfiler = true; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; @@ -3329,7 +3331,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$1 = Scheduler.unstable_scheduleCallback; +var scheduleCallback$2 = Scheduler.unstable_scheduleCallback; var cancelCallback$1 = Scheduler.unstable_cancelCallback; var shouldYield = Scheduler.unstable_shouldYield; var requestPaint = Scheduler.unstable_requestPaint; @@ -6281,102 +6283,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$1( - 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. @@ -7891,7 +7797,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( @@ -7927,8 +7833,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]; @@ -22538,7 +22444,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 @@ -22561,7 +22467,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -22574,6 +22480,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; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority; + 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$2(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$2(ImmediatePriority, cb); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -22698,6 +22974,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. @@ -22863,21 +23142,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(); + } } } } @@ -22885,147 +23168,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; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority; - 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. @@ -23057,6 +23199,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, @@ -23107,7 +23250,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -23157,7 +23300,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. @@ -23170,15 +23313,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( @@ -23536,12 +23672,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; } @@ -23572,7 +23709,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -23581,7 +23718,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. @@ -23596,7 +23733,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() { @@ -23617,7 +23754,7 @@ function batchedUpdates(fn, a) { !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + flushSyncWorkOnLegacyRootsOnly(); } } } @@ -23659,7 +23796,7 @@ function flushSync(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -24171,7 +24308,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); @@ -24900,7 +25037,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 @@ -24953,7 +25090,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { markCommitStopped(); @@ -25073,7 +25210,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { // If additional passive effects were scheduled, increment a counter. If this @@ -25135,7 +25272,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -25174,7 +25311,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -25250,7 +25387,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -25286,7 +25422,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -25305,7 +25441,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -25691,19 +25827,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$1(priorityLevel, callback); + return scheduleCallback$2(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; @@ -26920,6 +27048,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); @@ -27012,7 +27141,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-8310854ce-20230331"; +var ReactVersion = "18.3.0-next-09c8d2563-20230331"; function createPortal$1( children, diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 44c414dcb0..d6ec8ae21f 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -940,7 +940,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_240 = { +var injectedNamesToPlugins$jscomp$inline_241 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -986,32 +986,32 @@ var injectedNamesToPlugins$jscomp$inline_240 = { } } }, - isOrderingDirty$jscomp$inline_241 = !1, - pluginName$jscomp$inline_242; -for (pluginName$jscomp$inline_242 in injectedNamesToPlugins$jscomp$inline_240) + isOrderingDirty$jscomp$inline_242 = !1, + pluginName$jscomp$inline_243; +for (pluginName$jscomp$inline_243 in injectedNamesToPlugins$jscomp$inline_241) if ( - injectedNamesToPlugins$jscomp$inline_240.hasOwnProperty( - pluginName$jscomp$inline_242 + injectedNamesToPlugins$jscomp$inline_241.hasOwnProperty( + pluginName$jscomp$inline_243 ) ) { - var pluginModule$jscomp$inline_243 = - injectedNamesToPlugins$jscomp$inline_240[pluginName$jscomp$inline_242]; + var pluginModule$jscomp$inline_244 = + injectedNamesToPlugins$jscomp$inline_241[pluginName$jscomp$inline_243]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_242) || - namesToPlugins[pluginName$jscomp$inline_242] !== - pluginModule$jscomp$inline_243 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_243) || + namesToPlugins[pluginName$jscomp$inline_243] !== + pluginModule$jscomp$inline_244 ) { - if (namesToPlugins[pluginName$jscomp$inline_242]) + if (namesToPlugins[pluginName$jscomp$inline_243]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_242 + "`.") + (pluginName$jscomp$inline_243 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_242] = - pluginModule$jscomp$inline_243; - isOrderingDirty$jscomp$inline_241 = !0; + namesToPlugins[pluginName$jscomp$inline_243] = + pluginModule$jscomp$inline_244; + isOrderingDirty$jscomp$inline_242 = !0; } } -isOrderingDirty$jscomp$inline_241 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_242 && recomputePluginOrdering(); var emptyObject$1 = {}, removedKeys = null, removedKeyCount = 0, @@ -1315,7 +1315,9 @@ function dispatchEvent(target, topLevelType, nativeEvent) { }); } var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + enableDeferRootSchedulingToMicrotask = + dynamicFlags.enableDeferRootSchedulingToMicrotask, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -2025,50 +2027,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$1( - 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) { @@ -3535,10 +3494,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$27 = thenableIndexCounter; + var index$25 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$27); + usable = trackUsedThenable(thenableState, usable, index$25); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -5796,14 +5755,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$66 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$66 = lastTailNode), + for (var lastTailNode$64 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$66 + null === lastTailNode$64 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$66.sibling = null); + : (lastTailNode$64.sibling = null); } } function bubbleProperties(completedWork) { @@ -5813,19 +5772,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$67 = completedWork.child; null !== child$67; ) - (newChildLanes |= child$67.lanes | child$67.childLanes), - (subtreeFlags |= child$67.subtreeFlags & 31457280), - (subtreeFlags |= child$67.flags & 31457280), - (child$67.return = completedWork), - (child$67 = child$67.sibling); + for (var child$65 = completedWork.child; null !== child$65; ) + (newChildLanes |= child$65.lanes | child$65.childLanes), + (subtreeFlags |= child$65.subtreeFlags & 31457280), + (subtreeFlags |= child$65.flags & 31457280), + (child$65.return = completedWork), + (child$65 = child$65.sibling); else - for (child$67 = completedWork.child; null !== child$67; ) - (newChildLanes |= child$67.lanes | child$67.childLanes), - (subtreeFlags |= child$67.subtreeFlags), - (subtreeFlags |= child$67.flags), - (child$67.return = completedWork), - (child$67 = child$67.sibling); + for (child$65 = completedWork.child; null !== child$65; ) + (newChildLanes |= child$65.lanes | child$65.childLanes), + (subtreeFlags |= child$65.subtreeFlags), + (subtreeFlags |= child$65.flags), + (child$65.return = completedWork), + (child$65 = child$65.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6316,8 +6275,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$82) { - captureCommitPhaseError(current, nearestMountedAncestor, error$82); + } catch (error$80) { + captureCommitPhaseError(current, nearestMountedAncestor, error$80); } else ref.current = null; } @@ -6420,8 +6379,8 @@ function commitHookEffectListMount(flags, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & flags) === flags) { - var create$83 = effect.create; - effect.destroy = create$83(); + var create$81 = effect.create; + effect.destroy = create$81(); } effect = effect.next; } while (effect !== finishedWork); @@ -6484,11 +6443,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$84) { + } catch (error$82) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$84 + error$82 ); } } @@ -6806,8 +6765,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$86) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$86); + } catch (error$84) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$84); } } break; @@ -6867,14 +6826,14 @@ function commitMutationEffectsOnFiber(finishedWork, root) { flags & 512 && null !== current && safelyDetachRef(current, current.return); - var isHidden$93 = null !== finishedWork.memoizedState, - wasHidden$94 = null !== current && null !== current.memoizedState; + var isHidden$91 = null !== finishedWork.memoizedState, + wasHidden$92 = null !== current && null !== current.memoizedState; if (finishedWork.mode & 1) { var prevOffscreenSubtreeIsHidden = offscreenSubtreeIsHidden, prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; - offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden$93; + offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden$91; offscreenSubtreeWasHidden = - prevOffscreenSubtreeWasHidden || wasHidden$94; + prevOffscreenSubtreeWasHidden || wasHidden$92; recursivelyTraverseMutationEffects(root, finishedWork); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; @@ -6885,15 +6844,15 @@ function commitMutationEffectsOnFiber(finishedWork, root) { root._visibility &= -3; root._visibility |= root._pendingVisibility & 2; flags & 8192 && - ((root._visibility = isHidden$93 + ((root._visibility = isHidden$91 ? root._visibility & -2 : root._visibility | 1), - isHidden$93 && - ((isHidden$93 = + isHidden$91 && + ((isHidden$91 = offscreenSubtreeIsHidden || offscreenSubtreeWasHidden), null === current || - wasHidden$94 || - isHidden$93 || + wasHidden$92 || + isHidden$91 || (0 !== (finishedWork.mode & 1) && recursivelyTraverseDisappearLayoutEffects(finishedWork)))); flags & 4 && @@ -7333,6 +7292,202 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin( } } } +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), + scheduleCallback$2(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("Should not already be working."); + 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$2(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$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; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$2(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -7411,87 +7566,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() + 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$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; - } - 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$1(ImmediatePriority, flushSyncCallbacks), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(suspendedLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; - } + flushSyncWorkAcrossRoots_impl(!0)); } function performConcurrentWorkOnRoot(root, didTimeout) { currentEventTime = -1; @@ -7532,7 +7612,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); @@ -7546,16 +7626,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { exitStatus = renderRootSync(root, lanes); if (2 === exitStatus) { errorRetryLanes = lanes; - var errorRetryLanes$98 = getLanesToRetrySynchronouslyOnError( + var errorRetryLanes$97 = getLanesToRetrySynchronouslyOnError( root, errorRetryLanes ); - 0 !== errorRetryLanes$98 && - ((lanes = errorRetryLanes$98), + 0 !== errorRetryLanes$97 && + ((lanes = errorRetryLanes$97), (exitStatus = recoverFromConcurrentError( root, errorRetryLanes, - errorRetryLanes$98 + errorRetryLanes$97 ))); } if (1 === exitStatus) @@ -7563,7 +7643,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -7616,14 +7696,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if ((lanes & 8388480) === lanes) break; exitStatus = lanes; errorRetryLanes = root.eventTimes; - for (errorRetryLanes$98 = -1; 0 < exitStatus; ) { + for (errorRetryLanes$97 = -1; 0 < exitStatus; ) { var index$3 = 31 - clz32(exitStatus), lane = 1 << index$3; index$3 = errorRetryLanes[index$3]; - index$3 > errorRetryLanes$98 && (errorRetryLanes$98 = index$3); + index$3 > errorRetryLanes$97 && (errorRetryLanes$97 = index$3); exitStatus &= ~lane; } - exitStatus = errorRetryLanes$98; + exitStatus = errorRetryLanes$97; exitStatus = now() - exitStatus; exitStatus = (120 > exitStatus @@ -7675,10 +7755,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, @@ -7771,49 +7854,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 6)) - throw Error("Should not already be working."); - 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) @@ -7931,8 +7971,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$101) { - handleThrow(root, thrownValue$101); + } catch (thrownValue$100) { + handleThrow(root, thrownValue$100); } while (1); resetContextDependencies(); @@ -7980,7 +8020,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -8037,8 +8077,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$103) { - handleThrow(root, thrownValue$103); + } catch (thrownValue$102) { + handleThrow(root, thrownValue$102); } while (1); resetContextDependencies(); @@ -8192,10 +8232,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$34 = offscreenQueue.retryQueue; - null === retryQueue$34 + var retryQueue$32 = offscreenQueue.retryQueue; + null === retryQueue$32 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$34.add(wakeable); + : retryQueue$32.add(wakeable); } } break; @@ -8389,7 +8429,7 @@ function commitRootImpl( remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(transitions.stateNode, renderPriorityLevel); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, transitions = 0; @@ -8418,7 +8458,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); return null; } function flushPassiveEffects() { @@ -8442,7 +8482,7 @@ function flushPassiveEffects() { commitPassiveUnmountOnFiber(renderPriority.current); commitPassiveMountOnFiber(renderPriority, renderPriority.current); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if ( injectedHook && "function" === typeof injectedHook.onPostCommitFiberRoot @@ -8467,7 +8507,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) @@ -8504,7 +8544,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -8530,7 +8570,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 && @@ -8541,7 +8580,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 && @@ -8550,7 +8589,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, @@ -9023,7 +9062,7 @@ beginWork = function (current, workInProgress, renderLanes) { ); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$1(priorityLevel, callback); + return scheduleCallback$2(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -9295,6 +9334,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -9496,14 +9536,14 @@ batchedUpdatesImpl = function (fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1027 = { + devToolsConfig$jscomp$inline_1046 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-next-8310854ce-20230331", + version: "18.3.0-next-09c8d2563-20230331", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -9518,11 +9558,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1273 = { - bundleType: devToolsConfig$jscomp$inline_1027.bundleType, - version: devToolsConfig$jscomp$inline_1027.version, - rendererPackageName: devToolsConfig$jscomp$inline_1027.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1027.rendererConfig, +var internals$jscomp$inline_1291 = { + bundleType: devToolsConfig$jscomp$inline_1046.bundleType, + version: devToolsConfig$jscomp$inline_1046.version, + rendererPackageName: devToolsConfig$jscomp$inline_1046.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1046.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9538,26 +9578,26 @@ var internals$jscomp$inline_1273 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1027.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1046.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-8310854ce-20230331" + reconcilerVersion: "18.3.0-next-09c8d2563-20230331" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1274 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1292 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1274.isDisabled && - hook$jscomp$inline_1274.supportsFiber + !hook$jscomp$inline_1292.isDisabled && + hook$jscomp$inline_1292.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1274.inject( - internals$jscomp$inline_1273 + (rendererID = hook$jscomp$inline_1292.inject( + internals$jscomp$inline_1291 )), - (injectedHook = hook$jscomp$inline_1274); + (injectedHook = hook$jscomp$inline_1292); } catch (err) {} } exports.createPortal = function (children, containerTag) { diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 5e8840e111..1e9a031074 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -951,7 +951,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_256 = { +var injectedNamesToPlugins$jscomp$inline_257 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -997,32 +997,32 @@ var injectedNamesToPlugins$jscomp$inline_256 = { } } }, - isOrderingDirty$jscomp$inline_257 = !1, - pluginName$jscomp$inline_258; -for (pluginName$jscomp$inline_258 in injectedNamesToPlugins$jscomp$inline_256) + isOrderingDirty$jscomp$inline_258 = !1, + pluginName$jscomp$inline_259; +for (pluginName$jscomp$inline_259 in injectedNamesToPlugins$jscomp$inline_257) if ( - injectedNamesToPlugins$jscomp$inline_256.hasOwnProperty( - pluginName$jscomp$inline_258 + injectedNamesToPlugins$jscomp$inline_257.hasOwnProperty( + pluginName$jscomp$inline_259 ) ) { - var pluginModule$jscomp$inline_259 = - injectedNamesToPlugins$jscomp$inline_256[pluginName$jscomp$inline_258]; + var pluginModule$jscomp$inline_260 = + injectedNamesToPlugins$jscomp$inline_257[pluginName$jscomp$inline_259]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_258) || - namesToPlugins[pluginName$jscomp$inline_258] !== - pluginModule$jscomp$inline_259 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_259) || + namesToPlugins[pluginName$jscomp$inline_259] !== + pluginModule$jscomp$inline_260 ) { - if (namesToPlugins[pluginName$jscomp$inline_258]) + if (namesToPlugins[pluginName$jscomp$inline_259]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_258 + "`.") + (pluginName$jscomp$inline_259 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_258] = - pluginModule$jscomp$inline_259; - isOrderingDirty$jscomp$inline_257 = !0; + namesToPlugins[pluginName$jscomp$inline_259] = + pluginModule$jscomp$inline_260; + isOrderingDirty$jscomp$inline_258 = !0; } } -isOrderingDirty$jscomp$inline_257 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_258 && recomputePluginOrdering(); var emptyObject$1 = {}, removedKeys = null, removedKeyCount = 0, @@ -1326,7 +1326,9 @@ function dispatchEvent(target, topLevelType, nativeEvent) { }); } var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + enableDeferRootSchedulingToMicrotask = + dynamicFlags.enableDeferRootSchedulingToMicrotask, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -2153,50 +2155,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$1( - 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) { @@ -3663,10 +3622,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 @@ -6024,14 +5983,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$70 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$70 = lastTailNode), + for (var lastTailNode$68 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$68 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$70 + null === lastTailNode$68 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$70.sibling = null); + : (lastTailNode$68.sibling = null); } } function bubbleProperties(completedWork) { @@ -6043,53 +6002,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$72 = completedWork.selfBaseDuration, - child$73 = completedWork.child; - null !== child$73; + var treeBaseDuration$70 = completedWork.selfBaseDuration, + child$71 = completedWork.child; + null !== child$71; ) - (newChildLanes |= child$73.lanes | child$73.childLanes), - (subtreeFlags |= child$73.subtreeFlags & 31457280), - (subtreeFlags |= child$73.flags & 31457280), - (treeBaseDuration$72 += child$73.treeBaseDuration), - (child$73 = child$73.sibling); - completedWork.treeBaseDuration = treeBaseDuration$72; + (newChildLanes |= child$71.lanes | child$71.childLanes), + (subtreeFlags |= child$71.subtreeFlags & 31457280), + (subtreeFlags |= child$71.flags & 31457280), + (treeBaseDuration$70 += child$71.treeBaseDuration), + (child$71 = child$71.sibling); + completedWork.treeBaseDuration = treeBaseDuration$70; } else for ( - treeBaseDuration$72 = completedWork.child; - null !== treeBaseDuration$72; + treeBaseDuration$70 = completedWork.child; + null !== treeBaseDuration$70; ) (newChildLanes |= - treeBaseDuration$72.lanes | treeBaseDuration$72.childLanes), - (subtreeFlags |= treeBaseDuration$72.subtreeFlags & 31457280), - (subtreeFlags |= treeBaseDuration$72.flags & 31457280), - (treeBaseDuration$72.return = completedWork), - (treeBaseDuration$72 = treeBaseDuration$72.sibling); + treeBaseDuration$70.lanes | treeBaseDuration$70.childLanes), + (subtreeFlags |= treeBaseDuration$70.subtreeFlags & 31457280), + (subtreeFlags |= treeBaseDuration$70.flags & 31457280), + (treeBaseDuration$70.return = completedWork), + (treeBaseDuration$70 = treeBaseDuration$70.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$72 = completedWork.actualDuration; - child$73 = completedWork.selfBaseDuration; + treeBaseDuration$70 = completedWork.actualDuration; + child$71 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$72 += child.actualDuration), - (child$73 += child.treeBaseDuration), + (treeBaseDuration$70 += child.actualDuration), + (child$71 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$72; - completedWork.treeBaseDuration = child$73; + completedWork.actualDuration = treeBaseDuration$70; + completedWork.treeBaseDuration = child$71; } else for ( - treeBaseDuration$72 = completedWork.child; - null !== treeBaseDuration$72; + treeBaseDuration$70 = completedWork.child; + null !== treeBaseDuration$70; ) (newChildLanes |= - treeBaseDuration$72.lanes | treeBaseDuration$72.childLanes), - (subtreeFlags |= treeBaseDuration$72.subtreeFlags), - (subtreeFlags |= treeBaseDuration$72.flags), - (treeBaseDuration$72.return = completedWork), - (treeBaseDuration$72 = treeBaseDuration$72.sibling); + treeBaseDuration$70.lanes | treeBaseDuration$70.childLanes), + (subtreeFlags |= treeBaseDuration$70.subtreeFlags), + (subtreeFlags |= treeBaseDuration$70.flags), + (treeBaseDuration$70.return = completedWork), + (treeBaseDuration$70 = treeBaseDuration$70.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6639,8 +6598,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (error$91) { - captureCommitPhaseError(current, nearestMountedAncestor, error$91); + } catch (error$89) { + captureCommitPhaseError(current, nearestMountedAncestor, error$89); } else ref.current = null; } @@ -6772,8 +6731,8 @@ function commitHookEffectListMount(flags, finishedWork) { injectedProfilingHooks.markComponentLayoutEffectMountStarted( finishedWork ); - var create$92 = effect.create; - effect.destroy = create$92(); + var create$90 = effect.create; + effect.destroy = create$90(); 0 !== (flags & 8) ? null !== injectedProfilingHooks && "function" === @@ -6801,8 +6760,8 @@ function commitHookLayoutEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$94) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$94); + } catch (error$92) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$92); } } function commitClassCallbacks(finishedWork) { @@ -6891,11 +6850,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { } else try { finishedRoot.componentDidMount(); - } catch (error$95) { + } catch (error$93) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$95 + error$93 ); } else { @@ -6912,11 +6871,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$96) { + } catch (error$94) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$96 + error$94 ); } recordLayoutEffectDuration(finishedWork); @@ -6927,11 +6886,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$97) { + } catch (error$95) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$97 + error$95 ); } } @@ -7275,22 +7234,22 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { startLayoutEffectTimer(), commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$100) { + } catch (error$98) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$100 + error$98 ); } recordLayoutEffectDuration(finishedWork); } else try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$101) { + } catch (error$99) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$101 + error$99 ); } } @@ -7351,14 +7310,14 @@ function commitMutationEffectsOnFiber(finishedWork, root) { flags & 512 && null !== current && safelyDetachRef(current, current.return); - var isHidden$108 = null !== finishedWork.memoizedState, - wasHidden$109 = null !== current && null !== current.memoizedState; + var isHidden$106 = null !== finishedWork.memoizedState, + wasHidden$107 = null !== current && null !== current.memoizedState; if (finishedWork.mode & 1) { var prevOffscreenSubtreeIsHidden = offscreenSubtreeIsHidden, prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; - offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden$108; + offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden$106; offscreenSubtreeWasHidden = - prevOffscreenSubtreeWasHidden || wasHidden$109; + prevOffscreenSubtreeWasHidden || wasHidden$107; recursivelyTraverseMutationEffects(root, finishedWork); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; @@ -7369,15 +7328,15 @@ function commitMutationEffectsOnFiber(finishedWork, root) { root._visibility &= -3; root._visibility |= root._pendingVisibility & 2; flags & 8192 && - ((root._visibility = isHidden$108 + ((root._visibility = isHidden$106 ? root._visibility & -2 : root._visibility | 1), - isHidden$108 && - ((isHidden$108 = + isHidden$106 && + ((isHidden$106 = offscreenSubtreeIsHidden || offscreenSubtreeWasHidden), null === current || - wasHidden$109 || - isHidden$108 || + wasHidden$107 || + isHidden$106 || (0 !== (finishedWork.mode & 1) && recursivelyTraverseDisappearLayoutEffects(finishedWork)))); flags & 4 && @@ -7584,8 +7543,8 @@ function commitHookPassiveMountEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$112) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$112); + } catch (error$110) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$110); } } function recursivelyTraversePassiveMountEffects(root, parentFiber) { @@ -7858,6 +7817,204 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin( } } } +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), + scheduleCallback$2(ImmediatePriority, 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 = 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; + currentUpdateIsNested = nestedUpdateScheduled; + nestedUpdateScheduled = !1; + if (0 !== (executionContext & 6)) + throw Error("Should not already be working."); + 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$2(ImmediatePriority, workInProgressRoot$jscomp$0); + } + 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$5 = 31 - clz32(lanes), + lane = 1 << index$5, + expirationTime = expirationTimes[index$5]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$5] = 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; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$2(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -7938,87 +8095,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) { - for ( - var existingCallbackNode = root.callbackNode, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$5 = 31 - clz32(lanes), - lane = 1 << index$5, - expirationTime = expirationTimes[index$5]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$5] = 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$1(ImmediatePriority, flushSyncCallbacks), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(suspendedLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; - } + flushSyncWorkAcrossRoots_impl(!0)); } function performConcurrentWorkOnRoot(root, didTimeout) { nestedUpdateScheduled = currentUpdateIsNested = !1; @@ -8060,7 +8142,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); @@ -8074,16 +8156,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { exitStatus = renderRootSync(root, lanes); if (2 === exitStatus) { errorRetryLanes = lanes; - var errorRetryLanes$114 = getLanesToRetrySynchronouslyOnError( + var errorRetryLanes$113 = getLanesToRetrySynchronouslyOnError( root, errorRetryLanes ); - 0 !== errorRetryLanes$114 && - ((lanes = errorRetryLanes$114), + 0 !== errorRetryLanes$113 && + ((lanes = errorRetryLanes$113), (exitStatus = recoverFromConcurrentError( root, errorRetryLanes, - errorRetryLanes$114 + errorRetryLanes$113 ))); } if (1 === exitStatus) @@ -8091,7 +8173,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now$1()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -8144,14 +8226,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if ((lanes & 8388480) === lanes) break; exitStatus = lanes; errorRetryLanes = root.eventTimes; - for (errorRetryLanes$114 = -1; 0 < exitStatus; ) { + for (errorRetryLanes$113 = -1; 0 < exitStatus; ) { var index$4 = 31 - clz32(exitStatus), lane = 1 << index$4; index$4 = errorRetryLanes[index$4]; - index$4 > errorRetryLanes$114 && (errorRetryLanes$114 = index$4); + index$4 > errorRetryLanes$113 && (errorRetryLanes$113 = index$4); exitStatus &= ~lane; } - exitStatus = errorRetryLanes$114; + exitStatus = errorRetryLanes$113; exitStatus = now$1() - exitStatus; exitStatus = (120 > exitStatus @@ -8203,10 +8285,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, @@ -8299,51 +8384,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - currentUpdateIsNested = nestedUpdateScheduled; - nestedUpdateScheduled = !1; - if (0 !== (executionContext & 6)) - throw Error("Should not already be working."); - 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 resetWorkInProgressStack() { if (null !== workInProgress) { if (0 === workInProgressSuspendedReason) @@ -8500,8 +8540,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$117) { - handleThrow(root, thrownValue$117); + } catch (thrownValue$116) { + handleThrow(root, thrownValue$116); } while (1); resetContextDependencies(); @@ -8561,7 +8601,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; memoizedUpdaters.then(lanes, lanes); break a; @@ -8617,8 +8657,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$119) { - handleThrow(root, thrownValue$119); + } catch (thrownValue$118) { + handleThrow(root, thrownValue$118); } while (1); resetContextDependencies(); @@ -8790,10 +8830,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; @@ -9007,7 +9047,7 @@ function commitRootImpl( 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(transitions.stateNode, renderPriorityLevel); isDevToolsPresent && root.memoizedUpdaters.clear(); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, transitions = 0; @@ -9037,7 +9077,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); markCommitStopped(); return null; } @@ -9078,11 +9118,11 @@ function flushPassiveEffects() { _finishedWork$memoize = finishedWork.memoizedProps, id = _finishedWork$memoize.id, onPostCommit = _finishedWork$memoize.onPostCommit, - commitTime$93 = commitTime, + commitTime$91 = commitTime, phase = null === finishedWork.alternate ? "mount" : "update"; currentUpdateIsNested && (phase = "nested-update"); "function" === typeof onPostCommit && - onPostCommit(id, phase, passiveEffectDuration, commitTime$93); + onPostCommit(id, phase, passiveEffectDuration, commitTime$91); var parentFiber = finishedWork.return; b: for (; null !== parentFiber; ) { switch (parentFiber.tag) { @@ -9104,7 +9144,7 @@ function flushPassiveEffects() { typeof injectedProfilingHooks.markPassiveEffectsStopped && injectedProfilingHooks.markPassiveEffectsStopped(); executionContext = lanes; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if ( injectedHook && "function" === typeof injectedHook.onPostCommitFiberRoot @@ -9141,7 +9181,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) @@ -9178,7 +9218,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -9205,7 +9245,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 && @@ -9216,7 +9255,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 && @@ -9225,7 +9264,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, @@ -9712,7 +9751,7 @@ function restorePendingUpdaters(root, lanes) { }); } function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$1(priorityLevel, callback); + return scheduleCallback$2(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -9996,6 +10035,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -10204,14 +10244,14 @@ batchedUpdatesImpl = function (fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now$1() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1106 = { + devToolsConfig$jscomp$inline_1124 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-next-8310854ce-20230331", + version: "18.3.0-next-09c8d2563-20230331", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -10240,10 +10280,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1106.bundleType, - version: devToolsConfig$jscomp$inline_1106.version, - rendererPackageName: devToolsConfig$jscomp$inline_1106.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1106.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1124.bundleType, + version: devToolsConfig$jscomp$inline_1124.version, + rendererPackageName: devToolsConfig$jscomp$inline_1124.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1124.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10259,14 +10299,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1106.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1124.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-8310854ce-20230331" + reconcilerVersion: "18.3.0-next-09c8d2563-20230331" }); exports.createPortal = function (children, containerTag) { return createPortal$1( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index a79f4352d9..d681e32549 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -2915,7 +2915,9 @@ function set(key, value) { // NOTE: There are no flags, currently. Uncomment the stuff below if we add one. // the exports object every time a flag is read. -var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning; // The rest of the flags are static for better dead code elimination. +var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, + enableDeferRootSchedulingToMicrotask = + dynamicFlags.enableDeferRootSchedulingToMicrotask; // The rest of the flags are static for better dead code elimination. var enableSchedulingProfiler = true; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; @@ -4191,7 +4193,7 @@ var ReactNativeFiberHostComponent = /*#__PURE__*/ (function () { })(); // This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$1 = Scheduler.unstable_scheduleCallback; +var scheduleCallback$2 = Scheduler.unstable_scheduleCallback; var cancelCallback$1 = Scheduler.unstable_cancelCallback; var shouldYield = Scheduler.unstable_shouldYield; var requestPaint = Scheduler.unstable_requestPaint; @@ -6625,102 +6627,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$1( - 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. @@ -8235,7 +8141,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( @@ -8271,8 +8177,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]; @@ -23076,7 +22982,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 @@ -23101,7 +23007,7 @@ function isConcurrentActEnvironment() { if ( !isReactActEnvironmentGlobal && - ReactCurrentActQueue$1.current !== null + ReactCurrentActQueue$2.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -23114,6 +23020,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; + break; + + case IdleEventPriority: + schedulerPriorityLevel = IdlePriority; + break; + + default: + schedulerPriorityLevel = NormalPriority; + 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$2(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$2(ImmediatePriority, cb); + } +} + var ceil = Math.ceil; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -23238,6 +23514,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. @@ -23403,21 +23682,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(); + } } } } @@ -23425,147 +23708,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; - break; - - case IdleEventPriority: - schedulerPriorityLevel = IdlePriority; - break; - - default: - schedulerPriorityLevel = NormalPriority; - 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. @@ -23597,6 +23739,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, @@ -23647,7 +23790,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -23697,7 +23840,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. @@ -23710,15 +23853,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( @@ -24076,12 +24212,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; } @@ -24112,7 +24249,7 @@ function performSyncWorkOnRoot(root) { var fatalError = workInProgressRootFatalError; prepareFreshStack(root, NoLanes); markRootSuspended(root, lanes); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); throw fatalError; } @@ -24121,7 +24258,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. @@ -24136,7 +24273,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() { @@ -24157,7 +24294,7 @@ function batchedUpdates(fn, a) { !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); + flushSyncWorkOnLegacyRootsOnly(); } } } @@ -24199,7 +24336,7 @@ function flushSync(fn) { // the stack. if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); } } } @@ -24711,7 +24848,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); @@ -25440,7 +25577,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 @@ -25493,7 +25630,7 @@ function commitRootImpl( nestedUpdateCount = 0; } // If layout work was scheduled, flush it now. - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { markCommitStopped(); @@ -25613,7 +25750,7 @@ function flushPassiveEffectsImpl() { } executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkOnAllRoots(); { // If additional passive effects were scheduled, increment a counter. If this @@ -25675,7 +25812,7 @@ function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -25714,7 +25851,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { if (root !== null) { markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } return; @@ -25790,7 +25927,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { pingCache.delete(wakeable); } - var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); warnIfSuspenseResolutionNotWrappedWithActDEV(root); @@ -25826,7 +25962,7 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { } } - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } function retryTimedOutBoundary(boundaryFiber, retryLane) { @@ -25845,7 +25981,7 @@ function retryTimedOutBoundary(boundaryFiber, retryLane) { if (root !== null) { markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root); } } @@ -26231,19 +26367,11 @@ function scheduleCallback(priorityLevel, callback) { actQueue.push(callback); return fakeActCallbackNode; } else { - return scheduleCallback$1(priorityLevel, callback); + return scheduleCallback$2(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; @@ -27460,6 +27588,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); @@ -27552,7 +27681,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-8310854ce-20230331"; +var ReactVersion = "18.3.0-next-09c8d2563-20230331"; function createPortal$1( children, diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 335415f170..263b842e66 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -940,7 +940,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_247 = { +var injectedNamesToPlugins$jscomp$inline_248 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -986,32 +986,32 @@ var injectedNamesToPlugins$jscomp$inline_247 = { } } }, - isOrderingDirty$jscomp$inline_248 = !1, - pluginName$jscomp$inline_249; -for (pluginName$jscomp$inline_249 in injectedNamesToPlugins$jscomp$inline_247) + isOrderingDirty$jscomp$inline_249 = !1, + pluginName$jscomp$inline_250; +for (pluginName$jscomp$inline_250 in injectedNamesToPlugins$jscomp$inline_248) if ( - injectedNamesToPlugins$jscomp$inline_247.hasOwnProperty( - pluginName$jscomp$inline_249 + injectedNamesToPlugins$jscomp$inline_248.hasOwnProperty( + pluginName$jscomp$inline_250 ) ) { - var pluginModule$jscomp$inline_250 = - injectedNamesToPlugins$jscomp$inline_247[pluginName$jscomp$inline_249]; + var pluginModule$jscomp$inline_251 = + injectedNamesToPlugins$jscomp$inline_248[pluginName$jscomp$inline_250]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_249) || - namesToPlugins[pluginName$jscomp$inline_249] !== - pluginModule$jscomp$inline_250 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_250) || + namesToPlugins[pluginName$jscomp$inline_250] !== + pluginModule$jscomp$inline_251 ) { - if (namesToPlugins[pluginName$jscomp$inline_249]) + if (namesToPlugins[pluginName$jscomp$inline_250]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_249 + "`.") + (pluginName$jscomp$inline_250 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_249] = - pluginModule$jscomp$inline_250; - isOrderingDirty$jscomp$inline_248 = !0; + namesToPlugins[pluginName$jscomp$inline_250] = + pluginModule$jscomp$inline_251; + isOrderingDirty$jscomp$inline_249 = !0; } } -isOrderingDirty$jscomp$inline_248 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_249 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1160,6 +1160,8 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, + enableDeferRootSchedulingToMicrotask = + dynamicFlags.enableDeferRootSchedulingToMicrotask, REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -1699,7 +1701,7 @@ var ReactNativeFiberHostComponent = (function () { }; return ReactNativeFiberHostComponent; })(), - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -2103,50 +2105,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$1( - 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) { @@ -3625,10 +3584,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$29 = thenableIndexCounter; + var index$27 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$29); + usable = trackUsedThenable(thenableState, usable, index$27); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -5773,14 +5732,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$66 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$66 = lastTailNode), + for (var lastTailNode$64 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$66 + null === lastTailNode$64 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$66.sibling = null); + : (lastTailNode$64.sibling = null); } } function bubbleProperties(completedWork) { @@ -5790,19 +5749,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$67 = completedWork.child; null !== child$67; ) - (newChildLanes |= child$67.lanes | child$67.childLanes), - (subtreeFlags |= child$67.subtreeFlags & 31457280), - (subtreeFlags |= child$67.flags & 31457280), - (child$67.return = completedWork), - (child$67 = child$67.sibling); + for (var child$65 = completedWork.child; null !== child$65; ) + (newChildLanes |= child$65.lanes | child$65.childLanes), + (subtreeFlags |= child$65.subtreeFlags & 31457280), + (subtreeFlags |= child$65.flags & 31457280), + (child$65.return = completedWork), + (child$65 = child$65.sibling); else - for (child$67 = completedWork.child; null !== child$67; ) - (newChildLanes |= child$67.lanes | child$67.childLanes), - (subtreeFlags |= child$67.subtreeFlags), - (subtreeFlags |= child$67.flags), - (child$67.return = completedWork), - (child$67 = child$67.sibling); + for (child$65 = completedWork.child; null !== child$65; ) + (newChildLanes |= child$65.lanes | child$65.childLanes), + (subtreeFlags |= child$65.subtreeFlags), + (subtreeFlags |= child$65.flags), + (child$65.return = completedWork), + (child$65 = child$65.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6259,8 +6218,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$82) { - captureCommitPhaseError(current, nearestMountedAncestor, error$82); + } catch (error$80) { + captureCommitPhaseError(current, nearestMountedAncestor, error$80); } else ref.current = null; } @@ -6363,8 +6322,8 @@ function commitHookEffectListMount(flags, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & flags) === flags) { - var create$83 = effect.create; - effect.destroy = create$83(); + var create$81 = effect.create; + effect.destroy = create$81(); } effect = effect.next; } while (effect !== finishedWork); @@ -6418,11 +6377,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$84) { + } catch (error$82) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$84 + error$82 ); } } @@ -6905,8 +6864,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$92) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$92); + } catch (error$90) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$90); } } break; @@ -6955,11 +6914,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { viewConfig.uiViewClassName, updatePayload$jscomp$0 ); - } catch (error$95) { + } catch (error$93) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$95 + error$93 ); } } @@ -6980,8 +6939,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { "RCTRawText", { text: current } ); - } catch (error$96) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$96); + } catch (error$94) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$94); } } break; @@ -7094,11 +7053,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { throw Error("Not yet implemented."); - } catch (error$86) { + } catch (error$84) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$86 + error$84 ); } } else if ( @@ -7172,12 +7131,12 @@ function commitReconciliationEffects(finishedWork) { break; case 3: case 4: - var parent$87 = JSCompiler_inline_result.stateNode.containerInfo, - before$88 = getHostSibling(finishedWork); + var parent$85 = JSCompiler_inline_result.stateNode.containerInfo, + before$86 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$88, - parent$87 + before$86, + parent$85 ); break; default: @@ -7595,6 +7554,202 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin( } } } +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), + scheduleCallback$2(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("Should not already be working."); + 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$2(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$6 = 31 - clz32(lanes), + lane = 1 << index$6, + expirationTime = expirationTimes[index$6]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$6] = 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; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$2(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -7660,87 +7815,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() + 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$6 = 31 - clz32(lanes), - lane = 1 << index$6, - expirationTime = expirationTimes[index$6]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$6] = 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$1(ImmediatePriority, flushSyncCallbacks), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(suspendedLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; - } + flushSyncWorkAcrossRoots_impl(!0)); } function performConcurrentWorkOnRoot(root, didTimeout) { currentEventTime = -1; @@ -7781,7 +7861,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); @@ -7795,16 +7875,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { exitStatus = renderRootSync(root, lanes); if (2 === exitStatus) { errorRetryLanes = lanes; - var errorRetryLanes$104 = getLanesToRetrySynchronouslyOnError( + var errorRetryLanes$103 = getLanesToRetrySynchronouslyOnError( root, errorRetryLanes ); - 0 !== errorRetryLanes$104 && - ((lanes = errorRetryLanes$104), + 0 !== errorRetryLanes$103 && + ((lanes = errorRetryLanes$103), (exitStatus = recoverFromConcurrentError( root, errorRetryLanes, - errorRetryLanes$104 + errorRetryLanes$103 ))); } if (1 === exitStatus) @@ -7812,7 +7892,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -7865,14 +7945,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if ((lanes & 8388480) === lanes) break; exitStatus = lanes; errorRetryLanes = root.eventTimes; - for (errorRetryLanes$104 = -1; 0 < exitStatus; ) { + for (errorRetryLanes$103 = -1; 0 < exitStatus; ) { var index$5 = 31 - clz32(exitStatus), lane = 1 << index$5; index$5 = errorRetryLanes[index$5]; - index$5 > errorRetryLanes$104 && (errorRetryLanes$104 = index$5); + index$5 > errorRetryLanes$103 && (errorRetryLanes$103 = index$5); exitStatus &= ~lane; } - exitStatus = errorRetryLanes$104; + exitStatus = errorRetryLanes$103; exitStatus = now() - exitStatus; exitStatus = (120 > exitStatus @@ -7924,10 +8004,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, @@ -8020,49 +8103,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 6)) - throw Error("Should not already be working."); - 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) @@ -8180,8 +8220,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$107) { - handleThrow(root, thrownValue$107); + } catch (thrownValue$106) { + handleThrow(root, thrownValue$106); } while (1); resetContextDependencies(); @@ -8229,7 +8269,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); }; thrownValue.then(lanes, lanes); break a; @@ -8286,8 +8326,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$109) { - handleThrow(root, thrownValue$109); + } catch (thrownValue$108) { + handleThrow(root, thrownValue$108); } while (1); resetContextDependencies(); @@ -8441,10 +8481,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$36 = offscreenQueue.retryQueue; - null === retryQueue$36 + var retryQueue$34 = offscreenQueue.retryQueue; + null === retryQueue$34 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$36.add(wakeable); + : retryQueue$34.add(wakeable); } } break; @@ -8638,7 +8678,7 @@ function commitRootImpl( remainingLanes = root.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(transitions.stateNode, renderPriorityLevel); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, transitions = 0; @@ -8667,7 +8707,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); return null; } function flushPassiveEffects() { @@ -8691,7 +8731,7 @@ function flushPassiveEffects() { commitPassiveUnmountOnFiber(renderPriority.current); commitPassiveMountOnFiber(renderPriority, renderPriority.current); executionContext = prevExecutionContext; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if ( injectedHook && "function" === typeof injectedHook.onPostCommitFiberRoot @@ -8716,7 +8756,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) @@ -8753,7 +8793,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -8779,7 +8819,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 && @@ -8790,7 +8829,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 && @@ -8799,7 +8838,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, @@ -9272,7 +9311,7 @@ beginWork = function (current, workInProgress, renderLanes) { ); }; function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$1(priorityLevel, callback); + return scheduleCallback$2(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -9544,6 +9583,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -9752,14 +9792,14 @@ batchedUpdatesImpl = function (fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1086 = { + devToolsConfig$jscomp$inline_1105 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-next-8310854ce-20230331", + version: "18.3.0-next-09c8d2563-20230331", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -9774,11 +9814,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1339 = { - bundleType: devToolsConfig$jscomp$inline_1086.bundleType, - version: devToolsConfig$jscomp$inline_1086.version, - rendererPackageName: devToolsConfig$jscomp$inline_1086.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1086.rendererConfig, +var internals$jscomp$inline_1357 = { + bundleType: devToolsConfig$jscomp$inline_1105.bundleType, + version: devToolsConfig$jscomp$inline_1105.version, + rendererPackageName: devToolsConfig$jscomp$inline_1105.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1105.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9794,26 +9834,26 @@ var internals$jscomp$inline_1339 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1086.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1105.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-8310854ce-20230331" + reconcilerVersion: "18.3.0-next-09c8d2563-20230331" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1340 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1358 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1340.isDisabled && - hook$jscomp$inline_1340.supportsFiber + !hook$jscomp$inline_1358.isDisabled && + hook$jscomp$inline_1358.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1340.inject( - internals$jscomp$inline_1339 + (rendererID = hook$jscomp$inline_1358.inject( + internals$jscomp$inline_1357 )), - (injectedHook = hook$jscomp$inline_1340); + (injectedHook = hook$jscomp$inline_1358); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index fb1373931e..f01aac5d92 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -951,7 +951,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_263 = { +var injectedNamesToPlugins$jscomp$inline_264 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -997,32 +997,32 @@ var injectedNamesToPlugins$jscomp$inline_263 = { } } }, - isOrderingDirty$jscomp$inline_264 = !1, - pluginName$jscomp$inline_265; -for (pluginName$jscomp$inline_265 in injectedNamesToPlugins$jscomp$inline_263) + isOrderingDirty$jscomp$inline_265 = !1, + pluginName$jscomp$inline_266; +for (pluginName$jscomp$inline_266 in injectedNamesToPlugins$jscomp$inline_264) if ( - injectedNamesToPlugins$jscomp$inline_263.hasOwnProperty( - pluginName$jscomp$inline_265 + injectedNamesToPlugins$jscomp$inline_264.hasOwnProperty( + pluginName$jscomp$inline_266 ) ) { - var pluginModule$jscomp$inline_266 = - injectedNamesToPlugins$jscomp$inline_263[pluginName$jscomp$inline_265]; + var pluginModule$jscomp$inline_267 = + injectedNamesToPlugins$jscomp$inline_264[pluginName$jscomp$inline_266]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_265) || - namesToPlugins[pluginName$jscomp$inline_265] !== - pluginModule$jscomp$inline_266 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_266) || + namesToPlugins[pluginName$jscomp$inline_266] !== + pluginModule$jscomp$inline_267 ) { - if (namesToPlugins[pluginName$jscomp$inline_265]) + if (namesToPlugins[pluginName$jscomp$inline_266]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_265 + "`.") + (pluginName$jscomp$inline_266 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_265] = - pluginModule$jscomp$inline_266; - isOrderingDirty$jscomp$inline_264 = !0; + namesToPlugins[pluginName$jscomp$inline_266] = + pluginModule$jscomp$inline_267; + isOrderingDirty$jscomp$inline_265 = !0; } } -isOrderingDirty$jscomp$inline_264 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_265 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1171,6 +1171,8 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, + enableDeferRootSchedulingToMicrotask = + dynamicFlags.enableDeferRootSchedulingToMicrotask, REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -1710,7 +1712,7 @@ var ReactNativeFiberHostComponent = (function () { }; return ReactNativeFiberHostComponent; })(), - scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + scheduleCallback$2 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, requestPaint = Scheduler.unstable_requestPaint, @@ -2231,50 +2233,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$1( - 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) { @@ -3753,10 +3712,10 @@ createFunctionComponentUpdateQueue = function () { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) { - var index$32 = thenableIndexCounter; + var index$30 = thenableIndexCounter; thenableIndexCounter += 1; null === thenableState && (thenableState = []); - usable = trackUsedThenable(thenableState, usable, index$32); + usable = trackUsedThenable(thenableState, usable, index$30); null === currentlyRenderingFiber$1.alternate && (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState @@ -6001,14 +5960,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$70 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$70 = lastTailNode), + for (var lastTailNode$68 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$68 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$70 + null === lastTailNode$68 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$70.sibling = null); + : (lastTailNode$68.sibling = null); } } function bubbleProperties(completedWork) { @@ -6020,53 +5979,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$72 = completedWork.selfBaseDuration, - child$73 = completedWork.child; - null !== child$73; + var treeBaseDuration$70 = completedWork.selfBaseDuration, + child$71 = completedWork.child; + null !== child$71; ) - (newChildLanes |= child$73.lanes | child$73.childLanes), - (subtreeFlags |= child$73.subtreeFlags & 31457280), - (subtreeFlags |= child$73.flags & 31457280), - (treeBaseDuration$72 += child$73.treeBaseDuration), - (child$73 = child$73.sibling); - completedWork.treeBaseDuration = treeBaseDuration$72; + (newChildLanes |= child$71.lanes | child$71.childLanes), + (subtreeFlags |= child$71.subtreeFlags & 31457280), + (subtreeFlags |= child$71.flags & 31457280), + (treeBaseDuration$70 += child$71.treeBaseDuration), + (child$71 = child$71.sibling); + completedWork.treeBaseDuration = treeBaseDuration$70; } else for ( - treeBaseDuration$72 = completedWork.child; - null !== treeBaseDuration$72; + treeBaseDuration$70 = completedWork.child; + null !== treeBaseDuration$70; ) (newChildLanes |= - treeBaseDuration$72.lanes | treeBaseDuration$72.childLanes), - (subtreeFlags |= treeBaseDuration$72.subtreeFlags & 31457280), - (subtreeFlags |= treeBaseDuration$72.flags & 31457280), - (treeBaseDuration$72.return = completedWork), - (treeBaseDuration$72 = treeBaseDuration$72.sibling); + treeBaseDuration$70.lanes | treeBaseDuration$70.childLanes), + (subtreeFlags |= treeBaseDuration$70.subtreeFlags & 31457280), + (subtreeFlags |= treeBaseDuration$70.flags & 31457280), + (treeBaseDuration$70.return = completedWork), + (treeBaseDuration$70 = treeBaseDuration$70.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$72 = completedWork.actualDuration; - child$73 = completedWork.selfBaseDuration; + treeBaseDuration$70 = completedWork.actualDuration; + child$71 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$72 += child.actualDuration), - (child$73 += child.treeBaseDuration), + (treeBaseDuration$70 += child.actualDuration), + (child$71 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$72; - completedWork.treeBaseDuration = child$73; + completedWork.actualDuration = treeBaseDuration$70; + completedWork.treeBaseDuration = child$71; } else for ( - treeBaseDuration$72 = completedWork.child; - null !== treeBaseDuration$72; + treeBaseDuration$70 = completedWork.child; + null !== treeBaseDuration$70; ) (newChildLanes |= - treeBaseDuration$72.lanes | treeBaseDuration$72.childLanes), - (subtreeFlags |= treeBaseDuration$72.subtreeFlags), - (subtreeFlags |= treeBaseDuration$72.flags), - (treeBaseDuration$72.return = completedWork), - (treeBaseDuration$72 = treeBaseDuration$72.sibling); + treeBaseDuration$70.lanes | treeBaseDuration$70.childLanes), + (subtreeFlags |= treeBaseDuration$70.subtreeFlags), + (subtreeFlags |= treeBaseDuration$70.flags), + (treeBaseDuration$70.return = completedWork), + (treeBaseDuration$70 = treeBaseDuration$70.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6581,8 +6540,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (error$91) { - captureCommitPhaseError(current, nearestMountedAncestor, error$91); + } catch (error$89) { + captureCommitPhaseError(current, nearestMountedAncestor, error$89); } else ref.current = null; } @@ -6714,8 +6673,8 @@ function commitHookEffectListMount(flags, finishedWork) { injectedProfilingHooks.markComponentLayoutEffectMountStarted( finishedWork ); - var create$92 = effect.create; - effect.destroy = create$92(); + var create$90 = effect.create; + effect.destroy = create$90(); 0 !== (flags & 8) ? null !== injectedProfilingHooks && "function" === @@ -6743,8 +6702,8 @@ function commitHookLayoutEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$94) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$94); + } catch (error$92) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$92); } } function commitClassCallbacks(finishedWork) { @@ -6824,11 +6783,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { } else try { finishedRoot.componentDidMount(); - } catch (error$95) { + } catch (error$93) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$95 + error$93 ); } else { @@ -6845,11 +6804,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$96) { + } catch (error$94) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$96 + error$94 ); } recordLayoutEffectDuration(finishedWork); @@ -6860,11 +6819,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$97) { + } catch (error$95) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$97 + error$95 ); } } @@ -7373,22 +7332,22 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { startLayoutEffectTimer(), commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$106) { + } catch (error$104) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$106 + error$104 ); } recordLayoutEffectDuration(finishedWork); } else try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$107) { + } catch (error$105) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$107 + error$105 ); } } @@ -7438,11 +7397,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { viewConfig.uiViewClassName, updatePayload$jscomp$0 ); - } catch (error$110) { + } catch (error$108) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$110 + error$108 ); } } @@ -7463,8 +7422,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { "RCTRawText", { text: current } ); - } catch (error$111) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$111); + } catch (error$109) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$109); } } break; @@ -7577,11 +7536,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { throw Error("Not yet implemented."); - } catch (error$100) { + } catch (error$98) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$100 + error$98 ); } } else if ( @@ -7655,12 +7614,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: @@ -7846,8 +7805,8 @@ function commitHookPassiveMountEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$118) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$118); + } catch (error$116) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$116); } } function recursivelyTraversePassiveMountEffects(root, parentFiber) { @@ -8120,6 +8079,204 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin( } } } +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), + scheduleCallback$2(ImmediatePriority, 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 = 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; + currentUpdateIsNested = nestedUpdateScheduled; + nestedUpdateScheduled = !1; + if (0 !== (executionContext & 6)) + throw Error("Should not already be working."); + 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$2(ImmediatePriority, workInProgressRoot$jscomp$0); + } + 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$7 = 31 - clz32(lanes), + lane = 1 << index$7, + expirationTime = expirationTimes[index$7]; + if (-1 === expirationTime) { + if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) + expirationTimes[index$7] = 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; + break; + case 536870912: + suspendedLanes = IdlePriority; + break; + default: + suspendedLanes = NormalPriority; + } + pingedLanes = performConcurrentWorkOnRoot.bind(null, root); + suspendedLanes = scheduleCallback$2(suspendedLanes, pingedLanes); + root.callbackPriority = currentTime; + root.callbackNode = suspendedLanes; + return currentTime; +} var ceil = Math.ceil, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, @@ -8187,87 +8344,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) { - for ( - var existingCallbackNode = root.callbackNode, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes & -125829121; - 0 < lanes; - - ) { - var index$7 = 31 - clz32(lanes), - lane = 1 << index$7, - expirationTime = expirationTimes[index$7]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$7] = 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$1(ImmediatePriority, flushSyncCallbacks), - (existingCallbackNode = null); - else { - switch (lanesToEventPriority(suspendedLanes)) { - case 2: - existingCallbackNode = ImmediatePriority; - break; - case 8: - existingCallbackNode = UserBlockingPriority; - break; - case 32: - existingCallbackNode = NormalPriority; - break; - case 536870912: - existingCallbackNode = IdlePriority; - break; - default: - existingCallbackNode = NormalPriority; - } - existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ); - } - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; - } + flushSyncWorkAcrossRoots_impl(!0)); } function performConcurrentWorkOnRoot(root, didTimeout) { nestedUpdateScheduled = currentUpdateIsNested = !1; @@ -8309,7 +8391,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); @@ -8323,16 +8405,16 @@ function performConcurrentWorkOnRoot(root, didTimeout) { exitStatus = renderRootSync(root, lanes); if (2 === exitStatus) { errorRetryLanes = lanes; - var errorRetryLanes$120 = getLanesToRetrySynchronouslyOnError( + var errorRetryLanes$119 = getLanesToRetrySynchronouslyOnError( root, errorRetryLanes ); - 0 !== errorRetryLanes$120 && - ((lanes = errorRetryLanes$120), + 0 !== errorRetryLanes$119 && + ((lanes = errorRetryLanes$119), (exitStatus = recoverFromConcurrentError( root, errorRetryLanes, - errorRetryLanes$120 + errorRetryLanes$119 ))); } if (1 === exitStatus) @@ -8340,7 +8422,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), markRootSuspended(root, lanes), - ensureRootIsScheduled(root, now$1()), + ensureRootIsScheduled(root), originalCallbackNode) ); } @@ -8393,14 +8475,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if ((lanes & 8388480) === lanes) break; exitStatus = lanes; errorRetryLanes = root.eventTimes; - for (errorRetryLanes$120 = -1; 0 < exitStatus; ) { + for (errorRetryLanes$119 = -1; 0 < exitStatus; ) { var index$6 = 31 - clz32(exitStatus), lane = 1 << index$6; index$6 = errorRetryLanes[index$6]; - index$6 > errorRetryLanes$120 && (errorRetryLanes$120 = index$6); + index$6 > errorRetryLanes$119 && (errorRetryLanes$119 = index$6); exitStatus &= ~lane; } - exitStatus = errorRetryLanes$120; + exitStatus = errorRetryLanes$119; exitStatus = now$1() - exitStatus; exitStatus = (120 > exitStatus @@ -8452,10 +8534,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, @@ -8548,51 +8633,6 @@ function markRootSuspended(root, suspendedLanes) { suspendedLanes &= ~lane; } } -function performSyncWorkOnRoot(root) { - currentUpdateIsNested = nestedUpdateScheduled; - nestedUpdateScheduled = !1; - if (0 !== (executionContext & 6)) - throw Error("Should not already be working."); - 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 resetWorkInProgressStack() { if (null !== workInProgress) { if (0 === workInProgressSuspendedReason) @@ -8749,8 +8789,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$123) { - handleThrow(root, thrownValue$123); + } catch (thrownValue$122) { + handleThrow(root, thrownValue$122); } while (1); resetContextDependencies(); @@ -8810,7 +8850,7 @@ function renderRootConcurrent(root, lanes) { 2 === workInProgressSuspendedReason && workInProgressRoot === root && (workInProgressSuspendedReason = 7); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); }; memoizedUpdaters.then(lanes, lanes); break a; @@ -8866,8 +8906,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$125) { - handleThrow(root, thrownValue$125); + } catch (thrownValue$124) { + handleThrow(root, thrownValue$124); } while (1); resetContextDependencies(); @@ -9039,10 +9079,10 @@ function throwAndUnwindWorkLoop(unitOfWork, thrownValue) { }; suspenseBoundary.updateQueue = newOffscreenQueue; } else { - var retryQueue$39 = offscreenQueue.retryQueue; - null === retryQueue$39 + var retryQueue$37 = offscreenQueue.retryQueue; + null === retryQueue$37 ? (offscreenQueue.retryQueue = new Set([wakeable])) - : retryQueue$39.add(wakeable); + : retryQueue$37.add(wakeable); } } break; @@ -9256,7 +9296,7 @@ function commitRootImpl( 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); onCommitRoot(transitions.stateNode, renderPriorityLevel); isDevToolsPresent && root.memoizedUpdaters.clear(); - ensureRootIsScheduled(root, now$1()); + ensureRootIsScheduled(root); if (null !== recoverableErrors) for ( renderPriorityLevel = root.onRecoverableError, transitions = 0; @@ -9286,7 +9326,7 @@ function commitRootImpl( ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))) : (nestedUpdateCount = 0); - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); markCommitStopped(); return null; } @@ -9327,11 +9367,11 @@ function flushPassiveEffects() { _finishedWork$memoize = finishedWork.memoizedProps, id = _finishedWork$memoize.id, onPostCommit = _finishedWork$memoize.onPostCommit, - commitTime$93 = commitTime, + commitTime$91 = commitTime, phase = null === finishedWork.alternate ? "mount" : "update"; currentUpdateIsNested && (phase = "nested-update"); "function" === typeof onPostCommit && - onPostCommit(id, phase, passiveEffectDuration, commitTime$93); + onPostCommit(id, phase, passiveEffectDuration, commitTime$91); var parentFiber = finishedWork.return; b: for (; null !== parentFiber; ) { switch (parentFiber.tag) { @@ -9353,7 +9393,7 @@ function flushPassiveEffects() { typeof injectedProfilingHooks.markPassiveEffectsStopped && injectedProfilingHooks.markPassiveEffectsStopped(); executionContext = lanes; - flushSyncCallbacks(); + flushSyncWorkAcrossRoots_impl(!1); if ( injectedHook && "function" === typeof injectedHook.onPostCommitFiberRoot @@ -9390,7 +9430,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) @@ -9427,7 +9467,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { sourceFiber = requestEventTime(); null !== nearestMountedAncestor && (markRootUpdated(nearestMountedAncestor, 2, sourceFiber), - ensureRootIsScheduled(nearestMountedAncestor, sourceFiber)); + ensureRootIsScheduled(nearestMountedAncestor)); break; } } @@ -9454,7 +9494,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 && @@ -9465,7 +9504,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 && @@ -9474,7 +9513,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, @@ -9961,7 +10000,7 @@ function restorePendingUpdaters(root, lanes) { }); } function scheduleCallback(priorityLevel, callback) { - return scheduleCallback$1(priorityLevel, callback); + return scheduleCallback$2(priorityLevel, callback); } function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; @@ -10245,6 +10284,7 @@ function FiberRootNode( null; this.timeoutHandle = -1; this.callbackNode = + this.next = this.pendingContext = this.context = this.cancelPendingCommit = @@ -10460,14 +10500,14 @@ batchedUpdatesImpl = function (fn, a) { (executionContext = prevExecutionContext), 0 === executionContext && ((workInProgressRootRenderTargetTime = now$1() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + flushSyncWorkAcrossRoots_impl(!0)); } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1165 = { + devToolsConfig$jscomp$inline_1183 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-next-8310854ce-20230331", + version: "18.3.0-next-09c8d2563-20230331", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -10496,10 +10536,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1165.bundleType, - version: devToolsConfig$jscomp$inline_1165.version, - rendererPackageName: devToolsConfig$jscomp$inline_1165.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1165.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1183.bundleType, + version: devToolsConfig$jscomp$inline_1183.version, + rendererPackageName: devToolsConfig$jscomp$inline_1183.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1183.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10515,14 +10555,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1165.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1183.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-8310854ce-20230331" + reconcilerVersion: "18.3.0-next-09c8d2563-20230331" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) {