From 203bcf3249dbb8aac55fa410e00cfda2dd9165c2 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Thu, 17 Feb 2022 12:54:15 -0800 Subject: [PATCH] React Native sync for revisions a3bde79...27b5699 Summary: This sync includes the following changes: - **[27b569969](https://github.com/facebook/react/commit/27b569969 )**: Simplify cache pool contexts ([#23280](https://github.com/facebook/react/pull/23280)) //// - **[1fb0d0687](https://github.com/facebook/react/commit/1fb0d0687 )**: [Devtools][Transition Tracing] Add Transition callbacks to createRoot ([#23276](https://github.com/facebook/react/pull/23276)) //// - **[a6987bee7](https://github.com/facebook/react/commit/a6987bee7 )**: add component boilerplate ([#23275](https://github.com/facebook/react/pull/23275)) //// - **[796fff548](https://github.com/facebook/react/commit/796fff548 )**: Allow suspending outside a Suspense boundary ([#23267](https://github.com/facebook/react/pull/23267)) //// - **[64223fed8](https://github.com/facebook/react/commit/64223fed8 )**: Fix: Multiple hydration errors in same render ([#23273](https://github.com/facebook/react/pull/23273)) //// - **[efd8f6442](https://github.com/facebook/react/commit/efd8f6442 )**: Resolve default onRecoverableError at root init ([#23264](https://github.com/facebook/react/pull/23264)) //// - **[e0af1aabe](https://github.com/facebook/react/commit/e0af1aabe )**: Fix wrong context argument to `apply` //// - **[9b5e0517b](https://github.com/facebook/react/commit/9b5e0517b )**: Remove deprecated wildcard folder mapping ([#23256](https://github.com/facebook/react/pull/23256)) //// - **[274b9fb16](https://github.com/facebook/react/commit/274b9fb16 )**: Remove path resolution from internal forks plugin ([#23255](https://github.com/facebook/react/pull/23255)) //// Changelog: [General][Changed] - React Native sync for revisions a3bde79...27b5699 jest_e2e[run_all_tests] Reviewed By: rickhanlonii, kacieb Differential Revision: D34241986 fbshipit-source-id: f6ab62df2a918728864283b4f13201275eb3b8a3 --- Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 269 +++++++----- .../implementations/ReactFabric-prod.fb.js | 415 +++++++++--------- .../ReactFabric-profiling.fb.js | 402 +++++++++-------- .../ReactNativeRenderer-dev.fb.js | 269 +++++++----- .../ReactNativeRenderer-prod.fb.js | 409 ++++++++--------- .../ReactNativeRenderer-profiling.fb.js | 396 +++++++++-------- 7 files changed, 1181 insertions(+), 981 deletions(-) diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 17b725fb854b51..83b660c94c4507 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -a3bde7974c48cfa749b18531700f895c86cbad91 \ No newline at end of file +27b5699694f20220e0448f0ba3eb6bfa0d3a64ed \ 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 d8d4d08befc8f2..51fcc464687edf 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<<5cd13a68c6b2a6d7a0ea84aff011af30>> + * @generated SignedSource<> */ 'use strict'; @@ -1281,6 +1281,7 @@ var ScopeComponent = 21; var OffscreenComponent = 22; var LegacyHiddenComponent = 23; var CacheComponent = 24; +var TracingMarkerComponent = 25; /** * Instance of element that should respond to touch/move types of interactions, @@ -2614,6 +2615,7 @@ var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; var REACT_OFFSCREEN_TYPE = 0xeae2; var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; var REACT_CACHE_TYPE = 0xeae4; +var REACT_TRACING_MARKER_TYPE = 0xeae5; if (typeof Symbol === "function" && Symbol.for) { var symbolFor = Symbol.for; @@ -2634,6 +2636,7 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); REACT_CACHE_TYPE = symbolFor("react.cache"); + REACT_TRACING_MARKER_TYPE = symbolFor("react.tracing_marker"); } var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; @@ -2715,6 +2718,9 @@ function getComponentNameFromType(type) { case REACT_CACHE_TYPE: return "Cache"; + + case REACT_TRACING_MARKER_TYPE: + return "TracingMarker"; } if (typeof type === "object") { @@ -2835,6 +2841,9 @@ function getComponentNameFromFiber(fiber) { case SuspenseListComponent: return "SuspenseList"; + + case TracingMarkerComponent: + return "TracingMarker"; // The display name for this tags come from the user-provided type: case ClassComponent: @@ -10545,7 +10554,7 @@ function warnAboutMultipleRenderersDEV(mutableSource) { function getSuspendedCachePool() { { return null; - } // We check the cache on the stack first, since that's the one any new Caches + } // This function is called when a Suspense boundary suspends. It returns the } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -13616,7 +13625,7 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { return update; } -function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { +function attachPingListener(root, wakeable, lanes) { // Attach a ping listener // // The data might resolve before we have a chance to commit the fallback. Or, @@ -13629,38 +13638,40 @@ function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { // // We only need to do this in concurrent mode. Legacy Suspense always // commits fallbacks synchronously, so there are no pings. - if (suspenseBoundary.mode & ConcurrentMode) { - var pingCache = root.pingCache; - var threadIDs; + var pingCache = root.pingCache; + var threadIDs; + + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap$1(); + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } else { + threadIDs = pingCache.get(wakeable); - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap$1(); + if (threadIDs === undefined) { threadIDs = new Set(); pingCache.set(wakeable, threadIDs); - } else { - threadIDs = pingCache.get(wakeable); - - if (threadIDs === undefined) { - threadIDs = new Set(); - pingCache.set(wakeable, threadIDs); - } } + } - if (!threadIDs.has(lanes)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(lanes); - var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); + if (!threadIDs.has(lanes)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(lanes); + var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); - { - if (isDevToolsPresent) { - // If we have pending work still, restore the original updaters - restorePendingUpdaters(root, lanes); - } + { + if (isDevToolsPresent) { + // If we have pending work still, restore the original updaters + restorePendingUpdaters(root, lanes); } - - wakeable.then(ping, ping); } - } // Retry listener + + wakeable.then(ping, ping); + } +} + +function attachRetryListener(suspenseBoundary, root, wakeable, lanes) { + // Retry listener // // If the fallback does commit, we need to attach a different type of // listener. This one schedules an update on the Suspense boundary to turn @@ -13671,7 +13682,6 @@ function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { // // When the wakeable resolves, we'll attempt to render the boundary // again ("retry"). - var wakeables = suspenseBoundary.updateQueue; if (wakeables === null) { @@ -13889,25 +13899,45 @@ function throwException( sourceFiber, root, rootRenderLanes - ); - attachWakeableListeners( - suspenseBoundary, - root, - wakeable, - rootRenderLanes - ); + ); // We only attach ping listeners in concurrent mode. Legacy Suspense always + // commits fallbacks synchronously, so there are no pings. + + if (suspenseBoundary.mode & ConcurrentMode) { + attachPingListener(root, wakeable, rootRenderLanes); + } + + attachRetryListener(suspenseBoundary, root, wakeable); return; } else { - // No boundary was found. Fallthrough to error mode. + // No boundary was found. If we're inside startTransition, 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.) + 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? // TODO: We should never call getComponentNameFromFiber in production. // Log a warning or something to prevent us from accidentally bundling it. - value = new Error( + + var uncaughtSuspenseError = new Error( (getComponentNameFromFiber(sourceFiber) || "A React component") + " suspended while rendering, but no fallback UI was specified.\n" + "\n" + "Add a component higher in the tree to " + "provide a loading indicator or placeholder to display." - ); + ); // If we're outside a transition, fall through to the regular error path. + // The error will be caught by the nearest suspense boundary. + + value = uncaughtSuspenseError; } } // We didn't find a boundary that could handle this type of exception. Start // over and traverse parent path again, this time treating the exception @@ -18085,15 +18115,17 @@ function unwindWork(workInProgress, renderLanes) { resetWorkInProgressVersions(); var _flags = workInProgress.flags; - if ((_flags & DidCapture) !== NoFlags) { - throw new Error( - "The root failed to unmount after an error. This is likely a bug in " + - "React. Please file an issue." - ); - } + if ( + (_flags & ShouldCapture) !== NoFlags && + (_flags & DidCapture) === NoFlags + ) { + // There was an error during render that wasn't captured by a suspense + // boundary. Do a second pass on the root to unmount the children. + workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture; + return workInProgress; + } // We unwound to the root without completing it. Exit. - workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture; - return workInProgress; + return null; } case HostComponent: { @@ -20098,12 +20130,13 @@ var CommitContext = var RetryAfterError = /* */ 8; -var RootIncomplete = 0; +var RootInProgress = 0; var RootFatalErrored = 1; var RootErrored = 2; var RootSuspended = 3; var RootSuspendedWithDelay = 4; -var RootCompleted = 5; // Describes where we are in the React execution stack +var RootCompleted = 5; +var RootDidNotComplete = 6; // Describes where we are in the React execution stack var executionContext = NoContext; // The root we're working on @@ -20123,7 +20156,7 @@ var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to var subtreeRenderLanes = NoLanes; var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc. -var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown +var workInProgressRootExitStatus = RootInProgress; // A fatal error, if one is thrown var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's // slightly different than `renderLanes` because `renderLanes` can change as you @@ -20580,7 +20613,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ? renderRootConcurrent(root, lanes) : renderRootSync(root, lanes); - if (exitStatus !== RootIncomplete) { + if (exitStatus !== RootInProgress) { if (exitStatus === RootErrored) { // If something threw an error, try rendering one more time. We'll // render synchronously to block concurrent data mutations, and we'll @@ -20600,46 +20633,59 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes); ensureRootIsScheduled(root, now()); throw fatalError; - } // Check if this render may have yielded to a concurrent event, and if so, - // confirm that any newly rendered stores are consistent. - // TODO: It's possible that even a concurrent render may never have yielded - // to the main thread, if it was fast enough, or if it expired. We could - // skip the consistency check in that case, too. + } - var renderWasConcurrent = !includesBlockingLane(root, lanes); - var finishedWork = root.current.alternate; + if (exitStatus === RootDidNotComplete) { + // The render unwound without completing the tree. This happens in special + // cases where need to exit the current render without producing a + // consistent tree or committing. + // + // This should only happen during a concurrent render, not a discrete or + // synchronous update. We should have already checked for this when we + // unwound the stack. + markRootSuspended$1(root, lanes); + } else { + // The render completed. + // Check if this render may have yielded to a concurrent event, and if so, + // confirm that any newly rendered stores are consistent. + // TODO: It's possible that even a concurrent render may never have yielded + // to the main thread, if it was fast enough, or if it expired. We could + // skip the consistency check in that case, too. + var renderWasConcurrent = !includesBlockingLane(root, lanes); + var finishedWork = root.current.alternate; - if ( - renderWasConcurrent && - !isRenderConsistentWithExternalStores(finishedWork) - ) { - // A store was mutated in an interleaved event. Render again, - // synchronously, to block further mutations. - exitStatus = renderRootSync(root, lanes); // We need to check again if something threw + if ( + renderWasConcurrent && + !isRenderConsistentWithExternalStores(finishedWork) + ) { + // A store was mutated in an interleaved event. Render again, + // synchronously, to block further mutations. + exitStatus = renderRootSync(root, lanes); // We need to check again if something threw - if (exitStatus === RootErrored) { - var _errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); + if (exitStatus === RootErrored) { + var _errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); - if (_errorRetryLanes !== NoLanes) { - lanes = _errorRetryLanes; - exitStatus = recoverFromConcurrentError(root, _errorRetryLanes); // We assume the tree is now consistent because we didn't yield to any - // concurrent events. + if (_errorRetryLanes !== NoLanes) { + lanes = _errorRetryLanes; + exitStatus = recoverFromConcurrentError(root, _errorRetryLanes); // We assume the tree is now consistent because we didn't yield to any + // concurrent events. + } } - } - if (exitStatus === RootFatalErrored) { - var _fatalError = workInProgressRootFatalError; - prepareFreshStack(root, NoLanes); - markRootSuspended$1(root, lanes); - ensureRootIsScheduled(root, now()); - throw _fatalError; - } - } // We now have a consistent tree. The next step is either to commit it, - // or, if something suspended, wait to commit it after a timeout. + if (exitStatus === RootFatalErrored) { + var _fatalError = workInProgressRootFatalError; + prepareFreshStack(root, NoLanes); + markRootSuspended$1(root, lanes); + ensureRootIsScheduled(root, now()); + throw _fatalError; + } + } // We now have a consistent tree. The next step is either to commit it, + // or, if something suspended, wait to commit it after a timeout. - root.finishedWork = finishedWork; - root.finishedLanes = lanes; - finishConcurrentRender(root, exitStatus, lanes); + root.finishedWork = finishedWork; + root.finishedLanes = lanes; + finishConcurrentRender(root, exitStatus, lanes); + } } ensureRootIsScheduled(root, now()); @@ -20684,11 +20730,11 @@ function recoverFromConcurrentError(root, errorRetryLanes) { } function queueRecoverableErrors(errors) { - if (workInProgressRootConcurrentErrors === null) { + if (workInProgressRootRecoverableErrors === null) { workInProgressRootRecoverableErrors = errors; } else { - workInProgressRootConcurrentErrors = workInProgressRootConcurrentErrors.push.apply( - null, + workInProgressRootRecoverableErrors.push.apply( + workInProgressRootRecoverableErrors, errors ); } @@ -20696,7 +20742,7 @@ function queueRecoverableErrors(errors) { function finishConcurrentRender(root, exitStatus, lanes) { switch (exitStatus) { - case RootIncomplete: + case RootInProgress: case RootFatalErrored: { throw new Error("Root did not complete. This is a bug in React."); } @@ -20923,6 +20969,10 @@ function performSyncWorkOnRoot(root) { markRootSuspended$1(root, lanes); ensureRootIsScheduled(root, now()); throw fatalError; + } + + if (exitStatus === RootDidNotComplete) { + throw new Error("Root did not complete. This is a bug in React."); } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -21032,7 +21082,7 @@ function prepareFreshStack(root, lanes) { workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; - workInProgressRootExitStatus = RootIncomplete; + workInProgressRootExitStatus = RootInProgress; workInProgressRootFatalError = null; workInProgressRootSkippedLanes = NoLanes; workInProgressRootInterleavedUpdatedLanes = NoLanes; @@ -21162,13 +21212,13 @@ function markSkippedUpdateLanes(lane) { ); } function renderDidSuspend() { - if (workInProgressRootExitStatus === RootIncomplete) { + if (workInProgressRootExitStatus === RootInProgress) { workInProgressRootExitStatus = RootSuspended; } } function renderDidSuspendDelayIfPossible() { if ( - workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootInProgress || workInProgressRootExitStatus === RootSuspended || workInProgressRootExitStatus === RootErrored ) { @@ -21207,7 +21257,7 @@ function renderDidError(error) { function renderHasNotSuspendedYet() { // If something errored or completed, we can't really be sure, // so those are false. - return workInProgressRootExitStatus === RootIncomplete; + return workInProgressRootExitStatus === RootInProgress; } function renderRootSync(root, lanes) { @@ -21329,7 +21379,7 @@ function renderRootConcurrent(root, lanes) { markRenderYielded(); } - return RootIncomplete; + return RootInProgress; } else { // Completed the tree. { @@ -21448,6 +21498,11 @@ function completeUnitOfWork(unitOfWork) { returnFiber.flags |= Incomplete; returnFiber.subtreeFlags = NoFlags; returnFiber.deletions = null; + } else { + // We've unwound all the way to the root. + workInProgressRootExitStatus = RootDidNotComplete; + workInProgress = null; + return; } } @@ -21464,7 +21519,7 @@ function completeUnitOfWork(unitOfWork) { workInProgress = completedWork; } while (completedWork !== null); // We've reached the root. - if (workInProgressRootExitStatus === RootIncomplete) { + if (workInProgressRootExitStatus === RootInProgress) { workInProgressRootExitStatus = RootCompleted; } } @@ -21695,13 +21750,11 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without // needing to surface it to the UI. We log them here. + var onRecoverableError = root.onRecoverableError; + for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; - var onRecoverableError = root.onRecoverableError; - - if (onRecoverableError !== null) { - onRecoverableError(recoverableError); - } + onRecoverableError(recoverableError); } } @@ -23302,6 +23355,10 @@ function createFiberFromTypeAndProps( // eslint-disable-next-line no-fallthrough + case REACT_TRACING_MARKER_TYPE: + + // eslint-disable-next-line no-fallthrough + default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -23602,7 +23659,8 @@ function createFiberRoot( // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, - onRecoverableError + onRecoverableError, + transitionCallbacks ) { var root = new FiberRootNode( containerInfo, @@ -23632,7 +23690,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.0.0-rc.0-a3bde7974-20220208"; +var ReactVersion = "18.0.0-rc.0-27b569969-20220211"; function createPortal( children, @@ -23761,7 +23819,8 @@ function createContainer( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, - onRecoverableError + onRecoverableError, + transitionCallbacks ) { return createFiberRoot( containerInfo, @@ -24553,6 +24612,12 @@ function sendAccessibilityEvent(handle, eventType) { } } +function onRecoverableError(error$1) { + // TODO: Expose onRecoverableError option to userspace + // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args + error(error$1); +} + function render(element, containerTag, callback, concurrentRoot) { var root = roots.get(containerTag); @@ -24567,7 +24632,7 @@ function render(element, containerTag, callback, concurrentRoot) { false, null, "", - null + onRecoverableError ); roots.set(containerTag, root); } diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 5014f1e088bef9..f057093a044dbc 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<<97d9d60e7b93063137af17ba2abdf915>> + * @generated SignedSource<> */ "use strict"; @@ -927,7 +927,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_219 = { +var injectedNamesToPlugins$jscomp$inline_220 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -962,33 +962,33 @@ var injectedNamesToPlugins$jscomp$inline_219 = { } } }, - isOrderingDirty$jscomp$inline_220 = !1, - pluginName$jscomp$inline_221; -for (pluginName$jscomp$inline_221 in injectedNamesToPlugins$jscomp$inline_219) + isOrderingDirty$jscomp$inline_221 = !1, + pluginName$jscomp$inline_222; +for (pluginName$jscomp$inline_222 in injectedNamesToPlugins$jscomp$inline_220) if ( - injectedNamesToPlugins$jscomp$inline_219.hasOwnProperty( - pluginName$jscomp$inline_221 + injectedNamesToPlugins$jscomp$inline_220.hasOwnProperty( + pluginName$jscomp$inline_222 ) ) { - var pluginModule$jscomp$inline_222 = - injectedNamesToPlugins$jscomp$inline_219[pluginName$jscomp$inline_221]; + var pluginModule$jscomp$inline_223 = + injectedNamesToPlugins$jscomp$inline_220[pluginName$jscomp$inline_222]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_221) || - namesToPlugins[pluginName$jscomp$inline_221] !== - pluginModule$jscomp$inline_222 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_222) || + namesToPlugins[pluginName$jscomp$inline_222] !== + pluginModule$jscomp$inline_223 ) { - if (namesToPlugins[pluginName$jscomp$inline_221]) + if (namesToPlugins[pluginName$jscomp$inline_222]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_221 + "`.") + (pluginName$jscomp$inline_222 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_221 - ] = pluginModule$jscomp$inline_222; - isOrderingDirty$jscomp$inline_220 = !0; + pluginName$jscomp$inline_222 + ] = pluginModule$jscomp$inline_223; + isOrderingDirty$jscomp$inline_221 = !0; } } -isOrderingDirty$jscomp$inline_220 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_221 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1043,7 +1043,8 @@ var ReactSharedInternals = REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131, - REACT_CACHE_TYPE = 60132; + REACT_CACHE_TYPE = 60132, + REACT_TRACING_MARKER_TYPE = 60133; if ("function" === typeof Symbol && Symbol.for) { var symbolFor = Symbol.for; REACT_ELEMENT_TYPE = symbolFor("react.element"); @@ -1063,6 +1064,7 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); REACT_CACHE_TYPE = symbolFor("react.cache"); + REACT_TRACING_MARKER_TYPE = symbolFor("react.tracing_marker"); } var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { @@ -1091,6 +1093,8 @@ function getComponentNameFromType(type) { return "SuspenseList"; case REACT_CACHE_TYPE: return "Cache"; + case REACT_TRACING_MARKER_TYPE: + return "TracingMarker"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -1165,6 +1169,8 @@ function getComponentNameFromFiber(fiber) { return "Suspense"; case 19: return "SuspenseList"; + case 25: + return "TracingMarker"; case 1: case 0: case 17: @@ -4271,6 +4277,21 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { }); return lane; } +function attachPingListener(root, wakeable, lanes) { + var pingCache = root.pingCache; + if (null === pingCache) { + pingCache = root.pingCache = new PossiblyWeakMap(); + var threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } else + (threadIDs = pingCache.get(wakeable)), + void 0 === threadIDs && + ((threadIDs = new Set()), pingCache.set(wakeable, threadIDs)); + threadIDs.has(lanes) || + (threadIDs.add(lanes), + (root = pingSuspendedRoot.bind(null, root, wakeable, lanes)), + wakeable.then(root, root)); +} function hadNoMutationsEffects(current, completedWork) { if (null !== current && current.child === completedWork.child) return !0; if (0 !== (completedWork.flags & 16)) return !1; @@ -4603,29 +4624,14 @@ function completeWork(current, workInProgress, renderLanes) { return (workInProgress.lanes = renderLanes), workInProgress; renderLanes = !1; null !== current && (renderLanes = null !== current.memoizedState); - if ( - null !== newProps && - !renderLanes && - ((workInProgress.child.flags |= 8192), 0 !== (workInProgress.mode & 1)) - ) - if (null === current || 0 !== (suspenseStackCursor.current & 1)) - 0 === workInProgressRootExitStatus && - (workInProgressRootExitStatus = 3); - else { - if ( - 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus || - 2 === workInProgressRootExitStatus - ) - workInProgressRootExitStatus = 4; - null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || - markRootSuspended$1( - workInProgressRoot, - workInProgressRootRenderLanes - ); - } + null === newProps || + renderLanes || + ((workInProgress.child.flags |= 8192), + 0 !== (workInProgress.mode & 1) && + (null === current || 0 !== (suspenseStackCursor.current & 1) + ? 0 === workInProgressRootExitStatus && + (workInProgressRootExitStatus = 3) + : renderDidSuspendDelayIfPossible())); null !== workInProgress.updateQueue && (workInProgress.flags |= 4); bubbleProperties(workInProgress); return null; @@ -5748,17 +5754,16 @@ function unwindWork(workInProgress) { ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) : null; case 3: - popHostContainer(); - pop(didPerformWorkStackCursor); - pop(contextStackCursor); - resetWorkInProgressVersions(); - flags = workInProgress.flags; - if (0 !== (flags & 128)) - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ); - workInProgress.flags = (flags & -65537) | 128; - return workInProgress; + return ( + popHostContainer(), + pop(didPerformWorkStackCursor), + pop(contextStackCursor), + resetWorkInProgressVersions(), + (flags = workInProgress.flags), + 0 !== (flags & 65536) && 0 === (flags & 128) + ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + : null + ); case 5: return popHostContext(workInProgress), null; case 13: @@ -6454,96 +6459,99 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes), ensureRootIsScheduled(root, now()), originalCallbackNode); - prevDispatcher = !includesBlockingLane(root, lanes); - prevExecutionContext = root.current.alternate; - if ( - prevDispatcher && - !isRenderConsistentWithExternalStores(prevExecutionContext) && - ((didTimeout = renderRootSync(root, lanes)), - 2 === didTimeout && - ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), - 0 !== prevDispatcher && - ((lanes = prevDispatcher), - (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))), - 1 === didTimeout) - ) - throw ((originalCallbackNode = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), - originalCallbackNode); - root.finishedWork = prevExecutionContext; - root.finishedLanes = lanes; - switch (didTimeout) { - case 0: - case 1: - throw Error("Root did not complete. This is a bug in React."); - case 2: - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 3: - markRootSuspended$1(root, lanes); - if ( - (lanes & 130023424) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) - ) { - if (0 !== getNextLanes(root, 0)) break; - prevExecutionContext = root.suspendedLanes; - if ((prevExecutionContext & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + if (6 === didTimeout) markRootSuspended$1(root, lanes); + else { + prevDispatcher = !includesBlockingLane(root, lanes); + prevExecutionContext = root.current.alternate; + if ( + prevDispatcher && + !isRenderConsistentWithExternalStores(prevExecutionContext) && + ((didTimeout = renderRootSync(root, lanes)), + 2 === didTimeout && + ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), + 0 !== prevDispatcher && + ((lanes = prevDispatcher), + (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))), + 1 === didTimeout) + ) + throw ((originalCallbackNode = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), + originalCallbackNode); + root.finishedWork = prevExecutionContext; + root.finishedLanes = lanes; + switch (didTimeout) { + case 0: + case 1: + throw Error("Root did not complete. This is a bug in React."); + case 2: + commitRoot(root, workInProgressRootRecoverableErrors); + break; + case 3: + markRootSuspended$1(root, lanes); + if ( + (lanes & 130023424) === lanes && + ((didTimeout = globalMostRecentFallbackTime + 500 - now()), + 10 < didTimeout) + ) { + if (0 !== getNextLanes(root, 0)) break; + prevExecutionContext = root.suspendedLanes; + if ((prevExecutionContext & lanes) !== lanes) { + requestEventTime(); + root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + break; + } + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, workInProgressRootRecoverableErrors), + didTimeout + ); break; } - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root, workInProgressRootRecoverableErrors), - didTimeout - ); + commitRoot(root, workInProgressRootRecoverableErrors); break; - } - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 4: - markRootSuspended$1(root, lanes); - if ((lanes & 4194240) === lanes) break; - didTimeout = root.eventTimes; - for (prevExecutionContext = -1; 0 < lanes; ) { - var index$4 = 31 - clz32(lanes); - prevDispatcher = 1 << index$4; - index$4 = didTimeout[index$4]; - index$4 > prevExecutionContext && (prevExecutionContext = index$4); - lanes &= ~prevDispatcher; - } - lanes = prevExecutionContext; - lanes = now() - lanes; - lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes; - if (10 < lanes) { - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root, workInProgressRootRecoverableErrors), - lanes - ); + case 4: + markRootSuspended$1(root, lanes); + if ((lanes & 4194240) === lanes) break; + didTimeout = root.eventTimes; + for (prevExecutionContext = -1; 0 < lanes; ) { + var index$4 = 31 - clz32(lanes); + prevDispatcher = 1 << index$4; + index$4 = didTimeout[index$4]; + index$4 > prevExecutionContext && (prevExecutionContext = index$4); + lanes &= ~prevDispatcher; + } + lanes = prevExecutionContext; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; + if (10 < lanes) { + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, workInProgressRootRecoverableErrors), + lanes + ); + break; + } + commitRoot(root, workInProgressRootRecoverableErrors); break; - } - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 5: - commitRoot(root, workInProgressRootRecoverableErrors); - break; - default: - throw Error("Unknown root exit status."); + case 5: + commitRoot(root, workInProgressRootRecoverableErrors); + break; + default: + throw Error("Unknown root exit status."); + } } } ensureRootIsScheduled(root, now()); @@ -6559,12 +6567,12 @@ function recoverFromConcurrentError(root, errorRetryLanes) { root = renderRootSync(root, errorRetryLanes); 2 !== root && null !== errorsFromFirstAttempt && - (null === workInProgressRootConcurrentErrors + (null === workInProgressRootRecoverableErrors ? (workInProgressRootRecoverableErrors = errorsFromFirstAttempt) - : (workInProgressRootConcurrentErrors = workInProgressRootConcurrentErrors.push.apply( - null, + : workInProgressRootRecoverableErrors.push.apply( + workInProgressRootRecoverableErrors, errorsFromFirstAttempt - ))); + )); executionContext = prevExecutionContext; return root; } @@ -6633,6 +6641,8 @@ function performSyncWorkOnRoot(root) { markRootSuspended$1(root, lanes), ensureRootIsScheduled(root, now()), exitStatus); + if (6 === exitStatus) + throw Error("Root did not complete. This is a bug in React."); root.finishedWork = root.current.alternate; root.finishedLanes = lanes; commitRoot(root, workInProgressRootRecoverableErrors); @@ -6825,41 +6835,28 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber.lanes |= 1; } else (value.flags |= 65536), (value.lanes = sourceFiber$jscomp$0); - sourceFiber = void 0; - value = suspenseBoundary; - if (value.mode & 1) { - var pingCache = root.pingCache; - null === pingCache - ? ((pingCache = root.pingCache = new PossiblyWeakMap()), - (sourceFiber = new Set()), - pingCache.set(wakeable, sourceFiber)) - : ((sourceFiber = pingCache.get(wakeable)), - void 0 === sourceFiber && - ((sourceFiber = new Set()), - pingCache.set(wakeable, sourceFiber))); - if (!sourceFiber.has(thrownValue)) { - sourceFiber.add(thrownValue); - var ping = pingSuspendedRoot.bind( - null, - root, - wakeable, - thrownValue - ); - wakeable.then(ping, ping); - } - } - var wakeables = value.updateQueue; + suspenseBoundary.mode & 1 && + attachPingListener(root, wakeable, thrownValue); + thrownValue = suspenseBoundary; + root = wakeable; + var wakeables = thrownValue.updateQueue; if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(wakeable); - value.updateQueue = updateQueue; - } else wakeables.add(wakeable); + updateQueue.add(root); + thrownValue.updateQueue = updateQueue; + } else wakeables.add(root); break a; - } else + } else { + if ((thrownValue & 4194240) === thrownValue) { + attachPingListener(root, wakeable, thrownValue); + renderDidSuspendDelayIfPossible(); + break a; + } value = Error( (getComponentNameFromFiber(sourceFiber) || "A React component") + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." ); + } } root = value; 4 !== workInProgressRootExitStatus && @@ -6926,6 +6923,18 @@ function pushDispatcher() { ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } +function renderDidSuspendDelayIfPossible() { + if ( + 0 === workInProgressRootExitStatus || + 3 === workInProgressRootExitStatus || + 2 === workInProgressRootExitStatus + ) + workInProgressRootExitStatus = 4; + null === workInProgressRoot || + (0 === (workInProgressRootSkippedLanes & 268435455) && + 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || + markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); +} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 2; @@ -6984,10 +6993,15 @@ function completeUnitOfWork(unitOfWork) { workInProgress = current; return; } - null !== unitOfWork && - ((unitOfWork.flags |= 32768), - (unitOfWork.subtreeFlags = 0), - (unitOfWork.deletions = null)); + if (null !== unitOfWork) + (unitOfWork.flags |= 32768), + (unitOfWork.subtreeFlags = 0), + (unitOfWork.deletions = null); + else { + workInProgressRootExitStatus = 6; + workInProgress = null; + return; + } } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -7068,13 +7082,11 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { ensureRootIsScheduled(root, now()); if (null !== recoverableErrors) for ( - renderPriorityLevel = 0; - renderPriorityLevel < recoverableErrors.length; - renderPriorityLevel++ + renderPriorityLevel = root.onRecoverableError, finishedWork = 0; + finishedWork < recoverableErrors.length; + finishedWork++ ) - (finishedWork = recoverableErrors[renderPriorityLevel]), - (lanes = root.onRecoverableError), - null !== lanes && lanes(finishedWork); + renderPriorityLevel(recoverableErrors[finishedWork]); if (hasUncaughtError) throw ((hasUncaughtError = !1), (root = firstUncaughtError), @@ -8167,6 +8179,9 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle.canonical._nativeTag : componentOrHandle._nativeTag; } +function onRecoverableError(error) { + console.error(error); +} batchedUpdatesImpl = function(fn, a) { var prevExecutionContext = executionContext; executionContext |= 1; @@ -8180,10 +8195,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_927 = { + devToolsConfig$jscomp$inline_928 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-rc.0-a3bde7974-20220208", + version: "18.0.0-rc.0-27b569969-20220211", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8198,11 +8213,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1181 = { - bundleType: devToolsConfig$jscomp$inline_927.bundleType, - version: devToolsConfig$jscomp$inline_927.version, - rendererPackageName: devToolsConfig$jscomp$inline_927.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_927.rendererConfig, +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, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8218,26 +8233,26 @@ var internals$jscomp$inline_1181 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_927.findFiberByHostInstance || + devToolsConfig$jscomp$inline_928.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-rc.0-a3bde7974-20220208" + reconcilerVersion: "18.0.0-rc.0-27b569969-20220211" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1182 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1179 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1182.isDisabled && - hook$jscomp$inline_1182.supportsFiber + !hook$jscomp$inline_1179.isDisabled && + hook$jscomp$inline_1179.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1182.inject( - internals$jscomp$inline_1181 + (rendererID = hook$jscomp$inline_1179.inject( + internals$jscomp$inline_1178 )), - (injectedHook = hook$jscomp$inline_1182); + (injectedHook = hook$jscomp$inline_1179); } catch (err) {} } exports.createPortal = function(children, containerTag) { @@ -8277,7 +8292,13 @@ exports.render = function(element, containerTag, callback, concurrentRoot) { var root = roots.get(containerTag); root || ((root = concurrentRoot ? 1 : 0), - (concurrentRoot = new FiberRootNode(containerTag, root, !1, "", null)), + (concurrentRoot = new FiberRootNode( + containerTag, + root, + !1, + "", + onRecoverableError + )), (root = createFiber(3, null, null, 1 === root ? 1 : 0)), (concurrentRoot.current = root), (root.stateNode = concurrentRoot), diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 6df38b40d95fd3..3f8d9541bb390a 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<<5c079c38f5734a3f694bc72a4da400d4>> + * @generated SignedSource<> */ @@ -938,7 +938,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_228 = { +var injectedNamesToPlugins$jscomp$inline_229 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -973,33 +973,33 @@ var injectedNamesToPlugins$jscomp$inline_228 = { } } }, - isOrderingDirty$jscomp$inline_229 = !1, - pluginName$jscomp$inline_230; -for (pluginName$jscomp$inline_230 in injectedNamesToPlugins$jscomp$inline_228) + isOrderingDirty$jscomp$inline_230 = !1, + pluginName$jscomp$inline_231; +for (pluginName$jscomp$inline_231 in injectedNamesToPlugins$jscomp$inline_229) if ( - injectedNamesToPlugins$jscomp$inline_228.hasOwnProperty( - pluginName$jscomp$inline_230 + injectedNamesToPlugins$jscomp$inline_229.hasOwnProperty( + pluginName$jscomp$inline_231 ) ) { - var pluginModule$jscomp$inline_231 = - injectedNamesToPlugins$jscomp$inline_228[pluginName$jscomp$inline_230]; + var pluginModule$jscomp$inline_232 = + injectedNamesToPlugins$jscomp$inline_229[pluginName$jscomp$inline_231]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_230) || - namesToPlugins[pluginName$jscomp$inline_230] !== - pluginModule$jscomp$inline_231 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_231) || + namesToPlugins[pluginName$jscomp$inline_231] !== + pluginModule$jscomp$inline_232 ) { - if (namesToPlugins[pluginName$jscomp$inline_230]) + if (namesToPlugins[pluginName$jscomp$inline_231]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_230 + "`.") + (pluginName$jscomp$inline_231 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_230 - ] = pluginModule$jscomp$inline_231; - isOrderingDirty$jscomp$inline_229 = !0; + pluginName$jscomp$inline_231 + ] = pluginModule$jscomp$inline_232; + isOrderingDirty$jscomp$inline_230 = !0; } } -isOrderingDirty$jscomp$inline_229 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_230 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1054,7 +1054,8 @@ var ReactSharedInternals = REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131, - REACT_CACHE_TYPE = 60132; + REACT_CACHE_TYPE = 60132, + REACT_TRACING_MARKER_TYPE = 60133; if ("function" === typeof Symbol && Symbol.for) { var symbolFor = Symbol.for; REACT_ELEMENT_TYPE = symbolFor("react.element"); @@ -1074,6 +1075,7 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); REACT_CACHE_TYPE = symbolFor("react.cache"); + REACT_TRACING_MARKER_TYPE = symbolFor("react.tracing_marker"); } var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { @@ -1102,6 +1104,8 @@ function getComponentNameFromType(type) { return "SuspenseList"; case REACT_CACHE_TYPE: return "Cache"; + case REACT_TRACING_MARKER_TYPE: + return "TracingMarker"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -1176,6 +1180,8 @@ function getComponentNameFromFiber(fiber) { return "Suspense"; case 19: return "SuspenseList"; + case 25: + return "TracingMarker"; case 1: case 0: case 17: @@ -4463,6 +4469,22 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { }); return lane; } +function attachPingListener(root, wakeable, lanes) { + var pingCache = root.pingCache; + if (null === pingCache) { + pingCache = root.pingCache = new PossiblyWeakMap(); + var threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } else + (threadIDs = pingCache.get(wakeable)), + void 0 === threadIDs && + ((threadIDs = new Set()), pingCache.set(wakeable, threadIDs)); + threadIDs.has(lanes) || + (threadIDs.add(lanes), + (pingCache = pingSuspendedRoot.bind(null, root, wakeable, lanes)), + isDevToolsPresent && restorePendingUpdaters(root, lanes), + wakeable.then(pingCache, pingCache)); +} function hadNoMutationsEffects(current, completedWork) { if (null !== current && current.child === completedWork.child) return !0; if (0 !== (completedWork.flags & 16)) return !1; @@ -4837,29 +4859,14 @@ function completeWork(current, workInProgress, renderLanes) { newProps = null !== newProps; renderLanes = !1; null !== current && (renderLanes = null !== current.memoizedState); - if ( - newProps && + newProps && !renderLanes && - ((workInProgress.child.flags |= 8192), 0 !== (workInProgress.mode & 1)) - ) - if (null === current || 0 !== (suspenseStackCursor.current & 1)) - 0 === workInProgressRootExitStatus && - (workInProgressRootExitStatus = 3); - else { - if ( - 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus || - 2 === workInProgressRootExitStatus - ) - workInProgressRootExitStatus = 4; - null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || - markRootSuspended$1( - workInProgressRoot, - workInProgressRootRenderLanes - ); - } + ((workInProgress.child.flags |= 8192), + 0 !== (workInProgress.mode & 1) && + (null === current || 0 !== (suspenseStackCursor.current & 1) + ? 0 === workInProgressRootExitStatus && + (workInProgressRootExitStatus = 3) + : renderDidSuspendDelayIfPossible())); null !== workInProgress.updateQueue && (workInProgress.flags |= 4); bubbleProperties(workInProgress); 0 !== (workInProgress.mode & 2) && @@ -6023,17 +6030,16 @@ function unwindWork(workInProgress) { workInProgress) : null; case 3: - popHostContainer(); - pop(didPerformWorkStackCursor); - pop(contextStackCursor); - resetWorkInProgressVersions(); - flags = workInProgress.flags; - if (0 !== (flags & 128)) - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ); - workInProgress.flags = (flags & -65537) | 128; - return workInProgress; + return ( + popHostContainer(), + pop(didPerformWorkStackCursor), + pop(contextStackCursor), + resetWorkInProgressVersions(), + (flags = workInProgress.flags), + 0 !== (flags & 65536) && 0 === (flags & 128) + ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + : null + ); case 5: return popHostContext(workInProgress), null; case 13: @@ -6924,96 +6930,99 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes), ensureRootIsScheduled(root, now()), originalCallbackNode); - prevDispatcher = !includesBlockingLane(root, lanes); - prevExecutionContext = root.current.alternate; - if ( - prevDispatcher && - !isRenderConsistentWithExternalStores(prevExecutionContext) && - ((didTimeout = renderRootSync(root, lanes)), - 2 === didTimeout && - ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), - 0 !== prevDispatcher && - ((lanes = prevDispatcher), - (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))), - 1 === didTimeout) - ) - throw ((originalCallbackNode = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), - originalCallbackNode); - root.finishedWork = prevExecutionContext; - root.finishedLanes = lanes; - switch (didTimeout) { - case 0: - case 1: - throw Error("Root did not complete. This is a bug in React."); - case 2: - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 3: - markRootSuspended$1(root, lanes); - if ( - (lanes & 130023424) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) - ) { - if (0 !== getNextLanes(root, 0)) break; - prevExecutionContext = root.suspendedLanes; - if ((prevExecutionContext & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + if (6 === didTimeout) markRootSuspended$1(root, lanes); + else { + prevDispatcher = !includesBlockingLane(root, lanes); + prevExecutionContext = root.current.alternate; + if ( + prevDispatcher && + !isRenderConsistentWithExternalStores(prevExecutionContext) && + ((didTimeout = renderRootSync(root, lanes)), + 2 === didTimeout && + ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), + 0 !== prevDispatcher && + ((lanes = prevDispatcher), + (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))), + 1 === didTimeout) + ) + throw ((originalCallbackNode = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), + originalCallbackNode); + root.finishedWork = prevExecutionContext; + root.finishedLanes = lanes; + switch (didTimeout) { + case 0: + case 1: + throw Error("Root did not complete. This is a bug in React."); + case 2: + commitRoot(root, workInProgressRootRecoverableErrors); + break; + case 3: + markRootSuspended$1(root, lanes); + if ( + (lanes & 130023424) === lanes && + ((didTimeout = globalMostRecentFallbackTime + 500 - now()), + 10 < didTimeout) + ) { + if (0 !== getNextLanes(root, 0)) break; + prevExecutionContext = root.suspendedLanes; + if ((prevExecutionContext & lanes) !== lanes) { + requestEventTime(); + root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + break; + } + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, workInProgressRootRecoverableErrors), + didTimeout + ); break; } - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root, workInProgressRootRecoverableErrors), - didTimeout - ); + commitRoot(root, workInProgressRootRecoverableErrors); break; - } - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 4: - markRootSuspended$1(root, lanes); - if ((lanes & 4194240) === lanes) break; - didTimeout = root.eventTimes; - for (prevExecutionContext = -1; 0 < lanes; ) - (memoizedUpdaters = 31 - clz32(lanes)), - (prevDispatcher = 1 << memoizedUpdaters), - (memoizedUpdaters = didTimeout[memoizedUpdaters]), - memoizedUpdaters > prevExecutionContext && - (prevExecutionContext = memoizedUpdaters), - (lanes &= ~prevDispatcher); - lanes = prevExecutionContext; - lanes = now() - lanes; - lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes; - if (10 < lanes) { - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root, workInProgressRootRecoverableErrors), - lanes - ); + case 4: + markRootSuspended$1(root, lanes); + if ((lanes & 4194240) === lanes) break; + didTimeout = root.eventTimes; + for (prevExecutionContext = -1; 0 < lanes; ) + (memoizedUpdaters = 31 - clz32(lanes)), + (prevDispatcher = 1 << memoizedUpdaters), + (memoizedUpdaters = didTimeout[memoizedUpdaters]), + memoizedUpdaters > prevExecutionContext && + (prevExecutionContext = memoizedUpdaters), + (lanes &= ~prevDispatcher); + lanes = prevExecutionContext; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; + if (10 < lanes) { + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, workInProgressRootRecoverableErrors), + lanes + ); + break; + } + commitRoot(root, workInProgressRootRecoverableErrors); break; - } - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 5: - commitRoot(root, workInProgressRootRecoverableErrors); - break; - default: - throw Error("Unknown root exit status."); + case 5: + commitRoot(root, workInProgressRootRecoverableErrors); + break; + default: + throw Error("Unknown root exit status."); + } } } ensureRootIsScheduled(root, now()); @@ -7029,12 +7038,12 @@ function recoverFromConcurrentError(root, errorRetryLanes) { root = renderRootSync(root, errorRetryLanes); 2 !== root && null !== errorsFromFirstAttempt && - (null === workInProgressRootConcurrentErrors + (null === workInProgressRootRecoverableErrors ? (workInProgressRootRecoverableErrors = errorsFromFirstAttempt) - : (workInProgressRootConcurrentErrors = workInProgressRootConcurrentErrors.push.apply( - null, + : workInProgressRootRecoverableErrors.push.apply( + workInProgressRootRecoverableErrors, errorsFromFirstAttempt - ))); + )); executionContext = prevExecutionContext; return root; } @@ -7105,6 +7114,8 @@ function performSyncWorkOnRoot(root) { markRootSuspended$1(root, lanes), ensureRootIsScheduled(root, now()), exitStatus); + if (6 === exitStatus) + throw Error("Root did not complete. This is a bug in React."); root.finishedWork = root.current.alternate; root.finishedLanes = lanes; commitRoot(root, workInProgressRootRecoverableErrors); @@ -7322,43 +7333,28 @@ function handleError(root, thrownValue) { sourceFiber.lanes |= 1; } else (value.flags |= 65536), (value.lanes = sourceFiber$jscomp$0); - sourceFiber = void 0; - value = suspenseBoundary; - if (value.mode & 1) { - var pingCache = wakeable.pingCache; - null === pingCache - ? ((pingCache = wakeable.pingCache = new PossiblyWeakMap()), - (sourceFiber = new Set()), - pingCache.set(wakeable$jscomp$0, sourceFiber)) - : ((sourceFiber = pingCache.get(wakeable$jscomp$0)), - void 0 === sourceFiber && - ((sourceFiber = new Set()), - pingCache.set(wakeable$jscomp$0, sourceFiber))); - if (!sourceFiber.has(thrownValue)) { - sourceFiber.add(thrownValue); - var ping = pingSuspendedRoot.bind( - null, - wakeable, - wakeable$jscomp$0, - thrownValue - ); - isDevToolsPresent && - restorePendingUpdaters(wakeable, thrownValue); - wakeable$jscomp$0.then(ping, ping); - } - } - var wakeables = value.updateQueue; + suspenseBoundary.mode & 1 && + attachPingListener(wakeable, wakeable$jscomp$0, thrownValue); + thrownValue = suspenseBoundary; + wakeable = wakeable$jscomp$0; + var wakeables = thrownValue.updateQueue; if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(wakeable$jscomp$0); - value.updateQueue = updateQueue; - } else wakeables.add(wakeable$jscomp$0); + updateQueue.add(wakeable); + thrownValue.updateQueue = updateQueue; + } else wakeables.add(wakeable); break a; - } else + } else { + if ((thrownValue & 4194240) === thrownValue) { + attachPingListener(wakeable, wakeable$jscomp$0, thrownValue); + renderDidSuspendDelayIfPossible(); + break a; + } value = Error( (getComponentNameFromFiber(sourceFiber) || "A React component") + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." ); + } } wakeable = value; 4 !== workInProgressRootExitStatus && @@ -7425,6 +7421,18 @@ function pushDispatcher() { ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } +function renderDidSuspendDelayIfPossible() { + if ( + 0 === workInProgressRootExitStatus || + 3 === workInProgressRootExitStatus || + 2 === workInProgressRootExitStatus + ) + workInProgressRootExitStatus = 4; + null === workInProgressRoot || + (0 === (workInProgressRootSkippedLanes & 268435455) && + 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || + markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); +} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 2; @@ -7514,10 +7522,15 @@ function completeUnitOfWork(unitOfWork) { (current += fiber.actualDuration), (fiber = fiber.sibling); completedWork.actualDuration = current; } - null !== unitOfWork && - ((unitOfWork.flags |= 32768), - (unitOfWork.subtreeFlags = 0), - (unitOfWork.deletions = null)); + if (null !== unitOfWork) + (unitOfWork.flags |= 32768), + (unitOfWork.subtreeFlags = 0), + (unitOfWork.deletions = null); + else { + workInProgressRootExitStatus = 6; + workInProgress = null; + return; + } } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -7609,13 +7622,11 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { ensureRootIsScheduled(root, now()); if (null !== recoverableErrors) for ( - renderPriorityLevel = 0; - renderPriorityLevel < recoverableErrors.length; - renderPriorityLevel++ + renderPriorityLevel = root.onRecoverableError, finishedWork = 0; + finishedWork < recoverableErrors.length; + finishedWork++ ) - (finishedWork = recoverableErrors[renderPriorityLevel]), - (lanes = root.onRecoverableError), - null !== lanes && lanes(finishedWork); + renderPriorityLevel(recoverableErrors[finishedWork]); if (hasUncaughtError) throw ((hasUncaughtError = !1), (root = firstUncaughtError), @@ -8813,6 +8824,9 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle.canonical._nativeTag : componentOrHandle._nativeTag; } +function onRecoverableError(error) { + console.error(error); +} batchedUpdatesImpl = function(fn, a) { var prevExecutionContext = executionContext; executionContext |= 1; @@ -8826,10 +8840,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1004 = { + devToolsConfig$jscomp$inline_1005 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-rc.0-a3bde7974-20220208", + version: "18.0.0-rc.0-27b569969-20220211", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8858,10 +8872,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1004.bundleType, - version: devToolsConfig$jscomp$inline_1004.version, - rendererPackageName: devToolsConfig$jscomp$inline_1004.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1004.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1005.bundleType, + version: devToolsConfig$jscomp$inline_1005.version, + rendererPackageName: devToolsConfig$jscomp$inline_1005.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1005.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8877,14 +8891,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1004.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1005.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-rc.0-a3bde7974-20220208" + reconcilerVersion: "18.0.0-rc.0-27b569969-20220211" }); exports.createPortal = function(children, containerTag) { return createPortal( @@ -8923,7 +8937,13 @@ exports.render = function(element, containerTag, callback, concurrentRoot) { var root = roots.get(containerTag); root || ((root = concurrentRoot ? 1 : 0), - (concurrentRoot = new FiberRootNode(containerTag, root, !1, "", null)), + (concurrentRoot = new FiberRootNode( + containerTag, + root, + !1, + "", + onRecoverableError + )), (root = 1 === root ? 1 : 0), isDevToolsPresent && (root |= 2), (root = createFiber(3, null, null, root)), diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index c913b5af61deec..db26fad7a4c44b 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<> + * @generated SignedSource<<8857db59af5934c939dce4733ccdabb0>> */ 'use strict'; @@ -1281,6 +1281,7 @@ var ScopeComponent = 21; var OffscreenComponent = 22; var LegacyHiddenComponent = 23; var CacheComponent = 24; +var TracingMarkerComponent = 25; /** * Instance of element that should respond to touch/move types of interactions, @@ -2902,6 +2903,7 @@ var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; var REACT_OFFSCREEN_TYPE = 0xeae2; var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; var REACT_CACHE_TYPE = 0xeae4; +var REACT_TRACING_MARKER_TYPE = 0xeae5; if (typeof Symbol === "function" && Symbol.for) { var symbolFor = Symbol.for; @@ -2922,6 +2924,7 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); REACT_CACHE_TYPE = symbolFor("react.cache"); + REACT_TRACING_MARKER_TYPE = symbolFor("react.tracing_marker"); } var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; @@ -3003,6 +3006,9 @@ function getComponentNameFromType(type) { case REACT_CACHE_TYPE: return "Cache"; + + case REACT_TRACING_MARKER_TYPE: + return "TracingMarker"; } if (typeof type === "object") { @@ -3123,6 +3129,9 @@ function getComponentNameFromFiber(fiber) { case SuspenseListComponent: return "SuspenseList"; + + case TracingMarkerComponent: + return "TracingMarker"; // The display name for this tags come from the user-provided type: case ClassComponent: @@ -10752,7 +10761,7 @@ function warnAboutMultipleRenderersDEV(mutableSource) { function getSuspendedCachePool() { { return null; - } // We check the cache on the stack first, since that's the one any new Caches + } // This function is called when a Suspense boundary suspends. It returns the } var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, @@ -13823,7 +13832,7 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { return update; } -function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { +function attachPingListener(root, wakeable, lanes) { // Attach a ping listener // // The data might resolve before we have a chance to commit the fallback. Or, @@ -13836,38 +13845,40 @@ function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { // // We only need to do this in concurrent mode. Legacy Suspense always // commits fallbacks synchronously, so there are no pings. - if (suspenseBoundary.mode & ConcurrentMode) { - var pingCache = root.pingCache; - var threadIDs; + var pingCache = root.pingCache; + var threadIDs; + + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap$1(); + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } else { + threadIDs = pingCache.get(wakeable); - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap$1(); + if (threadIDs === undefined) { threadIDs = new Set(); pingCache.set(wakeable, threadIDs); - } else { - threadIDs = pingCache.get(wakeable); - - if (threadIDs === undefined) { - threadIDs = new Set(); - pingCache.set(wakeable, threadIDs); - } } + } - if (!threadIDs.has(lanes)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(lanes); - var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); + if (!threadIDs.has(lanes)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(lanes); + var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); - { - if (isDevToolsPresent) { - // If we have pending work still, restore the original updaters - restorePendingUpdaters(root, lanes); - } + { + if (isDevToolsPresent) { + // If we have pending work still, restore the original updaters + restorePendingUpdaters(root, lanes); } - - wakeable.then(ping, ping); } - } // Retry listener + + wakeable.then(ping, ping); + } +} + +function attachRetryListener(suspenseBoundary, root, wakeable, lanes) { + // Retry listener // // If the fallback does commit, we need to attach a different type of // listener. This one schedules an update on the Suspense boundary to turn @@ -13878,7 +13889,6 @@ function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { // // When the wakeable resolves, we'll attempt to render the boundary // again ("retry"). - var wakeables = suspenseBoundary.updateQueue; if (wakeables === null) { @@ -14077,25 +14087,45 @@ function throwException( sourceFiber, root, rootRenderLanes - ); - attachWakeableListeners( - suspenseBoundary, - root, - wakeable, - rootRenderLanes - ); + ); // We only attach ping listeners in concurrent mode. Legacy Suspense always + // commits fallbacks synchronously, so there are no pings. + + if (suspenseBoundary.mode & ConcurrentMode) { + attachPingListener(root, wakeable, rootRenderLanes); + } + + attachRetryListener(suspenseBoundary, root, wakeable); return; } else { - // No boundary was found. Fallthrough to error mode. + // No boundary was found. If we're inside startTransition, 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.) + 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? // TODO: We should never call getComponentNameFromFiber in production. // Log a warning or something to prevent us from accidentally bundling it. - value = new Error( + + var uncaughtSuspenseError = new Error( (getComponentNameFromFiber(sourceFiber) || "A React component") + " suspended while rendering, but no fallback UI was specified.\n" + "\n" + "Add a component higher in the tree to " + "provide a loading indicator or placeholder to display." - ); + ); // If we're outside a transition, fall through to the regular error path. + // The error will be caught by the nearest suspense boundary. + + value = uncaughtSuspenseError; } } // We didn't find a boundary that could handle this type of exception. Start // over and traverse parent path again, this time treating the exception @@ -18090,15 +18120,17 @@ function unwindWork(workInProgress, renderLanes) { resetWorkInProgressVersions(); var _flags = workInProgress.flags; - if ((_flags & DidCapture) !== NoFlags) { - throw new Error( - "The root failed to unmount after an error. This is likely a bug in " + - "React. Please file an issue." - ); - } + if ( + (_flags & ShouldCapture) !== NoFlags && + (_flags & DidCapture) === NoFlags + ) { + // There was an error during render that wasn't captured by a suspense + // boundary. Do a second pass on the root to unmount the children. + workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture; + return workInProgress; + } // We unwound to the root without completing it. Exit. - workInProgress.flags = (_flags & ~ShouldCapture) | DidCapture; - return workInProgress; + return null; } case HostComponent: { @@ -20487,12 +20519,13 @@ var CommitContext = var RetryAfterError = /* */ 8; -var RootIncomplete = 0; +var RootInProgress = 0; var RootFatalErrored = 1; var RootErrored = 2; var RootSuspended = 3; var RootSuspendedWithDelay = 4; -var RootCompleted = 5; // Describes where we are in the React execution stack +var RootCompleted = 5; +var RootDidNotComplete = 6; // Describes where we are in the React execution stack var executionContext = NoContext; // The root we're working on @@ -20512,7 +20545,7 @@ var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to var subtreeRenderLanes = NoLanes; var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc. -var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown +var workInProgressRootExitStatus = RootInProgress; // A fatal error, if one is thrown var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's // slightly different than `renderLanes` because `renderLanes` can change as you @@ -20969,7 +21002,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ? renderRootConcurrent(root, lanes) : renderRootSync(root, lanes); - if (exitStatus !== RootIncomplete) { + if (exitStatus !== RootInProgress) { if (exitStatus === RootErrored) { // If something threw an error, try rendering one more time. We'll // render synchronously to block concurrent data mutations, and we'll @@ -20989,46 +21022,59 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes); ensureRootIsScheduled(root, now()); throw fatalError; - } // Check if this render may have yielded to a concurrent event, and if so, - // confirm that any newly rendered stores are consistent. - // TODO: It's possible that even a concurrent render may never have yielded - // to the main thread, if it was fast enough, or if it expired. We could - // skip the consistency check in that case, too. + } - var renderWasConcurrent = !includesBlockingLane(root, lanes); - var finishedWork = root.current.alternate; + if (exitStatus === RootDidNotComplete) { + // The render unwound without completing the tree. This happens in special + // cases where need to exit the current render without producing a + // consistent tree or committing. + // + // This should only happen during a concurrent render, not a discrete or + // synchronous update. We should have already checked for this when we + // unwound the stack. + markRootSuspended$1(root, lanes); + } else { + // The render completed. + // Check if this render may have yielded to a concurrent event, and if so, + // confirm that any newly rendered stores are consistent. + // TODO: It's possible that even a concurrent render may never have yielded + // to the main thread, if it was fast enough, or if it expired. We could + // skip the consistency check in that case, too. + var renderWasConcurrent = !includesBlockingLane(root, lanes); + var finishedWork = root.current.alternate; - if ( - renderWasConcurrent && - !isRenderConsistentWithExternalStores(finishedWork) - ) { - // A store was mutated in an interleaved event. Render again, - // synchronously, to block further mutations. - exitStatus = renderRootSync(root, lanes); // We need to check again if something threw + if ( + renderWasConcurrent && + !isRenderConsistentWithExternalStores(finishedWork) + ) { + // A store was mutated in an interleaved event. Render again, + // synchronously, to block further mutations. + exitStatus = renderRootSync(root, lanes); // We need to check again if something threw - if (exitStatus === RootErrored) { - var _errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); + if (exitStatus === RootErrored) { + var _errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); - if (_errorRetryLanes !== NoLanes) { - lanes = _errorRetryLanes; - exitStatus = recoverFromConcurrentError(root, _errorRetryLanes); // We assume the tree is now consistent because we didn't yield to any - // concurrent events. + if (_errorRetryLanes !== NoLanes) { + lanes = _errorRetryLanes; + exitStatus = recoverFromConcurrentError(root, _errorRetryLanes); // We assume the tree is now consistent because we didn't yield to any + // concurrent events. + } } - } - if (exitStatus === RootFatalErrored) { - var _fatalError = workInProgressRootFatalError; - prepareFreshStack(root, NoLanes); - markRootSuspended$1(root, lanes); - ensureRootIsScheduled(root, now()); - throw _fatalError; - } - } // We now have a consistent tree. The next step is either to commit it, - // or, if something suspended, wait to commit it after a timeout. + if (exitStatus === RootFatalErrored) { + var _fatalError = workInProgressRootFatalError; + prepareFreshStack(root, NoLanes); + markRootSuspended$1(root, lanes); + ensureRootIsScheduled(root, now()); + throw _fatalError; + } + } // We now have a consistent tree. The next step is either to commit it, + // or, if something suspended, wait to commit it after a timeout. - root.finishedWork = finishedWork; - root.finishedLanes = lanes; - finishConcurrentRender(root, exitStatus, lanes); + root.finishedWork = finishedWork; + root.finishedLanes = lanes; + finishConcurrentRender(root, exitStatus, lanes); + } } ensureRootIsScheduled(root, now()); @@ -21073,11 +21119,11 @@ function recoverFromConcurrentError(root, errorRetryLanes) { } function queueRecoverableErrors(errors) { - if (workInProgressRootConcurrentErrors === null) { + if (workInProgressRootRecoverableErrors === null) { workInProgressRootRecoverableErrors = errors; } else { - workInProgressRootConcurrentErrors = workInProgressRootConcurrentErrors.push.apply( - null, + workInProgressRootRecoverableErrors.push.apply( + workInProgressRootRecoverableErrors, errors ); } @@ -21085,7 +21131,7 @@ function queueRecoverableErrors(errors) { function finishConcurrentRender(root, exitStatus, lanes) { switch (exitStatus) { - case RootIncomplete: + case RootInProgress: case RootFatalErrored: { throw new Error("Root did not complete. This is a bug in React."); } @@ -21312,6 +21358,10 @@ function performSyncWorkOnRoot(root) { markRootSuspended$1(root, lanes); ensureRootIsScheduled(root, now()); throw fatalError; + } + + if (exitStatus === RootDidNotComplete) { + throw new Error("Root did not complete. This is a bug in React."); } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. @@ -21421,7 +21471,7 @@ function prepareFreshStack(root, lanes) { workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; - workInProgressRootExitStatus = RootIncomplete; + workInProgressRootExitStatus = RootInProgress; workInProgressRootFatalError = null; workInProgressRootSkippedLanes = NoLanes; workInProgressRootInterleavedUpdatedLanes = NoLanes; @@ -21551,13 +21601,13 @@ function markSkippedUpdateLanes(lane) { ); } function renderDidSuspend() { - if (workInProgressRootExitStatus === RootIncomplete) { + if (workInProgressRootExitStatus === RootInProgress) { workInProgressRootExitStatus = RootSuspended; } } function renderDidSuspendDelayIfPossible() { if ( - workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootInProgress || workInProgressRootExitStatus === RootSuspended || workInProgressRootExitStatus === RootErrored ) { @@ -21596,7 +21646,7 @@ function renderDidError(error) { function renderHasNotSuspendedYet() { // If something errored or completed, we can't really be sure, // so those are false. - return workInProgressRootExitStatus === RootIncomplete; + return workInProgressRootExitStatus === RootInProgress; } function renderRootSync(root, lanes) { @@ -21718,7 +21768,7 @@ function renderRootConcurrent(root, lanes) { markRenderYielded(); } - return RootIncomplete; + return RootInProgress; } else { // Completed the tree. { @@ -21837,6 +21887,11 @@ function completeUnitOfWork(unitOfWork) { returnFiber.flags |= Incomplete; returnFiber.subtreeFlags = NoFlags; returnFiber.deletions = null; + } else { + // We've unwound all the way to the root. + workInProgressRootExitStatus = RootDidNotComplete; + workInProgress = null; + return; } } @@ -21853,7 +21908,7 @@ function completeUnitOfWork(unitOfWork) { workInProgress = completedWork; } while (completedWork !== null); // We've reached the root. - if (workInProgressRootExitStatus === RootIncomplete) { + if (workInProgressRootExitStatus === RootInProgress) { workInProgressRootExitStatus = RootCompleted; } } @@ -22084,13 +22139,11 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { if (recoverableErrors !== null) { // There were errors during this render, but recovered from them without // needing to surface it to the UI. We log them here. + var onRecoverableError = root.onRecoverableError; + for (var i = 0; i < recoverableErrors.length; i++) { var recoverableError = recoverableErrors[i]; - var onRecoverableError = root.onRecoverableError; - - if (onRecoverableError !== null) { - onRecoverableError(recoverableError); - } + onRecoverableError(recoverableError); } } @@ -23691,6 +23744,10 @@ function createFiberFromTypeAndProps( // eslint-disable-next-line no-fallthrough + case REACT_TRACING_MARKER_TYPE: + + // eslint-disable-next-line no-fallthrough + default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -23987,7 +24044,8 @@ function createFiberRoot( // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, - onRecoverableError + onRecoverableError, + transitionCallbacks ) { var root = new FiberRootNode( containerInfo, @@ -24017,7 +24075,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.0.0-rc.0-a3bde7974-20220208"; +var ReactVersion = "18.0.0-rc.0-27b569969-20220211"; function createPortal( children, @@ -24146,7 +24204,8 @@ function createContainer( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, - onRecoverableError + onRecoverableError, + transitionCallbacks ) { return createFiberRoot( containerInfo, @@ -24929,6 +24988,12 @@ function sendAccessibilityEvent(handle, eventType) { } } +function onRecoverableError(error$1) { + // TODO: Expose onRecoverableError option to userspace + // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args + error(error$1); +} + function render(element, containerTag, callback) { var root = roots.get(containerTag); @@ -24943,7 +25008,7 @@ function render(element, containerTag, callback) { false, null, "", - null + onRecoverableError ); roots.set(containerTag, root); } diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 2087079f42a22e..c288efd295471f 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<<74ace7caaea78f5e62bae1f9669d8351>> + * @generated SignedSource<<864338c9d062ce0a8cdbee102f1e32d4>> */ "use strict"; @@ -926,7 +926,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_222 = { +var injectedNamesToPlugins$jscomp$inline_223 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -961,33 +961,33 @@ var injectedNamesToPlugins$jscomp$inline_222 = { } } }, - isOrderingDirty$jscomp$inline_223 = !1, - pluginName$jscomp$inline_224; -for (pluginName$jscomp$inline_224 in injectedNamesToPlugins$jscomp$inline_222) + isOrderingDirty$jscomp$inline_224 = !1, + pluginName$jscomp$inline_225; +for (pluginName$jscomp$inline_225 in injectedNamesToPlugins$jscomp$inline_223) if ( - injectedNamesToPlugins$jscomp$inline_222.hasOwnProperty( - pluginName$jscomp$inline_224 + injectedNamesToPlugins$jscomp$inline_223.hasOwnProperty( + pluginName$jscomp$inline_225 ) ) { - var pluginModule$jscomp$inline_225 = - injectedNamesToPlugins$jscomp$inline_222[pluginName$jscomp$inline_224]; + var pluginModule$jscomp$inline_226 = + injectedNamesToPlugins$jscomp$inline_223[pluginName$jscomp$inline_225]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_224) || - namesToPlugins[pluginName$jscomp$inline_224] !== - pluginModule$jscomp$inline_225 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_225) || + namesToPlugins[pluginName$jscomp$inline_225] !== + pluginModule$jscomp$inline_226 ) { - if (namesToPlugins[pluginName$jscomp$inline_224]) + if (namesToPlugins[pluginName$jscomp$inline_225]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_224 + "`.") + (pluginName$jscomp$inline_225 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_224 - ] = pluginModule$jscomp$inline_225; - isOrderingDirty$jscomp$inline_223 = !0; + pluginName$jscomp$inline_225 + ] = pluginModule$jscomp$inline_226; + isOrderingDirty$jscomp$inline_224 = !0; } } -isOrderingDirty$jscomp$inline_223 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_224 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1146,7 +1146,8 @@ var ReactSharedInternals = REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131, - REACT_CACHE_TYPE = 60132; + REACT_CACHE_TYPE = 60132, + REACT_TRACING_MARKER_TYPE = 60133; if ("function" === typeof Symbol && Symbol.for) { var symbolFor = Symbol.for; REACT_ELEMENT_TYPE = symbolFor("react.element"); @@ -1166,6 +1167,7 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); REACT_CACHE_TYPE = symbolFor("react.cache"); + REACT_TRACING_MARKER_TYPE = symbolFor("react.tracing_marker"); } var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { @@ -1194,6 +1196,8 @@ function getComponentNameFromType(type) { return "SuspenseList"; case REACT_CACHE_TYPE: return "Cache"; + case REACT_TRACING_MARKER_TYPE: + return "TracingMarker"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -1268,6 +1272,8 @@ function getComponentNameFromFiber(fiber) { return "Suspense"; case 19: return "SuspenseList"; + case 25: + return "TracingMarker"; case 1: case 0: case 17: @@ -4242,6 +4248,21 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { }); return lane; } +function attachPingListener(root, wakeable, lanes) { + var pingCache = root.pingCache; + if (null === pingCache) { + pingCache = root.pingCache = new PossiblyWeakMap(); + var threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } else + (threadIDs = pingCache.get(wakeable)), + void 0 === threadIDs && + ((threadIDs = new Set()), pingCache.set(wakeable, threadIDs)); + threadIDs.has(lanes) || + (threadIDs.add(lanes), + (root = pingSuspendedRoot.bind(null, root, wakeable, lanes)), + wakeable.then(root, root)); +} var appendAllChildren, updateHostContainer, updateHostComponent, updateHostText; appendAllChildren = function(parent, workInProgress) { for (var node = workInProgress.child; null !== node; ) { @@ -4444,29 +4465,14 @@ function completeWork(current, workInProgress, renderLanes) { return (workInProgress.lanes = renderLanes), workInProgress; renderLanes = !1; null !== current && (renderLanes = null !== current.memoizedState); - if ( - null !== newProps && - !renderLanes && - ((workInProgress.child.flags |= 8192), 0 !== (workInProgress.mode & 1)) - ) - if (null === current || 0 !== (suspenseStackCursor.current & 1)) - 0 === workInProgressRootExitStatus && - (workInProgressRootExitStatus = 3); - else { - if ( - 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus || - 2 === workInProgressRootExitStatus - ) - workInProgressRootExitStatus = 4; - null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || - markRootSuspended$1( - workInProgressRoot, - workInProgressRootRenderLanes - ); - } + null === newProps || + renderLanes || + ((workInProgress.child.flags |= 8192), + 0 !== (workInProgress.mode & 1) && + (null === current || 0 !== (suspenseStackCursor.current & 1) + ? 0 === workInProgressRootExitStatus && + (workInProgressRootExitStatus = 3) + : renderDidSuspendDelayIfPossible())); null !== workInProgress.updateQueue && (workInProgress.flags |= 4); bubbleProperties(workInProgress); return null; @@ -5522,17 +5528,16 @@ function unwindWork(workInProgress) { ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) : null; case 3: - popHostContainer(); - pop(didPerformWorkStackCursor); - pop(contextStackCursor); - resetWorkInProgressVersions(); - flags = workInProgress.flags; - if (0 !== (flags & 128)) - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ); - workInProgress.flags = (flags & -65537) | 128; - return workInProgress; + return ( + popHostContainer(), + pop(didPerformWorkStackCursor), + pop(contextStackCursor), + resetWorkInProgressVersions(), + (flags = workInProgress.flags), + 0 !== (flags & 65536) && 0 === (flags & 128) + ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + : null + ); case 5: return popHostContext(workInProgress), null; case 13: @@ -6558,96 +6563,99 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes), ensureRootIsScheduled(root, now()), originalCallbackNode); - prevDispatcher = !includesBlockingLane(root, lanes); - prevExecutionContext = root.current.alternate; - if ( - prevDispatcher && - !isRenderConsistentWithExternalStores(prevExecutionContext) && - ((didTimeout = renderRootSync(root, lanes)), - 2 === didTimeout && - ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), - 0 !== prevDispatcher && - ((lanes = prevDispatcher), - (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))), - 1 === didTimeout) - ) - throw ((originalCallbackNode = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), - originalCallbackNode); - root.finishedWork = prevExecutionContext; - root.finishedLanes = lanes; - switch (didTimeout) { - case 0: - case 1: - throw Error("Root did not complete. This is a bug in React."); - case 2: - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 3: - markRootSuspended$1(root, lanes); - if ( - (lanes & 130023424) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) - ) { - if (0 !== getNextLanes(root, 0)) break; - prevExecutionContext = root.suspendedLanes; - if ((prevExecutionContext & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + if (6 === didTimeout) markRootSuspended$1(root, lanes); + else { + prevDispatcher = !includesBlockingLane(root, lanes); + prevExecutionContext = root.current.alternate; + if ( + prevDispatcher && + !isRenderConsistentWithExternalStores(prevExecutionContext) && + ((didTimeout = renderRootSync(root, lanes)), + 2 === didTimeout && + ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), + 0 !== prevDispatcher && + ((lanes = prevDispatcher), + (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))), + 1 === didTimeout) + ) + throw ((originalCallbackNode = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), + originalCallbackNode); + root.finishedWork = prevExecutionContext; + root.finishedLanes = lanes; + switch (didTimeout) { + case 0: + case 1: + throw Error("Root did not complete. This is a bug in React."); + case 2: + commitRoot(root, workInProgressRootRecoverableErrors); + break; + case 3: + markRootSuspended$1(root, lanes); + if ( + (lanes & 130023424) === lanes && + ((didTimeout = globalMostRecentFallbackTime + 500 - now()), + 10 < didTimeout) + ) { + if (0 !== getNextLanes(root, 0)) break; + prevExecutionContext = root.suspendedLanes; + if ((prevExecutionContext & lanes) !== lanes) { + requestEventTime(); + root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + break; + } + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, workInProgressRootRecoverableErrors), + didTimeout + ); break; } - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root, workInProgressRootRecoverableErrors), - didTimeout - ); + commitRoot(root, workInProgressRootRecoverableErrors); break; - } - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 4: - markRootSuspended$1(root, lanes); - if ((lanes & 4194240) === lanes) break; - didTimeout = root.eventTimes; - for (prevExecutionContext = -1; 0 < lanes; ) { - var index$5 = 31 - clz32(lanes); - prevDispatcher = 1 << index$5; - index$5 = didTimeout[index$5]; - index$5 > prevExecutionContext && (prevExecutionContext = index$5); - lanes &= ~prevDispatcher; - } - lanes = prevExecutionContext; - lanes = now() - lanes; - lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes; - if (10 < lanes) { - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root, workInProgressRootRecoverableErrors), - lanes - ); + case 4: + markRootSuspended$1(root, lanes); + if ((lanes & 4194240) === lanes) break; + didTimeout = root.eventTimes; + for (prevExecutionContext = -1; 0 < lanes; ) { + var index$5 = 31 - clz32(lanes); + prevDispatcher = 1 << index$5; + index$5 = didTimeout[index$5]; + index$5 > prevExecutionContext && (prevExecutionContext = index$5); + lanes &= ~prevDispatcher; + } + lanes = prevExecutionContext; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; + if (10 < lanes) { + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, workInProgressRootRecoverableErrors), + lanes + ); + break; + } + commitRoot(root, workInProgressRootRecoverableErrors); break; - } - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 5: - commitRoot(root, workInProgressRootRecoverableErrors); - break; - default: - throw Error("Unknown root exit status."); + case 5: + commitRoot(root, workInProgressRootRecoverableErrors); + break; + default: + throw Error("Unknown root exit status."); + } } } ensureRootIsScheduled(root, now()); @@ -6663,12 +6671,12 @@ function recoverFromConcurrentError(root, errorRetryLanes) { root = renderRootSync(root, errorRetryLanes); 2 !== root && null !== errorsFromFirstAttempt && - (null === workInProgressRootConcurrentErrors + (null === workInProgressRootRecoverableErrors ? (workInProgressRootRecoverableErrors = errorsFromFirstAttempt) - : (workInProgressRootConcurrentErrors = workInProgressRootConcurrentErrors.push.apply( - null, + : workInProgressRootRecoverableErrors.push.apply( + workInProgressRootRecoverableErrors, errorsFromFirstAttempt - ))); + )); executionContext = prevExecutionContext; return root; } @@ -6737,6 +6745,8 @@ function performSyncWorkOnRoot(root) { markRootSuspended$1(root, lanes), ensureRootIsScheduled(root, now()), exitStatus); + if (6 === exitStatus) + throw Error("Root did not complete. This is a bug in React."); root.finishedWork = root.current.alternate; root.finishedLanes = lanes; commitRoot(root, workInProgressRootRecoverableErrors); @@ -6915,41 +6925,28 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber.lanes |= 1; } else (value.flags |= 65536), (value.lanes = sourceFiber$jscomp$0); - sourceFiber = void 0; - value = suspenseBoundary; - if (value.mode & 1) { - var pingCache = root.pingCache; - null === pingCache - ? ((pingCache = root.pingCache = new PossiblyWeakMap()), - (sourceFiber = new Set()), - pingCache.set(wakeable, sourceFiber)) - : ((sourceFiber = pingCache.get(wakeable)), - void 0 === sourceFiber && - ((sourceFiber = new Set()), - pingCache.set(wakeable, sourceFiber))); - if (!sourceFiber.has(thrownValue)) { - sourceFiber.add(thrownValue); - var ping = pingSuspendedRoot.bind( - null, - root, - wakeable, - thrownValue - ); - wakeable.then(ping, ping); - } - } - var wakeables = value.updateQueue; + suspenseBoundary.mode & 1 && + attachPingListener(root, wakeable, thrownValue); + thrownValue = suspenseBoundary; + root = wakeable; + var wakeables = thrownValue.updateQueue; if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(wakeable); - value.updateQueue = updateQueue; - } else wakeables.add(wakeable); + updateQueue.add(root); + thrownValue.updateQueue = updateQueue; + } else wakeables.add(root); break a; - } else + } else { + if ((thrownValue & 4194240) === thrownValue) { + attachPingListener(root, wakeable, thrownValue); + renderDidSuspendDelayIfPossible(); + break a; + } value = Error( (getComponentNameFromFiber(sourceFiber) || "A React component") + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." ); + } } root = value; 4 !== workInProgressRootExitStatus && @@ -7016,6 +7013,18 @@ function pushDispatcher() { ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } +function renderDidSuspendDelayIfPossible() { + if ( + 0 === workInProgressRootExitStatus || + 3 === workInProgressRootExitStatus || + 2 === workInProgressRootExitStatus + ) + workInProgressRootExitStatus = 4; + null === workInProgressRoot || + (0 === (workInProgressRootSkippedLanes & 268435455) && + 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || + markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); +} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 2; @@ -7074,10 +7083,15 @@ function completeUnitOfWork(unitOfWork) { workInProgress = current; return; } - null !== unitOfWork && - ((unitOfWork.flags |= 32768), - (unitOfWork.subtreeFlags = 0), - (unitOfWork.deletions = null)); + if (null !== unitOfWork) + (unitOfWork.flags |= 32768), + (unitOfWork.subtreeFlags = 0), + (unitOfWork.deletions = null); + else { + workInProgressRootExitStatus = 6; + workInProgress = null; + return; + } } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -7158,13 +7172,11 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { ensureRootIsScheduled(root, now()); if (null !== recoverableErrors) for ( - renderPriorityLevel = 0; - renderPriorityLevel < recoverableErrors.length; - renderPriorityLevel++ + renderPriorityLevel = root.onRecoverableError, finishedWork = 0; + finishedWork < recoverableErrors.length; + finishedWork++ ) - (finishedWork = recoverableErrors[renderPriorityLevel]), - (lanes = root.onRecoverableError), - null !== lanes && lanes(finishedWork); + renderPriorityLevel(recoverableErrors[finishedWork]); if (hasUncaughtError) throw ((hasUncaughtError = !1), (root = firstUncaughtError), @@ -8250,6 +8262,9 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle.canonical._nativeTag : componentOrHandle._nativeTag; } +function onRecoverableError(error) { + console.error(error); +} function unmountComponentAtNode(containerTag) { var root = roots.get(containerTag); root && @@ -8270,10 +8285,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_968 = { + devToolsConfig$jscomp$inline_969 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-rc.0-a3bde7974-20220208", + version: "18.0.0-rc.0-27b569969-20220211", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8288,11 +8303,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1232 = { - bundleType: devToolsConfig$jscomp$inline_968.bundleType, - version: devToolsConfig$jscomp$inline_968.version, - rendererPackageName: devToolsConfig$jscomp$inline_968.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_968.rendererConfig, +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, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8308,26 +8323,26 @@ var internals$jscomp$inline_1232 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_968.findFiberByHostInstance || + devToolsConfig$jscomp$inline_969.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-rc.0-a3bde7974-20220208" + reconcilerVersion: "18.0.0-rc.0-27b569969-20220211" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1233 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1230 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1233.isDisabled && - hook$jscomp$inline_1233.supportsFiber + !hook$jscomp$inline_1230.isDisabled && + hook$jscomp$inline_1230.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1233.inject( - internals$jscomp$inline_1232 + (rendererID = hook$jscomp$inline_1230.inject( + internals$jscomp$inline_1229 )), - (injectedHook = hook$jscomp$inline_1233); + (injectedHook = hook$jscomp$inline_1230); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { @@ -8373,7 +8388,7 @@ exports.findNodeHandle = findNodeHandle; exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = new FiberRootNode(containerTag, 0, !1, "", null); + root = new FiberRootNode(containerTag, 0, !1, "", onRecoverableError); var JSCompiler_inline_result = createFiber(3, null, null, 0); root.current = JSCompiler_inline_result; JSCompiler_inline_result.stateNode = root; diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index ec6c578705217a..1bb71dd7138896 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<<6fb23e3f27b69a5703944d58969d32f4>> + * @generated SignedSource<> */ @@ -937,7 +937,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_231 = { +var injectedNamesToPlugins$jscomp$inline_232 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -972,33 +972,33 @@ var injectedNamesToPlugins$jscomp$inline_231 = { } } }, - isOrderingDirty$jscomp$inline_232 = !1, - pluginName$jscomp$inline_233; -for (pluginName$jscomp$inline_233 in injectedNamesToPlugins$jscomp$inline_231) + isOrderingDirty$jscomp$inline_233 = !1, + pluginName$jscomp$inline_234; +for (pluginName$jscomp$inline_234 in injectedNamesToPlugins$jscomp$inline_232) if ( - injectedNamesToPlugins$jscomp$inline_231.hasOwnProperty( - pluginName$jscomp$inline_233 + injectedNamesToPlugins$jscomp$inline_232.hasOwnProperty( + pluginName$jscomp$inline_234 ) ) { - var pluginModule$jscomp$inline_234 = - injectedNamesToPlugins$jscomp$inline_231[pluginName$jscomp$inline_233]; + var pluginModule$jscomp$inline_235 = + injectedNamesToPlugins$jscomp$inline_232[pluginName$jscomp$inline_234]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_233) || - namesToPlugins[pluginName$jscomp$inline_233] !== - pluginModule$jscomp$inline_234 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_234) || + namesToPlugins[pluginName$jscomp$inline_234] !== + pluginModule$jscomp$inline_235 ) { - if (namesToPlugins[pluginName$jscomp$inline_233]) + if (namesToPlugins[pluginName$jscomp$inline_234]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_233 + "`.") + (pluginName$jscomp$inline_234 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_233 - ] = pluginModule$jscomp$inline_234; - isOrderingDirty$jscomp$inline_232 = !0; + pluginName$jscomp$inline_234 + ] = pluginModule$jscomp$inline_235; + isOrderingDirty$jscomp$inline_233 = !0; } } -isOrderingDirty$jscomp$inline_232 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_233 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1157,7 +1157,8 @@ var ReactSharedInternals = REACT_DEBUG_TRACING_MODE_TYPE = 60129, REACT_OFFSCREEN_TYPE = 60130, REACT_LEGACY_HIDDEN_TYPE = 60131, - REACT_CACHE_TYPE = 60132; + REACT_CACHE_TYPE = 60132, + REACT_TRACING_MARKER_TYPE = 60133; if ("function" === typeof Symbol && Symbol.for) { var symbolFor = Symbol.for; REACT_ELEMENT_TYPE = symbolFor("react.element"); @@ -1177,6 +1178,7 @@ if ("function" === typeof Symbol && Symbol.for) { REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); REACT_CACHE_TYPE = symbolFor("react.cache"); + REACT_TRACING_MARKER_TYPE = symbolFor("react.tracing_marker"); } var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { @@ -1205,6 +1207,8 @@ function getComponentNameFromType(type) { return "SuspenseList"; case REACT_CACHE_TYPE: return "Cache"; + case REACT_TRACING_MARKER_TYPE: + return "TracingMarker"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -1279,6 +1283,8 @@ function getComponentNameFromFiber(fiber) { return "Suspense"; case 19: return "SuspenseList"; + case 25: + return "TracingMarker"; case 1: case 0: case 17: @@ -4434,6 +4440,22 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { }); return lane; } +function attachPingListener(root, wakeable, lanes) { + var pingCache = root.pingCache; + if (null === pingCache) { + pingCache = root.pingCache = new PossiblyWeakMap(); + var threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } else + (threadIDs = pingCache.get(wakeable)), + void 0 === threadIDs && + ((threadIDs = new Set()), pingCache.set(wakeable, threadIDs)); + threadIDs.has(lanes) || + (threadIDs.add(lanes), + (pingCache = pingSuspendedRoot.bind(null, root, wakeable, lanes)), + isDevToolsPresent && restorePendingUpdaters(root, lanes), + wakeable.then(pingCache, pingCache)); +} var appendAllChildren, updateHostContainer, updateHostComponent, updateHostText; appendAllChildren = function(parent, workInProgress) { for (var node = workInProgress.child; null !== node; ) { @@ -4678,29 +4700,14 @@ function completeWork(current, workInProgress, renderLanes) { newProps = null !== newProps; renderLanes = !1; null !== current && (renderLanes = null !== current.memoizedState); - if ( - newProps && + newProps && !renderLanes && - ((workInProgress.child.flags |= 8192), 0 !== (workInProgress.mode & 1)) - ) - if (null === current || 0 !== (suspenseStackCursor.current & 1)) - 0 === workInProgressRootExitStatus && - (workInProgressRootExitStatus = 3); - else { - if ( - 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus || - 2 === workInProgressRootExitStatus - ) - workInProgressRootExitStatus = 4; - null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || - markRootSuspended$1( - workInProgressRoot, - workInProgressRootRenderLanes - ); - } + ((workInProgress.child.flags |= 8192), + 0 !== (workInProgress.mode & 1) && + (null === current || 0 !== (suspenseStackCursor.current & 1) + ? 0 === workInProgressRootExitStatus && + (workInProgressRootExitStatus = 3) + : renderDidSuspendDelayIfPossible())); null !== workInProgress.updateQueue && (workInProgress.flags |= 4); bubbleProperties(workInProgress); 0 !== (workInProgress.mode & 2) && @@ -5795,17 +5802,16 @@ function unwindWork(workInProgress) { workInProgress) : null; case 3: - popHostContainer(); - pop(didPerformWorkStackCursor); - pop(contextStackCursor); - resetWorkInProgressVersions(); - flags = workInProgress.flags; - if (0 !== (flags & 128)) - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ); - workInProgress.flags = (flags & -65537) | 128; - return workInProgress; + return ( + popHostContainer(), + pop(didPerformWorkStackCursor), + pop(contextStackCursor), + resetWorkInProgressVersions(), + (flags = workInProgress.flags), + 0 !== (flags & 65536) && 0 === (flags & 128) + ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) + : null + ); case 5: return popHostContext(workInProgress), null; case 13: @@ -7020,96 +7026,99 @@ function performConcurrentWorkOnRoot(root, didTimeout) { markRootSuspended$1(root, lanes), ensureRootIsScheduled(root, now()), originalCallbackNode); - prevDispatcher = !includesBlockingLane(root, lanes); - prevExecutionContext = root.current.alternate; - if ( - prevDispatcher && - !isRenderConsistentWithExternalStores(prevExecutionContext) && - ((didTimeout = renderRootSync(root, lanes)), - 2 === didTimeout && - ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), - 0 !== prevDispatcher && - ((lanes = prevDispatcher), - (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))), - 1 === didTimeout) - ) - throw ((originalCallbackNode = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), - originalCallbackNode); - root.finishedWork = prevExecutionContext; - root.finishedLanes = lanes; - switch (didTimeout) { - case 0: - case 1: - throw Error("Root did not complete. This is a bug in React."); - case 2: - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 3: - markRootSuspended$1(root, lanes); - if ( - (lanes & 130023424) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) - ) { - if (0 !== getNextLanes(root, 0)) break; - prevExecutionContext = root.suspendedLanes; - if ((prevExecutionContext & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + if (6 === didTimeout) markRootSuspended$1(root, lanes); + else { + prevDispatcher = !includesBlockingLane(root, lanes); + prevExecutionContext = root.current.alternate; + if ( + prevDispatcher && + !isRenderConsistentWithExternalStores(prevExecutionContext) && + ((didTimeout = renderRootSync(root, lanes)), + 2 === didTimeout && + ((prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), + 0 !== prevDispatcher && + ((lanes = prevDispatcher), + (didTimeout = recoverFromConcurrentError(root, prevDispatcher)))), + 1 === didTimeout) + ) + throw ((originalCallbackNode = workInProgressRootFatalError), + prepareFreshStack(root, 0), + markRootSuspended$1(root, lanes), + ensureRootIsScheduled(root, now()), + originalCallbackNode); + root.finishedWork = prevExecutionContext; + root.finishedLanes = lanes; + switch (didTimeout) { + case 0: + case 1: + throw Error("Root did not complete. This is a bug in React."); + case 2: + commitRoot(root, workInProgressRootRecoverableErrors); + break; + case 3: + markRootSuspended$1(root, lanes); + if ( + (lanes & 130023424) === lanes && + ((didTimeout = globalMostRecentFallbackTime + 500 - now()), + 10 < didTimeout) + ) { + if (0 !== getNextLanes(root, 0)) break; + prevExecutionContext = root.suspendedLanes; + if ((prevExecutionContext & lanes) !== lanes) { + requestEventTime(); + root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + break; + } + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, workInProgressRootRecoverableErrors), + didTimeout + ); break; } - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root, workInProgressRootRecoverableErrors), - didTimeout - ); + commitRoot(root, workInProgressRootRecoverableErrors); break; - } - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 4: - markRootSuspended$1(root, lanes); - if ((lanes & 4194240) === lanes) break; - didTimeout = root.eventTimes; - for (prevExecutionContext = -1; 0 < lanes; ) - (memoizedUpdaters = 31 - clz32(lanes)), - (prevDispatcher = 1 << memoizedUpdaters), - (memoizedUpdaters = didTimeout[memoizedUpdaters]), - memoizedUpdaters > prevExecutionContext && - (prevExecutionContext = memoizedUpdaters), - (lanes &= ~prevDispatcher); - lanes = prevExecutionContext; - lanes = now() - lanes; - lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes; - if (10 < lanes) { - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root, workInProgressRootRecoverableErrors), - lanes - ); + case 4: + markRootSuspended$1(root, lanes); + if ((lanes & 4194240) === lanes) break; + didTimeout = root.eventTimes; + for (prevExecutionContext = -1; 0 < lanes; ) + (memoizedUpdaters = 31 - clz32(lanes)), + (prevDispatcher = 1 << memoizedUpdaters), + (memoizedUpdaters = didTimeout[memoizedUpdaters]), + memoizedUpdaters > prevExecutionContext && + (prevExecutionContext = memoizedUpdaters), + (lanes &= ~prevDispatcher); + lanes = prevExecutionContext; + lanes = now() - lanes; + lanes = + (120 > lanes + ? 120 + : 480 > lanes + ? 480 + : 1080 > lanes + ? 1080 + : 1920 > lanes + ? 1920 + : 3e3 > lanes + ? 3e3 + : 4320 > lanes + ? 4320 + : 1960 * ceil(lanes / 1960)) - lanes; + if (10 < lanes) { + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, workInProgressRootRecoverableErrors), + lanes + ); + break; + } + commitRoot(root, workInProgressRootRecoverableErrors); break; - } - commitRoot(root, workInProgressRootRecoverableErrors); - break; - case 5: - commitRoot(root, workInProgressRootRecoverableErrors); - break; - default: - throw Error("Unknown root exit status."); + case 5: + commitRoot(root, workInProgressRootRecoverableErrors); + break; + default: + throw Error("Unknown root exit status."); + } } } ensureRootIsScheduled(root, now()); @@ -7125,12 +7134,12 @@ function recoverFromConcurrentError(root, errorRetryLanes) { root = renderRootSync(root, errorRetryLanes); 2 !== root && null !== errorsFromFirstAttempt && - (null === workInProgressRootConcurrentErrors + (null === workInProgressRootRecoverableErrors ? (workInProgressRootRecoverableErrors = errorsFromFirstAttempt) - : (workInProgressRootConcurrentErrors = workInProgressRootConcurrentErrors.push.apply( - null, + : workInProgressRootRecoverableErrors.push.apply( + workInProgressRootRecoverableErrors, errorsFromFirstAttempt - ))); + )); executionContext = prevExecutionContext; return root; } @@ -7201,6 +7210,8 @@ function performSyncWorkOnRoot(root) { markRootSuspended$1(root, lanes), ensureRootIsScheduled(root, now()), exitStatus); + if (6 === exitStatus) + throw Error("Root did not complete. This is a bug in React."); root.finishedWork = root.current.alternate; root.finishedLanes = lanes; commitRoot(root, workInProgressRootRecoverableErrors); @@ -7404,43 +7415,28 @@ function handleError(root, thrownValue) { sourceFiber.lanes |= 1; } else (value.flags |= 65536), (value.lanes = sourceFiber$jscomp$0); - sourceFiber = void 0; - value = suspenseBoundary; - if (value.mode & 1) { - var pingCache = wakeable.pingCache; - null === pingCache - ? ((pingCache = wakeable.pingCache = new PossiblyWeakMap()), - (sourceFiber = new Set()), - pingCache.set(wakeable$jscomp$0, sourceFiber)) - : ((sourceFiber = pingCache.get(wakeable$jscomp$0)), - void 0 === sourceFiber && - ((sourceFiber = new Set()), - pingCache.set(wakeable$jscomp$0, sourceFiber))); - if (!sourceFiber.has(thrownValue)) { - sourceFiber.add(thrownValue); - var ping = pingSuspendedRoot.bind( - null, - wakeable, - wakeable$jscomp$0, - thrownValue - ); - isDevToolsPresent && - restorePendingUpdaters(wakeable, thrownValue); - wakeable$jscomp$0.then(ping, ping); - } - } - var wakeables = value.updateQueue; + suspenseBoundary.mode & 1 && + attachPingListener(wakeable, wakeable$jscomp$0, thrownValue); + thrownValue = suspenseBoundary; + wakeable = wakeable$jscomp$0; + var wakeables = thrownValue.updateQueue; if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(wakeable$jscomp$0); - value.updateQueue = updateQueue; - } else wakeables.add(wakeable$jscomp$0); + updateQueue.add(wakeable); + thrownValue.updateQueue = updateQueue; + } else wakeables.add(wakeable); break a; - } else + } else { + if ((thrownValue & 4194240) === thrownValue) { + attachPingListener(wakeable, wakeable$jscomp$0, thrownValue); + renderDidSuspendDelayIfPossible(); + break a; + } value = Error( (getComponentNameFromFiber(sourceFiber) || "A React component") + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." ); + } } wakeable = value; 4 !== workInProgressRootExitStatus && @@ -7507,6 +7503,18 @@ function pushDispatcher() { ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } +function renderDidSuspendDelayIfPossible() { + if ( + 0 === workInProgressRootExitStatus || + 3 === workInProgressRootExitStatus || + 2 === workInProgressRootExitStatus + ) + workInProgressRootExitStatus = 4; + null === workInProgressRoot || + (0 === (workInProgressRootSkippedLanes & 268435455) && + 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || + markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); +} function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; executionContext |= 2; @@ -7596,10 +7604,15 @@ function completeUnitOfWork(unitOfWork) { (current += fiber.actualDuration), (fiber = fiber.sibling); completedWork.actualDuration = current; } - null !== unitOfWork && - ((unitOfWork.flags |= 32768), - (unitOfWork.subtreeFlags = 0), - (unitOfWork.deletions = null)); + if (null !== unitOfWork) + (unitOfWork.flags |= 32768), + (unitOfWork.subtreeFlags = 0), + (unitOfWork.deletions = null); + else { + workInProgressRootExitStatus = 6; + workInProgress = null; + return; + } } completedWork = completedWork.sibling; if (null !== completedWork) { @@ -7691,13 +7704,11 @@ function commitRootImpl(root, recoverableErrors, renderPriorityLevel) { ensureRootIsScheduled(root, now()); if (null !== recoverableErrors) for ( - renderPriorityLevel = 0; - renderPriorityLevel < recoverableErrors.length; - renderPriorityLevel++ + renderPriorityLevel = root.onRecoverableError, finishedWork = 0; + finishedWork < recoverableErrors.length; + finishedWork++ ) - (finishedWork = recoverableErrors[renderPriorityLevel]), - (lanes = root.onRecoverableError), - null !== lanes && lanes(finishedWork); + renderPriorityLevel(recoverableErrors[finishedWork]); if (hasUncaughtError) throw ((hasUncaughtError = !1), (root = firstUncaughtError), @@ -8888,6 +8899,9 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle.canonical._nativeTag : componentOrHandle._nativeTag; } +function onRecoverableError(error) { + console.error(error); +} function unmountComponentAtNode(containerTag) { var root = roots.get(containerTag); root && @@ -8908,10 +8922,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1045 = { + devToolsConfig$jscomp$inline_1046 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-rc.0-a3bde7974-20220208", + version: "18.0.0-rc.0-27b569969-20220211", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8940,10 +8954,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1045.bundleType, - version: devToolsConfig$jscomp$inline_1045.version, - rendererPackageName: devToolsConfig$jscomp$inline_1045.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1045.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1046.bundleType, + version: devToolsConfig$jscomp$inline_1046.version, + rendererPackageName: devToolsConfig$jscomp$inline_1046.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1046.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8959,14 +8973,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1045.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1046.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-rc.0-a3bde7974-20220208" + reconcilerVersion: "18.0.0-rc.0-27b569969-20220211" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function(reactTag) { @@ -9011,7 +9025,7 @@ exports.findNodeHandle = findNodeHandle; exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = new FiberRootNode(containerTag, 0, !1, "", null); + root = new FiberRootNode(containerTag, 0, !1, "", onRecoverableError); var JSCompiler_inline_result = 0; isDevToolsPresent && (JSCompiler_inline_result |= 2); JSCompiler_inline_result = createFiber(