diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index ac1bb7c764..cdf4b841f1 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -cae635054e17a6f107a39d328649137b83f25972 \ No newline at end of file +419cc9c3799bc296c3c2a2c93880826aca680886 \ 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 79d4f4b95b..06a99f732f 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<<45ddf77f62454702039adab715d6bb58>> + * @generated SignedSource<<7030f8cf60391b0a117fd83a00a5b3be>> */ 'use strict'; @@ -2945,7 +2945,7 @@ var MutationMask = Ref | Hydrating | Visibility; -var LayoutMask = Update | Callback | Ref; // TODO: Split into PassiveMountMask and PassiveUnmountMask +var LayoutMask = Update | Callback | Ref | Visibility; // TODO: Split into PassiveMountMask and PassiveUnmountMask var PassiveMask = Passive | ChildDeletion; // Union of tags that don't get reset on clones. // This allows certain concepts to persist without recalculting them, @@ -3714,6 +3714,7 @@ function diff(prevProps, nextProps, validAttributes) { var batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; + var isInsideEventHandler = false; function batchedUpdates(fn, bookkeeping) { if (isInsideEventHandler) { @@ -3730,11 +3731,7 @@ function batchedUpdates(fn, bookkeeping) { isInsideEventHandler = false; } } -function setBatchingImplementation( - _batchedUpdatesImpl, - _discreteUpdatesImpl, - _batchedEventUpdatesImpl -) { +function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl) { batchedUpdatesImpl = _batchedUpdatesImpl; } @@ -3917,9 +3914,15 @@ function injectInternals(internals) { { error("React instrumentation encountered an error: %s.", err); } - } // DevTools exists + } - return true; + if (hook.checkDCE) { + // This is the real DevTools. + return true; + } else { + // This is likely a hook installed by Fast Refresh runtime. + return false; + } } function onScheduleRoot(root, children) { { @@ -5859,7 +5862,7 @@ var Passive$1 = /* */ 4; -var ReactVersion = "18.0.0-cae635054-20210626"; +var ReactVersion = "18.0.0-419cc9c37-20210726"; var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -9574,38 +9577,6 @@ function ChildReconciler(shouldTrackSideEffects) { if (typeof newChild === "function") { warnOnFunctionType(returnFiber); } - } - - if (typeof newChild === "undefined" && !isUnkeyedTopLevelFragment) { - // If the new child is undefined, and the return fiber is a composite - // component, throw an error. If Fiber return types are disabled, - // we already threw above. - switch (returnFiber.tag) { - case ClassComponent: { - { - var instance = returnFiber.stateNode; - - if (instance.render._isMockFunction) { - // We allow auto-mocks to proceed as if they're returning null. - break; - } - } - } - // Intentionally fall through to the next case, which handles both - // functions and classes - // eslint-disable-next-lined no-fallthrough - - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - { - throw Error( - (getComponentNameFromFiber(returnFiber) || "Component") + - "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - ); - } - } - } } // Remaining cases are all treated as empty. return deleteRemainingChildren(returnFiber, currentFirstChild); @@ -9778,11 +9749,7 @@ function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { return false; } - var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop. - - if (props.fallback === undefined) { - return false; - } // Regular boundaries always capture. + var props = workInProgress.memoizedProps; // Regular boundaries always capture. if (props.unstable_avoidThisFallback !== true) { return true; @@ -14326,12 +14293,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // This is a new mount or this boundary is already showing a fallback state. // Mark this subtree context as having at least one invisible parent that could // handle the fallback state. - // Boundaries without fallbacks or should be avoided are not considered since - // they cannot handle preferred fallback states. - if ( - nextProps.fallback !== undefined && - nextProps.unstable_avoidThisFallback !== true - ) { + // Avoided boundaries are not considered since they cannot handle preferred fallback states. + if (nextProps.unstable_avoidThisFallback !== true) { suspenseContext = addSubtreeSuspenseContext( suspenseContext, InvisibleParentSuspenseContext @@ -14365,11 +14328,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // a stack. if (current === null) { - // Initial mount - // If we're currently hydrating, try to hydrate this boundary. - // But only if this has a fallback. - if (nextProps.fallback !== undefined); - var nextPrimaryChildren = nextProps.children; var nextFallbackChildren = nextProps.fallback; @@ -15859,42 +15817,16 @@ var updateHostText$1; appendInitialChild(parent, _instance); } else if (node.tag === HostPortal); - else if (node.tag === SuspenseComponent) { - if ((node.flags & Update) !== NoFlags) { - // Need to toggle the visibility of the primary children. - var newIsHidden = node.memoizedState !== null; + else if (node.tag === OffscreenComponent && node.memoizedState !== null) { + // The children in this boundary are hidden. Toggle their visibility + // before appending. + var child = node.child; - if (newIsHidden) { - var primaryChildParent = node.child; - - if (primaryChildParent !== null) { - if (primaryChildParent.child !== null) { - primaryChildParent.child.return = primaryChildParent; - appendAllChildren( - parent, - primaryChildParent, - true, - newIsHidden - ); - } - - var fallbackChildParent = primaryChildParent.sibling; - - if (fallbackChildParent !== null) { - fallbackChildParent.return = node; - node = fallbackChildParent; - continue; - } - } - } + if (child !== null) { + child.return = node; } - if (node.child !== null) { - // Continue traversing like normal - node.child.return = node; - node = node.child; - continue; - } + appendAllChildren(parent, node, true, true); } else if (node.child !== null) { node.child.return = node; node = node.child; @@ -15954,42 +15886,16 @@ var updateHostText$1; appendChildToContainerChildSet(containerChildSet, _instance2); } else if (node.tag === HostPortal); - else if (node.tag === SuspenseComponent) { - if ((node.flags & Update) !== NoFlags) { - // Need to toggle the visibility of the primary children. - var newIsHidden = node.memoizedState !== null; + else if (node.tag === OffscreenComponent && node.memoizedState !== null) { + // The children in this boundary are hidden. Toggle their visibility + // before appending. + var child = node.child; - if (newIsHidden) { - var primaryChildParent = node.child; - - if (primaryChildParent !== null) { - if (primaryChildParent.child !== null) { - primaryChildParent.child.return = primaryChildParent; - appendAllChildrenToContainer( - containerChildSet, - primaryChildParent, - true, - newIsHidden - ); - } - - var fallbackChildParent = primaryChildParent.sibling; - - if (fallbackChildParent !== null) { - fallbackChildParent.return = node; - node = fallbackChildParent; - continue; - } - } - } + if (child !== null) { + child.return = node; } - if (node.child !== null) { - // Continue traversing like normal - node.child.return = node; - node = node.child; - continue; - } + appendAllChildrenToContainer(containerChildSet, node, true, true); } else if (node.child !== null) { node.child.return = node; node = node.child; @@ -16482,17 +16388,28 @@ function completeWork(current, workInProgress, renderLanes) { var nextDidTimeout = nextState !== null; var prevDidTimeout = false; - if (current === null) { - if (workInProgress.memoizedProps.fallback !== undefined); - } else { + if (current === null); + else { var prevState = current.memoizedState; prevDidTimeout = prevState !== null; - } + } // If the suspended state of the boundary changes, we need to schedule + // an effect to toggle the subtree's visibility. When we switch from + // fallback -> primary, the inner Offscreen fiber schedules this effect + // as part of its normal complete phase. But when we switch from + // primary -> fallback, the inner Offscreen fiber does not have a complete + // phase. So we need to schedule its effect here. + // + // We also use this flag to connect/disconnect the effects, but the same + // logic applies: when re-connecting, the Offscreen fiber's complete + // phase will handle scheduling the effect. It's only when the fallback + // is active that we have to do anything special. if (nextDidTimeout && !prevDidTimeout) { - // TODO: This will still suspend a synchronous tree if anything + var offscreenFiber = workInProgress.child; + offscreenFiber.flags |= Visibility; // TODO: This will still suspend a synchronous tree if anything // in the concurrent tree already suspended during this render. // This is a known bug. + if ((workInProgress.mode & ConcurrentMode) !== NoMode) { // TODO: Move this back to throwException because this is too late // if this is a large tree which is common for initial loads. We @@ -16523,14 +16440,12 @@ function completeWork(current, workInProgress, renderLanes) { } } - { - // TODO: Only schedule updates if not prevDidTimeout. - if (nextDidTimeout) { - // If this boundary just timed out, schedule an effect to attach a - // retry listener to the promise. This flag is also used to hide the - // primary children. - workInProgress.flags |= Update; - } + var wakeables = workInProgress.updateQueue; + + if (wakeables !== null) { + // Schedule an effect to attach a retry listener to the promise. + // TODO: Move to passive phase + workInProgress.flags |= Update; } bubbleProperties(workInProgress); @@ -16809,18 +16724,21 @@ function completeWork(current, workInProgress, renderLanes) { if ( prevIsHidden !== nextIsHidden && - newProps.mode !== "unstable-defer-without-hiding" + newProps.mode !== "unstable-defer-without-hiding" && // LegacyHidden doesn't do any hiding — it only pre-renders. + workInProgress.tag !== LegacyHiddenComponent ) { - workInProgress.flags |= Update; + workInProgress.flags |= Visibility; } - } // Don't bubble properties for hidden children. + } - if ( - !nextIsHidden || - includesSomeLane(subtreeRenderLanes, OffscreenLane) || - (workInProgress.mode & ConcurrentMode) === NoMode - ) { + if (!nextIsHidden || (workInProgress.mode & ConcurrentMode) === NoMode) { bubbleProperties(workInProgress); + } else { + // Don't bubble properties for hidden children unless we're rendering + // at offscreen priority. + if (includesSomeLane(subtreeRenderLanes, OffscreenLane)) { + bubbleProperties(workInProgress); + } } return null; @@ -17372,24 +17290,26 @@ function commitLayoutEffectOnFiber( finishedWork, committedLanes ) { - if ((finishedWork.flags & (Update | Callback)) !== NoFlags) { + if ((finishedWork.flags & LayoutMask) !== NoFlags) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - // At this point layout effects have already been destroyed (during mutation phase). - // This is done to prevent sibling component effects from interfering with each other, - // e.g. a destroy function in one component should never override a ref set - // by a create function in another component during the same commit. - if (finishedWork.mode & ProfileMode) { - try { - startLayoutEffectTimer(); + { + // At this point layout effects have already been destroyed (during mutation phase). + // This is done to prevent sibling component effects from interfering with each other, + // e.g. a destroy function in one component should never override a ref set + // by a create function in another component during the same commit. + if (finishedWork.mode & ProfileMode) { + try { + startLayoutEffectTimer(); + commitHookEffectListMount(Layout | HasEffect, finishedWork); + } finally { + recordLayoutEffectDuration(finishedWork); + } + } else { commitHookEffectListMount(Layout | HasEffect, finishedWork); - } finally { - recordLayoutEffectDuration(finishedWork); } - } else { - commitHookEffectListMount(Layout | HasEffect, finishedWork); } break; @@ -17399,104 +17319,109 @@ function commitLayoutEffectOnFiber( var instance = finishedWork.stateNode; if (finishedWork.flags & Update) { - if (current === null) { - // We could update instance props and state here, - // but instead we rely on them being set during last render. - // TODO: revisit this when we implement resuming. - { - if ( - finishedWork.type === finishedWork.elementType && - !didWarnAboutReassigningProps - ) { - if (instance.props !== finishedWork.memoizedProps) { - error( - "Expected %s props to match memoized props before " + - "componentDidMount. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentNameFromFiber(finishedWork) || "instance" - ); - } + { + if (current === null) { + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "componentDidMount. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentNameFromFiber(finishedWork) || "instance" + ); + } - if (instance.state !== finishedWork.memoizedState) { - error( - "Expected %s state to match memoized state before " + - "componentDidMount. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.state`. " + - "Please file an issue.", - getComponentNameFromFiber(finishedWork) || "instance" - ); + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "componentDidMount. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.state`. " + + "Please file an issue.", + getComponentNameFromFiber(finishedWork) || "instance" + ); + } } } - } - if (finishedWork.mode & ProfileMode) { - try { - startLayoutEffectTimer(); + if (finishedWork.mode & ProfileMode) { + try { + startLayoutEffectTimer(); + instance.componentDidMount(); + } finally { + recordLayoutEffectDuration(finishedWork); + } + } else { instance.componentDidMount(); - } finally { - recordLayoutEffectDuration(finishedWork); } } else { - instance.componentDidMount(); - } - } else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps(finishedWork.type, current.memoizedProps); - var prevState = current.memoizedState; // We could update instance props and state here, - // but instead we rely on them being set during last render. - // TODO: revisit this when we implement resuming. + var prevProps = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current.memoizedProps + ); + var prevState = current.memoizedState; // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. - { - if ( - finishedWork.type === finishedWork.elementType && - !didWarnAboutReassigningProps - ) { - if (instance.props !== finishedWork.memoizedProps) { - error( - "Expected %s props to match memoized props before " + - "componentDidUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentNameFromFiber(finishedWork) || "instance" - ); - } + { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentNameFromFiber(finishedWork) || "instance" + ); + } - if (instance.state !== finishedWork.memoizedState) { - error( - "Expected %s state to match memoized state before " + - "componentDidUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.state`. " + - "Please file an issue.", - getComponentNameFromFiber(finishedWork) || "instance" - ); + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.state`. " + + "Please file an issue.", + getComponentNameFromFiber(finishedWork) || "instance" + ); + } } } - } - if (finishedWork.mode & ProfileMode) { - try { - startLayoutEffectTimer(); + if (finishedWork.mode & ProfileMode) { + try { + startLayoutEffectTimer(); + instance.componentDidUpdate( + prevProps, + prevState, + instance.__reactInternalSnapshotBeforeUpdate + ); + } finally { + recordLayoutEffectDuration(finishedWork); + } + } else { instance.componentDidUpdate( prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate ); - } finally { - recordLayoutEffectDuration(finishedWork); } - } else { - instance.componentDidUpdate( - prevProps, - prevState, - instance.__reactInternalSnapshotBeforeUpdate - ); } } } // TODO: I think this is now always non-null by the time it reaches the @@ -17677,8 +17602,10 @@ function commitLayoutEffectOnFiber( } { - if (finishedWork.flags & Ref) { - commitAttachRef(finishedWork); + { + if (finishedWork.flags & Ref) { + commitAttachRef(finishedWork); + } } } } @@ -18005,6 +17932,11 @@ function commitWork(current, finishedWork) { // This prevents sibling component effects from interfering with each other, // e.g. a destroy function in one component should never override a ref set // by a create function in another component during the same commit. + // TODO: Check if we're inside an Offscreen subtree that disappeared + // during this commit. If so, we would have already unmounted its + // layout hooks. (However, since we null out the `destroy` function + // right before calling it, the behavior is already correct, so this + // would mostly be for modeling purposes.) if (finishedWork.mode & ProfileMode) { try { startLayoutEffectTimer(); @@ -18032,7 +17964,7 @@ function commitWork(current, finishedWork) { } case SuspenseComponent: { - commitSuspenseComponent(finishedWork); + commitSuspenseCallback(finishedWork); attachSuspenseRetryListeners(finishedWork); return; } @@ -18057,12 +17989,9 @@ function commitWork(current, finishedWork) { } } -function commitSuspenseComponent(finishedWork) { +function commitSuspenseCallback(finishedWork) { + // TODO: Move this to passive phase var newState = finishedWork.memoizedState; - - if (newState !== null) { - markCommitTimeOfFallback(); - } } function attachSuspenseRetryListeners(finishedWork) { @@ -18170,6 +18099,10 @@ function commitMutationEffects_complete(root) { } function commitMutationEffectsOnFiber(finishedWork, root) { + // TODO: The factoring of this phase could probably be improved. Consider + // switching on the type of work before checking the flags. That's what + // we do in all the other phases. I think this one is only different + // because of the shared reconcilation logic below. var flags = finishedWork.flags; if (flags & Ref) { @@ -18178,6 +18111,35 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (current !== null) { commitDetachRef(current); } + } + + if (flags & Visibility) { + switch (finishedWork.tag) { + case SuspenseComponent: { + var newState = finishedWork.memoizedState; + var isHidden = newState !== null; + + if (isHidden) { + var _current = finishedWork.alternate; + var wasHidden = _current !== null && _current.memoizedState !== null; + + if (!wasHidden) { + // TODO: Move to passive phase + markCommitTimeOfFallback(); + } + } + + break; + } + + case OffscreenComponent: { + var _newState = finishedWork.memoizedState; + + var _current2 = finishedWork.alternate; + + var _wasHidden = _current2 !== null && _current2.memoizedState !== null; + } + } } // The following switch statement is only concerned about placement, // updates, and deletions. To avoid needing to add a case for every possible // bitmap value, we remove the secondary effects from the effect tag and @@ -18200,8 +18162,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { finishedWork.flags &= ~Placement; // Update - var _current = finishedWork.alternate; - commitWork(_current, finishedWork); + var _current3 = finishedWork.alternate; + commitWork(_current3, finishedWork); break; } @@ -18213,14 +18175,14 @@ function commitMutationEffectsOnFiber(finishedWork, root) { case HydratingAndUpdate: { finishedWork.flags &= ~Hydrating; // Update - var _current2 = finishedWork.alternate; - commitWork(_current2, finishedWork); + var _current4 = finishedWork.alternate; + commitWork(_current4, finishedWork); break; } case Update: { - var _current3 = finishedWork.alternate; - commitWork(_current3, finishedWork); + var _current5 = finishedWork.alternate; + commitWork(_current5, finishedWork); break; } } @@ -18253,9 +18215,6 @@ function commitLayoutEffects_begin(subtreeRoot, root, committedLanes) { } function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) { - // Suspense layout effects semantics don't change for legacy roots. - var isModernRoot = (subtreeRoot.mode & ConcurrentMode) !== NoMode; - while (nextEffect !== null) { var fiber = nextEffect; @@ -18569,7 +18528,7 @@ function ensureCorrectReturnPointer(fiber, expectedReturnFiber) { // anything, by checking the warning logs for the above invariant fiber.return = expectedReturnFiber; -} +} // TODO: Reuse reappearLayoutEffects traversal here? function invokeLayoutEffectMountInDEV(fiber) { { @@ -18706,18 +18665,15 @@ var NoContext = var BatchedContext = /* */ 1; -var LegacyUnbatchedContext = - /* */ - 4; var RenderContext = /* */ - 8; + 2; var CommitContext = /* */ - 16; + 4; var RetryAfterError = /* */ - 32; + 8; var RootIncomplete = 0; var RootFatalErrored = 1; var RootErrored = 2; @@ -18930,35 +18886,21 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { } } - if (lane === SyncLane) { - if ( - // Check if we're inside unbatchedUpdates - (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering - (executionContext & (RenderContext | CommitContext)) === NoContext - ) { - // This is a legacy edge case. The initial mount of a ReactDOM.render-ed - // root inside of batchedUpdates should be synchronous, but layout updates - // should be deferred until the end of the batch. - performSyncWorkOnRoot(root); - } else { - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root, eventTime); - if ( - executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode - ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); - } - } - } else { - // Schedule other updates after in case the callback is sync. - ensureRootIsScheduled(root, eventTime); + if ( + lane === SyncLane && + executionContext === NoContext && + (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + !ReactCurrentActQueue.isBatchingLegacy + ) { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncCallbacksOnlyInLegacyMode(); } return root; @@ -19095,6 +19037,10 @@ function ensureRootIsScheduled(root, currentTime) { // Special case: Sync React callbacks are scheduled on a special // internal queue if (root.tag === LegacyRoot) { + if (ReactCurrentActQueue.isBatchingLegacy !== null) { + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } + scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); } else { scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); @@ -19193,6 +19139,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if (exitStatus !== RootIncomplete) { if (exitStatus === RootErrored) { + var prevExecutionContext = executionContext; executionContext |= RetryAfterError; // If an error occurred during hydration, // discard server response and fall back to client side render. @@ -19215,6 +19162,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { lanes = errorRetryLanes; exitStatus = renderRootSync(root, errorRetryLanes); } + + executionContext = prevExecutionContext; } if (exitStatus === RootFatalErrored) { @@ -19393,6 +19342,7 @@ function performSyncWorkOnRoot(root) { var exitStatus = renderRootSync(root, lanes); if (root.tag !== LegacyRoot && exitStatus === RootErrored) { + var prevExecutionContext = executionContext; executionContext |= RetryAfterError; // If an error occurred during hydration, // discard server response and fall back to client side render. @@ -19415,6 +19365,8 @@ function performSyncWorkOnRoot(root) { lanes = errorRetryLanes; exitStatus = renderRootSync(root, lanes); } + + executionContext = prevExecutionContext; } if (exitStatus === RootFatalErrored) { @@ -19445,13 +19397,29 @@ function batchedUpdates$1(fn, a) { executionContext = prevExecutionContext; // If there were legacy sync updates, flush them at the end of the outer // most batchedUpdates-like method. - if (executionContext === NoContext) { + if ( + executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + !ReactCurrentActQueue.isBatchingLegacy + ) { resetRenderTimer(); flushSyncCallbacksOnlyInLegacyMode(); } } } -function flushSync(fn, a) { +// Warning, this opts-out of checking the function body. + +// eslint-disable-next-line no-redeclare +function flushSyncWithoutWarningIfAlreadyRendering(fn) { + // In legacy mode, we flush pending passive effects at the beginning of the + // next event, not at the end of the previous one. + if ( + rootWithPendingPassiveEffects !== null && + rootWithPendingPassiveEffects.tag === LegacyRoot && + (executionContext & (RenderContext | CommitContext)) === NoContext + ) { + flushPassiveEffects(); + } + var prevExecutionContext = executionContext; executionContext |= BatchedContext; var prevTransition = ReactCurrentBatchConfig$2.transition; @@ -19462,7 +19430,7 @@ function flushSync(fn, a) { setCurrentUpdatePriority(DiscreteEventPriority); if (fn) { - return fn(a); + return fn(); } else { return undefined; } @@ -19475,16 +19443,24 @@ function flushSync(fn, a) { if ((executionContext & (RenderContext | CommitContext)) === NoContext) { flushSyncCallbacks(); - } else { - { - error( - "flushSync was called from inside a lifecycle method. React cannot " + - "flush when React is already rendering. Consider moving this call to " + - "a scheduler task or micro task." - ); - } } } +} // Overload the definition to the two valid signatures. +// Warning, this opts-out of checking the function body. + +// eslint-disable-next-line no-redeclare +function flushSync(fn) { + { + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + error( + "flushSync was called from inside a lifecycle method. React cannot " + + "flush when React is already rendering. Consider moving this call to " + + "a scheduler task or micro task." + ); + } + } + + return flushSyncWithoutWarningIfAlreadyRendering(fn); } function pushRenderLanes(fiber, lanes) { push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); @@ -20123,14 +20099,6 @@ function commitRootImpl(root, renderPriorityLevel) { var error$1 = firstUncaughtError; firstUncaughtError = null; throw error$1; - } - - if ((executionContext & LegacyUnbatchedContext) !== NoContext) { - // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired - // synchronously, but layout updates should be deferred until the end - // of the batch. - - return null; } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is // immediately observable. Otherwise, we assume that they are not @@ -22497,65 +22465,16 @@ var emptyObject$1 = {}; Object.freeze(emptyObject$1); } -var getInspectorDataForViewTag; -var getInspectorDataForViewAtPoint; +var createHierarchy; +var getHostNode; +var getHostProps; +var lastNonHostInstance; + +var getOwnerHierarchy; +var traverseOwnerTreeUp; { - var traverseOwnerTreeUp = function(hierarchy, instance) { - if (instance) { - hierarchy.unshift(instance); - traverseOwnerTreeUp(hierarchy, instance._debugOwner); - } - }; - - var getOwnerHierarchy = function(instance) { - var hierarchy = []; - traverseOwnerTreeUp(hierarchy, instance); - return hierarchy; - }; - - var lastNonHostInstance = function(hierarchy) { - for (var i = hierarchy.length - 1; i > 1; i--) { - var instance = hierarchy[i]; - - if (instance.tag !== HostComponent) { - return instance; - } - } - - return hierarchy[0]; - }; - - var getHostProps = function(fiber) { - var host = findCurrentHostFiber(fiber); - - if (host) { - return host.memoizedProps || emptyObject$1; - } - - return emptyObject$1; - }; - - var getHostNode = function(fiber, findNodeHandle) { - var hostNode; // look for children first for the hostNode - // as composite fibers do not have a hostNode - - while (fiber) { - if (fiber.stateNode !== null && fiber.tag === HostComponent) { - hostNode = findNodeHandle(fiber.stateNode); - } - - if (hostNode) { - return hostNode; - } - - fiber = fiber.child; - } - - return null; - }; - - var createHierarchy = function(fiberHierarchy) { + createHierarchy = function(fiberHierarchy) { return fiberHierarchy.map(function(fiber) { return { name: getComponentNameFromType(fiber.type), @@ -22586,7 +22505,36 @@ var getInspectorDataForViewAtPoint; }); }; - var getInspectorDataForInstance = function(closestInstance) { + getHostNode = function(fiber, findNodeHandle) { + var hostNode; // look for children first for the hostNode + // as composite fibers do not have a hostNode + + while (fiber) { + if (fiber.stateNode !== null && fiber.tag === HostComponent) { + hostNode = findNodeHandle(fiber.stateNode); + } + + if (hostNode) { + return hostNode; + } + + fiber = fiber.child; + } + + return null; + }; + + getHostProps = function(fiber) { + var host = findCurrentHostFiber(fiber); + + if (host) { + return host.memoizedProps || emptyObject$1; + } + + return emptyObject$1; + }; + + exports.getInspectorDataForInstance = function(closestInstance) { // Handle case where user clicks outside of ReactNative if (!closestInstance) { return { @@ -22612,6 +22560,36 @@ var getInspectorDataForViewAtPoint; }; }; + getOwnerHierarchy = function(instance) { + var hierarchy = []; + traverseOwnerTreeUp(hierarchy, instance); + return hierarchy; + }; + + lastNonHostInstance = function(hierarchy) { + for (var i = hierarchy.length - 1; i > 1; i--) { + var instance = hierarchy[i]; + + if (instance.tag !== HostComponent) { + return instance; + } + } + + return hierarchy[0]; + }; + + traverseOwnerTreeUp = function(hierarchy, instance) { + if (instance) { + hierarchy.unshift(instance); + traverseOwnerTreeUp(hierarchy, instance._debugOwner); + } + }; +} + +var getInspectorDataForViewTag; +var getInspectorDataForViewAtPoint; + +{ getInspectorDataForViewTag = function(viewTag) { var closestInstance = getInstanceFromTag(viewTag); // Handle case where user clicks outside of ReactNative @@ -22667,7 +22645,7 @@ var getInspectorDataForViewAtPoint; height: 0 } }, - getInspectorDataForInstance(closestInstance) + exports.getInspectorDataForInstance(closestInstance) ) ); } @@ -22680,7 +22658,9 @@ var getInspectorDataForViewAtPoint; nativeFabricUIManager.measure( internalInstanceHandle.stateNode.node, function(x, y, width, height, pageX, pageY) { - var inspectorData = getInspectorDataForInstance(closestInstance); + var inspectorData = exports.getInspectorDataForInstance( + closestInstance + ); callback( Object.assign({}, inspectorData, { pointerY: locationY, @@ -22703,7 +22683,7 @@ var getInspectorDataForViewAtPoint; findNodeHandle(inspectedView), [locationX, locationY], function(nativeViewTag, left, top, width, height) { - var inspectorData = getInspectorDataForInstance( + var inspectorData = exports.getInspectorDataForInstance( getInstanceFromTag(nativeViewTag) ); callback( @@ -22858,12 +22838,12 @@ function dispatchCommand(handle, command, args) { return; } - if (handle._internalInstanceHandle) { - nativeFabricUIManager.dispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ); + if (handle._internalInstanceHandle != null) { + var stateNode = handle._internalInstanceHandle.stateNode; + + if (stateNode != null) { + nativeFabricUIManager.dispatchCommand(stateNode.node, command, args); + } } else { ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( handle._nativeTag, @@ -22885,11 +22865,12 @@ function sendAccessibilityEvent(handle, eventType) { return; } - if (handle._internalInstanceHandle) { - nativeFabricUIManager.sendAccessibilityEvent( - handle._internalInstanceHandle.stateNode.node, - eventType - ); + if (handle._internalInstanceHandle != null) { + var stateNode = handle._internalInstanceHandle.stateNode; + + if (stateNode != null) { + nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType); + } } else { ReactNativePrivateInterface.legacySendAccessibilityEvent( handle._nativeTag, diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 4991274c2d..829170b1fe 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<<065d375daf77622fdbba58722ce9d961>> + * @generated SignedSource<<8066df1aa410b680ab0fb087ce46a9a4>> */ "use strict"; @@ -930,7 +930,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_216 = { +var injectedNamesToPlugins$jscomp$inline_220 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -965,34 +965,34 @@ var injectedNamesToPlugins$jscomp$inline_216 = { } } }, - isOrderingDirty$jscomp$inline_217 = !1, - pluginName$jscomp$inline_218; -for (pluginName$jscomp$inline_218 in injectedNamesToPlugins$jscomp$inline_216) + isOrderingDirty$jscomp$inline_221 = !1, + pluginName$jscomp$inline_222; +for (pluginName$jscomp$inline_222 in injectedNamesToPlugins$jscomp$inline_220) if ( - injectedNamesToPlugins$jscomp$inline_216.hasOwnProperty( - pluginName$jscomp$inline_218 + injectedNamesToPlugins$jscomp$inline_220.hasOwnProperty( + pluginName$jscomp$inline_222 ) ) { - var pluginModule$jscomp$inline_219 = - injectedNamesToPlugins$jscomp$inline_216[pluginName$jscomp$inline_218]; + var pluginModule$jscomp$inline_223 = + injectedNamesToPlugins$jscomp$inline_220[pluginName$jscomp$inline_222]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_218) || - namesToPlugins[pluginName$jscomp$inline_218] !== - pluginModule$jscomp$inline_219 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_222) || + namesToPlugins[pluginName$jscomp$inline_222] !== + pluginModule$jscomp$inline_223 ) { - if (namesToPlugins[pluginName$jscomp$inline_218]) + if (namesToPlugins[pluginName$jscomp$inline_222]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_218 + + pluginName$jscomp$inline_222 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_218 - ] = pluginModule$jscomp$inline_219; - isOrderingDirty$jscomp$inline_217 = !0; + pluginName$jscomp$inline_222 + ] = pluginModule$jscomp$inline_223; + isOrderingDirty$jscomp$inline_221 = !0; } } -isOrderingDirty$jscomp$inline_217 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_221 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -2216,7 +2216,7 @@ function enqueueUpdate(fiber, update) { ((updateQueue = updateQueue.shared), null !== workInProgressRoot && 0 !== (fiber.mode & 1) && - 0 === (executionContext & 8) + 0 === (executionContext & 2) ? ((fiber = updateQueue.interleaved), null === fiber ? ((update.next = update), @@ -3053,60 +3053,49 @@ function ChildReconciler(shouldTrackSideEffects) { return iteratorFn; } return function(returnFiber, currentFirstChild, newChild, lanes) { - var isUnkeyedTopLevelFragment = - "object" === typeof newChild && + "object" === typeof newChild && null !== newChild && newChild.type === REACT_FRAGMENT_TYPE && - null === newChild.key; - isUnkeyedTopLevelFragment && (newChild = newChild.props.children); + null === newChild.key && + (newChild = newChild.props.children); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: a: { - var key = newChild.key; for ( - isUnkeyedTopLevelFragment = currentFirstChild; - null !== isUnkeyedTopLevelFragment; + var key = newChild.key, child = currentFirstChild; + null !== child; ) { - if (isUnkeyedTopLevelFragment.key === key) { + if (child.key === key) { key = newChild.type; if (key === REACT_FRAGMENT_TYPE) { - if (7 === isUnkeyedTopLevelFragment.tag) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); + if (7 === child.tag) { + deleteRemainingChildren(returnFiber, child.sibling); currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, + child, newChild.props.children ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; } - } else if (isUnkeyedTopLevelFragment.elementType === key) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props - ); + } else if (child.elementType === key) { + deleteRemainingChildren(returnFiber, child.sibling); + currentFirstChild = useFiber(child, newChild.props); currentFirstChild.ref = coerceRef( returnFiber, - isUnkeyedTopLevelFragment, + child, newChild ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; } - deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, child); break; - } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); - isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; + } else deleteChild(returnFiber, child); + child = child.sibling; } newChild.type === REACT_FRAGMENT_TYPE ? ((currentFirstChild = createFiberFromFragment( @@ -3136,12 +3125,8 @@ function ChildReconciler(shouldTrackSideEffects) { return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: a: { - for ( - isUnkeyedTopLevelFragment = newChild.key; - null !== currentFirstChild; - - ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + for (child = newChild.key; null !== currentFirstChild; ) { + if (currentFirstChild.key === child) if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -3193,9 +3178,8 @@ function ChildReconciler(shouldTrackSideEffects) { ); throwOnInvalidObjectType(returnFiber, newChild); } - if ("string" === typeof newChild || "number" === typeof newChild) - return ( - (newChild = "" + newChild), + return "string" === typeof newChild || "number" === typeof newChild + ? ((newChild = "" + newChild), null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber(currentFirstChild, newChild)), @@ -3209,20 +3193,8 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), - placeSingleChild(returnFiber) - ); - if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) - switch (returnFiber.tag) { - case 1: - case 0: - case 11: - case 15: - throw Error( - (getComponentNameFromFiber(returnFiber) || "Component") + - "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - ); - } - return deleteRemainingChildren(returnFiber, currentFirstChild); + placeSingleChild(returnFiber)) + : deleteRemainingChildren(returnFiber, currentFirstChild); }; } var reconcileChildFibers = ChildReconciler(!0), @@ -3777,7 +3749,7 @@ function dispatchAction(fiber, queue, action) { if ( null !== workInProgressRoot && 0 !== (fiber.mode & 1) && - 0 === (executionContext & 8) + 0 === (executionContext & 2) ) { var interleaved = queue.interleaved; null === interleaved @@ -4573,7 +4545,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { JSCompiler_temp ? ((showFallback = !0), (workInProgress.flags &= -129)) : (null !== current && null === current.memoizedState) || - void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); @@ -4938,32 +4909,16 @@ appendAllChildren = function( if (needsVisibilityToggle && isHidden) throw Error("Not yet implemented."); appendChildNode(parent.node, instance.node); - } else if (4 !== node.tag) { - if ( - 13 === node.tag && - 0 !== (node.flags & 4) && - (instance = null !== node.memoizedState) - ) { - var primaryChildParent = node.child; - if ( - null !== primaryChildParent && - (null !== primaryChildParent.child && - ((primaryChildParent.child.return = primaryChildParent), - appendAllChildren(parent, primaryChildParent, !0, instance)), - (instance = primaryChildParent.sibling), - null !== instance) - ) { - instance.return = node; - node = instance; - continue; - } - } - if (null !== node.child) { + } else if (4 !== node.tag) + if (22 === node.tag && null !== node.memoizedState) + (instance = node.child), + null !== instance && (instance.return = node), + appendAllChildren(parent, node, !0, !0); + else if (null !== node.child) { node.child.return = node; node = node.child; continue; } - } if (node === workInProgress) break; for (; null === node.sibling; ) { if (null === node.return || node.return === workInProgress) return; @@ -4991,37 +4946,16 @@ function appendAllChildrenToContainer( if (needsVisibilityToggle && isHidden) throw Error("Not yet implemented."); appendChildNodeToSet(containerChildSet, instance.node); - } else if (4 !== node.tag) { - if ( - 13 === node.tag && - 0 !== (node.flags & 4) && - (instance = null !== node.memoizedState) - ) { - var primaryChildParent = node.child; - if ( - null !== primaryChildParent && - (null !== primaryChildParent.child && - ((primaryChildParent.child.return = primaryChildParent), - appendAllChildrenToContainer( - containerChildSet, - primaryChildParent, - !0, - instance - )), - (instance = primaryChildParent.sibling), - null !== instance) - ) { - instance.return = node; - node = instance; - continue; - } - } - if (null !== node.child) { + } else if (4 !== node.tag) + if (22 === node.tag && null !== node.memoizedState) + (instance = node.child), + null !== instance && (instance.return = node), + appendAllChildrenToContainer(containerChildSet, node, !0, !0); + else if (null !== node.child) { node.child.return = node; node = node.child; continue; } - } if (node === workInProgress) break; for (; null === node.sibling; ) { if (null === node.return || node.return === workInProgress) return; @@ -5262,10 +5196,13 @@ function completeWork(current, workInProgress, renderLanes) { newProps = workInProgress.memoizedState; if (0 !== (workInProgress.flags & 128)) return (workInProgress.lanes = renderLanes), workInProgress; - newProps = null !== newProps; renderLanes = !1; null !== current && (renderLanes = null !== current.memoizedState); - if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1)) + if ( + null !== newProps && + !renderLanes && + ((workInProgress.child.flags |= 4096), 0 !== (workInProgress.mode & 1)) + ) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || @@ -5287,7 +5224,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootRenderLanes ); } - newProps && (workInProgress.flags |= 4); + null !== workInProgress.updateQueue && (workInProgress.flags |= 4); bubbleProperties(workInProgress); return null; case 4: @@ -5439,11 +5376,12 @@ function completeWork(current, workInProgress, renderLanes) { null !== current && (null !== current.memoizedState) !== renderLanes && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.flags |= 4), - (renderLanes && - 0 === (subtreeRenderLanes & 1073741824) && - 0 !== (workInProgress.mode & 1)) || - bubbleProperties(workInProgress), + 23 !== workInProgress.tag && + (workInProgress.flags |= 4096), + renderLanes && 0 !== (workInProgress.mode & 1) + ? 0 !== (subtreeRenderLanes & 1073741824) && + bubbleProperties(workInProgress) + : bubbleProperties(workInProgress), null ); } @@ -5640,8 +5578,6 @@ function commitWork(current, finishedWork) { case 12: return; case 13: - null !== finishedWork.memoizedState && - (globalMostRecentFallbackTime = now()); attachSuspenseRetryListeners(finishedWork); return; case 19: @@ -5788,6 +5724,15 @@ function commitMutationEffects(root, firstChild) { : (currentRef.current = null)); } } + if (flags & 4096) + switch (root.tag) { + case 13: + if (null !== root.memoizedState) { + var current$86 = root.alternate; + if (null === current$86 || null === current$86.memoizedState) + globalMostRecentFallbackTime = now(); + } + } switch (flags & 2054) { case 2: root.flags &= -3; @@ -5823,15 +5768,15 @@ function commitLayoutEffects(finishedWork) { for (nextEffect = finishedWork; null !== nextEffect; ) { var fiber = nextEffect, firstChild = fiber.child; - if (0 !== (fiber.subtreeFlags & 324) && null !== firstChild) + if (0 !== (fiber.subtreeFlags & 4420) && null !== firstChild) (firstChild.return = fiber), (nextEffect = firstChild); else for (fiber = finishedWork; null !== nextEffect; ) { firstChild = nextEffect; - if (0 !== (firstChild.flags & 324)) { + if (0 !== (firstChild.flags & 4420)) { var current = firstChild.alternate; try { - if (0 !== (firstChild.flags & 68)) + if (0 !== (firstChild.flags & 4420)) switch (firstChild.tag) { case 0: case 11: @@ -5960,7 +5905,7 @@ var ceil = Math.ceil, currentEventTime = -1, currentEventTransitionLane = 0; function requestEventTime() { - return 0 !== (executionContext & 24) + return 0 !== (executionContext & 6) ? now() : -1 !== currentEventTime ? currentEventTime @@ -5968,7 +5913,7 @@ function requestEventTime() { } function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 1; - if (0 !== (executionContext & 8) && 0 !== workInProgressRootRenderLanes) + if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; if (0 !== ReactCurrentBatchConfig.transition) return ( @@ -6006,18 +5951,15 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { if (null === root) return null; markRootUpdated(root, lane, eventTime); root === workInProgressRoot && - (0 === (executionContext & 8) && (workInProgressRootUpdatedLanes |= lane), + (0 === (executionContext & 2) && (workInProgressRootUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended$1(root, workInProgressRootRenderLanes)); - 1 === lane - ? 0 !== (executionContext & 4) && 0 === (executionContext & 24) - ? performSyncWorkOnRoot(root) - : (ensureRootIsScheduled(root, eventTime), - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks())) - : ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6107,7 +6049,7 @@ function ensureRootIsScheduled(root, currentTime) { function performConcurrentWorkOnRoot(root, didTimeout) { currentEventTime = -1; currentEventTransitionLane = 0; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); var originalCallbackNode = root.callbackNode; if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) @@ -6126,7 +6068,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if (JSCompiler_inline_result && !didTimeout) { didTimeout = lanes; JSCompiler_inline_result = executionContext; - executionContext |= 8; + executionContext |= 2; var prevDispatcher = pushDispatcher(); if ( workInProgressRoot !== root || @@ -6153,12 +6095,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } else didTimeout = renderRootSync(root, lanes); if (0 !== didTimeout) { 2 === didTimeout && - ((executionContext |= 32), + ((JSCompiler_inline_result = executionContext), + (executionContext |= 8), root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), - (JSCompiler_inline_result = getLanesToRetrySynchronouslyOnError(root)), - 0 !== JSCompiler_inline_result && - ((lanes = JSCompiler_inline_result), - (didTimeout = renderRootSync(root, JSCompiler_inline_result)))); + (prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), + 0 !== prevDispatcher && + ((lanes = prevDispatcher), + (didTimeout = renderRootSync(root, prevDispatcher))), + (executionContext = JSCompiler_inline_result)); if (1 === didTimeout) throw ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), @@ -6258,18 +6202,20 @@ function markRootSuspended$1(root, suspendedLanes) { } } function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); flushPassiveEffects(); var lanes = getNextLanes(root, 0); if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null; var exitStatus = renderRootSync(root, lanes); if (0 !== root.tag && 2 === exitStatus) { - executionContext |= 32; + var prevExecutionContext = executionContext; + executionContext |= 8; root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); + executionContext = prevExecutionContext; } if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), @@ -6417,19 +6363,17 @@ function handleError(root$jscomp$0, thrownValue) { var JSCompiler_temp; if ((JSCompiler_temp = 13 === workInProgress$30.tag)) { var nextState = workInProgress$30.memoizedState; - if (null !== nextState) - JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; - else { - var props = workInProgress$30.memoizedProps; - JSCompiler_temp = - void 0 === props.fallback - ? !1 - : !0 !== props.unstable_avoidThisFallback + JSCompiler_temp = + null !== nextState + ? null !== nextState.dehydrated ? !0 - : hasInvisibleParentBoundary - ? !1 - : !0; - } + : !1 + : !0 !== + workInProgress$30.memoizedProps.unstable_avoidThisFallback + ? !0 + : hasInvisibleParentBoundary + ? !1 + : !0; } if (JSCompiler_temp) { var wakeables = workInProgress$30.updateQueue; @@ -6549,7 +6493,7 @@ function pushDispatcher() { } function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; - executionContext |= 8; + executionContext |= 2; var prevDispatcher = pushDispatcher(); (workInProgressRoot === root && workInProgressRootRenderLanes === lanes) || prepareFreshStack(root, lanes); @@ -6635,7 +6579,7 @@ function commitRoot(root) { function commitRootImpl(root, renderPriorityLevel) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); var finishedWork = root.finishedWork, lanes = root.finishedLanes; @@ -6668,7 +6612,7 @@ function commitRootImpl(root, renderPriorityLevel) { var previousPriority = currentUpdatePriority; currentUpdatePriority = 1; var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= 4; ReactCurrentOwner$2.current = null; commitBeforeMutationEffects(root, finishedWork); commitMutationEffects(root, finishedWork); @@ -6697,7 +6641,6 @@ function commitRootImpl(root, renderPriorityLevel) { (root = firstUncaughtError), (firstUncaughtError = null), root); - if (0 !== (executionContext & 4)) return null; 0 !== (pendingPassiveEffectsLanes & 1) && 0 !== root.tag && flushPassiveEffects(); @@ -6718,10 +6661,10 @@ function flushPassiveEffects() { renderPriority = rootWithPendingPassiveEffects; rootWithPendingPassiveEffects = null; pendingPassiveEffectsLanes = 0; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= 4; for (nextEffect = renderPriority.current; null !== nextEffect; ) { var fiber = nextEffect, child = fiber.child; @@ -7731,6 +7674,95 @@ function updateContainer(element, container, parentComponent, callback) { function emptyFindFiberByHostInstance() { return null; } +var emptyObject$1 = {}, + createHierarchy, + getHostNode, + getHostProps, + lastNonHostInstance, + getOwnerHierarchy, + traverseOwnerTreeUp; +createHierarchy = function(fiberHierarchy) { + return fiberHierarchy.map(function(fiber) { + return { + name: getComponentNameFromType(fiber.type), + getInspectorData: function(findNodeHandle) { + return { + props: getHostProps(fiber), + source: fiber._debugSource, + measure: function(callback) { + var hostFiber = findCurrentHostFiber(fiber); + if ( + (hostFiber = + null != hostFiber && + null !== hostFiber.stateNode && + hostFiber.stateNode.node) + ) + nativeFabricUIManager.measure(hostFiber, callback); + else + return ReactNativePrivateInterface.UIManager.measure( + getHostNode(fiber, findNodeHandle), + callback + ); + } + }; + } + }; + }); +}; +getHostNode = function(fiber, findNodeHandle) { + for (var hostNode; fiber; ) { + null !== fiber.stateNode && + 5 === fiber.tag && + (hostNode = findNodeHandle(fiber.stateNode)); + if (hostNode) return hostNode; + fiber = fiber.child; + } + return null; +}; +getHostProps = function(fiber) { + return (fiber = findCurrentHostFiber(fiber)) + ? fiber.memoizedProps || emptyObject$1 + : emptyObject$1; +}; +exports.getInspectorDataForInstance = function(closestInstance) { + if (!closestInstance) + return { + hierarchy: [], + props: emptyObject$1, + selectedIndex: null, + source: null + }; + closestInstance = findCurrentFiberUsingSlowPath(closestInstance); + var fiberHierarchy = getOwnerHierarchy(closestInstance), + instance = lastNonHostInstance(fiberHierarchy); + closestInstance = createHierarchy(fiberHierarchy); + var props = getHostProps(instance), + source = instance._debugSource; + fiberHierarchy = fiberHierarchy.indexOf(instance); + return { + hierarchy: closestInstance, + props: props, + selectedIndex: fiberHierarchy, + source: source + }; +}; +getOwnerHierarchy = function(instance) { + var hierarchy = []; + traverseOwnerTreeUp(hierarchy, instance); + return hierarchy; +}; +lastNonHostInstance = function(hierarchy) { + for (var i = hierarchy.length - 1; 1 < i; i--) { + var instance = hierarchy[i]; + if (5 !== instance.tag) return instance; + } + return hierarchy[0]; +}; +traverseOwnerTreeUp = function(hierarchy, instance) { + instance && + (hierarchy.unshift(instance), + traverseOwnerTreeUp(hierarchy, instance._debugOwner)); +}; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; @@ -7757,10 +7789,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_939 = { + devToolsConfig$jscomp$inline_949 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-cae635054-20210626", + version: "18.0.0-419cc9c37-20210726", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -7775,11 +7807,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1177 = { - bundleType: devToolsConfig$jscomp$inline_939.bundleType, - version: devToolsConfig$jscomp$inline_939.version, - rendererPackageName: devToolsConfig$jscomp$inline_939.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_939.rendererConfig, +var internals$jscomp$inline_1186 = { + bundleType: devToolsConfig$jscomp$inline_949.bundleType, + version: devToolsConfig$jscomp$inline_949.version, + rendererPackageName: devToolsConfig$jscomp$inline_949.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_949.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -7795,26 +7827,26 @@ var internals$jscomp$inline_1177 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_939.findFiberByHostInstance || + devToolsConfig$jscomp$inline_949.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-cae635054-20210626" + reconcilerVersion: "18.0.0-419cc9c37-20210726" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1178 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1187 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1178.isDisabled && - hook$jscomp$inline_1178.supportsFiber + !hook$jscomp$inline_1187.isDisabled && + hook$jscomp$inline_1187.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1178.inject( - internals$jscomp$inline_1177 + (rendererID = hook$jscomp$inline_1187.inject( + internals$jscomp$inline_1186 )), - (injectedHook = hook$jscomp$inline_1178); + (injectedHook = hook$jscomp$inline_1187); } catch (err) {} } exports.createPortal = function(children, containerTag) { @@ -7827,12 +7859,10 @@ exports.createPortal = function(children, containerTag) { }; exports.dispatchCommand = function(handle, command, args) { null != handle._nativeTag && - (handle._internalInstanceHandle - ? nativeFabricUIManager.dispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ) + (null != handle._internalInstanceHandle + ? ((handle = handle._internalInstanceHandle.stateNode), + null != handle && + nativeFabricUIManager.dispatchCommand(handle.node, command, args)) : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( handle._nativeTag, command, @@ -7878,11 +7908,10 @@ exports.render = function(element, containerTag, callback, concurrentRoot) { }; exports.sendAccessibilityEvent = function(handle, eventType) { null != handle._nativeTag && - (handle._internalInstanceHandle - ? nativeFabricUIManager.sendAccessibilityEvent( - handle._internalInstanceHandle.stateNode.node, - eventType - ) + (null != handle._internalInstanceHandle + ? ((handle = handle._internalInstanceHandle.stateNode), + null != handle && + nativeFabricUIManager.sendAccessibilityEvent(handle.node, eventType)) : ReactNativePrivateInterface.legacySendAccessibilityEvent( handle._nativeTag, eventType diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index ac6cbca15c..6163d4f5d1 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<<6166092fac6dde5ba6dc59392f7ac520>> + * @generated SignedSource<> */ "use strict"; @@ -930,7 +930,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_224 = { +var injectedNamesToPlugins$jscomp$inline_228 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -965,34 +965,34 @@ var injectedNamesToPlugins$jscomp$inline_224 = { } } }, - isOrderingDirty$jscomp$inline_225 = !1, - pluginName$jscomp$inline_226; -for (pluginName$jscomp$inline_226 in injectedNamesToPlugins$jscomp$inline_224) + isOrderingDirty$jscomp$inline_229 = !1, + pluginName$jscomp$inline_230; +for (pluginName$jscomp$inline_230 in injectedNamesToPlugins$jscomp$inline_228) if ( - injectedNamesToPlugins$jscomp$inline_224.hasOwnProperty( - pluginName$jscomp$inline_226 + injectedNamesToPlugins$jscomp$inline_228.hasOwnProperty( + pluginName$jscomp$inline_230 ) ) { - var pluginModule$jscomp$inline_227 = - injectedNamesToPlugins$jscomp$inline_224[pluginName$jscomp$inline_226]; + var pluginModule$jscomp$inline_231 = + injectedNamesToPlugins$jscomp$inline_228[pluginName$jscomp$inline_230]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_226) || - namesToPlugins[pluginName$jscomp$inline_226] !== - pluginModule$jscomp$inline_227 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_230) || + namesToPlugins[pluginName$jscomp$inline_230] !== + pluginModule$jscomp$inline_231 ) { - if (namesToPlugins[pluginName$jscomp$inline_226]) + if (namesToPlugins[pluginName$jscomp$inline_230]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_226 + + pluginName$jscomp$inline_230 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_226 - ] = pluginModule$jscomp$inline_227; - isOrderingDirty$jscomp$inline_225 = !0; + pluginName$jscomp$inline_230 + ] = pluginModule$jscomp$inline_231; + isOrderingDirty$jscomp$inline_229 = !0; } } -isOrderingDirty$jscomp$inline_225 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_229 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -2264,7 +2264,7 @@ function enqueueUpdate(fiber, update) { ((updateQueue = updateQueue.shared), null !== workInProgressRoot && 0 !== (fiber.mode & 1) && - 0 === (executionContext & 8) + 0 === (executionContext & 2) ? ((fiber = updateQueue.interleaved), null === fiber ? ((update.next = update), @@ -3101,60 +3101,49 @@ function ChildReconciler(shouldTrackSideEffects) { return iteratorFn; } return function(returnFiber, currentFirstChild, newChild, lanes) { - var isUnkeyedTopLevelFragment = - "object" === typeof newChild && + "object" === typeof newChild && null !== newChild && newChild.type === REACT_FRAGMENT_TYPE && - null === newChild.key; - isUnkeyedTopLevelFragment && (newChild = newChild.props.children); + null === newChild.key && + (newChild = newChild.props.children); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: a: { - var key = newChild.key; for ( - isUnkeyedTopLevelFragment = currentFirstChild; - null !== isUnkeyedTopLevelFragment; + var key = newChild.key, child = currentFirstChild; + null !== child; ) { - if (isUnkeyedTopLevelFragment.key === key) { + if (child.key === key) { key = newChild.type; if (key === REACT_FRAGMENT_TYPE) { - if (7 === isUnkeyedTopLevelFragment.tag) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); + if (7 === child.tag) { + deleteRemainingChildren(returnFiber, child.sibling); currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, + child, newChild.props.children ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; } - } else if (isUnkeyedTopLevelFragment.elementType === key) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props - ); + } else if (child.elementType === key) { + deleteRemainingChildren(returnFiber, child.sibling); + currentFirstChild = useFiber(child, newChild.props); currentFirstChild.ref = coerceRef( returnFiber, - isUnkeyedTopLevelFragment, + child, newChild ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; } - deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, child); break; - } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); - isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; + } else deleteChild(returnFiber, child); + child = child.sibling; } newChild.type === REACT_FRAGMENT_TYPE ? ((currentFirstChild = createFiberFromFragment( @@ -3184,12 +3173,8 @@ function ChildReconciler(shouldTrackSideEffects) { return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: a: { - for ( - isUnkeyedTopLevelFragment = newChild.key; - null !== currentFirstChild; - - ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + for (child = newChild.key; null !== currentFirstChild; ) { + if (currentFirstChild.key === child) if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -3241,9 +3226,8 @@ function ChildReconciler(shouldTrackSideEffects) { ); throwOnInvalidObjectType(returnFiber, newChild); } - if ("string" === typeof newChild || "number" === typeof newChild) - return ( - (newChild = "" + newChild), + return "string" === typeof newChild || "number" === typeof newChild + ? ((newChild = "" + newChild), null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber(currentFirstChild, newChild)), @@ -3257,20 +3241,8 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), - placeSingleChild(returnFiber) - ); - if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) - switch (returnFiber.tag) { - case 1: - case 0: - case 11: - case 15: - throw Error( - (getComponentNameFromFiber(returnFiber) || "Component") + - "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - ); - } - return deleteRemainingChildren(returnFiber, currentFirstChild); + placeSingleChild(returnFiber)) + : deleteRemainingChildren(returnFiber, currentFirstChild); }; } var reconcileChildFibers = ChildReconciler(!0), @@ -3825,7 +3797,7 @@ function dispatchAction(fiber, queue, action) { if ( null !== workInProgressRoot && 0 !== (fiber.mode & 1) && - 0 === (executionContext & 8) + 0 === (executionContext & 2) ) { var interleaved = queue.interleaved; null === interleaved @@ -4683,7 +4655,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { JSCompiler_temp ? ((showFallback = !0), (workInProgress.flags &= -129)) : (null !== current && null === current.memoizedState) || - void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); @@ -5059,32 +5030,16 @@ appendAllChildren = function( if (needsVisibilityToggle && isHidden) throw Error("Not yet implemented."); appendChildNode(parent.node, instance.node); - } else if (4 !== node.tag) { - if ( - 13 === node.tag && - 0 !== (node.flags & 4) && - (instance = null !== node.memoizedState) - ) { - var primaryChildParent = node.child; - if ( - null !== primaryChildParent && - (null !== primaryChildParent.child && - ((primaryChildParent.child.return = primaryChildParent), - appendAllChildren(parent, primaryChildParent, !0, instance)), - (instance = primaryChildParent.sibling), - null !== instance) - ) { - instance.return = node; - node = instance; - continue; - } - } - if (null !== node.child) { + } else if (4 !== node.tag) + if (22 === node.tag && null !== node.memoizedState) + (instance = node.child), + null !== instance && (instance.return = node), + appendAllChildren(parent, node, !0, !0); + else if (null !== node.child) { node.child.return = node; node = node.child; continue; } - } if (node === workInProgress) break; for (; null === node.sibling; ) { if (null === node.return || node.return === workInProgress) return; @@ -5112,37 +5067,16 @@ function appendAllChildrenToContainer( if (needsVisibilityToggle && isHidden) throw Error("Not yet implemented."); appendChildNodeToSet(containerChildSet, instance.node); - } else if (4 !== node.tag) { - if ( - 13 === node.tag && - 0 !== (node.flags & 4) && - (instance = null !== node.memoizedState) - ) { - var primaryChildParent = node.child; - if ( - null !== primaryChildParent && - (null !== primaryChildParent.child && - ((primaryChildParent.child.return = primaryChildParent), - appendAllChildrenToContainer( - containerChildSet, - primaryChildParent, - !0, - instance - )), - (instance = primaryChildParent.sibling), - null !== instance) - ) { - instance.return = node; - node = instance; - continue; - } - } - if (null !== node.child) { + } else if (4 !== node.tag) + if (22 === node.tag && null !== node.memoizedState) + (instance = node.child), + null !== instance && (instance.return = node), + appendAllChildrenToContainer(containerChildSet, node, !0, !0); + else if (null !== node.child) { node.child.return = node; node = node.child; continue; } - } if (node === workInProgress) break; for (; null === node.sibling; ) { if (null === node.return || node.return === workInProgress) return; @@ -5427,7 +5361,11 @@ function completeWork(current, workInProgress, renderLanes) { newProps = null !== newProps; renderLanes = !1; null !== current && (renderLanes = null !== current.memoizedState); - if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1)) + if ( + newProps && + !renderLanes && + ((workInProgress.child.flags |= 4096), 0 !== (workInProgress.mode & 1)) + ) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || @@ -5449,7 +5387,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootRenderLanes ); } - newProps && (workInProgress.flags |= 4); + null !== workInProgress.updateQueue && (workInProgress.flags |= 4); bubbleProperties(workInProgress); 0 !== (workInProgress.mode & 2) && newProps && @@ -5608,11 +5546,12 @@ function completeWork(current, workInProgress, renderLanes) { null !== current && (null !== current.memoizedState) !== renderLanes && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.flags |= 4), - (renderLanes && - 0 === (subtreeRenderLanes & 1073741824) && - 0 !== (workInProgress.mode & 1)) || - bubbleProperties(workInProgress), + 23 !== workInProgress.tag && + (workInProgress.flags |= 4096), + renderLanes && 0 !== (workInProgress.mode & 1) + ? 0 !== (subtreeRenderLanes & 1073741824) && + bubbleProperties(workInProgress) + : bubbleProperties(workInProgress), null ); } @@ -5830,8 +5769,6 @@ function commitWork(current, finishedWork) { case 12: return; case 13: - null !== finishedWork.memoizedState && - (globalMostRecentFallbackTime = now()); attachSuspenseRetryListeners(finishedWork); return; case 19: @@ -6003,6 +5940,15 @@ function commitMutationEffects(root, firstChild, committedLanes) { else currentRef.current = null; } } + if (flags & 4096) + switch (root.tag) { + case 13: + if (null !== root.memoizedState) { + var current$94 = root.alternate; + if (null === current$94 || null === current$94.memoizedState) + globalMostRecentFallbackTime = now(); + } + } switch (flags & 2054) { case 2: root.flags &= -3; @@ -6042,16 +5988,16 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { if ( ((root = nextEffect), (committedLanes = root.child), - 0 !== (root.subtreeFlags & 324) && null !== committedLanes) + 0 !== (root.subtreeFlags & 4420) && null !== committedLanes) ) (committedLanes.return = root), (nextEffect = committedLanes); else for (root = finishedWork; null !== nextEffect; ) { committedLanes = nextEffect; - if (0 !== (committedLanes.flags & 324)) { + if (0 !== (committedLanes.flags & 4420)) { var current = committedLanes.alternate; try { - if (0 !== (committedLanes.flags & 68)) + if (0 !== (committedLanes.flags & 4420)) switch (committedLanes.tag) { case 0: case 11: @@ -6261,7 +6207,7 @@ var ceil = Math.ceil, currentEventTime = -1, currentEventTransitionLane = 0; function requestEventTime() { - return 0 !== (executionContext & 24) + return 0 !== (executionContext & 6) ? now() : -1 !== currentEventTime ? currentEventTime @@ -6269,7 +6215,7 @@ function requestEventTime() { } function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 1; - if (0 !== (executionContext & 8) && 0 !== workInProgressRootRenderLanes) + if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; if (0 !== ReactCurrentBatchConfig.transition) return ( @@ -6308,18 +6254,15 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { isDevToolsPresent && addFiberToLanesMap(root, fiber, lane); markRootUpdated(root, lane, eventTime); root === workInProgressRoot && - (0 === (executionContext & 8) && (workInProgressRootUpdatedLanes |= lane), + (0 === (executionContext & 2) && (workInProgressRootUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended$1(root, workInProgressRootRenderLanes)); - 1 === lane - ? 0 !== (executionContext & 4) && 0 === (executionContext & 24) - ? performSyncWorkOnRoot(root) - : (ensureRootIsScheduled(root, eventTime), - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks())) - : ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6410,7 +6353,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { nestedUpdateScheduled = currentUpdateIsNested = !1; currentEventTime = -1; currentEventTransitionLane = 0; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); var originalCallbackNode = root.callbackNode; if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) @@ -6429,7 +6372,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if (JSCompiler_inline_result && !didTimeout) { didTimeout = lanes; JSCompiler_inline_result = executionContext; - executionContext |= 8; + executionContext |= 2; var prevDispatcher = pushDispatcher(); if ( workInProgressRoot !== root || @@ -6464,12 +6407,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } else didTimeout = renderRootSync(root, lanes); if (0 !== didTimeout) { 2 === didTimeout && - ((executionContext |= 32), + ((JSCompiler_inline_result = executionContext), + (executionContext |= 8), root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), - (JSCompiler_inline_result = getLanesToRetrySynchronouslyOnError(root)), - 0 !== JSCompiler_inline_result && - ((lanes = JSCompiler_inline_result), - (didTimeout = renderRootSync(root, JSCompiler_inline_result)))); + (prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), + 0 !== prevDispatcher && + ((lanes = prevDispatcher), + (didTimeout = renderRootSync(root, prevDispatcher))), + (executionContext = JSCompiler_inline_result)); if (1 === didTimeout) throw ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), @@ -6570,18 +6515,20 @@ function markRootSuspended$1(root, suspendedLanes) { function performSyncWorkOnRoot(root) { currentUpdateIsNested = nestedUpdateScheduled; nestedUpdateScheduled = !1; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); flushPassiveEffects(); var lanes = getNextLanes(root, 0); if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null; var exitStatus = renderRootSync(root, lanes); if (0 !== root.tag && 2 === exitStatus) { - executionContext |= 32; + var prevExecutionContext = executionContext; + executionContext |= 8; root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); + executionContext = prevExecutionContext; } if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), @@ -6732,19 +6679,17 @@ function handleError(root$jscomp$0, thrownValue) { var JSCompiler_temp; if ((JSCompiler_temp = 13 === workInProgress$32.tag)) { var nextState = workInProgress$32.memoizedState; - if (null !== nextState) - JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; - else { - var props = workInProgress$32.memoizedProps; - JSCompiler_temp = - void 0 === props.fallback - ? !1 - : !0 !== props.unstable_avoidThisFallback + JSCompiler_temp = + null !== nextState + ? null !== nextState.dehydrated ? !0 - : hasInvisibleParentBoundary - ? !1 - : !0; - } + : !1 + : !0 !== + workInProgress$32.memoizedProps.unstable_avoidThisFallback + ? !0 + : hasInvisibleParentBoundary + ? !1 + : !0; } if (JSCompiler_temp) { var wakeables = workInProgress$32.updateQueue; @@ -6865,7 +6810,7 @@ function pushDispatcher() { } function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; - executionContext |= 8; + executionContext |= 2; var prevDispatcher = pushDispatcher(); if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { if (isDevToolsPresent) { @@ -6980,7 +6925,7 @@ function commitRoot(root) { function commitRootImpl(root, renderPriorityLevel) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); var finishedWork = root.finishedWork, lanes = root.finishedLanes; @@ -7013,7 +6958,7 @@ function commitRootImpl(root, renderPriorityLevel) { var previousPriority = currentUpdatePriority; currentUpdatePriority = 1; var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= 4; ReactCurrentOwner$2.current = null; commitBeforeMutationEffects(root, finishedWork); commitTime = now$1(); @@ -7045,7 +6990,6 @@ function commitRootImpl(root, renderPriorityLevel) { (root = firstUncaughtError), (firstUncaughtError = null), root); - if (0 !== (executionContext & 4)) return null; 0 !== (pendingPassiveEffectsLanes & 1) && 0 !== root.tag && flushPassiveEffects(); @@ -7066,10 +7010,10 @@ function flushPassiveEffects() { renderPriority = rootWithPendingPassiveEffects; rootWithPendingPassiveEffects = null; pendingPassiveEffectsLanes = 0; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= 4; for (nextEffect = renderPriority.current; null !== nextEffect; ) { var fiber = nextEffect, child = fiber.child; @@ -8173,6 +8117,95 @@ function updateContainer(element, container, parentComponent, callback) { function emptyFindFiberByHostInstance() { return null; } +var emptyObject$1 = {}, + createHierarchy, + getHostNode, + getHostProps, + lastNonHostInstance, + getOwnerHierarchy, + traverseOwnerTreeUp; +createHierarchy = function(fiberHierarchy) { + return fiberHierarchy.map(function(fiber) { + return { + name: getComponentNameFromType(fiber.type), + getInspectorData: function(findNodeHandle) { + return { + props: getHostProps(fiber), + source: fiber._debugSource, + measure: function(callback) { + var hostFiber = findCurrentHostFiber(fiber); + if ( + (hostFiber = + null != hostFiber && + null !== hostFiber.stateNode && + hostFiber.stateNode.node) + ) + nativeFabricUIManager.measure(hostFiber, callback); + else + return ReactNativePrivateInterface.UIManager.measure( + getHostNode(fiber, findNodeHandle), + callback + ); + } + }; + } + }; + }); +}; +getHostNode = function(fiber, findNodeHandle) { + for (var hostNode; fiber; ) { + null !== fiber.stateNode && + 5 === fiber.tag && + (hostNode = findNodeHandle(fiber.stateNode)); + if (hostNode) return hostNode; + fiber = fiber.child; + } + return null; +}; +getHostProps = function(fiber) { + return (fiber = findCurrentHostFiber(fiber)) + ? fiber.memoizedProps || emptyObject$1 + : emptyObject$1; +}; +exports.getInspectorDataForInstance = function(closestInstance) { + if (!closestInstance) + return { + hierarchy: [], + props: emptyObject$1, + selectedIndex: null, + source: null + }; + closestInstance = findCurrentFiberUsingSlowPath(closestInstance); + var fiberHierarchy = getOwnerHierarchy(closestInstance), + instance = lastNonHostInstance(fiberHierarchy); + closestInstance = createHierarchy(fiberHierarchy); + var props = getHostProps(instance), + source = instance._debugSource; + fiberHierarchy = fiberHierarchy.indexOf(instance); + return { + hierarchy: closestInstance, + props: props, + selectedIndex: fiberHierarchy, + source: source + }; +}; +getOwnerHierarchy = function(instance) { + var hierarchy = []; + traverseOwnerTreeUp(hierarchy, instance); + return hierarchy; +}; +lastNonHostInstance = function(hierarchy) { + for (var i = hierarchy.length - 1; 1 < i; i--) { + var instance = hierarchy[i]; + if (5 !== instance.tag) return instance; + } + return hierarchy[0]; +}; +traverseOwnerTreeUp = function(hierarchy, instance) { + instance && + (hierarchy.unshift(instance), + traverseOwnerTreeUp(hierarchy, instance._debugOwner)); +}; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; @@ -8199,10 +8232,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_969 = { + devToolsConfig$jscomp$inline_979 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-cae635054-20210626", + version: "18.0.0-419cc9c37-20210726", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8217,11 +8250,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1227 = { - bundleType: devToolsConfig$jscomp$inline_969.bundleType, - version: devToolsConfig$jscomp$inline_969.version, - rendererPackageName: devToolsConfig$jscomp$inline_969.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_969.rendererConfig, +var internals$jscomp$inline_1236 = { + bundleType: devToolsConfig$jscomp$inline_979.bundleType, + version: devToolsConfig$jscomp$inline_979.version, + rendererPackageName: devToolsConfig$jscomp$inline_979.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_979.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8237,26 +8270,26 @@ var internals$jscomp$inline_1227 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_969.findFiberByHostInstance || + devToolsConfig$jscomp$inline_979.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-cae635054-20210626" + reconcilerVersion: "18.0.0-419cc9c37-20210726" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1228 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1237 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1228.isDisabled && - hook$jscomp$inline_1228.supportsFiber + !hook$jscomp$inline_1237.isDisabled && + hook$jscomp$inline_1237.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1228.inject( - internals$jscomp$inline_1227 + (rendererID = hook$jscomp$inline_1237.inject( + internals$jscomp$inline_1236 )), - (injectedHook = hook$jscomp$inline_1228); + (injectedHook = hook$jscomp$inline_1237); } catch (err) {} } exports.createPortal = function(children, containerTag) { @@ -8269,12 +8302,10 @@ exports.createPortal = function(children, containerTag) { }; exports.dispatchCommand = function(handle, command, args) { null != handle._nativeTag && - (handle._internalInstanceHandle - ? nativeFabricUIManager.dispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ) + (null != handle._internalInstanceHandle + ? ((handle = handle._internalInstanceHandle.stateNode), + null != handle && + nativeFabricUIManager.dispatchCommand(handle.node, command, args)) : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( handle._nativeTag, command, @@ -8322,11 +8353,10 @@ exports.render = function(element, containerTag, callback, concurrentRoot) { }; exports.sendAccessibilityEvent = function(handle, eventType) { null != handle._nativeTag && - (handle._internalInstanceHandle - ? nativeFabricUIManager.sendAccessibilityEvent( - handle._internalInstanceHandle.stateNode.node, - eventType - ) + (null != handle._internalInstanceHandle + ? ((handle = handle._internalInstanceHandle.stateNode), + null != handle && + nativeFabricUIManager.sendAccessibilityEvent(handle.node, eventType)) : ReactNativePrivateInterface.legacySendAccessibilityEvent( handle._nativeTag, eventType diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index ad0232aa48..9d63f703e0 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<<4167a4b8fd3fe6a1e0fe7e90131522e1>> + * @generated SignedSource<> */ 'use strict'; @@ -2534,6 +2534,7 @@ function updateFiberProps(tag, props) { var batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; + var isInsideEventHandler = false; function batchedUpdates(fn, bookkeeping) { if (isInsideEventHandler) { @@ -2550,11 +2551,7 @@ function batchedUpdates(fn, bookkeeping) { isInsideEventHandler = false; } } -function setBatchingImplementation( - _batchedUpdatesImpl, - _discreteUpdatesImpl, - _batchedEventUpdatesImpl -) { +function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl) { batchedUpdatesImpl = _batchedUpdatesImpl; } @@ -3235,7 +3232,7 @@ var MutationMask = Ref | Hydrating | Visibility; -var LayoutMask = Update | Callback | Ref; // TODO: Split into PassiveMountMask and PassiveUnmountMask +var LayoutMask = Update | Callback | Ref | Visibility; // TODO: Split into PassiveMountMask and PassiveUnmountMask var PassiveMask = Passive | ChildDeletion; // Union of tags that don't get reset on clones. // This allows certain concepts to persist without recalculting them, @@ -4160,9 +4157,15 @@ function injectInternals(internals) { { error("React instrumentation encountered an error: %s.", err); } - } // DevTools exists + } - return true; + if (hook.checkDCE) { + // This is the real DevTools. + return true; + } else { + // This is likely a hook installed by Fast Refresh runtime. + return false; + } } function onScheduleRoot(root, children) { { @@ -6128,7 +6131,7 @@ var Passive$1 = /* */ 4; -var ReactVersion = "18.0.0-cae635054-20210626"; +var ReactVersion = "18.0.0-419cc9c37-20210726"; var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -9843,38 +9846,6 @@ function ChildReconciler(shouldTrackSideEffects) { if (typeof newChild === "function") { warnOnFunctionType(returnFiber); } - } - - if (typeof newChild === "undefined" && !isUnkeyedTopLevelFragment) { - // If the new child is undefined, and the return fiber is a composite - // component, throw an error. If Fiber return types are disabled, - // we already threw above. - switch (returnFiber.tag) { - case ClassComponent: { - { - var instance = returnFiber.stateNode; - - if (instance.render._isMockFunction) { - // We allow auto-mocks to proceed as if they're returning null. - break; - } - } - } - // Intentionally fall through to the next case, which handles both - // functions and classes - // eslint-disable-next-lined no-fallthrough - - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - { - throw Error( - (getComponentNameFromFiber(returnFiber) || "Component") + - "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - ); - } - } - } } // Remaining cases are all treated as empty. return deleteRemainingChildren(returnFiber, currentFirstChild); @@ -10047,11 +10018,7 @@ function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { return false; } - var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop. - - if (props.fallback === undefined) { - return false; - } // Regular boundaries always capture. + var props = workInProgress.memoizedProps; // Regular boundaries always capture. if (props.unstable_avoidThisFallback !== true) { return true; @@ -14616,12 +14583,8 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // This is a new mount or this boundary is already showing a fallback state. // Mark this subtree context as having at least one invisible parent that could // handle the fallback state. - // Boundaries without fallbacks or should be avoided are not considered since - // they cannot handle preferred fallback states. - if ( - nextProps.fallback !== undefined && - nextProps.unstable_avoidThisFallback !== true - ) { + // Avoided boundaries are not considered since they cannot handle preferred fallback states. + if (nextProps.unstable_avoidThisFallback !== true) { suspenseContext = addSubtreeSuspenseContext( suspenseContext, InvisibleParentSuspenseContext @@ -14655,11 +14618,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // a stack. if (current === null) { - // Initial mount - // If we're currently hydrating, try to hydrate this boundary. - // But only if this has a fallback. - if (nextProps.fallback !== undefined); - var nextPrimaryChildren = nextProps.children; var nextFallbackChildren = nextProps.fallback; @@ -16544,17 +16502,28 @@ function completeWork(current, workInProgress, renderLanes) { var nextDidTimeout = nextState !== null; var prevDidTimeout = false; - if (current === null) { - if (workInProgress.memoizedProps.fallback !== undefined); - } else { + if (current === null); + else { var prevState = current.memoizedState; prevDidTimeout = prevState !== null; - } + } // If the suspended state of the boundary changes, we need to schedule + // an effect to toggle the subtree's visibility. When we switch from + // fallback -> primary, the inner Offscreen fiber schedules this effect + // as part of its normal complete phase. But when we switch from + // primary -> fallback, the inner Offscreen fiber does not have a complete + // phase. So we need to schedule its effect here. + // + // We also use this flag to connect/disconnect the effects, but the same + // logic applies: when re-connecting, the Offscreen fiber's complete + // phase will handle scheduling the effect. It's only when the fallback + // is active that we have to do anything special. if (nextDidTimeout && !prevDidTimeout) { - // TODO: This will still suspend a synchronous tree if anything + var offscreenFiber = workInProgress.child; + offscreenFiber.flags |= Visibility; // TODO: This will still suspend a synchronous tree if anything // in the concurrent tree already suspended during this render. // This is a known bug. + if ((workInProgress.mode & ConcurrentMode) !== NoMode) { // TODO: Move this back to throwException because this is too late // if this is a large tree which is common for initial loads. We @@ -16585,16 +16554,12 @@ function completeWork(current, workInProgress, renderLanes) { } } - { - // TODO: Only schedule updates if these values are non equal, i.e. it changed. - if (nextDidTimeout || prevDidTimeout) { - // If this boundary just timed out, schedule an effect to attach a - // retry listener to the promise. This flag is also used to hide the - // primary children. In mutation mode, we also need the flag to - // *unhide* children that were previously hidden, so check if this - // is currently timed out, too. - workInProgress.flags |= Update; - } + var wakeables = workInProgress.updateQueue; + + if (wakeables !== null) { + // Schedule an effect to attach a retry listener to the promise. + // TODO: Move to passive phase + workInProgress.flags |= Update; } bubbleProperties(workInProgress); @@ -16873,18 +16838,34 @@ function completeWork(current, workInProgress, renderLanes) { if ( prevIsHidden !== nextIsHidden && - newProps.mode !== "unstable-defer-without-hiding" + newProps.mode !== "unstable-defer-without-hiding" && // LegacyHidden doesn't do any hiding — it only pre-renders. + workInProgress.tag !== LegacyHiddenComponent ) { - workInProgress.flags |= Update; + workInProgress.flags |= Visibility; } - } // Don't bubble properties for hidden children. + } - if ( - !nextIsHidden || - includesSomeLane(subtreeRenderLanes, OffscreenLane) || - (workInProgress.mode & ConcurrentMode) === NoMode - ) { + if (!nextIsHidden || (workInProgress.mode & ConcurrentMode) === NoMode) { bubbleProperties(workInProgress); + } else { + // Don't bubble properties for hidden children unless we're rendering + // at offscreen priority. + if (includesSomeLane(subtreeRenderLanes, OffscreenLane)) { + bubbleProperties(workInProgress); + + { + // Check if there was an insertion or update in the hidden subtree. + // If so, we need to hide those nodes in the commit phase, so + // schedule a visibility effect. + if ( + workInProgress.tag !== LegacyHiddenComponent && + workInProgress.subtreeFlags & (Placement | Update) && + newProps.mode !== "unstable-defer-without-hiding" + ) { + workInProgress.flags |= Visibility; + } + } + } } return null; @@ -17441,24 +17422,26 @@ function commitLayoutEffectOnFiber( finishedWork, committedLanes ) { - if ((finishedWork.flags & (Update | Callback)) !== NoFlags) { + if ((finishedWork.flags & LayoutMask) !== NoFlags) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - // At this point layout effects have already been destroyed (during mutation phase). - // This is done to prevent sibling component effects from interfering with each other, - // e.g. a destroy function in one component should never override a ref set - // by a create function in another component during the same commit. - if (finishedWork.mode & ProfileMode) { - try { - startLayoutEffectTimer(); + { + // At this point layout effects have already been destroyed (during mutation phase). + // This is done to prevent sibling component effects from interfering with each other, + // e.g. a destroy function in one component should never override a ref set + // by a create function in another component during the same commit. + if (finishedWork.mode & ProfileMode) { + try { + startLayoutEffectTimer(); + commitHookEffectListMount(Layout | HasEffect, finishedWork); + } finally { + recordLayoutEffectDuration(finishedWork); + } + } else { commitHookEffectListMount(Layout | HasEffect, finishedWork); - } finally { - recordLayoutEffectDuration(finishedWork); } - } else { - commitHookEffectListMount(Layout | HasEffect, finishedWork); } break; @@ -17468,104 +17451,109 @@ function commitLayoutEffectOnFiber( var instance = finishedWork.stateNode; if (finishedWork.flags & Update) { - if (current === null) { - // We could update instance props and state here, - // but instead we rely on them being set during last render. - // TODO: revisit this when we implement resuming. - { - if ( - finishedWork.type === finishedWork.elementType && - !didWarnAboutReassigningProps - ) { - if (instance.props !== finishedWork.memoizedProps) { - error( - "Expected %s props to match memoized props before " + - "componentDidMount. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentNameFromFiber(finishedWork) || "instance" - ); - } + { + if (current === null) { + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "componentDidMount. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentNameFromFiber(finishedWork) || "instance" + ); + } - if (instance.state !== finishedWork.memoizedState) { - error( - "Expected %s state to match memoized state before " + - "componentDidMount. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.state`. " + - "Please file an issue.", - getComponentNameFromFiber(finishedWork) || "instance" - ); + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "componentDidMount. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.state`. " + + "Please file an issue.", + getComponentNameFromFiber(finishedWork) || "instance" + ); + } } } - } - if (finishedWork.mode & ProfileMode) { - try { - startLayoutEffectTimer(); + if (finishedWork.mode & ProfileMode) { + try { + startLayoutEffectTimer(); + instance.componentDidMount(); + } finally { + recordLayoutEffectDuration(finishedWork); + } + } else { instance.componentDidMount(); - } finally { - recordLayoutEffectDuration(finishedWork); } } else { - instance.componentDidMount(); - } - } else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps(finishedWork.type, current.memoizedProps); - var prevState = current.memoizedState; // We could update instance props and state here, - // but instead we rely on them being set during last render. - // TODO: revisit this when we implement resuming. + var prevProps = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current.memoizedProps + ); + var prevState = current.memoizedState; // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. - { - if ( - finishedWork.type === finishedWork.elementType && - !didWarnAboutReassigningProps - ) { - if (instance.props !== finishedWork.memoizedProps) { - error( - "Expected %s props to match memoized props before " + - "componentDidUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.props`. " + - "Please file an issue.", - getComponentNameFromFiber(finishedWork) || "instance" - ); - } + { + if ( + finishedWork.type === finishedWork.elementType && + !didWarnAboutReassigningProps + ) { + if (instance.props !== finishedWork.memoizedProps) { + error( + "Expected %s props to match memoized props before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.props`. " + + "Please file an issue.", + getComponentNameFromFiber(finishedWork) || "instance" + ); + } - if (instance.state !== finishedWork.memoizedState) { - error( - "Expected %s state to match memoized state before " + - "componentDidUpdate. " + - "This might either be because of a bug in React, or because " + - "a component reassigns its own `this.state`. " + - "Please file an issue.", - getComponentNameFromFiber(finishedWork) || "instance" - ); + if (instance.state !== finishedWork.memoizedState) { + error( + "Expected %s state to match memoized state before " + + "componentDidUpdate. " + + "This might either be because of a bug in React, or because " + + "a component reassigns its own `this.state`. " + + "Please file an issue.", + getComponentNameFromFiber(finishedWork) || "instance" + ); + } } } - } - if (finishedWork.mode & ProfileMode) { - try { - startLayoutEffectTimer(); + if (finishedWork.mode & ProfileMode) { + try { + startLayoutEffectTimer(); + instance.componentDidUpdate( + prevProps, + prevState, + instance.__reactInternalSnapshotBeforeUpdate + ); + } finally { + recordLayoutEffectDuration(finishedWork); + } + } else { instance.componentDidUpdate( prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate ); - } finally { - recordLayoutEffectDuration(finishedWork); } - } else { - instance.componentDidUpdate( - prevProps, - prevState, - instance.__reactInternalSnapshotBeforeUpdate - ); } } } // TODO: I think this is now always non-null by the time it reaches the @@ -17745,18 +17733,16 @@ function commitLayoutEffectOnFiber( } { - if (finishedWork.flags & Ref) { - commitAttachRef(finishedWork); + { + if (finishedWork.flags & Ref) { + commitAttachRef(finishedWork); + } } } } function hideOrUnhideAllChildren(finishedWork, isHidden) { - // Suspense layout effects semantics don't change for legacy roots. - var isModernRoot = (finishedWork.mode & ConcurrentMode) !== NoMode; - var current = finishedWork.alternate; - var wasHidden = current !== null && current.memoizedState !== null; // Only hide or unhide the top-most host nodes. - + // Only hide or unhide the top-most host nodes. var hostSubtreeRoot = null; { @@ -18468,7 +18454,7 @@ function commitWork(current, finishedWork) { } case SuspenseComponent: { - commitSuspenseComponent(finishedWork); + commitSuspenseCallback(finishedWork); attachSuspenseRetryListeners(finishedWork); return; } @@ -18481,18 +18467,6 @@ function commitWork(current, finishedWork) { case IncompleteClassComponent: { return; } - - case ScopeComponent: { - break; - } - - case OffscreenComponent: - case LegacyHiddenComponent: { - var newState = finishedWork.memoizedState; - var isHidden = newState !== null; - hideOrUnhideAllChildren(finishedWork, isHidden); - return; - } } { @@ -18502,26 +18476,9 @@ function commitWork(current, finishedWork) { } } -function commitSuspenseComponent(finishedWork) { +function commitSuspenseCallback(finishedWork) { + // TODO: Move this to passive phase var newState = finishedWork.memoizedState; - - if (newState !== null) { - markCommitTimeOfFallback(); - - { - // Hide the Offscreen component that contains the primary children. TODO: - // Ideally, this effect would have been scheduled on the Offscreen fiber - // itself. That's how unhiding works: the Offscreen component schedules an - // effect on itself. However, in this case, the component didn't complete, - // so the fiber was never added to the effect list in the normal path. We - // could have appended it to the effect list in the Suspense component's - // second pass, but doing it this way is less complicated. This would be - // simpler if we got rid of the effect list and traversed the tree, like - // we're planning to do. - var primaryChildParent = finishedWork.child; - hideOrUnhideAllChildren(primaryChildParent, true); - } - } } function attachSuspenseRetryListeners(finishedWork) { @@ -18633,6 +18590,10 @@ function commitMutationEffects_complete(root) { } function commitMutationEffectsOnFiber(finishedWork, root) { + // TODO: The factoring of this phase could probably be improved. Consider + // switching on the type of work before checking the flags. That's what + // we do in all the other phases. I think this one is only different + // because of the shared reconcilation logic below. var flags = finishedWork.flags; if (flags & ContentReset) { @@ -18645,6 +18606,45 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (current !== null) { commitDetachRef(current); } + } + + if (flags & Visibility) { + switch (finishedWork.tag) { + case SuspenseComponent: { + var newState = finishedWork.memoizedState; + var isHidden = newState !== null; + + if (isHidden) { + var _current = finishedWork.alternate; + var wasHidden = _current !== null && _current.memoizedState !== null; + + if (!wasHidden) { + // TODO: Move to passive phase + markCommitTimeOfFallback(); + } + } + + break; + } + + case OffscreenComponent: { + var _newState = finishedWork.memoizedState; + + var _isHidden = _newState !== null; + + var _current2 = finishedWork.alternate; + + var _wasHidden = _current2 !== null && _current2.memoizedState !== null; + + var offscreenBoundary = finishedWork; + + { + // TODO: This needs to run whenever there's an insertion or update + // inside a hidden Offscreen tree. + hideOrUnhideAllChildren(offscreenBoundary, _isHidden); + } + } + } } // The following switch statement is only concerned about placement, // updates, and deletions. To avoid needing to add a case for every possible // bitmap value, we remove the secondary effects from the effect tag and @@ -18670,8 +18670,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { finishedWork.flags &= ~Placement; // Update - var _current = finishedWork.alternate; - commitWork(_current, finishedWork); + var _current3 = finishedWork.alternate; + commitWork(_current3, finishedWork); break; } @@ -18683,14 +18683,14 @@ function commitMutationEffectsOnFiber(finishedWork, root) { case HydratingAndUpdate: { finishedWork.flags &= ~Hydrating; // Update - var _current2 = finishedWork.alternate; - commitWork(_current2, finishedWork); + var _current4 = finishedWork.alternate; + commitWork(_current4, finishedWork); break; } case Update: { - var _current3 = finishedWork.alternate; - commitWork(_current3, finishedWork); + var _current5 = finishedWork.alternate; + commitWork(_current5, finishedWork); break; } } @@ -18723,9 +18723,6 @@ function commitLayoutEffects_begin(subtreeRoot, root, committedLanes) { } function commitLayoutMountEffects_complete(subtreeRoot, root, committedLanes) { - // Suspense layout effects semantics don't change for legacy roots. - var isModernRoot = (subtreeRoot.mode & ConcurrentMode) !== NoMode; - while (nextEffect !== null) { var fiber = nextEffect; @@ -19039,7 +19036,7 @@ function ensureCorrectReturnPointer(fiber, expectedReturnFiber) { // anything, by checking the warning logs for the above invariant fiber.return = expectedReturnFiber; -} +} // TODO: Reuse reappearLayoutEffects traversal here? function invokeLayoutEffectMountInDEV(fiber) { { @@ -19176,18 +19173,15 @@ var NoContext = var BatchedContext = /* */ 1; -var LegacyUnbatchedContext = - /* */ - 4; var RenderContext = /* */ - 8; + 2; var CommitContext = /* */ - 16; + 4; var RetryAfterError = /* */ - 32; + 8; var RootIncomplete = 0; var RootFatalErrored = 1; var RootErrored = 2; @@ -19400,35 +19394,21 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { } } - if (lane === SyncLane) { - if ( - // Check if we're inside unbatchedUpdates - (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering - (executionContext & (RenderContext | CommitContext)) === NoContext - ) { - // This is a legacy edge case. The initial mount of a ReactDOM.render-ed - // root inside of batchedUpdates should be synchronous, but layout updates - // should be deferred until the end of the batch. - performSyncWorkOnRoot(root); - } else { - ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root, eventTime); - if ( - executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode - ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); - } - } - } else { - // Schedule other updates after in case the callback is sync. - ensureRootIsScheduled(root, eventTime); + if ( + lane === SyncLane && + executionContext === NoContext && + (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + !ReactCurrentActQueue.isBatchingLegacy + ) { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncCallbacksOnlyInLegacyMode(); } return root; @@ -19565,6 +19545,10 @@ function ensureRootIsScheduled(root, currentTime) { // Special case: Sync React callbacks are scheduled on a special // internal queue if (root.tag === LegacyRoot) { + if (ReactCurrentActQueue.isBatchingLegacy !== null) { + ReactCurrentActQueue.didScheduleLegacyUpdate = true; + } + scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); } else { scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); @@ -19663,6 +19647,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if (exitStatus !== RootIncomplete) { if (exitStatus === RootErrored) { + var prevExecutionContext = executionContext; executionContext |= RetryAfterError; // If an error occurred during hydration, // discard server response and fall back to client side render. @@ -19685,6 +19670,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { lanes = errorRetryLanes; exitStatus = renderRootSync(root, errorRetryLanes); } + + executionContext = prevExecutionContext; } if (exitStatus === RootFatalErrored) { @@ -19863,6 +19850,7 @@ function performSyncWorkOnRoot(root) { var exitStatus = renderRootSync(root, lanes); if (root.tag !== LegacyRoot && exitStatus === RootErrored) { + var prevExecutionContext = executionContext; executionContext |= RetryAfterError; // If an error occurred during hydration, // discard server response and fall back to client side render. @@ -19885,6 +19873,8 @@ function performSyncWorkOnRoot(root) { lanes = errorRetryLanes; exitStatus = renderRootSync(root, lanes); } + + executionContext = prevExecutionContext; } if (exitStatus === RootFatalErrored) { @@ -19915,13 +19905,29 @@ function batchedUpdates$1(fn, a) { executionContext = prevExecutionContext; // If there were legacy sync updates, flush them at the end of the outer // most batchedUpdates-like method. - if (executionContext === NoContext) { + if ( + executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + !ReactCurrentActQueue.isBatchingLegacy + ) { resetRenderTimer(); flushSyncCallbacksOnlyInLegacyMode(); } } } -function flushSync(fn, a) { +// Warning, this opts-out of checking the function body. + +// eslint-disable-next-line no-redeclare +function flushSyncWithoutWarningIfAlreadyRendering(fn) { + // In legacy mode, we flush pending passive effects at the beginning of the + // next event, not at the end of the previous one. + if ( + rootWithPendingPassiveEffects !== null && + rootWithPendingPassiveEffects.tag === LegacyRoot && + (executionContext & (RenderContext | CommitContext)) === NoContext + ) { + flushPassiveEffects(); + } + var prevExecutionContext = executionContext; executionContext |= BatchedContext; var prevTransition = ReactCurrentBatchConfig$2.transition; @@ -19932,7 +19938,7 @@ function flushSync(fn, a) { setCurrentUpdatePriority(DiscreteEventPriority); if (fn) { - return fn(a); + return fn(); } else { return undefined; } @@ -19945,16 +19951,24 @@ function flushSync(fn, a) { if ((executionContext & (RenderContext | CommitContext)) === NoContext) { flushSyncCallbacks(); - } else { - { - error( - "flushSync was called from inside a lifecycle method. React cannot " + - "flush when React is already rendering. Consider moving this call to " + - "a scheduler task or micro task." - ); - } } } +} // Overload the definition to the two valid signatures. +// Warning, this opts-out of checking the function body. + +// eslint-disable-next-line no-redeclare +function flushSync(fn) { + { + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + error( + "flushSync was called from inside a lifecycle method. React cannot " + + "flush when React is already rendering. Consider moving this call to " + + "a scheduler task or micro task." + ); + } + } + + return flushSyncWithoutWarningIfAlreadyRendering(fn); } function pushRenderLanes(fiber, lanes) { push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); @@ -20593,14 +20607,6 @@ function commitRootImpl(root, renderPriorityLevel) { var error$1 = firstUncaughtError; firstUncaughtError = null; throw error$1; - } - - if ((executionContext & LegacyUnbatchedContext) !== NoContext) { - // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired - // synchronously, but layout updates should be deferred until the end - // of the batch. - - return null; } // If the passive effects are the result of a discrete render, flush them // synchronously at the end of the current task so that the result is // immediately observable. Otherwise, we assume that they are not @@ -23031,65 +23037,16 @@ var emptyObject$1 = {}; Object.freeze(emptyObject$1); } -var getInspectorDataForViewTag; -var getInspectorDataForViewAtPoint; +var createHierarchy; +var getHostNode; +var getHostProps; +var lastNonHostInstance; + +var getOwnerHierarchy; +var traverseOwnerTreeUp; { - var traverseOwnerTreeUp = function(hierarchy, instance) { - if (instance) { - hierarchy.unshift(instance); - traverseOwnerTreeUp(hierarchy, instance._debugOwner); - } - }; - - var getOwnerHierarchy = function(instance) { - var hierarchy = []; - traverseOwnerTreeUp(hierarchy, instance); - return hierarchy; - }; - - var lastNonHostInstance = function(hierarchy) { - for (var i = hierarchy.length - 1; i > 1; i--) { - var instance = hierarchy[i]; - - if (instance.tag !== HostComponent) { - return instance; - } - } - - return hierarchy[0]; - }; - - var getHostProps = function(fiber) { - var host = findCurrentHostFiber(fiber); - - if (host) { - return host.memoizedProps || emptyObject$1; - } - - return emptyObject$1; - }; - - var getHostNode = function(fiber, findNodeHandle) { - var hostNode; // look for children first for the hostNode - // as composite fibers do not have a hostNode - - while (fiber) { - if (fiber.stateNode !== null && fiber.tag === HostComponent) { - hostNode = findNodeHandle(fiber.stateNode); - } - - if (hostNode) { - return hostNode; - } - - fiber = fiber.child; - } - - return null; - }; - - var createHierarchy = function(fiberHierarchy) { + createHierarchy = function(fiberHierarchy) { return fiberHierarchy.map(function(fiber) { return { name: getComponentNameFromType(fiber.type), @@ -23120,7 +23077,36 @@ var getInspectorDataForViewAtPoint; }); }; - var getInspectorDataForInstance = function(closestInstance) { + getHostNode = function(fiber, findNodeHandle) { + var hostNode; // look for children first for the hostNode + // as composite fibers do not have a hostNode + + while (fiber) { + if (fiber.stateNode !== null && fiber.tag === HostComponent) { + hostNode = findNodeHandle(fiber.stateNode); + } + + if (hostNode) { + return hostNode; + } + + fiber = fiber.child; + } + + return null; + }; + + getHostProps = function(fiber) { + var host = findCurrentHostFiber(fiber); + + if (host) { + return host.memoizedProps || emptyObject$1; + } + + return emptyObject$1; + }; + + exports.getInspectorDataForInstance = function(closestInstance) { // Handle case where user clicks outside of ReactNative if (!closestInstance) { return { @@ -23146,6 +23132,36 @@ var getInspectorDataForViewAtPoint; }; }; + getOwnerHierarchy = function(instance) { + var hierarchy = []; + traverseOwnerTreeUp(hierarchy, instance); + return hierarchy; + }; + + lastNonHostInstance = function(hierarchy) { + for (var i = hierarchy.length - 1; i > 1; i--) { + var instance = hierarchy[i]; + + if (instance.tag !== HostComponent) { + return instance; + } + } + + return hierarchy[0]; + }; + + traverseOwnerTreeUp = function(hierarchy, instance) { + if (instance) { + hierarchy.unshift(instance); + traverseOwnerTreeUp(hierarchy, instance._debugOwner); + } + }; +} + +var getInspectorDataForViewTag; +var getInspectorDataForViewAtPoint; + +{ getInspectorDataForViewTag = function(viewTag) { var closestInstance = getInstanceFromTag(viewTag); // Handle case where user clicks outside of ReactNative @@ -23201,7 +23217,7 @@ var getInspectorDataForViewAtPoint; height: 0 } }, - getInspectorDataForInstance(closestInstance) + exports.getInspectorDataForInstance(closestInstance) ) ); } @@ -23214,7 +23230,9 @@ var getInspectorDataForViewAtPoint; nativeFabricUIManager.measure( internalInstanceHandle.stateNode.node, function(x, y, width, height, pageX, pageY) { - var inspectorData = getInspectorDataForInstance(closestInstance); + var inspectorData = exports.getInspectorDataForInstance( + closestInstance + ); callback( Object.assign({}, inspectorData, { pointerY: locationY, @@ -23237,7 +23255,7 @@ var getInspectorDataForViewAtPoint; findNodeHandle(inspectedView), [locationX, locationY], function(nativeViewTag, left, top, width, height) { - var inspectorData = getInspectorDataForInstance( + var inspectorData = exports.getInspectorDataForInstance( getInstanceFromTag(nativeViewTag) ); callback( @@ -23389,12 +23407,12 @@ function dispatchCommand(handle, command, args) { return; } - if (handle._internalInstanceHandle) { - nativeFabricUIManager.dispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ); + if (handle._internalInstanceHandle != null) { + var stateNode = handle._internalInstanceHandle.stateNode; + + if (stateNode != null) { + nativeFabricUIManager.dispatchCommand(stateNode.node, command, args); + } } else { ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( handle._nativeTag, @@ -23416,11 +23434,12 @@ function sendAccessibilityEvent(handle, eventType) { return; } - if (handle._internalInstanceHandle) { - nativeFabricUIManager.sendAccessibilityEvent( - handle._internalInstanceHandle.stateNode.node, - eventType - ); + if (handle._internalInstanceHandle != null) { + var stateNode = handle._internalInstanceHandle.stateNode; + + if (stateNode != null) { + nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType); + } } else { ReactNativePrivateInterface.legacySendAccessibilityEvent( handle._nativeTag, diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 69fa5b0e05..43eb09ea3e 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<> + * @generated SignedSource<> */ "use strict"; @@ -930,7 +930,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_219 = { +var injectedNamesToPlugins$jscomp$inline_224 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -965,34 +965,34 @@ 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_225 = !1, + pluginName$jscomp$inline_226; +for (pluginName$jscomp$inline_226 in injectedNamesToPlugins$jscomp$inline_224) if ( - injectedNamesToPlugins$jscomp$inline_219.hasOwnProperty( - pluginName$jscomp$inline_221 + injectedNamesToPlugins$jscomp$inline_224.hasOwnProperty( + pluginName$jscomp$inline_226 ) ) { - var pluginModule$jscomp$inline_222 = - injectedNamesToPlugins$jscomp$inline_219[pluginName$jscomp$inline_221]; + var pluginModule$jscomp$inline_227 = + injectedNamesToPlugins$jscomp$inline_224[pluginName$jscomp$inline_226]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_221) || - namesToPlugins[pluginName$jscomp$inline_221] !== - pluginModule$jscomp$inline_222 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_226) || + namesToPlugins[pluginName$jscomp$inline_226] !== + pluginModule$jscomp$inline_227 ) { - if (namesToPlugins[pluginName$jscomp$inline_221]) + if (namesToPlugins[pluginName$jscomp$inline_226]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_221 + + pluginName$jscomp$inline_226 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_221 - ] = pluginModule$jscomp$inline_222; - isOrderingDirty$jscomp$inline_220 = !0; + pluginName$jscomp$inline_226 + ] = pluginModule$jscomp$inline_227; + isOrderingDirty$jscomp$inline_225 = !0; } } -isOrderingDirty$jscomp$inline_220 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_225 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -2236,7 +2236,7 @@ function enqueueUpdate(fiber, update) { ((updateQueue = updateQueue.shared), null !== workInProgressRoot && 0 !== (fiber.mode & 1) && - 0 === (executionContext & 8) + 0 === (executionContext & 2) ? ((fiber = updateQueue.interleaved), null === fiber ? ((update.next = update), @@ -3073,60 +3073,49 @@ function ChildReconciler(shouldTrackSideEffects) { return iteratorFn; } return function(returnFiber, currentFirstChild, newChild, lanes) { - var isUnkeyedTopLevelFragment = - "object" === typeof newChild && + "object" === typeof newChild && null !== newChild && newChild.type === REACT_FRAGMENT_TYPE && - null === newChild.key; - isUnkeyedTopLevelFragment && (newChild = newChild.props.children); + null === newChild.key && + (newChild = newChild.props.children); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: a: { - var key = newChild.key; for ( - isUnkeyedTopLevelFragment = currentFirstChild; - null !== isUnkeyedTopLevelFragment; + var key = newChild.key, child = currentFirstChild; + null !== child; ) { - if (isUnkeyedTopLevelFragment.key === key) { + if (child.key === key) { key = newChild.type; if (key === REACT_FRAGMENT_TYPE) { - if (7 === isUnkeyedTopLevelFragment.tag) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); + if (7 === child.tag) { + deleteRemainingChildren(returnFiber, child.sibling); currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, + child, newChild.props.children ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; } - } else if (isUnkeyedTopLevelFragment.elementType === key) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props - ); + } else if (child.elementType === key) { + deleteRemainingChildren(returnFiber, child.sibling); + currentFirstChild = useFiber(child, newChild.props); currentFirstChild.ref = coerceRef( returnFiber, - isUnkeyedTopLevelFragment, + child, newChild ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; } - deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, child); break; - } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); - isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; + } else deleteChild(returnFiber, child); + child = child.sibling; } newChild.type === REACT_FRAGMENT_TYPE ? ((currentFirstChild = createFiberFromFragment( @@ -3156,12 +3145,8 @@ function ChildReconciler(shouldTrackSideEffects) { return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: a: { - for ( - isUnkeyedTopLevelFragment = newChild.key; - null !== currentFirstChild; - - ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + for (child = newChild.key; null !== currentFirstChild; ) { + if (currentFirstChild.key === child) if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -3213,9 +3198,8 @@ function ChildReconciler(shouldTrackSideEffects) { ); throwOnInvalidObjectType(returnFiber, newChild); } - if ("string" === typeof newChild || "number" === typeof newChild) - return ( - (newChild = "" + newChild), + return "string" === typeof newChild || "number" === typeof newChild + ? ((newChild = "" + newChild), null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber(currentFirstChild, newChild)), @@ -3229,20 +3213,8 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), - placeSingleChild(returnFiber) - ); - if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) - switch (returnFiber.tag) { - case 1: - case 0: - case 11: - case 15: - throw Error( - (getComponentNameFromFiber(returnFiber) || "Component") + - "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - ); - } - return deleteRemainingChildren(returnFiber, currentFirstChild); + placeSingleChild(returnFiber)) + : deleteRemainingChildren(returnFiber, currentFirstChild); }; } var reconcileChildFibers = ChildReconciler(!0), @@ -3797,7 +3769,7 @@ function dispatchAction(fiber, queue, action) { if ( null !== workInProgressRoot && 0 !== (fiber.mode & 1) && - 0 === (executionContext & 8) + 0 === (executionContext & 2) ) { var interleaved = queue.interleaved; null === interleaved @@ -4587,7 +4559,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { JSCompiler_temp ? ((showFallback = !0), (workInProgress.flags &= -129)) : (null !== current && null === current.memoizedState) || - void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); @@ -5122,10 +5093,13 @@ function completeWork(current, workInProgress, renderLanes) { newProps = workInProgress.memoizedState; if (0 !== (workInProgress.flags & 128)) return (workInProgress.lanes = renderLanes), workInProgress; - newProps = null !== newProps; renderLanes = !1; null !== current && (renderLanes = null !== current.memoizedState); - if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1)) + if ( + null !== newProps && + !renderLanes && + ((workInProgress.child.flags |= 4096), 0 !== (workInProgress.mode & 1)) + ) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || @@ -5147,7 +5121,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootRenderLanes ); } - if (newProps || renderLanes) workInProgress.flags |= 4; + null !== workInProgress.updateQueue && (workInProgress.flags |= 4); bubbleProperties(workInProgress); return null; case 4: @@ -5299,11 +5273,16 @@ function completeWork(current, workInProgress, renderLanes) { null !== current && (null !== current.memoizedState) !== renderLanes && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.flags |= 4), - (renderLanes && - 0 === (subtreeRenderLanes & 1073741824) && - 0 !== (workInProgress.mode & 1)) || - bubbleProperties(workInProgress), + 23 !== workInProgress.tag && + (workInProgress.flags |= 4096), + renderLanes && 0 !== (workInProgress.mode & 1) + ? 0 !== (subtreeRenderLanes & 1073741824) && + (bubbleProperties(workInProgress), + 23 !== workInProgress.tag && + workInProgress.subtreeFlags & 6 && + "unstable-defer-without-hiding" !== newProps.mode && + (workInProgress.flags |= 4096)) + : bubbleProperties(workInProgress), null ); } @@ -5473,68 +5452,6 @@ function commitHookEffectListMount(tag, finishedWork) { } while (effect !== finishedWork); } } -function hideOrUnhideAllChildren(finishedWork, isHidden) { - for (var hostSubtreeRoot = null, node = finishedWork; ; ) { - if (5 === node.tag) { - if (null === hostSubtreeRoot) { - hostSubtreeRoot = node; - var instance = node.stateNode; - if (isHidden) { - var viewConfig = instance.viewConfig; - var updatePayload = diffProperties( - null, - emptyObject, - { style: { display: "none" } }, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, - viewConfig.uiViewClassName, - updatePayload - ); - } else { - instance = node.stateNode; - updatePayload = node.memoizedProps; - viewConfig = instance.viewConfig; - var prevProps = Object.assign({}, updatePayload, { - style: [updatePayload.style, { display: "none" }] - }); - updatePayload = diffProperties( - null, - prevProps, - updatePayload, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, - viewConfig.uiViewClassName, - updatePayload - ); - } - } - } else if (6 === node.tag) { - if (null === hostSubtreeRoot) throw Error("Not yet implemented."); - } else if ( - ((22 !== node.tag && 23 !== node.tag) || - null === node.memoizedState || - node === finishedWork) && - null !== node.child - ) { - node.child.return = node; - node = node.child; - continue; - } - if (node === finishedWork) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === finishedWork) return; - hostSubtreeRoot === node && (hostSubtreeRoot = null); - node = node.return; - } - hostSubtreeRoot === node && (hostSubtreeRoot = null); - node.sibling.return = node.return; - node = node.sibling; - } -} function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) { if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount) try { @@ -5925,9 +5842,6 @@ function commitWork(current, finishedWork) { case 12: return; case 13: - null !== finishedWork.memoizedState && - ((globalMostRecentFallbackTime = now()), - hideOrUnhideAllChildren(finishedWork.child, !0)); attachSuspenseRetryListeners(finishedWork); return; case 19: @@ -5935,13 +5849,6 @@ function commitWork(current, finishedWork) { return; case 17: return; - case 22: - case 23: - hideOrUnhideAllChildren( - finishedWork, - null !== finishedWork.memoizedState - ); - return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." @@ -5995,6 +5902,87 @@ function commitMutationEffects(root, firstChild) { : (currentRef.current = null)); } } + if (flags & 4096) + switch (firstChild.tag) { + case 13: + if (null !== firstChild.memoizedState) { + var current$87 = firstChild.alternate; + if (null === current$87 || null === current$87.memoizedState) + globalMostRecentFallbackTime = now(); + } + break; + case 22: + a: { + deletions = firstChild; + var isHidden = null !== firstChild.memoizedState; + i = null; + for (childToDelete = deletions; ; ) { + if (5 === childToDelete.tag) { + if (null === i) { + i = childToDelete; + var instance = childToDelete.stateNode; + if (isHidden) { + var instance$jscomp$0 = instance, + viewConfig = instance$jscomp$0.viewConfig; + var updatePayload = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + instance$jscomp$0._nativeTag, + viewConfig.uiViewClassName, + updatePayload + ); + } else { + var instance$jscomp$1 = childToDelete.stateNode, + props = childToDelete.memoizedProps, + viewConfig$jscomp$0 = instance$jscomp$1.viewConfig, + prevProps = Object.assign({}, props, { + style: [props.style, { display: "none" }] + }); + var updatePayload$jscomp$0 = diffProperties( + null, + prevProps, + props, + viewConfig$jscomp$0.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + instance$jscomp$1._nativeTag, + viewConfig$jscomp$0.uiViewClassName, + updatePayload$jscomp$0 + ); + } + } + } else if (6 === childToDelete.tag) { + if (null === i) throw Error("Not yet implemented."); + } else if ( + ((22 !== childToDelete.tag && 23 !== childToDelete.tag) || + null === childToDelete.memoizedState || + childToDelete === deletions) && + null !== childToDelete.child + ) { + childToDelete.child.return = childToDelete; + childToDelete = childToDelete.child; + continue; + } + if (childToDelete === deletions) break; + for (; null === childToDelete.sibling; ) { + if ( + null === childToDelete.return || + childToDelete.return === deletions + ) + break a; + i === childToDelete && (i = null); + childToDelete = childToDelete.return; + } + i === childToDelete && (i = null); + childToDelete.sibling.return = childToDelete.return; + childToDelete = childToDelete.sibling; + } + } + } switch (flags & 2054) { case 2: commitPlacement(firstChild); @@ -6032,15 +6020,15 @@ function commitLayoutEffects(finishedWork) { for (nextEffect = finishedWork; null !== nextEffect; ) { var fiber = nextEffect, firstChild = fiber.child; - if (0 !== (fiber.subtreeFlags & 324) && null !== firstChild) + if (0 !== (fiber.subtreeFlags & 4420) && null !== firstChild) (firstChild.return = fiber), (nextEffect = firstChild); else for (fiber = finishedWork; null !== nextEffect; ) { firstChild = nextEffect; - if (0 !== (firstChild.flags & 324)) { + if (0 !== (firstChild.flags & 4420)) { var current = firstChild.alternate; try { - if (0 !== (firstChild.flags & 68)) + if (0 !== (firstChild.flags & 4420)) switch (firstChild.tag) { case 0: case 11: @@ -6168,7 +6156,7 @@ var ceil = Math.ceil, currentEventTime = -1, currentEventTransitionLane = 0; function requestEventTime() { - return 0 !== (executionContext & 24) + return 0 !== (executionContext & 6) ? now() : -1 !== currentEventTime ? currentEventTime @@ -6176,7 +6164,7 @@ function requestEventTime() { } function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 1; - if (0 !== (executionContext & 8) && 0 !== workInProgressRootRenderLanes) + if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; if (0 !== ReactCurrentBatchConfig.transition) return ( @@ -6201,18 +6189,15 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { if (null === root) return null; markRootUpdated(root, lane, eventTime); root === workInProgressRoot && - (0 === (executionContext & 8) && (workInProgressRootUpdatedLanes |= lane), + (0 === (executionContext & 2) && (workInProgressRootUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended$1(root, workInProgressRootRenderLanes)); - 1 === lane - ? 0 !== (executionContext & 4) && 0 === (executionContext & 24) - ? performSyncWorkOnRoot(root) - : (ensureRootIsScheduled(root, eventTime), - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks())) - : ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6302,7 +6287,7 @@ function ensureRootIsScheduled(root, currentTime) { function performConcurrentWorkOnRoot(root, didTimeout) { currentEventTime = -1; currentEventTransitionLane = 0; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); var originalCallbackNode = root.callbackNode; if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) @@ -6321,7 +6306,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if (JSCompiler_inline_result && !didTimeout) { didTimeout = lanes; JSCompiler_inline_result = executionContext; - executionContext |= 8; + executionContext |= 2; var prevDispatcher = pushDispatcher(); if ( workInProgressRoot !== root || @@ -6348,12 +6333,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } else didTimeout = renderRootSync(root, lanes); if (0 !== didTimeout) { 2 === didTimeout && - ((executionContext |= 32), + ((JSCompiler_inline_result = executionContext), + (executionContext |= 8), root.hydrate && (root.hydrate = !1), - (JSCompiler_inline_result = getLanesToRetrySynchronouslyOnError(root)), - 0 !== JSCompiler_inline_result && - ((lanes = JSCompiler_inline_result), - (didTimeout = renderRootSync(root, JSCompiler_inline_result)))); + (prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), + 0 !== prevDispatcher && + ((lanes = prevDispatcher), + (didTimeout = renderRootSync(root, prevDispatcher))), + (executionContext = JSCompiler_inline_result)); if (1 === didTimeout) throw ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), @@ -6453,18 +6440,20 @@ function markRootSuspended$1(root, suspendedLanes) { } } function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); flushPassiveEffects(); var lanes = getNextLanes(root, 0); if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null; var exitStatus = renderRootSync(root, lanes); if (0 !== root.tag && 2 === exitStatus) { - executionContext |= 32; + var prevExecutionContext = executionContext; + executionContext |= 8; root.hydrate && (root.hydrate = !1); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); + executionContext = prevExecutionContext; } if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), @@ -6612,19 +6601,17 @@ function handleError(root$jscomp$0, thrownValue) { var JSCompiler_temp; if ((JSCompiler_temp = 13 === workInProgress$32.tag)) { var nextState = workInProgress$32.memoizedState; - if (null !== nextState) - JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; - else { - var props = workInProgress$32.memoizedProps; - JSCompiler_temp = - void 0 === props.fallback - ? !1 - : !0 !== props.unstable_avoidThisFallback + JSCompiler_temp = + null !== nextState + ? null !== nextState.dehydrated ? !0 - : hasInvisibleParentBoundary - ? !1 - : !0; - } + : !1 + : !0 !== + workInProgress$32.memoizedProps.unstable_avoidThisFallback + ? !0 + : hasInvisibleParentBoundary + ? !1 + : !0; } if (JSCompiler_temp) { var wakeables = workInProgress$32.updateQueue; @@ -6744,7 +6731,7 @@ function pushDispatcher() { } function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; - executionContext |= 8; + executionContext |= 2; var prevDispatcher = pushDispatcher(); (workInProgressRoot === root && workInProgressRootRenderLanes === lanes) || prepareFreshStack(root, lanes); @@ -6830,7 +6817,7 @@ function commitRoot(root) { function commitRootImpl(root, renderPriorityLevel) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); var finishedWork = root.finishedWork, lanes = root.finishedLanes; @@ -6863,7 +6850,7 @@ function commitRootImpl(root, renderPriorityLevel) { var previousPriority = currentUpdatePriority; currentUpdatePriority = 1; var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= 4; ReactCurrentOwner$2.current = null; commitBeforeMutationEffects(root, finishedWork); commitMutationEffects(root, finishedWork); @@ -6892,7 +6879,6 @@ function commitRootImpl(root, renderPriorityLevel) { (root = firstUncaughtError), (firstUncaughtError = null), root); - if (0 !== (executionContext & 4)) return null; 0 !== (pendingPassiveEffectsLanes & 1) && 0 !== root.tag && flushPassiveEffects(); @@ -6913,10 +6899,10 @@ function flushPassiveEffects() { renderPriority = rootWithPendingPassiveEffects; rootWithPendingPassiveEffects = null; pendingPassiveEffectsLanes = 0; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= 4; for (nextEffect = renderPriority.current; null !== nextEffect; ) { var fiber = nextEffect, child = fiber.child; @@ -7926,6 +7912,95 @@ function updateContainer(element, container, parentComponent, callback) { function emptyFindFiberByHostInstance() { return null; } +var emptyObject$1 = {}, + createHierarchy, + getHostNode, + getHostProps, + lastNonHostInstance, + getOwnerHierarchy, + traverseOwnerTreeUp; +createHierarchy = function(fiberHierarchy) { + return fiberHierarchy.map(function(fiber) { + return { + name: getComponentNameFromType(fiber.type), + getInspectorData: function(findNodeHandle) { + return { + props: getHostProps(fiber), + source: fiber._debugSource, + measure: function(callback) { + var hostFiber = findCurrentHostFiber(fiber); + if ( + (hostFiber = + null != hostFiber && + null !== hostFiber.stateNode && + hostFiber.stateNode.node) + ) + nativeFabricUIManager.measure(hostFiber, callback); + else + return ReactNativePrivateInterface.UIManager.measure( + getHostNode(fiber, findNodeHandle), + callback + ); + } + }; + } + }; + }); +}; +getHostNode = function(fiber, findNodeHandle) { + for (var hostNode; fiber; ) { + null !== fiber.stateNode && + 5 === fiber.tag && + (hostNode = findNodeHandle(fiber.stateNode)); + if (hostNode) return hostNode; + fiber = fiber.child; + } + return null; +}; +getHostProps = function(fiber) { + return (fiber = findCurrentHostFiber(fiber)) + ? fiber.memoizedProps || emptyObject$1 + : emptyObject$1; +}; +exports.getInspectorDataForInstance = function(closestInstance) { + if (!closestInstance) + return { + hierarchy: [], + props: emptyObject$1, + selectedIndex: null, + source: null + }; + closestInstance = findCurrentFiberUsingSlowPath(closestInstance); + var fiberHierarchy = getOwnerHierarchy(closestInstance), + instance = lastNonHostInstance(fiberHierarchy); + closestInstance = createHierarchy(fiberHierarchy); + var props = getHostProps(instance), + source = instance._debugSource; + fiberHierarchy = fiberHierarchy.indexOf(instance); + return { + hierarchy: closestInstance, + props: props, + selectedIndex: fiberHierarchy, + source: source + }; +}; +getOwnerHierarchy = function(instance) { + var hierarchy = []; + traverseOwnerTreeUp(hierarchy, instance); + return hierarchy; +}; +lastNonHostInstance = function(hierarchy) { + for (var i = hierarchy.length - 1; 1 < i; i--) { + var instance = hierarchy[i]; + if (5 !== instance.tag) return instance; + } + return hierarchy[0]; +}; +traverseOwnerTreeUp = function(hierarchy, instance) { + instance && + (hierarchy.unshift(instance), + traverseOwnerTreeUp(hierarchy, instance._debugOwner)); +}; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; @@ -7959,10 +8034,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_983 = { + devToolsConfig$jscomp$inline_981 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-cae635054-20210626", + version: "18.0.0-419cc9c37-20210726", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -7977,11 +8052,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1237 = { - bundleType: devToolsConfig$jscomp$inline_983.bundleType, - version: devToolsConfig$jscomp$inline_983.version, - rendererPackageName: devToolsConfig$jscomp$inline_983.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_983.rendererConfig, +var internals$jscomp$inline_1228 = { + bundleType: devToolsConfig$jscomp$inline_981.bundleType, + version: devToolsConfig$jscomp$inline_981.version, + rendererPackageName: devToolsConfig$jscomp$inline_981.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_981.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -7997,26 +8072,26 @@ var internals$jscomp$inline_1237 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_983.findFiberByHostInstance || + devToolsConfig$jscomp$inline_981.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-cae635054-20210626" + reconcilerVersion: "18.0.0-419cc9c37-20210726" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1238 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1229 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1238.isDisabled && - hook$jscomp$inline_1238.supportsFiber + !hook$jscomp$inline_1229.isDisabled && + hook$jscomp$inline_1229.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1238.inject( - internals$jscomp$inline_1237 + (rendererID = hook$jscomp$inline_1229.inject( + internals$jscomp$inline_1228 )), - (injectedHook = hook$jscomp$inline_1238); + (injectedHook = hook$jscomp$inline_1229); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { @@ -8036,12 +8111,10 @@ exports.createPortal = function(children, containerTag) { }; exports.dispatchCommand = function(handle, command, args) { null != handle._nativeTag && - (handle._internalInstanceHandle - ? nativeFabricUIManager.dispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ) + (null != handle._internalInstanceHandle + ? ((handle = handle._internalInstanceHandle.stateNode), + null != handle && + nativeFabricUIManager.dispatchCommand(handle.node, command, args)) : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( handle._nativeTag, command, @@ -8086,11 +8159,10 @@ exports.render = function(element, containerTag, callback) { }; exports.sendAccessibilityEvent = function(handle, eventType) { null != handle._nativeTag && - (handle._internalInstanceHandle - ? nativeFabricUIManager.sendAccessibilityEvent( - handle._internalInstanceHandle.stateNode.node, - eventType - ) + (null != handle._internalInstanceHandle + ? ((handle = handle._internalInstanceHandle.stateNode), + null != handle && + nativeFabricUIManager.sendAccessibilityEvent(handle.node, eventType)) : ReactNativePrivateInterface.legacySendAccessibilityEvent( handle._nativeTag, eventType diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 69d8e1ccc0..2c8a86864c 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<<77d835ca6cf96fe4731cd307ffa7cac7>> + * @generated SignedSource<> */ "use strict"; @@ -930,7 +930,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_227 = { +var injectedNamesToPlugins$jscomp$inline_232 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -965,34 +965,34 @@ var injectedNamesToPlugins$jscomp$inline_227 = { } } }, - isOrderingDirty$jscomp$inline_228 = !1, - pluginName$jscomp$inline_229; -for (pluginName$jscomp$inline_229 in injectedNamesToPlugins$jscomp$inline_227) + isOrderingDirty$jscomp$inline_233 = !1, + pluginName$jscomp$inline_234; +for (pluginName$jscomp$inline_234 in injectedNamesToPlugins$jscomp$inline_232) if ( - injectedNamesToPlugins$jscomp$inline_227.hasOwnProperty( - pluginName$jscomp$inline_229 + injectedNamesToPlugins$jscomp$inline_232.hasOwnProperty( + pluginName$jscomp$inline_234 ) ) { - var pluginModule$jscomp$inline_230 = - injectedNamesToPlugins$jscomp$inline_227[pluginName$jscomp$inline_229]; + var pluginModule$jscomp$inline_235 = + injectedNamesToPlugins$jscomp$inline_232[pluginName$jscomp$inline_234]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_229) || - namesToPlugins[pluginName$jscomp$inline_229] !== - pluginModule$jscomp$inline_230 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_234) || + namesToPlugins[pluginName$jscomp$inline_234] !== + pluginModule$jscomp$inline_235 ) { - if (namesToPlugins[pluginName$jscomp$inline_229]) + if (namesToPlugins[pluginName$jscomp$inline_234]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_229 + + pluginName$jscomp$inline_234 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_229 - ] = pluginModule$jscomp$inline_230; - isOrderingDirty$jscomp$inline_228 = !0; + pluginName$jscomp$inline_234 + ] = pluginModule$jscomp$inline_235; + isOrderingDirty$jscomp$inline_233 = !0; } } -isOrderingDirty$jscomp$inline_228 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_233 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -2284,7 +2284,7 @@ function enqueueUpdate(fiber, update) { ((updateQueue = updateQueue.shared), null !== workInProgressRoot && 0 !== (fiber.mode & 1) && - 0 === (executionContext & 8) + 0 === (executionContext & 2) ? ((fiber = updateQueue.interleaved), null === fiber ? ((update.next = update), @@ -3121,60 +3121,49 @@ function ChildReconciler(shouldTrackSideEffects) { return iteratorFn; } return function(returnFiber, currentFirstChild, newChild, lanes) { - var isUnkeyedTopLevelFragment = - "object" === typeof newChild && + "object" === typeof newChild && null !== newChild && newChild.type === REACT_FRAGMENT_TYPE && - null === newChild.key; - isUnkeyedTopLevelFragment && (newChild = newChild.props.children); + null === newChild.key && + (newChild = newChild.props.children); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: a: { - var key = newChild.key; for ( - isUnkeyedTopLevelFragment = currentFirstChild; - null !== isUnkeyedTopLevelFragment; + var key = newChild.key, child = currentFirstChild; + null !== child; ) { - if (isUnkeyedTopLevelFragment.key === key) { + if (child.key === key) { key = newChild.type; if (key === REACT_FRAGMENT_TYPE) { - if (7 === isUnkeyedTopLevelFragment.tag) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); + if (7 === child.tag) { + deleteRemainingChildren(returnFiber, child.sibling); currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, + child, newChild.props.children ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; } - } else if (isUnkeyedTopLevelFragment.elementType === key) { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment.sibling - ); - currentFirstChild = useFiber( - isUnkeyedTopLevelFragment, - newChild.props - ); + } else if (child.elementType === key) { + deleteRemainingChildren(returnFiber, child.sibling); + currentFirstChild = useFiber(child, newChild.props); currentFirstChild.ref = coerceRef( returnFiber, - isUnkeyedTopLevelFragment, + child, newChild ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; } - deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, child); break; - } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); - isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; + } else deleteChild(returnFiber, child); + child = child.sibling; } newChild.type === REACT_FRAGMENT_TYPE ? ((currentFirstChild = createFiberFromFragment( @@ -3204,12 +3193,8 @@ function ChildReconciler(shouldTrackSideEffects) { return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: a: { - for ( - isUnkeyedTopLevelFragment = newChild.key; - null !== currentFirstChild; - - ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + for (child = newChild.key; null !== currentFirstChild; ) { + if (currentFirstChild.key === child) if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -3261,9 +3246,8 @@ function ChildReconciler(shouldTrackSideEffects) { ); throwOnInvalidObjectType(returnFiber, newChild); } - if ("string" === typeof newChild || "number" === typeof newChild) - return ( - (newChild = "" + newChild), + return "string" === typeof newChild || "number" === typeof newChild + ? ((newChild = "" + newChild), null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber(currentFirstChild, newChild)), @@ -3277,20 +3261,8 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), - placeSingleChild(returnFiber) - ); - if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) - switch (returnFiber.tag) { - case 1: - case 0: - case 11: - case 15: - throw Error( - (getComponentNameFromFiber(returnFiber) || "Component") + - "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." - ); - } - return deleteRemainingChildren(returnFiber, currentFirstChild); + placeSingleChild(returnFiber)) + : deleteRemainingChildren(returnFiber, currentFirstChild); }; } var reconcileChildFibers = ChildReconciler(!0), @@ -3845,7 +3817,7 @@ function dispatchAction(fiber, queue, action) { if ( null !== workInProgressRoot && 0 !== (fiber.mode & 1) && - 0 === (executionContext & 8) + 0 === (executionContext & 2) ) { var interleaved = queue.interleaved; null === interleaved @@ -4697,7 +4669,6 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { JSCompiler_temp ? ((showFallback = !0), (workInProgress.flags &= -129)) : (null !== current && null === current.memoizedState) || - void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); @@ -5287,7 +5258,11 @@ function completeWork(current, workInProgress, renderLanes) { newProps = null !== newProps; renderLanes = !1; null !== current && (renderLanes = null !== current.memoizedState); - if (newProps && !renderLanes && 0 !== (workInProgress.mode & 1)) + if ( + newProps && + !renderLanes && + ((workInProgress.child.flags |= 4096), 0 !== (workInProgress.mode & 1)) + ) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || @@ -5309,7 +5284,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootRenderLanes ); } - if (newProps || renderLanes) workInProgress.flags |= 4; + null !== workInProgress.updateQueue && (workInProgress.flags |= 4); bubbleProperties(workInProgress); 0 !== (workInProgress.mode & 2) && newProps && @@ -5468,11 +5443,16 @@ function completeWork(current, workInProgress, renderLanes) { null !== current && (null !== current.memoizedState) !== renderLanes && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.flags |= 4), - (renderLanes && - 0 === (subtreeRenderLanes & 1073741824) && - 0 !== (workInProgress.mode & 1)) || - bubbleProperties(workInProgress), + 23 !== workInProgress.tag && + (workInProgress.flags |= 4096), + renderLanes && 0 !== (workInProgress.mode & 1) + ? 0 !== (subtreeRenderLanes & 1073741824) && + (bubbleProperties(workInProgress), + 23 !== workInProgress.tag && + workInProgress.subtreeFlags & 6 && + "unstable-defer-without-hiding" !== newProps.mode && + (workInProgress.flags |= 4096)) + : bubbleProperties(workInProgress), null ); } @@ -5656,68 +5636,6 @@ function commitHookEffectListMount(tag, finishedWork) { } while (effect !== finishedWork); } } -function hideOrUnhideAllChildren(finishedWork, isHidden) { - for (var hostSubtreeRoot = null, node = finishedWork; ; ) { - if (5 === node.tag) { - if (null === hostSubtreeRoot) { - hostSubtreeRoot = node; - var instance = node.stateNode; - if (isHidden) { - var viewConfig = instance.viewConfig; - var updatePayload = diffProperties( - null, - emptyObject, - { style: { display: "none" } }, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, - viewConfig.uiViewClassName, - updatePayload - ); - } else { - instance = node.stateNode; - updatePayload = node.memoizedProps; - viewConfig = instance.viewConfig; - var prevProps = Object.assign({}, updatePayload, { - style: [updatePayload.style, { display: "none" }] - }); - updatePayload = diffProperties( - null, - prevProps, - updatePayload, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, - viewConfig.uiViewClassName, - updatePayload - ); - } - } - } else if (6 === node.tag) { - if (null === hostSubtreeRoot) throw Error("Not yet implemented."); - } else if ( - ((22 !== node.tag && 23 !== node.tag) || - null === node.memoizedState || - node === finishedWork) && - null !== node.child - ) { - node.child.return = node; - node = node.child; - continue; - } - if (node === finishedWork) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === finishedWork) return; - hostSubtreeRoot === node && (hostSubtreeRoot = null); - node = node.return; - } - hostSubtreeRoot === node && (hostSubtreeRoot = null); - node.sibling.return = node.return; - node = node.sibling; - } -} function commitUnmount(finishedRoot, current, nearestMountedAncestor) { if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount) try { @@ -6113,9 +6031,6 @@ function commitWork(current, finishedWork) { case 12: return; case 13: - null !== finishedWork.memoizedState && - ((globalMostRecentFallbackTime = now()), - hideOrUnhideAllChildren(finishedWork.child, !0)); attachSuspenseRetryListeners(finishedWork); return; case 19: @@ -6123,13 +6038,6 @@ function commitWork(current, finishedWork) { return; case 17: return; - case 22: - case 23: - hideOrUnhideAllChildren( - finishedWork, - null !== finishedWork.memoizedState - ); - return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." @@ -6201,6 +6109,87 @@ function commitMutationEffects(root, firstChild, committedLanes) { else currentRef.current = null; } } + if (flags & 4096) + switch (firstChild.tag) { + case 13: + if (null !== firstChild.memoizedState) { + var current$95 = firstChild.alternate; + if (null === current$95 || null === current$95.memoizedState) + globalMostRecentFallbackTime = now(); + } + break; + case 22: + a: { + committedLanes = firstChild; + var isHidden = null !== firstChild.memoizedState; + i = null; + for (childToDelete = committedLanes; ; ) { + if (5 === childToDelete.tag) { + if (null === i) { + i = childToDelete; + var instance = childToDelete.stateNode; + if (isHidden) { + var instance$jscomp$0 = instance, + viewConfig = instance$jscomp$0.viewConfig; + var updatePayload = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + instance$jscomp$0._nativeTag, + viewConfig.uiViewClassName, + updatePayload + ); + } else { + var instance$jscomp$1 = childToDelete.stateNode, + props = childToDelete.memoizedProps, + viewConfig$jscomp$0 = instance$jscomp$1.viewConfig, + prevProps = Object.assign({}, props, { + style: [props.style, { display: "none" }] + }); + var updatePayload$jscomp$0 = diffProperties( + null, + prevProps, + props, + viewConfig$jscomp$0.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + instance$jscomp$1._nativeTag, + viewConfig$jscomp$0.uiViewClassName, + updatePayload$jscomp$0 + ); + } + } + } else if (6 === childToDelete.tag) { + if (null === i) throw Error("Not yet implemented."); + } else if ( + ((22 !== childToDelete.tag && 23 !== childToDelete.tag) || + null === childToDelete.memoizedState || + childToDelete === committedLanes) && + null !== childToDelete.child + ) { + childToDelete.child.return = childToDelete; + childToDelete = childToDelete.child; + continue; + } + if (childToDelete === committedLanes) break; + for (; null === childToDelete.sibling; ) { + if ( + null === childToDelete.return || + childToDelete.return === committedLanes + ) + break a; + i === childToDelete && (i = null); + childToDelete = childToDelete.return; + } + i === childToDelete && (i = null); + childToDelete.sibling.return = childToDelete.return; + childToDelete = childToDelete.sibling; + } + } + } switch (flags & 2054) { case 2: commitPlacement(firstChild); @@ -6242,16 +6231,16 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { if ( ((root = nextEffect), (committedLanes = root.child), - 0 !== (root.subtreeFlags & 324) && null !== committedLanes) + 0 !== (root.subtreeFlags & 4420) && null !== committedLanes) ) (committedLanes.return = root), (nextEffect = committedLanes); else for (root = finishedWork; null !== nextEffect; ) { committedLanes = nextEffect; - if (0 !== (committedLanes.flags & 324)) { + if (0 !== (committedLanes.flags & 4420)) { var current = committedLanes.alternate; try { - if (0 !== (committedLanes.flags & 68)) + if (0 !== (committedLanes.flags & 4420)) switch (committedLanes.tag) { case 0: case 11: @@ -6459,7 +6448,7 @@ var ceil = Math.ceil, currentEventTime = -1, currentEventTransitionLane = 0; function requestEventTime() { - return 0 !== (executionContext & 24) + return 0 !== (executionContext & 6) ? now() : -1 !== currentEventTime ? currentEventTime @@ -6467,7 +6456,7 @@ function requestEventTime() { } function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 1; - if (0 !== (executionContext & 8) && 0 !== workInProgressRootRenderLanes) + if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; if (0 !== ReactCurrentBatchConfig.transition) return ( @@ -6493,18 +6482,15 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { isDevToolsPresent && addFiberToLanesMap(root, fiber, lane); markRootUpdated(root, lane, eventTime); root === workInProgressRoot && - (0 === (executionContext & 8) && (workInProgressRootUpdatedLanes |= lane), + (0 === (executionContext & 2) && (workInProgressRootUpdatedLanes |= lane), 4 === workInProgressRootExitStatus && markRootSuspended$1(root, workInProgressRootRenderLanes)); - 1 === lane - ? 0 !== (executionContext & 4) && 0 === (executionContext & 24) - ? performSyncWorkOnRoot(root) - : (ensureRootIsScheduled(root, eventTime), - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks())) - : ensureRootIsScheduled(root, eventTime); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6595,7 +6581,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { nestedUpdateScheduled = currentUpdateIsNested = !1; currentEventTime = -1; currentEventTransitionLane = 0; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); var originalCallbackNode = root.callbackNode; if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) @@ -6614,7 +6600,7 @@ function performConcurrentWorkOnRoot(root, didTimeout) { if (JSCompiler_inline_result && !didTimeout) { didTimeout = lanes; JSCompiler_inline_result = executionContext; - executionContext |= 8; + executionContext |= 2; var prevDispatcher = pushDispatcher(); if ( workInProgressRoot !== root || @@ -6649,12 +6635,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } else didTimeout = renderRootSync(root, lanes); if (0 !== didTimeout) { 2 === didTimeout && - ((executionContext |= 32), + ((JSCompiler_inline_result = executionContext), + (executionContext |= 8), root.hydrate && (root.hydrate = !1), - (JSCompiler_inline_result = getLanesToRetrySynchronouslyOnError(root)), - 0 !== JSCompiler_inline_result && - ((lanes = JSCompiler_inline_result), - (didTimeout = renderRootSync(root, JSCompiler_inline_result)))); + (prevDispatcher = getLanesToRetrySynchronouslyOnError(root)), + 0 !== prevDispatcher && + ((lanes = prevDispatcher), + (didTimeout = renderRootSync(root, prevDispatcher))), + (executionContext = JSCompiler_inline_result)); if (1 === didTimeout) throw ((originalCallbackNode = workInProgressRootFatalError), prepareFreshStack(root, 0), @@ -6755,18 +6743,20 @@ function markRootSuspended$1(root, suspendedLanes) { function performSyncWorkOnRoot(root) { currentUpdateIsNested = nestedUpdateScheduled; nestedUpdateScheduled = !1; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); flushPassiveEffects(); var lanes = getNextLanes(root, 0); if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null; var exitStatus = renderRootSync(root, lanes); if (0 !== root.tag && 2 === exitStatus) { - executionContext |= 32; + var prevExecutionContext = executionContext; + executionContext |= 8; root.hydrate && (root.hydrate = !1); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); + executionContext = prevExecutionContext; } if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), @@ -6917,19 +6907,17 @@ function handleError(root$jscomp$0, thrownValue) { var JSCompiler_temp; if ((JSCompiler_temp = 13 === workInProgress$34.tag)) { var nextState = workInProgress$34.memoizedState; - if (null !== nextState) - JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; - else { - var props = workInProgress$34.memoizedProps; - JSCompiler_temp = - void 0 === props.fallback - ? !1 - : !0 !== props.unstable_avoidThisFallback + JSCompiler_temp = + null !== nextState + ? null !== nextState.dehydrated ? !0 - : hasInvisibleParentBoundary - ? !1 - : !0; - } + : !1 + : !0 !== + workInProgress$34.memoizedProps.unstable_avoidThisFallback + ? !0 + : hasInvisibleParentBoundary + ? !1 + : !0; } if (JSCompiler_temp) { var wakeables = workInProgress$34.updateQueue; @@ -7050,7 +7038,7 @@ function pushDispatcher() { } function renderRootSync(root, lanes) { var prevExecutionContext = executionContext; - executionContext |= 8; + executionContext |= 2; var prevDispatcher = pushDispatcher(); if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { if (isDevToolsPresent) { @@ -7165,7 +7153,7 @@ function commitRoot(root) { function commitRootImpl(root, renderPriorityLevel) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Should not already be working."); var finishedWork = root.finishedWork, lanes = root.finishedLanes; @@ -7198,7 +7186,7 @@ function commitRootImpl(root, renderPriorityLevel) { var previousPriority = currentUpdatePriority; currentUpdatePriority = 1; var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= 4; ReactCurrentOwner$2.current = null; commitBeforeMutationEffects(root, finishedWork); commitTime = now$1(); @@ -7230,7 +7218,6 @@ function commitRootImpl(root, renderPriorityLevel) { (root = firstUncaughtError), (firstUncaughtError = null), root); - if (0 !== (executionContext & 4)) return null; 0 !== (pendingPassiveEffectsLanes & 1) && 0 !== root.tag && flushPassiveEffects(); @@ -7251,10 +7238,10 @@ function flushPassiveEffects() { renderPriority = rootWithPendingPassiveEffects; rootWithPendingPassiveEffects = null; pendingPassiveEffectsLanes = 0; - if (0 !== (executionContext & 24)) + if (0 !== (executionContext & 6)) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= 4; for (nextEffect = renderPriority.current; null !== nextEffect; ) { var fiber = nextEffect, child = fiber.child; @@ -8358,6 +8345,95 @@ function updateContainer(element, container, parentComponent, callback) { function emptyFindFiberByHostInstance() { return null; } +var emptyObject$1 = {}, + createHierarchy, + getHostNode, + getHostProps, + lastNonHostInstance, + getOwnerHierarchy, + traverseOwnerTreeUp; +createHierarchy = function(fiberHierarchy) { + return fiberHierarchy.map(function(fiber) { + return { + name: getComponentNameFromType(fiber.type), + getInspectorData: function(findNodeHandle) { + return { + props: getHostProps(fiber), + source: fiber._debugSource, + measure: function(callback) { + var hostFiber = findCurrentHostFiber(fiber); + if ( + (hostFiber = + null != hostFiber && + null !== hostFiber.stateNode && + hostFiber.stateNode.node) + ) + nativeFabricUIManager.measure(hostFiber, callback); + else + return ReactNativePrivateInterface.UIManager.measure( + getHostNode(fiber, findNodeHandle), + callback + ); + } + }; + } + }; + }); +}; +getHostNode = function(fiber, findNodeHandle) { + for (var hostNode; fiber; ) { + null !== fiber.stateNode && + 5 === fiber.tag && + (hostNode = findNodeHandle(fiber.stateNode)); + if (hostNode) return hostNode; + fiber = fiber.child; + } + return null; +}; +getHostProps = function(fiber) { + return (fiber = findCurrentHostFiber(fiber)) + ? fiber.memoizedProps || emptyObject$1 + : emptyObject$1; +}; +exports.getInspectorDataForInstance = function(closestInstance) { + if (!closestInstance) + return { + hierarchy: [], + props: emptyObject$1, + selectedIndex: null, + source: null + }; + closestInstance = findCurrentFiberUsingSlowPath(closestInstance); + var fiberHierarchy = getOwnerHierarchy(closestInstance), + instance = lastNonHostInstance(fiberHierarchy); + closestInstance = createHierarchy(fiberHierarchy); + var props = getHostProps(instance), + source = instance._debugSource; + fiberHierarchy = fiberHierarchy.indexOf(instance); + return { + hierarchy: closestInstance, + props: props, + selectedIndex: fiberHierarchy, + source: source + }; +}; +getOwnerHierarchy = function(instance) { + var hierarchy = []; + traverseOwnerTreeUp(hierarchy, instance); + return hierarchy; +}; +lastNonHostInstance = function(hierarchy) { + for (var i = hierarchy.length - 1; 1 < i; i--) { + var instance = hierarchy[i]; + if (5 !== instance.tag) return instance; + } + return hierarchy[0]; +}; +traverseOwnerTreeUp = function(hierarchy, instance) { + instance && + (hierarchy.unshift(instance), + traverseOwnerTreeUp(hierarchy, instance._debugOwner)); +}; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; @@ -8391,10 +8467,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1013 = { + devToolsConfig$jscomp$inline_1011 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-cae635054-20210626", + version: "18.0.0-419cc9c37-20210726", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8409,11 +8485,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1287 = { - bundleType: devToolsConfig$jscomp$inline_1013.bundleType, - version: devToolsConfig$jscomp$inline_1013.version, - rendererPackageName: devToolsConfig$jscomp$inline_1013.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1013.rendererConfig, +var internals$jscomp$inline_1278 = { + bundleType: devToolsConfig$jscomp$inline_1011.bundleType, + version: devToolsConfig$jscomp$inline_1011.version, + rendererPackageName: devToolsConfig$jscomp$inline_1011.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1011.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8429,26 +8505,26 @@ var internals$jscomp$inline_1287 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1013.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1011.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-cae635054-20210626" + reconcilerVersion: "18.0.0-419cc9c37-20210726" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1288 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1279 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1288.isDisabled && - hook$jscomp$inline_1288.supportsFiber + !hook$jscomp$inline_1279.isDisabled && + hook$jscomp$inline_1279.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1288.inject( - internals$jscomp$inline_1287 + (rendererID = hook$jscomp$inline_1279.inject( + internals$jscomp$inline_1278 )), - (injectedHook = hook$jscomp$inline_1288); + (injectedHook = hook$jscomp$inline_1279); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { @@ -8468,12 +8544,10 @@ exports.createPortal = function(children, containerTag) { }; exports.dispatchCommand = function(handle, command, args) { null != handle._nativeTag && - (handle._internalInstanceHandle - ? nativeFabricUIManager.dispatchCommand( - handle._internalInstanceHandle.stateNode.node, - command, - args - ) + (null != handle._internalInstanceHandle + ? ((handle = handle._internalInstanceHandle.stateNode), + null != handle && + nativeFabricUIManager.dispatchCommand(handle.node, command, args)) : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( handle._nativeTag, command, @@ -8525,11 +8599,10 @@ exports.render = function(element, containerTag, callback) { }; exports.sendAccessibilityEvent = function(handle, eventType) { null != handle._nativeTag && - (handle._internalInstanceHandle - ? nativeFabricUIManager.sendAccessibilityEvent( - handle._internalInstanceHandle.stateNode.node, - eventType - ) + (null != handle._internalInstanceHandle + ? ((handle = handle._internalInstanceHandle.stateNode), + null != handle && + nativeFabricUIManager.sendAccessibilityEvent(handle.node, eventType)) : ReactNativePrivateInterface.legacySendAccessibilityEvent( handle._nativeTag, eventType