diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 83b660c94c4..d4d3fc3d904 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -27b5699694f20220e0448f0ba3eb6bfa0d3a64ed \ No newline at end of file +4de99b3ca689e8f995f90f199cd8d7bfb4b35eca \ No newline at end of file diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 51fcc464687..11dc6ff58ce 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<6d80dd918594e27535a434318a0b1bb0>> */ 'use strict'; @@ -5009,6 +5009,9 @@ function getLanesToRetrySynchronouslyOnError(root) { return NoLanes; } +function includesSyncLane(lanes) { + return (lanes & SyncLane) !== NoLanes; +} function includesNonIdleWork(lanes) { return (lanes & NonIdleLanes) !== NoLanes; } @@ -6324,7 +6327,7 @@ function flushSyncCallbacks() { } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; -var NoTransition = 0; +var NoTransition = null; function requestCurrentTransition() { return ReactCurrentBatchConfig.transition; } @@ -11541,7 +11544,9 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { { if (!didWarnUncachedGetSnapshot) { - if (nextSnapshot !== getSnapshot()) { + var cachedSnapshot = getSnapshot(); + + if (!objectIs(nextSnapshot, cachedSnapshot)) { error( "The result of getSnapshot should be cached to avoid an infinite loop" ); @@ -11607,7 +11612,9 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { { if (!didWarnUncachedGetSnapshot) { - if (nextSnapshot !== getSnapshot()) { + var cachedSnapshot = getSnapshot(); + + if (!objectIs(nextSnapshot, cachedSnapshot)) { error( "The result of getSnapshot should be cached to avoid an infinite loop" ); @@ -12044,7 +12051,7 @@ function mountDeferredValue(value) { mountEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); @@ -12065,7 +12072,7 @@ function updateDeferredValue(value) { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); @@ -12086,7 +12093,7 @@ function rerenderDeferredValue(value) { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); @@ -12106,7 +12113,12 @@ function startTransition(setPending, callback) { ); setPending(true); var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; + var currentTransition = ReactCurrentBatchConfig$1.transition; + + { + ReactCurrentBatchConfig$1.transition._updatedFibers = new Set(); + } try { setPending(false); @@ -12117,11 +12129,11 @@ function startTransition(setPending, callback) { { if ( - prevTransition !== 1 && + prevTransition === null && warnOnSubscriptionInsideStartTransition && - ReactCurrentBatchConfig$1._updatedFibers + currentTransition._updatedFibers ) { - var updatedFibersCount = ReactCurrentBatchConfig$1._updatedFibers.size; + var updatedFibersCount = currentTransition._updatedFibers.size; if (updatedFibersCount > 10) { warn( @@ -12131,7 +12143,7 @@ function startTransition(setPending, callback) { ); } - ReactCurrentBatchConfig$1._updatedFibers.clear(); + currentTransition._updatedFibers.clear(); } } } @@ -13909,22 +13921,22 @@ function throwException( attachRetryListener(suspenseBoundary, root, wakeable); return; } else { - // No boundary was found. If we're inside startTransition, this is OK. + // No boundary was found. Unless this is a sync update, this is OK. // We can suspend and wait for more data to arrive. - if (includesOnlyTransitions(rootRenderLanes)) { - // This is a transition. Suspend. Since we're not activating a Suspense - // boundary, this will unwind all the way to the root without performing - // a second pass to render a fallback. (This is arguably how refresh - // transitions should work, too, since we're not going to commit the - // fallbacks anyway.) + if (!includesSyncLane(rootRenderLanes)) { + // This is not a sync update. Suspend. Since we're not activating a + // Suspense boundary, this will unwind all the way to the root without + // performing a second pass to render a fallback. (This is arguably how + // refresh transitions should work, too, since we're not going to commit + // the fallbacks anyway.) + // + // This case also applies to initial hydration. attachPingListener(root, wakeable, rootRenderLanes); renderDidSuspendDelayIfPossible(); return; - } // We're not in a transition. We treat this case like an error because - // discrete renders are expected to finish synchronously to maintain - // consistency with external state. - // TODO: This will error during non-transition concurrent renders, too. - // But maybe it shouldn't? + } // This is a sync/discrete update. We treat this case like an error + // because discrete renders are expected to produce a complete tree + // synchronously to maintain consistency with external state. // TODO: We should never call getComponentNameFromFiber in production. // Log a warning or something to prevent us from accidentally bundling it. @@ -15440,11 +15452,7 @@ function updateSimpleMemoComponent( function updateOffscreenComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var nextChildren = nextProps.children; - var prevState = current !== null ? current.memoizedState : null; // If this is not null, this is a cache pool that was carried over from the - // previous render. We will push this to the cache pool context so that we can - // resume in-flight requests. - - var spawnedCachePool = null; + var prevState = current !== null ? current.memoizedState : null; if ( nextProps.mode === "hidden" || @@ -15458,10 +15466,12 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { cachePool: null }; workInProgress.memoizedState = nextState; + pushRenderLanes(workInProgress, renderLanes); } else if (!includesSomeLane(renderLanes, OffscreenLane)) { - // We're hidden, and we're not rendering at Offscreen. We will bail out + var spawnedCachePool = null; // We're hidden, and we're not rendering at Offscreen. We will bail out // and resume this tree later. + var nextBaseLanes; if (prevState !== null) { @@ -15479,13 +15489,16 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { cachePool: spawnedCachePool }; workInProgress.memoizedState = _nextState; - workInProgress.updateQueue = null; // We're about to bail out, but we need to push this to the stack anyway + workInProgress.updateQueue = null; // to avoid a push/pop misalignment. pushRenderLanes(workInProgress, nextBaseLanes); return null; } else { + // This is the second render. The surrounding visible content has already + // committed. Now we resume rendering the hidden tree. + // Rendering at offscreen, so we can clear the base lanes. var _nextState2 = { baseLanes: NoLanes, cachePool: null @@ -15494,6 +15507,7 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { var subtreeRenderLanes = prevState !== null ? prevState.baseLanes : renderLanes; + pushRenderLanes(workInProgress, subtreeRenderLanes); } } else { @@ -18079,7 +18093,7 @@ function beginWork(current, workInProgress, renderLanes) { ); } -function unwindWork(workInProgress, renderLanes) { +function unwindWork(current, workInProgress, renderLanes) { // Note: This intentionally doesn't check if we're hydrating because comparing // to the current tree provider fiber is just as fast and less error-prone. // Ideally we would have a special version of the work loop only @@ -18182,7 +18196,7 @@ function unwindWork(workInProgress, renderLanes) { } } -function unwindInterruptedWork(interruptedWork, renderLanes) { +function unwindInterruptedWork(current, interruptedWork, renderLanes) { // Note: This intentionally doesn't check if we're hydrating because comparing // to the current tree provider fiber is just as fast and less error-prone. // Ideally we would have a special version of the work loop only @@ -20127,9 +20141,6 @@ var RenderContext = var CommitContext = /* */ 4; -var RetryAfterError = - /* */ - 8; var RootInProgress = 0; var RootFatalErrored = 1; var RootErrored = 2; @@ -20334,7 +20345,36 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { warnIfUpdatesNotWrappedWithActDEV(fiber); - if (root === workInProgressRoot) { + if (root.isDehydrated && root.tag !== LegacyRoot) { + // This root's shell hasn't hydrated yet. Revert to client rendering. + if (workInProgressRoot === root) { + // If this happened during an interleaved event, interrupt the + // in-progress hydration. Theoretically, we could attempt to force a + // synchronous hydration before switching to client rendering, but the + // most common reason the shell hasn't hydrated yet is because it + // suspended. So it's very likely to suspend again anyway. For + // simplicity, we'll skip that atttempt and go straight to + // client rendering. + // + // Another way to model this would be to give the initial hydration its + // own special lane. However, it may not be worth adding a lane solely + // for this purpose, so we'll wait until we find another use case before + // adding it. + // + // TODO: Consider only interrupting hydration if the priority of the + // update is higher than default. + prepareFreshStack(root, NoLanes); + } + + root.isDehydrated = false; + var error = new Error( + "This root received an early update, before anything was able " + + "hydrate. Switched the entire root to client rendering." + ); + var onRecoverableError = root.onRecoverableError; + onRecoverableError(error); + } else if (root === workInProgressRoot) { + // TODO: Consolidate with `isInterleavedUpdate` check // Received an update to a tree that's in the middle of rendering. Mark // that there was an interleaved update work on this root. Unless the // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render @@ -20377,7 +20417,7 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { } return root; -} // This is split into a separate function so we can mark a fiber with pending +} // work without treating it as a typical update that originates from an event; // e.g. retrying a Suspense boundary isn't an update, but it does schedule work // on a fiber. @@ -20700,16 +20740,21 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } function recoverFromConcurrentError(root, errorRetryLanes) { - var prevExecutionContext = executionContext; - executionContext |= RetryAfterError; // If an error occurred during hydration, discard server response and fall + // If an error occurred during hydration, discard server response and fall // back to client side render. - if (root.isDehydrated) { root.isDehydrated = false; { errorHydratingContainer(root.containerInfo); } + + var error = new Error( + "There was an error while hydrating. Because the error happened outside " + + "of a Suspense boundary, the entire root will switch to " + + "client rendering." + ); + renderDidError(error); } var errorsFromFirstAttempt = workInProgressRootConcurrentErrors; @@ -20725,7 +20770,6 @@ function recoverFromConcurrentError(root, errorRetryLanes) { } } - executionContext = prevExecutionContext; return exitStatus; } @@ -21024,7 +21068,7 @@ function flushSync(fn) { var previousPriority = getCurrentUpdatePriority(); try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; setCurrentUpdatePriority(DiscreteEventPriority); if (fn) { @@ -21074,7 +21118,8 @@ function prepareFreshStack(root, lanes) { var interruptedWork = workInProgress.return; while (interruptedWork !== null) { - unwindInterruptedWork(interruptedWork); + var current = interruptedWork.alternate; + unwindInterruptedWork(current, interruptedWork); interruptedWork = interruptedWork.return; } } @@ -21466,7 +21511,7 @@ function completeUnitOfWork(unitOfWork) { // This fiber did not complete because something threw. Pop values off // the stack without entering the complete phase. If this is a boundary, // capture values if possible. - var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its lanes. + var _next = unwindWork(current, completedWork); // Because this fiber did not complete, don't reset its lanes. if (_next !== null) { // If completing this work spawned new work, do that next. We'll come @@ -21531,7 +21576,7 @@ function commitRoot(root, recoverableErrors) { var prevTransition = ReactCurrentBatchConfig$2.transition; try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; setCurrentUpdatePriority(DiscreteEventPriority); commitRootImpl(root, recoverableErrors, previousUpdateLanePriority); } finally { @@ -21643,7 +21688,7 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { if (subtreeHasEffects || rootHasEffect) { var prevTransition = ReactCurrentBatchConfig$2.transition; - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; var previousPriority = getCurrentUpdatePriority(); setCurrentUpdatePriority(DiscreteEventPriority); var prevExecutionContext = executionContext; @@ -21820,7 +21865,7 @@ function flushPassiveEffects() { var previousPriority = getCurrentUpdatePriority(); try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; setCurrentUpdatePriority(priority); return flushPassiveEffectsImpl(); } finally { @@ -21951,11 +21996,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { return; } - var fiber = null; - - { - fiber = sourceFiber.return; - } + var fiber = nearestMountedAncestor; while (fiber !== null) { if (fiber.tag === HostRoot) { @@ -21989,14 +22030,9 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { } { - // TODO: Until we re-land skipUnmountedBoundaries (see #20147), this warning - // will fire for errors that are thrown by destroy functions inside deleted - // trees. What it should instead do is propagate the error to the parent of - // the deleted tree. In the meantime, do not add this warning to the - // allowlist; this is only for our internal use. error( "Internal React error: Attempted to capture a commit phase error " + - "inside a detached tree. This indicates a bug in React. Likely " + + "inside a detached tree. This indicates a bug in React. Potential " + "causes include deleting the same fiber more than once, committing an " + "already-finished tree, or an inconsistent return pointer.\n\n" + "Error message:\n\n%s", @@ -22299,7 +22335,7 @@ var beginWork$1; // same fiber again. // Unwind the failed stack frame - unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. + unwindInterruptedWork(current, unitOfWork); // Restore the original properties of the fiber. assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); @@ -23690,7 +23726,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.0.0-rc.0-27b569969-20220211"; +var ReactVersion = "18.0.0-rc.0-4de99b3ca-20220221"; function createPortal( children, @@ -23813,7 +23849,8 @@ function findHostInstanceWithWarning(component, methodName) { function createContainer( containerInfo, - tag, + tag, // TODO: We can remove hydration-specific stuff from createContainer once + // we delete legacy mode. The new root API uses createHydrationContainer. hydrate, hydrationCallbacks, isStrictMode, diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index f057093a044..9c9d4e2cc67 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<9d64ad4ce3ec89212953470f0d425676>> */ "use strict"; @@ -927,7 +927,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_220 = { +var injectedNamesToPlugins$jscomp$inline_221 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -962,33 +962,33 @@ var injectedNamesToPlugins$jscomp$inline_220 = { } } }, - isOrderingDirty$jscomp$inline_221 = !1, - pluginName$jscomp$inline_222; -for (pluginName$jscomp$inline_222 in injectedNamesToPlugins$jscomp$inline_220) + isOrderingDirty$jscomp$inline_222 = !1, + pluginName$jscomp$inline_223; +for (pluginName$jscomp$inline_223 in injectedNamesToPlugins$jscomp$inline_221) if ( - injectedNamesToPlugins$jscomp$inline_220.hasOwnProperty( - pluginName$jscomp$inline_222 + injectedNamesToPlugins$jscomp$inline_221.hasOwnProperty( + pluginName$jscomp$inline_223 ) ) { - var pluginModule$jscomp$inline_223 = - injectedNamesToPlugins$jscomp$inline_220[pluginName$jscomp$inline_222]; + var pluginModule$jscomp$inline_224 = + injectedNamesToPlugins$jscomp$inline_221[pluginName$jscomp$inline_223]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_222) || - namesToPlugins[pluginName$jscomp$inline_222] !== - pluginModule$jscomp$inline_223 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_223) || + namesToPlugins[pluginName$jscomp$inline_223] !== + pluginModule$jscomp$inline_224 ) { - if (namesToPlugins[pluginName$jscomp$inline_222]) + if (namesToPlugins[pluginName$jscomp$inline_223]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_222 + "`.") + (pluginName$jscomp$inline_223 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_222 - ] = pluginModule$jscomp$inline_223; - isOrderingDirty$jscomp$inline_221 = !0; + pluginName$jscomp$inline_223 + ] = pluginModule$jscomp$inline_224; + isOrderingDirty$jscomp$inline_222 = !0; } } -isOrderingDirty$jscomp$inline_221 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_222 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -3865,7 +3865,7 @@ function startTransition(setPending, callback) { 0 !== previousPriority && 4 > previousPriority ? previousPriority : 4; setPending(!0); var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setPending(!1), callback(); } finally { @@ -4053,7 +4053,7 @@ var ContextOnlyDispatcher = { mountEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -4137,7 +4137,7 @@ var ContextOnlyDispatcher = { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -4180,7 +4180,7 @@ var ContextOnlyDispatcher = { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -5744,24 +5744,26 @@ function attemptEarlyBailoutIfNoScheduledUpdate( } return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } -function unwindWork(workInProgress) { +function unwindWork(current, workInProgress) { popTreeContext(workInProgress); switch (workInProgress.tag) { case 1: - isContextProvider(workInProgress.type) && popContext(); - var flags = workInProgress.flags; - return flags & 65536 - ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) - : null; + return ( + isContextProvider(workInProgress.type) && popContext(), + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), workInProgress) + : null + ); case 3: return ( popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), resetWorkInProgressVersions(), - (flags = workInProgress.flags), - 0 !== (flags & 65536) && 0 === (flags & 128) - ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + (current = workInProgress.flags), + 0 !== (current & 65536) && 0 === (current & 128) + ? ((workInProgress.flags = (current & -65537) | 128), workInProgress) : null ); case 5: @@ -5769,9 +5771,9 @@ function unwindWork(workInProgress) { case 13: return ( pop(suspenseStackCursor), - (flags = workInProgress.flags), - flags & 65536 - ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), workInProgress) : null ); case 19: @@ -6267,7 +6269,7 @@ function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 1; if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; - if (0 !== ReactCurrentBatchConfig.transition) + if (null !== ReactCurrentBatchConfig.transition) return ( 0 === currentEventTransitionLane && ((fiber = nextTransitionLane), @@ -6302,18 +6304,29 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (null === root) return null; markRootUpdated(root, lane, eventTime); - if (0 === (executionContext & 2) || root !== workInProgressRoot) - root === workInProgressRoot && - (0 === (executionContext & 2) && - (workInProgressRootInterleavedUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(root, workInProgressRootRenderLanes)), - ensureRootIsScheduled(root, eventTime), - 1 === lane && - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + if (0 === (executionContext & 2) || root !== workInProgressRoot) { + if (root.isDehydrated && 0 !== root.tag) { + workInProgressRoot === root && prepareFreshStack(root, 0); + root.isDehydrated = !1; + var onRecoverableError$91 = root.onRecoverableError; + onRecoverableError$91( + Error( + "This root received an early update, before anything was able hydrate. Switched the entire root to client rendering." + ) + ); + } else + root === workInProgressRoot && + (0 === (executionContext & 2) && + (workInProgressRootInterleavedUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(root, workInProgressRootRenderLanes)); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); + } return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6560,9 +6573,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { : null; } function recoverFromConcurrentError(root, errorRetryLanes) { - var prevExecutionContext = executionContext; - executionContext |= 8; - root.isDehydrated && (root.isDehydrated = !1); + root.isDehydrated && + ((root.isDehydrated = !1), + renderDidError( + Error( + "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering." + ) + )); var errorsFromFirstAttempt = workInProgressRootConcurrentErrors; root = renderRootSync(root, errorRetryLanes); 2 !== root && @@ -6573,7 +6590,6 @@ function recoverFromConcurrentError(root, errorRetryLanes) { workInProgressRootRecoverableErrors, errorsFromFirstAttempt )); - executionContext = prevExecutionContext; return root; } function isRenderConsistentWithExternalStores(finishedWork) { @@ -6847,7 +6863,7 @@ function handleError(root$jscomp$0, thrownValue) { } else wakeables.add(root); break a; } else { - if ((thrownValue & 4194240) === thrownValue) { + if (0 === (thrownValue & 1)) { attachPingListener(root, wakeable, thrownValue); renderDidSuspendDelayIfPossible(); break a; @@ -6858,12 +6874,7 @@ function handleError(root$jscomp$0, thrownValue) { ); } } - root = value; - 4 !== workInProgressRootExitStatus && - (workInProgressRootExitStatus = 2); - null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + renderDidError(value); value = createCapturedValue(value, sourceFiber); root = returnFiber; do { @@ -6935,6 +6946,12 @@ function renderDidSuspendDelayIfPossible() { 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); } +function renderDidError(error) { + 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); + null === workInProgressRootConcurrentErrors + ? (workInProgressRootConcurrentErrors = [error]) + : workInProgressRootConcurrentErrors.push(error); +} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 2; @@ -6987,7 +7004,7 @@ function completeUnitOfWork(unitOfWork) { return; } } else { - current = unwindWork(completedWork); + current = unwindWork(current, completedWork); if (null !== current) { current.flags &= 32767; workInProgress = current; @@ -7016,7 +7033,7 @@ function commitRoot(root, recoverableErrors) { var previousUpdateLanePriority = currentUpdatePriority, prevTransition = ReactCurrentBatchConfig$2.transition; try { - (ReactCurrentBatchConfig$2.transition = 0), + (ReactCurrentBatchConfig$2.transition = null), (currentUpdatePriority = 1), commitRootImpl(root, recoverableErrors, previousUpdateLanePriority); } finally { @@ -7057,7 +7074,7 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { remainingLanes = 0 !== (finishedWork.flags & 15990); if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) { remainingLanes = ReactCurrentBatchConfig$2.transition; - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; var previousPriority = currentUpdatePriority; currentUpdatePriority = 1; var prevExecutionContext = executionContext; @@ -7110,7 +7127,7 @@ function flushPassiveEffects() { prevTransition = ReactCurrentBatchConfig$2.transition, previousPriority = currentUpdatePriority; try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; currentUpdatePriority = 16 > renderPriority ? 16 : renderPriority; if (null === rootWithPendingPassiveEffects) var JSCompiler_inline_result = !1; @@ -7263,11 +7280,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); else - for ( - nearestMountedAncestor = sourceFiber.return; - null !== nearestMountedAncestor; - - ) { + for (; null !== nearestMountedAncestor; ) { if (3 === nearestMountedAncestor.tag) { captureCommitPhaseErrorOnRoot( nearestMountedAncestor, @@ -8195,10 +8208,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_928 = { + devToolsConfig$jscomp$inline_930 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-rc.0-27b569969-20220211", + version: "18.0.0-rc.0-4de99b3ca-20220221", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8214,10 +8227,10 @@ var roots = new Map(), } }; var internals$jscomp$inline_1178 = { - bundleType: devToolsConfig$jscomp$inline_928.bundleType, - version: devToolsConfig$jscomp$inline_928.version, - rendererPackageName: devToolsConfig$jscomp$inline_928.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_928.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_930.bundleType, + version: devToolsConfig$jscomp$inline_930.version, + rendererPackageName: devToolsConfig$jscomp$inline_930.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_930.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8233,14 +8246,14 @@ var internals$jscomp$inline_1178 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_928.findFiberByHostInstance || + devToolsConfig$jscomp$inline_930.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-rc.0-27b569969-20220211" + reconcilerVersion: "18.0.0-rc.0-4de99b3ca-20220221" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1179 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 3f8d9541bb3..a3878770557 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<5ba9e2059ecc2a06c22933fa3c732fc7>> */ @@ -938,7 +938,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_229 = { +var injectedNamesToPlugins$jscomp$inline_230 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -973,33 +973,33 @@ var injectedNamesToPlugins$jscomp$inline_229 = { } } }, - isOrderingDirty$jscomp$inline_230 = !1, - pluginName$jscomp$inline_231; -for (pluginName$jscomp$inline_231 in injectedNamesToPlugins$jscomp$inline_229) + isOrderingDirty$jscomp$inline_231 = !1, + pluginName$jscomp$inline_232; +for (pluginName$jscomp$inline_232 in injectedNamesToPlugins$jscomp$inline_230) if ( - injectedNamesToPlugins$jscomp$inline_229.hasOwnProperty( - pluginName$jscomp$inline_231 + injectedNamesToPlugins$jscomp$inline_230.hasOwnProperty( + pluginName$jscomp$inline_232 ) ) { - var pluginModule$jscomp$inline_232 = - injectedNamesToPlugins$jscomp$inline_229[pluginName$jscomp$inline_231]; + var pluginModule$jscomp$inline_233 = + injectedNamesToPlugins$jscomp$inline_230[pluginName$jscomp$inline_232]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_231) || - namesToPlugins[pluginName$jscomp$inline_231] !== - pluginModule$jscomp$inline_232 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_232) || + namesToPlugins[pluginName$jscomp$inline_232] !== + pluginModule$jscomp$inline_233 ) { - if (namesToPlugins[pluginName$jscomp$inline_231]) + if (namesToPlugins[pluginName$jscomp$inline_232]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_231 + "`.") + (pluginName$jscomp$inline_232 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_231 - ] = pluginModule$jscomp$inline_232; - isOrderingDirty$jscomp$inline_230 = !0; + pluginName$jscomp$inline_232 + ] = pluginModule$jscomp$inline_233; + isOrderingDirty$jscomp$inline_231 = !0; } } -isOrderingDirty$jscomp$inline_230 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_231 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -3997,7 +3997,7 @@ function startTransition(setPending, callback) { 0 !== previousPriority && 4 > previousPriority ? previousPriority : 4; setPending(!0); var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setPending(!1), callback(); } finally { @@ -4187,7 +4187,7 @@ var ContextOnlyDispatcher = { mountEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -4271,7 +4271,7 @@ var ContextOnlyDispatcher = { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -4314,7 +4314,7 @@ var ContextOnlyDispatcher = { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -6017,27 +6017,29 @@ function attemptEarlyBailoutIfNoScheduledUpdate( } return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } -function unwindWork(workInProgress) { +function unwindWork(current, workInProgress) { popTreeContext(workInProgress); switch (workInProgress.tag) { case 1: - isContextProvider(workInProgress.type) && popContext(); - var flags = workInProgress.flags; - return flags & 65536 - ? ((workInProgress.flags = (flags & -65537) | 128), - 0 !== (workInProgress.mode & 2) && - transferActualDuration(workInProgress), - workInProgress) - : null; + return ( + isContextProvider(workInProgress.type) && popContext(), + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), + 0 !== (workInProgress.mode & 2) && + transferActualDuration(workInProgress), + workInProgress) + : null + ); case 3: return ( popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), resetWorkInProgressVersions(), - (flags = workInProgress.flags), - 0 !== (flags & 65536) && 0 === (flags & 128) - ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + (current = workInProgress.flags), + 0 !== (current & 65536) && 0 === (current & 128) + ? ((workInProgress.flags = (current & -65537) | 128), workInProgress) : null ); case 5: @@ -6045,9 +6047,9 @@ function unwindWork(workInProgress) { case 13: return ( pop(suspenseStackCursor), - (flags = workInProgress.flags), - flags & 65536 - ? ((workInProgress.flags = (flags & -65537) | 128), + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), 0 !== (workInProgress.mode & 2) && transferActualDuration(workInProgress), workInProgress) @@ -6723,7 +6725,7 @@ function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 1; if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; - if (0 !== ReactCurrentBatchConfig.transition) + if (null !== ReactCurrentBatchConfig.transition) return ( 0 === currentEventTransitionLane && ((fiber = nextTransitionLane), @@ -6758,19 +6760,30 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (null === root) return null; markRootUpdated(root, lane, eventTime); - if (0 === (executionContext & 2) || root !== workInProgressRoot) - isDevToolsPresent && addFiberToLanesMap(root, fiber, lane), + if (0 === (executionContext & 2) || root !== workInProgressRoot) { + isDevToolsPresent && addFiberToLanesMap(root, fiber, lane); + if (root.isDehydrated && 0 !== root.tag) { + workInProgressRoot === root && prepareFreshStack(root, 0); + root.isDehydrated = !1; + var onRecoverableError$100 = root.onRecoverableError; + onRecoverableError$100( + Error( + "This root received an early update, before anything was able hydrate. Switched the entire root to client rendering." + ) + ); + } else root === workInProgressRoot && (0 === (executionContext & 2) && (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && - markRootSuspended$1(root, workInProgressRootRenderLanes)), - ensureRootIsScheduled(root, eventTime), - 1 === lane && - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + markRootSuspended$1(root, workInProgressRootRenderLanes)); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); + } return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -7031,9 +7044,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { : null; } function recoverFromConcurrentError(root, errorRetryLanes) { - var prevExecutionContext = executionContext; - executionContext |= 8; - root.isDehydrated && (root.isDehydrated = !1); + root.isDehydrated && + ((root.isDehydrated = !1), + renderDidError( + Error( + "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering." + ) + )); var errorsFromFirstAttempt = workInProgressRootConcurrentErrors; root = renderRootSync(root, errorRetryLanes); 2 !== root && @@ -7044,7 +7061,6 @@ function recoverFromConcurrentError(root, errorRetryLanes) { workInProgressRootRecoverableErrors, errorsFromFirstAttempt )); - executionContext = prevExecutionContext; return root; } function isRenderConsistentWithExternalStores(finishedWork) { @@ -7345,7 +7361,7 @@ function handleError(root, thrownValue) { } else wakeables.add(wakeable); break a; } else { - if ((thrownValue & 4194240) === thrownValue) { + if (0 === (thrownValue & 1)) { attachPingListener(wakeable, wakeable$jscomp$0, thrownValue); renderDidSuspendDelayIfPossible(); break a; @@ -7356,12 +7372,7 @@ function handleError(root, thrownValue) { ); } } - wakeable = value; - 4 !== workInProgressRootExitStatus && - (workInProgressRootExitStatus = 2); - null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [wakeable]) - : workInProgressRootConcurrentErrors.push(wakeable); + renderDidError(value); value = createCapturedValue(value, sourceFiber); wakeable = returnFiber; do { @@ -7433,6 +7444,12 @@ function renderDidSuspendDelayIfPossible() { 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); } +function renderDidError(error) { + 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); + null === workInProgressRootConcurrentErrors + ? (workInProgressRootConcurrentErrors = [error]) + : workInProgressRootConcurrentErrors.push(error); +} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 2; @@ -7509,7 +7526,7 @@ function completeUnitOfWork(unitOfWork) { return; } } else { - current = unwindWork(completedWork); + current = unwindWork(current, completedWork); if (null !== current) { current.flags &= 32767; workInProgress = current; @@ -7545,7 +7562,7 @@ function commitRoot(root, recoverableErrors) { var previousUpdateLanePriority = currentUpdatePriority, prevTransition = ReactCurrentBatchConfig$2.transition; try { - (ReactCurrentBatchConfig$2.transition = 0), + (ReactCurrentBatchConfig$2.transition = null), (currentUpdatePriority = 1), commitRootImpl(root, recoverableErrors, previousUpdateLanePriority); } finally { @@ -7589,7 +7606,7 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { remainingLanes = 0 !== (finishedWork.flags & 15990); if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) { remainingLanes = ReactCurrentBatchConfig$2.transition; - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; var previousPriority = currentUpdatePriority; currentUpdatePriority = 1; var prevExecutionContext = executionContext; @@ -7652,7 +7669,7 @@ function flushPassiveEffects() { prevTransition = ReactCurrentBatchConfig$2.transition, previousPriority = currentUpdatePriority; try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; currentUpdatePriority = 16 > renderPriority ? 16 : renderPriority; if (null === rootWithPendingPassiveEffects) var JSCompiler_inline_result = !1; @@ -7879,11 +7896,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); else - for ( - nearestMountedAncestor = sourceFiber.return; - null !== nearestMountedAncestor; - - ) { + for (; null !== nearestMountedAncestor; ) { if (3 === nearestMountedAncestor.tag) { captureCommitPhaseErrorOnRoot( nearestMountedAncestor, @@ -8840,10 +8853,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1005 = { + devToolsConfig$jscomp$inline_1007 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-rc.0-27b569969-20220211", + version: "18.0.0-rc.0-4de99b3ca-20220221", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8872,10 +8885,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1005.bundleType, - version: devToolsConfig$jscomp$inline_1005.version, - rendererPackageName: devToolsConfig$jscomp$inline_1005.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1005.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1007.bundleType, + version: devToolsConfig$jscomp$inline_1007.version, + rendererPackageName: devToolsConfig$jscomp$inline_1007.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1007.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8891,14 +8904,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1005.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1007.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-rc.0-27b569969-20220211" + reconcilerVersion: "18.0.0-rc.0-4de99b3ca-20220221" }); exports.createPortal = function(children, containerTag) { return createPortal( diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index db26fad7a4c..7d4b813f6e1 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<8857db59af5934c939dce4733ccdabb0>> + * @generated SignedSource<<352e7339901c7a326f6e97b0faea7ffa>> */ 'use strict'; @@ -5225,6 +5225,9 @@ function getLanesToRetrySynchronouslyOnError(root) { return NoLanes; } +function includesSyncLane(lanes) { + return (lanes & SyncLane) !== NoLanes; +} function includesNonIdleWork(lanes) { return (lanes & NonIdleLanes) !== NoLanes; } @@ -6531,7 +6534,7 @@ function flushSyncCallbacks() { } var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; -var NoTransition = 0; +var NoTransition = null; function requestCurrentTransition() { return ReactCurrentBatchConfig.transition; } @@ -11748,7 +11751,9 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { { if (!didWarnUncachedGetSnapshot) { - if (nextSnapshot !== getSnapshot()) { + var cachedSnapshot = getSnapshot(); + + if (!objectIs(nextSnapshot, cachedSnapshot)) { error( "The result of getSnapshot should be cached to avoid an infinite loop" ); @@ -11814,7 +11819,9 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { { if (!didWarnUncachedGetSnapshot) { - if (nextSnapshot !== getSnapshot()) { + var cachedSnapshot = getSnapshot(); + + if (!objectIs(nextSnapshot, cachedSnapshot)) { error( "The result of getSnapshot should be cached to avoid an infinite loop" ); @@ -12251,7 +12258,7 @@ function mountDeferredValue(value) { mountEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); @@ -12272,7 +12279,7 @@ function updateDeferredValue(value) { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); @@ -12293,7 +12300,7 @@ function rerenderDeferredValue(value) { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); @@ -12313,7 +12320,12 @@ function startTransition(setPending, callback) { ); setPending(true); var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; + var currentTransition = ReactCurrentBatchConfig$1.transition; + + { + ReactCurrentBatchConfig$1.transition._updatedFibers = new Set(); + } try { setPending(false); @@ -12324,11 +12336,11 @@ function startTransition(setPending, callback) { { if ( - prevTransition !== 1 && + prevTransition === null && warnOnSubscriptionInsideStartTransition && - ReactCurrentBatchConfig$1._updatedFibers + currentTransition._updatedFibers ) { - var updatedFibersCount = ReactCurrentBatchConfig$1._updatedFibers.size; + var updatedFibersCount = currentTransition._updatedFibers.size; if (updatedFibersCount > 10) { warn( @@ -12338,7 +12350,7 @@ function startTransition(setPending, callback) { ); } - ReactCurrentBatchConfig$1._updatedFibers.clear(); + currentTransition._updatedFibers.clear(); } } } @@ -14097,22 +14109,22 @@ function throwException( attachRetryListener(suspenseBoundary, root, wakeable); return; } else { - // No boundary was found. If we're inside startTransition, this is OK. + // No boundary was found. Unless this is a sync update, this is OK. // We can suspend and wait for more data to arrive. - if (includesOnlyTransitions(rootRenderLanes)) { - // This is a transition. Suspend. Since we're not activating a Suspense - // boundary, this will unwind all the way to the root without performing - // a second pass to render a fallback. (This is arguably how refresh - // transitions should work, too, since we're not going to commit the - // fallbacks anyway.) + if (!includesSyncLane(rootRenderLanes)) { + // This is not a sync update. Suspend. Since we're not activating a + // Suspense boundary, this will unwind all the way to the root without + // performing a second pass to render a fallback. (This is arguably how + // refresh transitions should work, too, since we're not going to commit + // the fallbacks anyway.) + // + // This case also applies to initial hydration. attachPingListener(root, wakeable, rootRenderLanes); renderDidSuspendDelayIfPossible(); return; - } // We're not in a transition. We treat this case like an error because - // discrete renders are expected to finish synchronously to maintain - // consistency with external state. - // TODO: This will error during non-transition concurrent renders, too. - // But maybe it shouldn't? + } // This is a sync/discrete update. We treat this case like an error + // because discrete renders are expected to produce a complete tree + // synchronously to maintain consistency with external state. // TODO: We should never call getComponentNameFromFiber in production. // Log a warning or something to prevent us from accidentally bundling it. @@ -15463,11 +15475,7 @@ function updateSimpleMemoComponent( function updateOffscreenComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var nextChildren = nextProps.children; - var prevState = current !== null ? current.memoizedState : null; // If this is not null, this is a cache pool that was carried over from the - // previous render. We will push this to the cache pool context so that we can - // resume in-flight requests. - - var spawnedCachePool = null; + var prevState = current !== null ? current.memoizedState : null; if ( nextProps.mode === "hidden" || @@ -15481,10 +15489,12 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { cachePool: null }; workInProgress.memoizedState = nextState; + pushRenderLanes(workInProgress, renderLanes); } else if (!includesSomeLane(renderLanes, OffscreenLane)) { - // We're hidden, and we're not rendering at Offscreen. We will bail out + var spawnedCachePool = null; // We're hidden, and we're not rendering at Offscreen. We will bail out // and resume this tree later. + var nextBaseLanes; if (prevState !== null) { @@ -15502,13 +15512,16 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { cachePool: spawnedCachePool }; workInProgress.memoizedState = _nextState; - workInProgress.updateQueue = null; // We're about to bail out, but we need to push this to the stack anyway + workInProgress.updateQueue = null; // to avoid a push/pop misalignment. pushRenderLanes(workInProgress, nextBaseLanes); return null; } else { + // This is the second render. The surrounding visible content has already + // committed. Now we resume rendering the hidden tree. + // Rendering at offscreen, so we can clear the base lanes. var _nextState2 = { baseLanes: NoLanes, cachePool: null @@ -15517,6 +15530,7 @@ function updateOffscreenComponent(current, workInProgress, renderLanes) { var subtreeRenderLanes = prevState !== null ? prevState.baseLanes : renderLanes; + pushRenderLanes(workInProgress, subtreeRenderLanes); } } else { @@ -18084,7 +18098,7 @@ function beginWork(current, workInProgress, renderLanes) { ); } -function unwindWork(workInProgress, renderLanes) { +function unwindWork(current, workInProgress, renderLanes) { // Note: This intentionally doesn't check if we're hydrating because comparing // to the current tree provider fiber is just as fast and less error-prone. // Ideally we would have a special version of the work loop only @@ -18187,7 +18201,7 @@ function unwindWork(workInProgress, renderLanes) { } } -function unwindInterruptedWork(interruptedWork, renderLanes) { +function unwindInterruptedWork(current, interruptedWork, renderLanes) { // Note: This intentionally doesn't check if we're hydrating because comparing // to the current tree provider fiber is just as fast and less error-prone. // Ideally we would have a special version of the work loop only @@ -20516,9 +20530,6 @@ var RenderContext = var CommitContext = /* */ 4; -var RetryAfterError = - /* */ - 8; var RootInProgress = 0; var RootFatalErrored = 1; var RootErrored = 2; @@ -20723,7 +20734,36 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { warnIfUpdatesNotWrappedWithActDEV(fiber); - if (root === workInProgressRoot) { + if (root.isDehydrated && root.tag !== LegacyRoot) { + // This root's shell hasn't hydrated yet. Revert to client rendering. + if (workInProgressRoot === root) { + // If this happened during an interleaved event, interrupt the + // in-progress hydration. Theoretically, we could attempt to force a + // synchronous hydration before switching to client rendering, but the + // most common reason the shell hasn't hydrated yet is because it + // suspended. So it's very likely to suspend again anyway. For + // simplicity, we'll skip that atttempt and go straight to + // client rendering. + // + // Another way to model this would be to give the initial hydration its + // own special lane. However, it may not be worth adding a lane solely + // for this purpose, so we'll wait until we find another use case before + // adding it. + // + // TODO: Consider only interrupting hydration if the priority of the + // update is higher than default. + prepareFreshStack(root, NoLanes); + } + + root.isDehydrated = false; + var error = new Error( + "This root received an early update, before anything was able " + + "hydrate. Switched the entire root to client rendering." + ); + var onRecoverableError = root.onRecoverableError; + onRecoverableError(error); + } else if (root === workInProgressRoot) { + // TODO: Consolidate with `isInterleavedUpdate` check // Received an update to a tree that's in the middle of rendering. Mark // that there was an interleaved update work on this root. Unless the // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render @@ -20766,7 +20806,7 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { } return root; -} // This is split into a separate function so we can mark a fiber with pending +} // work without treating it as a typical update that originates from an event; // e.g. retrying a Suspense boundary isn't an update, but it does schedule work // on a fiber. @@ -21089,16 +21129,21 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } function recoverFromConcurrentError(root, errorRetryLanes) { - var prevExecutionContext = executionContext; - executionContext |= RetryAfterError; // If an error occurred during hydration, discard server response and fall + // If an error occurred during hydration, discard server response and fall // back to client side render. - if (root.isDehydrated) { root.isDehydrated = false; { errorHydratingContainer(root.containerInfo); } + + var error = new Error( + "There was an error while hydrating. Because the error happened outside " + + "of a Suspense boundary, the entire root will switch to " + + "client rendering." + ); + renderDidError(error); } var errorsFromFirstAttempt = workInProgressRootConcurrentErrors; @@ -21114,7 +21159,6 @@ function recoverFromConcurrentError(root, errorRetryLanes) { } } - executionContext = prevExecutionContext; return exitStatus; } @@ -21413,7 +21457,7 @@ function flushSync(fn) { var previousPriority = getCurrentUpdatePriority(); try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; setCurrentUpdatePriority(DiscreteEventPriority); if (fn) { @@ -21463,7 +21507,8 @@ function prepareFreshStack(root, lanes) { var interruptedWork = workInProgress.return; while (interruptedWork !== null) { - unwindInterruptedWork(interruptedWork); + var current = interruptedWork.alternate; + unwindInterruptedWork(current, interruptedWork); interruptedWork = interruptedWork.return; } } @@ -21855,7 +21900,7 @@ function completeUnitOfWork(unitOfWork) { // This fiber did not complete because something threw. Pop values off // the stack without entering the complete phase. If this is a boundary, // capture values if possible. - var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its lanes. + var _next = unwindWork(current, completedWork); // Because this fiber did not complete, don't reset its lanes. if (_next !== null) { // If completing this work spawned new work, do that next. We'll come @@ -21920,7 +21965,7 @@ function commitRoot(root, recoverableErrors) { var prevTransition = ReactCurrentBatchConfig$2.transition; try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; setCurrentUpdatePriority(DiscreteEventPriority); commitRootImpl(root, recoverableErrors, previousUpdateLanePriority); } finally { @@ -22032,7 +22077,7 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { if (subtreeHasEffects || rootHasEffect) { var prevTransition = ReactCurrentBatchConfig$2.transition; - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; var previousPriority = getCurrentUpdatePriority(); setCurrentUpdatePriority(DiscreteEventPriority); var prevExecutionContext = executionContext; @@ -22209,7 +22254,7 @@ function flushPassiveEffects() { var previousPriority = getCurrentUpdatePriority(); try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; setCurrentUpdatePriority(priority); return flushPassiveEffectsImpl(); } finally { @@ -22340,11 +22385,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { return; } - var fiber = null; - - { - fiber = sourceFiber.return; - } + var fiber = nearestMountedAncestor; while (fiber !== null) { if (fiber.tag === HostRoot) { @@ -22378,14 +22419,9 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error$1) { } { - // TODO: Until we re-land skipUnmountedBoundaries (see #20147), this warning - // will fire for errors that are thrown by destroy functions inside deleted - // trees. What it should instead do is propagate the error to the parent of - // the deleted tree. In the meantime, do not add this warning to the - // allowlist; this is only for our internal use. error( "Internal React error: Attempted to capture a commit phase error " + - "inside a detached tree. This indicates a bug in React. Likely " + + "inside a detached tree. This indicates a bug in React. Potential " + "causes include deleting the same fiber more than once, committing an " + "already-finished tree, or an inconsistent return pointer.\n\n" + "Error message:\n\n%s", @@ -22688,7 +22724,7 @@ var beginWork$1; // same fiber again. // Unwind the failed stack frame - unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. + unwindInterruptedWork(current, unitOfWork); // Restore the original properties of the fiber. assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); @@ -24075,7 +24111,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.0.0-rc.0-27b569969-20220211"; +var ReactVersion = "18.0.0-rc.0-4de99b3ca-20220221"; function createPortal( children, @@ -24198,7 +24234,8 @@ function findHostInstanceWithWarning(component, methodName) { function createContainer( containerInfo, - tag, + tag, // TODO: We can remove hydration-specific stuff from createContainer once + // we delete legacy mode. The new root API uses createHydrationContainer. hydrate, hydrationCallbacks, isStrictMode, diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index c288efd2954..5b7b2c20947 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<864338c9d062ce0a8cdbee102f1e32d4>> + * @generated SignedSource<<4999d18c1629b3657b9e8453167861e8>> */ "use strict"; @@ -926,7 +926,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_223 = { +var injectedNamesToPlugins$jscomp$inline_224 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -961,33 +961,33 @@ var injectedNamesToPlugins$jscomp$inline_223 = { } } }, - isOrderingDirty$jscomp$inline_224 = !1, - pluginName$jscomp$inline_225; -for (pluginName$jscomp$inline_225 in injectedNamesToPlugins$jscomp$inline_223) + isOrderingDirty$jscomp$inline_225 = !1, + pluginName$jscomp$inline_226; +for (pluginName$jscomp$inline_226 in injectedNamesToPlugins$jscomp$inline_224) if ( - injectedNamesToPlugins$jscomp$inline_223.hasOwnProperty( - pluginName$jscomp$inline_225 + injectedNamesToPlugins$jscomp$inline_224.hasOwnProperty( + pluginName$jscomp$inline_226 ) ) { - var pluginModule$jscomp$inline_226 = - injectedNamesToPlugins$jscomp$inline_223[pluginName$jscomp$inline_225]; + var pluginModule$jscomp$inline_227 = + injectedNamesToPlugins$jscomp$inline_224[pluginName$jscomp$inline_226]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_225) || - namesToPlugins[pluginName$jscomp$inline_225] !== - pluginModule$jscomp$inline_226 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_226) || + namesToPlugins[pluginName$jscomp$inline_226] !== + pluginModule$jscomp$inline_227 ) { - if (namesToPlugins[pluginName$jscomp$inline_225]) + if (namesToPlugins[pluginName$jscomp$inline_226]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_225 + "`.") + (pluginName$jscomp$inline_226 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_225 - ] = pluginModule$jscomp$inline_226; - isOrderingDirty$jscomp$inline_224 = !0; + pluginName$jscomp$inline_226 + ] = pluginModule$jscomp$inline_227; + isOrderingDirty$jscomp$inline_225 = !0; } } -isOrderingDirty$jscomp$inline_224 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_225 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -3842,7 +3842,7 @@ function startTransition(setPending, callback) { 0 !== previousPriority && 4 > previousPriority ? previousPriority : 4; setPending(!0); var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setPending(!1), callback(); } finally { @@ -4030,7 +4030,7 @@ var ContextOnlyDispatcher = { mountEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -4114,7 +4114,7 @@ var ContextOnlyDispatcher = { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -4157,7 +4157,7 @@ var ContextOnlyDispatcher = { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -5518,24 +5518,26 @@ function attemptEarlyBailoutIfNoScheduledUpdate( } return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } -function unwindWork(workInProgress) { +function unwindWork(current, workInProgress) { popTreeContext(workInProgress); switch (workInProgress.tag) { case 1: - isContextProvider(workInProgress.type) && popContext(); - var flags = workInProgress.flags; - return flags & 65536 - ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) - : null; + return ( + isContextProvider(workInProgress.type) && popContext(), + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), workInProgress) + : null + ); case 3: return ( popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), resetWorkInProgressVersions(), - (flags = workInProgress.flags), - 0 !== (flags & 65536) && 0 === (flags & 128) - ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + (current = workInProgress.flags), + 0 !== (current & 65536) && 0 === (current & 128) + ? ((workInProgress.flags = (current & -65537) | 128), workInProgress) : null ); case 5: @@ -5543,9 +5545,9 @@ function unwindWork(workInProgress) { case 13: return ( pop(suspenseStackCursor), - (flags = workInProgress.flags), - flags & 65536 - ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), workInProgress) : null ); case 19: @@ -6384,7 +6386,7 @@ function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 1; if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; - if (0 !== ReactCurrentBatchConfig.transition) + if (null !== ReactCurrentBatchConfig.transition) return ( 0 === currentEventTransitionLane && ((fiber = nextTransitionLane), @@ -6406,18 +6408,29 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (null === root) return null; markRootUpdated(root, lane, eventTime); - if (0 === (executionContext & 2) || root !== workInProgressRoot) - root === workInProgressRoot && - (0 === (executionContext & 2) && - (workInProgressRootInterleavedUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(root, workInProgressRootRenderLanes)), - ensureRootIsScheduled(root, eventTime), - 1 === lane && - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + if (0 === (executionContext & 2) || root !== workInProgressRoot) { + if (root.isDehydrated && 0 !== root.tag) { + workInProgressRoot === root && prepareFreshStack(root, 0); + root.isDehydrated = !1; + var onRecoverableError$93 = root.onRecoverableError; + onRecoverableError$93( + Error( + "This root received an early update, before anything was able hydrate. Switched the entire root to client rendering." + ) + ); + } else + root === workInProgressRoot && + (0 === (executionContext & 2) && + (workInProgressRootInterleavedUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(root, workInProgressRootRenderLanes)); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); + } return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6664,9 +6677,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { : null; } function recoverFromConcurrentError(root, errorRetryLanes) { - var prevExecutionContext = executionContext; - executionContext |= 8; - root.isDehydrated && (root.isDehydrated = !1); + root.isDehydrated && + ((root.isDehydrated = !1), + renderDidError( + Error( + "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering." + ) + )); var errorsFromFirstAttempt = workInProgressRootConcurrentErrors; root = renderRootSync(root, errorRetryLanes); 2 !== root && @@ -6677,7 +6694,6 @@ function recoverFromConcurrentError(root, errorRetryLanes) { workInProgressRootRecoverableErrors, errorsFromFirstAttempt )); - executionContext = prevExecutionContext; return root; } function isRenderConsistentWithExternalStores(finishedWork) { @@ -6937,7 +6953,7 @@ function handleError(root$jscomp$0, thrownValue) { } else wakeables.add(root); break a; } else { - if ((thrownValue & 4194240) === thrownValue) { + if (0 === (thrownValue & 1)) { attachPingListener(root, wakeable, thrownValue); renderDidSuspendDelayIfPossible(); break a; @@ -6948,12 +6964,7 @@ function handleError(root$jscomp$0, thrownValue) { ); } } - root = value; - 4 !== workInProgressRootExitStatus && - (workInProgressRootExitStatus = 2); - null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + renderDidError(value); value = createCapturedValue(value, sourceFiber); root = returnFiber; do { @@ -7025,6 +7036,12 @@ function renderDidSuspendDelayIfPossible() { 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); } +function renderDidError(error) { + 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); + null === workInProgressRootConcurrentErrors + ? (workInProgressRootConcurrentErrors = [error]) + : workInProgressRootConcurrentErrors.push(error); +} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 2; @@ -7077,7 +7094,7 @@ function completeUnitOfWork(unitOfWork) { return; } } else { - current = unwindWork(completedWork); + current = unwindWork(current, completedWork); if (null !== current) { current.flags &= 32767; workInProgress = current; @@ -7106,7 +7123,7 @@ function commitRoot(root, recoverableErrors) { var previousUpdateLanePriority = currentUpdatePriority, prevTransition = ReactCurrentBatchConfig$2.transition; try { - (ReactCurrentBatchConfig$2.transition = 0), + (ReactCurrentBatchConfig$2.transition = null), (currentUpdatePriority = 1), commitRootImpl(root, recoverableErrors, previousUpdateLanePriority); } finally { @@ -7147,7 +7164,7 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { remainingLanes = 0 !== (finishedWork.flags & 15990); if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) { remainingLanes = ReactCurrentBatchConfig$2.transition; - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; var previousPriority = currentUpdatePriority; currentUpdatePriority = 1; var prevExecutionContext = executionContext; @@ -7200,7 +7217,7 @@ function flushPassiveEffects() { prevTransition = ReactCurrentBatchConfig$2.transition, previousPriority = currentUpdatePriority; try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; currentUpdatePriority = 16 > renderPriority ? 16 : renderPriority; if (null === rootWithPendingPassiveEffects) var JSCompiler_inline_result = !1; @@ -7353,11 +7370,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); else - for ( - nearestMountedAncestor = sourceFiber.return; - null !== nearestMountedAncestor; - - ) { + for (; null !== nearestMountedAncestor; ) { if (3 === nearestMountedAncestor.tag) { captureCommitPhaseErrorOnRoot( nearestMountedAncestor, @@ -8285,10 +8298,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_969 = { + devToolsConfig$jscomp$inline_971 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-rc.0-27b569969-20220211", + version: "18.0.0-rc.0-4de99b3ca-20220221", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8304,10 +8317,10 @@ var roots = new Map(), } }; var internals$jscomp$inline_1229 = { - bundleType: devToolsConfig$jscomp$inline_969.bundleType, - version: devToolsConfig$jscomp$inline_969.version, - rendererPackageName: devToolsConfig$jscomp$inline_969.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_969.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_971.bundleType, + version: devToolsConfig$jscomp$inline_971.version, + rendererPackageName: devToolsConfig$jscomp$inline_971.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_971.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8323,14 +8336,14 @@ var internals$jscomp$inline_1229 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_969.findFiberByHostInstance || + devToolsConfig$jscomp$inline_971.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-rc.0-27b569969-20220211" + reconcilerVersion: "18.0.0-rc.0-4de99b3ca-20220221" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1230 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 1bb71dd7138..8a48388f0f6 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<3509fb902c15e4c5d01b428ac9a79cbc>> */ @@ -937,7 +937,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_232 = { +var injectedNamesToPlugins$jscomp$inline_233 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -972,33 +972,33 @@ var injectedNamesToPlugins$jscomp$inline_232 = { } } }, - isOrderingDirty$jscomp$inline_233 = !1, - pluginName$jscomp$inline_234; -for (pluginName$jscomp$inline_234 in injectedNamesToPlugins$jscomp$inline_232) + isOrderingDirty$jscomp$inline_234 = !1, + pluginName$jscomp$inline_235; +for (pluginName$jscomp$inline_235 in injectedNamesToPlugins$jscomp$inline_233) if ( - injectedNamesToPlugins$jscomp$inline_232.hasOwnProperty( - pluginName$jscomp$inline_234 + injectedNamesToPlugins$jscomp$inline_233.hasOwnProperty( + pluginName$jscomp$inline_235 ) ) { - var pluginModule$jscomp$inline_235 = - injectedNamesToPlugins$jscomp$inline_232[pluginName$jscomp$inline_234]; + var pluginModule$jscomp$inline_236 = + injectedNamesToPlugins$jscomp$inline_233[pluginName$jscomp$inline_235]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_234) || - namesToPlugins[pluginName$jscomp$inline_234] !== - pluginModule$jscomp$inline_235 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_235) || + namesToPlugins[pluginName$jscomp$inline_235] !== + pluginModule$jscomp$inline_236 ) { - if (namesToPlugins[pluginName$jscomp$inline_234]) + if (namesToPlugins[pluginName$jscomp$inline_235]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_234 + "`.") + (pluginName$jscomp$inline_235 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_234 - ] = pluginModule$jscomp$inline_235; - isOrderingDirty$jscomp$inline_233 = !0; + pluginName$jscomp$inline_235 + ] = pluginModule$jscomp$inline_236; + isOrderingDirty$jscomp$inline_234 = !0; } } -isOrderingDirty$jscomp$inline_233 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_234 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -3974,7 +3974,7 @@ function startTransition(setPending, callback) { 0 !== previousPriority && 4 > previousPriority ? previousPriority : 4; setPending(!0); var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setPending(!1), callback(); } finally { @@ -4164,7 +4164,7 @@ var ContextOnlyDispatcher = { mountEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -4248,7 +4248,7 @@ var ContextOnlyDispatcher = { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -4291,7 +4291,7 @@ var ContextOnlyDispatcher = { updateEffect( function() { var prevTransition = ReactCurrentBatchConfig$1.transition; - ReactCurrentBatchConfig$1.transition = 1; + ReactCurrentBatchConfig$1.transition = {}; try { setValue(value); } finally { @@ -5789,27 +5789,29 @@ function attemptEarlyBailoutIfNoScheduledUpdate( } return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } -function unwindWork(workInProgress) { +function unwindWork(current, workInProgress) { popTreeContext(workInProgress); switch (workInProgress.tag) { case 1: - isContextProvider(workInProgress.type) && popContext(); - var flags = workInProgress.flags; - return flags & 65536 - ? ((workInProgress.flags = (flags & -65537) | 128), - 0 !== (workInProgress.mode & 2) && - transferActualDuration(workInProgress), - workInProgress) - : null; + return ( + isContextProvider(workInProgress.type) && popContext(), + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), + 0 !== (workInProgress.mode & 2) && + transferActualDuration(workInProgress), + workInProgress) + : null + ); case 3: return ( popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), resetWorkInProgressVersions(), - (flags = workInProgress.flags), - 0 !== (flags & 65536) && 0 === (flags & 128) - ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + (current = workInProgress.flags), + 0 !== (current & 65536) && 0 === (current & 128) + ? ((workInProgress.flags = (current & -65537) | 128), workInProgress) : null ); case 5: @@ -5817,9 +5819,9 @@ function unwindWork(workInProgress) { case 13: return ( pop(suspenseStackCursor), - (flags = workInProgress.flags), - flags & 65536 - ? ((workInProgress.flags = (flags & -65537) | 128), + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), 0 !== (workInProgress.mode & 2) && transferActualDuration(workInProgress), workInProgress) @@ -6832,7 +6834,7 @@ function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 1; if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; - if (0 !== ReactCurrentBatchConfig.transition) + if (null !== ReactCurrentBatchConfig.transition) return ( 0 === currentEventTransitionLane && ((fiber = nextTransitionLane), @@ -6854,19 +6856,30 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (null === root) return null; markRootUpdated(root, lane, eventTime); - if (0 === (executionContext & 2) || root !== workInProgressRoot) - isDevToolsPresent && addFiberToLanesMap(root, fiber, lane), + if (0 === (executionContext & 2) || root !== workInProgressRoot) { + isDevToolsPresent && addFiberToLanesMap(root, fiber, lane); + if (root.isDehydrated && 0 !== root.tag) { + workInProgressRoot === root && prepareFreshStack(root, 0); + root.isDehydrated = !1; + var onRecoverableError$102 = root.onRecoverableError; + onRecoverableError$102( + Error( + "This root received an early update, before anything was able hydrate. Switched the entire root to client rendering." + ) + ); + } else root === workInProgressRoot && (0 === (executionContext & 2) && (workInProgressRootInterleavedUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && - markRootSuspended$1(root, workInProgressRootRenderLanes)), - ensureRootIsScheduled(root, eventTime), - 1 === lane && - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks()); + markRootSuspended$1(root, workInProgressRootRenderLanes)); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); + } return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -7127,9 +7140,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { : null; } function recoverFromConcurrentError(root, errorRetryLanes) { - var prevExecutionContext = executionContext; - executionContext |= 8; - root.isDehydrated && (root.isDehydrated = !1); + root.isDehydrated && + ((root.isDehydrated = !1), + renderDidError( + Error( + "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering." + ) + )); var errorsFromFirstAttempt = workInProgressRootConcurrentErrors; root = renderRootSync(root, errorRetryLanes); 2 !== root && @@ -7140,7 +7157,6 @@ function recoverFromConcurrentError(root, errorRetryLanes) { workInProgressRootRecoverableErrors, errorsFromFirstAttempt )); - executionContext = prevExecutionContext; return root; } function isRenderConsistentWithExternalStores(finishedWork) { @@ -7427,7 +7443,7 @@ function handleError(root, thrownValue) { } else wakeables.add(wakeable); break a; } else { - if ((thrownValue & 4194240) === thrownValue) { + if (0 === (thrownValue & 1)) { attachPingListener(wakeable, wakeable$jscomp$0, thrownValue); renderDidSuspendDelayIfPossible(); break a; @@ -7438,12 +7454,7 @@ function handleError(root, thrownValue) { ); } } - wakeable = value; - 4 !== workInProgressRootExitStatus && - (workInProgressRootExitStatus = 2); - null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [wakeable]) - : workInProgressRootConcurrentErrors.push(wakeable); + renderDidError(value); value = createCapturedValue(value, sourceFiber); wakeable = returnFiber; do { @@ -7515,6 +7526,12 @@ function renderDidSuspendDelayIfPossible() { 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); } +function renderDidError(error) { + 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); + null === workInProgressRootConcurrentErrors + ? (workInProgressRootConcurrentErrors = [error]) + : workInProgressRootConcurrentErrors.push(error); +} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 2; @@ -7591,7 +7608,7 @@ function completeUnitOfWork(unitOfWork) { return; } } else { - current = unwindWork(completedWork); + current = unwindWork(current, completedWork); if (null !== current) { current.flags &= 32767; workInProgress = current; @@ -7627,7 +7644,7 @@ function commitRoot(root, recoverableErrors) { var previousUpdateLanePriority = currentUpdatePriority, prevTransition = ReactCurrentBatchConfig$2.transition; try { - (ReactCurrentBatchConfig$2.transition = 0), + (ReactCurrentBatchConfig$2.transition = null), (currentUpdatePriority = 1), commitRootImpl(root, recoverableErrors, previousUpdateLanePriority); } finally { @@ -7671,7 +7688,7 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { remainingLanes = 0 !== (finishedWork.flags & 15990); if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) { remainingLanes = ReactCurrentBatchConfig$2.transition; - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; var previousPriority = currentUpdatePriority; currentUpdatePriority = 1; var prevExecutionContext = executionContext; @@ -7734,7 +7751,7 @@ function flushPassiveEffects() { prevTransition = ReactCurrentBatchConfig$2.transition, previousPriority = currentUpdatePriority; try { - ReactCurrentBatchConfig$2.transition = 0; + ReactCurrentBatchConfig$2.transition = null; currentUpdatePriority = 16 > renderPriority ? 16 : renderPriority; if (null === rootWithPendingPassiveEffects) var JSCompiler_inline_result = !1; @@ -7961,11 +7978,7 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { if (3 === sourceFiber.tag) captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); else - for ( - nearestMountedAncestor = sourceFiber.return; - null !== nearestMountedAncestor; - - ) { + for (; null !== nearestMountedAncestor; ) { if (3 === nearestMountedAncestor.tag) { captureCommitPhaseErrorOnRoot( nearestMountedAncestor, @@ -8922,10 +8935,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1046 = { + devToolsConfig$jscomp$inline_1048 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-rc.0-27b569969-20220211", + version: "18.0.0-rc.0-4de99b3ca-20220221", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8954,10 +8967,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1046.bundleType, - version: devToolsConfig$jscomp$inline_1046.version, - rendererPackageName: devToolsConfig$jscomp$inline_1046.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1046.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1048.bundleType, + version: devToolsConfig$jscomp$inline_1048.version, + rendererPackageName: devToolsConfig$jscomp$inline_1048.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1048.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8973,14 +8986,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1046.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1048.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-rc.0-27b569969-20220211" + reconcilerVersion: "18.0.0-rc.0-4de99b3ca-20220221" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function(reactTag) {