From d2a3772cd075e0687c11343321d2f46adcfc961a Mon Sep 17 00:00:00 2001 From: sebmarkbage Date: Sun, 26 May 2024 22:00:39 +0000 Subject: [PATCH] [Fiber] Enable Native console.createTask Stacks When Available (#29223) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stacked on #29206 and #29221. This disables appending owner stacks to console when `console.createTask` is available in the environment. Instead we rely on native "async" stacks that end up looking like this with source maps and ignore list enabled. Screenshot 2024-05-22 at 4 00 27 PM Unfortunately Chrome requires a string name for each async stack and, worse, a suffix of `(async)` is automatically added which is very confusing since it seems like it might be an async component or something which it is not. In this case it's not so bad because it's nice to refer to the host component which otherwise doesn't have a stack frame since it's internal. However, if there were more owners here there would also be a ` (async)` which ends up being kind of duplicative. If the Chrome DevTools is not open from the start of the app, then `console.createTask` is disabled and so you lose the stack for those errors (or those parents if the devtools is opened later). Unlike our appended ones that are always added. That's unfortunate and likely to be a bit of a DX issue but it's also nice that it saves on perf in DEV mode for those cases. Framework dialogs can still surface the stack since we also track it in user space in parallel. This currently doesn't track Server Components yet. We need a more clever hack for that part in a follow up. I think I probably need to also add something to React DevTools to disable its stacks for this case too. Since it looks for stacks in the console.error and adds a stack otherwise. Since we don't add them anymore from the runtime, the DevTools adds them instead. DiffTrain build for [ea6e05912aa43a0bbfbee381752caa1817a41a86](https://github.com/facebook/react/commit/ea6e05912aa43a0bbfbee381752caa1817a41a86) --- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/ReactART-dev.classic.js | 394 ++++++++--------- compiled/facebook-www/ReactART-dev.modern.js | 386 ++++++++-------- .../facebook-www/ReactART-prod.classic.js | 79 ++-- compiled/facebook-www/ReactART-prod.modern.js | 77 ++-- compiled/facebook-www/ReactDOM-dev.classic.js | 414 ++++++++--------- compiled/facebook-www/ReactDOM-dev.modern.js | 406 ++++++++--------- .../facebook-www/ReactDOM-prod.classic.js | 119 +++-- compiled/facebook-www/ReactDOM-prod.modern.js | 117 +++-- .../ReactDOM-profiling.classic.js | 104 +++-- .../facebook-www/ReactDOM-profiling.modern.js | 102 +++-- .../ReactDOMTesting-dev.classic.js | 414 ++++++++--------- .../ReactDOMTesting-dev.modern.js | 406 ++++++++--------- .../ReactDOMTesting-prod.classic.js | 119 +++-- .../ReactDOMTesting-prod.modern.js | 117 +++-- .../ReactReconciler-dev.classic.js | 418 ++++++++---------- .../ReactReconciler-dev.modern.js | 410 ++++++++--------- .../ReactReconciler-prod.classic.js | 51 +-- .../ReactReconciler-prod.modern.js | 49 +- .../ReactTestRenderer-dev.classic.js | 382 ++++++++-------- .../ReactTestRenderer-dev.modern.js | 382 ++++++++-------- 21 files changed, 2228 insertions(+), 2720 deletions(-) diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 556138a30420b..7ebb26ed718bf 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -d6cfa0f295f4c8b366af15fd20c84e27cdd1fab7 +ea6e05912aa43a0bbfbee381752caa1817a41a86 diff --git a/compiled/facebook-www/ReactART-dev.classic.js b/compiled/facebook-www/ReactART-dev.classic.js index 3e69e6fa59269..d29d58fd790e9 100644 --- a/compiled/facebook-www/ReactART-dev.classic.js +++ b/compiled/facebook-www/ReactART-dev.classic.js @@ -60,7 +60,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = '19.0.0-www-classic-5829b24d'; +var ReactVersion = '19.0.0-www-classic-1c397ec5'; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -167,6 +167,7 @@ var enableAsyncActions = true; var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler; var enableAsyncIterableChildren = false; var disableLegacyMode = false; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1119,15 +1120,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1145,11 +1154,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -5951,14 +5955,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -6314,12 +6313,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -6341,12 +6337,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -6359,13 +6352,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -12641,11 +12630,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -12672,11 +12659,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -12689,11 +12674,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -18581,15 +18564,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -18617,10 +18600,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -18702,10 +18681,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitBeforeMutationEffectsDeletion(deletion) { @@ -19121,7 +19096,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -19132,7 +19107,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -19151,7 +19126,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -19190,7 +19165,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -19208,7 +19183,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -19220,7 +19195,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } @@ -19250,14 +19225,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -19275,7 +19250,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -20230,9 +20205,11 @@ function isSuspenseBoundaryBeingHidden(current, finishedWork) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } @@ -20254,19 +20231,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitMutationEffectsOnFiber(finishedWork, root, lanes) { @@ -20281,7 +20256,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -20320,7 +20295,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -20346,7 +20321,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -20409,7 +20384,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -20439,7 +20414,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostRoot: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -20449,7 +20424,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostPortal: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -20458,7 +20433,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -20530,11 +20505,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); } commitReconciliationEffects(finishedWork); @@ -20597,7 +20572,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -20615,7 +20590,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -20637,7 +20612,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -20672,29 +20647,30 @@ function commitReconciliationEffects(finishedWork) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -20895,16 +20871,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -21063,25 +21040,23 @@ function commitTracingMarkerPassiveMountEffect(finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -21197,7 +21172,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -21269,15 +21244,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -21337,7 +21312,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -21404,19 +21379,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -21428,7 +21402,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -21442,7 +21416,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -21455,16 +21429,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -21610,21 +21584,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -21688,19 +21661,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -21742,9 +21714,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -23747,15 +23720,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -23775,9 +23753,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -23852,22 +23853,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -23954,20 +23942,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -24332,9 +24323,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -24882,13 +24874,9 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode) { - doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - - resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -24901,19 +24889,15 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only // if it is visible and its visibility has changed. - doubleInvokeEffectsOnFiber(root, fiber); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber); } else if (fiber.subtreeFlags & PlacementDEV) { // Something in the subtree could have been suspended. // We need to continue traversal and find newly inserted fibers. - recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); + runWithFiberInDEV(fiber, recursivelyTraverseAndDoubleInvokeEffectsInDEV, root, fiber, isInStrictMode); } - - resetCurrentDebugFiberInDEV(); } } @@ -24928,7 +24912,8 @@ function commitDoubleInvokeEffectsInDEV(root, hasPassiveEffects) { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, root.current, doubleInvokeEffects); } else { - legacyCommitDoubleInvokeEffectsInDEV(root.current, hasPassiveEffects); + // TODO: Is this runWithFiberInDEV needed since the other effect functions do it too? + runWithFiberInDEV(root.current, legacyCommitDoubleInvokeEffectsInDEV, root.current, hasPassiveEffects); } } } @@ -24937,7 +24922,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { // TODO (StrictEffects) Should we set a marker on the root if it contains strict effects // so we don't traverse unnecessarily? similar to subtreeFlags but just at the root level. // Maybe not a big deal since this is DEV only behavior. - setCurrentDebugFiberInDEV(fiber); invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV); if (hasPassiveEffects) { @@ -24949,8 +24933,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { if (hasPassiveEffects) { invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV); } - - resetCurrentDebugFiberInDEV(); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { @@ -25010,19 +24992,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -25131,19 +25103,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } diff --git a/compiled/facebook-www/ReactART-dev.modern.js b/compiled/facebook-www/ReactART-dev.modern.js index cf0136d83fcc2..ef8a0eaf05630 100644 --- a/compiled/facebook-www/ReactART-dev.modern.js +++ b/compiled/facebook-www/ReactART-dev.modern.js @@ -60,7 +60,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = '19.0.0-www-modern-aa8749b8'; +var ReactVersion = '19.0.0-www-modern-67a1f020'; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -167,6 +167,7 @@ var enableAsyncActions = true; var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler; var enableAsyncIterableChildren = false; var disableLegacyMode = true; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1121,15 +1122,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1147,11 +1156,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -5740,14 +5744,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -6103,12 +6102,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -6130,12 +6126,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -6148,13 +6141,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -12406,11 +12395,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -12437,11 +12424,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -12454,11 +12439,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -18086,15 +18069,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -18122,10 +18105,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -18207,10 +18186,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitBeforeMutationEffectsDeletion(deletion) { @@ -18626,7 +18601,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -18637,7 +18612,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -18656,7 +18631,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -18695,7 +18670,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -18713,7 +18688,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -18725,7 +18700,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } @@ -18755,14 +18730,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -18780,7 +18755,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -19733,9 +19708,11 @@ function isSuspenseBoundaryBeingHidden(current, finishedWork) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } @@ -19757,19 +19734,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitMutationEffectsOnFiber(finishedWork, root, lanes) { @@ -19784,7 +19759,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -19823,7 +19798,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -19849,7 +19824,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -19912,7 +19887,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -19942,7 +19917,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostRoot: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -19952,7 +19927,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostPortal: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -19961,7 +19936,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -20033,7 +20008,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } @@ -20098,7 +20073,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -20116,7 +20091,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -20138,7 +20113,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -20173,29 +20148,30 @@ function commitReconciliationEffects(finishedWork) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -20396,16 +20372,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -20564,25 +20541,23 @@ function commitTracingMarkerPassiveMountEffect(finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -20698,7 +20673,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } } @@ -20766,15 +20741,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -20834,7 +20809,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } } @@ -20897,19 +20872,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -20921,7 +20895,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -20935,7 +20909,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -20948,16 +20922,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -21103,21 +21077,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -21181,19 +21154,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -21235,9 +21207,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -23106,15 +23079,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -23134,9 +23112,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -23206,22 +23207,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -23308,20 +23296,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -23686,9 +23677,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -24236,13 +24228,9 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode) { - doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - - resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -24255,19 +24243,15 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only // if it is visible and its visibility has changed. - doubleInvokeEffectsOnFiber(root, fiber); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber); } else if (fiber.subtreeFlags & PlacementDEV) { // Something in the subtree could have been suspended. // We need to continue traversal and find newly inserted fibers. - recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); + runWithFiberInDEV(fiber, recursivelyTraverseAndDoubleInvokeEffectsInDEV, root, fiber, isInStrictMode); } - - resetCurrentDebugFiberInDEV(); } } @@ -24315,19 +24299,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -24418,19 +24392,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } diff --git a/compiled/facebook-www/ReactART-prod.classic.js b/compiled/facebook-www/ReactART-prod.classic.js index 4f259494e6de2..e024bef9b22d6 100644 --- a/compiled/facebook-www/ReactART-prod.classic.js +++ b/compiled/facebook-www/ReactART-prod.classic.js @@ -9673,24 +9673,24 @@ function performUnitOfWork(unitOfWork) { null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate; - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate; + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); var context = isContextProvider(Component) ? previousContext : contextStackCursor$1.current; - context = getMaskedContext(unitOfWork, context); - current$jscomp$0 = replayFunctionComponent( + context = getMaskedContext(next, context); + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, context, @@ -9698,39 +9698,32 @@ function replaySuspendedUnitOfWork(unitOfWork) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), - (current$jscomp$0 = beginWork( - current$jscomp$0, - unitOfWork, - entangledRenderLanes - )); + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), + (next = beginWork(current$jscomp$0, next, entangledRenderLanes)); } current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -10646,19 +10639,19 @@ var slice = Array.prototype.slice, }; return Text; })(React.Component), - devToolsConfig$jscomp$inline_1146 = { + devToolsConfig$jscomp$inline_1158 = { findFiberByHostInstance: function () { return null; }, bundleType: 0, - version: "19.0.0-www-classic-f92fa0c7", + version: "19.0.0-www-classic-720dabbc", rendererPackageName: "react-art" }; -var internals$jscomp$inline_1358 = { - bundleType: devToolsConfig$jscomp$inline_1146.bundleType, - version: devToolsConfig$jscomp$inline_1146.version, - rendererPackageName: devToolsConfig$jscomp$inline_1146.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1146.rendererConfig, +var internals$jscomp$inline_1370 = { + bundleType: devToolsConfig$jscomp$inline_1158.bundleType, + version: devToolsConfig$jscomp$inline_1158.version, + rendererPackageName: devToolsConfig$jscomp$inline_1158.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1158.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10675,26 +10668,26 @@ var internals$jscomp$inline_1358 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1146.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1158.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-f92fa0c7" + reconcilerVersion: "19.0.0-www-classic-720dabbc" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1359 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1371 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1359.isDisabled && - hook$jscomp$inline_1359.supportsFiber + !hook$jscomp$inline_1371.isDisabled && + hook$jscomp$inline_1371.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1359.inject( - internals$jscomp$inline_1358 + (rendererID = hook$jscomp$inline_1371.inject( + internals$jscomp$inline_1370 )), - (injectedHook = hook$jscomp$inline_1359); + (injectedHook = hook$jscomp$inline_1371); } catch (err) {} } var Path = Mode$1.Path; diff --git a/compiled/facebook-www/ReactART-prod.modern.js b/compiled/facebook-www/ReactART-prod.modern.js index dee98d45a6091..70236117d068f 100644 --- a/compiled/facebook-www/ReactART-prod.modern.js +++ b/compiled/facebook-www/ReactART-prod.modern.js @@ -9197,20 +9197,20 @@ function performUnitOfWork(unitOfWork) { null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate; - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate; + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, void 0, @@ -9218,39 +9218,32 @@ function replaySuspendedUnitOfWork(unitOfWork) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), - (current$jscomp$0 = beginWork( - current$jscomp$0, - unitOfWork, - entangledRenderLanes - )); + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), + (next = beginWork(current$jscomp$0, next, entangledRenderLanes)); } current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -10121,19 +10114,19 @@ var slice = Array.prototype.slice, }; return Text; })(React.Component), - devToolsConfig$jscomp$inline_1111 = { + devToolsConfig$jscomp$inline_1122 = { findFiberByHostInstance: function () { return null; }, bundleType: 0, - version: "19.0.0-www-modern-0d5de310", + version: "19.0.0-www-modern-bfe50115", rendererPackageName: "react-art" }; -var internals$jscomp$inline_1345 = { - bundleType: devToolsConfig$jscomp$inline_1111.bundleType, - version: devToolsConfig$jscomp$inline_1111.version, - rendererPackageName: devToolsConfig$jscomp$inline_1111.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1111.rendererConfig, +var internals$jscomp$inline_1356 = { + bundleType: devToolsConfig$jscomp$inline_1122.bundleType, + version: devToolsConfig$jscomp$inline_1122.version, + rendererPackageName: devToolsConfig$jscomp$inline_1122.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1122.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10150,26 +10143,26 @@ var internals$jscomp$inline_1345 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1111.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1122.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-0d5de310" + reconcilerVersion: "19.0.0-www-modern-bfe50115" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1346 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1357 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1346.isDisabled && - hook$jscomp$inline_1346.supportsFiber + !hook$jscomp$inline_1357.isDisabled && + hook$jscomp$inline_1357.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1346.inject( - internals$jscomp$inline_1345 + (rendererID = hook$jscomp$inline_1357.inject( + internals$jscomp$inline_1356 )), - (injectedHook = hook$jscomp$inline_1346); + (injectedHook = hook$jscomp$inline_1357); } catch (err) {} } var Path = Mode$1.Path; diff --git a/compiled/facebook-www/ReactDOM-dev.classic.js b/compiled/facebook-www/ReactDOM-dev.classic.js index e966ac5ff6365..c97d764c219ce 100644 --- a/compiled/facebook-www/ReactDOM-dev.classic.js +++ b/compiled/facebook-www/ReactDOM-dev.classic.js @@ -134,6 +134,7 @@ var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler; var enableAsyncIterableChildren = false; var enableSuspenseCallback = true; var disableLegacyMode = false; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1096,15 +1097,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1122,11 +1131,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -9578,14 +9582,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -9948,12 +9947,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -9975,12 +9971,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -9993,13 +9986,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -16528,11 +16517,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -16559,11 +16546,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -16576,11 +16561,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -22898,15 +22881,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -22935,10 +22918,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -23026,10 +23005,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitBeforeMutationEffectsDeletion(deletion) { @@ -23446,7 +23421,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -23457,7 +23432,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -23476,7 +23451,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -23513,7 +23488,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostHoistable: { { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Ref) { safelyAttachRef(finishedWork, finishedWork.return); @@ -23527,7 +23502,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -23545,7 +23520,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -23557,7 +23532,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); @@ -23591,14 +23566,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -23616,7 +23591,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -24681,9 +24656,11 @@ function isSuspenseBoundaryBeingHidden(current, finishedWork) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } @@ -24705,19 +24682,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } var currentHoistableRoot = null; @@ -24734,7 +24709,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -24773,7 +24748,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24799,7 +24774,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { // We cast because we always set the root at the React root and so it cannot be // null while we are processing mutation effects var hoistableRoot = currentHoistableRoot; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24874,7 +24849,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24938,7 +24913,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -24971,7 +24946,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { prepareToCommitHoistables(); var previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(root.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); currentHoistableRoot = previousHoistableRoot; commitReconciliationEffects(finishedWork); } @@ -25014,7 +24989,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { { var _previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(finishedWork.stateNode.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); currentHoistableRoot = _previousHoistableRoot; } @@ -25024,7 +24999,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -25096,11 +25071,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); } commitReconciliationEffects(finishedWork); @@ -25163,7 +25138,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -25181,7 +25156,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -25204,7 +25179,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -25259,29 +25234,30 @@ function resetFormOnFiber(fiber) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -25487,16 +25463,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -25655,25 +25632,23 @@ function commitTracingMarkerPassiveMountEffect(finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -25789,7 +25764,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -25861,15 +25836,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -25929,7 +25904,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -25996,19 +25971,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -26020,7 +25994,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -26034,7 +26008,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -26047,16 +26021,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -26207,21 +26181,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -26285,19 +26258,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -26339,9 +26311,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -28485,15 +28458,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -28513,9 +28491,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -28590,22 +28591,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -28692,20 +28680,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -29082,9 +29073,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -29660,13 +29652,9 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode) { - doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - - resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -29679,19 +29667,15 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only // if it is visible and its visibility has changed. - doubleInvokeEffectsOnFiber(root, fiber); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber); } else if (fiber.subtreeFlags & PlacementDEV) { // Something in the subtree could have been suspended. // We need to continue traversal and find newly inserted fibers. - recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); + runWithFiberInDEV(fiber, recursivelyTraverseAndDoubleInvokeEffectsInDEV, root, fiber, isInStrictMode); } - - resetCurrentDebugFiberInDEV(); } } @@ -29706,7 +29690,8 @@ function commitDoubleInvokeEffectsInDEV(root, hasPassiveEffects) { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, root.current, doubleInvokeEffects); } else { - legacyCommitDoubleInvokeEffectsInDEV(root.current, hasPassiveEffects); + // TODO: Is this runWithFiberInDEV needed since the other effect functions do it too? + runWithFiberInDEV(root.current, legacyCommitDoubleInvokeEffectsInDEV, root.current, hasPassiveEffects); } } } @@ -29715,7 +29700,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { // TODO (StrictEffects) Should we set a marker on the root if it contains strict effects // so we don't traverse unnecessarily? similar to subtreeFlags but just at the root level. // Maybe not a big deal since this is DEV only behavior. - setCurrentDebugFiberInDEV(fiber); invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV); if (hasPassiveEffects) { @@ -29727,8 +29711,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { if (hasPassiveEffects) { invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV); } - - resetCurrentDebugFiberInDEV(); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { @@ -29788,19 +29770,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -29909,19 +29881,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } @@ -31088,7 +31050,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-classic-0392a6d6'; +var ReactVersion = '19.0.0-www-classic-70e5b810'; function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. implementation) { @@ -31182,25 +31144,13 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(hostFiber); - + runWithFiberInDEV(hostFiber, function () { if (fiber.mode & StrictLegacyMode) { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } else { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } - } finally { - // Ideally this should reset to previous but this shouldn't be called in - // render and there's another warning for that anyway. - if (previousFiber) { - setCurrentDebugFiberInDEV(previousFiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } diff --git a/compiled/facebook-www/ReactDOM-dev.modern.js b/compiled/facebook-www/ReactDOM-dev.modern.js index cab4d78a58caa..ee8c95f87f60d 100644 --- a/compiled/facebook-www/ReactDOM-dev.modern.js +++ b/compiled/facebook-www/ReactDOM-dev.modern.js @@ -131,6 +131,7 @@ var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler; var enableAsyncIterableChildren = false; var enableSuspenseCallback = true; var disableLegacyMode = true; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1095,15 +1096,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1121,11 +1130,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -9319,14 +9323,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -9689,12 +9688,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -9716,12 +9712,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -9734,13 +9727,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -16245,11 +16234,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -16276,11 +16263,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -16293,11 +16278,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -22355,15 +22338,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -22392,10 +22375,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -22483,10 +22462,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitBeforeMutationEffectsDeletion(deletion) { @@ -22903,7 +22878,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -22914,7 +22889,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -22933,7 +22908,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -22970,7 +22945,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostHoistable: { { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Ref) { safelyAttachRef(finishedWork, finishedWork.return); @@ -22984,7 +22959,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -23002,7 +22977,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -23014,7 +22989,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); @@ -23048,14 +23023,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -23073,7 +23048,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -24136,9 +24111,11 @@ function isSuspenseBoundaryBeingHidden(current, finishedWork) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } @@ -24160,19 +24137,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } var currentHoistableRoot = null; @@ -24189,7 +24164,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -24228,7 +24203,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24254,7 +24229,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { // We cast because we always set the root at the React root and so it cannot be // null while we are processing mutation effects var hoistableRoot = currentHoistableRoot; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24329,7 +24304,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24393,7 +24368,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -24426,7 +24401,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { prepareToCommitHoistables(); var previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(root.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); currentHoistableRoot = previousHoistableRoot; commitReconciliationEffects(finishedWork); } @@ -24469,7 +24444,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { { var _previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(finishedWork.stateNode.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); currentHoistableRoot = _previousHoistableRoot; } @@ -24479,7 +24454,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -24551,7 +24526,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } @@ -24616,7 +24591,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -24634,7 +24609,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -24657,7 +24632,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -24712,29 +24687,30 @@ function resetFormOnFiber(fiber) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -24940,16 +24916,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -25108,25 +25085,23 @@ function commitTracingMarkerPassiveMountEffect(finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -25242,7 +25217,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } } @@ -25310,15 +25285,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -25378,7 +25353,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } } @@ -25441,19 +25416,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -25465,7 +25439,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -25479,7 +25453,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -25492,16 +25466,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -25652,21 +25626,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -25730,19 +25703,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -25784,9 +25756,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -27741,15 +27714,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -27769,9 +27747,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -27841,22 +27842,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -27943,20 +27931,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -28333,9 +28324,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -28911,13 +28903,9 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode) { - doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - - resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -28930,19 +28918,15 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only // if it is visible and its visibility has changed. - doubleInvokeEffectsOnFiber(root, fiber); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber); } else if (fiber.subtreeFlags & PlacementDEV) { // Something in the subtree could have been suspended. // We need to continue traversal and find newly inserted fibers. - recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); + runWithFiberInDEV(fiber, recursivelyTraverseAndDoubleInvokeEffectsInDEV, root, fiber, isInStrictMode); } - - resetCurrentDebugFiberInDEV(); } } @@ -28990,19 +28974,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -29093,19 +29067,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } @@ -30263,7 +30227,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-modern-9bd19cf5'; +var ReactVersion = '19.0.0-www-modern-20c6b73e'; function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. implementation) { @@ -30357,25 +30321,13 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(hostFiber); - + runWithFiberInDEV(hostFiber, function () { if (fiber.mode & StrictLegacyMode) { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } else { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } - } finally { - // Ideally this should reset to previous but this shouldn't be called in - // render and there's another warning for that anyway. - if (previousFiber) { - setCurrentDebugFiberInDEV(previousFiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } diff --git a/compiled/facebook-www/ReactDOM-prod.classic.js b/compiled/facebook-www/ReactDOM-prod.classic.js index b1a4c80ab6704..f92cf1f7923eb 100644 --- a/compiled/facebook-www/ReactDOM-prod.classic.js +++ b/compiled/facebook-www/ReactDOM-prod.classic.js @@ -11518,24 +11518,24 @@ function performUnitOfWork(unitOfWork) { null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate; - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate; + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; - context = getMaskedContext(unitOfWork, context); - current$jscomp$0 = replayFunctionComponent( + context = getMaskedContext(next, context); + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, context, @@ -11543,39 +11543,32 @@ function replaySuspendedUnitOfWork(unitOfWork) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), - (current$jscomp$0 = beginWork( - current$jscomp$0, - unitOfWork, - entangledRenderLanes - )); + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), + (next = beginWork(current$jscomp$0, next, entangledRenderLanes)); } current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -13106,14 +13099,14 @@ var isInputEventSupported = !1; if (canUseDOM) { var JSCompiler_inline_result$jscomp$370; if (canUseDOM) { - var isSupported$jscomp$inline_1527 = "oninput" in document; - if (!isSupported$jscomp$inline_1527) { - var element$jscomp$inline_1528 = document.createElement("div"); - element$jscomp$inline_1528.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1527 = - "function" === typeof element$jscomp$inline_1528.oninput; + var isSupported$jscomp$inline_1539 = "oninput" in document; + if (!isSupported$jscomp$inline_1539) { + var element$jscomp$inline_1540 = document.createElement("div"); + element$jscomp$inline_1540.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1539 = + "function" === typeof element$jscomp$inline_1540.oninput; } - JSCompiler_inline_result$jscomp$370 = isSupported$jscomp$inline_1527; + JSCompiler_inline_result$jscomp$370 = isSupported$jscomp$inline_1539; } else JSCompiler_inline_result$jscomp$370 = !1; isInputEventSupported = JSCompiler_inline_result$jscomp$370 && @@ -13525,20 +13518,20 @@ function extractEvents$1( } } for ( - var i$jscomp$inline_1568 = 0; - i$jscomp$inline_1568 < simpleEventPluginEvents.length; - i$jscomp$inline_1568++ + var i$jscomp$inline_1580 = 0; + i$jscomp$inline_1580 < simpleEventPluginEvents.length; + i$jscomp$inline_1580++ ) { - var eventName$jscomp$inline_1569 = - simpleEventPluginEvents[i$jscomp$inline_1568], - domEventName$jscomp$inline_1570 = - eventName$jscomp$inline_1569.toLowerCase(), - capitalizedEvent$jscomp$inline_1571 = - eventName$jscomp$inline_1569[0].toUpperCase() + - eventName$jscomp$inline_1569.slice(1); + var eventName$jscomp$inline_1581 = + simpleEventPluginEvents[i$jscomp$inline_1580], + domEventName$jscomp$inline_1582 = + eventName$jscomp$inline_1581.toLowerCase(), + capitalizedEvent$jscomp$inline_1583 = + eventName$jscomp$inline_1581[0].toUpperCase() + + eventName$jscomp$inline_1581.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1570, - "on" + capitalizedEvent$jscomp$inline_1571 + domEventName$jscomp$inline_1582, + "on" + capitalizedEvent$jscomp$inline_1583 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -17068,17 +17061,17 @@ Internals.Events = [ return fn(a); } ]; -var devToolsConfig$jscomp$inline_1746 = { +var devToolsConfig$jscomp$inline_1758 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-classic-5570ad6d", + version: "19.0.0-www-classic-9f6bd68c", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2190 = { - bundleType: devToolsConfig$jscomp$inline_1746.bundleType, - version: devToolsConfig$jscomp$inline_1746.version, - rendererPackageName: devToolsConfig$jscomp$inline_1746.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1746.rendererConfig, +var internals$jscomp$inline_2202 = { + bundleType: devToolsConfig$jscomp$inline_1758.bundleType, + version: devToolsConfig$jscomp$inline_1758.version, + rendererPackageName: devToolsConfig$jscomp$inline_1758.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1758.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17094,26 +17087,26 @@ var internals$jscomp$inline_2190 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1746.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1758.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-5570ad6d" + reconcilerVersion: "19.0.0-www-classic-9f6bd68c" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2191 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2203 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2191.isDisabled && - hook$jscomp$inline_2191.supportsFiber + !hook$jscomp$inline_2203.isDisabled && + hook$jscomp$inline_2203.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2191.inject( - internals$jscomp$inline_2190 + (rendererID = hook$jscomp$inline_2203.inject( + internals$jscomp$inline_2202 )), - (injectedHook = hook$jscomp$inline_2191); + (injectedHook = hook$jscomp$inline_2203); } catch (err) {} } function ReactDOMRoot(internalRoot) { @@ -17605,4 +17598,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-classic-5570ad6d"; +exports.version = "19.0.0-www-classic-9f6bd68c"; diff --git a/compiled/facebook-www/ReactDOM-prod.modern.js b/compiled/facebook-www/ReactDOM-prod.modern.js index b3844cd7b9735..97220a0f400d0 100644 --- a/compiled/facebook-www/ReactDOM-prod.modern.js +++ b/compiled/facebook-www/ReactDOM-prod.modern.js @@ -11001,20 +11001,20 @@ function performUnitOfWork(unitOfWork) { null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate; - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate; + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, void 0, @@ -11022,39 +11022,32 @@ function replaySuspendedUnitOfWork(unitOfWork) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), - (current$jscomp$0 = beginWork( - current$jscomp$0, - unitOfWork, - entangledRenderLanes - )); + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), + (next = beginWork(current$jscomp$0, next, entangledRenderLanes)); } current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -12489,14 +12482,14 @@ var isInputEventSupported = !1; if (canUseDOM) { var JSCompiler_inline_result$jscomp$357; if (canUseDOM) { - var isSupported$jscomp$inline_1499 = "oninput" in document; - if (!isSupported$jscomp$inline_1499) { - var element$jscomp$inline_1500 = document.createElement("div"); - element$jscomp$inline_1500.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1499 = - "function" === typeof element$jscomp$inline_1500.oninput; + var isSupported$jscomp$inline_1510 = "oninput" in document; + if (!isSupported$jscomp$inline_1510) { + var element$jscomp$inline_1511 = document.createElement("div"); + element$jscomp$inline_1511.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1510 = + "function" === typeof element$jscomp$inline_1511.oninput; } - JSCompiler_inline_result$jscomp$357 = isSupported$jscomp$inline_1499; + JSCompiler_inline_result$jscomp$357 = isSupported$jscomp$inline_1510; } else JSCompiler_inline_result$jscomp$357 = !1; isInputEventSupported = JSCompiler_inline_result$jscomp$357 && @@ -12908,20 +12901,20 @@ function extractEvents$1( } } for ( - var i$jscomp$inline_1540 = 0; - i$jscomp$inline_1540 < simpleEventPluginEvents.length; - i$jscomp$inline_1540++ + var i$jscomp$inline_1551 = 0; + i$jscomp$inline_1551 < simpleEventPluginEvents.length; + i$jscomp$inline_1551++ ) { - var eventName$jscomp$inline_1541 = - simpleEventPluginEvents[i$jscomp$inline_1540], - domEventName$jscomp$inline_1542 = - eventName$jscomp$inline_1541.toLowerCase(), - capitalizedEvent$jscomp$inline_1543 = - eventName$jscomp$inline_1541[0].toUpperCase() + - eventName$jscomp$inline_1541.slice(1); + var eventName$jscomp$inline_1552 = + simpleEventPluginEvents[i$jscomp$inline_1551], + domEventName$jscomp$inline_1553 = + eventName$jscomp$inline_1552.toLowerCase(), + capitalizedEvent$jscomp$inline_1554 = + eventName$jscomp$inline_1552[0].toUpperCase() + + eventName$jscomp$inline_1552.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1542, - "on" + capitalizedEvent$jscomp$inline_1543 + domEventName$jscomp$inline_1553, + "on" + capitalizedEvent$jscomp$inline_1554 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -16431,17 +16424,17 @@ Internals.Events = [ return fn(a); } ]; -var devToolsConfig$jscomp$inline_1713 = { +var devToolsConfig$jscomp$inline_1724 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-modern-468632ed", + version: "19.0.0-www-modern-8100be65", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2182 = { - bundleType: devToolsConfig$jscomp$inline_1713.bundleType, - version: devToolsConfig$jscomp$inline_1713.version, - rendererPackageName: devToolsConfig$jscomp$inline_1713.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1713.rendererConfig, +var internals$jscomp$inline_2193 = { + bundleType: devToolsConfig$jscomp$inline_1724.bundleType, + version: devToolsConfig$jscomp$inline_1724.version, + rendererPackageName: devToolsConfig$jscomp$inline_1724.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1724.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -16457,26 +16450,26 @@ var internals$jscomp$inline_2182 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1713.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1724.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-468632ed" + reconcilerVersion: "19.0.0-www-modern-8100be65" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2183 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2194 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2183.isDisabled && - hook$jscomp$inline_2183.supportsFiber + !hook$jscomp$inline_2194.isDisabled && + hook$jscomp$inline_2194.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2183.inject( - internals$jscomp$inline_2182 + (rendererID = hook$jscomp$inline_2194.inject( + internals$jscomp$inline_2193 )), - (injectedHook = hook$jscomp$inline_2183); + (injectedHook = hook$jscomp$inline_2194); } catch (err) {} } function ReactDOMRoot(internalRoot) { @@ -16838,4 +16831,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-modern-468632ed"; +exports.version = "19.0.0-www-modern-8100be65"; diff --git a/compiled/facebook-www/ReactDOM-profiling.classic.js b/compiled/facebook-www/ReactDOM-profiling.classic.js index a17fa0a43144e..022f487c9219f 100644 --- a/compiled/facebook-www/ReactDOM-profiling.classic.js +++ b/compiled/facebook-www/ReactDOM-profiling.classic.js @@ -12187,26 +12187,26 @@ function performUnitOfWork(unitOfWork) { : (workInProgress = current$jscomp$0); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate, - isProfilingMode = 0 !== (unitOfWork.mode & 2); - isProfilingMode && startProfilerTimer(unitOfWork); - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate, + isProfilingMode = 0 !== (next.mode & 2); + isProfilingMode && startProfilerTimer(next); + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; - context = getMaskedContext(unitOfWork, context); + context = getMaskedContext(next, context); current$jscomp$0 = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, context, @@ -12214,40 +12214,38 @@ function replaySuspendedUnitOfWork(unitOfWork) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); current$jscomp$0 = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), (current$jscomp$0 = beginWork( current$jscomp$0, - unitOfWork, + next, entangledRenderLanes )); } - isProfilingMode && stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0); + isProfilingMode && stopProfilerTimerIfRunningAndRecordDelta(next, !0); + next = current$jscomp$0; current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -13870,14 +13868,14 @@ var isInputEventSupported = !1; if (canUseDOM) { var JSCompiler_inline_result$jscomp$391; if (canUseDOM) { - var isSupported$jscomp$inline_1613 = "oninput" in document; - if (!isSupported$jscomp$inline_1613) { - var element$jscomp$inline_1614 = document.createElement("div"); - element$jscomp$inline_1614.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1613 = - "function" === typeof element$jscomp$inline_1614.oninput; + var isSupported$jscomp$inline_1626 = "oninput" in document; + if (!isSupported$jscomp$inline_1626) { + var element$jscomp$inline_1627 = document.createElement("div"); + element$jscomp$inline_1627.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1626 = + "function" === typeof element$jscomp$inline_1627.oninput; } - JSCompiler_inline_result$jscomp$391 = isSupported$jscomp$inline_1613; + JSCompiler_inline_result$jscomp$391 = isSupported$jscomp$inline_1626; } else JSCompiler_inline_result$jscomp$391 = !1; isInputEventSupported = JSCompiler_inline_result$jscomp$391 && @@ -14289,20 +14287,20 @@ function extractEvents$1( } } for ( - var i$jscomp$inline_1654 = 0; - i$jscomp$inline_1654 < simpleEventPluginEvents.length; - i$jscomp$inline_1654++ + var i$jscomp$inline_1667 = 0; + i$jscomp$inline_1667 < simpleEventPluginEvents.length; + i$jscomp$inline_1667++ ) { - var eventName$jscomp$inline_1655 = - simpleEventPluginEvents[i$jscomp$inline_1654], - domEventName$jscomp$inline_1656 = - eventName$jscomp$inline_1655.toLowerCase(), - capitalizedEvent$jscomp$inline_1657 = - eventName$jscomp$inline_1655[0].toUpperCase() + - eventName$jscomp$inline_1655.slice(1); + var eventName$jscomp$inline_1668 = + simpleEventPluginEvents[i$jscomp$inline_1667], + domEventName$jscomp$inline_1669 = + eventName$jscomp$inline_1668.toLowerCase(), + capitalizedEvent$jscomp$inline_1670 = + eventName$jscomp$inline_1668[0].toUpperCase() + + eventName$jscomp$inline_1668.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1656, - "on" + capitalizedEvent$jscomp$inline_1657 + domEventName$jscomp$inline_1669, + "on" + capitalizedEvent$jscomp$inline_1670 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -17832,10 +17830,10 @@ Internals.Events = [ return fn(a); } ]; -var devToolsConfig$jscomp$inline_1832 = { +var devToolsConfig$jscomp$inline_1845 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-classic-1f9bd151", + version: "19.0.0-www-classic-8cd678b4", rendererPackageName: "react-dom" }; (function (internals) { @@ -17853,10 +17851,10 @@ var devToolsConfig$jscomp$inline_1832 = { } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1832.bundleType, - version: devToolsConfig$jscomp$inline_1832.version, - rendererPackageName: devToolsConfig$jscomp$inline_1832.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1832.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1845.bundleType, + version: devToolsConfig$jscomp$inline_1845.version, + rendererPackageName: devToolsConfig$jscomp$inline_1845.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1845.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17872,14 +17870,14 @@ var devToolsConfig$jscomp$inline_1832 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1832.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1845.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-1f9bd151" + reconcilerVersion: "19.0.0-www-classic-8cd678b4" }); function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; @@ -18370,7 +18368,7 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-classic-1f9bd151"; +exports.version = "19.0.0-www-classic-8cd678b4"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled/facebook-www/ReactDOM-profiling.modern.js b/compiled/facebook-www/ReactDOM-profiling.modern.js index 12c967ac07600..bbc68ed8506f4 100644 --- a/compiled/facebook-www/ReactDOM-profiling.modern.js +++ b/compiled/facebook-www/ReactDOM-profiling.modern.js @@ -11653,22 +11653,22 @@ function performUnitOfWork(unitOfWork) { : (workInProgress = current$jscomp$0); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate, - isProfilingMode = 0 !== (unitOfWork.mode & 2); - isProfilingMode && startProfilerTimer(unitOfWork); - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate, + isProfilingMode = 0 !== (next.mode & 2); + isProfilingMode && startProfilerTimer(next); + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); current$jscomp$0 = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, void 0, @@ -11676,40 +11676,38 @@ function replaySuspendedUnitOfWork(unitOfWork) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); current$jscomp$0 = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), (current$jscomp$0 = beginWork( current$jscomp$0, - unitOfWork, + next, entangledRenderLanes )); } - isProfilingMode && stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0); + isProfilingMode && stopProfilerTimerIfRunningAndRecordDelta(next, !0); + next = current$jscomp$0; current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -13236,14 +13234,14 @@ var isInputEventSupported = !1; if (canUseDOM) { var JSCompiler_inline_result$jscomp$378; if (canUseDOM) { - var isSupported$jscomp$inline_1585 = "oninput" in document; - if (!isSupported$jscomp$inline_1585) { - var element$jscomp$inline_1586 = document.createElement("div"); - element$jscomp$inline_1586.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1585 = - "function" === typeof element$jscomp$inline_1586.oninput; + var isSupported$jscomp$inline_1597 = "oninput" in document; + if (!isSupported$jscomp$inline_1597) { + var element$jscomp$inline_1598 = document.createElement("div"); + element$jscomp$inline_1598.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1597 = + "function" === typeof element$jscomp$inline_1598.oninput; } - JSCompiler_inline_result$jscomp$378 = isSupported$jscomp$inline_1585; + JSCompiler_inline_result$jscomp$378 = isSupported$jscomp$inline_1597; } else JSCompiler_inline_result$jscomp$378 = !1; isInputEventSupported = JSCompiler_inline_result$jscomp$378 && @@ -13655,20 +13653,20 @@ function extractEvents$1( } } for ( - var i$jscomp$inline_1626 = 0; - i$jscomp$inline_1626 < simpleEventPluginEvents.length; - i$jscomp$inline_1626++ + var i$jscomp$inline_1638 = 0; + i$jscomp$inline_1638 < simpleEventPluginEvents.length; + i$jscomp$inline_1638++ ) { - var eventName$jscomp$inline_1627 = - simpleEventPluginEvents[i$jscomp$inline_1626], - domEventName$jscomp$inline_1628 = - eventName$jscomp$inline_1627.toLowerCase(), - capitalizedEvent$jscomp$inline_1629 = - eventName$jscomp$inline_1627[0].toUpperCase() + - eventName$jscomp$inline_1627.slice(1); + var eventName$jscomp$inline_1639 = + simpleEventPluginEvents[i$jscomp$inline_1638], + domEventName$jscomp$inline_1640 = + eventName$jscomp$inline_1639.toLowerCase(), + capitalizedEvent$jscomp$inline_1641 = + eventName$jscomp$inline_1639[0].toUpperCase() + + eventName$jscomp$inline_1639.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1628, - "on" + capitalizedEvent$jscomp$inline_1629 + domEventName$jscomp$inline_1640, + "on" + capitalizedEvent$jscomp$inline_1641 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -17178,10 +17176,10 @@ Internals.Events = [ return fn(a); } ]; -var devToolsConfig$jscomp$inline_1799 = { +var devToolsConfig$jscomp$inline_1811 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-modern-f3b3106d", + version: "19.0.0-www-modern-d69be7d1", rendererPackageName: "react-dom" }; (function (internals) { @@ -17199,10 +17197,10 @@ var devToolsConfig$jscomp$inline_1799 = { } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1799.bundleType, - version: devToolsConfig$jscomp$inline_1799.version, - rendererPackageName: devToolsConfig$jscomp$inline_1799.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1799.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1811.bundleType, + version: devToolsConfig$jscomp$inline_1811.version, + rendererPackageName: devToolsConfig$jscomp$inline_1811.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1811.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17218,14 +17216,14 @@ var devToolsConfig$jscomp$inline_1799 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1799.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1811.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-f3b3106d" + reconcilerVersion: "19.0.0-www-modern-d69be7d1" }); function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; @@ -17586,7 +17584,7 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-modern-f3b3106d"; +exports.version = "19.0.0-www-modern-d69be7d1"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled/facebook-www/ReactDOMTesting-dev.classic.js b/compiled/facebook-www/ReactDOMTesting-dev.classic.js index 3bd4961221b47..51ba985dbfbd1 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.classic.js @@ -128,6 +128,7 @@ var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler; var enableAsyncIterableChildren = false; var enableSuspenseCallback = true; var disableLegacyMode = false; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1090,15 +1091,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1116,11 +1125,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -9719,14 +9723,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -10089,12 +10088,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -10116,12 +10112,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -10134,13 +10127,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -16669,11 +16658,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -16700,11 +16687,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -16717,11 +16702,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -23039,15 +23022,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -23076,10 +23059,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -23167,10 +23146,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitBeforeMutationEffectsDeletion(deletion) { @@ -23587,7 +23562,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -23598,7 +23573,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -23617,7 +23592,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -23654,7 +23629,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostHoistable: { { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Ref) { safelyAttachRef(finishedWork, finishedWork.return); @@ -23668,7 +23643,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -23686,7 +23661,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -23698,7 +23673,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); @@ -23732,14 +23707,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -23757,7 +23732,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -24822,9 +24797,11 @@ function isSuspenseBoundaryBeingHidden(current, finishedWork) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } @@ -24846,19 +24823,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } var currentHoistableRoot = null; @@ -24875,7 +24850,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -24914,7 +24889,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24940,7 +24915,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { // We cast because we always set the root at the React root and so it cannot be // null while we are processing mutation effects var hoistableRoot = currentHoistableRoot; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -25015,7 +24990,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -25079,7 +25054,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -25112,7 +25087,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { prepareToCommitHoistables(); var previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(root.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); currentHoistableRoot = previousHoistableRoot; commitReconciliationEffects(finishedWork); } @@ -25155,7 +25130,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { { var _previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(finishedWork.stateNode.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); currentHoistableRoot = _previousHoistableRoot; } @@ -25165,7 +25140,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -25237,11 +25212,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); } commitReconciliationEffects(finishedWork); @@ -25304,7 +25279,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -25322,7 +25297,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -25345,7 +25320,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -25400,29 +25375,30 @@ function resetFormOnFiber(fiber) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -25628,16 +25604,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -25796,25 +25773,23 @@ function commitTracingMarkerPassiveMountEffect(finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -25930,7 +25905,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -26002,15 +25977,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -26070,7 +26045,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -26137,19 +26112,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -26161,7 +26135,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -26175,7 +26149,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -26188,16 +26162,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -26348,21 +26322,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -26426,19 +26399,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -26480,9 +26452,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -29051,15 +29024,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -29079,9 +29057,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -29156,22 +29157,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -29258,20 +29246,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -29648,9 +29639,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -30226,13 +30218,9 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode) { - doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - - resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -30245,19 +30233,15 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only // if it is visible and its visibility has changed. - doubleInvokeEffectsOnFiber(root, fiber); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber); } else if (fiber.subtreeFlags & PlacementDEV) { // Something in the subtree could have been suspended. // We need to continue traversal and find newly inserted fibers. - recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); + runWithFiberInDEV(fiber, recursivelyTraverseAndDoubleInvokeEffectsInDEV, root, fiber, isInStrictMode); } - - resetCurrentDebugFiberInDEV(); } } @@ -30272,7 +30256,8 @@ function commitDoubleInvokeEffectsInDEV(root, hasPassiveEffects) { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, root.current, doubleInvokeEffects); } else { - legacyCommitDoubleInvokeEffectsInDEV(root.current, hasPassiveEffects); + // TODO: Is this runWithFiberInDEV needed since the other effect functions do it too? + runWithFiberInDEV(root.current, legacyCommitDoubleInvokeEffectsInDEV, root.current, hasPassiveEffects); } } } @@ -30281,7 +30266,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { // TODO (StrictEffects) Should we set a marker on the root if it contains strict effects // so we don't traverse unnecessarily? similar to subtreeFlags but just at the root level. // Maybe not a big deal since this is DEV only behavior. - setCurrentDebugFiberInDEV(fiber); invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV); if (hasPassiveEffects) { @@ -30293,8 +30277,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { if (hasPassiveEffects) { invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV); } - - resetCurrentDebugFiberInDEV(); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { @@ -30354,19 +30336,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -30475,19 +30447,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } @@ -31654,7 +31616,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-classic-c6c3b7e2'; +var ReactVersion = '19.0.0-www-classic-deb17ee3'; function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. implementation) { @@ -31748,25 +31710,13 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(hostFiber); - + runWithFiberInDEV(hostFiber, function () { if (fiber.mode & StrictLegacyMode) { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } else { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } - } finally { - // Ideally this should reset to previous but this shouldn't be called in - // render and there's another warning for that anyway. - if (previousFiber) { - setCurrentDebugFiberInDEV(previousFiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } diff --git a/compiled/facebook-www/ReactDOMTesting-dev.modern.js b/compiled/facebook-www/ReactDOMTesting-dev.modern.js index 68c6f64692f94..b76ee8af6ef25 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.modern.js @@ -125,6 +125,7 @@ var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler; var enableAsyncIterableChildren = false; var enableSuspenseCallback = true; var disableLegacyMode = true; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1089,15 +1090,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1115,11 +1124,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -9460,14 +9464,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -9830,12 +9829,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -9857,12 +9853,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -9875,13 +9868,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -16386,11 +16375,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -16417,11 +16404,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -16434,11 +16419,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -22496,15 +22479,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -22533,10 +22516,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -22624,10 +22603,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitBeforeMutationEffectsDeletion(deletion) { @@ -23044,7 +23019,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -23055,7 +23030,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -23074,7 +23049,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -23111,7 +23086,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostHoistable: { { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Ref) { safelyAttachRef(finishedWork, finishedWork.return); @@ -23125,7 +23100,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -23143,7 +23118,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -23155,7 +23130,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); @@ -23189,14 +23164,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -23214,7 +23189,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -24277,9 +24252,11 @@ function isSuspenseBoundaryBeingHidden(current, finishedWork) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } @@ -24301,19 +24278,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } var currentHoistableRoot = null; @@ -24330,7 +24305,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -24369,7 +24344,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24395,7 +24370,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { // We cast because we always set the root at the React root and so it cannot be // null while we are processing mutation effects var hoistableRoot = currentHoistableRoot; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24470,7 +24445,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -24534,7 +24509,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -24567,7 +24542,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { prepareToCommitHoistables(); var previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(root.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); currentHoistableRoot = previousHoistableRoot; commitReconciliationEffects(finishedWork); } @@ -24610,7 +24585,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { { var _previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(finishedWork.stateNode.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); currentHoistableRoot = _previousHoistableRoot; } @@ -24620,7 +24595,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -24692,7 +24667,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } @@ -24757,7 +24732,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -24775,7 +24750,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -24798,7 +24773,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -24853,29 +24828,30 @@ function resetFormOnFiber(fiber) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -25081,16 +25057,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -25249,25 +25226,23 @@ function commitTracingMarkerPassiveMountEffect(finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -25383,7 +25358,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } } @@ -25451,15 +25426,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -25519,7 +25494,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } } @@ -25582,19 +25557,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -25606,7 +25580,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -25620,7 +25594,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -25633,16 +25607,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -25793,21 +25767,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -25871,19 +25844,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -25925,9 +25897,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -28307,15 +28280,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -28335,9 +28313,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -28407,22 +28408,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -28509,20 +28497,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -28899,9 +28890,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -29477,13 +29469,9 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode) { - doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - - resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -29496,19 +29484,15 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only // if it is visible and its visibility has changed. - doubleInvokeEffectsOnFiber(root, fiber); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber); } else if (fiber.subtreeFlags & PlacementDEV) { // Something in the subtree could have been suspended. // We need to continue traversal and find newly inserted fibers. - recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); + runWithFiberInDEV(fiber, recursivelyTraverseAndDoubleInvokeEffectsInDEV, root, fiber, isInStrictMode); } - - resetCurrentDebugFiberInDEV(); } } @@ -29556,19 +29540,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -29659,19 +29633,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } @@ -30829,7 +30793,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-modern-70908518'; +var ReactVersion = '19.0.0-www-modern-216a6a9a'; function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. implementation) { @@ -30923,25 +30887,13 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(hostFiber); - + runWithFiberInDEV(hostFiber, function () { if (fiber.mode & StrictLegacyMode) { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } else { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } - } finally { - // Ideally this should reset to previous but this shouldn't be called in - // render and there's another warning for that anyway. - if (previousFiber) { - setCurrentDebugFiberInDEV(previousFiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } diff --git a/compiled/facebook-www/ReactDOMTesting-prod.classic.js b/compiled/facebook-www/ReactDOMTesting-prod.classic.js index 42eedc956631f..42c4501a7a44e 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.classic.js @@ -11790,24 +11790,24 @@ function performUnitOfWork(unitOfWork) { null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate; - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate; + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; - context = getMaskedContext(unitOfWork, context); - current$jscomp$0 = replayFunctionComponent( + context = getMaskedContext(next, context); + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, context, @@ -11815,39 +11815,32 @@ function replaySuspendedUnitOfWork(unitOfWork) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), - (current$jscomp$0 = beginWork( - current$jscomp$0, - unitOfWork, - entangledRenderLanes - )); + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), + (next = beginWork(current$jscomp$0, next, entangledRenderLanes)); } current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -13378,14 +13371,14 @@ var isInputEventSupported = !1; if (canUseDOM) { var JSCompiler_inline_result$jscomp$373; if (canUseDOM) { - var isSupported$jscomp$inline_1557 = "oninput" in document; - if (!isSupported$jscomp$inline_1557) { - var element$jscomp$inline_1558 = document.createElement("div"); - element$jscomp$inline_1558.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1557 = - "function" === typeof element$jscomp$inline_1558.oninput; + var isSupported$jscomp$inline_1569 = "oninput" in document; + if (!isSupported$jscomp$inline_1569) { + var element$jscomp$inline_1570 = document.createElement("div"); + element$jscomp$inline_1570.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1569 = + "function" === typeof element$jscomp$inline_1570.oninput; } - JSCompiler_inline_result$jscomp$373 = isSupported$jscomp$inline_1557; + JSCompiler_inline_result$jscomp$373 = isSupported$jscomp$inline_1569; } else JSCompiler_inline_result$jscomp$373 = !1; isInputEventSupported = JSCompiler_inline_result$jscomp$373 && @@ -13797,20 +13790,20 @@ function extractEvents$1( } } for ( - var i$jscomp$inline_1598 = 0; - i$jscomp$inline_1598 < simpleEventPluginEvents.length; - i$jscomp$inline_1598++ + var i$jscomp$inline_1610 = 0; + i$jscomp$inline_1610 < simpleEventPluginEvents.length; + i$jscomp$inline_1610++ ) { - var eventName$jscomp$inline_1599 = - simpleEventPluginEvents[i$jscomp$inline_1598], - domEventName$jscomp$inline_1600 = - eventName$jscomp$inline_1599.toLowerCase(), - capitalizedEvent$jscomp$inline_1601 = - eventName$jscomp$inline_1599[0].toUpperCase() + - eventName$jscomp$inline_1599.slice(1); + var eventName$jscomp$inline_1611 = + simpleEventPluginEvents[i$jscomp$inline_1610], + domEventName$jscomp$inline_1612 = + eventName$jscomp$inline_1611.toLowerCase(), + capitalizedEvent$jscomp$inline_1613 = + eventName$jscomp$inline_1611[0].toUpperCase() + + eventName$jscomp$inline_1611.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1600, - "on" + capitalizedEvent$jscomp$inline_1601 + domEventName$jscomp$inline_1612, + "on" + capitalizedEvent$jscomp$inline_1613 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -17397,17 +17390,17 @@ Internals.Events = [ return fn(a); } ]; -var devToolsConfig$jscomp$inline_1776 = { +var devToolsConfig$jscomp$inline_1788 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-classic-7eb1e9d7", + version: "19.0.0-www-classic-96989544", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2225 = { - bundleType: devToolsConfig$jscomp$inline_1776.bundleType, - version: devToolsConfig$jscomp$inline_1776.version, - rendererPackageName: devToolsConfig$jscomp$inline_1776.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1776.rendererConfig, +var internals$jscomp$inline_2237 = { + bundleType: devToolsConfig$jscomp$inline_1788.bundleType, + version: devToolsConfig$jscomp$inline_1788.version, + rendererPackageName: devToolsConfig$jscomp$inline_1788.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1788.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17423,26 +17416,26 @@ var internals$jscomp$inline_2225 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1776.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1788.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-7eb1e9d7" + reconcilerVersion: "19.0.0-www-classic-96989544" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2226 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2238 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2226.isDisabled && - hook$jscomp$inline_2226.supportsFiber + !hook$jscomp$inline_2238.isDisabled && + hook$jscomp$inline_2238.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2226.inject( - internals$jscomp$inline_2225 + (rendererID = hook$jscomp$inline_2238.inject( + internals$jscomp$inline_2237 )), - (injectedHook = hook$jscomp$inline_2226); + (injectedHook = hook$jscomp$inline_2238); } catch (err) {} } function ReactDOMRoot(internalRoot) { @@ -18085,4 +18078,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-classic-7eb1e9d7"; +exports.version = "19.0.0-www-classic-96989544"; diff --git a/compiled/facebook-www/ReactDOMTesting-prod.modern.js b/compiled/facebook-www/ReactDOMTesting-prod.modern.js index c3af927eb474b..58f20f5ce054c 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.modern.js @@ -11332,20 +11332,20 @@ function performUnitOfWork(unitOfWork) { null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate; - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate; + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, void 0, @@ -11353,39 +11353,32 @@ function replaySuspendedUnitOfWork(unitOfWork) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), - (current$jscomp$0 = beginWork( - current$jscomp$0, - unitOfWork, - entangledRenderLanes - )); + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), + (next = beginWork(current$jscomp$0, next, entangledRenderLanes)); } current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -12820,14 +12813,14 @@ var isInputEventSupported = !1; if (canUseDOM) { var JSCompiler_inline_result$jscomp$360; if (canUseDOM) { - var isSupported$jscomp$inline_1529 = "oninput" in document; - if (!isSupported$jscomp$inline_1529) { - var element$jscomp$inline_1530 = document.createElement("div"); - element$jscomp$inline_1530.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1529 = - "function" === typeof element$jscomp$inline_1530.oninput; + var isSupported$jscomp$inline_1540 = "oninput" in document; + if (!isSupported$jscomp$inline_1540) { + var element$jscomp$inline_1541 = document.createElement("div"); + element$jscomp$inline_1541.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1540 = + "function" === typeof element$jscomp$inline_1541.oninput; } - JSCompiler_inline_result$jscomp$360 = isSupported$jscomp$inline_1529; + JSCompiler_inline_result$jscomp$360 = isSupported$jscomp$inline_1540; } else JSCompiler_inline_result$jscomp$360 = !1; isInputEventSupported = JSCompiler_inline_result$jscomp$360 && @@ -13239,20 +13232,20 @@ function extractEvents$1( } } for ( - var i$jscomp$inline_1570 = 0; - i$jscomp$inline_1570 < simpleEventPluginEvents.length; - i$jscomp$inline_1570++ + var i$jscomp$inline_1581 = 0; + i$jscomp$inline_1581 < simpleEventPluginEvents.length; + i$jscomp$inline_1581++ ) { - var eventName$jscomp$inline_1571 = - simpleEventPluginEvents[i$jscomp$inline_1570], - domEventName$jscomp$inline_1572 = - eventName$jscomp$inline_1571.toLowerCase(), - capitalizedEvent$jscomp$inline_1573 = - eventName$jscomp$inline_1571[0].toUpperCase() + - eventName$jscomp$inline_1571.slice(1); + var eventName$jscomp$inline_1582 = + simpleEventPluginEvents[i$jscomp$inline_1581], + domEventName$jscomp$inline_1583 = + eventName$jscomp$inline_1582.toLowerCase(), + capitalizedEvent$jscomp$inline_1584 = + eventName$jscomp$inline_1582[0].toUpperCase() + + eventName$jscomp$inline_1582.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1572, - "on" + capitalizedEvent$jscomp$inline_1573 + domEventName$jscomp$inline_1583, + "on" + capitalizedEvent$jscomp$inline_1584 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -16819,17 +16812,17 @@ Internals.Events = [ return fn(a); } ]; -var devToolsConfig$jscomp$inline_1743 = { +var devToolsConfig$jscomp$inline_1754 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-modern-e7b9ecb2", + version: "19.0.0-www-modern-60d66d1e", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2217 = { - bundleType: devToolsConfig$jscomp$inline_1743.bundleType, - version: devToolsConfig$jscomp$inline_1743.version, - rendererPackageName: devToolsConfig$jscomp$inline_1743.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1743.rendererConfig, +var internals$jscomp$inline_2228 = { + bundleType: devToolsConfig$jscomp$inline_1754.bundleType, + version: devToolsConfig$jscomp$inline_1754.version, + rendererPackageName: devToolsConfig$jscomp$inline_1754.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1754.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -16845,26 +16838,26 @@ var internals$jscomp$inline_2217 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1743.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1754.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-e7b9ecb2" + reconcilerVersion: "19.0.0-www-modern-60d66d1e" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2218 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2229 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2218.isDisabled && - hook$jscomp$inline_2218.supportsFiber + !hook$jscomp$inline_2229.isDisabled && + hook$jscomp$inline_2229.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2218.inject( - internals$jscomp$inline_2217 + (rendererID = hook$jscomp$inline_2229.inject( + internals$jscomp$inline_2228 )), - (injectedHook = hook$jscomp$inline_2218); + (injectedHook = hook$jscomp$inline_2229); } catch (err) {} } function ReactDOMRoot(internalRoot) { @@ -17377,4 +17370,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-modern-e7b9ecb2"; +exports.version = "19.0.0-www-modern-60d66d1e"; diff --git a/compiled/facebook-www/ReactReconciler-dev.classic.js b/compiled/facebook-www/ReactReconciler-dev.classic.js index 77f6a5e49e317..1ba2d5aab1e2a 100644 --- a/compiled/facebook-www/ReactReconciler-dev.classic.js +++ b/compiled/facebook-www/ReactReconciler-dev.classic.js @@ -128,6 +128,7 @@ var enableAsyncIterableChildren = false; var enableSuspenseCallback = true; var passChildrenWhenCloningPersistedNodes = false; var disableLegacyMode = false; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1080,15 +1081,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1106,11 +1115,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -6479,14 +6483,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -6849,12 +6848,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -6876,12 +6872,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -6894,13 +6887,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -13429,11 +13418,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -13460,11 +13447,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -13477,11 +13462,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -20120,15 +20103,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -20157,10 +20140,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -20248,10 +20227,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitBeforeMutationEffectsDeletion(deletion) { @@ -20668,7 +20643,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -20679,7 +20654,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -20698,7 +20673,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -20735,7 +20710,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostHoistable: { if (supportsResources) { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Ref) { safelyAttachRef(finishedWork, finishedWork.return); @@ -20749,7 +20724,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -20767,7 +20742,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -20779,7 +20754,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); @@ -20813,14 +20788,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -20838,7 +20813,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -21928,9 +21903,11 @@ function isSuspenseBoundaryBeingHidden(current, finishedWork) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } @@ -21952,19 +21929,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } var currentHoistableRoot = null; @@ -21981,7 +21956,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -22020,7 +21995,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -22046,7 +22021,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { // We cast because we always set the root at the React root and so it cannot be // null while we are processing mutation effects var hoistableRoot = currentHoistableRoot; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -22121,7 +22096,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -22185,7 +22160,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -22218,11 +22193,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { prepareToCommitHoistables(); var previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(root.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); currentHoistableRoot = previousHoistableRoot; commitReconciliationEffects(finishedWork); } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -22275,11 +22250,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { if (supportsResources) { var _previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(finishedWork.stateNode.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); currentHoistableRoot = _previousHoistableRoot; } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -22302,7 +22277,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -22374,11 +22349,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); } commitReconciliationEffects(finishedWork); @@ -22441,7 +22416,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -22459,7 +22434,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -22482,7 +22457,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -22537,29 +22512,30 @@ function resetFormOnFiber(fiber) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -22765,16 +22741,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -22933,25 +22910,23 @@ function commitTracingMarkerPassiveMountEffect(finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -23067,7 +23042,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -23139,15 +23114,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -23207,7 +23182,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -23274,19 +23249,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -23298,7 +23272,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -23312,7 +23286,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -23325,16 +23299,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -23497,21 +23471,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -23575,19 +23548,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -23629,9 +23601,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -26245,15 +26218,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -26273,9 +26251,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -26350,22 +26351,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -26452,20 +26440,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -26842,9 +26833,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -27420,13 +27412,9 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode) { - doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - - resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -27439,19 +27427,15 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only // if it is visible and its visibility has changed. - doubleInvokeEffectsOnFiber(root, fiber); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber); } else if (fiber.subtreeFlags & PlacementDEV) { // Something in the subtree could have been suspended. // We need to continue traversal and find newly inserted fibers. - recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); + runWithFiberInDEV(fiber, recursivelyTraverseAndDoubleInvokeEffectsInDEV, root, fiber, isInStrictMode); } - - resetCurrentDebugFiberInDEV(); } } @@ -27466,7 +27450,8 @@ function commitDoubleInvokeEffectsInDEV(root, hasPassiveEffects) { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, root.current, doubleInvokeEffects); } else { - legacyCommitDoubleInvokeEffectsInDEV(root.current, hasPassiveEffects); + // TODO: Is this runWithFiberInDEV needed since the other effect functions do it too? + runWithFiberInDEV(root.current, legacyCommitDoubleInvokeEffectsInDEV, root.current, hasPassiveEffects); } } } @@ -27475,7 +27460,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { // TODO (StrictEffects) Should we set a marker on the root if it contains strict effects // so we don't traverse unnecessarily? similar to subtreeFlags but just at the root level. // Maybe not a big deal since this is DEV only behavior. - setCurrentDebugFiberInDEV(fiber); invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV); if (hasPassiveEffects) { @@ -27487,8 +27471,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { if (hasPassiveEffects) { invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV); } - - resetCurrentDebugFiberInDEV(); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { @@ -27548,19 +27530,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -27669,19 +27641,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } @@ -28856,7 +28818,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-classic-9052b1b3'; +var ReactVersion = '19.0.0-www-classic-3f35c9fb'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol @@ -29018,25 +28980,13 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(hostFiber); - + runWithFiberInDEV(hostFiber, function () { if (fiber.mode & StrictLegacyMode) { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } else { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } - } finally { - // Ideally this should reset to previous but this shouldn't be called in - // render and there's another warning for that anyway. - if (previousFiber) { - setCurrentDebugFiberInDEV(previousFiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } diff --git a/compiled/facebook-www/ReactReconciler-dev.modern.js b/compiled/facebook-www/ReactReconciler-dev.modern.js index 39ea3b2d66862..2950514900da2 100644 --- a/compiled/facebook-www/ReactReconciler-dev.modern.js +++ b/compiled/facebook-www/ReactReconciler-dev.modern.js @@ -128,6 +128,7 @@ var enableAsyncIterableChildren = false; var enableSuspenseCallback = true; var passChildrenWhenCloningPersistedNodes = false; var disableLegacyMode = true; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1082,15 +1083,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1108,11 +1117,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -6270,14 +6274,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -6640,12 +6639,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -6667,12 +6663,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -6685,13 +6678,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -13196,11 +13185,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -13227,11 +13214,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -13244,11 +13229,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -19627,15 +19610,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -19664,10 +19647,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -19755,10 +19734,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitBeforeMutationEffectsDeletion(deletion) { @@ -20175,7 +20150,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -20186,7 +20161,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -20205,7 +20180,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -20242,7 +20217,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostHoistable: { if (supportsResources) { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Ref) { safelyAttachRef(finishedWork, finishedWork.return); @@ -20256,7 +20231,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -20274,7 +20249,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -20286,7 +20261,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); @@ -20320,14 +20295,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -20345,7 +20320,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -21433,9 +21408,11 @@ function isSuspenseBoundaryBeingHidden(current, finishedWork) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } @@ -21457,19 +21434,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } var currentHoistableRoot = null; @@ -21486,7 +21461,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -21525,7 +21500,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -21551,7 +21526,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { // We cast because we always set the root at the React root and so it cannot be // null while we are processing mutation effects var hoistableRoot = currentHoistableRoot; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -21626,7 +21601,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -21690,7 +21665,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -21723,11 +21698,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { prepareToCommitHoistables(); var previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(root.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); currentHoistableRoot = previousHoistableRoot; commitReconciliationEffects(finishedWork); } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -21780,11 +21755,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { if (supportsResources) { var _previousHoistableRoot = currentHoistableRoot; currentHoistableRoot = getHoistableRoot(finishedWork.stateNode.containerInfo); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); currentHoistableRoot = _previousHoistableRoot; } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -21807,7 +21782,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -21879,7 +21854,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } @@ -21944,7 +21919,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -21962,7 +21937,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -21985,7 +21960,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -22040,29 +22015,30 @@ function resetFormOnFiber(fiber) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } + inProgressLanes = null; inProgressRoot = null; } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -22268,16 +22244,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -22436,25 +22413,23 @@ function commitTracingMarkerPassiveMountEffect(finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -22570,7 +22545,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } } @@ -22638,15 +22613,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -22706,7 +22681,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } } @@ -22769,19 +22744,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -22793,7 +22767,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -22807,7 +22781,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -22820,16 +22794,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -22992,21 +22966,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -23070,19 +23043,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -23124,9 +23096,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -25592,15 +25565,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -25620,9 +25598,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -25692,22 +25693,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -25794,20 +25782,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -26184,9 +26175,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -26762,13 +26754,9 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode) { - doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - - resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -26781,19 +26769,15 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentDebugFiberInDEV(fiber); - if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only // if it is visible and its visibility has changed. - doubleInvokeEffectsOnFiber(root, fiber); + runWithFiberInDEV(fiber, doubleInvokeEffectsOnFiber, root, fiber); } else if (fiber.subtreeFlags & PlacementDEV) { // Something in the subtree could have been suspended. // We need to continue traversal and find newly inserted fibers. - recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); + runWithFiberInDEV(fiber, recursivelyTraverseAndDoubleInvokeEffectsInDEV, root, fiber, isInStrictMode); } - - resetCurrentDebugFiberInDEV(); } } @@ -26841,19 +26825,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -26944,19 +26918,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } @@ -28122,7 +28086,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-modern-b4e39258'; +var ReactVersion = '19.0.0-www-modern-986e0542'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol @@ -28284,25 +28248,13 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(hostFiber); - + runWithFiberInDEV(hostFiber, function () { if (fiber.mode & StrictLegacyMode) { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } else { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); } - } finally { - // Ideally this should reset to previous but this shouldn't be called in - // render and there's another warning for that anyway. - if (previousFiber) { - setCurrentDebugFiberInDEV(previousFiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } diff --git a/compiled/facebook-www/ReactReconciler-prod.classic.js b/compiled/facebook-www/ReactReconciler-prod.classic.js index fe01f256fada5..dd304f3a11d7d 100644 --- a/compiled/facebook-www/ReactReconciler-prod.classic.js +++ b/compiled/facebook-www/ReactReconciler-prod.classic.js @@ -10489,15 +10489,15 @@ module.exports = function ($$$config) { null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate; - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate; + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent( Component, @@ -10506,10 +10506,10 @@ module.exports = function ($$$config) { var context = isContextProvider(Component) ? previousContext : contextStackCursor$1.current; - context = getMaskedContext(unitOfWork, context); - current$jscomp$0 = replayFunctionComponent( + context = getMaskedContext(next, context); + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, context, @@ -10517,42 +10517,35 @@ module.exports = function ($$$config) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent( Component, unresolvedProps ); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), - (current$jscomp$0 = beginWork( - current$jscomp$0, - unitOfWork, - entangledRenderLanes - )); + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), + (next = beginWork(current$jscomp$0, next, entangledRenderLanes)); } current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -12648,7 +12641,7 @@ module.exports = function ($$$config) { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-d931df93" + reconcilerVersion: "19.0.0-www-classic-b5a9754b" }; if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) devToolsConfig = !1; diff --git a/compiled/facebook-www/ReactReconciler-prod.modern.js b/compiled/facebook-www/ReactReconciler-prod.modern.js index 8ee4e67b4be7a..533ea38b699fe 100644 --- a/compiled/facebook-www/ReactReconciler-prod.modern.js +++ b/compiled/facebook-www/ReactReconciler-prod.modern.js @@ -10060,23 +10060,23 @@ module.exports = function ($$$config) { null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function replaySuspendedUnitOfWork(unitOfWork) { - var current$jscomp$0 = unitOfWork.alternate; - switch (unitOfWork.tag) { + var next = unitOfWork; + var current$jscomp$0 = next.alternate; + switch (next.tag) { case 15: case 0: - var Component = unitOfWork.type, - unresolvedProps = unitOfWork.pendingProps; + var Component = next.type, + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent( Component, unresolvedProps ); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, void 0, @@ -10084,42 +10084,35 @@ module.exports = function ($$$config) { ); break; case 11: - Component = unitOfWork.type.render; - unresolvedProps = unitOfWork.pendingProps; + Component = next.type.render; + unresolvedProps = next.pendingProps; unresolvedProps = - disableDefaultPropsExceptForClasses || - unitOfWork.elementType === Component + disableDefaultPropsExceptForClasses || next.elementType === Component ? unresolvedProps : resolveDefaultPropsOnNonClassComponent( Component, unresolvedProps ); - current$jscomp$0 = replayFunctionComponent( + next = replayFunctionComponent( current$jscomp$0, - unitOfWork, + next, unresolvedProps, Component, - unitOfWork.ref, + next.ref, workInProgressRootRenderLanes ); break; case 5: - resetHooksOnUnwind(unitOfWork); + resetHooksOnUnwind(next); default: - unwindInterruptedWork(current$jscomp$0, unitOfWork), - (unitOfWork = workInProgress = - resetWorkInProgress(unitOfWork, entangledRenderLanes)), - (current$jscomp$0 = beginWork( - current$jscomp$0, - unitOfWork, - entangledRenderLanes - )); + unwindInterruptedWork(current$jscomp$0, next), + (next = workInProgress = + resetWorkInProgress(next, entangledRenderLanes)), + (next = beginWork(current$jscomp$0, next, entangledRenderLanes)); } current = null; unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current$jscomp$0 - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current$jscomp$0); + null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -12161,7 +12154,7 @@ module.exports = function ($$$config) { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-db5978b6" + reconcilerVersion: "19.0.0-www-modern-72273d97" }; if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) devToolsConfig = !1; diff --git a/compiled/facebook-www/ReactTestRenderer-dev.classic.js b/compiled/facebook-www/ReactTestRenderer-dev.classic.js index e3af2253f3157..a618aed19e367 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.classic.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.classic.js @@ -132,6 +132,7 @@ var enableLegacyHidden = false; var enableAsyncActions = true; var alwaysThrottleRetries = true; var disableLegacyMode = false; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1050,15 +1051,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1076,11 +1085,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -5118,14 +5122,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -5481,12 +5480,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -5508,12 +5504,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -5526,13 +5519,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -11587,11 +11576,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -11618,11 +11605,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -11635,11 +11620,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -16612,15 +16595,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -16637,10 +16620,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { var current = finishedWork.alternate; var flags = finishedWork.flags; - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -16723,10 +16702,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitHookEffectListUnmount(flags, finishedWork, nearestMountedAncestor) { @@ -17085,7 +17060,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -17096,7 +17071,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -17115,7 +17090,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -17154,7 +17129,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -17172,7 +17147,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -17184,7 +17159,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } @@ -17214,14 +17189,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -17239,7 +17214,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -17977,9 +17952,10 @@ function attachSuspenseRetryListeners(finishedWork, wakeables) { }); } // This function detects when a Suspense boundary goes from visible to hidden. function commitMutationEffects(root, finishedWork, committedLanes) { - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } } function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { @@ -17999,19 +17975,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitMutationEffectsOnFiber(finishedWork, root, lanes) { @@ -18026,7 +18000,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -18065,7 +18039,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -18091,7 +18065,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -18154,7 +18128,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -18184,7 +18158,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostRoot: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -18194,7 +18168,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostPortal: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -18203,7 +18177,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -18269,11 +18243,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); } commitReconciliationEffects(finishedWork); @@ -18336,7 +18310,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -18354,7 +18328,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -18377,7 +18351,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -18410,27 +18384,27 @@ function commitReconciliationEffects(finishedWork) { } function commitLayoutEffects(finishedWork, root, committedLanes) { - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -18631,16 +18605,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -18718,25 +18693,23 @@ function commitCachePassiveMountEffect(current, finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -18816,7 +18789,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -18876,15 +18849,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -18934,7 +18907,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -18989,19 +18962,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -19013,7 +18985,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -19026,7 +18998,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -19039,16 +19011,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -19194,21 +19166,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -19272,19 +19243,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -19326,9 +19296,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -21065,15 +21036,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -21093,9 +21069,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -21170,22 +21169,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -21272,20 +21258,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -21517,14 +21506,14 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh } // The next phase is the mutation phase, where we mutate the host tree. - commitMutationEffects(root, finishedWork); + commitMutationEffects(root, finishedWork, lanes); // the mutation phase, so that the previous tree is still current during // componentWillUnmount, but before the layout phase, so that the finished // work is current during componentDidMount/Update. root.current = finishedWork; // The next phase is the layout phase, where we call effects that read - commitLayoutEffects(finishedWork, root); + commitLayoutEffects(finishedWork, root, lanes); // opportunity to paint. @@ -21601,9 +21590,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -22054,7 +22044,8 @@ function flushRenderPhaseStrictModeWarningsInDEV() { function commitDoubleInvokeEffectsInDEV(root, hasPassiveEffects) { { { - legacyCommitDoubleInvokeEffectsInDEV(root.current, hasPassiveEffects); + // TODO: Is this runWithFiberInDEV needed since the other effect functions do it too? + runWithFiberInDEV(root.current, legacyCommitDoubleInvokeEffectsInDEV, root.current, hasPassiveEffects); } } } @@ -22063,7 +22054,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { // TODO (StrictEffects) Should we set a marker on the root if it contains strict effects // so we don't traverse unnecessarily? similar to subtreeFlags but just at the root level. // Maybe not a big deal since this is DEV only behavior. - setCurrentDebugFiberInDEV(fiber); invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV); if (hasPassiveEffects) { @@ -22075,8 +22065,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { if (hasPassiveEffects) { invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV); } - - resetCurrentDebugFiberInDEV(); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { @@ -22136,19 +22124,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -22244,19 +22222,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } @@ -23336,7 +23304,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-classic-df7aa931'; +var ReactVersion = '19.0.0-www-classic-99738b5a'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled/facebook-www/ReactTestRenderer-dev.modern.js b/compiled/facebook-www/ReactTestRenderer-dev.modern.js index f6e839400efe4..2df6ba417a854 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.modern.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.modern.js @@ -132,6 +132,7 @@ var enableLegacyHidden = false; var enableAsyncActions = true; var alwaysThrottleRetries = true; var disableLegacyMode = false; +var enableOwnerStacks = false; // Flow magic to verify the exports of this file match the original version. var FunctionComponent = 0; var ClassComponent = 1; @@ -1050,15 +1051,23 @@ function getCurrentFiberStackInDev() { } } -function resetCurrentDebugFiberInDEV() { - { - resetCurrentFiber(); - } -} -function setCurrentDebugFiberInDEV(fiber) { +function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { { + var previousFiber = current; setCurrentFiber(fiber); - } + + try { + if (enableOwnerStacks) ; + + return callback(arg0, arg1, arg2, arg3, arg4); + } finally { + current = previousFiber; + } + } // These errors should never make it into a build so we don't need to encode them in codes.json + // eslint-disable-next-line react-internal/prod-error-codes + + + throw new Error('runWithFiberInDEV should never be called in production. This is a bug in React.'); } function resetCurrentFiber() { { @@ -1076,11 +1085,6 @@ function setCurrentFiber(fiber) { current = fiber; } -function getCurrentFiber() { - { - return current; - } -} function setIsRendering(rendering) { { isRendering = rendering; @@ -5118,14 +5122,9 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); - - try { - setCurrentDebugFiberInDEV(firstFiber); - + runWithFiberInDEV(firstFiber, function () { error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); - } finally { - resetCurrentDebugFiberInDEV(); - } + }); }); }; @@ -5481,12 +5480,9 @@ var warnForMissingKey = function (child, returnFiber) {}; var fiber = createFiberFromElement(child, returnFiber.mode, 0); fiber.return = returnFiber; - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwnerAppendix); + }); }; } // Given a fragment, validate that it can only be provided with fragment props // We do this here instead of BeginWork because the Fragment fiber doesn't have @@ -5508,12 +5504,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var prevDebugFiber = getCurrentFiber(); - setCurrentFiber(fiber); - - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - - setCurrentFiber(prevDebugFiber); + runWithFiberInDEV(fiber, function (erroredKey) { + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', erroredKey); + }, key); break; } } @@ -5526,13 +5519,9 @@ function validateFragmentProps(element, fiber, returnFiber) { fiber.return = returnFiber; } - var _prevDebugFiber = getCurrentFiber(); - - setCurrentFiber(fiber); - - error('Invalid attribute `ref` supplied to `React.Fragment`.'); - - setCurrentFiber(_prevDebugFiber); + runWithFiberInDEV(fiber, function () { + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + }); } } } @@ -11587,11 +11576,9 @@ function createRootErrorUpdate(root, errorInfo, lane) { }; update.callback = function () { - var prevFiber = getCurrentFiber(); // should just be the root - - setCurrentDebugFiberInDEV(errorInfo.source); - logUncaughtError(root, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logUncaughtError, root, errorInfo); + } }; return update; @@ -11618,11 +11605,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } }; } @@ -11635,11 +11620,9 @@ function initializeClassErrorUpdate(update, root, fiber, errorInfo) { markFailedErrorBoundaryForHotReloading(fiber); } - var prevFiber = getCurrentFiber(); // should be the error boundary - - setCurrentDebugFiberInDEV(errorInfo.source); - logCaughtError(root, fiber, errorInfo); - setCurrentDebugFiberInDEV(prevFiber); + { + runWithFiberInDEV(errorInfo.source, logCaughtError, root, fiber, errorInfo); + } if (typeof getDerivedStateFromError !== 'function') { // To preserve the preexisting retry behavior of error boundaries, @@ -16612,15 +16595,15 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentDebugFiberInDEV(fiber); try { - commitBeforeMutationEffectsOnFiber(fiber); + if (true) { + runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber); + } } catch (error) { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -16637,10 +16620,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { var current = finishedWork.alternate; var flags = finishedWork.flags; - if ((flags & Snapshot) !== NoFlags$1) { - setCurrentDebugFiberInDEV(finishedWork); - } - switch (finishedWork.tag) { case FunctionComponent: { @@ -16723,10 +16702,6 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } } } - - if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentDebugFiberInDEV(); - } } function commitHookEffectListUnmount(flags, finishedWork, nearestMountedAncestor) { @@ -17085,7 +17060,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ForwardRef: case SimpleMemoComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitHookLayoutEffects(finishedWork, Layout | HasEffect); @@ -17096,7 +17071,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case ClassComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Update) { commitClassLayoutLifecycles(finishedWork, current); @@ -17115,7 +17090,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostRoot: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); if (flags & Callback) { // TODO: I think this is now always non-null by the time it reaches the @@ -17154,7 +17129,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case HostSingleton: case HostComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // Renderers may schedule work to be done after host components are mounted + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // Renderers may schedule work to be done after host components are mounted // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. @@ -17172,7 +17147,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case Profiler: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); // TODO: Should this fire inside an offscreen tree? Or should it wait to + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); // TODO: Should this fire inside an offscreen tree? Or should it wait to // fire when the tree becomes visible again. if (flags & Update) { @@ -17184,7 +17159,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe case SuspenseComponent: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } @@ -17214,14 +17189,14 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe var includeWorkInProgressEffects = (finishedWork.subtreeFlags & LayoutMask) !== NoFlags$1; recursivelyTraverseReappearLayoutEffects(finishedRoot, finishedWork, includeWorkInProgressEffects); } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; } } else { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); } if (flags & Ref) { @@ -17239,7 +17214,7 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork, committe default: { - recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork, committedLanes); break; } } @@ -17977,9 +17952,10 @@ function attachSuspenseRetryListeners(finishedWork, wakeables) { }); } // This function detects when a Suspense boundary goes from visible to hidden. function commitMutationEffects(root, finishedWork, committedLanes) { - setCurrentDebugFiberInDEV(finishedWork); - commitMutationEffectsOnFiber(finishedWork, root); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitMutationEffectsOnFiber, finishedWork, root, committedLanes); + } } function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { @@ -17999,19 +17975,17 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { } } - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & MutationMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitMutationEffectsOnFiber(child, root); + { + runWithFiberInDEV(child, commitMutationEffectsOnFiber, child, root, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitMutationEffectsOnFiber(finishedWork, root, lanes) { @@ -18026,7 +18000,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case MemoComponent: case SimpleMemoComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -18065,7 +18039,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ClassComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -18091,7 +18065,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Ref) { @@ -18154,7 +18128,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostText: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -18184,7 +18158,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostRoot: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -18194,7 +18168,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case HostPortal: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); } @@ -18203,7 +18177,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: We should mark a flag on the Suspense fiber itself, rather than // relying on the Offscreen fiber having a flag also being marked. The // reason is that this offscreen fiber might not be part of the work-in- @@ -18269,11 +18243,11 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; } else { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); } commitReconciliationEffects(finishedWork); @@ -18336,7 +18310,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case SuspenseListComponent: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & Update) { @@ -18354,7 +18328,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { case ScopeComponent: { { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. @@ -18377,7 +18351,7 @@ function commitMutationEffectsOnFiber(finishedWork, root, lanes) { default: { - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); return; } @@ -18410,27 +18384,27 @@ function commitReconciliationEffects(finishedWork) { } function commitLayoutEffects(finishedWork, root, committedLanes) { - setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; - commitLayoutEffectOnFiber(root, current, finishedWork); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(finishedWork, commitLayoutEffectOnFiber, root, current, finishedWork, committedLanes); + } } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & LayoutMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); var current = child.alternate; - commitLayoutEffectOnFiber(root, current, child); + + { + runWithFiberInDEV(child, commitLayoutEffectOnFiber, root, current, child, lanes); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -18631,16 +18605,17 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & LayoutMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { var current = child.alternate; - reappearLayoutEffects(finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + + { + runWithFiberInDEV(child, reappearLayoutEffects, finishedRoot, current, child, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -18718,25 +18693,23 @@ function commitCachePassiveMountEffect(current, finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveMountOnFiber, root, finishedWork, committedLanes, committedTransitions); + } } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { - var prevDebugFiber = getCurrentFiber(); - if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); + { + runWithFiberInDEV(child, commitPassiveMountOnFiber, root, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -18816,7 +18789,7 @@ function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, c // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -18876,15 +18849,15 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c // node was reused. var childShouldIncludeWorkInProgressEffects = includeWorkInProgressEffects && (parentFiber.subtreeFlags & PassiveMask) !== NoFlags$1; // TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic) - var prevDebugFiber = getCurrentFiber(); var child = parentFiber.child; while (child !== null) { - reconnectPassiveEffects(finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + { + runWithFiberInDEV(child, reconnectPassiveEffects, finishedRoot, child, committedLanes, committedTransitions, childShouldIncludeWorkInProgressEffects); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -18934,7 +18907,7 @@ includeWorkInProgressEffects) { // "Atomic" effects are ones that need to fire on every commit, // even during pre-rendering. An example is updating the reference // count on cache instances. - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); } } else { // Legacy Mode: Fire the effects even if the tree is hidden. @@ -18989,19 +18962,18 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm // "Atomic" effects are ones that need to fire on every commit, even during // pre-rendering. We call this function when traversing a hidden tree whose // regular effects are currently disconnected. - var prevDebugFiber = getCurrentFiber(); // TODO: Add special flag for atomic effects - + // TODO: Add special flag for atomic effects if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitAtomicPassiveEffects(finishedRoot, child); + { + runWithFiberInDEV(child, commitAtomicPassiveEffects, finishedRoot, child, committedLanes, committedTransitions); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -19013,7 +18985,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, switch (finishedWork.tag) { case OffscreenComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -19026,7 +18998,7 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, case CacheComponent: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); if (flags & Passive$1) { // TODO: Pass `current` as argument to this function @@ -19039,16 +19011,16 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, default: { - recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork); + recursivelyTraverseAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions); break; } } } function commitPassiveUnmountEffects(finishedWork) { - setCurrentDebugFiberInDEV(finishedWork); - commitPassiveUnmountOnFiber(finishedWork); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork); + } } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -19194,21 +19166,20 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Split PassiveMask into separate masks for mount and unmount? - var prevDebugFiber = getCurrentFiber(); // TODO: Split PassiveMask into separate masks for mount and unmount? if (parentFiber.subtreeFlags & PassiveMask) { var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - commitPassiveUnmountOnFiber(child); + { + runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child); + } + child = child.sibling; } } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -19272,19 +19243,18 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { } detachAlternateSiblings(parentFiber); - } + } // TODO: Check PassiveStatic flag - var prevDebugFiber = getCurrentFiber(); // TODO: Check PassiveStatic flag var child = parentFiber.child; while (child !== null) { - setCurrentDebugFiberInDEV(child); - disconnectPassiveEffect(child); + { + runWithFiberInDEV(child, disconnectPassiveEffect, child); + } + child = child.sibling; } - - setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -19326,9 +19296,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentDebugFiberInDEV(fiber); - commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentDebugFiberInDEV(); + { + runWithFiberInDEV(fiber, commitPassiveUnmountInsideDeletedTreeOnFiber, fiber, nearestMountedAncestor); + } + var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -21065,15 +21036,20 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork(current, unitOfWork, entangledRenderLanes); + + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork(current, unitOfWork, entangledRenderLanes); + { + next = runWithFiberInDEV(unitOfWork, beginWork, current, unitOfWork, entangledRenderLanes); + } } { @@ -21093,9 +21069,32 @@ function performUnitOfWork(unitOfWork) { function replaySuspendedUnitOfWork(unitOfWork) { // This is a fork of performUnitOfWork specifcally for replaying a fiber that // just suspended. - // + var next; + + { + next = runWithFiberInDEV(unitOfWork, replayBeginWork, unitOfWork); + } // The begin phase finished successfully without suspending. Return to the + // normal work loop. + + + { + resetCurrentFiber(); + } + + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } +} + +function replayBeginWork(unitOfWork) { + // This is a fork of beginWork specifcally for replaying a fiber that + // just suspended. var current = unitOfWork.alternate; - setCurrentDebugFiberInDEV(unitOfWork); var next; var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; @@ -21170,22 +21169,9 @@ function replaySuspendedUnitOfWork(unitOfWork) { if (isProfilingMode) { stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); - } // The begin phase finished successfully without suspending. Return to the - // normal work loop. - - - { - resetCurrentFiber(); } - unitOfWork.memoizedProps = unitOfWork.pendingProps; - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; - } + return next; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -21272,20 +21258,23 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, entangledRenderLanes); + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } } else { startProfilerTimer(completedWork); - next = completeWork(current, completedWork, entangledRenderLanes); // Update render duration assuming we didn't error. + + { + next = runWithFiberInDEV(completedWork, completeWork, current, completedWork, entangledRenderLanes); + } // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentDebugFiberInDEV(); - if (next !== null) { // Completing this fiber spawned new work. Work on that next. workInProgress = next; @@ -21517,14 +21506,14 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh } // The next phase is the mutation phase, where we mutate the host tree. - commitMutationEffects(root, finishedWork); + commitMutationEffects(root, finishedWork, lanes); // the mutation phase, so that the previous tree is still current during // componentWillUnmount, but before the layout phase, so that the finished // work is current during componentDidMount/Update. root.current = finishedWork; // The next phase is the layout phase, where we call effects that read - commitLayoutEffects(finishedWork, root); + commitLayoutEffects(finishedWork, root, lanes); // opportunity to paint. @@ -21601,9 +21590,10 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; var errorInfo = makeErrorInfo(recoverableError.stack); - setCurrentDebugFiberInDEV(recoverableError.source); - onRecoverableError(recoverableError.value, errorInfo); - resetCurrentDebugFiberInDEV(); + + { + runWithFiberInDEV(recoverableError.source, onRecoverableError, recoverableError.value, errorInfo); + } } } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is @@ -22054,7 +22044,8 @@ function flushRenderPhaseStrictModeWarningsInDEV() { function commitDoubleInvokeEffectsInDEV(root, hasPassiveEffects) { { { - legacyCommitDoubleInvokeEffectsInDEV(root.current, hasPassiveEffects); + // TODO: Is this runWithFiberInDEV needed since the other effect functions do it too? + runWithFiberInDEV(root.current, legacyCommitDoubleInvokeEffectsInDEV, root.current, hasPassiveEffects); } } } @@ -22063,7 +22054,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { // TODO (StrictEffects) Should we set a marker on the root if it contains strict effects // so we don't traverse unnecessarily? similar to subtreeFlags but just at the root level. // Maybe not a big deal since this is DEV only behavior. - setCurrentDebugFiberInDEV(fiber); invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV); if (hasPassiveEffects) { @@ -22075,8 +22065,6 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { if (hasPassiveEffects) { invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV); } - - resetCurrentDebugFiberInDEV(); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { @@ -22136,19 +22124,9 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); } - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } var didWarnAboutUpdateInRender = false; @@ -22244,19 +22222,9 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } if (ReactSharedInternals.actQueue === null) { - var previousFiber = current; - - try { - setCurrentDebugFiberInDEV(fiber); - + runWithFiberInDEV(fiber, function () { error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); - } finally { - if (previousFiber) { - setCurrentDebugFiberInDEV(fiber); - } else { - resetCurrentDebugFiberInDEV(); - } - } + }); } } } @@ -23336,7 +23304,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-modern-df7aa931'; +var ReactVersion = '19.0.0-www-modern-99738b5a'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol