diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js index 94fe3406f7eca..46125477496c6 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<7ba027f268ac025f6f9101e98d1ea585>> */ 'use strict'; @@ -562,578 +562,969 @@ var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; -var currentOwner = null; -function setCurrentOwner(fiber) { - currentOwner = fiber; -} - -function getNearestMountedFiber(fiber) { - var node = fiber; - var nearestMounted = fiber; - - if (!fiber.alternate) { - // If there is no alternate, this might be a new tree that isn't inserted - // yet. If it is, then it will have a pending insertion effect on it. - var nextNode = node; +// Helpers to patch console.logs to avoid logging during side-effect free +// replaying on render function. This currently only patches the object +// lazily which won't cover if the log function was extracted eagerly. +// We could also eagerly patch the method. +var disabledDepth = 0; +var prevLog; +var prevInfo; +var prevWarn; +var prevError; +var prevGroup; +var prevGroupCollapsed; +var prevGroupEnd; - do { - node = nextNode; +function disabledLog() {} - if ((node.flags & (Placement | Hydrating)) !== NoFlags$1) { - // This is an insertion or in-progress hydration. The nearest possible - // mounted fiber is the parent but we need to continue to figure out - // if that one is still mounted. - nearestMounted = node.return; - } // $FlowFixMe[incompatible-type] we bail out when we get a null +disabledLog.__reactDisabledLog = true; +function disableLogs() { + { + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + prevLog = console.log; + prevInfo = console.info; + prevWarn = console.warn; + prevError = console.error; + prevGroup = console.group; + prevGroupCollapsed = console.groupCollapsed; + prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 + var props = { + configurable: true, + enumerable: true, + value: disabledLog, + writable: true + }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. - nextNode = node.return; - } while (nextNode); - } else { - while (node.return) { - node = node.return; + Object.defineProperties(console, { + info: props, + log: props, + warn: props, + error: props, + group: props, + groupCollapsed: props, + groupEnd: props + }); + /* eslint-enable react-internal/no-production-logging */ } - } - - if (node.tag === HostRoot) { - // TODO: Check if this was a nested HostRoot when used with - // renderContainerIntoSubtree. - return nearestMounted; - } // If we didn't hit the root, that means that we're in an disconnected tree - // that has been unmounted. - - return null; -} -function isFiberMounted(fiber) { - return getNearestMountedFiber(fiber) === fiber; + disabledDepth++; + } } -function isMounted(component) { +function reenableLogs() { { - var owner = currentOwner; + disabledDepth--; - if (owner !== null && owner.tag === ClassComponent) { - var ownerFiber = owner; - var instance = ownerFiber.stateNode; + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + var props = { + configurable: true, + enumerable: true, + writable: true + }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. - if (!instance._warnedAboutRefsInRender) { - error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentNameFromFiber(ownerFiber) || 'A component'); - } + Object.defineProperties(console, { + log: assign({}, props, { + value: prevLog + }), + info: assign({}, props, { + value: prevInfo + }), + warn: assign({}, props, { + value: prevWarn + }), + error: assign({}, props, { + value: prevError + }), + group: assign({}, props, { + value: prevGroup + }), + groupCollapsed: assign({}, props, { + value: prevGroupCollapsed + }), + groupEnd: assign({}, props, { + value: prevGroupEnd + }) + }); + /* eslint-enable react-internal/no-production-logging */ + } - instance._warnedAboutRefsInRender = true; + if (disabledDepth < 0) { + error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); } } +} - var fiber = get(component); +var prefix; +function describeBuiltInComponentFrame(name) { + { + if (prefix === undefined) { + // Extract the VM specific prefix used by each line. + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = match && match[1] || ''; + } + } // We use the prefix to ensure our stacks line up with native stack frames. - if (!fiber) { - return false; - } - return getNearestMountedFiber(fiber) === fiber; + return '\n' + prefix + name; + } +} +function describeDebugInfoFrame(name, env) { + return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : '')); } +var reentry = false; +var componentFrameCache; -function assertIsMounted(fiber) { - if (getNearestMountedFiber(fiber) !== fiber) { - throw new Error('Unable to find node on an unmounted component.'); - } +{ + var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap$1(); } +/** + * Leverages native browser/VM stack frames to get proper details (e.g. + * filename, line + col number) for a single component in a component stack. We + * do this by: + * (1) throwing and catching an error in the function - this will be our + * control error. + * (2) calling the component which will eventually throw an error that we'll + * catch - this will be our sample error. + * (3) diffing the control and sample error stacks to find the stack frame + * which represents our component. + */ -function findCurrentFiberUsingSlowPath(fiber) { - var alternate = fiber.alternate; - if (!alternate) { - // If there is no alternate, then we only need to check if it is mounted. - var nearestMounted = getNearestMountedFiber(fiber); +function describeNativeComponentFrame(fn, construct) { + // If something asked for a stack inside a fake render, it should get ignored. + if (!fn || reentry) { + return ''; + } - if (nearestMounted === null) { - throw new Error('Unable to find node on an unmounted component.'); - } + { + var frame = componentFrameCache.get(fn); - if (nearestMounted !== fiber) { - return null; + if (frame !== undefined) { + return frame; } + } - return fiber; - } // If we have two possible branches, we'll walk backwards up to the root - // to see what path the root points to. On the way we may hit one of the - // special cases and we'll deal with them. - - - var a = fiber; - var b = alternate; - - while (true) { - var parentA = a.return; + reentry = true; + var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. - if (parentA === null) { - // We're at the root. - break; - } + Error.prepareStackTrace = undefined; + var previousDispatcher = null; - var parentB = parentA.alternate; + { + previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + // for warnings. - if (parentB === null) { - // There is no alternate. This is an unusual case. Currently, it only - // happens when a Suspense component is hidden. An extra fragment fiber - // is inserted in between the Suspense fiber and its children. Skip - // over this extra fragment fiber and proceed to the next parent. - var nextParent = parentA.return; + ReactSharedInternals.H = null; + disableLogs(); + } + /** + * Finding a common stack frame between sample and control errors can be + * tricky given the different types and levels of stack trace truncation from + * different JS VMs. So instead we'll attempt to control what that common + * frame should be through this object method: + * Having both the sample and control errors be in the function under the + * `DescribeNativeComponentFrameRoot` property, + setting the `name` and + * `displayName` properties of the function ensures that a stack + * frame exists that has the method name `DescribeNativeComponentFrameRoot` in + * it for both control and sample stacks. + */ - if (nextParent !== null) { - a = b = nextParent; - continue; - } // If there's no parent, we're at the root. + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + var control; - break; - } // If both copies of the parent fiber point to the same child, we can - // assume that the child is current. This happens when we bailout on low - // priority: the bailed out fiber's child reuses the current child. + try { + // This should throw. + if (construct) { + // Something should be setting the props in the constructor. + var Fake = function () { + throw Error(); + }; // $FlowFixMe[prop-missing] - if (parentA.child === parentB.child) { - var child = parentA.child; + Object.defineProperty(Fake.prototype, 'props', { + set: function () { + // We use a throwing setter instead of frozen or non-writable props + // because that won't throw in a non-strict mode function. + throw Error(); + } + }); - while (child) { - if (child === a) { - // We've determined that A is the current branch. - assertIsMounted(parentA); - return fiber; - } + if (typeof Reflect === 'object' && Reflect.construct) { + // We construct a different control for this case to include any extra + // frames added by the construct call. + try { + Reflect.construct(Fake, []); + } catch (x) { + control = x; + } - if (child === b) { - // We've determined that B is the current branch. - assertIsMounted(parentA); - return alternate; - } + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x) { + control = x; + } // $FlowFixMe[prop-missing] found when upgrading Flow - child = child.sibling; - } // We should never have an alternate for any mounting node. So the only - // way this could possibly happen is if this was unmounted, if at all. + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x) { + control = x; + } // TODO(luna): This will currently only throw if the function component + // tries to access React/ReactDOM/props. We should probably make this throw + // in simple components too - throw new Error('Unable to find node on an unmounted component.'); - } - if (a.return !== b.return) { - // The return pointer of A and the return pointer of B point to different - // fibers. We assume that return pointers never criss-cross, so A must - // belong to the child set of A.return, and B must belong to the child - // set of B.return. - a = parentA; - b = parentB; - } else { - // The return pointers point to the same fiber. We'll have to use the - // default, slow path: scan the child sets of each parent alternate to see - // which child belongs to which set. - // - // Search parent A's child set - var didFindChild = false; - var _child = parentA.child; + var maybePromise = fn(); // If the function component returns a promise, it's likely an async + // component, which we don't yet support. Attach a noop catch handler to + // silence the error. + // TODO: Implement component stacks for async client components? - while (_child) { - if (_child === a) { - didFindChild = true; - a = parentA; - b = parentB; - break; + if (maybePromise && typeof maybePromise.catch === 'function') { + maybePromise.catch(function () {}); + } } - - if (_child === b) { - didFindChild = true; - b = parentA; - a = parentB; - break; + } catch (sample) { + // This is inlined manually because closure doesn't do it for us. + if (sample && control && typeof sample.stack === 'string') { + return [sample.stack, control.stack]; } - - _child = _child.sibling; } - if (!didFindChild) { - // Search parent B's child set - _child = parentB.child; + return [null, null]; + } + }; // $FlowFixMe[prop-missing] - while (_child) { - if (_child === a) { - didFindChild = true; - a = parentB; - b = parentA; - break; - } + RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; + var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable. - if (_child === b) { - didFindChild = true; - b = parentB; - a = parentA; - break; - } + if (namePropDescriptor && namePropDescriptor.configurable) { + // V8 utilizes a function's `name` property when generating a stack trace. + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor + // is set to `false`. + // $FlowFixMe[cannot-write] + 'name', { + value: 'DetermineComponentFrameRoot' + }); + } - _child = _child.sibling; - } + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; - if (!didFindChild) { - throw new Error('Child was not found in either parent set. This indicates a bug ' + 'in React related to the return pointer. Please file an issue.'); - } + if (sampleStack && controlStack) { + // This extracts the first frame from the sample that isn't also in the control. + // Skipping one frame that we assume is the frame that calls the two. + var sampleLines = sampleStack.split('\n'); + var controlLines = controlStack.split('\n'); + var s = 0; + var c = 0; + + while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { + s++; } - } - if (a.alternate !== b) { - throw new Error("Return fibers should always be each others' alternates. " + 'This error is likely caused by a bug in React. Please file an issue.'); - } - } // If the root is not a host container, we're in a disconnected tree. I.e. - // unmounted. + while (c < controlLines.length && !controlLines[c].includes('DetermineComponentFrameRoot')) { + c++; + } // We couldn't find our intentionally injected common root frame, attempt + // to find another common root frame by search from the bottom of the + // control stack... - if (a.tag !== HostRoot) { - throw new Error('Unable to find node on an unmounted component.'); - } + if (s === sampleLines.length || c === controlLines.length) { + s = sampleLines.length - 1; + c = controlLines.length - 1; - if (a.stateNode.current === a) { - // We've determined that A is the current branch. - return fiber; - } // Otherwise B has to be current branch. + while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { + // We expect at least one stack frame to be shared. + // Typically this will be the root most one. However, stack frames may be + // cut off due to maximum stack limits. In this case, one maybe cut off + // earlier than the other. We assume that the sample is longer or the same + // and there for cut off earlier. So we should find the root most frame in + // the sample somewhere in the control. + c--; + } + } + for (; s >= 1 && c >= 0; s--, c--) { + // Next we find the first one that isn't the same which should be the + // frame that called our sample function and the control. + if (sampleLines[s] !== controlLines[c]) { + // In V8, the first line is describing the message but other VMs don't. + // If we're about to return the first line, and the control is also on the same + // line, that's a pretty good indicator that our sample threw at same line as + // the control. I.e. before we entered the sample frame. So we ignore this result. + // This can happen if you passed a class to function component, or non-function. + if (s !== 1 || c !== 1) { + do { + s--; + c--; // We may still have similar intermediate frames from the construct call. + // The next one that isn't the same should be our match though. - return alternate; -} -function findCurrentHostFiber(parent) { - var currentParent = findCurrentFiberUsingSlowPath(parent); - return currentParent !== null ? findCurrentHostFiberImpl(currentParent) : null; -} + if (c < 0 || sampleLines[s] !== controlLines[c]) { + // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. + var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "" + // but we have a user-provided "displayName" + // splice it in to make the stack more readable. -function findCurrentHostFiberImpl(node) { - // Next we'll drill down this component to find the first HostComponent/Text. - var tag = node.tag; - if (tag === HostComponent || tag === HostHoistable || tag === HostSingleton || tag === HostText) { - return node; - } + if (fn.displayName && _frame.includes('')) { + _frame = _frame.replace('', fn.displayName); + } - var child = node.child; + if (true) { + if (typeof fn === 'function') { + componentFrameCache.set(fn, _frame); + } + } // Return the line we found. - while (child !== null) { - var match = findCurrentHostFiberImpl(child); - if (match !== null) { - return match; + return _frame; + } + } while (s >= 1 && c >= 0); + } + + break; + } + } } + } finally { + reentry = false; - child = child.sibling; + { + ReactSharedInternals.H = previousDispatcher; + reenableLogs(); + } + + Error.prepareStackTrace = previousPrepareStackTrace; + } // Fallback to just using the name if we couldn't make it throw. + + + var name = fn ? fn.displayName || fn.name : ''; + var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; + + { + if (typeof fn === 'function') { + componentFrameCache.set(fn, syntheticFrame); + } } - return null; + return syntheticFrame; } -var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare - -function isArray(a) { - return isArrayImpl(a); +function describeClassComponentFrame(ctor) { + { + return describeNativeComponentFrame(ctor, true); + } +} +function describeFunctionComponentFrame(fn) { + { + return describeNativeComponentFrame(fn, false); + } } -// This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$3 = Scheduler$1.unstable_scheduleCallback; -var cancelCallback$1 = Scheduler$1.unstable_cancelCallback; -var shouldYield = Scheduler$1.unstable_shouldYield; -var requestPaint = Scheduler$1.unstable_requestPaint; -var now$1 = Scheduler$1.unstable_now; -var ImmediatePriority = Scheduler$1.unstable_ImmediatePriority; -var UserBlockingPriority = Scheduler$1.unstable_UserBlockingPriority; -var NormalPriority$1 = Scheduler$1.unstable_NormalPriority; -var IdlePriority = Scheduler$1.unstable_IdlePriority; // this doesn't actually exist on the scheduler, but it *does* +function describeFiber(fiber) { + switch (fiber.tag) { + case HostHoistable: + case HostSingleton: + case HostComponent: + return describeBuiltInComponentFrame(fiber.type); -// Helpers to patch console.logs to avoid logging during side-effect free -// replaying on render function. This currently only patches the object -// lazily which won't cover if the log function was extracted eagerly. -// We could also eagerly patch the method. -var disabledDepth = 0; -var prevLog; -var prevInfo; -var prevWarn; -var prevError; -var prevGroup; -var prevGroupCollapsed; -var prevGroupEnd; + case LazyComponent: + return describeBuiltInComponentFrame('Lazy'); -function disabledLog() {} + case SuspenseComponent: + return describeBuiltInComponentFrame('Suspense'); -disabledLog.__reactDisabledLog = true; -function disableLogs() { - { - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - prevLog = console.log; - prevInfo = console.info; - prevWarn = console.warn; - prevError = console.error; - prevGroup = console.group; - prevGroupCollapsed = console.groupCollapsed; - prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 + case SuspenseListComponent: + return describeBuiltInComponentFrame('SuspenseList'); - var props = { - configurable: true, - enumerable: true, - value: disabledLog, - writable: true - }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. + case FunctionComponent: + case SimpleMemoComponent: + return describeFunctionComponentFrame(fiber.type); - Object.defineProperties(console, { - info: props, - log: props, - warn: props, - error: props, - group: props, - groupCollapsed: props, - groupEnd: props - }); - /* eslint-enable react-internal/no-production-logging */ - } + case ForwardRef: + return describeFunctionComponentFrame(fiber.type.render); - disabledDepth++; + case ClassComponent: + return describeClassComponentFrame(fiber.type); + + default: + return ''; } } -function reenableLogs() { - { - disabledDepth--; - - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - var props = { - configurable: true, - enumerable: true, - writable: true - }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. - Object.defineProperties(console, { - log: assign({}, props, { - value: prevLog - }), - info: assign({}, props, { - value: prevInfo - }), - warn: assign({}, props, { - value: prevWarn - }), - error: assign({}, props, { - value: prevError - }), - group: assign({}, props, { - value: prevGroup - }), - groupCollapsed: assign({}, props, { - value: prevGroupCollapsed - }), - groupEnd: assign({}, props, { - value: prevGroupEnd - }) - }); - /* eslint-enable react-internal/no-production-logging */ - } +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ''; + var node = workInProgress; - if (disabledDepth < 0) { - error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); - } - } -} + do { + info += describeFiber(node); -var rendererID = null; -var injectedHook = null; -var injectedProfilingHooks = null; -var hasLoggedError = false; -var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'; -function injectInternals(internals) { - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { - // No DevTools - return false; - } + if (true) { + // Add any Server Component stack frames in reverse order. + var debugInfo = node._debugInfo; - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if (debugInfo) { + for (var i = debugInfo.length - 1; i >= 0; i--) { + var entry = debugInfo[i]; - if (hook.isDisabled) { - // This isn't a real property on the hook, but it can be set to opt out - // of DevTools integration and associated warnings and logs. - // https://github.com/facebook/react/issues/3877 - return true; - } + if (typeof entry.name === 'string') { + info += describeDebugInfoFrame(entry.name, entry.env); + } + } + } + } // $FlowFixMe[incompatible-type] we bail out when we get a null - if (!hook.supportsFiber) { - { - error('The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://react.dev/link/react-devtools'); - } // DevTools exists, even though it doesn't support Fiber. + node = node.return; + } while (node); - return true; + return info; + } catch (x) { + return '\nError generating stack: ' + x.message + '\n' + x.stack; } +} - try { - if (enableSchedulingProfiler) { - // Conditionally inject these hooks only if Timeline profiler is supported by this build. - // This gives DevTools a way to feature detect that isn't tied to version number - // (since profiling and timeline are controlled by different feature flags). - internals = assign({}, internals, { - getLaneLabelMap: getLaneLabelMap, - injectProfilingHooks: injectProfilingHooks - }); - } +var current = null; +var isRendering = false; - rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. +function getCurrentFiberStackInDev() { + { + if (current === null) { + return ''; + } // Safe because if current fiber exists, we are reconciling, + // and it is guaranteed to be the work-in-progress version. - injectedHook = hook; - } catch (err) { - // Catch all errors because it is unsafe to throw during initialization. - { - error('React instrumentation encountered an error: %s.', err); - } + + return getStackByFiberInDevAndProd(current); } +} - if (hook.checkDCE) { - // This is the real DevTools. - return true; - } else { - // This is likely a hook installed by Fast Refresh runtime. - return false; +function resetCurrentDebugFiberInDEV() { + { + resetCurrentFiber(); } } -function onScheduleRoot(root, children) { +function setCurrentDebugFiberInDEV(fiber) { { - if (injectedHook && typeof injectedHook.onScheduleFiberRoot === 'function') { - try { - injectedHook.onScheduleFiberRoot(rendererID, root, children); - } catch (err) { - if (!hasLoggedError) { - hasLoggedError = true; - - error('React instrumentation encountered an error: %s', err); - } - } - } + setCurrentFiber(fiber); } } -function onCommitRoot(root, eventPriority) { - if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') { - try { - var didError = (root.current.flags & DidCapture) === DidCapture; - - if (enableProfilerTimer) { - var schedulerPriority; +function resetCurrentFiber() { + { + ReactSharedInternals.getCurrentStack = null; + isRendering = false; + } - switch (eventPriority) { - case DiscreteEventPriority: - schedulerPriority = ImmediatePriority; - break; + current = null; +} +function setCurrentFiber(fiber) { + { + ReactSharedInternals.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev; + isRendering = false; + } - case ContinuousEventPriority: - schedulerPriority = UserBlockingPriority; - break; + current = fiber; +} +function getCurrentFiber() { + { + return current; + } +} +function setIsRendering(rendering) { + { + isRendering = rendering; + } +} - case DefaultEventPriority: - schedulerPriority = NormalPriority$1; - break; +function getNearestMountedFiber(fiber) { + var node = fiber; + var nearestMounted = fiber; - case IdleEventPriority: - schedulerPriority = IdlePriority; - break; + if (!fiber.alternate) { + // If there is no alternate, this might be a new tree that isn't inserted + // yet. If it is, then it will have a pending insertion effect on it. + var nextNode = node; - default: - schedulerPriority = NormalPriority$1; - break; - } + do { + node = nextNode; - injectedHook.onCommitFiberRoot(rendererID, root, schedulerPriority, didError); - } - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; + if ((node.flags & (Placement | Hydrating)) !== NoFlags$1) { + // This is an insertion or in-progress hydration. The nearest possible + // mounted fiber is the parent but we need to continue to figure out + // if that one is still mounted. + nearestMounted = node.return; + } // $FlowFixMe[incompatible-type] we bail out when we get a null - error('React instrumentation encountered an error: %s', err); - } - } + + nextNode = node.return; + } while (nextNode); + } else { + while (node.return) { + node = node.return; } } + + if (node.tag === HostRoot) { + // TODO: Check if this was a nested HostRoot when used with + // renderContainerIntoSubtree. + return nearestMounted; + } // If we didn't hit the root, that means that we're in an disconnected tree + // that has been unmounted. + + + return null; } -function onPostCommitRoot(root) { - if (injectedHook && typeof injectedHook.onPostCommitFiberRoot === 'function') { - try { - injectedHook.onPostCommitFiberRoot(rendererID, root); - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; +function isFiberMounted(fiber) { + return getNearestMountedFiber(fiber) === fiber; +} +function isMounted(component) { + { + var owner = current; - error('React instrumentation encountered an error: %s', err); - } + if (owner !== null && isRendering && owner.tag === ClassComponent) { + var ownerFiber = owner; + var instance = ownerFiber.stateNode; + + if (!instance._warnedAboutRefsInRender) { + error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentNameFromFiber(ownerFiber) || 'A component'); } + + instance._warnedAboutRefsInRender = true; } } + + var fiber = get(component); + + if (!fiber) { + return false; + } + + return getNearestMountedFiber(fiber) === fiber; } -function onCommitUnmount(fiber) { - if (injectedHook && typeof injectedHook.onCommitFiberUnmount === 'function') { - try { - injectedHook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; - error('React instrumentation encountered an error: %s', err); - } - } - } +function assertIsMounted(fiber) { + if (getNearestMountedFiber(fiber) !== fiber) { + throw new Error('Unable to find node on an unmounted component.'); } } -function setIsStrictModeForDevtools(newIsStrictMode) { - { - if (newIsStrictMode) { - disableLogs(); - } else { - reenableLogs(); + +function findCurrentFiberUsingSlowPath(fiber) { + var alternate = fiber.alternate; + + if (!alternate) { + // If there is no alternate, then we only need to check if it is mounted. + var nearestMounted = getNearestMountedFiber(fiber); + + if (nearestMounted === null) { + throw new Error('Unable to find node on an unmounted component.'); } - } -} // Profiler API hooks -function injectProfilingHooks(profilingHooks) { - injectedProfilingHooks = profilingHooks; -} + if (nearestMounted !== fiber) { + return null; + } -function getLaneLabelMap() { - { - var map = new Map(); - var lane = 1; + return fiber; + } // If we have two possible branches, we'll walk backwards up to the root + // to see what path the root points to. On the way we may hit one of the + // special cases and we'll deal with them. - for (var index = 0; index < TotalLanes; index++) { - var label = getLabelForLane(lane); - map.set(lane, label); - lane *= 2; + + var a = fiber; + var b = alternate; + + while (true) { + var parentA = a.return; + + if (parentA === null) { + // We're at the root. + break; } - return map; - } -} + var parentB = parentA.alternate; -function markCommitStarted(lanes) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStarted === 'function') { - injectedProfilingHooks.markCommitStarted(lanes); + if (parentB === null) { + // There is no alternate. This is an unusual case. Currently, it only + // happens when a Suspense component is hidden. An extra fragment fiber + // is inserted in between the Suspense fiber and its children. Skip + // over this extra fragment fiber and proceed to the next parent. + var nextParent = parentA.return; + + if (nextParent !== null) { + a = b = nextParent; + continue; + } // If there's no parent, we're at the root. + + + break; + } // If both copies of the parent fiber point to the same child, we can + // assume that the child is current. This happens when we bailout on low + // priority: the bailed out fiber's child reuses the current child. + + + if (parentA.child === parentB.child) { + var child = parentA.child; + + while (child) { + if (child === a) { + // We've determined that A is the current branch. + assertIsMounted(parentA); + return fiber; + } + + if (child === b) { + // We've determined that B is the current branch. + assertIsMounted(parentA); + return alternate; + } + + child = child.sibling; + } // We should never have an alternate for any mounting node. So the only + // way this could possibly happen is if this was unmounted, if at all. + + + throw new Error('Unable to find node on an unmounted component.'); } - } -} -function markCommitStopped() { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStopped === 'function') { - injectedProfilingHooks.markCommitStopped(); + + if (a.return !== b.return) { + // The return pointer of A and the return pointer of B point to different + // fibers. We assume that return pointers never criss-cross, so A must + // belong to the child set of A.return, and B must belong to the child + // set of B.return. + a = parentA; + b = parentB; + } else { + // The return pointers point to the same fiber. We'll have to use the + // default, slow path: scan the child sets of each parent alternate to see + // which child belongs to which set. + // + // Search parent A's child set + var didFindChild = false; + var _child = parentA.child; + + while (_child) { + if (_child === a) { + didFindChild = true; + a = parentA; + b = parentB; + break; + } + + if (_child === b) { + didFindChild = true; + b = parentA; + a = parentB; + break; + } + + _child = _child.sibling; + } + + if (!didFindChild) { + // Search parent B's child set + _child = parentB.child; + + while (_child) { + if (_child === a) { + didFindChild = true; + a = parentB; + b = parentA; + break; + } + + if (_child === b) { + didFindChild = true; + b = parentB; + a = parentA; + break; + } + + _child = _child.sibling; + } + + if (!didFindChild) { + throw new Error('Child was not found in either parent set. This indicates a bug ' + 'in React related to the return pointer. Please file an issue.'); + } + } } - } -} -function markComponentRenderStarted(fiber) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStarted === 'function') { - injectedProfilingHooks.markComponentRenderStarted(fiber); + + if (a.alternate !== b) { + throw new Error("Return fibers should always be each others' alternates. " + 'This error is likely caused by a bug in React. Please file an issue.'); } + } // If the root is not a host container, we're in a disconnected tree. I.e. + // unmounted. + + + if (a.tag !== HostRoot) { + throw new Error('Unable to find node on an unmounted component.'); } -} -function markComponentRenderStopped() { - { + + if (a.stateNode.current === a) { + // We've determined that A is the current branch. + return fiber; + } // Otherwise B has to be current branch. + + + return alternate; +} +function findCurrentHostFiber(parent) { + var currentParent = findCurrentFiberUsingSlowPath(parent); + return currentParent !== null ? findCurrentHostFiberImpl(currentParent) : null; +} + +function findCurrentHostFiberImpl(node) { + // Next we'll drill down this component to find the first HostComponent/Text. + var tag = node.tag; + + if (tag === HostComponent || tag === HostHoistable || tag === HostSingleton || tag === HostText) { + return node; + } + + var child = node.child; + + while (child !== null) { + var match = findCurrentHostFiberImpl(child); + + if (match !== null) { + return match; + } + + child = child.sibling; + } + + return null; +} + +var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare + +function isArray(a) { + return isArrayImpl(a); +} + +// This module only exists as an ESM wrapper around the external CommonJS +var scheduleCallback$3 = Scheduler$1.unstable_scheduleCallback; +var cancelCallback$1 = Scheduler$1.unstable_cancelCallback; +var shouldYield = Scheduler$1.unstable_shouldYield; +var requestPaint = Scheduler$1.unstable_requestPaint; +var now$1 = Scheduler$1.unstable_now; +var ImmediatePriority = Scheduler$1.unstable_ImmediatePriority; +var UserBlockingPriority = Scheduler$1.unstable_UserBlockingPriority; +var NormalPriority$1 = Scheduler$1.unstable_NormalPriority; +var IdlePriority = Scheduler$1.unstable_IdlePriority; // this doesn't actually exist on the scheduler, but it *does* + +var rendererID = null; +var injectedHook = null; +var injectedProfilingHooks = null; +var hasLoggedError = false; +var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'; +function injectInternals(internals) { + if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { + // No DevTools + return false; + } + + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + + if (hook.isDisabled) { + // This isn't a real property on the hook, but it can be set to opt out + // of DevTools integration and associated warnings and logs. + // https://github.com/facebook/react/issues/3877 + return true; + } + + if (!hook.supportsFiber) { + { + error('The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://react.dev/link/react-devtools'); + } // DevTools exists, even though it doesn't support Fiber. + + + return true; + } + + try { + if (enableSchedulingProfiler) { + // Conditionally inject these hooks only if Timeline profiler is supported by this build. + // This gives DevTools a way to feature detect that isn't tied to version number + // (since profiling and timeline are controlled by different feature flags). + internals = assign({}, internals, { + getLaneLabelMap: getLaneLabelMap, + injectProfilingHooks: injectProfilingHooks + }); + } + + rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + + injectedHook = hook; + } catch (err) { + // Catch all errors because it is unsafe to throw during initialization. + { + error('React instrumentation encountered an error: %s.', err); + } + } + + 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) { + { + if (injectedHook && typeof injectedHook.onScheduleFiberRoot === 'function') { + try { + injectedHook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } + } + } +} +function onCommitRoot(root, eventPriority) { + if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') { + try { + var didError = (root.current.flags & DidCapture) === DidCapture; + + if (enableProfilerTimer) { + var schedulerPriority; + + switch (eventPriority) { + case DiscreteEventPriority: + schedulerPriority = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriority = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriority = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriority = IdlePriority; + break; + + default: + schedulerPriority = NormalPriority$1; + break; + } + + injectedHook.onCommitFiberRoot(rendererID, root, schedulerPriority, didError); + } + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } + } + } +} +function onPostCommitRoot(root) { + if (injectedHook && typeof injectedHook.onPostCommitFiberRoot === 'function') { + try { + injectedHook.onPostCommitFiberRoot(rendererID, root); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } + } + } +} +function onCommitUnmount(fiber) { + if (injectedHook && typeof injectedHook.onCommitFiberUnmount === 'function') { + try { + injectedHook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } + } + } +} +function setIsStrictModeForDevtools(newIsStrictMode) { + { + if (newIsStrictMode) { + disableLogs(); + } else { + reenableLogs(); + } + } +} // Profiler API hooks + +function injectProfilingHooks(profilingHooks) { + injectedProfilingHooks = profilingHooks; +} + +function getLaneLabelMap() { + { + var map = new Map(); + var lane = 1; + + for (var index = 0; index < TotalLanes; index++) { + var label = getLabelForLane(lane); + map.set(lane, label); + lane *= 2; + } + + return map; + } +} + +function markCommitStarted(lanes) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStarted === 'function') { + injectedProfilingHooks.markCommitStarted(lanes); + } + } +} +function markCommitStopped() { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStopped === 'function') { + injectedProfilingHooks.markCommitStopped(); + } + } +} +function markComponentRenderStarted(fiber) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStarted === 'function') { + injectedProfilingHooks.markComponentRenderStarted(fiber); + } + } +} +function markComponentRenderStopped() { + { if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStopped === 'function') { injectedProfilingHooks.markComponentRenderStopped(); } @@ -1479,1539 +1870,1195 @@ function getLabelForLane(lane) { } if (lane & SelectiveHydrationLane) { - return 'SelectiveHydration'; - } - - if (lane & IdleHydrationLane) { - return 'IdleHydration'; - } - - if (lane & IdleLane) { - return 'Idle'; - } - - if (lane & OffscreenLane) { - return 'Offscreen'; - } - - if (lane & DeferredLane) { - return 'Deferred'; - } - } -} -var NoTimestamp = -1; -var nextTransitionLane = TransitionLane1; -var nextRetryLane = RetryLane1; - -function getHighestPriorityLanes(lanes) { - { - var pendingSyncLanes = lanes & SyncUpdateLanes; - - if (pendingSyncLanes !== 0) { - return pendingSyncLanes; - } - } - - switch (getHighestPriorityLane(lanes)) { - case SyncHydrationLane: - return SyncHydrationLane; - - case SyncLane: - return SyncLane; - - case InputContinuousHydrationLane: - return InputContinuousHydrationLane; - - case InputContinuousLane: - return InputContinuousLane; - - case DefaultHydrationLane: - return DefaultHydrationLane; - - case DefaultLane: - return DefaultLane; - - case TransitionHydrationLane: - return TransitionHydrationLane; - - case TransitionLane1: - case TransitionLane2: - case TransitionLane3: - case TransitionLane4: - case TransitionLane5: - case TransitionLane6: - case TransitionLane7: - case TransitionLane8: - case TransitionLane9: - case TransitionLane10: - case TransitionLane11: - case TransitionLane12: - case TransitionLane13: - case TransitionLane14: - case TransitionLane15: - return lanes & TransitionLanes; - - case RetryLane1: - case RetryLane2: - case RetryLane3: - case RetryLane4: - return lanes & RetryLanes; - - case SelectiveHydrationLane: - return SelectiveHydrationLane; - - case IdleHydrationLane: - return IdleHydrationLane; - - case IdleLane: - return IdleLane; - - case OffscreenLane: - return OffscreenLane; - - case DeferredLane: - // This shouldn't be reachable because deferred work is always entangled - // with something else. - return NoLanes; - - default: - { - error('Should have found matching lanes. This is a bug in React.'); - } // This shouldn't be reachable, but as a fallback, return the entire bitmask. - - - return lanes; - } -} - -function getNextLanes(root, wipLanes) { - // Early bailout if there's no pending work left. - var pendingLanes = root.pendingLanes; - - if (pendingLanes === NoLanes) { - return NoLanes; - } - - var nextLanes = NoLanes; - var suspendedLanes = root.suspendedLanes; - var pingedLanes = root.pingedLanes; // Do not work on any idle work until all the non-idle work has finished, - // even if the work is suspended. - - var nonIdlePendingLanes = pendingLanes & NonIdleLanes; - - if (nonIdlePendingLanes !== NoLanes) { - var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; - - if (nonIdleUnblockedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); - } else { - var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; - - if (nonIdlePingedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); - } - } - } else { - // The only remaining work is Idle. - var unblockedLanes = pendingLanes & ~suspendedLanes; - - if (unblockedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(unblockedLanes); - } else { - if (pingedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(pingedLanes); - } - } - } - - if (nextLanes === NoLanes) { - // This should only be reachable if we're suspended - // TODO: Consider warning in this path if a fallback timer is not scheduled. - return NoLanes; - } // If we're already in the middle of a render, switching lanes will interrupt - // it and we'll lose our progress. We should only do this if the new lanes are - // higher priority. - - - if (wipLanes !== NoLanes && wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't - // bother waiting until the root is complete. - (wipLanes & suspendedLanes) === NoLanes) { - var nextLane = getHighestPriorityLane(nextLanes); - var wipLane = getHighestPriorityLane(wipLanes); - - if ( // Tests whether the next lane is equal or lower priority than the wip - // one. This works because the bits decrease in priority as you go left. - nextLane >= wipLane || // Default priority updates should not interrupt transition updates. The - // only difference between default updates and transition updates is that - // default updates do not support refresh transitions. - nextLane === DefaultLane && (wipLane & TransitionLanes) !== NoLanes) { - // Keep working on the existing in-progress tree. Do not interrupt. - return wipLanes; - } - } - - return nextLanes; -} -function getEntangledLanes(root, renderLanes) { - var entangledLanes = renderLanes; - - if ((root.current.mode & ConcurrentUpdatesByDefaultMode) !== NoMode) ; else if ((entangledLanes & InputContinuousLane) !== NoLanes) { - // When updates are sync by default, we entangle continuous priority updates - // and default updates, so they render in the same batch. The only reason - // they use separate lanes is because continuous updates should interrupt - // transitions, but default updates should not. - entangledLanes |= entangledLanes & DefaultLane; - } // Check for entangled lanes and add them to the batch. - // - // A lane is said to be entangled with another when it's not allowed to render - // in a batch that does not also include the other lane. Typically we do this - // when multiple updates have the same source, and we only want to respond to - // the most recent event from that source. - // - // Note that we apply entanglements *after* checking for partial work above. - // This means that if a lane is entangled during an interleaved event while - // it's already rendering, we won't interrupt it. This is intentional, since - // entanglement is usually "best effort": we'll try our best to render the - // lanes in the same batch, but it's not worth throwing out partially - // completed work in order to do it. - // TODO: Reconsider this. The counter-argument is that the partial work - // represents an intermediate state, which we don't want to show to the user. - // And by spending extra time finishing it, we're increasing the amount of - // time it takes to show the final state, which is what they are actually - // waiting for. - // - // For those exceptions where entanglement is semantically important, - // we should ensure that there is no partial work at the - // time we apply the entanglement. - - - var allEntangledLanes = root.entangledLanes; - - if (allEntangledLanes !== NoLanes) { - var entanglements = root.entanglements; - var lanes = entangledLanes & allEntangledLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - entangledLanes |= entanglements[index]; - lanes &= ~lane; - } - } - - return entangledLanes; -} - -function computeExpirationTime(lane, currentTime) { - switch (lane) { - case SyncHydrationLane: - case SyncLane: - case InputContinuousHydrationLane: - case InputContinuousLane: - // User interactions should expire slightly more quickly. - // - // NOTE: This is set to the corresponding constant as in Scheduler.js. - // When we made it larger, a product metric in www regressed, suggesting - // there's a user interaction that's being starved by a series of - // synchronous updates. If that theory is correct, the proper solution is - // to fix the starvation. However, this scenario supports the idea that - // expiration times are an important safeguard when starvation - // does happen. - return currentTime + syncLaneExpirationMs; - - case DefaultHydrationLane: - case DefaultLane: - case TransitionHydrationLane: - case TransitionLane1: - case TransitionLane2: - case TransitionLane3: - case TransitionLane4: - case TransitionLane5: - case TransitionLane6: - case TransitionLane7: - case TransitionLane8: - case TransitionLane9: - case TransitionLane10: - case TransitionLane11: - case TransitionLane12: - case TransitionLane13: - case TransitionLane14: - case TransitionLane15: - return currentTime + transitionLaneExpirationMs; - - case RetryLane1: - case RetryLane2: - case RetryLane3: - case RetryLane4: - // TODO: Retries should be allowed to expire if they are CPU bound for - // too long, but when I made this change it caused a spike in browser - // crashes. There must be some other underlying bug; not super urgent but - // ideally should figure out why and fix it. Unfortunately we don't have - // a repro for the crashes, only detected via production metrics. - return NoTimestamp; - - case SelectiveHydrationLane: - case IdleHydrationLane: - case IdleLane: - case OffscreenLane: - case DeferredLane: - // Anything idle priority or lower should never expire. - return NoTimestamp; - - default: - { - error('Should have found matching lanes. This is a bug in React.'); - } - - return NoTimestamp; - } -} - -function markStarvedLanesAsExpired(root, currentTime) { - // TODO: This gets called every time we yield. We can optimize by storing - // the earliest expiration time on the root. Then use that to quickly bail out - // of this function. - var pendingLanes = root.pendingLanes; - var suspendedLanes = root.suspendedLanes; - var pingedLanes = root.pingedLanes; - var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their - // expiration time. If so, we'll assume the update is being starved and mark - // it as expired to force it to finish. - // TODO: We should be able to replace this with upgradePendingLanesToSync - // - // We exclude retry lanes because those must always be time sliced, in order - // to unwrap uncached promises. - // TODO: Write a test for this - - var lanes = pendingLanes & ~RetryLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - var expirationTime = expirationTimes[index]; - - if (expirationTime === NoTimestamp) { - // Found a pending lane with no expiration time. If it's not suspended, or - // if it's pinged, assume it's CPU-bound. Compute a new expiration time - // using the current time. - if ((lane & suspendedLanes) === NoLanes || (lane & pingedLanes) !== NoLanes) { - // Assumes timestamps are monotonically increasing. - expirationTimes[index] = computeExpirationTime(lane, currentTime); - } - } else if (expirationTime <= currentTime) { - // This lane expired - root.expiredLanes |= lane; - } - - lanes &= ~lane; - } -} // This returns the highest priority pending lanes regardless of whether they -function getLanesToRetrySynchronouslyOnError(root, originallyAttemptedLanes) { - if (root.errorRecoveryDisabledLanes & originallyAttemptedLanes) { - // The error recovery mechanism is disabled until these lanes are cleared. - return NoLanes; - } - - var everythingButOffscreen = root.pendingLanes & ~OffscreenLane; - - if (everythingButOffscreen !== NoLanes) { - return everythingButOffscreen; - } - - if (everythingButOffscreen & OffscreenLane) { - return OffscreenLane; - } - - return NoLanes; -} -function includesSyncLane(lanes) { - return (lanes & (SyncLane | SyncHydrationLane)) !== NoLanes; -} -function includesNonIdleWork(lanes) { - return (lanes & NonIdleLanes) !== NoLanes; -} -function includesOnlyRetries(lanes) { - return (lanes & RetryLanes) === lanes; -} -function includesOnlyNonUrgentLanes(lanes) { - // TODO: Should hydration lanes be included here? This function is only - // used in `updateDeferredValueImpl`. - var UrgentLanes = SyncLane | InputContinuousLane | DefaultLane; - return (lanes & UrgentLanes) === NoLanes; -} -function includesOnlyTransitions(lanes) { - return (lanes & TransitionLanes) === lanes; -} -function includesBlockingLane(root, lanes) { - if ((root.current.mode & ConcurrentUpdatesByDefaultMode) !== NoMode) { - // Concurrent updates by default always use time slicing. - return false; - } - - var SyncDefaultLanes = InputContinuousHydrationLane | InputContinuousLane | DefaultHydrationLane | DefaultLane; - return (lanes & SyncDefaultLanes) !== NoLanes; -} -function includesExpiredLane(root, lanes) { - // This is a separate check from includesBlockingLane because a lane can - // expire after a render has already started. - return (lanes & root.expiredLanes) !== NoLanes; -} -function isTransitionLane(lane) { - return (lane & TransitionLanes) !== NoLanes; -} -function claimNextTransitionLane() { - // Cycle through the lanes, assigning each new transition to the next lane. - // In most cases, this means every transition gets its own lane, until we - // run out of lanes and cycle back to the beginning. - var lane = nextTransitionLane; - nextTransitionLane <<= 1; - - if ((nextTransitionLane & TransitionLanes) === NoLanes) { - nextTransitionLane = TransitionLane1; - } - - return lane; -} -function claimNextRetryLane() { - var lane = nextRetryLane; - nextRetryLane <<= 1; - - if ((nextRetryLane & RetryLanes) === NoLanes) { - nextRetryLane = RetryLane1; - } - - return lane; -} -function getHighestPriorityLane(lanes) { - return lanes & -lanes; -} -function pickArbitraryLane(lanes) { - // This wrapper function gets inlined. Only exists so to communicate that it - // doesn't matter which bit is selected; you can pick any bit without - // affecting the algorithms where its used. Here I'm using - // getHighestPriorityLane because it requires the fewest operations. - return getHighestPriorityLane(lanes); -} - -function pickArbitraryLaneIndex(lanes) { - return 31 - clz32(lanes); -} - -function laneToIndex(lane) { - return pickArbitraryLaneIndex(lane); -} - -function includesSomeLane(a, b) { - return (a & b) !== NoLanes; -} -function isSubsetOfLanes(set, subset) { - return (set & subset) === subset; -} -function mergeLanes(a, b) { - return a | b; -} -function removeLanes(set, subset) { - return set & ~subset; -} -function intersectLanes(a, b) { - return a & b; -} // Seems redundant, but it changes the type from a single lane (used for -// updates) to a group of lanes (used for flushing work). - -function laneToLanes(lane) { - return lane; -} -function createLaneMap(initial) { - // Intentionally pushing one by one. - // https://v8.dev/blog/elements-kinds#avoid-creating-holes - var laneMap = []; - - for (var i = 0; i < TotalLanes; i++) { - laneMap.push(initial); - } - - return laneMap; -} -function markRootUpdated$1(root, updateLane) { - root.pendingLanes |= updateLane; // If there are any suspended transitions, it's possible this new update - // could unblock them. Clear the suspended lanes so that we can try rendering - // them again. - // - // TODO: We really only need to unsuspend only lanes that are in the - // `subtreeLanes` of the updated fiber, or the update lanes of the return - // path. This would exclude suspended updates in an unrelated sibling tree, - // since there's no way for this update to unblock it. - // - // We don't do this if the incoming update is idle, because we never process - // idle updates until after all the regular updates have finished; there's no - // way it could unblock a transition. - - if (updateLane !== IdleLane) { - root.suspendedLanes = NoLanes; - root.pingedLanes = NoLanes; - } -} -function markRootSuspended$1(root, suspendedLanes, spawnedLane) { - root.suspendedLanes |= suspendedLanes; - root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times. - - var expirationTimes = root.expirationTimes; - var lanes = suspendedLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - expirationTimes[index] = NoTimestamp; - lanes &= ~lane; - } - - if (spawnedLane !== NoLane) { - markSpawnedDeferredLane(root, spawnedLane, suspendedLanes); - } -} -function markRootPinged$1(root, pingedLanes) { - root.pingedLanes |= root.suspendedLanes & pingedLanes; -} -function markRootFinished(root, remainingLanes, spawnedLane) { - var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; - root.pendingLanes = remainingLanes; // Let's try everything again - - root.suspendedLanes = NoLanes; - root.pingedLanes = NoLanes; - root.expiredLanes &= remainingLanes; - root.entangledLanes &= remainingLanes; - root.errorRecoveryDisabledLanes &= remainingLanes; - root.shellSuspendCounter = 0; - var entanglements = root.entanglements; - var expirationTimes = root.expirationTimes; - var hiddenUpdates = root.hiddenUpdates; // Clear the lanes that no longer have pending work - - var lanes = noLongerPendingLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - entanglements[index] = NoLanes; - expirationTimes[index] = NoTimestamp; - var hiddenUpdatesForLane = hiddenUpdates[index]; + return 'SelectiveHydration'; + } - if (hiddenUpdatesForLane !== null) { - hiddenUpdates[index] = null; // "Hidden" updates are updates that were made to a hidden component. They - // have special logic associated with them because they may be entangled - // with updates that occur outside that tree. But once the outer tree - // commits, they behave like regular updates. + if (lane & IdleHydrationLane) { + return 'IdleHydration'; + } - for (var i = 0; i < hiddenUpdatesForLane.length; i++) { - var update = hiddenUpdatesForLane[i]; + if (lane & IdleLane) { + return 'Idle'; + } - if (update !== null) { - update.lane &= ~OffscreenLane; - } - } + if (lane & OffscreenLane) { + return 'Offscreen'; } - lanes &= ~lane; + if (lane & DeferredLane) { + return 'Deferred'; + } } +} +var NoTimestamp = -1; +var nextTransitionLane = TransitionLane1; +var nextRetryLane = RetryLane1; - if (spawnedLane !== NoLane) { - markSpawnedDeferredLane(root, spawnedLane, // This render finished successfully without suspending, so we don't need - // to entangle the spawned task with the parent task. - NoLanes); +function getHighestPriorityLanes(lanes) { + { + var pendingSyncLanes = lanes & SyncUpdateLanes; + + if (pendingSyncLanes !== 0) { + return pendingSyncLanes; + } } -} -function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) { - // This render spawned a deferred task. Mark it as pending. - root.pendingLanes |= spawnedLane; - root.suspendedLanes &= ~spawnedLane; // Entangle the spawned lane with the DeferredLane bit so that we know it - // was the result of another render. This lets us avoid a useDeferredValue - // waterfall — only the first level will defer. + switch (getHighestPriorityLane(lanes)) { + case SyncHydrationLane: + return SyncHydrationLane; - var spawnedLaneIndex = laneToIndex(spawnedLane); - root.entangledLanes |= spawnedLane; - root.entanglements[spawnedLaneIndex] |= DeferredLane | // If the parent render task suspended, we must also entangle those lanes - // with the spawned task, so that the deferred task includes all the same - // updates that the parent task did. We can exclude any lane that is not - // used for updates (e.g. Offscreen). - entangledLanes & UpdateLanes; -} + case SyncLane: + return SyncLane; -function markRootEntangled(root, entangledLanes) { - // In addition to entangling each of the given lanes with each other, we also - // have to consider _transitive_ entanglements. For each lane that is already - // entangled with *any* of the given lanes, that lane is now transitively - // entangled with *all* the given lanes. - // - // Translated: If C is entangled with A, then entangling A with B also - // entangles C with B. - // - // If this is hard to grasp, it might help to intentionally break this - // function and look at the tests that fail in ReactTransition-test.js. Try - // commenting out one of the conditions below. - var rootEntangledLanes = root.entangledLanes |= entangledLanes; - var entanglements = root.entanglements; - var lanes = rootEntangledLanes; + case InputContinuousHydrationLane: + return InputContinuousHydrationLane; - while (lanes) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; + case InputContinuousLane: + return InputContinuousLane; - if ( // Is this one of the newly entangled lanes? - lane & entangledLanes | // Is this lane transitively entangled with the newly entangled lanes? - entanglements[index] & entangledLanes) { - entanglements[index] |= entangledLanes; - } + case DefaultHydrationLane: + return DefaultHydrationLane; - lanes &= ~lane; - } -} -function upgradePendingLaneToSync(root, lane) { - // Since we're upgrading the priority of the given lane, there is now pending - // sync work. - root.pendingLanes |= SyncLane; // Entangle the sync lane with the lane we're upgrading. This means SyncLane - // will not be allowed to finish without also finishing the given lane. + case DefaultLane: + return DefaultLane; - root.entangledLanes |= SyncLane; - root.entanglements[SyncLaneIndex] |= lane; -} -function markHiddenUpdate(root, update, lane) { - var index = laneToIndex(lane); - var hiddenUpdates = root.hiddenUpdates; - var hiddenUpdatesForLane = hiddenUpdates[index]; + case TransitionHydrationLane: + return TransitionHydrationLane; - if (hiddenUpdatesForLane === null) { - hiddenUpdates[index] = [update]; - } else { - hiddenUpdatesForLane.push(update); - } + case TransitionLane1: + case TransitionLane2: + case TransitionLane3: + case TransitionLane4: + case TransitionLane5: + case TransitionLane6: + case TransitionLane7: + case TransitionLane8: + case TransitionLane9: + case TransitionLane10: + case TransitionLane11: + case TransitionLane12: + case TransitionLane13: + case TransitionLane14: + case TransitionLane15: + return lanes & TransitionLanes; - update.lane = lane | OffscreenLane; -} -function getBumpedLaneForHydration(root, renderLanes) { - var renderLane = getHighestPriorityLane(renderLanes); - var lane; + case RetryLane1: + case RetryLane2: + case RetryLane3: + case RetryLane4: + return lanes & RetryLanes; - if ((renderLane & SyncUpdateLanes) !== NoLane) { - lane = SyncHydrationLane; - } else { - switch (renderLane) { - case SyncLane: - lane = SyncHydrationLane; - break; + case SelectiveHydrationLane: + return SelectiveHydrationLane; - case InputContinuousLane: - lane = InputContinuousHydrationLane; - break; + case IdleHydrationLane: + return IdleHydrationLane; - case DefaultLane: - lane = DefaultHydrationLane; - break; + case IdleLane: + return IdleLane; - case TransitionLane1: - case TransitionLane2: - case TransitionLane3: - case TransitionLane4: - case TransitionLane5: - case TransitionLane6: - case TransitionLane7: - case TransitionLane8: - case TransitionLane9: - case TransitionLane10: - case TransitionLane11: - case TransitionLane12: - case TransitionLane13: - case TransitionLane14: - case TransitionLane15: - case RetryLane1: - case RetryLane2: - case RetryLane3: - case RetryLane4: - lane = TransitionHydrationLane; - break; + case OffscreenLane: + return OffscreenLane; - case IdleLane: - lane = IdleHydrationLane; - break; + case DeferredLane: + // This shouldn't be reachable because deferred work is always entangled + // with something else. + return NoLanes; - default: - // Everything else is already either a hydration lane, or shouldn't - // be retried at a hydration lane. - lane = NoLane; - break; - } - } // Check if the lane we chose is suspended. If so, that indicates that we - // already attempted and failed to hydrate at that level. Also check if we're - // already rendering that lane, which is rare but could happen. + default: + { + error('Should have found matching lanes. This is a bug in React.'); + } // This shouldn't be reachable, but as a fallback, return the entire bitmask. - if ((lane & (root.suspendedLanes | renderLanes)) !== NoLane) { - // Give up trying to hydrate and fall back to client render. - return NoLane; + return lanes; } - - return lane; } -function getTransitionsForLanes(root, lanes) { - { - return null; + +function getNextLanes(root, wipLanes) { + // Early bailout if there's no pending work left. + var pendingLanes = root.pendingLanes; + + if (pendingLanes === NoLanes) { + return NoLanes; } -} -var NoEventPriority = NoLane; -var DiscreteEventPriority = SyncLane; -var ContinuousEventPriority = InputContinuousLane; -var DefaultEventPriority = DefaultLane; -var IdleEventPriority = IdleLane; -function higherEventPriority(a, b) { - return a !== 0 && a < b ? a : b; -} -function lowerEventPriority(a, b) { - return a === 0 || a > b ? a : b; -} -function isHigherEventPriority(a, b) { - return a !== 0 && a < b; -} -function eventPriorityToLane(updatePriority) { - return updatePriority; -} -function lanesToEventPriority(lanes) { - var lane = getHighestPriorityLane(lanes); + var nextLanes = NoLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; // Do not work on any idle work until all the non-idle work has finished, + // even if the work is suspended. + + var nonIdlePendingLanes = pendingLanes & NonIdleLanes; + + if (nonIdlePendingLanes !== NoLanes) { + var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; + + if (nonIdleUnblockedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); + } else { + var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; + + if (nonIdlePingedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); + } + } + } else { + // The only remaining work is Idle. + var unblockedLanes = pendingLanes & ~suspendedLanes; - if (!isHigherEventPriority(DiscreteEventPriority, lane)) { - return DiscreteEventPriority; + if (unblockedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(unblockedLanes); + } else { + if (pingedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(pingedLanes); + } + } } - if (!isHigherEventPriority(ContinuousEventPriority, lane)) { - return ContinuousEventPriority; - } + if (nextLanes === NoLanes) { + // This should only be reachable if we're suspended + // TODO: Consider warning in this path if a fallback timer is not scheduled. + return NoLanes; + } // If we're already in the middle of a render, switching lanes will interrupt + // it and we'll lose our progress. We should only do this if the new lanes are + // higher priority. - if (includesNonIdleWork(lane)) { - return DefaultEventPriority; + + if (wipLanes !== NoLanes && wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't + // bother waiting until the root is complete. + (wipLanes & suspendedLanes) === NoLanes) { + var nextLane = getHighestPriorityLane(nextLanes); + var wipLane = getHighestPriorityLane(wipLanes); + + if ( // Tests whether the next lane is equal or lower priority than the wip + // one. This works because the bits decrease in priority as you go left. + nextLane >= wipLane || // Default priority updates should not interrupt transition updates. The + // only difference between default updates and transition updates is that + // default updates do not support refresh transitions. + nextLane === DefaultLane && (wipLane & TransitionLanes) !== NoLanes) { + // Keep working on the existing in-progress tree. Do not interrupt. + return wipLanes; + } } - return IdleEventPriority; + return nextLanes; } +function getEntangledLanes(root, renderLanes) { + var entangledLanes = renderLanes; -// Renderers that don't support hydration -// can re-export everything from this module. -function shim$1() { - throw new Error('The current renderer does not support hydration. ' + 'This error is likely caused by a bug in React. ' + 'Please file an issue.'); -} // Hydration (when unsupported) + if ((root.current.mode & ConcurrentUpdatesByDefaultMode) !== NoMode) ; else if ((entangledLanes & InputContinuousLane) !== NoLanes) { + // When updates are sync by default, we entangle continuous priority updates + // and default updates, so they render in the same batch. The only reason + // they use separate lanes is because continuous updates should interrupt + // transitions, but default updates should not. + entangledLanes |= entangledLanes & DefaultLane; + } // Check for entangled lanes and add them to the batch. + // + // A lane is said to be entangled with another when it's not allowed to render + // in a batch that does not also include the other lane. Typically we do this + // when multiple updates have the same source, and we only want to respond to + // the most recent event from that source. + // + // Note that we apply entanglements *after* checking for partial work above. + // This means that if a lane is entangled during an interleaved event while + // it's already rendering, we won't interrupt it. This is intentional, since + // entanglement is usually "best effort": we'll try our best to render the + // lanes in the same batch, but it's not worth throwing out partially + // completed work in order to do it. + // TODO: Reconsider this. The counter-argument is that the partial work + // represents an intermediate state, which we don't want to show to the user. + // And by spending extra time finishing it, we're increasing the amount of + // time it takes to show the final state, which is what they are actually + // waiting for. + // + // For those exceptions where entanglement is semantically important, + // we should ensure that there is no partial work at the + // time we apply the entanglement. -var supportsHydration = false; -var isSuspenseInstancePending = shim$1; -var isSuspenseInstanceFallback = shim$1; -var getSuspenseInstanceFallbackErrorDetails = shim$1; -var registerSuspenseInstanceRetry = shim$1; -var clearSuspenseBoundary = shim$1; -var clearSuspenseBoundaryFromContainer = shim$1; + var allEntangledLanes = root.entangledLanes; -// Renderers that don't support hydration -// can re-export everything from this module. -function shim() { - throw new Error('The current renderer does not support Resources. ' + 'This error is likely caused by a bug in React. ' + 'Please file an issue.'); -} // Resources (when unsupported) -var preloadResource = shim; -var suspendResource = shim; + if (allEntangledLanes !== NoLanes) { + var entanglements = root.entanglements; + var lanes = entangledLanes & allEntangledLanes; -var NO_CONTEXT = {}; -var nodeToInstanceMap = new WeakMap(); + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + entangledLanes |= entanglements[index]; + lanes &= ~lane; + } + } -{ - Object.freeze(NO_CONTEXT); + return entangledLanes; } -function getPublicInstance(inst) { - switch (inst.tag) { - case 'INSTANCE': - var createNodeMock = inst.rootContainerInstance.createNodeMock; - var mockNode = createNodeMock({ - type: inst.type, - props: inst.props - }); +function computeExpirationTime(lane, currentTime) { + switch (lane) { + case SyncHydrationLane: + case SyncLane: + case InputContinuousHydrationLane: + case InputContinuousLane: + // User interactions should expire slightly more quickly. + // + // NOTE: This is set to the corresponding constant as in Scheduler.js. + // When we made it larger, a product metric in www regressed, suggesting + // there's a user interaction that's being starved by a series of + // synchronous updates. If that theory is correct, the proper solution is + // to fix the starvation. However, this scenario supports the idea that + // expiration times are an important safeguard when starvation + // does happen. + return currentTime + syncLaneExpirationMs; - if (typeof mockNode === 'object' && mockNode !== null) { - nodeToInstanceMap.set(mockNode, inst); - } + case DefaultHydrationLane: + case DefaultLane: + case TransitionHydrationLane: + case TransitionLane1: + case TransitionLane2: + case TransitionLane3: + case TransitionLane4: + case TransitionLane5: + case TransitionLane6: + case TransitionLane7: + case TransitionLane8: + case TransitionLane9: + case TransitionLane10: + case TransitionLane11: + case TransitionLane12: + case TransitionLane13: + case TransitionLane14: + case TransitionLane15: + return currentTime + transitionLaneExpirationMs; - return mockNode; + case RetryLane1: + case RetryLane2: + case RetryLane3: + case RetryLane4: + // TODO: Retries should be allowed to expire if they are CPU bound for + // too long, but when I made this change it caused a spike in browser + // crashes. There must be some other underlying bug; not super urgent but + // ideally should figure out why and fix it. Unfortunately we don't have + // a repro for the crashes, only detected via production metrics. + return NoTimestamp; + + case SelectiveHydrationLane: + case IdleHydrationLane: + case IdleLane: + case OffscreenLane: + case DeferredLane: + // Anything idle priority or lower should never expire. + return NoTimestamp; default: - return inst; + { + error('Should have found matching lanes. This is a bug in React.'); + } + + return NoTimestamp; } } -function appendChild(parentInstance, child) { - { - if (!isArray(parentInstance.children)) { - error('An invalid container has been provided. ' + 'This may indicate that another renderer is being used in addition to the test renderer. ' + '(For example, ReactDOM.createPortal inside of a ReactTestRenderer tree.) ' + 'This is not supported.'); - } - } - var index = parentInstance.children.indexOf(child); +function markStarvedLanesAsExpired(root, currentTime) { + // TODO: This gets called every time we yield. We can optimize by storing + // the earliest expiration time on the root. Then use that to quickly bail out + // of this function. + var pendingLanes = root.pendingLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; + var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their + // expiration time. If so, we'll assume the update is being starved and mark + // it as expired to force it to finish. + // TODO: We should be able to replace this with upgradePendingLanesToSync + // + // We exclude retry lanes because those must always be time sliced, in order + // to unwrap uncached promises. + // TODO: Write a test for this - if (index !== -1) { - parentInstance.children.splice(index, 1); - } + var lanes = pendingLanes & ~RetryLanes; - parentInstance.children.push(child); -} -function insertBefore(parentInstance, child, beforeChild) { - var index = parentInstance.children.indexOf(child); + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + var expirationTime = expirationTimes[index]; - if (index !== -1) { - parentInstance.children.splice(index, 1); - } + if (expirationTime === NoTimestamp) { + // Found a pending lane with no expiration time. If it's not suspended, or + // if it's pinged, assume it's CPU-bound. Compute a new expiration time + // using the current time. + if ((lane & suspendedLanes) === NoLanes || (lane & pingedLanes) !== NoLanes) { + // Assumes timestamps are monotonically increasing. + expirationTimes[index] = computeExpirationTime(lane, currentTime); + } + } else if (expirationTime <= currentTime) { + // This lane expired + root.expiredLanes |= lane; + } - var beforeIndex = parentInstance.children.indexOf(beforeChild); - parentInstance.children.splice(beforeIndex, 0, child); -} -function removeChild(parentInstance, child) { - var index = parentInstance.children.indexOf(child); - parentInstance.children.splice(index, 1); -} -function clearContainer(container) { - container.children.splice(0); -} -function getRootHostContext(rootContainerInstance) { - return NO_CONTEXT; -} -function getChildHostContext(parentHostContext, type) { - return NO_CONTEXT; -} -function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { - return { - type: type, - props: props, - isHidden: false, - children: [], - internalInstanceHandle: internalInstanceHandle, - rootContainerInstance: rootContainerInstance, - tag: 'INSTANCE' - }; -} -function appendInitialChild(parentInstance, child) { - var index = parentInstance.children.indexOf(child); + lanes &= ~lane; + } +} // This returns the highest priority pending lanes regardless of whether they +function getLanesToRetrySynchronouslyOnError(root, originallyAttemptedLanes) { + if (root.errorRecoveryDisabledLanes & originallyAttemptedLanes) { + // The error recovery mechanism is disabled until these lanes are cleared. + return NoLanes; + } - if (index !== -1) { - parentInstance.children.splice(index, 1); + var everythingButOffscreen = root.pendingLanes & ~OffscreenLane; + + if (everythingButOffscreen !== NoLanes) { + return everythingButOffscreen; } - parentInstance.children.push(child); + if (everythingButOffscreen & OffscreenLane) { + return OffscreenLane; + } + + return NoLanes; } -function shouldSetTextContent(type, props) { - return false; +function includesSyncLane(lanes) { + return (lanes & (SyncLane | SyncHydrationLane)) !== NoLanes; } -function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) { - return { - text: text, - isHidden: false, - tag: 'TEXT' - }; +function includesNonIdleWork(lanes) { + return (lanes & NonIdleLanes) !== NoLanes; } -var currentUpdatePriority = NoEventPriority; -function setCurrentUpdatePriority(newPriority) { - currentUpdatePriority = newPriority; +function includesOnlyRetries(lanes) { + return (lanes & RetryLanes) === lanes; } -function getCurrentUpdatePriority() { - return currentUpdatePriority; +function includesOnlyNonUrgentLanes(lanes) { + // TODO: Should hydration lanes be included here? This function is only + // used in `updateDeferredValueImpl`. + var UrgentLanes = SyncLane | InputContinuousLane | DefaultLane; + return (lanes & UrgentLanes) === NoLanes; } -function resolveUpdatePriority() { - if (currentUpdatePriority !== NoEventPriority) { - return currentUpdatePriority; +function includesOnlyTransitions(lanes) { + return (lanes & TransitionLanes) === lanes; +} +function includesBlockingLane(root, lanes) { + if ((root.current.mode & ConcurrentUpdatesByDefaultMode) !== NoMode) { + // Concurrent updates by default always use time slicing. + return false; } - return DefaultEventPriority; + var SyncDefaultLanes = InputContinuousHydrationLane | InputContinuousLane | DefaultHydrationLane | DefaultLane; + return (lanes & SyncDefaultLanes) !== NoLanes; } -function shouldAttemptEagerTransition() { - return false; +function includesExpiredLane(root, lanes) { + // This is a separate check from includesBlockingLane because a lane can + // expire after a render has already started. + return (lanes & root.expiredLanes) !== NoLanes; } -var scheduleTimeout = setTimeout; -var cancelTimeout = clearTimeout; -var noTimeout = -1; // ------------------- -function commitUpdate(instance, type, oldProps, newProps, internalInstanceHandle) { - instance.type = type; - instance.props = newProps; +function isTransitionLane(lane) { + return (lane & TransitionLanes) !== NoLanes; } -function commitMount(instance, type, newProps, internalInstanceHandle) {// noop +function claimNextTransitionLane() { + // Cycle through the lanes, assigning each new transition to the next lane. + // In most cases, this means every transition gets its own lane, until we + // run out of lanes and cycle back to the beginning. + var lane = nextTransitionLane; + nextTransitionLane <<= 1; + + if ((nextTransitionLane & TransitionLanes) === NoLanes) { + nextTransitionLane = TransitionLane1; + } + + return lane; } -function commitTextUpdate(textInstance, oldText, newText) { - textInstance.text = newText; +function claimNextRetryLane() { + var lane = nextRetryLane; + nextRetryLane <<= 1; + + if ((nextRetryLane & RetryLanes) === NoLanes) { + nextRetryLane = RetryLane1; + } + + return lane; } -function resetTextContent(testElement) {// noop +function getHighestPriorityLane(lanes) { + return lanes & -lanes; } -var appendChildToContainer = appendChild; -var insertInContainerBefore = insertBefore; -var removeChildFromContainer = removeChild; -function hideInstance(instance) { - instance.isHidden = true; +function pickArbitraryLane(lanes) { + // This wrapper function gets inlined. Only exists so to communicate that it + // doesn't matter which bit is selected; you can pick any bit without + // affecting the algorithms where its used. Here I'm using + // getHighestPriorityLane because it requires the fewest operations. + return getHighestPriorityLane(lanes); } -function hideTextInstance(textInstance) { - textInstance.isHidden = true; + +function pickArbitraryLaneIndex(lanes) { + return 31 - clz32(lanes); } -function unhideInstance(instance, props) { - instance.isHidden = false; + +function laneToIndex(lane) { + return pickArbitraryLaneIndex(lane); } -function unhideTextInstance(textInstance, text) { - textInstance.isHidden = false; + +function includesSomeLane(a, b) { + return (a & b) !== NoLanes; } -function preloadInstance(type, props) { - // Return true to indicate it's already loaded - return true; +function isSubsetOfLanes(set, subset) { + return (set & subset) === subset; } -function waitForCommitToBeReady() { - return null; +function mergeLanes(a, b) { + return a | b; } -var NotPendingTransition = null; - -var valueStack = []; -var fiberStack; - -{ - fiberStack = []; +function removeLanes(set, subset) { + return set & ~subset; } +function intersectLanes(a, b) { + return a & b; +} // Seems redundant, but it changes the type from a single lane (used for +// updates) to a group of lanes (used for flushing work). -var index = -1; - -function createCursor(defaultValue) { - return { - current: defaultValue - }; +function laneToLanes(lane) { + return lane; } +function createLaneMap(initial) { + // Intentionally pushing one by one. + // https://v8.dev/blog/elements-kinds#avoid-creating-holes + var laneMap = []; -function pop(cursor, fiber) { - if (index < 0) { - { - error('Unexpected pop.'); - } - - return; - } - - { - if (fiber !== fiberStack[index]) { - error('Unexpected Fiber popped.'); - } + for (var i = 0; i < TotalLanes; i++) { + laneMap.push(initial); } - cursor.current = valueStack[index]; - valueStack[index] = null; + return laneMap; +} +function markRootUpdated$1(root, updateLane) { + root.pendingLanes |= updateLane; // If there are any suspended transitions, it's possible this new update + // could unblock them. Clear the suspended lanes so that we can try rendering + // them again. + // + // TODO: We really only need to unsuspend only lanes that are in the + // `subtreeLanes` of the updated fiber, or the update lanes of the return + // path. This would exclude suspended updates in an unrelated sibling tree, + // since there's no way for this update to unblock it. + // + // We don't do this if the incoming update is idle, because we never process + // idle updates until after all the regular updates have finished; there's no + // way it could unblock a transition. - { - fiberStack[index] = null; + if (updateLane !== IdleLane) { + root.suspendedLanes = NoLanes; + root.pingedLanes = NoLanes; } - - index--; } +function markRootSuspended$1(root, suspendedLanes, spawnedLane) { + root.suspendedLanes |= suspendedLanes; + root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times. -function push(cursor, value, fiber) { - index++; - valueStack[index] = cursor.current; + var expirationTimes = root.expirationTimes; + var lanes = suspendedLanes; - { - fiberStack[index] = fiber; + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + expirationTimes[index] = NoTimestamp; + lanes &= ~lane; } - cursor.current = value; + if (spawnedLane !== NoLane) { + markSpawnedDeferredLane(root, spawnedLane, suspendedLanes); + } } - -var warnedAboutMissingGetChildContext; - -{ - warnedAboutMissingGetChildContext = {}; +function markRootPinged$1(root, pingedLanes) { + root.pingedLanes |= root.suspendedLanes & pingedLanes; } +function markRootFinished(root, remainingLanes, spawnedLane) { + var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; + root.pendingLanes = remainingLanes; // Let's try everything again -var emptyContextObject = {}; - -{ - Object.freeze(emptyContextObject); -} // A cursor to the current merged context object on the stack. + root.suspendedLanes = NoLanes; + root.pingedLanes = NoLanes; + root.expiredLanes &= remainingLanes; + root.entangledLanes &= remainingLanes; + root.errorRecoveryDisabledLanes &= remainingLanes; + root.shellSuspendCounter = 0; + var entanglements = root.entanglements; + var expirationTimes = root.expirationTimes; + var hiddenUpdates = root.hiddenUpdates; // Clear the lanes that no longer have pending work + var lanes = noLongerPendingLanes; -var contextStackCursor$1 = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + entanglements[index] = NoLanes; + expirationTimes[index] = NoTimestamp; + var hiddenUpdatesForLane = hiddenUpdates[index]; -var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. -// We use this to get access to the parent context after we have already -// pushed the next context provider, and now need to merge their contexts. + if (hiddenUpdatesForLane !== null) { + hiddenUpdates[index] = null; // "Hidden" updates are updates that were made to a hidden component. They + // have special logic associated with them because they may be entangled + // with updates that occur outside that tree. But once the outer tree + // commits, they behave like regular updates. -var previousContext = emptyContextObject; + for (var i = 0; i < hiddenUpdatesForLane.length; i++) { + var update = hiddenUpdatesForLane[i]; -function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { - { - if (didPushOwnContextIfProvider && isContextProvider(Component)) { - // If the fiber is a context provider itself, when we read its context - // we may have already pushed its own child context on the stack. A context - // provider should not "see" its own child context. Therefore we read the - // previous (parent) context instead for a context provider. - return previousContext; + if (update !== null) { + update.lane &= ~OffscreenLane; + } + } } - return contextStackCursor$1.current; + lanes &= ~lane; } -} -function cacheContext(workInProgress, unmaskedContext, maskedContext) { - { - var instance = workInProgress.stateNode; - instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; - instance.__reactInternalMemoizedMaskedChildContext = maskedContext; + if (spawnedLane !== NoLane) { + markSpawnedDeferredLane(root, spawnedLane, // This render finished successfully without suspending, so we don't need + // to entangle the spawned task with the parent task. + NoLanes); } } -function getMaskedContext(workInProgress, unmaskedContext) { - { - var type = workInProgress.type; - var contextTypes = type.contextTypes; - - if (!contextTypes) { - return emptyContextObject; - } // Avoid recreating masked context unless unmasked context has changed. - // Failing to do this will result in unnecessary calls to componentWillReceiveProps. - // This may trigger infinite loops if componentWillReceiveProps calls setState. - - - var instance = workInProgress.stateNode; - - if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { - return instance.__reactInternalMemoizedMaskedChildContext; - } +function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) { + // This render spawned a deferred task. Mark it as pending. + root.pendingLanes |= spawnedLane; + root.suspendedLanes &= ~spawnedLane; // Entangle the spawned lane with the DeferredLane bit so that we know it + // was the result of another render. This lets us avoid a useDeferredValue + // waterfall — only the first level will defer. - var context = {}; + var spawnedLaneIndex = laneToIndex(spawnedLane); + root.entangledLanes |= spawnedLane; + root.entanglements[spawnedLaneIndex] |= DeferredLane | // If the parent render task suspended, we must also entangle those lanes + // with the spawned task, so that the deferred task includes all the same + // updates that the parent task did. We can exclude any lane that is not + // used for updates (e.g. Offscreen). + entangledLanes & UpdateLanes; +} - for (var key in contextTypes) { - context[key] = unmaskedContext[key]; - } // Cache unmasked context so we can avoid recreating masked context unless necessary. - // Context is created before the class component is instantiated so check for instance. +function markRootEntangled(root, entangledLanes) { + // In addition to entangling each of the given lanes with each other, we also + // have to consider _transitive_ entanglements. For each lane that is already + // entangled with *any* of the given lanes, that lane is now transitively + // entangled with *all* the given lanes. + // + // Translated: If C is entangled with A, then entangling A with B also + // entangles C with B. + // + // If this is hard to grasp, it might help to intentionally break this + // function and look at the tests that fail in ReactTransition-test.js. Try + // commenting out one of the conditions below. + var rootEntangledLanes = root.entangledLanes |= entangledLanes; + var entanglements = root.entanglements; + var lanes = rootEntangledLanes; + while (lanes) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; - if (instance) { - cacheContext(workInProgress, unmaskedContext, context); + if ( // Is this one of the newly entangled lanes? + lane & entangledLanes | // Is this lane transitively entangled with the newly entangled lanes? + entanglements[index] & entangledLanes) { + entanglements[index] |= entangledLanes; } - return context; - } -} - -function hasContextChanged() { - { - return didPerformWorkStackCursor.current; + lanes &= ~lane; } } +function upgradePendingLaneToSync(root, lane) { + // Since we're upgrading the priority of the given lane, there is now pending + // sync work. + root.pendingLanes |= SyncLane; // Entangle the sync lane with the lane we're upgrading. This means SyncLane + // will not be allowed to finish without also finishing the given lane. -function isContextProvider(type) { - { - var childContextTypes = type.childContextTypes; - return childContextTypes !== null && childContextTypes !== undefined; - } + root.entangledLanes |= SyncLane; + root.entanglements[SyncLaneIndex] |= lane; } +function markHiddenUpdate(root, update, lane) { + var index = laneToIndex(lane); + var hiddenUpdates = root.hiddenUpdates; + var hiddenUpdatesForLane = hiddenUpdates[index]; -function popContext(fiber) { - { - pop(didPerformWorkStackCursor, fiber); - pop(contextStackCursor$1, fiber); + if (hiddenUpdatesForLane === null) { + hiddenUpdates[index] = [update]; + } else { + hiddenUpdatesForLane.push(update); } -} -function popTopLevelContextObject(fiber) { - { - pop(didPerformWorkStackCursor, fiber); - pop(contextStackCursor$1, fiber); - } + update.lane = lane | OffscreenLane; } +function getBumpedLaneForHydration(root, renderLanes) { + var renderLane = getHighestPriorityLane(renderLanes); + var lane; -function pushTopLevelContextObject(fiber, context, didChange) { - { - if (contextStackCursor$1.current !== emptyContextObject) { - throw new Error('Unexpected context found on stack. ' + 'This error is likely caused by a bug in React. Please file an issue.'); - } - - push(contextStackCursor$1, context, fiber); - push(didPerformWorkStackCursor, didChange, fiber); - } -} + if ((renderLane & SyncUpdateLanes) !== NoLane) { + lane = SyncHydrationLane; + } else { + switch (renderLane) { + case SyncLane: + lane = SyncHydrationLane; + break; -function processChildContext(fiber, type, parentContext) { - { - var instance = fiber.stateNode; - var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. - // It has only been added in Fiber to match the (unintentional) behavior in Stack. + case InputContinuousLane: + lane = InputContinuousHydrationLane; + break; - if (typeof instance.getChildContext !== 'function') { - { - var componentName = getComponentNameFromFiber(fiber) || 'Unknown'; + case DefaultLane: + lane = DefaultHydrationLane; + break; - if (!warnedAboutMissingGetChildContext[componentName]) { - warnedAboutMissingGetChildContext[componentName] = true; + case TransitionLane1: + case TransitionLane2: + case TransitionLane3: + case TransitionLane4: + case TransitionLane5: + case TransitionLane6: + case TransitionLane7: + case TransitionLane8: + case TransitionLane9: + case TransitionLane10: + case TransitionLane11: + case TransitionLane12: + case TransitionLane13: + case TransitionLane14: + case TransitionLane15: + case RetryLane1: + case RetryLane2: + case RetryLane3: + case RetryLane4: + lane = TransitionHydrationLane; + break; - error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); - } - } + case IdleLane: + lane = IdleHydrationLane; + break; - return parentContext; + default: + // Everything else is already either a hydration lane, or shouldn't + // be retried at a hydration lane. + lane = NoLane; + break; } + } // Check if the lane we chose is suspended. If so, that indicates that we + // already attempted and failed to hydrate at that level. Also check if we're + // already rendering that lane, which is rare but could happen. - var childContext = instance.getChildContext(); - - for (var contextKey in childContext) { - if (!(contextKey in childContextTypes)) { - throw new Error((getComponentNameFromFiber(fiber) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."); - } - } - return assign({}, parentContext, childContext); + if ((lane & (root.suspendedLanes | renderLanes)) !== NoLane) { + // Give up trying to hydrate and fall back to client render. + return NoLane; } -} -function pushContextProvider(workInProgress) { + return lane; +} +function getTransitionsForLanes(root, lanes) { { - var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. - // If the instance does not exist yet, we will push null at first, - // and replace it on the stack later when invalidating the context. - - var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. - // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. - - previousContext = contextStackCursor$1.current; - push(contextStackCursor$1, memoizedMergedChildContext, workInProgress); - push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); - return true; + return null; } } -function invalidateContextProvider(workInProgress, type, didChange) { - { - var instance = workInProgress.stateNode; - - if (!instance) { - throw new Error('Expected to have an instance by this point. ' + 'This error is likely caused by a bug in React. Please file an issue.'); - } - - if (didChange) { - // Merge parent and own context. - // Skip this if we're not updating due to sCU. - // This avoids unnecessarily recomputing memoized values. - var mergedContext = processChildContext(workInProgress, type, previousContext); - instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. - // It is important to unwind the context in the reverse order. +var NoEventPriority = NoLane; +var DiscreteEventPriority = SyncLane; +var ContinuousEventPriority = InputContinuousLane; +var DefaultEventPriority = DefaultLane; +var IdleEventPriority = IdleLane; +function higherEventPriority(a, b) { + return a !== 0 && a < b ? a : b; +} +function lowerEventPriority(a, b) { + return a === 0 || a > b ? a : b; +} +function isHigherEventPriority(a, b) { + return a !== 0 && a < b; +} +function eventPriorityToLane(updatePriority) { + return updatePriority; +} +function lanesToEventPriority(lanes) { + var lane = getHighestPriorityLane(lanes); - pop(didPerformWorkStackCursor, workInProgress); - pop(contextStackCursor$1, workInProgress); // Now push the new context and mark that it has changed. + if (!isHigherEventPriority(DiscreteEventPriority, lane)) { + return DiscreteEventPriority; + } - push(contextStackCursor$1, mergedContext, workInProgress); - push(didPerformWorkStackCursor, didChange, workInProgress); - } else { - pop(didPerformWorkStackCursor, workInProgress); - push(didPerformWorkStackCursor, didChange, workInProgress); - } + if (!isHigherEventPriority(ContinuousEventPriority, lane)) { + return ContinuousEventPriority; + } + + if (includesNonIdleWork(lane)) { + return DefaultEventPriority; } + + return IdleEventPriority; } -function findCurrentUnmaskedContext(fiber) { - { - // Currently this is only used with renderSubtreeIntoContainer; not sure if it - // makes sense elsewhere - if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) { - throw new Error('Expected subtree parent to be a mounted class component. ' + 'This error is likely caused by a bug in React. Please file an issue.'); - } +// Renderers that don't support hydration +// can re-export everything from this module. +function shim$1() { + throw new Error('The current renderer does not support hydration. ' + 'This error is likely caused by a bug in React. ' + 'Please file an issue.'); +} // Hydration (when unsupported) - var node = fiber; - do { - switch (node.tag) { - case HostRoot: - return node.stateNode.context; +var supportsHydration = false; +var isSuspenseInstancePending = shim$1; +var isSuspenseInstanceFallback = shim$1; +var getSuspenseInstanceFallbackErrorDetails = shim$1; +var registerSuspenseInstanceRetry = shim$1; +var clearSuspenseBoundary = shim$1; +var clearSuspenseBoundaryFromContainer = shim$1; - case ClassComponent: - { - var Component = node.type; +// Renderers that don't support hydration +// can re-export everything from this module. +function shim() { + throw new Error('The current renderer does not support Resources. ' + 'This error is likely caused by a bug in React. ' + 'Please file an issue.'); +} // Resources (when unsupported) +var preloadResource = shim; +var suspendResource = shim; - if (isContextProvider(Component)) { - return node.stateNode.__reactInternalMemoizedMergedChildContext; - } +var NO_CONTEXT = {}; +var nodeToInstanceMap = new WeakMap(); - break; - } - } // $FlowFixMe[incompatible-type] we bail out when we get a null +{ + Object.freeze(NO_CONTEXT); +} +function getPublicInstance(inst) { + switch (inst.tag) { + case 'INSTANCE': + var createNodeMock = inst.rootContainerInstance.createNodeMock; + var mockNode = createNodeMock({ + type: inst.type, + props: inst.props + }); - node = node.return; - } while (node !== null); + if (typeof mockNode === 'object' && mockNode !== null) { + nodeToInstanceMap.set(mockNode, inst); + } - throw new Error('Found unexpected detached subtree parent. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + return mockNode; + + default: + return inst; } } +function appendChild(parentInstance, child) { + { + if (!isArray(parentInstance.children)) { + error('An invalid container has been provided. ' + 'This may indicate that another renderer is being used in addition to the test renderer. ' + '(For example, ReactDOM.createPortal inside of a ReactTestRenderer tree.) ' + 'This is not supported.'); + } + } -// We use the existence of the state object as an indicator that the component -// is hidden. -var OffscreenVisible = -/* */ -1; -var OffscreenDetached = -/* */ -2; -var OffscreenPassiveEffectsConnected = -/* */ -4; -function isOffscreenManual(offscreenFiber) { - return offscreenFiber.memoizedProps !== null && offscreenFiber.memoizedProps.mode === 'manual'; -} + var index = parentInstance.children.indexOf(child); -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ -function is(x, y) { - return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare - ; + if (index !== -1) { + parentInstance.children.splice(index, 1); + } + + parentInstance.children.push(child); } +function insertBefore(parentInstance, child, beforeChild) { + var index = parentInstance.children.indexOf(child); -var objectIs = // $FlowFixMe[method-unbinding] -typeof Object.is === 'function' ? Object.is : is; + if (index !== -1) { + parentInstance.children.splice(index, 1); + } -var prefix; -function describeBuiltInComponentFrame(name) { - { - if (prefix === undefined) { - // Extract the VM specific prefix used by each line. - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = match && match[1] || ''; - } - } // We use the prefix to ensure our stacks line up with native stack frames. + var beforeIndex = parentInstance.children.indexOf(beforeChild); + parentInstance.children.splice(beforeIndex, 0, child); +} +function removeChild(parentInstance, child) { + var index = parentInstance.children.indexOf(child); + parentInstance.children.splice(index, 1); +} +function clearContainer(container) { + container.children.splice(0); +} +function getRootHostContext(rootContainerInstance) { + return NO_CONTEXT; +} +function getChildHostContext(parentHostContext, type) { + return NO_CONTEXT; +} +function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { + return { + type: type, + props: props, + isHidden: false, + children: [], + internalInstanceHandle: internalInstanceHandle, + rootContainerInstance: rootContainerInstance, + tag: 'INSTANCE' + }; +} +function appendInitialChild(parentInstance, child) { + var index = parentInstance.children.indexOf(child); + if (index !== -1) { + parentInstance.children.splice(index, 1); + } - return '\n' + prefix + name; + parentInstance.children.push(child); +} +function shouldSetTextContent(type, props) { + return false; +} +function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) { + return { + text: text, + isHidden: false, + tag: 'TEXT' + }; +} +var currentUpdatePriority = NoEventPriority; +function setCurrentUpdatePriority(newPriority) { + currentUpdatePriority = newPriority; +} +function getCurrentUpdatePriority() { + return currentUpdatePriority; +} +function resolveUpdatePriority() { + if (currentUpdatePriority !== NoEventPriority) { + return currentUpdatePriority; } + + return DefaultEventPriority; } -function describeDebugInfoFrame(name, env) { - return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : '')); +function shouldAttemptEagerTransition() { + return false; } -var reentry = false; -var componentFrameCache; +var scheduleTimeout = setTimeout; +var cancelTimeout = clearTimeout; +var noTimeout = -1; // ------------------- +function commitUpdate(instance, type, oldProps, newProps, internalInstanceHandle) { + instance.type = type; + instance.props = newProps; +} +function commitMount(instance, type, newProps, internalInstanceHandle) {// noop +} +function commitTextUpdate(textInstance, oldText, newText) { + textInstance.text = newText; +} +function resetTextContent(testElement) {// noop +} +var appendChildToContainer = appendChild; +var insertInContainerBefore = insertBefore; +var removeChildFromContainer = removeChild; +function hideInstance(instance) { + instance.isHidden = true; +} +function hideTextInstance(textInstance) { + textInstance.isHidden = true; +} +function unhideInstance(instance, props) { + instance.isHidden = false; +} +function unhideTextInstance(textInstance, text) { + textInstance.isHidden = false; +} +function preloadInstance(type, props) { + // Return true to indicate it's already loaded + return true; +} +function waitForCommitToBeReady() { + return null; +} +var NotPendingTransition = null; + +var valueStack = []; +var fiberStack; { - var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; - componentFrameCache = new PossiblyWeakMap$1(); + fiberStack = []; } -/** - * Leverages native browser/VM stack frames to get proper details (e.g. - * filename, line + col number) for a single component in a component stack. We - * do this by: - * (1) throwing and catching an error in the function - this will be our - * control error. - * (2) calling the component which will eventually throw an error that we'll - * catch - this will be our sample error. - * (3) diffing the control and sample error stacks to find the stack frame - * which represents our component. - */ +var index = -1; + +function createCursor(defaultValue) { + return { + current: defaultValue + }; +} -function describeNativeComponentFrame(fn, construct) { - // If something asked for a stack inside a fake render, it should get ignored. - if (!fn || reentry) { - return ''; +function pop(cursor, fiber) { + if (index < 0) { + { + error('Unexpected pop.'); + } + + return; } { - var frame = componentFrameCache.get(fn); - - if (frame !== undefined) { - return frame; + if (fiber !== fiberStack[index]) { + error('Unexpected Fiber popped.'); } } - reentry = true; - var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. - - Error.prepareStackTrace = undefined; - var previousDispatcher = null; + cursor.current = valueStack[index]; + valueStack[index] = null; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function - // for warnings. - - ReactSharedInternals.H = null; - disableLogs(); + fiberStack[index] = null; } - /** - * Finding a common stack frame between sample and control errors can be - * tricky given the different types and levels of stack trace truncation from - * different JS VMs. So instead we'll attempt to control what that common - * frame should be through this object method: - * Having both the sample and control errors be in the function under the - * `DescribeNativeComponentFrameRoot` property, + setting the `name` and - * `displayName` properties of the function ensures that a stack - * frame exists that has the method name `DescribeNativeComponentFrameRoot` in - * it for both control and sample stacks. - */ + index--; +} - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - var control; +function push(cursor, value, fiber) { + index++; + valueStack[index] = cursor.current; - try { - // This should throw. - if (construct) { - // Something should be setting the props in the constructor. - var Fake = function () { - throw Error(); - }; // $FlowFixMe[prop-missing] + { + fiberStack[index] = fiber; + } + cursor.current = value; +} - Object.defineProperty(Fake.prototype, 'props', { - set: function () { - // We use a throwing setter instead of frozen or non-writable props - // because that won't throw in a non-strict mode function. - throw Error(); - } - }); +var warnedAboutMissingGetChildContext; - if (typeof Reflect === 'object' && Reflect.construct) { - // We construct a different control for this case to include any extra - // frames added by the construct call. - try { - Reflect.construct(Fake, []); - } catch (x) { - control = x; - } +{ + warnedAboutMissingGetChildContext = {}; +} - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x) { - control = x; - } // $FlowFixMe[prop-missing] found when upgrading Flow +var emptyContextObject = {}; +{ + Object.freeze(emptyContextObject); +} // A cursor to the current merged context object on the stack. - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x) { - control = x; - } // TODO(luna): This will currently only throw if the function component - // tries to access React/ReactDOM/props. We should probably make this throw - // in simple components too +var contextStackCursor$1 = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. - var maybePromise = fn(); // If the function component returns a promise, it's likely an async - // component, which we don't yet support. Attach a noop catch handler to - // silence the error. - // TODO: Implement component stacks for async client components? +var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. +// We use this to get access to the parent context after we have already +// pushed the next context provider, and now need to merge their contexts. - if (maybePromise && typeof maybePromise.catch === 'function') { - maybePromise.catch(function () {}); - } - } - } catch (sample) { - // This is inlined manually because closure doesn't do it for us. - if (sample && control && typeof sample.stack === 'string') { - return [sample.stack, control.stack]; - } - } +var previousContext = emptyContextObject; - return [null, null]; +function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { + { + if (didPushOwnContextIfProvider && isContextProvider(Component)) { + // If the fiber is a context provider itself, when we read its context + // we may have already pushed its own child context on the stack. A context + // provider should not "see" its own child context. Therefore we read the + // previous (parent) context instead for a context provider. + return previousContext; } - }; // $FlowFixMe[prop-missing] - RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; - var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable. + return contextStackCursor$1.current; + } +} - if (namePropDescriptor && namePropDescriptor.configurable) { - // V8 utilizes a function's `name` property when generating a stack trace. - Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor - // is set to `false`. - // $FlowFixMe[cannot-write] - 'name', { - value: 'DetermineComponentFrameRoot' - }); +function cacheContext(workInProgress, unmaskedContext, maskedContext) { + { + var instance = workInProgress.stateNode; + instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; + instance.__reactInternalMemoizedMaskedChildContext = maskedContext; } +} - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; +function getMaskedContext(workInProgress, unmaskedContext) { + { + var type = workInProgress.type; + var contextTypes = type.contextTypes; - if (sampleStack && controlStack) { - // This extracts the first frame from the sample that isn't also in the control. - // Skipping one frame that we assume is the frame that calls the two. - var sampleLines = sampleStack.split('\n'); - var controlLines = controlStack.split('\n'); - var s = 0; - var c = 0; + if (!contextTypes) { + return emptyContextObject; + } // Avoid recreating masked context unless unmasked context has changed. + // Failing to do this will result in unnecessary calls to componentWillReceiveProps. + // This may trigger infinite loops if componentWillReceiveProps calls setState. - while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { - s++; - } - while (c < controlLines.length && !controlLines[c].includes('DetermineComponentFrameRoot')) { - c++; - } // We couldn't find our intentionally injected common root frame, attempt - // to find another common root frame by search from the bottom of the - // control stack... + var instance = workInProgress.stateNode; + if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { + return instance.__reactInternalMemoizedMaskedChildContext; + } - if (s === sampleLines.length || c === controlLines.length) { - s = sampleLines.length - 1; - c = controlLines.length - 1; + var context = {}; - while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { - // We expect at least one stack frame to be shared. - // Typically this will be the root most one. However, stack frames may be - // cut off due to maximum stack limits. In this case, one maybe cut off - // earlier than the other. We assume that the sample is longer or the same - // and there for cut off earlier. So we should find the root most frame in - // the sample somewhere in the control. - c--; - } - } + for (var key in contextTypes) { + context[key] = unmaskedContext[key]; + } // Cache unmasked context so we can avoid recreating masked context unless necessary. + // Context is created before the class component is instantiated so check for instance. - for (; s >= 1 && c >= 0; s--, c--) { - // Next we find the first one that isn't the same which should be the - // frame that called our sample function and the control. - if (sampleLines[s] !== controlLines[c]) { - // In V8, the first line is describing the message but other VMs don't. - // If we're about to return the first line, and the control is also on the same - // line, that's a pretty good indicator that our sample threw at same line as - // the control. I.e. before we entered the sample frame. So we ignore this result. - // This can happen if you passed a class to function component, or non-function. - if (s !== 1 || c !== 1) { - do { - s--; - c--; // We may still have similar intermediate frames from the construct call. - // The next one that isn't the same should be our match though. - if (c < 0 || sampleLines[s] !== controlLines[c]) { - // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. - var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "" - // but we have a user-provided "displayName" - // splice it in to make the stack more readable. + if (instance) { + cacheContext(workInProgress, unmaskedContext, context); + } + + return context; + } +} + +function hasContextChanged() { + { + return didPerformWorkStackCursor.current; + } +} + +function isContextProvider(type) { + { + var childContextTypes = type.childContextTypes; + return childContextTypes !== null && childContextTypes !== undefined; + } +} + +function popContext(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor$1, fiber); + } +} + +function popTopLevelContextObject(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor$1, fiber); + } +} +function pushTopLevelContextObject(fiber, context, didChange) { + { + if (contextStackCursor$1.current !== emptyContextObject) { + throw new Error('Unexpected context found on stack. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + } - if (fn.displayName && _frame.includes('')) { - _frame = _frame.replace('', fn.displayName); - } + push(contextStackCursor$1, context, fiber); + push(didPerformWorkStackCursor, didChange, fiber); + } +} - if (true) { - if (typeof fn === 'function') { - componentFrameCache.set(fn, _frame); - } - } // Return the line we found. +function processChildContext(fiber, type, parentContext) { + { + var instance = fiber.stateNode; + var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. + // It has only been added in Fiber to match the (unintentional) behavior in Stack. + if (typeof instance.getChildContext !== 'function') { + { + var componentName = getComponentNameFromFiber(fiber) || 'Unknown'; - return _frame; - } - } while (s >= 1 && c >= 0); - } + if (!warnedAboutMissingGetChildContext[componentName]) { + warnedAboutMissingGetChildContext[componentName] = true; - break; + error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); } } - } - } finally { - reentry = false; - { - ReactSharedInternals.H = previousDispatcher; - reenableLogs(); + return parentContext; } - Error.prepareStackTrace = previousPrepareStackTrace; - } // Fallback to just using the name if we couldn't make it throw. - - - var name = fn ? fn.displayName || fn.name : ''; - var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; + var childContext = instance.getChildContext(); - { - if (typeof fn === 'function') { - componentFrameCache.set(fn, syntheticFrame); + for (var contextKey in childContext) { + if (!(contextKey in childContextTypes)) { + throw new Error((getComponentNameFromFiber(fiber) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."); + } } - } - - return syntheticFrame; -} -function describeClassComponentFrame(ctor) { - { - return describeNativeComponentFrame(ctor, true); - } -} -function describeFunctionComponentFrame(fn) { - { - return describeNativeComponentFrame(fn, false); + return assign({}, parentContext, childContext); } } -function describeFiber(fiber) { - switch (fiber.tag) { - case HostHoistable: - case HostSingleton: - case HostComponent: - return describeBuiltInComponentFrame(fiber.type); +function pushContextProvider(workInProgress) { + { + var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. + // If the instance does not exist yet, we will push null at first, + // and replace it on the stack later when invalidating the context. - case LazyComponent: - return describeBuiltInComponentFrame('Lazy'); + var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. + // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. - case SuspenseComponent: - return describeBuiltInComponentFrame('Suspense'); + previousContext = contextStackCursor$1.current; + push(contextStackCursor$1, memoizedMergedChildContext, workInProgress); + push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); + return true; + } +} - case SuspenseListComponent: - return describeBuiltInComponentFrame('SuspenseList'); +function invalidateContextProvider(workInProgress, type, didChange) { + { + var instance = workInProgress.stateNode; - case FunctionComponent: - case SimpleMemoComponent: - return describeFunctionComponentFrame(fiber.type); + if (!instance) { + throw new Error('Expected to have an instance by this point. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + } - case ForwardRef: - return describeFunctionComponentFrame(fiber.type.render); + if (didChange) { + // Merge parent and own context. + // Skip this if we're not updating due to sCU. + // This avoids unnecessarily recomputing memoized values. + var mergedContext = processChildContext(workInProgress, type, previousContext); + instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. + // It is important to unwind the context in the reverse order. - case ClassComponent: - return describeClassComponentFrame(fiber.type); + pop(didPerformWorkStackCursor, workInProgress); + pop(contextStackCursor$1, workInProgress); // Now push the new context and mark that it has changed. - default: - return ''; + push(contextStackCursor$1, mergedContext, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); + } else { + pop(didPerformWorkStackCursor, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); + } } } -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ''; - var node = workInProgress; +function findCurrentUnmaskedContext(fiber) { + { + // Currently this is only used with renderSubtreeIntoContainer; not sure if it + // makes sense elsewhere + if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) { + throw new Error('Expected subtree parent to be a mounted class component. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + } - do { - info += describeFiber(node); + var node = fiber; - if (true) { - // Add any Server Component stack frames in reverse order. - var debugInfo = node._debugInfo; + do { + switch (node.tag) { + case HostRoot: + return node.stateNode.context; - if (debugInfo) { - for (var i = debugInfo.length - 1; i >= 0; i--) { - var entry = debugInfo[i]; + case ClassComponent: + { + var Component = node.type; - if (typeof entry.name === 'string') { - info += describeDebugInfoFrame(entry.name, entry.env); + if (isContextProvider(Component)) { + return node.stateNode.__reactInternalMemoizedMergedChildContext; } + + break; } - } } // $FlowFixMe[incompatible-type] we bail out when we get a null node = node.return; - } while (node); + } while (node !== null); - return info; - } catch (x) { - return '\nError generating stack: ' + x.message + '\n' + x.stack; + throw new Error('Found unexpected detached subtree parent. ' + 'This error is likely caused by a bug in React. Please file an issue.'); } } +// We use the existence of the state object as an indicator that the component +// is hidden. +var OffscreenVisible = +/* */ +1; +var OffscreenDetached = +/* */ +2; +var OffscreenPassiveEffectsConnected = +/* */ +4; +function isOffscreenManual(offscreenFiber) { + return offscreenFiber.memoizedProps !== null && offscreenFiber.memoizedProps.mode === 'manual'; +} + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare + ; +} + +var objectIs = // $FlowFixMe[method-unbinding] +typeof Object.is === 'function' ? Object.is : is; + var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { // If the value is an error, call this function immediately after it is thrown @@ -5056,46 +5103,6 @@ function shallowEqual(objA, objB) { return true; } -var current = null; -var isRendering = false; - -function getCurrentFiberStackInDev() { - { - if (current === null) { - return ''; - } // Safe because if current fiber exists, we are reconciling, - // and it is guaranteed to be the work-in-progress version. - - - return getStackByFiberInDevAndProd(current); - } -} - -function resetCurrentFiber() { - { - ReactSharedInternals.getCurrentStack = null; - current = null; - isRendering = false; - } -} -function setCurrentFiber(fiber) { - { - ReactSharedInternals.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev; - current = fiber; - isRendering = false; - } -} -function getCurrentFiber() { - { - return current; - } -} -function setIsRendering(rendering) { - { - isRendering = rendering; - } -} - var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function (fiber, instance) {}, flushPendingUnsafeLifecycleWarnings: function () {}, @@ -5315,11 +5322,11 @@ var ReactStrictModeWarnings = { var sortedNames = setToSortedString(uniqueNames); try { - setCurrentFiber(firstFiber); + setCurrentDebugFiberInDEV(firstFiber); error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); } finally { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } }); }; @@ -12162,7 +12169,6 @@ function updateForwardRef(current, workInProgress, Component, nextProps, renderL } { - setCurrentOwner(workInProgress); setIsRendering(true); nextChildren = renderWithHooks(current, workInProgress, render, propsWithoutRef, ref, renderLanes); setIsRendering(false); @@ -12632,7 +12638,6 @@ function updateFunctionComponent(current, workInProgress, Component, nextProps, } { - setCurrentOwner(workInProgress); setIsRendering(true); nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes); setIsRendering(false); @@ -12784,7 +12789,7 @@ function finishClassComponent(current, workInProgress, Component, shouldUpdate, var instance = workInProgress.stateNode; // Rerender { - setCurrentOwner(workInProgress); + setCurrentFiber(workInProgress); } var nextChildren; @@ -14080,7 +14085,6 @@ function updateContextConsumer(current, workInProgress, renderLanes) { var newChildren; { - setCurrentOwner(workInProgress); setIsRendering(true); newChildren = render(newValue); setIsRendering(false); @@ -16473,7 +16477,7 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); try { commitBeforeMutationEffectsOnFiber(fiber); @@ -16481,7 +16485,7 @@ function commitBeforeMutationEffects_complete() { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -16499,7 +16503,7 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { var flags = finishedWork.flags; if ((flags & Snapshot) !== NoFlags$1) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); } switch (finishedWork.tag) { @@ -16586,7 +16590,7 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } @@ -17841,9 +17845,9 @@ function attachSuspenseRetryListeners(finishedWork, wakeables) { }); } // This function detects when a Suspense boundary goes from visible to hidden. function commitMutationEffects(root, finishedWork, committedLanes) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); commitMutationEffectsOnFiber(finishedWork, root); - setCurrentFiber(finishedWork); + resetCurrentDebugFiberInDEV(); } function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { @@ -17869,13 +17873,13 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitMutationEffectsOnFiber(child, root); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitMutationEffectsOnFiber(finishedWork, root, lanes) { @@ -18257,8 +18261,10 @@ function commitReconciliationEffects(finishedWork) { } function commitLayoutEffects(finishedWork, root, committedLanes) { + setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; commitLayoutEffectOnFiber(root, current, finishedWork); + resetCurrentDebugFiberInDEV(); } function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { @@ -18268,14 +18274,14 @@ function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); var current = child.alternate; commitLayoutEffectOnFiber(root, current, child); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -18485,7 +18491,7 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc child = child.sibling; } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -18563,9 +18569,9 @@ function commitCachePassiveMountEffect(current, finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { @@ -18575,13 +18581,13 @@ function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLane var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -18729,7 +18735,7 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c child = child.sibling; } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -18840,13 +18846,13 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitAtomicPassiveEffects(finishedRoot, child); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -18891,9 +18897,9 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, } function commitPassiveUnmountEffects(finishedWork) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); commitPassiveUnmountOnFiber(finishedWork); - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -19047,13 +19053,13 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitPassiveUnmountOnFiber(child); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -19124,12 +19130,12 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); disconnectPassiveEffect(child); child = child.sibling; } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -19171,9 +19177,9 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -19395,7 +19401,7 @@ var DefaultAsyncDispatcher = { { DefaultAsyncDispatcher.getOwner = function () { - return currentOwner; + return current; }; } @@ -20348,10 +20354,9 @@ function handleThrow(root, thrownValue) { // These should be reset immediately because they're only supposed to be set // when React is executing user code. resetHooksAfterThrow(); - resetCurrentFiber(); { - setCurrentOwner(null); + resetCurrentFiber(); } if (thrownValue === SuspenseException) { @@ -20950,7 +20955,7 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentFiber(unitOfWork); + setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { @@ -20961,7 +20966,10 @@ function performUnitOfWork(unitOfWork) { next = beginWork(current, unitOfWork, entangledRenderLanes); } - resetCurrentFiber(); + { + resetCurrentFiber(); + } + unitOfWork.memoizedProps = unitOfWork.pendingProps; if (next === null) { @@ -20970,10 +20978,6 @@ function performUnitOfWork(unitOfWork) { } else { workInProgress = next; } - - { - setCurrentOwner(null); - } } function replaySuspendedUnitOfWork(unitOfWork) { @@ -20981,9 +20985,8 @@ function replaySuspendedUnitOfWork(unitOfWork) { // just suspended. // var current = unitOfWork.alternate; - setCurrentFiber(unitOfWork); + setCurrentDebugFiberInDEV(unitOfWork); var next; - setCurrentFiber(unitOfWork); var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; if (isProfilingMode) { @@ -21061,7 +21064,10 @@ function replaySuspendedUnitOfWork(unitOfWork) { // normal work loop. - resetCurrentFiber(); + { + resetCurrentFiber(); + } + unitOfWork.memoizedProps = unitOfWork.pendingProps; if (next === null) { @@ -21070,10 +21076,6 @@ function replaySuspendedUnitOfWork(unitOfWork) { } else { workInProgress = next; } - - { - setCurrentOwner(null); - } } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -21160,7 +21162,7 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentFiber(completedWork); + setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { @@ -21172,7 +21174,7 @@ function completeUnitOfWork(unitOfWork) { stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); if (next !== null) { // Completing this fiber spawned new work. Work on that next. @@ -21397,18 +21399,13 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh var previousPriority = getCurrentUpdatePriority(); setCurrentUpdatePriority(DiscreteEventPriority); var prevExecutionContext = executionContext; - executionContext |= CommitContext; // Reset this to null before calling lifecycles - - { - setCurrentOwner(null); - } // The commit phase is broken into several sub-phases. We do a separate pass + executionContext |= CommitContext; // The commit phase is broken into several sub-phases. We do a separate pass // of the effect list for each phase: all mutation effects come before all // layout effects, and so on. // The first phase a "before mutation" phase. We use this phase to read the // state of the host tree right before we mutate it. This is where // getSnapshotBeforeUpdate is called. - commitBeforeMutationEffects(root, finishedWork); { @@ -22011,13 +22008,13 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); if (isInStrictMode) { doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -22030,7 +22027,7 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only @@ -22042,7 +22039,7 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } @@ -22066,7 +22063,7 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { // TODO (StrictEffects) Should we set a marker on the root if it contains strict effects // so we don't traverse unnecessarily? similar to subtreeFlags but just at the root level. // Maybe not a big deal since this is DEV only behavior. - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV); if (hasPassiveEffects) { @@ -22079,7 +22076,7 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { @@ -22142,14 +22139,14 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { var previousFiber = current; try { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); } finally { if (previousFiber) { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); } else { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } } @@ -22250,14 +22247,14 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { var previousFiber = current; try { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); } finally { if (previousFiber) { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); } else { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } } @@ -23306,7 +23303,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-rc-143c3a2f'; +var ReactVersion = '19.0.0-rc-e2db64f5'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js index 65d6c12f509ae..93261d2835b83 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<6540b866a6ff4178bae5e8496c9c2dc6>> */ "use strict"; @@ -165,6 +165,188 @@ function getComponentNameFromFiber(fiber) { } return null; } +var ReactSharedInternals = + React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, + prefix; +function describeBuiltInComponentFrame(name) { + if (void 0 === prefix) + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = (match && match[1]) || ""; + } + return "\n" + prefix + name; +} +var reentry = !1; +function describeNativeComponentFrame(fn, construct) { + if (!fn || reentry) return ""; + reentry = !0; + var previousPrepareStackTrace = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + try { + if (construct) { + var Fake = function () { + throw Error(); + }; + Object.defineProperty(Fake.prototype, "props", { + set: function () { + throw Error(); + } + }); + if ("object" === typeof Reflect && Reflect.construct) { + try { + Reflect.construct(Fake, []); + } catch (x) { + var control = x; + } + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x$0) { + control = x$0; + } + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x$1) { + control = x$1; + } + (Fake = fn()) && + "function" === typeof Fake.catch && + Fake.catch(function () {}); + } + } catch (sample) { + if (sample && control && "string" === typeof sample.stack) + return [sample.stack, control.stack]; + } + return [null, null]; + } + }; + RunInRootFrame.DetermineComponentFrameRoot.displayName = + "DetermineComponentFrameRoot"; + var namePropDescriptor = Object.getOwnPropertyDescriptor( + RunInRootFrame.DetermineComponentFrameRoot, + "name" + ); + namePropDescriptor && + namePropDescriptor.configurable && + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { + value: "DetermineComponentFrameRoot" + }); + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; + if (sampleStack && controlStack) { + var sampleLines = sampleStack.split("\n"), + controlLines = controlStack.split("\n"); + for ( + namePropDescriptor = RunInRootFrame = 0; + RunInRootFrame < sampleLines.length && + !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); + + ) + RunInRootFrame++; + for ( + ; + namePropDescriptor < controlLines.length && + !controlLines[namePropDescriptor].includes( + "DetermineComponentFrameRoot" + ); + + ) + namePropDescriptor++; + if ( + RunInRootFrame === sampleLines.length || + namePropDescriptor === controlLines.length + ) + for ( + RunInRootFrame = sampleLines.length - 1, + namePropDescriptor = controlLines.length - 1; + 1 <= RunInRootFrame && + 0 <= namePropDescriptor && + sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; + + ) + namePropDescriptor--; + for ( + ; + 1 <= RunInRootFrame && 0 <= namePropDescriptor; + RunInRootFrame--, namePropDescriptor-- + ) + if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { + if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { + do + if ( + (RunInRootFrame--, + namePropDescriptor--, + 0 > namePropDescriptor || + sampleLines[RunInRootFrame] !== + controlLines[namePropDescriptor]) + ) { + var frame = + "\n" + + sampleLines[RunInRootFrame].replace(" at new ", " at "); + fn.displayName && + frame.includes("") && + (frame = frame.replace("", fn.displayName)); + return frame; + } + while (1 <= RunInRootFrame && 0 <= namePropDescriptor); + } + break; + } + } + } finally { + (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); + } + return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") + ? describeBuiltInComponentFrame(previousPrepareStackTrace) + : ""; +} +function describeFiber(fiber) { + switch (fiber.tag) { + case 26: + case 27: + case 5: + return describeBuiltInComponentFrame(fiber.type); + case 16: + return describeBuiltInComponentFrame("Lazy"); + case 13: + return describeBuiltInComponentFrame("Suspense"); + case 19: + return describeBuiltInComponentFrame("SuspenseList"); + case 0: + case 15: + return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; + case 11: + return ( + (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber + ); + case 1: + return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; + default: + return ""; + } +} +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} function getNearestMountedFiber(fiber) { var node = fiber, nearestMounted = fiber; @@ -213,36 +395,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$0 = parentA.child; child$0; ) { - if (child$0 === a) { + for (var didFindChild = !1, child$2 = parentA.child; child$2; ) { + if (child$2 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$0 === b) { + if (child$2 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$0 = child$0.sibling; + child$2 = child$2.sibling; } if (!didFindChild) { - for (child$0 = parentB.child; child$0; ) { - if (child$0 === a) { + for (child$2 = parentB.child; child$2; ) { + if (child$2 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$0 === b) { + if (child$2 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$0 = child$0.sibling; + child$2 = child$2.sibling; } if (!didFindChild) throw Error( @@ -270,8 +452,6 @@ function findCurrentHostFiberImpl(node) { return null; } var isArrayImpl = Array.isArray, - ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, scheduleCallback$3 = Scheduler$1.unstable_scheduleCallback, cancelCallback$1 = Scheduler$1.unstable_cancelCallback, shouldYield = Scheduler$1.unstable_shouldYield, @@ -471,18 +651,18 @@ function markRootFinished(root, remainingLanes, spawnedLane) { 0 < noLongerPendingLanes; ) { - var index$4 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$4; - remainingLanes[index$4] = 0; - expirationTimes[index$4] = -1; - var hiddenUpdatesForLane = hiddenUpdates[index$4]; + var index$6 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$6; + remainingLanes[index$6] = 0; + expirationTimes[index$6] = -1; + var hiddenUpdatesForLane = hiddenUpdates[index$6]; if (null !== hiddenUpdatesForLane) for ( - hiddenUpdates[index$4] = null, index$4 = 0; - index$4 < hiddenUpdatesForLane.length; - index$4++ + hiddenUpdates[index$6] = null, index$6 = 0; + index$6 < hiddenUpdatesForLane.length; + index$6++ ) { - var update = hiddenUpdatesForLane[index$4]; + var update = hiddenUpdatesForLane[index$6]; null !== update && (update.lane &= -536870913); } noLongerPendingLanes &= ~lane; @@ -502,10 +682,10 @@ function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) { function markRootEntangled(root, entangledLanes) { var rootEntangledLanes = (root.entangledLanes |= entangledLanes); for (root = root.entanglements; rootEntangledLanes; ) { - var index$5 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$5; - (lane & entangledLanes) | (root[index$5] & entangledLanes) && - (root[index$5] |= entangledLanes); + var index$7 = 31 - clz32(rootEntangledLanes), + lane = 1 << index$7; + (lane & entangledLanes) | (root[index$7] & entangledLanes) && + (root[index$7] |= entangledLanes); rootEntangledLanes &= ~lane; } } @@ -659,187 +839,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - prefix; -function describeBuiltInComponentFrame(name) { - if (void 0 === prefix) - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = (match && match[1]) || ""; - } - return "\n" + prefix + name; -} -var reentry = !1; -function describeNativeComponentFrame(fn, construct) { - if (!fn || reentry) return ""; - reentry = !0; - var previousPrepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - try { - if (construct) { - var Fake = function () { - throw Error(); - }; - Object.defineProperty(Fake.prototype, "props", { - set: function () { - throw Error(); - } - }); - if ("object" === typeof Reflect && Reflect.construct) { - try { - Reflect.construct(Fake, []); - } catch (x) { - var control = x; - } - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x$6) { - control = x$6; - } - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x$7) { - control = x$7; - } - (Fake = fn()) && - "function" === typeof Fake.catch && - Fake.catch(function () {}); - } - } catch (sample) { - if (sample && control && "string" === typeof sample.stack) - return [sample.stack, control.stack]; - } - return [null, null]; - } - }; - RunInRootFrame.DetermineComponentFrameRoot.displayName = - "DetermineComponentFrameRoot"; - var namePropDescriptor = Object.getOwnPropertyDescriptor( - RunInRootFrame.DetermineComponentFrameRoot, - "name" - ); - namePropDescriptor && - namePropDescriptor.configurable && - Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { - value: "DetermineComponentFrameRoot" - }); - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; - if (sampleStack && controlStack) { - var sampleLines = sampleStack.split("\n"), - controlLines = controlStack.split("\n"); - for ( - namePropDescriptor = RunInRootFrame = 0; - RunInRootFrame < sampleLines.length && - !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); - - ) - RunInRootFrame++; - for ( - ; - namePropDescriptor < controlLines.length && - !controlLines[namePropDescriptor].includes( - "DetermineComponentFrameRoot" - ); - - ) - namePropDescriptor++; - if ( - RunInRootFrame === sampleLines.length || - namePropDescriptor === controlLines.length - ) - for ( - RunInRootFrame = sampleLines.length - 1, - namePropDescriptor = controlLines.length - 1; - 1 <= RunInRootFrame && - 0 <= namePropDescriptor && - sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; - - ) - namePropDescriptor--; - for ( - ; - 1 <= RunInRootFrame && 0 <= namePropDescriptor; - RunInRootFrame--, namePropDescriptor-- - ) - if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { - if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { - do - if ( - (RunInRootFrame--, - namePropDescriptor--, - 0 > namePropDescriptor || - sampleLines[RunInRootFrame] !== - controlLines[namePropDescriptor]) - ) { - var frame = - "\n" + - sampleLines[RunInRootFrame].replace(" at new ", " at "); - fn.displayName && - frame.includes("") && - (frame = frame.replace("", fn.displayName)); - return frame; - } - while (1 <= RunInRootFrame && 0 <= namePropDescriptor); - } - break; - } - } - } finally { - (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); - } - return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") - ? describeBuiltInComponentFrame(previousPrepareStackTrace) - : ""; -} -function describeFiber(fiber) { - switch (fiber.tag) { - case 26: - case 27: - case 5: - return describeBuiltInComponentFrame(fiber.type); - case 16: - return describeBuiltInComponentFrame("Lazy"); - case 13: - return describeBuiltInComponentFrame("Suspense"); - case 19: - return describeBuiltInComponentFrame("SuspenseList"); - case 0: - case 15: - return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; - case 11: - return ( - (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber - ); - case 1: - return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; - default: - return ""; - } -} -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - do - (info += describeFiber(workInProgress)), - (workInProgress = workInProgress.return); - while (workInProgress); - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} -var CapturedStacks = new WeakMap(); + CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { if ("object" === typeof value && null !== value) { var stack = CapturedStacks.get(value); @@ -1040,12 +1040,12 @@ function scheduleTaskForRootDuringMicrotask(root, currentTime) { 0 < lanes; ) { - var index$2 = 31 - clz32(lanes), - lane = 1 << index$2, - expirationTime = expirationTimes[index$2]; + var index$4 = 31 - clz32(lanes), + lane = 1 << index$4, + expirationTime = expirationTimes[index$4]; if (-1 === expirationTime) { if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$2] = computeExpirationTime(lane, currentTime); + expirationTimes[index$4] = computeExpirationTime(lane, currentTime); } else expirationTime <= currentTime && (root.expiredLanes |= lane); lanes &= ~lane; } @@ -7832,9 +7832,9 @@ function markRootSuspended(root, suspendedLanes, spawnedLane) { 0 < lanes; ) { - var index$3 = 31 - clz32(lanes), - lane = 1 << index$3; - expirationTimes[index$3] = -1; + var index$5 = 31 - clz32(lanes), + lane = 1 << index$5; + expirationTimes[index$5] = -1; lanes &= ~lane; } 0 !== spawnedLane && @@ -7953,9 +7953,9 @@ function prepareFreshStack(root, lanes) { 0 < allEntangledLanes; ) { - var index$1 = 31 - clz32(allEntangledLanes), - lane = 1 << index$1; - lanes |= root[index$1]; + var index$3 = 31 - clz32(allEntangledLanes), + lane = 1 << index$3; + lanes |= root[index$3]; allEntangledLanes &= ~lane; } entangledRenderLanes = lanes; @@ -9300,7 +9300,7 @@ var devToolsConfig$jscomp$inline_1042 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "19.0.0-rc-f717fc51", + version: "19.0.0-rc-59df980e", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1229 = { @@ -9331,7 +9331,7 @@ var internals$jscomp$inline_1229 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-rc-f717fc51" + reconcilerVersion: "19.0.0-rc-59df980e" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1230 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js index 929256df44c32..78ca489cb86ac 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<55c6c62200803666b583edcc47a6b173>> + * @generated SignedSource<<9640a2643c047b950331599cf3b70c9c>> */ "use strict"; @@ -165,6 +165,188 @@ function getComponentNameFromFiber(fiber) { } return null; } +var ReactSharedInternals = + React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, + prefix; +function describeBuiltInComponentFrame(name) { + if (void 0 === prefix) + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = (match && match[1]) || ""; + } + return "\n" + prefix + name; +} +var reentry = !1; +function describeNativeComponentFrame(fn, construct) { + if (!fn || reentry) return ""; + reentry = !0; + var previousPrepareStackTrace = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + try { + if (construct) { + var Fake = function () { + throw Error(); + }; + Object.defineProperty(Fake.prototype, "props", { + set: function () { + throw Error(); + } + }); + if ("object" === typeof Reflect && Reflect.construct) { + try { + Reflect.construct(Fake, []); + } catch (x) { + var control = x; + } + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x$0) { + control = x$0; + } + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x$1) { + control = x$1; + } + (Fake = fn()) && + "function" === typeof Fake.catch && + Fake.catch(function () {}); + } + } catch (sample) { + if (sample && control && "string" === typeof sample.stack) + return [sample.stack, control.stack]; + } + return [null, null]; + } + }; + RunInRootFrame.DetermineComponentFrameRoot.displayName = + "DetermineComponentFrameRoot"; + var namePropDescriptor = Object.getOwnPropertyDescriptor( + RunInRootFrame.DetermineComponentFrameRoot, + "name" + ); + namePropDescriptor && + namePropDescriptor.configurable && + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { + value: "DetermineComponentFrameRoot" + }); + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; + if (sampleStack && controlStack) { + var sampleLines = sampleStack.split("\n"), + controlLines = controlStack.split("\n"); + for ( + namePropDescriptor = RunInRootFrame = 0; + RunInRootFrame < sampleLines.length && + !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); + + ) + RunInRootFrame++; + for ( + ; + namePropDescriptor < controlLines.length && + !controlLines[namePropDescriptor].includes( + "DetermineComponentFrameRoot" + ); + + ) + namePropDescriptor++; + if ( + RunInRootFrame === sampleLines.length || + namePropDescriptor === controlLines.length + ) + for ( + RunInRootFrame = sampleLines.length - 1, + namePropDescriptor = controlLines.length - 1; + 1 <= RunInRootFrame && + 0 <= namePropDescriptor && + sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; + + ) + namePropDescriptor--; + for ( + ; + 1 <= RunInRootFrame && 0 <= namePropDescriptor; + RunInRootFrame--, namePropDescriptor-- + ) + if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { + if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { + do + if ( + (RunInRootFrame--, + namePropDescriptor--, + 0 > namePropDescriptor || + sampleLines[RunInRootFrame] !== + controlLines[namePropDescriptor]) + ) { + var frame = + "\n" + + sampleLines[RunInRootFrame].replace(" at new ", " at "); + fn.displayName && + frame.includes("") && + (frame = frame.replace("", fn.displayName)); + return frame; + } + while (1 <= RunInRootFrame && 0 <= namePropDescriptor); + } + break; + } + } + } finally { + (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); + } + return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") + ? describeBuiltInComponentFrame(previousPrepareStackTrace) + : ""; +} +function describeFiber(fiber) { + switch (fiber.tag) { + case 26: + case 27: + case 5: + return describeBuiltInComponentFrame(fiber.type); + case 16: + return describeBuiltInComponentFrame("Lazy"); + case 13: + return describeBuiltInComponentFrame("Suspense"); + case 19: + return describeBuiltInComponentFrame("SuspenseList"); + case 0: + case 15: + return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; + case 11: + return ( + (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber + ); + case 1: + return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; + default: + return ""; + } +} +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} function getNearestMountedFiber(fiber) { var node = fiber, nearestMounted = fiber; @@ -213,36 +395,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$0 = parentA.child; child$0; ) { - if (child$0 === a) { + for (var didFindChild = !1, child$2 = parentA.child; child$2; ) { + if (child$2 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$0 === b) { + if (child$2 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$0 = child$0.sibling; + child$2 = child$2.sibling; } if (!didFindChild) { - for (child$0 = parentB.child; child$0; ) { - if (child$0 === a) { + for (child$2 = parentB.child; child$2; ) { + if (child$2 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$0 === b) { + if (child$2 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$0 = child$0.sibling; + child$2 = child$2.sibling; } if (!didFindChild) throw Error( @@ -270,8 +452,6 @@ function findCurrentHostFiberImpl(node) { return null; } var isArrayImpl = Array.isArray, - ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, scheduleCallback$3 = Scheduler$1.unstable_scheduleCallback, cancelCallback$1 = Scheduler$1.unstable_cancelCallback, shouldYield = Scheduler$1.unstable_shouldYield, @@ -317,7 +497,7 @@ function injectProfilingHooks(profilingHooks) { injectedProfilingHooks = profilingHooks; } function getLaneLabelMap() { - for (var map = new Map(), lane = 1, index$1 = 0; 31 > index$1; index$1++) { + for (var map = new Map(), lane = 1, index$3 = 0; 31 > index$3; index$3++) { var label = getLabelForLane(lane); map.set(lane, label); lane *= 2; @@ -559,18 +739,18 @@ function markRootFinished(root, remainingLanes, spawnedLane) { 0 < noLongerPendingLanes; ) { - var index$5 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$5; - remainingLanes[index$5] = 0; - expirationTimes[index$5] = -1; - var hiddenUpdatesForLane = hiddenUpdates[index$5]; + var index$7 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$7; + remainingLanes[index$7] = 0; + expirationTimes[index$7] = -1; + var hiddenUpdatesForLane = hiddenUpdates[index$7]; if (null !== hiddenUpdatesForLane) for ( - hiddenUpdates[index$5] = null, index$5 = 0; - index$5 < hiddenUpdatesForLane.length; - index$5++ + hiddenUpdates[index$7] = null, index$7 = 0; + index$7 < hiddenUpdatesForLane.length; + index$7++ ) { - var update = hiddenUpdatesForLane[index$5]; + var update = hiddenUpdatesForLane[index$7]; null !== update && (update.lane &= -536870913); } noLongerPendingLanes &= ~lane; @@ -590,10 +770,10 @@ function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) { function markRootEntangled(root, entangledLanes) { var rootEntangledLanes = (root.entangledLanes |= entangledLanes); for (root = root.entanglements; rootEntangledLanes; ) { - var index$6 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$6; - (lane & entangledLanes) | (root[index$6] & entangledLanes) && - (root[index$6] |= entangledLanes); + var index$8 = 31 - clz32(rootEntangledLanes), + lane = 1 << index$8; + (lane & entangledLanes) | (root[index$8] & entangledLanes) && + (root[index$8] |= entangledLanes); rootEntangledLanes &= ~lane; } } @@ -747,187 +927,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - prefix; -function describeBuiltInComponentFrame(name) { - if (void 0 === prefix) - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = (match && match[1]) || ""; - } - return "\n" + prefix + name; -} -var reentry = !1; -function describeNativeComponentFrame(fn, construct) { - if (!fn || reentry) return ""; - reentry = !0; - var previousPrepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - try { - if (construct) { - var Fake = function () { - throw Error(); - }; - Object.defineProperty(Fake.prototype, "props", { - set: function () { - throw Error(); - } - }); - if ("object" === typeof Reflect && Reflect.construct) { - try { - Reflect.construct(Fake, []); - } catch (x) { - var control = x; - } - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x$7) { - control = x$7; - } - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x$8) { - control = x$8; - } - (Fake = fn()) && - "function" === typeof Fake.catch && - Fake.catch(function () {}); - } - } catch (sample) { - if (sample && control && "string" === typeof sample.stack) - return [sample.stack, control.stack]; - } - return [null, null]; - } - }; - RunInRootFrame.DetermineComponentFrameRoot.displayName = - "DetermineComponentFrameRoot"; - var namePropDescriptor = Object.getOwnPropertyDescriptor( - RunInRootFrame.DetermineComponentFrameRoot, - "name" - ); - namePropDescriptor && - namePropDescriptor.configurable && - Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { - value: "DetermineComponentFrameRoot" - }); - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; - if (sampleStack && controlStack) { - var sampleLines = sampleStack.split("\n"), - controlLines = controlStack.split("\n"); - for ( - namePropDescriptor = RunInRootFrame = 0; - RunInRootFrame < sampleLines.length && - !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); - - ) - RunInRootFrame++; - for ( - ; - namePropDescriptor < controlLines.length && - !controlLines[namePropDescriptor].includes( - "DetermineComponentFrameRoot" - ); - - ) - namePropDescriptor++; - if ( - RunInRootFrame === sampleLines.length || - namePropDescriptor === controlLines.length - ) - for ( - RunInRootFrame = sampleLines.length - 1, - namePropDescriptor = controlLines.length - 1; - 1 <= RunInRootFrame && - 0 <= namePropDescriptor && - sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; - - ) - namePropDescriptor--; - for ( - ; - 1 <= RunInRootFrame && 0 <= namePropDescriptor; - RunInRootFrame--, namePropDescriptor-- - ) - if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { - if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { - do - if ( - (RunInRootFrame--, - namePropDescriptor--, - 0 > namePropDescriptor || - sampleLines[RunInRootFrame] !== - controlLines[namePropDescriptor]) - ) { - var frame = - "\n" + - sampleLines[RunInRootFrame].replace(" at new ", " at "); - fn.displayName && - frame.includes("") && - (frame = frame.replace("", fn.displayName)); - return frame; - } - while (1 <= RunInRootFrame && 0 <= namePropDescriptor); - } - break; - } - } - } finally { - (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); - } - return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") - ? describeBuiltInComponentFrame(previousPrepareStackTrace) - : ""; -} -function describeFiber(fiber) { - switch (fiber.tag) { - case 26: - case 27: - case 5: - return describeBuiltInComponentFrame(fiber.type); - case 16: - return describeBuiltInComponentFrame("Lazy"); - case 13: - return describeBuiltInComponentFrame("Suspense"); - case 19: - return describeBuiltInComponentFrame("SuspenseList"); - case 0: - case 15: - return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; - case 11: - return ( - (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber - ); - case 1: - return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; - default: - return ""; - } -} -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - do - (info += describeFiber(workInProgress)), - (workInProgress = workInProgress.return); - while (workInProgress); - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} -var CapturedStacks = new WeakMap(); + CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { if ("object" === typeof value && null !== value) { var stack = CapturedStacks.get(value); @@ -1128,12 +1128,12 @@ function scheduleTaskForRootDuringMicrotask(root, currentTime) { 0 < lanes; ) { - var index$3 = 31 - clz32(lanes), - lane = 1 << index$3, - expirationTime = expirationTimes[index$3]; + var index$5 = 31 - clz32(lanes), + lane = 1 << index$5, + expirationTime = expirationTimes[index$5]; if (-1 === expirationTime) { if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$3] = computeExpirationTime(lane, currentTime); + expirationTimes[index$5] = computeExpirationTime(lane, currentTime); } else expirationTime <= currentTime && (root.expiredLanes |= lane); lanes &= ~lane; } @@ -8326,9 +8326,9 @@ function markRootSuspended(root, suspendedLanes, spawnedLane) { 0 < lanes; ) { - var index$4 = 31 - clz32(lanes), - lane = 1 << index$4; - expirationTimes[index$4] = -1; + var index$6 = 31 - clz32(lanes), + lane = 1 << index$6; + expirationTimes[index$6] = -1; lanes &= ~lane; } 0 !== spawnedLane && @@ -8449,9 +8449,9 @@ function prepareFreshStack(root, lanes) { 0 < allEntangledLanes; ) { - var index$2 = 31 - clz32(allEntangledLanes), - lane = 1 << index$2; - lanes |= root[index$2]; + var index$4 = 31 - clz32(allEntangledLanes), + lane = 1 << index$4; + lanes |= root[index$4]; allEntangledLanes &= ~lane; } entangledRenderLanes = lanes; @@ -9943,7 +9943,7 @@ var devToolsConfig$jscomp$inline_1105 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "19.0.0-rc-4fb75363", + version: "19.0.0-rc-98cdfed4", rendererPackageName: "react-test-renderer" }; (function (internals) { @@ -9987,7 +9987,7 @@ var devToolsConfig$jscomp$inline_1105 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-rc-4fb75363" + reconcilerVersion: "19.0.0-rc-98cdfed4" }); exports._Scheduler = Scheduler; exports.act = act; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index 8bec10254f085..84bfc1ac369e3 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -3ac551e855f9bec3161da2fc8787958aa62113db +2e3e6a9b1cc97ec91248be74565e7ccbf6946067 diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index aa36230c6dccc..901ec28360970 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<6e0dbc85780a10efda46829381a887c4>> */ 'use strict'; @@ -4783,931 +4783,978 @@ function getComponentNameFromFiber(fiber) { return null; } -var currentOwner = null; -function setCurrentOwner(fiber) { - currentOwner = fiber; -} +var prefix; +function describeBuiltInComponentFrame(name) { + { + if (prefix === undefined) { + // Extract the VM specific prefix used by each line. + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = match && match[1] || ''; + } + } // We use the prefix to ensure our stacks line up with native stack frames. -function getNearestMountedFiber(fiber) { - var node = fiber; - var nearestMounted = fiber; - if (!fiber.alternate) { - // If there is no alternate, this might be a new tree that isn't inserted - // yet. If it is, then it will have a pending insertion effect on it. - var nextNode = node; + return '\n' + prefix + name; + } +} +function describeDebugInfoFrame(name, env) { + return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : '')); +} +var reentry = false; +var componentFrameCache; - do { - node = nextNode; +{ + var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap$1(); +} +/** + * Leverages native browser/VM stack frames to get proper details (e.g. + * filename, line + col number) for a single component in a component stack. We + * do this by: + * (1) throwing and catching an error in the function - this will be our + * control error. + * (2) calling the component which will eventually throw an error that we'll + * catch - this will be our sample error. + * (3) diffing the control and sample error stacks to find the stack frame + * which represents our component. + */ - if ((node.flags & (Placement | Hydrating)) !== NoFlags$1) { - // This is an insertion or in-progress hydration. The nearest possible - // mounted fiber is the parent but we need to continue to figure out - // if that one is still mounted. - nearestMounted = node.return; - } // $FlowFixMe[incompatible-type] we bail out when we get a null +function describeNativeComponentFrame(fn, construct) { + // If something asked for a stack inside a fake render, it should get ignored. + if (!fn || reentry) { + return ''; + } - nextNode = node.return; - } while (nextNode); - } else { - while (node.return) { - node = node.return; + { + var frame = componentFrameCache.get(fn); + + if (frame !== undefined) { + return frame; } } - if (node.tag === HostRoot) { - // TODO: Check if this was a nested HostRoot when used with - // renderContainerIntoSubtree. - return nearestMounted; - } // If we didn't hit the root, that means that we're in an disconnected tree - // that has been unmounted. + reentry = true; + var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. + Error.prepareStackTrace = undefined; + var previousDispatcher = null; - return null; -} -function isFiberMounted(fiber) { - return getNearestMountedFiber(fiber) === fiber; -} -function isMounted(component) { { - var owner = currentOwner; - - if (owner !== null && owner.tag === ClassComponent) { - var ownerFiber = owner; - var instance = ownerFiber.stateNode; - - if (!instance._warnedAboutRefsInRender) { - error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentNameFromFiber(ownerFiber) || 'A component'); - } + previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + // for warnings. - instance._warnedAboutRefsInRender = true; - } + ReactSharedInternals.H = null; + disableLogs(); } + /** + * Finding a common stack frame between sample and control errors can be + * tricky given the different types and levels of stack trace truncation from + * different JS VMs. So instead we'll attempt to control what that common + * frame should be through this object method: + * Having both the sample and control errors be in the function under the + * `DescribeNativeComponentFrameRoot` property, + setting the `name` and + * `displayName` properties of the function ensures that a stack + * frame exists that has the method name `DescribeNativeComponentFrameRoot` in + * it for both control and sample stacks. + */ - var fiber = get(component); - if (!fiber) { - return false; - } + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + var control; - return getNearestMountedFiber(fiber) === fiber; -} + try { + // This should throw. + if (construct) { + // Something should be setting the props in the constructor. + var Fake = function () { + throw Error(); + }; // $FlowFixMe[prop-missing] -function assertIsMounted(fiber) { - if (getNearestMountedFiber(fiber) !== fiber) { - throw new Error('Unable to find node on an unmounted component.'); - } -} -function findCurrentFiberUsingSlowPath(fiber) { - var alternate = fiber.alternate; + Object.defineProperty(Fake.prototype, 'props', { + set: function () { + // We use a throwing setter instead of frozen or non-writable props + // because that won't throw in a non-strict mode function. + throw Error(); + } + }); - if (!alternate) { - // If there is no alternate, then we only need to check if it is mounted. - var nearestMounted = getNearestMountedFiber(fiber); + if (typeof Reflect === 'object' && Reflect.construct) { + // We construct a different control for this case to include any extra + // frames added by the construct call. + try { + Reflect.construct(Fake, []); + } catch (x) { + control = x; + } - if (nearestMounted === null) { - throw new Error('Unable to find node on an unmounted component.'); - } + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x) { + control = x; + } // $FlowFixMe[prop-missing] found when upgrading Flow - if (nearestMounted !== fiber) { - return null; - } - return fiber; - } // If we have two possible branches, we'll walk backwards up to the root - // to see what path the root points to. On the way we may hit one of the - // special cases and we'll deal with them. + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x) { + control = x; + } // TODO(luna): This will currently only throw if the function component + // tries to access React/ReactDOM/props. We should probably make this throw + // in simple components too - var a = fiber; - var b = alternate; + var maybePromise = fn(); // If the function component returns a promise, it's likely an async + // component, which we don't yet support. Attach a noop catch handler to + // silence the error. + // TODO: Implement component stacks for async client components? - while (true) { - var parentA = a.return; + if (maybePromise && typeof maybePromise.catch === 'function') { + maybePromise.catch(function () {}); + } + } + } catch (sample) { + // This is inlined manually because closure doesn't do it for us. + if (sample && control && typeof sample.stack === 'string') { + return [sample.stack, control.stack]; + } + } - if (parentA === null) { - // We're at the root. - break; + return [null, null]; } + }; // $FlowFixMe[prop-missing] - var parentB = parentA.alternate; + RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; + var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable. - if (parentB === null) { - // There is no alternate. This is an unusual case. Currently, it only - // happens when a Suspense component is hidden. An extra fragment fiber - // is inserted in between the Suspense fiber and its children. Skip - // over this extra fragment fiber and proceed to the next parent. - var nextParent = parentA.return; + if (namePropDescriptor && namePropDescriptor.configurable) { + // V8 utilizes a function's `name` property when generating a stack trace. + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor + // is set to `false`. + // $FlowFixMe[cannot-write] + 'name', { + value: 'DetermineComponentFrameRoot' + }); + } - if (nextParent !== null) { - a = b = nextParent; - continue; - } // If there's no parent, we're at the root. + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; + + if (sampleStack && controlStack) { + // This extracts the first frame from the sample that isn't also in the control. + // Skipping one frame that we assume is the frame that calls the two. + var sampleLines = sampleStack.split('\n'); + var controlLines = controlStack.split('\n'); + var s = 0; + var c = 0; + while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { + s++; + } - break; - } // If both copies of the parent fiber point to the same child, we can - // assume that the child is current. This happens when we bailout on low - // priority: the bailed out fiber's child reuses the current child. + while (c < controlLines.length && !controlLines[c].includes('DetermineComponentFrameRoot')) { + c++; + } // We couldn't find our intentionally injected common root frame, attempt + // to find another common root frame by search from the bottom of the + // control stack... - if (parentA.child === parentB.child) { - var child = parentA.child; + if (s === sampleLines.length || c === controlLines.length) { + s = sampleLines.length - 1; + c = controlLines.length - 1; - while (child) { - if (child === a) { - // We've determined that A is the current branch. - assertIsMounted(parentA); - return fiber; + while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { + // We expect at least one stack frame to be shared. + // Typically this will be the root most one. However, stack frames may be + // cut off due to maximum stack limits. In this case, one maybe cut off + // earlier than the other. We assume that the sample is longer or the same + // and there for cut off earlier. So we should find the root most frame in + // the sample somewhere in the control. + c--; } + } - if (child === b) { - // We've determined that B is the current branch. - assertIsMounted(parentA); - return alternate; - } + for (; s >= 1 && c >= 0; s--, c--) { + // Next we find the first one that isn't the same which should be the + // frame that called our sample function and the control. + if (sampleLines[s] !== controlLines[c]) { + // In V8, the first line is describing the message but other VMs don't. + // If we're about to return the first line, and the control is also on the same + // line, that's a pretty good indicator that our sample threw at same line as + // the control. I.e. before we entered the sample frame. So we ignore this result. + // This can happen if you passed a class to function component, or non-function. + if (s !== 1 || c !== 1) { + do { + s--; + c--; // We may still have similar intermediate frames from the construct call. + // The next one that isn't the same should be our match though. - child = child.sibling; - } // We should never have an alternate for any mounting node. So the only - // way this could possibly happen is if this was unmounted, if at all. + if (c < 0 || sampleLines[s] !== controlLines[c]) { + // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. + var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "" + // but we have a user-provided "displayName" + // splice it in to make the stack more readable. - throw new Error('Unable to find node on an unmounted component.'); - } + if (fn.displayName && _frame.includes('')) { + _frame = _frame.replace('', fn.displayName); + } - if (a.return !== b.return) { - // The return pointer of A and the return pointer of B point to different - // fibers. We assume that return pointers never criss-cross, so A must - // belong to the child set of A.return, and B must belong to the child - // set of B.return. - a = parentA; - b = parentB; - } else { - // The return pointers point to the same fiber. We'll have to use the - // default, slow path: scan the child sets of each parent alternate to see - // which child belongs to which set. - // - // Search parent A's child set - var didFindChild = false; - var _child = parentA.child; + if (true) { + if (typeof fn === 'function') { + componentFrameCache.set(fn, _frame); + } + } // Return the line we found. - while (_child) { - if (_child === a) { - didFindChild = true; - a = parentA; - b = parentB; - break; - } - if (_child === b) { - didFindChild = true; - b = parentA; - a = parentB; + return _frame; + } + } while (s >= 1 && c >= 0); + } + break; } - - _child = _child.sibling; } + } + } finally { + reentry = false; - if (!didFindChild) { - // Search parent B's child set - _child = parentB.child; - - while (_child) { - if (_child === a) { - didFindChild = true; - a = parentB; - b = parentA; - break; - } + { + ReactSharedInternals.H = previousDispatcher; + reenableLogs(); + } - if (_child === b) { - didFindChild = true; - b = parentB; - a = parentA; - break; - } + Error.prepareStackTrace = previousPrepareStackTrace; + } // Fallback to just using the name if we couldn't make it throw. - _child = _child.sibling; - } - if (!didFindChild) { - throw new Error('Child was not found in either parent set. This indicates a bug ' + 'in React related to the return pointer. Please file an issue.'); - } - } - } + var name = fn ? fn.displayName || fn.name : ''; + var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; - if (a.alternate !== b) { - throw new Error("Return fibers should always be each others' alternates. " + 'This error is likely caused by a bug in React. Please file an issue.'); + { + if (typeof fn === 'function') { + componentFrameCache.set(fn, syntheticFrame); } - } // If the root is not a host container, we're in a disconnected tree. I.e. - // unmounted. + } + return syntheticFrame; +} - if (a.tag !== HostRoot) { - throw new Error('Unable to find node on an unmounted component.'); +function describeClassComponentFrame(ctor) { + { + return describeNativeComponentFrame(ctor, true); } +} +function describeFunctionComponentFrame(fn) { + { + return describeNativeComponentFrame(fn, false); + } +} - if (a.stateNode.current === a) { - // We've determined that A is the current branch. - return fiber; - } // Otherwise B has to be current branch. +function describeFiber(fiber) { + switch (fiber.tag) { + case HostHoistable: + case HostSingleton: + case HostComponent: + return describeBuiltInComponentFrame(fiber.type); + case LazyComponent: + return describeBuiltInComponentFrame('Lazy'); - return alternate; -} -function findCurrentHostFiber(parent) { - var currentParent = findCurrentFiberUsingSlowPath(parent); - return currentParent !== null ? findCurrentHostFiberImpl(currentParent) : null; -} + case SuspenseComponent: + return describeBuiltInComponentFrame('Suspense'); -function findCurrentHostFiberImpl(node) { - // Next we'll drill down this component to find the first HostComponent/Text. - var tag = node.tag; + case SuspenseListComponent: + return describeBuiltInComponentFrame('SuspenseList'); - if (tag === HostComponent || tag === HostHoistable || tag === HostSingleton || tag === HostText) { - return node; + case FunctionComponent: + case SimpleMemoComponent: + return describeFunctionComponentFrame(fiber.type); + + case ForwardRef: + return describeFunctionComponentFrame(fiber.type.render); + + case ClassComponent: + return describeClassComponentFrame(fiber.type); + + default: + return ''; } +} - var child = node.child; +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ''; + var node = workInProgress; - while (child !== null) { - var match = findCurrentHostFiberImpl(child); + do { + info += describeFiber(node); - if (match !== null) { - return match; - } + if (true) { + // Add any Server Component stack frames in reverse order. + var debugInfo = node._debugInfo; - child = child.sibling; - } + if (debugInfo) { + for (var i = debugInfo.length - 1; i >= 0; i--) { + var entry = debugInfo[i]; + + if (typeof entry.name === 'string') { + info += describeDebugInfoFrame(entry.name, entry.env); + } + } + } + } // $FlowFixMe[incompatible-type] we bail out when we get a null - return null; -} -function doesFiberContain(parentFiber, childFiber) { - var node = childFiber; - var parentFiberAlternate = parentFiber.alternate; - while (node !== null) { - if (node === parentFiber || node === parentFiberAlternate) { - return true; - } + node = node.return; + } while (node); - node = node.return; + return info; + } catch (x) { + return '\nError generating stack: ' + x.message + '\n' + x.stack; } - - return false; } -var valueStack = []; -var fiberStack; +var current = null; +var isRendering = false; -{ - fiberStack = []; -} +function getCurrentFiberStackInDev() { + { + if (current === null) { + return ''; + } // Safe because if current fiber exists, we are reconciling, + // and it is guaranteed to be the work-in-progress version. -var index = -1; -function createCursor(defaultValue) { - return { - current: defaultValue - }; + return getStackByFiberInDevAndProd(current); + } } -function pop(cursor, fiber) { - if (index < 0) { - { - error('Unexpected pop.'); - } - - return; +function resetCurrentDebugFiberInDEV() { + { + resetCurrentFiber(); } - +} +function setCurrentDebugFiberInDEV(fiber) { { - if (fiber !== fiberStack[index]) { - error('Unexpected Fiber popped.'); - } + setCurrentFiber(fiber); } - - cursor.current = valueStack[index]; - valueStack[index] = null; - +} +function resetCurrentFiber() { { - fiberStack[index] = null; + ReactSharedInternals.getCurrentStack = null; + isRendering = false; } - index--; + current = null; } - -function push(cursor, value, fiber) { - index++; - valueStack[index] = cursor.current; - +function setCurrentFiber(fiber) { { - fiberStack[index] = fiber; + ReactSharedInternals.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev; + isRendering = false; } - cursor.current = value; + current = fiber; +} +function getCurrentFiber() { + { + return current; + } +} +function setIsRendering(rendering) { + { + isRendering = rendering; + } } -var warnedAboutMissingGetChildContext; +function getNearestMountedFiber(fiber) { + var node = fiber; + var nearestMounted = fiber; -{ - warnedAboutMissingGetChildContext = {}; -} + if (!fiber.alternate) { + // If there is no alternate, this might be a new tree that isn't inserted + // yet. If it is, then it will have a pending insertion effect on it. + var nextNode = node; -var emptyContextObject = {}; + do { + node = nextNode; -{ - Object.freeze(emptyContextObject); -} // A cursor to the current merged context object on the stack. + if ((node.flags & (Placement | Hydrating)) !== NoFlags$1) { + // This is an insertion or in-progress hydration. The nearest possible + // mounted fiber is the parent but we need to continue to figure out + // if that one is still mounted. + nearestMounted = node.return; + } // $FlowFixMe[incompatible-type] we bail out when we get a null -var contextStackCursor$1 = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. + nextNode = node.return; + } while (nextNode); + } else { + while (node.return) { + node = node.return; + } + } -var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. -// We use this to get access to the parent context after we have already -// pushed the next context provider, and now need to merge their contexts. + if (node.tag === HostRoot) { + // TODO: Check if this was a nested HostRoot when used with + // renderContainerIntoSubtree. + return nearestMounted; + } // If we didn't hit the root, that means that we're in an disconnected tree + // that has been unmounted. -var previousContext = emptyContextObject; -function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { + return null; +} +function isFiberMounted(fiber) { + return getNearestMountedFiber(fiber) === fiber; +} +function isMounted(component) { { - if (didPushOwnContextIfProvider && isContextProvider(Component)) { - // If the fiber is a context provider itself, when we read its context - // we may have already pushed its own child context on the stack. A context - // provider should not "see" its own child context. Therefore we read the - // previous (parent) context instead for a context provider. - return previousContext; + var owner = current; + + if (owner !== null && isRendering && owner.tag === ClassComponent) { + var ownerFiber = owner; + var instance = ownerFiber.stateNode; + + if (!instance._warnedAboutRefsInRender) { + error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentNameFromFiber(ownerFiber) || 'A component'); + } + + instance._warnedAboutRefsInRender = true; } + } - return contextStackCursor$1.current; + var fiber = get(component); + + if (!fiber) { + return false; } + + return getNearestMountedFiber(fiber) === fiber; } -function cacheContext(workInProgress, unmaskedContext, maskedContext) { - { - var instance = workInProgress.stateNode; - instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; - instance.__reactInternalMemoizedMaskedChildContext = maskedContext; +function assertIsMounted(fiber) { + if (getNearestMountedFiber(fiber) !== fiber) { + throw new Error('Unable to find node on an unmounted component.'); } } -function getMaskedContext(workInProgress, unmaskedContext) { - { - var type = workInProgress.type; - var contextTypes = type.contextTypes; - - if (!contextTypes) { - return emptyContextObject; - } // Avoid recreating masked context unless unmasked context has changed. - // Failing to do this will result in unnecessary calls to componentWillReceiveProps. - // This may trigger infinite loops if componentWillReceiveProps calls setState. - +function findCurrentFiberUsingSlowPath(fiber) { + var alternate = fiber.alternate; - var instance = workInProgress.stateNode; + if (!alternate) { + // If there is no alternate, then we only need to check if it is mounted. + var nearestMounted = getNearestMountedFiber(fiber); - if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { - return instance.__reactInternalMemoizedMaskedChildContext; + if (nearestMounted === null) { + throw new Error('Unable to find node on an unmounted component.'); } - var context = {}; + if (nearestMounted !== fiber) { + return null; + } - for (var key in contextTypes) { - context[key] = unmaskedContext[key]; - } // Cache unmasked context so we can avoid recreating masked context unless necessary. - // Context is created before the class component is instantiated so check for instance. + return fiber; + } // If we have two possible branches, we'll walk backwards up to the root + // to see what path the root points to. On the way we may hit one of the + // special cases and we'll deal with them. - if (instance) { - cacheContext(workInProgress, unmaskedContext, context); - } + var a = fiber; + var b = alternate; - return context; - } -} + while (true) { + var parentA = a.return; -function hasContextChanged() { - { - return didPerformWorkStackCursor.current; - } -} + if (parentA === null) { + // We're at the root. + break; + } -function isContextProvider(type) { - { - var childContextTypes = type.childContextTypes; - return childContextTypes !== null && childContextTypes !== undefined; - } -} + var parentB = parentA.alternate; -function popContext(fiber) { - { - pop(didPerformWorkStackCursor, fiber); - pop(contextStackCursor$1, fiber); - } -} + if (parentB === null) { + // There is no alternate. This is an unusual case. Currently, it only + // happens when a Suspense component is hidden. An extra fragment fiber + // is inserted in between the Suspense fiber and its children. Skip + // over this extra fragment fiber and proceed to the next parent. + var nextParent = parentA.return; -function popTopLevelContextObject(fiber) { - { - pop(didPerformWorkStackCursor, fiber); - pop(contextStackCursor$1, fiber); - } -} + if (nextParent !== null) { + a = b = nextParent; + continue; + } // If there's no parent, we're at the root. -function pushTopLevelContextObject(fiber, context, didChange) { - { - if (contextStackCursor$1.current !== emptyContextObject) { - throw new Error('Unexpected context found on stack. ' + 'This error is likely caused by a bug in React. Please file an issue.'); - } - push(contextStackCursor$1, context, fiber); - push(didPerformWorkStackCursor, didChange, fiber); - } -} + break; + } // If both copies of the parent fiber point to the same child, we can + // assume that the child is current. This happens when we bailout on low + // priority: the bailed out fiber's child reuses the current child. -function processChildContext(fiber, type, parentContext) { - { - var instance = fiber.stateNode; - var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. - // It has only been added in Fiber to match the (unintentional) behavior in Stack. - if (typeof instance.getChildContext !== 'function') { - { - var componentName = getComponentNameFromFiber(fiber) || 'Unknown'; + if (parentA.child === parentB.child) { + var child = parentA.child; - if (!warnedAboutMissingGetChildContext[componentName]) { - warnedAboutMissingGetChildContext[componentName] = true; + while (child) { + if (child === a) { + // We've determined that A is the current branch. + assertIsMounted(parentA); + return fiber; + } - error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); + if (child === b) { + // We've determined that B is the current branch. + assertIsMounted(parentA); + return alternate; } - } - return parentContext; - } + child = child.sibling; + } // We should never have an alternate for any mounting node. So the only + // way this could possibly happen is if this was unmounted, if at all. - var childContext = instance.getChildContext(); - for (var contextKey in childContext) { - if (!(contextKey in childContextTypes)) { - throw new Error((getComponentNameFromFiber(fiber) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."); - } + throw new Error('Unable to find node on an unmounted component.'); } - return assign({}, parentContext, childContext); - } -} + if (a.return !== b.return) { + // The return pointer of A and the return pointer of B point to different + // fibers. We assume that return pointers never criss-cross, so A must + // belong to the child set of A.return, and B must belong to the child + // set of B.return. + a = parentA; + b = parentB; + } else { + // The return pointers point to the same fiber. We'll have to use the + // default, slow path: scan the child sets of each parent alternate to see + // which child belongs to which set. + // + // Search parent A's child set + var didFindChild = false; + var _child = parentA.child; -function pushContextProvider(workInProgress) { - { - var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. - // If the instance does not exist yet, we will push null at first, - // and replace it on the stack later when invalidating the context. + while (_child) { + if (_child === a) { + didFindChild = true; + a = parentA; + b = parentB; + break; + } - var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. - // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. + if (_child === b) { + didFindChild = true; + b = parentA; + a = parentB; + break; + } - previousContext = contextStackCursor$1.current; - push(contextStackCursor$1, memoizedMergedChildContext, workInProgress); - push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); - return true; - } -} + _child = _child.sibling; + } -function invalidateContextProvider(workInProgress, type, didChange) { - { - var instance = workInProgress.stateNode; + if (!didFindChild) { + // Search parent B's child set + _child = parentB.child; - if (!instance) { - throw new Error('Expected to have an instance by this point. ' + 'This error is likely caused by a bug in React. Please file an issue.'); - } + while (_child) { + if (_child === a) { + didFindChild = true; + a = parentB; + b = parentA; + break; + } - if (didChange) { - // Merge parent and own context. - // Skip this if we're not updating due to sCU. - // This avoids unnecessarily recomputing memoized values. - var mergedContext = processChildContext(workInProgress, type, previousContext); - instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. - // It is important to unwind the context in the reverse order. + if (_child === b) { + didFindChild = true; + b = parentB; + a = parentA; + break; + } - pop(didPerformWorkStackCursor, workInProgress); - pop(contextStackCursor$1, workInProgress); // Now push the new context and mark that it has changed. + _child = _child.sibling; + } - push(contextStackCursor$1, mergedContext, workInProgress); - push(didPerformWorkStackCursor, didChange, workInProgress); - } else { - pop(didPerformWorkStackCursor, workInProgress); - push(didPerformWorkStackCursor, didChange, workInProgress); + if (!didFindChild) { + throw new Error('Child was not found in either parent set. This indicates a bug ' + 'in React related to the return pointer. Please file an issue.'); + } + } } - } -} -function findCurrentUnmaskedContext(fiber) { - { - // Currently this is only used with renderSubtreeIntoContainer; not sure if it - // makes sense elsewhere - if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) { - throw new Error('Expected subtree parent to be a mounted class component. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + if (a.alternate !== b) { + throw new Error("Return fibers should always be each others' alternates. " + 'This error is likely caused by a bug in React. Please file an issue.'); } + } // If the root is not a host container, we're in a disconnected tree. I.e. + // unmounted. - var node = fiber; - - do { - switch (node.tag) { - case HostRoot: - return node.stateNode.context; - case ClassComponent: - { - var Component = node.type; + if (a.tag !== HostRoot) { + throw new Error('Unable to find node on an unmounted component.'); + } - if (isContextProvider(Component)) { - return node.stateNode.__reactInternalMemoizedMergedChildContext; - } + if (a.stateNode.current === a) { + // We've determined that A is the current branch. + return fiber; + } // Otherwise B has to be current branch. - break; - } - } // $FlowFixMe[incompatible-type] we bail out when we get a null + return alternate; +} +function findCurrentHostFiber(parent) { + var currentParent = findCurrentFiberUsingSlowPath(parent); + return currentParent !== null ? findCurrentHostFiberImpl(currentParent) : null; +} - node = node.return; - } while (node !== null); +function findCurrentHostFiberImpl(node) { + // Next we'll drill down this component to find the first HostComponent/Text. + var tag = node.tag; - throw new Error('Found unexpected detached subtree parent. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + if (tag === HostComponent || tag === HostHoistable || tag === HostSingleton || tag === HostText) { + return node; } -} -// We use the existence of the state object as an indicator that the component -// is hidden. -var OffscreenVisible = -/* */ -1; -var OffscreenDetached = -/* */ -2; -var OffscreenPassiveEffectsConnected = -/* */ -4; -function isOffscreenManual(offscreenFiber) { - return offscreenFiber.memoizedProps !== null && offscreenFiber.memoizedProps.mode === 'manual'; -} + var child = node.child; -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ -function is(x, y) { - return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare - ; -} + while (child !== null) { + var match = findCurrentHostFiberImpl(child); -var objectIs = // $FlowFixMe[method-unbinding] -typeof Object.is === 'function' ? Object.is : is; + if (match !== null) { + return match; + } -var prefix; -function describeBuiltInComponentFrame(name) { - { - if (prefix === undefined) { - // Extract the VM specific prefix used by each line. - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = match && match[1] || ''; - } - } // We use the prefix to ensure our stacks line up with native stack frames. + child = child.sibling; + } + return null; +} +function doesFiberContain(parentFiber, childFiber) { + var node = childFiber; + var parentFiberAlternate = parentFiber.alternate; - return '\n' + prefix + name; + while (node !== null) { + if (node === parentFiber || node === parentFiberAlternate) { + return true; + } + + node = node.return; } + + return false; } -function describeDebugInfoFrame(name, env) { - return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : '')); -} -var reentry = false; -var componentFrameCache; + +var valueStack = []; +var fiberStack; { - var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; - componentFrameCache = new PossiblyWeakMap$1(); + fiberStack = []; } -/** - * Leverages native browser/VM stack frames to get proper details (e.g. - * filename, line + col number) for a single component in a component stack. We - * do this by: - * (1) throwing and catching an error in the function - this will be our - * control error. - * (2) calling the component which will eventually throw an error that we'll - * catch - this will be our sample error. - * (3) diffing the control and sample error stacks to find the stack frame - * which represents our component. - */ +var index = -1; + +function createCursor(defaultValue) { + return { + current: defaultValue + }; +} -function describeNativeComponentFrame(fn, construct) { - // If something asked for a stack inside a fake render, it should get ignored. - if (!fn || reentry) { - return ''; +function pop(cursor, fiber) { + if (index < 0) { + { + error('Unexpected pop.'); + } + + return; } { - var frame = componentFrameCache.get(fn); - - if (frame !== undefined) { - return frame; + if (fiber !== fiberStack[index]) { + error('Unexpected Fiber popped.'); } } - reentry = true; - var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. - - Error.prepareStackTrace = undefined; - var previousDispatcher = null; + cursor.current = valueStack[index]; + valueStack[index] = null; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function - // for warnings. - - ReactSharedInternals.H = null; - disableLogs(); + fiberStack[index] = null; } - /** - * Finding a common stack frame between sample and control errors can be - * tricky given the different types and levels of stack trace truncation from - * different JS VMs. So instead we'll attempt to control what that common - * frame should be through this object method: - * Having both the sample and control errors be in the function under the - * `DescribeNativeComponentFrameRoot` property, + setting the `name` and - * `displayName` properties of the function ensures that a stack - * frame exists that has the method name `DescribeNativeComponentFrameRoot` in - * it for both control and sample stacks. - */ + index--; +} - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - var control; +function push(cursor, value, fiber) { + index++; + valueStack[index] = cursor.current; - try { - // This should throw. - if (construct) { - // Something should be setting the props in the constructor. - var Fake = function () { - throw Error(); - }; // $FlowFixMe[prop-missing] + { + fiberStack[index] = fiber; + } + cursor.current = value; +} - Object.defineProperty(Fake.prototype, 'props', { - set: function () { - // We use a throwing setter instead of frozen or non-writable props - // because that won't throw in a non-strict mode function. - throw Error(); - } - }); +var warnedAboutMissingGetChildContext; - if (typeof Reflect === 'object' && Reflect.construct) { - // We construct a different control for this case to include any extra - // frames added by the construct call. - try { - Reflect.construct(Fake, []); - } catch (x) { - control = x; - } +{ + warnedAboutMissingGetChildContext = {}; +} - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x) { - control = x; - } // $FlowFixMe[prop-missing] found when upgrading Flow +var emptyContextObject = {}; +{ + Object.freeze(emptyContextObject); +} // A cursor to the current merged context object on the stack. - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x) { - control = x; - } // TODO(luna): This will currently only throw if the function component - // tries to access React/ReactDOM/props. We should probably make this throw - // in simple components too +var contextStackCursor$1 = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. - var maybePromise = fn(); // If the function component returns a promise, it's likely an async - // component, which we don't yet support. Attach a noop catch handler to - // silence the error. - // TODO: Implement component stacks for async client components? +var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. +// We use this to get access to the parent context after we have already +// pushed the next context provider, and now need to merge their contexts. - if (maybePromise && typeof maybePromise.catch === 'function') { - maybePromise.catch(function () {}); - } - } - } catch (sample) { - // This is inlined manually because closure doesn't do it for us. - if (sample && control && typeof sample.stack === 'string') { - return [sample.stack, control.stack]; - } - } +var previousContext = emptyContextObject; - return [null, null]; +function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { + { + if (didPushOwnContextIfProvider && isContextProvider(Component)) { + // If the fiber is a context provider itself, when we read its context + // we may have already pushed its own child context on the stack. A context + // provider should not "see" its own child context. Therefore we read the + // previous (parent) context instead for a context provider. + return previousContext; } - }; // $FlowFixMe[prop-missing] - RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; - var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable. + return contextStackCursor$1.current; + } +} - if (namePropDescriptor && namePropDescriptor.configurable) { - // V8 utilizes a function's `name` property when generating a stack trace. - Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor - // is set to `false`. - // $FlowFixMe[cannot-write] - 'name', { - value: 'DetermineComponentFrameRoot' - }); +function cacheContext(workInProgress, unmaskedContext, maskedContext) { + { + var instance = workInProgress.stateNode; + instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; + instance.__reactInternalMemoizedMaskedChildContext = maskedContext; } +} - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; +function getMaskedContext(workInProgress, unmaskedContext) { + { + var type = workInProgress.type; + var contextTypes = type.contextTypes; - if (sampleStack && controlStack) { - // This extracts the first frame from the sample that isn't also in the control. - // Skipping one frame that we assume is the frame that calls the two. - var sampleLines = sampleStack.split('\n'); - var controlLines = controlStack.split('\n'); - var s = 0; - var c = 0; + if (!contextTypes) { + return emptyContextObject; + } // Avoid recreating masked context unless unmasked context has changed. + // Failing to do this will result in unnecessary calls to componentWillReceiveProps. + // This may trigger infinite loops if componentWillReceiveProps calls setState. - while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { - s++; - } - while (c < controlLines.length && !controlLines[c].includes('DetermineComponentFrameRoot')) { - c++; - } // We couldn't find our intentionally injected common root frame, attempt - // to find another common root frame by search from the bottom of the - // control stack... + var instance = workInProgress.stateNode; + if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { + return instance.__reactInternalMemoizedMaskedChildContext; + } - if (s === sampleLines.length || c === controlLines.length) { - s = sampleLines.length - 1; - c = controlLines.length - 1; + var context = {}; - while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { - // We expect at least one stack frame to be shared. - // Typically this will be the root most one. However, stack frames may be - // cut off due to maximum stack limits. In this case, one maybe cut off - // earlier than the other. We assume that the sample is longer or the same - // and there for cut off earlier. So we should find the root most frame in - // the sample somewhere in the control. - c--; - } - } + for (var key in contextTypes) { + context[key] = unmaskedContext[key]; + } // Cache unmasked context so we can avoid recreating masked context unless necessary. + // Context is created before the class component is instantiated so check for instance. - for (; s >= 1 && c >= 0; s--, c--) { - // Next we find the first one that isn't the same which should be the - // frame that called our sample function and the control. - if (sampleLines[s] !== controlLines[c]) { - // In V8, the first line is describing the message but other VMs don't. - // If we're about to return the first line, and the control is also on the same - // line, that's a pretty good indicator that our sample threw at same line as - // the control. I.e. before we entered the sample frame. So we ignore this result. - // This can happen if you passed a class to function component, or non-function. - if (s !== 1 || c !== 1) { - do { - s--; - c--; // We may still have similar intermediate frames from the construct call. - // The next one that isn't the same should be our match though. - if (c < 0 || sampleLines[s] !== controlLines[c]) { - // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. - var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "" - // but we have a user-provided "displayName" - // splice it in to make the stack more readable. + if (instance) { + cacheContext(workInProgress, unmaskedContext, context); + } + + return context; + } +} + +function hasContextChanged() { + { + return didPerformWorkStackCursor.current; + } +} + +function isContextProvider(type) { + { + var childContextTypes = type.childContextTypes; + return childContextTypes !== null && childContextTypes !== undefined; + } +} + +function popContext(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor$1, fiber); + } +} + +function popTopLevelContextObject(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor$1, fiber); + } +} +function pushTopLevelContextObject(fiber, context, didChange) { + { + if (contextStackCursor$1.current !== emptyContextObject) { + throw new Error('Unexpected context found on stack. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + } - if (fn.displayName && _frame.includes('')) { - _frame = _frame.replace('', fn.displayName); - } + push(contextStackCursor$1, context, fiber); + push(didPerformWorkStackCursor, didChange, fiber); + } +} - if (true) { - if (typeof fn === 'function') { - componentFrameCache.set(fn, _frame); - } - } // Return the line we found. +function processChildContext(fiber, type, parentContext) { + { + var instance = fiber.stateNode; + var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. + // It has only been added in Fiber to match the (unintentional) behavior in Stack. + if (typeof instance.getChildContext !== 'function') { + { + var componentName = getComponentNameFromFiber(fiber) || 'Unknown'; - return _frame; - } - } while (s >= 1 && c >= 0); - } + if (!warnedAboutMissingGetChildContext[componentName]) { + warnedAboutMissingGetChildContext[componentName] = true; - break; + error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); } } - } - } finally { - reentry = false; - { - ReactSharedInternals.H = previousDispatcher; - reenableLogs(); + return parentContext; } - Error.prepareStackTrace = previousPrepareStackTrace; - } // Fallback to just using the name if we couldn't make it throw. - - - var name = fn ? fn.displayName || fn.name : ''; - var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; + var childContext = instance.getChildContext(); - { - if (typeof fn === 'function') { - componentFrameCache.set(fn, syntheticFrame); + for (var contextKey in childContext) { + if (!(contextKey in childContextTypes)) { + throw new Error((getComponentNameFromFiber(fiber) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."); + } } - } - return syntheticFrame; -} - -function describeClassComponentFrame(ctor) { - { - return describeNativeComponentFrame(ctor, true); - } -} -function describeFunctionComponentFrame(fn) { - { - return describeNativeComponentFrame(fn, false); + return assign({}, parentContext, childContext); } } -function describeFiber(fiber) { - switch (fiber.tag) { - case HostHoistable: - case HostSingleton: - case HostComponent: - return describeBuiltInComponentFrame(fiber.type); +function pushContextProvider(workInProgress) { + { + var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. + // If the instance does not exist yet, we will push null at first, + // and replace it on the stack later when invalidating the context. - case LazyComponent: - return describeBuiltInComponentFrame('Lazy'); + var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. + // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. - case SuspenseComponent: - return describeBuiltInComponentFrame('Suspense'); + previousContext = contextStackCursor$1.current; + push(contextStackCursor$1, memoizedMergedChildContext, workInProgress); + push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); + return true; + } +} - case SuspenseListComponent: - return describeBuiltInComponentFrame('SuspenseList'); +function invalidateContextProvider(workInProgress, type, didChange) { + { + var instance = workInProgress.stateNode; - case FunctionComponent: - case SimpleMemoComponent: - return describeFunctionComponentFrame(fiber.type); + if (!instance) { + throw new Error('Expected to have an instance by this point. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + } - case ForwardRef: - return describeFunctionComponentFrame(fiber.type.render); + if (didChange) { + // Merge parent and own context. + // Skip this if we're not updating due to sCU. + // This avoids unnecessarily recomputing memoized values. + var mergedContext = processChildContext(workInProgress, type, previousContext); + instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. + // It is important to unwind the context in the reverse order. - case ClassComponent: - return describeClassComponentFrame(fiber.type); + pop(didPerformWorkStackCursor, workInProgress); + pop(contextStackCursor$1, workInProgress); // Now push the new context and mark that it has changed. - default: - return ''; + push(contextStackCursor$1, mergedContext, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); + } else { + pop(didPerformWorkStackCursor, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); + } } } -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ''; - var node = workInProgress; +function findCurrentUnmaskedContext(fiber) { + { + // Currently this is only used with renderSubtreeIntoContainer; not sure if it + // makes sense elsewhere + if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) { + throw new Error('Expected subtree parent to be a mounted class component. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + } - do { - info += describeFiber(node); + var node = fiber; - if (true) { - // Add any Server Component stack frames in reverse order. - var debugInfo = node._debugInfo; + do { + switch (node.tag) { + case HostRoot: + return node.stateNode.context; - if (debugInfo) { - for (var i = debugInfo.length - 1; i >= 0; i--) { - var entry = debugInfo[i]; + case ClassComponent: + { + var Component = node.type; - if (typeof entry.name === 'string') { - info += describeDebugInfoFrame(entry.name, entry.env); + if (isContextProvider(Component)) { + return node.stateNode.__reactInternalMemoizedMergedChildContext; } + + break; } - } } // $FlowFixMe[incompatible-type] we bail out when we get a null node = node.return; - } while (node); + } while (node !== null); - return info; - } catch (x) { - return '\nError generating stack: ' + x.message + '\n' + x.stack; + throw new Error('Found unexpected detached subtree parent. ' + 'This error is likely caused by a bug in React. Please file an issue.'); } } +// We use the existence of the state object as an indicator that the component +// is hidden. +var OffscreenVisible = +/* */ +1; +var OffscreenDetached = +/* */ +2; +var OffscreenPassiveEffectsConnected = +/* */ +4; +function isOffscreenManual(offscreenFiber) { + return offscreenFiber.memoizedProps !== null && offscreenFiber.memoizedProps.mode === 'manual'; +} + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare + ; +} + +var objectIs = // $FlowFixMe[method-unbinding] +typeof Object.is === 'function' ? Object.is : is; + var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { // If the value is an error, call this function immediately after it is thrown @@ -7791,46 +7838,6 @@ function shallowEqual(objA, objB) { return true; } -var current = null; -var isRendering = false; - -function getCurrentFiberStackInDev() { - { - if (current === null) { - return ''; - } // Safe because if current fiber exists, we are reconciling, - // and it is guaranteed to be the work-in-progress version. - - - return getStackByFiberInDevAndProd(current); - } -} - -function resetCurrentFiber() { - { - ReactSharedInternals.getCurrentStack = null; - current = null; - isRendering = false; - } -} -function setCurrentFiber(fiber) { - { - ReactSharedInternals.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev; - current = fiber; - isRendering = false; - } -} -function getCurrentFiber() { - { - return current; - } -} -function setIsRendering(rendering) { - { - isRendering = rendering; - } -} - var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function (fiber, instance) {}, flushPendingUnsafeLifecycleWarnings: function () {}, @@ -8050,11 +8057,11 @@ var ReactStrictModeWarnings = { var sortedNames = setToSortedString(uniqueNames); try { - setCurrentFiber(firstFiber); + setCurrentDebugFiberInDEV(firstFiber); error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); } finally { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } }); }; @@ -14965,7 +14972,6 @@ function updateForwardRef(current, workInProgress, Component, nextProps, renderL } { - setCurrentOwner(workInProgress); setIsRendering(true); nextChildren = renderWithHooks(current, workInProgress, render, propsWithoutRef, ref, renderLanes); setIsRendering(false); @@ -15435,7 +15441,6 @@ function updateFunctionComponent(current, workInProgress, Component, nextProps, } { - setCurrentOwner(workInProgress); setIsRendering(true); nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes); setIsRendering(false); @@ -15587,7 +15592,7 @@ function finishClassComponent(current, workInProgress, Component, shouldUpdate, var instance = workInProgress.stateNode; // Rerender { - setCurrentOwner(workInProgress); + setCurrentFiber(workInProgress); } var nextChildren; @@ -16893,7 +16898,6 @@ function updateContextConsumer(current, workInProgress, renderLanes) { var newChildren; { - setCurrentOwner(workInProgress); setIsRendering(true); newChildren = render(newValue); setIsRendering(false); @@ -19486,7 +19490,7 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); try { commitBeforeMutationEffectsOnFiber(fiber); @@ -19494,7 +19498,7 @@ function commitBeforeMutationEffects_complete() { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -19512,7 +19516,7 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { var flags = finishedWork.flags; if ((flags & Snapshot) !== NoFlags$1) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); } switch (finishedWork.tag) { @@ -19593,7 +19597,7 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } @@ -20547,9 +20551,9 @@ function attachSuspenseRetryListeners(finishedWork, wakeables) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); commitMutationEffectsOnFiber(finishedWork, root); - setCurrentFiber(finishedWork); + resetCurrentDebugFiberInDEV(); inProgressLanes = null; inProgressRoot = null; } @@ -20577,13 +20581,13 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitMutationEffectsOnFiber(child, root); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitMutationEffectsOnFiber(finishedWork, root, lanes) { @@ -20923,8 +20927,10 @@ function commitReconciliationEffects(finishedWork) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; + setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; commitLayoutEffectOnFiber(root, current, finishedWork); + resetCurrentDebugFiberInDEV(); inProgressLanes = null; inProgressRoot = null; } @@ -20936,14 +20942,14 @@ function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); var current = child.alternate; commitLayoutEffectOnFiber(root, current, child); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -21153,7 +21159,7 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc child = child.sibling; } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -21231,9 +21237,9 @@ function commitCachePassiveMountEffect(current, finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { @@ -21243,13 +21249,13 @@ function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLane var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -21397,7 +21403,7 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c child = child.sibling; } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -21508,13 +21514,13 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitAtomicPassiveEffects(finishedRoot, child); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -21559,9 +21565,9 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, } function commitPassiveUnmountEffects(finishedWork) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); commitPassiveUnmountOnFiber(finishedWork); - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -21715,13 +21721,13 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitPassiveUnmountOnFiber(child); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -21792,12 +21798,12 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); disconnectPassiveEffect(child); child = child.sibling; } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -21839,9 +21845,9 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -22063,7 +22069,7 @@ var DefaultAsyncDispatcher = { { DefaultAsyncDispatcher.getOwner = function () { - return currentOwner; + return current; }; } @@ -23013,10 +23019,9 @@ function handleThrow(root, thrownValue) { // These should be reset immediately because they're only supposed to be set // when React is executing user code. resetHooksAfterThrow(); - resetCurrentFiber(); { - setCurrentOwner(null); + resetCurrentFiber(); } if (thrownValue === SuspenseException) { @@ -23647,7 +23652,7 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentFiber(unitOfWork); + setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { @@ -23658,7 +23663,10 @@ function performUnitOfWork(unitOfWork) { next = beginWork(current, unitOfWork, entangledRenderLanes); } - resetCurrentFiber(); + { + resetCurrentFiber(); + } + unitOfWork.memoizedProps = unitOfWork.pendingProps; if (next === null) { @@ -23667,10 +23675,6 @@ function performUnitOfWork(unitOfWork) { } else { workInProgress = next; } - - { - setCurrentOwner(null); - } } function replaySuspendedUnitOfWork(unitOfWork) { @@ -23678,9 +23682,8 @@ function replaySuspendedUnitOfWork(unitOfWork) { // just suspended. // var current = unitOfWork.alternate; - setCurrentFiber(unitOfWork); + setCurrentDebugFiberInDEV(unitOfWork); var next; - setCurrentFiber(unitOfWork); var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; if (isProfilingMode) { @@ -23758,7 +23761,10 @@ function replaySuspendedUnitOfWork(unitOfWork) { // normal work loop. - resetCurrentFiber(); + { + resetCurrentFiber(); + } + unitOfWork.memoizedProps = unitOfWork.pendingProps; if (next === null) { @@ -23767,10 +23773,6 @@ function replaySuspendedUnitOfWork(unitOfWork) { } else { workInProgress = next; } - - { - setCurrentOwner(null); - } } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -23857,7 +23859,7 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentFiber(completedWork); + setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { @@ -23869,7 +23871,7 @@ function completeUnitOfWork(unitOfWork) { stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); if (next !== null) { // Completing this fiber spawned new work. Work on that next. @@ -24096,18 +24098,13 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh var previousPriority = getCurrentUpdatePriority(); setCurrentUpdatePriority(DiscreteEventPriority); var prevExecutionContext = executionContext; - executionContext |= CommitContext; // Reset this to null before calling lifecycles - - { - setCurrentOwner(null); - } // The commit phase is broken into several sub-phases. We do a separate pass + executionContext |= CommitContext; // The commit phase is broken into several sub-phases. We do a separate pass // of the effect list for each phase: all mutation effects come before all // layout effects, and so on. // The first phase a "before mutation" phase. We use this phase to read the // state of the host tree right before we mutate it. This is where // getSnapshotBeforeUpdate is called. - commitBeforeMutationEffects(root, finishedWork); { @@ -24733,13 +24730,13 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); if (isInStrictMode) { doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -24752,7 +24749,7 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only @@ -24764,7 +24761,7 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } @@ -24788,7 +24785,7 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { // TODO (StrictEffects) Should we set a marker on the root if it contains strict effects // so we don't traverse unnecessarily? similar to subtreeFlags but just at the root level. // Maybe not a big deal since this is DEV only behavior. - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV); if (hasPassiveEffects) { @@ -24801,7 +24798,7 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { @@ -24864,14 +24861,14 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { var previousFiber = current; try { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); } finally { if (previousFiber) { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); } else { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } } @@ -24985,14 +24982,14 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { var previousFiber = current; try { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); } finally { if (previousFiber) { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); } else { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } } @@ -26045,7 +26042,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-rc-bb385be5'; +var ReactVersion = '19.0.0-rc-477cc72f'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol @@ -26189,7 +26186,7 @@ function findHostInstanceWithWarning(component, methodName) { var previousFiber = current; try { - setCurrentFiber(hostFiber); + setCurrentDebugFiberInDEV(hostFiber); if (fiber.mode & StrictLegacyMode) { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); @@ -26200,9 +26197,9 @@ function findHostInstanceWithWarning(component, methodName) { // Ideally this should reset to previous but this shouldn't be called in // render and there's another warning for that anyway. if (previousFiber) { - setCurrentFiber(previousFiber); + setCurrentDebugFiberInDEV(previousFiber); } else { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } } @@ -26601,9 +26598,9 @@ function getInstanceFromTag(tag) { function findHostInstance_DEPRECATED(componentOrHandle) { { - var owner = currentOwner; + var owner = current; - if (owner !== null && owner.stateNode !== null) { + if (owner !== null && isRendering && owner.stateNode !== null) { if (!owner.stateNode._warnedAboutRefsInRender) { error('%s is accessing findNodeHandle inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentNameFromType(owner.type) || 'A component'); } @@ -26642,7 +26639,7 @@ function findHostInstance_DEPRECATED(componentOrHandle) { } function findNodeHandle(componentOrHandle) { { - var owner = currentOwner; + var owner = current; if (owner !== null && owner.stateNode !== null) { if (!owner.stateNode._warnedAboutRefsInRender) { diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 57b8e3886704c..2e631936967ba 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<65b72c4e42cec9cba37885e439426393>> + * @generated SignedSource<<1d2b130328f4bb108e9de82ba65c62c7>> */ "use strict"; @@ -1813,6 +1813,186 @@ function getComponentNameFromFiber(fiber) { } return null; } +var prefix; +function describeBuiltInComponentFrame(name) { + if (void 0 === prefix) + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = (match && match[1]) || ""; + } + return "\n" + prefix + name; +} +var reentry = !1; +function describeNativeComponentFrame(fn, construct) { + if (!fn || reentry) return ""; + reentry = !0; + var previousPrepareStackTrace = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + try { + if (construct) { + var Fake = function () { + throw Error(); + }; + Object.defineProperty(Fake.prototype, "props", { + set: function () { + throw Error(); + } + }); + if ("object" === typeof Reflect && Reflect.construct) { + try { + Reflect.construct(Fake, []); + } catch (x) { + var control = x; + } + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x$7) { + control = x$7; + } + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x$8) { + control = x$8; + } + (Fake = fn()) && + "function" === typeof Fake.catch && + Fake.catch(function () {}); + } + } catch (sample) { + if (sample && control && "string" === typeof sample.stack) + return [sample.stack, control.stack]; + } + return [null, null]; + } + }; + RunInRootFrame.DetermineComponentFrameRoot.displayName = + "DetermineComponentFrameRoot"; + var namePropDescriptor = Object.getOwnPropertyDescriptor( + RunInRootFrame.DetermineComponentFrameRoot, + "name" + ); + namePropDescriptor && + namePropDescriptor.configurable && + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { + value: "DetermineComponentFrameRoot" + }); + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; + if (sampleStack && controlStack) { + var sampleLines = sampleStack.split("\n"), + controlLines = controlStack.split("\n"); + for ( + namePropDescriptor = RunInRootFrame = 0; + RunInRootFrame < sampleLines.length && + !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); + + ) + RunInRootFrame++; + for ( + ; + namePropDescriptor < controlLines.length && + !controlLines[namePropDescriptor].includes( + "DetermineComponentFrameRoot" + ); + + ) + namePropDescriptor++; + if ( + RunInRootFrame === sampleLines.length || + namePropDescriptor === controlLines.length + ) + for ( + RunInRootFrame = sampleLines.length - 1, + namePropDescriptor = controlLines.length - 1; + 1 <= RunInRootFrame && + 0 <= namePropDescriptor && + sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; + + ) + namePropDescriptor--; + for ( + ; + 1 <= RunInRootFrame && 0 <= namePropDescriptor; + RunInRootFrame--, namePropDescriptor-- + ) + if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { + if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { + do + if ( + (RunInRootFrame--, + namePropDescriptor--, + 0 > namePropDescriptor || + sampleLines[RunInRootFrame] !== + controlLines[namePropDescriptor]) + ) { + var frame = + "\n" + + sampleLines[RunInRootFrame].replace(" at new ", " at "); + fn.displayName && + frame.includes("") && + (frame = frame.replace("", fn.displayName)); + return frame; + } + while (1 <= RunInRootFrame && 0 <= namePropDescriptor); + } + break; + } + } + } finally { + (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); + } + return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") + ? describeBuiltInComponentFrame(previousPrepareStackTrace) + : ""; +} +function describeFiber(fiber) { + switch (fiber.tag) { + case 26: + case 27: + case 5: + return describeBuiltInComponentFrame(fiber.type); + case 16: + return describeBuiltInComponentFrame("Lazy"); + case 13: + return describeBuiltInComponentFrame("Suspense"); + case 19: + return describeBuiltInComponentFrame("SuspenseList"); + case 0: + case 15: + return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; + case 11: + return ( + (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber + ); + case 1: + return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; + default: + return ""; + } +} +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} function getNearestMountedFiber(fiber) { var node = fiber, nearestMounted = fiber; @@ -1861,36 +2041,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$7 = parentA.child; child$7; ) { - if (child$7 === a) { + for (var didFindChild = !1, child$9 = parentA.child; child$9; ) { + if (child$9 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$7 === b) { + if (child$9 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$7 = child$7.sibling; + child$9 = child$9.sibling; } if (!didFindChild) { - for (child$7 = parentB.child; child$7; ) { - if (child$7 === a) { + for (child$9 = parentB.child; child$9; ) { + if (child$9 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$7 === b) { + if (child$9 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$7 = child$7.sibling; + child$9 = child$9.sibling; } if (!didFindChild) throw Error( @@ -2022,187 +2202,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - prefix; -function describeBuiltInComponentFrame(name) { - if (void 0 === prefix) - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = (match && match[1]) || ""; - } - return "\n" + prefix + name; -} -var reentry = !1; -function describeNativeComponentFrame(fn, construct) { - if (!fn || reentry) return ""; - reentry = !0; - var previousPrepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - try { - if (construct) { - var Fake = function () { - throw Error(); - }; - Object.defineProperty(Fake.prototype, "props", { - set: function () { - throw Error(); - } - }); - if ("object" === typeof Reflect && Reflect.construct) { - try { - Reflect.construct(Fake, []); - } catch (x) { - var control = x; - } - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x$8) { - control = x$8; - } - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x$9) { - control = x$9; - } - (Fake = fn()) && - "function" === typeof Fake.catch && - Fake.catch(function () {}); - } - } catch (sample) { - if (sample && control && "string" === typeof sample.stack) - return [sample.stack, control.stack]; - } - return [null, null]; - } - }; - RunInRootFrame.DetermineComponentFrameRoot.displayName = - "DetermineComponentFrameRoot"; - var namePropDescriptor = Object.getOwnPropertyDescriptor( - RunInRootFrame.DetermineComponentFrameRoot, - "name" - ); - namePropDescriptor && - namePropDescriptor.configurable && - Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { - value: "DetermineComponentFrameRoot" - }); - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; - if (sampleStack && controlStack) { - var sampleLines = sampleStack.split("\n"), - controlLines = controlStack.split("\n"); - for ( - namePropDescriptor = RunInRootFrame = 0; - RunInRootFrame < sampleLines.length && - !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); - - ) - RunInRootFrame++; - for ( - ; - namePropDescriptor < controlLines.length && - !controlLines[namePropDescriptor].includes( - "DetermineComponentFrameRoot" - ); - - ) - namePropDescriptor++; - if ( - RunInRootFrame === sampleLines.length || - namePropDescriptor === controlLines.length - ) - for ( - RunInRootFrame = sampleLines.length - 1, - namePropDescriptor = controlLines.length - 1; - 1 <= RunInRootFrame && - 0 <= namePropDescriptor && - sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; - - ) - namePropDescriptor--; - for ( - ; - 1 <= RunInRootFrame && 0 <= namePropDescriptor; - RunInRootFrame--, namePropDescriptor-- - ) - if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { - if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { - do - if ( - (RunInRootFrame--, - namePropDescriptor--, - 0 > namePropDescriptor || - sampleLines[RunInRootFrame] !== - controlLines[namePropDescriptor]) - ) { - var frame = - "\n" + - sampleLines[RunInRootFrame].replace(" at new ", " at "); - fn.displayName && - frame.includes("") && - (frame = frame.replace("", fn.displayName)); - return frame; - } - while (1 <= RunInRootFrame && 0 <= namePropDescriptor); - } - break; - } - } - } finally { - (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); - } - return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") - ? describeBuiltInComponentFrame(previousPrepareStackTrace) - : ""; -} -function describeFiber(fiber) { - switch (fiber.tag) { - case 26: - case 27: - case 5: - return describeBuiltInComponentFrame(fiber.type); - case 16: - return describeBuiltInComponentFrame("Lazy"); - case 13: - return describeBuiltInComponentFrame("Suspense"); - case 19: - return describeBuiltInComponentFrame("SuspenseList"); - case 0: - case 15: - return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; - case 11: - return ( - (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber - ); - case 1: - return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; - default: - return ""; - } -} -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - do - (info += describeFiber(workInProgress)), - (workInProgress = workInProgress.return); - while (workInProgress); - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} -var CapturedStacks = new WeakMap(); + CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { if ("object" === typeof value && null !== value) { var stack = CapturedStacks.get(value); @@ -10558,7 +10558,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1119 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "19.0.0-rc-8d89f616", + version: "19.0.0-rc-727abc63", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10601,7 +10601,7 @@ var internals$jscomp$inline_1349 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-rc-8d89f616" + reconcilerVersion: "19.0.0-rc-727abc63" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1350 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index a59704f7a7040..f7a48b05482ac 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<86492ff1a75d58ad80afad8ec9246a92>> */ "use strict"; @@ -1935,6 +1935,186 @@ function getComponentNameFromFiber(fiber) { } return null; } +var prefix; +function describeBuiltInComponentFrame(name) { + if (void 0 === prefix) + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = (match && match[1]) || ""; + } + return "\n" + prefix + name; +} +var reentry = !1; +function describeNativeComponentFrame(fn, construct) { + if (!fn || reentry) return ""; + reentry = !0; + var previousPrepareStackTrace = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + try { + if (construct) { + var Fake = function () { + throw Error(); + }; + Object.defineProperty(Fake.prototype, "props", { + set: function () { + throw Error(); + } + }); + if ("object" === typeof Reflect && Reflect.construct) { + try { + Reflect.construct(Fake, []); + } catch (x) { + var control = x; + } + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x$10) { + control = x$10; + } + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x$11) { + control = x$11; + } + (Fake = fn()) && + "function" === typeof Fake.catch && + Fake.catch(function () {}); + } + } catch (sample) { + if (sample && control && "string" === typeof sample.stack) + return [sample.stack, control.stack]; + } + return [null, null]; + } + }; + RunInRootFrame.DetermineComponentFrameRoot.displayName = + "DetermineComponentFrameRoot"; + var namePropDescriptor = Object.getOwnPropertyDescriptor( + RunInRootFrame.DetermineComponentFrameRoot, + "name" + ); + namePropDescriptor && + namePropDescriptor.configurable && + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { + value: "DetermineComponentFrameRoot" + }); + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; + if (sampleStack && controlStack) { + var sampleLines = sampleStack.split("\n"), + controlLines = controlStack.split("\n"); + for ( + namePropDescriptor = RunInRootFrame = 0; + RunInRootFrame < sampleLines.length && + !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); + + ) + RunInRootFrame++; + for ( + ; + namePropDescriptor < controlLines.length && + !controlLines[namePropDescriptor].includes( + "DetermineComponentFrameRoot" + ); + + ) + namePropDescriptor++; + if ( + RunInRootFrame === sampleLines.length || + namePropDescriptor === controlLines.length + ) + for ( + RunInRootFrame = sampleLines.length - 1, + namePropDescriptor = controlLines.length - 1; + 1 <= RunInRootFrame && + 0 <= namePropDescriptor && + sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; + + ) + namePropDescriptor--; + for ( + ; + 1 <= RunInRootFrame && 0 <= namePropDescriptor; + RunInRootFrame--, namePropDescriptor-- + ) + if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { + if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { + do + if ( + (RunInRootFrame--, + namePropDescriptor--, + 0 > namePropDescriptor || + sampleLines[RunInRootFrame] !== + controlLines[namePropDescriptor]) + ) { + var frame = + "\n" + + sampleLines[RunInRootFrame].replace(" at new ", " at "); + fn.displayName && + frame.includes("") && + (frame = frame.replace("", fn.displayName)); + return frame; + } + while (1 <= RunInRootFrame && 0 <= namePropDescriptor); + } + break; + } + } + } finally { + (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); + } + return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") + ? describeBuiltInComponentFrame(previousPrepareStackTrace) + : ""; +} +function describeFiber(fiber) { + switch (fiber.tag) { + case 26: + case 27: + case 5: + return describeBuiltInComponentFrame(fiber.type); + case 16: + return describeBuiltInComponentFrame("Lazy"); + case 13: + return describeBuiltInComponentFrame("Suspense"); + case 19: + return describeBuiltInComponentFrame("SuspenseList"); + case 0: + case 15: + return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; + case 11: + return ( + (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber + ); + case 1: + return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; + default: + return ""; + } +} +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} function getNearestMountedFiber(fiber) { var node = fiber, nearestMounted = fiber; @@ -1983,36 +2163,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$10 = parentA.child; child$10; ) { - if (child$10 === a) { + for (var didFindChild = !1, child$12 = parentA.child; child$12; ) { + if (child$12 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$10 === b) { + if (child$12 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$10 = child$10.sibling; + child$12 = child$12.sibling; } if (!didFindChild) { - for (child$10 = parentB.child; child$10; ) { - if (child$10 === a) { + for (child$12 = parentB.child; child$12; ) { + if (child$12 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$10 === b) { + if (child$12 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$10 = child$10.sibling; + child$12 = child$12.sibling; } if (!didFindChild) throw Error( @@ -2144,187 +2324,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - prefix; -function describeBuiltInComponentFrame(name) { - if (void 0 === prefix) - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = (match && match[1]) || ""; - } - return "\n" + prefix + name; -} -var reentry = !1; -function describeNativeComponentFrame(fn, construct) { - if (!fn || reentry) return ""; - reentry = !0; - var previousPrepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - try { - if (construct) { - var Fake = function () { - throw Error(); - }; - Object.defineProperty(Fake.prototype, "props", { - set: function () { - throw Error(); - } - }); - if ("object" === typeof Reflect && Reflect.construct) { - try { - Reflect.construct(Fake, []); - } catch (x) { - var control = x; - } - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x$11) { - control = x$11; - } - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x$12) { - control = x$12; - } - (Fake = fn()) && - "function" === typeof Fake.catch && - Fake.catch(function () {}); - } - } catch (sample) { - if (sample && control && "string" === typeof sample.stack) - return [sample.stack, control.stack]; - } - return [null, null]; - } - }; - RunInRootFrame.DetermineComponentFrameRoot.displayName = - "DetermineComponentFrameRoot"; - var namePropDescriptor = Object.getOwnPropertyDescriptor( - RunInRootFrame.DetermineComponentFrameRoot, - "name" - ); - namePropDescriptor && - namePropDescriptor.configurable && - Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { - value: "DetermineComponentFrameRoot" - }); - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; - if (sampleStack && controlStack) { - var sampleLines = sampleStack.split("\n"), - controlLines = controlStack.split("\n"); - for ( - namePropDescriptor = RunInRootFrame = 0; - RunInRootFrame < sampleLines.length && - !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); - - ) - RunInRootFrame++; - for ( - ; - namePropDescriptor < controlLines.length && - !controlLines[namePropDescriptor].includes( - "DetermineComponentFrameRoot" - ); - - ) - namePropDescriptor++; - if ( - RunInRootFrame === sampleLines.length || - namePropDescriptor === controlLines.length - ) - for ( - RunInRootFrame = sampleLines.length - 1, - namePropDescriptor = controlLines.length - 1; - 1 <= RunInRootFrame && - 0 <= namePropDescriptor && - sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; - - ) - namePropDescriptor--; - for ( - ; - 1 <= RunInRootFrame && 0 <= namePropDescriptor; - RunInRootFrame--, namePropDescriptor-- - ) - if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { - if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { - do - if ( - (RunInRootFrame--, - namePropDescriptor--, - 0 > namePropDescriptor || - sampleLines[RunInRootFrame] !== - controlLines[namePropDescriptor]) - ) { - var frame = - "\n" + - sampleLines[RunInRootFrame].replace(" at new ", " at "); - fn.displayName && - frame.includes("") && - (frame = frame.replace("", fn.displayName)); - return frame; - } - while (1 <= RunInRootFrame && 0 <= namePropDescriptor); - } - break; - } - } - } finally { - (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); - } - return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") - ? describeBuiltInComponentFrame(previousPrepareStackTrace) - : ""; -} -function describeFiber(fiber) { - switch (fiber.tag) { - case 26: - case 27: - case 5: - return describeBuiltInComponentFrame(fiber.type); - case 16: - return describeBuiltInComponentFrame("Lazy"); - case 13: - return describeBuiltInComponentFrame("Suspense"); - case 19: - return describeBuiltInComponentFrame("SuspenseList"); - case 0: - case 15: - return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; - case 11: - return ( - (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber - ); - case 1: - return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; - default: - return ""; - } -} -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - do - (info += describeFiber(workInProgress)), - (workInProgress = workInProgress.return); - while (workInProgress); - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} -var CapturedStacks = new WeakMap(); + CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { if ("object" === typeof value && null !== value) { var stack = CapturedStacks.get(value); @@ -11263,7 +11263,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1199 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "19.0.0-rc-3594d067", + version: "19.0.0-rc-0c0ae0e7", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -11319,7 +11319,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-rc-3594d067" + reconcilerVersion: "19.0.0-rc-0c0ae0e7" }); exports.createPortal = function (children, containerTag) { return createPortal$1( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index d890733e054f7..7ceb9f0fd2e69 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<55f31038f2be45dd38383c50d946e009>> + * @generated SignedSource<<012d5029444c4f0231a53d1bf5c6d80c>> */ 'use strict'; @@ -2748,1202 +2748,1593 @@ var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; -var currentOwner = null; -function setCurrentOwner(fiber) { - currentOwner = fiber; -} - -function getNearestMountedFiber(fiber) { - var node = fiber; - var nearestMounted = fiber; - - if (!fiber.alternate) { - // If there is no alternate, this might be a new tree that isn't inserted - // yet. If it is, then it will have a pending insertion effect on it. - var nextNode = node; +// Helpers to patch console.logs to avoid logging during side-effect free +// replaying on render function. This currently only patches the object +// lazily which won't cover if the log function was extracted eagerly. +// We could also eagerly patch the method. +var disabledDepth = 0; +var prevLog; +var prevInfo; +var prevWarn; +var prevError; +var prevGroup; +var prevGroupCollapsed; +var prevGroupEnd; - do { - node = nextNode; +function disabledLog() {} - if ((node.flags & (Placement | Hydrating)) !== NoFlags$1) { - // This is an insertion or in-progress hydration. The nearest possible - // mounted fiber is the parent but we need to continue to figure out - // if that one is still mounted. - nearestMounted = node.return; - } // $FlowFixMe[incompatible-type] we bail out when we get a null +disabledLog.__reactDisabledLog = true; +function disableLogs() { + { + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + prevLog = console.log; + prevInfo = console.info; + prevWarn = console.warn; + prevError = console.error; + prevGroup = console.group; + prevGroupCollapsed = console.groupCollapsed; + prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 + var props = { + configurable: true, + enumerable: true, + value: disabledLog, + writable: true + }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. - nextNode = node.return; - } while (nextNode); - } else { - while (node.return) { - node = node.return; + Object.defineProperties(console, { + info: props, + log: props, + warn: props, + error: props, + group: props, + groupCollapsed: props, + groupEnd: props + }); + /* eslint-enable react-internal/no-production-logging */ } - } - - if (node.tag === HostRoot) { - // TODO: Check if this was a nested HostRoot when used with - // renderContainerIntoSubtree. - return nearestMounted; - } // If we didn't hit the root, that means that we're in an disconnected tree - // that has been unmounted. - - return null; -} -function isFiberMounted(fiber) { - return getNearestMountedFiber(fiber) === fiber; + disabledDepth++; + } } -function isMounted(component) { +function reenableLogs() { { - var owner = currentOwner; + disabledDepth--; - if (owner !== null && owner.tag === ClassComponent) { - var ownerFiber = owner; - var instance = ownerFiber.stateNode; + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + var props = { + configurable: true, + enumerable: true, + writable: true + }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. - if (!instance._warnedAboutRefsInRender) { - error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentNameFromFiber(ownerFiber) || 'A component'); - } + Object.defineProperties(console, { + log: assign({}, props, { + value: prevLog + }), + info: assign({}, props, { + value: prevInfo + }), + warn: assign({}, props, { + value: prevWarn + }), + error: assign({}, props, { + value: prevError + }), + group: assign({}, props, { + value: prevGroup + }), + groupCollapsed: assign({}, props, { + value: prevGroupCollapsed + }), + groupEnd: assign({}, props, { + value: prevGroupEnd + }) + }); + /* eslint-enable react-internal/no-production-logging */ + } - instance._warnedAboutRefsInRender = true; + if (disabledDepth < 0) { + error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); } } +} - var fiber = get(component); +var prefix; +function describeBuiltInComponentFrame(name) { + { + if (prefix === undefined) { + // Extract the VM specific prefix used by each line. + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = match && match[1] || ''; + } + } // We use the prefix to ensure our stacks line up with native stack frames. - if (!fiber) { - return false; - } - return getNearestMountedFiber(fiber) === fiber; + return '\n' + prefix + name; + } +} +function describeDebugInfoFrame(name, env) { + return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : '')); } +var reentry = false; +var componentFrameCache; -function assertIsMounted(fiber) { - if (getNearestMountedFiber(fiber) !== fiber) { - throw new Error('Unable to find node on an unmounted component.'); - } +{ + var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap$1(); } +/** + * Leverages native browser/VM stack frames to get proper details (e.g. + * filename, line + col number) for a single component in a component stack. We + * do this by: + * (1) throwing and catching an error in the function - this will be our + * control error. + * (2) calling the component which will eventually throw an error that we'll + * catch - this will be our sample error. + * (3) diffing the control and sample error stacks to find the stack frame + * which represents our component. + */ -function findCurrentFiberUsingSlowPath(fiber) { - var alternate = fiber.alternate; - if (!alternate) { - // If there is no alternate, then we only need to check if it is mounted. - var nearestMounted = getNearestMountedFiber(fiber); +function describeNativeComponentFrame(fn, construct) { + // If something asked for a stack inside a fake render, it should get ignored. + if (!fn || reentry) { + return ''; + } - if (nearestMounted === null) { - throw new Error('Unable to find node on an unmounted component.'); - } + { + var frame = componentFrameCache.get(fn); - if (nearestMounted !== fiber) { - return null; + if (frame !== undefined) { + return frame; } + } - return fiber; - } // If we have two possible branches, we'll walk backwards up to the root - // to see what path the root points to. On the way we may hit one of the - // special cases and we'll deal with them. - - - var a = fiber; - var b = alternate; - - while (true) { - var parentA = a.return; + reentry = true; + var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. - if (parentA === null) { - // We're at the root. - break; - } + Error.prepareStackTrace = undefined; + var previousDispatcher = null; - var parentB = parentA.alternate; + { + previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + // for warnings. - if (parentB === null) { - // There is no alternate. This is an unusual case. Currently, it only - // happens when a Suspense component is hidden. An extra fragment fiber - // is inserted in between the Suspense fiber and its children. Skip - // over this extra fragment fiber and proceed to the next parent. - var nextParent = parentA.return; + ReactSharedInternals.H = null; + disableLogs(); + } + /** + * Finding a common stack frame between sample and control errors can be + * tricky given the different types and levels of stack trace truncation from + * different JS VMs. So instead we'll attempt to control what that common + * frame should be through this object method: + * Having both the sample and control errors be in the function under the + * `DescribeNativeComponentFrameRoot` property, + setting the `name` and + * `displayName` properties of the function ensures that a stack + * frame exists that has the method name `DescribeNativeComponentFrameRoot` in + * it for both control and sample stacks. + */ - if (nextParent !== null) { - a = b = nextParent; - continue; - } // If there's no parent, we're at the root. + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + var control; - break; - } // If both copies of the parent fiber point to the same child, we can - // assume that the child is current. This happens when we bailout on low - // priority: the bailed out fiber's child reuses the current child. + try { + // This should throw. + if (construct) { + // Something should be setting the props in the constructor. + var Fake = function () { + throw Error(); + }; // $FlowFixMe[prop-missing] - if (parentA.child === parentB.child) { - var child = parentA.child; + Object.defineProperty(Fake.prototype, 'props', { + set: function () { + // We use a throwing setter instead of frozen or non-writable props + // because that won't throw in a non-strict mode function. + throw Error(); + } + }); - while (child) { - if (child === a) { - // We've determined that A is the current branch. - assertIsMounted(parentA); - return fiber; - } + if (typeof Reflect === 'object' && Reflect.construct) { + // We construct a different control for this case to include any extra + // frames added by the construct call. + try { + Reflect.construct(Fake, []); + } catch (x) { + control = x; + } - if (child === b) { - // We've determined that B is the current branch. - assertIsMounted(parentA); - return alternate; - } + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x) { + control = x; + } // $FlowFixMe[prop-missing] found when upgrading Flow - child = child.sibling; - } // We should never have an alternate for any mounting node. So the only - // way this could possibly happen is if this was unmounted, if at all. + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x) { + control = x; + } // TODO(luna): This will currently only throw if the function component + // tries to access React/ReactDOM/props. We should probably make this throw + // in simple components too - throw new Error('Unable to find node on an unmounted component.'); - } - if (a.return !== b.return) { - // The return pointer of A and the return pointer of B point to different - // fibers. We assume that return pointers never criss-cross, so A must - // belong to the child set of A.return, and B must belong to the child - // set of B.return. - a = parentA; - b = parentB; - } else { - // The return pointers point to the same fiber. We'll have to use the - // default, slow path: scan the child sets of each parent alternate to see - // which child belongs to which set. - // - // Search parent A's child set - var didFindChild = false; - var _child = parentA.child; + var maybePromise = fn(); // If the function component returns a promise, it's likely an async + // component, which we don't yet support. Attach a noop catch handler to + // silence the error. + // TODO: Implement component stacks for async client components? - while (_child) { - if (_child === a) { - didFindChild = true; - a = parentA; - b = parentB; - break; + if (maybePromise && typeof maybePromise.catch === 'function') { + maybePromise.catch(function () {}); + } } - - if (_child === b) { - didFindChild = true; - b = parentA; - a = parentB; - break; + } catch (sample) { + // This is inlined manually because closure doesn't do it for us. + if (sample && control && typeof sample.stack === 'string') { + return [sample.stack, control.stack]; } - - _child = _child.sibling; } - if (!didFindChild) { - // Search parent B's child set - _child = parentB.child; + return [null, null]; + } + }; // $FlowFixMe[prop-missing] - while (_child) { - if (_child === a) { - didFindChild = true; - a = parentB; - b = parentA; - break; - } + RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; + var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable. - if (_child === b) { - didFindChild = true; - b = parentB; - a = parentA; - break; - } + if (namePropDescriptor && namePropDescriptor.configurable) { + // V8 utilizes a function's `name` property when generating a stack trace. + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor + // is set to `false`. + // $FlowFixMe[cannot-write] + 'name', { + value: 'DetermineComponentFrameRoot' + }); + } - _child = _child.sibling; - } + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; - if (!didFindChild) { - throw new Error('Child was not found in either parent set. This indicates a bug ' + 'in React related to the return pointer. Please file an issue.'); - } + if (sampleStack && controlStack) { + // This extracts the first frame from the sample that isn't also in the control. + // Skipping one frame that we assume is the frame that calls the two. + var sampleLines = sampleStack.split('\n'); + var controlLines = controlStack.split('\n'); + var s = 0; + var c = 0; + + while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { + s++; } - } - if (a.alternate !== b) { - throw new Error("Return fibers should always be each others' alternates. " + 'This error is likely caused by a bug in React. Please file an issue.'); - } - } // If the root is not a host container, we're in a disconnected tree. I.e. - // unmounted. + while (c < controlLines.length && !controlLines[c].includes('DetermineComponentFrameRoot')) { + c++; + } // We couldn't find our intentionally injected common root frame, attempt + // to find another common root frame by search from the bottom of the + // control stack... - if (a.tag !== HostRoot) { - throw new Error('Unable to find node on an unmounted component.'); - } + if (s === sampleLines.length || c === controlLines.length) { + s = sampleLines.length - 1; + c = controlLines.length - 1; - if (a.stateNode.current === a) { - // We've determined that A is the current branch. - return fiber; - } // Otherwise B has to be current branch. + while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { + // We expect at least one stack frame to be shared. + // Typically this will be the root most one. However, stack frames may be + // cut off due to maximum stack limits. In this case, one maybe cut off + // earlier than the other. We assume that the sample is longer or the same + // and there for cut off earlier. So we should find the root most frame in + // the sample somewhere in the control. + c--; + } + } + for (; s >= 1 && c >= 0; s--, c--) { + // Next we find the first one that isn't the same which should be the + // frame that called our sample function and the control. + if (sampleLines[s] !== controlLines[c]) { + // In V8, the first line is describing the message but other VMs don't. + // If we're about to return the first line, and the control is also on the same + // line, that's a pretty good indicator that our sample threw at same line as + // the control. I.e. before we entered the sample frame. So we ignore this result. + // This can happen if you passed a class to function component, or non-function. + if (s !== 1 || c !== 1) { + do { + s--; + c--; // We may still have similar intermediate frames from the construct call. + // The next one that isn't the same should be our match though. - return alternate; -} -function findCurrentHostFiber(parent) { - var currentParent = findCurrentFiberUsingSlowPath(parent); - return currentParent !== null ? findCurrentHostFiberImpl(currentParent) : null; -} + if (c < 0 || sampleLines[s] !== controlLines[c]) { + // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. + var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "" + // but we have a user-provided "displayName" + // splice it in to make the stack more readable. -function findCurrentHostFiberImpl(node) { - // Next we'll drill down this component to find the first HostComponent/Text. - var tag = node.tag; - if (tag === HostComponent || tag === HostHoistable || tag === HostSingleton || tag === HostText) { - return node; - } + if (fn.displayName && _frame.includes('')) { + _frame = _frame.replace('', fn.displayName); + } - var child = node.child; + if (true) { + if (typeof fn === 'function') { + componentFrameCache.set(fn, _frame); + } + } // Return the line we found. - while (child !== null) { - var match = findCurrentHostFiberImpl(child); - if (match !== null) { - return match; + return _frame; + } + } while (s >= 1 && c >= 0); + } + + break; + } + } } + } finally { + reentry = false; - child = child.sibling; - } + { + ReactSharedInternals.H = previousDispatcher; + reenableLogs(); + } - return null; -} -function doesFiberContain(parentFiber, childFiber) { - var node = childFiber; - var parentFiberAlternate = parentFiber.alternate; + Error.prepareStackTrace = previousPrepareStackTrace; + } // Fallback to just using the name if we couldn't make it throw. - while (node !== null) { - if (node === parentFiber || node === parentFiberAlternate) { - return true; - } - node = node.return; + var name = fn ? fn.displayName || fn.name : ''; + var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; + + { + if (typeof fn === 'function') { + componentFrameCache.set(fn, syntheticFrame); + } } - return false; + return syntheticFrame; } -// Modules provided by RN: -var emptyObject$1 = {}; -/** - * Create a payload that contains all the updates between two sets of props. - * - * These helpers are all encapsulated into a single module, because they use - * mutation as a performance optimization which leads to subtle shared - * dependencies between the code paths. To avoid this mutable state leaking - * across modules, I've kept them isolated to this module. - */ -// Tracks removed keys - -var removedKeys = null; -var removedKeyCount = 0; -var deepDifferOptions = { - unsafelyIgnoreFunctions: true -}; - -function defaultDiffer(prevProp, nextProp) { - if (typeof nextProp !== 'object' || nextProp === null) { - // Scalars have already been checked for equality - return true; - } else { - // For objects and arrays, the default diffing algorithm is a deep compare - return ReactNativePrivateInterface.deepDiffer(prevProp, nextProp, deepDifferOptions); +function describeClassComponentFrame(ctor) { + { + return describeNativeComponentFrame(ctor, true); + } +} +function describeFunctionComponentFrame(fn) { + { + return describeNativeComponentFrame(fn, false); } } -function restoreDeletedValuesInNestedArray(updatePayload, node, validAttributes) { - if (isArray(node)) { - var i = node.length; +function describeFiber(fiber) { + switch (fiber.tag) { + case HostHoistable: + case HostSingleton: + case HostComponent: + return describeBuiltInComponentFrame(fiber.type); - while (i-- && removedKeyCount > 0) { - restoreDeletedValuesInNestedArray(updatePayload, node[i], validAttributes); - } - } else if (node && removedKeyCount > 0) { - var obj = node; + case LazyComponent: + return describeBuiltInComponentFrame('Lazy'); - for (var propKey in removedKeys) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - if (!removedKeys[propKey]) { - continue; - } + case SuspenseComponent: + return describeBuiltInComponentFrame('Suspense'); - var nextProp = obj[propKey]; + case SuspenseListComponent: + return describeBuiltInComponentFrame('SuspenseList'); - if (nextProp === undefined) { - continue; - } + case FunctionComponent: + case SimpleMemoComponent: + return describeFunctionComponentFrame(fiber.type); - var attributeConfig = validAttributes[propKey]; + case ForwardRef: + return describeFunctionComponentFrame(fiber.type.render); - if (!attributeConfig) { - continue; // not a valid native prop - } + case ClassComponent: + return describeClassComponentFrame(fiber.type); - if (typeof nextProp === 'function') { - // $FlowFixMe[incompatible-type] found when upgrading Flow - nextProp = true; - } + default: + return ''; + } +} - if (typeof nextProp === 'undefined') { - // $FlowFixMe[incompatible-type] found when upgrading Flow - nextProp = null; - } +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ''; + var node = workInProgress; - if (typeof attributeConfig !== 'object') { - // case: !Object is the default case - updatePayload[propKey] = nextProp; - } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { - // case: CustomAttributeConfiguration - var nextValue = typeof attributeConfig.process === 'function' ? attributeConfig.process(nextProp) : nextProp; - updatePayload[propKey] = nextValue; - } // $FlowFixMe[incompatible-use] found when upgrading Flow + do { + info += describeFiber(node); + if (true) { + // Add any Server Component stack frames in reverse order. + var debugInfo = node._debugInfo; - removedKeys[propKey] = false; - removedKeyCount--; - } - } -} + if (debugInfo) { + for (var i = debugInfo.length - 1; i >= 0; i--) { + var entry = debugInfo[i]; -function diffNestedArrayProperty(updatePayload, prevArray, nextArray, validAttributes) { - var minLength = prevArray.length < nextArray.length ? prevArray.length : nextArray.length; - var i; + if (typeof entry.name === 'string') { + info += describeDebugInfoFrame(entry.name, entry.env); + } + } + } + } // $FlowFixMe[incompatible-type] we bail out when we get a null - for (i = 0; i < minLength; i++) { - // Diff any items in the array in the forward direction. Repeated keys - // will be overwritten by later values. - updatePayload = diffNestedProperty(updatePayload, prevArray[i], nextArray[i], validAttributes); - } - for (; i < prevArray.length; i++) { - // Clear out all remaining properties. - updatePayload = clearNestedProperty(updatePayload, prevArray[i], validAttributes); - } + node = node.return; + } while (node); - for (; i < nextArray.length; i++) { - // Add all remaining properties. - updatePayload = addNestedProperty(updatePayload, nextArray[i], validAttributes); + return info; + } catch (x) { + return '\nError generating stack: ' + x.message + '\n' + x.stack; } - - return updatePayload; } -function diffNestedProperty(updatePayload, prevProp, nextProp, validAttributes) { - if (!updatePayload && prevProp === nextProp) { - // If no properties have been added, then we can bail out quickly on object - // equality. - return updatePayload; - } - - if (!prevProp || !nextProp) { - if (nextProp) { - return addNestedProperty(updatePayload, nextProp, validAttributes); - } - - if (prevProp) { - return clearNestedProperty(updatePayload, prevProp, validAttributes); - } +var current = null; +var isRendering = false; - return updatePayload; - } +function getCurrentFiberStackInDev() { + { + if (current === null) { + return ''; + } // Safe because if current fiber exists, we are reconciling, + // and it is guaranteed to be the work-in-progress version. - if (!isArray(prevProp) && !isArray(nextProp)) { - // Both are leaves, we can diff the leaves. - return diffProperties(updatePayload, prevProp, nextProp, validAttributes); - } - if (isArray(prevProp) && isArray(nextProp)) { - // Both are arrays, we can diff the arrays. - return diffNestedArrayProperty(updatePayload, prevProp, nextProp, validAttributes); + return getStackByFiberInDevAndProd(current); } +} - if (isArray(prevProp)) { - return diffProperties(updatePayload, ReactNativePrivateInterface.flattenStyle(prevProp), nextProp, validAttributes); +function resetCurrentDebugFiberInDEV() { + { + resetCurrentFiber(); } - - return diffProperties(updatePayload, prevProp, ReactNativePrivateInterface.flattenStyle(nextProp), validAttributes); } -/** - * addNestedProperty takes a single set of props and valid attribute - * attribute configurations. It processes each prop and adds it to the - * updatePayload. - */ - - -function addNestedProperty(updatePayload, nextProp, validAttributes) { - if (!nextProp) { - return updatePayload; +function setCurrentDebugFiberInDEV(fiber) { + { + setCurrentFiber(fiber); } - - if (!isArray(nextProp)) { - // Add each property of the leaf. - return addProperties(updatePayload, nextProp, validAttributes); +} +function resetCurrentFiber() { + { + ReactSharedInternals.getCurrentStack = null; + isRendering = false; } - for (var i = 0; i < nextProp.length; i++) { - // Add all the properties of the array. - updatePayload = addNestedProperty(updatePayload, nextProp[i], validAttributes); + current = null; +} +function setCurrentFiber(fiber) { + { + ReactSharedInternals.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev; + isRendering = false; } - return updatePayload; + current = fiber; } -/** - * clearNestedProperty takes a single set of props and valid attributes. It - * adds a null sentinel to the updatePayload, for each prop key. - */ - - -function clearNestedProperty(updatePayload, prevProp, validAttributes) { - if (!prevProp) { - return updatePayload; +function getCurrentFiber() { + { + return current; } - - if (!isArray(prevProp)) { - // Add each property of the leaf. - return clearProperties(updatePayload, prevProp, validAttributes); +} +function setIsRendering(rendering) { + { + isRendering = rendering; } +} - for (var i = 0; i < prevProp.length; i++) { - // Add all the properties of the array. - updatePayload = clearNestedProperty(updatePayload, prevProp[i], validAttributes); - } +function getNearestMountedFiber(fiber) { + var node = fiber; + var nearestMounted = fiber; - return updatePayload; -} -/** - * diffProperties takes two sets of props and a set of valid attributes - * and write to updatePayload the values that changed or were deleted. - * If no updatePayload is provided, a new one is created and returned if - * anything changed. - */ + if (!fiber.alternate) { + // If there is no alternate, this might be a new tree that isn't inserted + // yet. If it is, then it will have a pending insertion effect on it. + var nextNode = node; + do { + node = nextNode; -function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { - var attributeConfig; - var nextProp; - var prevProp; + if ((node.flags & (Placement | Hydrating)) !== NoFlags$1) { + // This is an insertion or in-progress hydration. The nearest possible + // mounted fiber is the parent but we need to continue to figure out + // if that one is still mounted. + nearestMounted = node.return; + } // $FlowFixMe[incompatible-type] we bail out when we get a null - for (var propKey in nextProps) { - attributeConfig = validAttributes[propKey]; - if (!attributeConfig) { - continue; // not a valid native prop + nextNode = node.return; + } while (nextNode); + } else { + while (node.return) { + node = node.return; } + } - prevProp = prevProps[propKey]; - nextProp = nextProps[propKey]; // functions are converted to booleans as markers that the associated - // events should be sent from native. - - if (typeof nextProp === 'function') { - nextProp = true; // If nextProp is not a function, then don't bother changing prevProp - // since nextProp will win and go into the updatePayload regardless. + if (node.tag === HostRoot) { + // TODO: Check if this was a nested HostRoot when used with + // renderContainerIntoSubtree. + return nearestMounted; + } // If we didn't hit the root, that means that we're in an disconnected tree + // that has been unmounted. - if (typeof prevProp === 'function') { - prevProp = true; - } - } // An explicit value of undefined is treated as a null because it overrides - // any other preceding value. + return null; +} +function isFiberMounted(fiber) { + return getNearestMountedFiber(fiber) === fiber; +} +function isMounted(component) { + { + var owner = current; - if (typeof nextProp === 'undefined') { - nextProp = null; + if (owner !== null && isRendering && owner.tag === ClassComponent) { + var ownerFiber = owner; + var instance = ownerFiber.stateNode; - if (typeof prevProp === 'undefined') { - prevProp = null; + if (!instance._warnedAboutRefsInRender) { + error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentNameFromFiber(ownerFiber) || 'A component'); } - } - if (removedKeys) { - removedKeys[propKey] = false; + instance._warnedAboutRefsInRender = true; } + } - if (updatePayload && updatePayload[propKey] !== undefined) { - // Something else already triggered an update to this key because another - // value diffed. Since we're now later in the nested arrays our value is - // more important so we need to calculate it and override the existing - // value. It doesn't matter if nothing changed, we'll set it anyway. - // Pattern match on: attributeConfig - if (typeof attributeConfig !== 'object') { - // case: !Object is the default case - updatePayload[propKey] = nextProp; - } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { - // case: CustomAttributeConfiguration - var nextValue = typeof attributeConfig.process === 'function' ? attributeConfig.process(nextProp) : nextProp; - updatePayload[propKey] = nextValue; - } - - continue; - } + var fiber = get(component); - if (prevProp === nextProp) { - continue; // nothing changed - } // Pattern match on: attributeConfig + if (!fiber) { + return false; + } + return getNearestMountedFiber(fiber) === fiber; +} - if (typeof attributeConfig !== 'object') { - // case: !Object is the default case - if (defaultDiffer(prevProp, nextProp)) { - // a normal leaf has changed - (updatePayload || (updatePayload = {}))[propKey] = nextProp; - } - } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { - // case: CustomAttributeConfiguration - var shouldUpdate = prevProp === undefined || (typeof attributeConfig.diff === 'function' ? attributeConfig.diff(prevProp, nextProp) : defaultDiffer(prevProp, nextProp)); +function assertIsMounted(fiber) { + if (getNearestMountedFiber(fiber) !== fiber) { + throw new Error('Unable to find node on an unmounted component.'); + } +} - if (shouldUpdate) { - var _nextValue = typeof attributeConfig.process === 'function' ? // $FlowFixMe[incompatible-use] found when upgrading Flow - attributeConfig.process(nextProp) : nextProp; +function findCurrentFiberUsingSlowPath(fiber) { + var alternate = fiber.alternate; - (updatePayload || (updatePayload = {}))[propKey] = _nextValue; - } - } else { - // default: fallthrough case when nested properties are defined - removedKeys = null; - removedKeyCount = 0; // We think that attributeConfig is not CustomAttributeConfiguration at - // this point so we assume it must be AttributeConfiguration. + if (!alternate) { + // If there is no alternate, then we only need to check if it is mounted. + var nearestMounted = getNearestMountedFiber(fiber); - updatePayload = diffNestedProperty(updatePayload, prevProp, nextProp, attributeConfig); + if (nearestMounted === null) { + throw new Error('Unable to find node on an unmounted component.'); + } - if (removedKeyCount > 0 && updatePayload) { - restoreDeletedValuesInNestedArray(updatePayload, nextProp, attributeConfig); - removedKeys = null; - } + if (nearestMounted !== fiber) { + return null; } - } // Also iterate through all the previous props to catch any that have been - // removed and make sure native gets the signal so it can reset them to the - // default. + return fiber; + } // If we have two possible branches, we'll walk backwards up to the root + // to see what path the root points to. On the way we may hit one of the + // special cases and we'll deal with them. - for (var _propKey in prevProps) { - if (nextProps[_propKey] !== undefined) { - continue; // we've already covered this key in the previous pass - } - attributeConfig = validAttributes[_propKey]; + var a = fiber; + var b = alternate; - if (!attributeConfig) { - continue; // not a valid native prop - } + while (true) { + var parentA = a.return; - if (updatePayload && updatePayload[_propKey] !== undefined) { - // This was already updated to a diff result earlier. - continue; + if (parentA === null) { + // We're at the root. + break; } - prevProp = prevProps[_propKey]; + var parentB = parentA.alternate; - if (prevProp === undefined) { - continue; // was already empty anyway - } // Pattern match on: attributeConfig + if (parentB === null) { + // There is no alternate. This is an unusual case. Currently, it only + // happens when a Suspense component is hidden. An extra fragment fiber + // is inserted in between the Suspense fiber and its children. Skip + // over this extra fragment fiber and proceed to the next parent. + var nextParent = parentA.return; + if (nextParent !== null) { + a = b = nextParent; + continue; + } // If there's no parent, we're at the root. - if (typeof attributeConfig !== 'object' || typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { - // case: CustomAttributeConfiguration | !Object - // Flag the leaf property for removal by sending a sentinel. - (updatePayload || (updatePayload = {}))[_propKey] = null; - if (!removedKeys) { - removedKeys = {}; - } + break; + } // If both copies of the parent fiber point to the same child, we can + // assume that the child is current. This happens when we bailout on low + // priority: the bailed out fiber's child reuses the current child. - if (!removedKeys[_propKey]) { - removedKeys[_propKey] = true; - removedKeyCount++; - } - } else { - // default: - // This is a nested attribute configuration where all the properties - // were removed so we need to go through and clear out all of them. - updatePayload = clearNestedProperty(updatePayload, prevProp, attributeConfig); - } - } - return updatePayload; -} -/** - * addProperties adds all the valid props to the payload after being processed. - */ + if (parentA.child === parentB.child) { + var child = parentA.child; + + while (child) { + if (child === a) { + // We've determined that A is the current branch. + assertIsMounted(parentA); + return fiber; + } + if (child === b) { + // We've determined that B is the current branch. + assertIsMounted(parentA); + return alternate; + } -function addProperties(updatePayload, props, validAttributes) { - // TODO: Fast path - return diffProperties(updatePayload, emptyObject$1, props, validAttributes); -} -/** - * clearProperties clears all the previous props by adding a null sentinel - * to the payload for each valid key. - */ + child = child.sibling; + } // We should never have an alternate for any mounting node. So the only + // way this could possibly happen is if this was unmounted, if at all. -function clearProperties(updatePayload, prevProps, validAttributes) { - // TODO: Fast path - return diffProperties(updatePayload, prevProps, emptyObject$1, validAttributes); -} + throw new Error('Unable to find node on an unmounted component.'); + } -function create(props, validAttributes) { - return addProperties(null, // updatePayload - props, validAttributes); -} -function diff(prevProps, nextProps, validAttributes) { - return diffProperties(null, // updatePayload - prevProps, nextProps, validAttributes); -} + if (a.return !== b.return) { + // The return pointer of A and the return pointer of B point to different + // fibers. We assume that return pointers never criss-cross, so A must + // belong to the child set of A.return, and B must belong to the child + // set of B.return. + a = parentA; + b = parentB; + } else { + // The return pointers point to the same fiber. We'll have to use the + // default, slow path: scan the child sets of each parent alternate to see + // which child belongs to which set. + // + // Search parent A's child set + var didFindChild = false; + var _child = parentA.child; -/** - * In the future, we should cleanup callbacks by cancelling them instead of - * using this. - */ -function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { - return function () { - if (!callback) { - return undefined; - } // This protects against createClass() components. - // We don't know if there is code depending on it. - // We intentionally don't use isMounted() because even accessing - // isMounted property on a React ES6 class will trigger a warning. + while (_child) { + if (_child === a) { + didFindChild = true; + a = parentA; + b = parentB; + break; + } + if (_child === b) { + didFindChild = true; + b = parentA; + a = parentB; + break; + } - if (typeof context.__isMounted === 'boolean') { - if (!context.__isMounted) { - return undefined; + _child = _child.sibling; } - } // FIXME: there used to be other branches that protected - // against unmounted host components. But RN host components don't - // define isMounted() anymore, so those checks didn't do anything. - // They caused false positive warning noise so we removed them: - // https://github.com/facebook/react-native/issues/18868#issuecomment-413579095 - // However, this means that the callback is NOT guaranteed to be safe - // for host components. The solution we should implement is to make - // UIManager.measure() and similar calls truly cancelable. Then we - // can change our own code calling them to cancel when something unmounts. + if (!didFindChild) { + // Search parent B's child set + _child = parentB.child; - return callback.apply(context, arguments); - }; -} -function warnForStyleProps(props, validAttributes) { - { - for (var key in validAttributes.style) { - if (!(validAttributes[key] || props[key] === undefined)) { - error('You are setting the style `{ %s' + ': ... }` as a prop. You ' + 'should nest it in a style object. ' + 'E.g. `{ style: { %s' + ': ... } }`', key, key); + while (_child) { + if (_child === a) { + didFindChild = true; + a = parentB; + b = parentA; + break; + } + + if (_child === b) { + didFindChild = true; + b = parentB; + a = parentA; + break; + } + + _child = _child.sibling; + } + + if (!didFindChild) { + throw new Error('Child was not found in either parent set. This indicates a bug ' + 'in React related to the return pointer. Please file an issue.'); + } } } - } -} - -var ReactNativeFiberHostComponent = /*#__PURE__*/function () { - function ReactNativeFiberHostComponent(tag, viewConfig, internalInstanceHandleDEV) { - this._children = void 0; - this._nativeTag = void 0; - this._internalFiberInstanceHandleDEV = void 0; - this.viewConfig = void 0; - this._nativeTag = tag; - this._children = []; - this.viewConfig = viewConfig; - { - this._internalFiberInstanceHandleDEV = internalInstanceHandleDEV; + if (a.alternate !== b) { + throw new Error("Return fibers should always be each others' alternates. " + 'This error is likely caused by a bug in React. Please file an issue.'); } - } + } // If the root is not a host container, we're in a disconnected tree. I.e. + // unmounted. - var _proto = ReactNativeFiberHostComponent.prototype; - _proto.blur = function blur() { - ReactNativePrivateInterface.TextInputState.blurTextInput(this); - }; + if (a.tag !== HostRoot) { + throw new Error('Unable to find node on an unmounted component.'); + } - _proto.focus = function focus() { - ReactNativePrivateInterface.TextInputState.focusTextInput(this); - }; + if (a.stateNode.current === a) { + // We've determined that A is the current branch. + return fiber; + } // Otherwise B has to be current branch. - _proto.measure = function measure(callback) { - ReactNativePrivateInterface.UIManager.measure(this._nativeTag, mountSafeCallback_NOT_REALLY_SAFE(this, callback)); - }; - _proto.measureInWindow = function measureInWindow(callback) { - ReactNativePrivateInterface.UIManager.measureInWindow(this._nativeTag, mountSafeCallback_NOT_REALLY_SAFE(this, callback)); - }; + return alternate; +} +function findCurrentHostFiber(parent) { + var currentParent = findCurrentFiberUsingSlowPath(parent); + return currentParent !== null ? findCurrentHostFiberImpl(currentParent) : null; +} - _proto.measureLayout = function measureLayout(relativeToNativeNode, onSuccess, onFail - /* currently unused */ - ) { - var relativeNode; +function findCurrentHostFiberImpl(node) { + // Next we'll drill down this component to find the first HostComponent/Text. + var tag = node.tag; - if (typeof relativeToNativeNode === 'number') { - // Already a node handle - relativeNode = relativeToNativeNode; - } else { - var nativeNode = relativeToNativeNode; + if (tag === HostComponent || tag === HostHoistable || tag === HostSingleton || tag === HostText) { + return node; + } - if (nativeNode._nativeTag) { - relativeNode = nativeNode._nativeTag; - } - } + var child = node.child; - if (relativeNode == null) { - { - error('Warning: ref.measureLayout must be called with a node handle or a ref to a native component.'); - } + while (child !== null) { + var match = findCurrentHostFiberImpl(child); - return; + if (match !== null) { + return match; } - ReactNativePrivateInterface.UIManager.measureLayout(this._nativeTag, relativeNode, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess)); - }; + child = child.sibling; + } - _proto.setNativeProps = function setNativeProps(nativeProps) { - { - warnForStyleProps(nativeProps, this.viewConfig.validAttributes); + return null; +} +function doesFiberContain(parentFiber, childFiber) { + var node = childFiber; + var parentFiberAlternate = parentFiber.alternate; + + while (node !== null) { + if (node === parentFiber || node === parentFiberAlternate) { + return true; } - var updatePayload = create(nativeProps, this.viewConfig.validAttributes); // Avoid the overhead of bridge calls if there's no update. - // This is an expensive no-op for Android, and causes an unnecessary - // view invalidation for certain components (eg RCTTextInput) on iOS. + node = node.return; + } - if (updatePayload != null) { - ReactNativePrivateInterface.UIManager.updateView(this._nativeTag, this.viewConfig.uiViewClassName, updatePayload); - } - }; + return false; +} - return ReactNativeFiberHostComponent; -}(); +// Modules provided by RN: +var emptyObject$1 = {}; +/** + * Create a payload that contains all the updates between two sets of props. + * + * These helpers are all encapsulated into a single module, because they use + * mutation as a performance optimization which leads to subtle shared + * dependencies between the code paths. To avoid this mutable state leaking + * across modules, I've kept them isolated to this module. + */ +// Tracks removed keys -// This module only exists as an ESM wrapper around the external CommonJS -var scheduleCallback$3 = Scheduler.unstable_scheduleCallback; -var cancelCallback$1 = Scheduler.unstable_cancelCallback; -var shouldYield = Scheduler.unstable_shouldYield; -var requestPaint = Scheduler.unstable_requestPaint; -var now$1 = Scheduler.unstable_now; -var ImmediatePriority = Scheduler.unstable_ImmediatePriority; -var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; -var NormalPriority$1 = Scheduler.unstable_NormalPriority; -var IdlePriority = Scheduler.unstable_IdlePriority; // this doesn't actually exist on the scheduler, but it *does* -// on scheduler/unstable_mock, which we'll need for internal testing +var removedKeys = null; +var removedKeyCount = 0; +var deepDifferOptions = { + unsafelyIgnoreFunctions: true +}; -var log$1 = Scheduler.log; -var unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue; +function defaultDiffer(prevProp, nextProp) { + if (typeof nextProp !== 'object' || nextProp === null) { + // Scalars have already been checked for equality + return true; + } else { + // For objects and arrays, the default diffing algorithm is a deep compare + return ReactNativePrivateInterface.deepDiffer(prevProp, nextProp, deepDifferOptions); + } +} -// Helpers to patch console.logs to avoid logging during side-effect free -// replaying on render function. This currently only patches the object -// lazily which won't cover if the log function was extracted eagerly. -// We could also eagerly patch the method. -var disabledDepth = 0; -var prevLog; -var prevInfo; -var prevWarn; -var prevError; -var prevGroup; -var prevGroupCollapsed; -var prevGroupEnd; +function restoreDeletedValuesInNestedArray(updatePayload, node, validAttributes) { + if (isArray(node)) { + var i = node.length; -function disabledLog() {} + while (i-- && removedKeyCount > 0) { + restoreDeletedValuesInNestedArray(updatePayload, node[i], validAttributes); + } + } else if (node && removedKeyCount > 0) { + var obj = node; -disabledLog.__reactDisabledLog = true; -function disableLogs() { - { - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - prevLog = console.log; - prevInfo = console.info; - prevWarn = console.warn; - prevError = console.error; - prevGroup = console.group; - prevGroupCollapsed = console.groupCollapsed; - prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 + for (var propKey in removedKeys) { + // $FlowFixMe[incompatible-use] found when upgrading Flow + if (!removedKeys[propKey]) { + continue; + } - var props = { - configurable: true, - enumerable: true, - value: disabledLog, - writable: true - }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. + var nextProp = obj[propKey]; - Object.defineProperties(console, { - info: props, - log: props, - warn: props, - error: props, - group: props, - groupCollapsed: props, - groupEnd: props - }); - /* eslint-enable react-internal/no-production-logging */ - } + if (nextProp === undefined) { + continue; + } - disabledDepth++; - } -} -function reenableLogs() { - { - disabledDepth--; + var attributeConfig = validAttributes[propKey]; - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - var props = { - configurable: true, - enumerable: true, - writable: true - }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. + if (!attributeConfig) { + continue; // not a valid native prop + } - Object.defineProperties(console, { - log: assign({}, props, { - value: prevLog - }), - info: assign({}, props, { - value: prevInfo - }), - warn: assign({}, props, { - value: prevWarn - }), - error: assign({}, props, { - value: prevError - }), - group: assign({}, props, { - value: prevGroup - }), - groupCollapsed: assign({}, props, { - value: prevGroupCollapsed - }), - groupEnd: assign({}, props, { - value: prevGroupEnd - }) - }); - /* eslint-enable react-internal/no-production-logging */ - } + if (typeof nextProp === 'function') { + // $FlowFixMe[incompatible-type] found when upgrading Flow + nextProp = true; + } - if (disabledDepth < 0) { - error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); + if (typeof nextProp === 'undefined') { + // $FlowFixMe[incompatible-type] found when upgrading Flow + nextProp = null; + } + + if (typeof attributeConfig !== 'object') { + // case: !Object is the default case + updatePayload[propKey] = nextProp; + } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { + // case: CustomAttributeConfiguration + var nextValue = typeof attributeConfig.process === 'function' ? attributeConfig.process(nextProp) : nextProp; + updatePayload[propKey] = nextValue; + } // $FlowFixMe[incompatible-use] found when upgrading Flow + + + removedKeys[propKey] = false; + removedKeyCount--; } } } -var rendererID = null; -var injectedHook = null; -var injectedProfilingHooks = null; -var hasLoggedError = false; -var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'; -function injectInternals(internals) { - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { - // No DevTools - return false; - } +function diffNestedArrayProperty(updatePayload, prevArray, nextArray, validAttributes) { + var minLength = prevArray.length < nextArray.length ? prevArray.length : nextArray.length; + var i; - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + for (i = 0; i < minLength; i++) { + // Diff any items in the array in the forward direction. Repeated keys + // will be overwritten by later values. + updatePayload = diffNestedProperty(updatePayload, prevArray[i], nextArray[i], validAttributes); + } - if (hook.isDisabled) { - // This isn't a real property on the hook, but it can be set to opt out - // of DevTools integration and associated warnings and logs. - // https://github.com/facebook/react/issues/3877 - return true; + for (; i < prevArray.length; i++) { + // Clear out all remaining properties. + updatePayload = clearNestedProperty(updatePayload, prevArray[i], validAttributes); } - if (!hook.supportsFiber) { - { - error('The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://react.dev/link/react-devtools'); - } // DevTools exists, even though it doesn't support Fiber. + for (; i < nextArray.length; i++) { + // Add all remaining properties. + updatePayload = addNestedProperty(updatePayload, nextArray[i], validAttributes); + } + return updatePayload; +} - return true; +function diffNestedProperty(updatePayload, prevProp, nextProp, validAttributes) { + if (!updatePayload && prevProp === nextProp) { + // If no properties have been added, then we can bail out quickly on object + // equality. + return updatePayload; } - try { - if (enableSchedulingProfiler) { - // Conditionally inject these hooks only if Timeline profiler is supported by this build. - // This gives DevTools a way to feature detect that isn't tied to version number - // (since profiling and timeline are controlled by different feature flags). - internals = assign({}, internals, { - getLaneLabelMap: getLaneLabelMap, - injectProfilingHooks: injectProfilingHooks - }); + if (!prevProp || !nextProp) { + if (nextProp) { + return addNestedProperty(updatePayload, nextProp, validAttributes); } - rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. - - injectedHook = hook; - } catch (err) { - // Catch all errors because it is unsafe to throw during initialization. - { - error('React instrumentation encountered an error: %s.', err); + if (prevProp) { + return clearNestedProperty(updatePayload, prevProp, validAttributes); } + + return updatePayload; } - if (hook.checkDCE) { - // This is the real DevTools. - return true; - } else { - // This is likely a hook installed by Fast Refresh runtime. - return false; + if (!isArray(prevProp) && !isArray(nextProp)) { + // Both are leaves, we can diff the leaves. + return diffProperties(updatePayload, prevProp, nextProp, validAttributes); } -} -function onScheduleRoot(root, children) { - { - if (injectedHook && typeof injectedHook.onScheduleFiberRoot === 'function') { - try { - injectedHook.onScheduleFiberRoot(rendererID, root, children); - } catch (err) { - if (!hasLoggedError) { - hasLoggedError = true; - error('React instrumentation encountered an error: %s', err); - } - } - } + if (isArray(prevProp) && isArray(nextProp)) { + // Both are arrays, we can diff the arrays. + return diffNestedArrayProperty(updatePayload, prevProp, nextProp, validAttributes); } -} -function onCommitRoot(root, eventPriority) { - if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') { - try { - var didError = (root.current.flags & DidCapture) === DidCapture; - if (enableProfilerTimer) { - var schedulerPriority; + if (isArray(prevProp)) { + return diffProperties(updatePayload, ReactNativePrivateInterface.flattenStyle(prevProp), nextProp, validAttributes); + } - switch (eventPriority) { - case DiscreteEventPriority: - schedulerPriority = ImmediatePriority; - break; + return diffProperties(updatePayload, prevProp, ReactNativePrivateInterface.flattenStyle(nextProp), validAttributes); +} +/** + * addNestedProperty takes a single set of props and valid attribute + * attribute configurations. It processes each prop and adds it to the + * updatePayload. + */ - case ContinuousEventPriority: - schedulerPriority = UserBlockingPriority; - break; - case DefaultEventPriority: - schedulerPriority = NormalPriority$1; - break; +function addNestedProperty(updatePayload, nextProp, validAttributes) { + if (!nextProp) { + return updatePayload; + } - case IdleEventPriority: - schedulerPriority = IdlePriority; - break; + if (!isArray(nextProp)) { + // Add each property of the leaf. + return addProperties(updatePayload, nextProp, validAttributes); + } - default: - schedulerPriority = NormalPriority$1; - break; - } + for (var i = 0; i < nextProp.length; i++) { + // Add all the properties of the array. + updatePayload = addNestedProperty(updatePayload, nextProp[i], validAttributes); + } - injectedHook.onCommitFiberRoot(rendererID, root, schedulerPriority, didError); - } - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; + return updatePayload; +} +/** + * clearNestedProperty takes a single set of props and valid attributes. It + * adds a null sentinel to the updatePayload, for each prop key. + */ - error('React instrumentation encountered an error: %s', err); - } - } - } + +function clearNestedProperty(updatePayload, prevProp, validAttributes) { + if (!prevProp) { + return updatePayload; } -} -function onPostCommitRoot(root) { - if (injectedHook && typeof injectedHook.onPostCommitFiberRoot === 'function') { - try { - injectedHook.onPostCommitFiberRoot(rendererID, root); - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; - error('React instrumentation encountered an error: %s', err); - } - } - } + if (!isArray(prevProp)) { + // Add each property of the leaf. + return clearProperties(updatePayload, prevProp, validAttributes); } -} -function onCommitUnmount(fiber) { - if (injectedHook && typeof injectedHook.onCommitFiberUnmount === 'function') { - try { - injectedHook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; - error('React instrumentation encountered an error: %s', err); - } - } - } + for (var i = 0; i < prevProp.length; i++) { + // Add all the properties of the array. + updatePayload = clearNestedProperty(updatePayload, prevProp[i], validAttributes); } + + return updatePayload; } -function setIsStrictModeForDevtools(newIsStrictMode) { - if (consoleManagedByDevToolsDuringStrictMode) { - if (typeof log$1 === 'function') { - // We're in a test because Scheduler.log only exists - // in SchedulerMock. To reduce the noise in strict mode tests, - // suppress warnings and disable scheduler yielding during the double render - unstable_setDisableYieldValue(newIsStrictMode); - setSuppressWarning(newIsStrictMode); - } +/** + * diffProperties takes two sets of props and a set of valid attributes + * and write to updatePayload the values that changed or were deleted. + * If no updatePayload is provided, a new one is created and returned if + * anything changed. + */ - if (injectedHook && typeof injectedHook.setStrictMode === 'function') { - try { - injectedHook.setStrictMode(rendererID, newIsStrictMode); - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; - error('React instrumentation encountered an error: %s', err); - } - } +function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { + var attributeConfig; + var nextProp; + var prevProp; + + for (var propKey in nextProps) { + attributeConfig = validAttributes[propKey]; + + if (!attributeConfig) { + continue; // not a valid native prop + } + + prevProp = prevProps[propKey]; + nextProp = nextProps[propKey]; // functions are converted to booleans as markers that the associated + // events should be sent from native. + + if (typeof nextProp === 'function') { + nextProp = true; // If nextProp is not a function, then don't bother changing prevProp + // since nextProp will win and go into the updatePayload regardless. + + if (typeof prevProp === 'function') { + prevProp = true; + } + } // An explicit value of undefined is treated as a null because it overrides + // any other preceding value. + + + if (typeof nextProp === 'undefined') { + nextProp = null; + + if (typeof prevProp === 'undefined') { + prevProp = null; } } - } else { - if (newIsStrictMode) { - disableLogs(); + + if (removedKeys) { + removedKeys[propKey] = false; + } + + if (updatePayload && updatePayload[propKey] !== undefined) { + // Something else already triggered an update to this key because another + // value diffed. Since we're now later in the nested arrays our value is + // more important so we need to calculate it and override the existing + // value. It doesn't matter if nothing changed, we'll set it anyway. + // Pattern match on: attributeConfig + if (typeof attributeConfig !== 'object') { + // case: !Object is the default case + updatePayload[propKey] = nextProp; + } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { + // case: CustomAttributeConfiguration + var nextValue = typeof attributeConfig.process === 'function' ? attributeConfig.process(nextProp) : nextProp; + updatePayload[propKey] = nextValue; + } + + continue; + } + + if (prevProp === nextProp) { + continue; // nothing changed + } // Pattern match on: attributeConfig + + + if (typeof attributeConfig !== 'object') { + // case: !Object is the default case + if (defaultDiffer(prevProp, nextProp)) { + // a normal leaf has changed + (updatePayload || (updatePayload = {}))[propKey] = nextProp; + } + } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { + // case: CustomAttributeConfiguration + var shouldUpdate = prevProp === undefined || (typeof attributeConfig.diff === 'function' ? attributeConfig.diff(prevProp, nextProp) : defaultDiffer(prevProp, nextProp)); + + if (shouldUpdate) { + var _nextValue = typeof attributeConfig.process === 'function' ? // $FlowFixMe[incompatible-use] found when upgrading Flow + attributeConfig.process(nextProp) : nextProp; + + (updatePayload || (updatePayload = {}))[propKey] = _nextValue; + } } else { - reenableLogs(); + // default: fallthrough case when nested properties are defined + removedKeys = null; + removedKeyCount = 0; // We think that attributeConfig is not CustomAttributeConfiguration at + // this point so we assume it must be AttributeConfiguration. + + updatePayload = diffNestedProperty(updatePayload, prevProp, nextProp, attributeConfig); + + if (removedKeyCount > 0 && updatePayload) { + restoreDeletedValuesInNestedArray(updatePayload, nextProp, attributeConfig); + removedKeys = null; + } } - } -} // Profiler API hooks + } // Also iterate through all the previous props to catch any that have been + // removed and make sure native gets the signal so it can reset them to the + // default. -function injectProfilingHooks(profilingHooks) { - injectedProfilingHooks = profilingHooks; -} -function getLaneLabelMap() { - { - var map = new Map(); - var lane = 1; + for (var _propKey in prevProps) { + if (nextProps[_propKey] !== undefined) { + continue; // we've already covered this key in the previous pass + } - for (var index = 0; index < TotalLanes; index++) { - var label = getLabelForLane(lane); - map.set(lane, label); - lane *= 2; + attributeConfig = validAttributes[_propKey]; + + if (!attributeConfig) { + continue; // not a valid native prop } - return map; - } -} + if (updatePayload && updatePayload[_propKey] !== undefined) { + // This was already updated to a diff result earlier. + continue; + } -function markCommitStarted(lanes) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStarted === 'function') { - injectedProfilingHooks.markCommitStarted(lanes); + prevProp = prevProps[_propKey]; + + if (prevProp === undefined) { + continue; // was already empty anyway + } // Pattern match on: attributeConfig + + + if (typeof attributeConfig !== 'object' || typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { + // case: CustomAttributeConfiguration | !Object + // Flag the leaf property for removal by sending a sentinel. + (updatePayload || (updatePayload = {}))[_propKey] = null; + + if (!removedKeys) { + removedKeys = {}; + } + + if (!removedKeys[_propKey]) { + removedKeys[_propKey] = true; + removedKeyCount++; + } + } else { + // default: + // This is a nested attribute configuration where all the properties + // were removed so we need to go through and clear out all of them. + updatePayload = clearNestedProperty(updatePayload, prevProp, attributeConfig); } } + + return updatePayload; } -function markCommitStopped() { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStopped === 'function') { - injectedProfilingHooks.markCommitStopped(); - } - } +/** + * addProperties adds all the valid props to the payload after being processed. + */ + + +function addProperties(updatePayload, props, validAttributes) { + // TODO: Fast path + return diffProperties(updatePayload, emptyObject$1, props, validAttributes); } -function markComponentRenderStarted(fiber) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStarted === 'function') { - injectedProfilingHooks.markComponentRenderStarted(fiber); - } - } +/** + * clearProperties clears all the previous props by adding a null sentinel + * to the payload for each valid key. + */ + + +function clearProperties(updatePayload, prevProps, validAttributes) { + // TODO: Fast path + return diffProperties(updatePayload, prevProps, emptyObject$1, validAttributes); } -function markComponentRenderStopped() { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStopped === 'function') { - injectedProfilingHooks.markComponentRenderStopped(); - } - } + +function create(props, validAttributes) { + return addProperties(null, // updatePayload + props, validAttributes); } -function markComponentPassiveEffectMountStarted(fiber) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectMountStarted === 'function') { - injectedProfilingHooks.markComponentPassiveEffectMountStarted(fiber); - } - } +function diff(prevProps, nextProps, validAttributes) { + return diffProperties(null, // updatePayload + prevProps, nextProps, validAttributes); } -function markComponentPassiveEffectMountStopped() { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectMountStopped === 'function') { - injectedProfilingHooks.markComponentPassiveEffectMountStopped(); - } - } + +/** + * In the future, we should cleanup callbacks by cancelling them instead of + * using this. + */ +function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { + return function () { + if (!callback) { + return undefined; + } // This protects against createClass() components. + // We don't know if there is code depending on it. + // We intentionally don't use isMounted() because even accessing + // isMounted property on a React ES6 class will trigger a warning. + + + if (typeof context.__isMounted === 'boolean') { + if (!context.__isMounted) { + return undefined; + } + } // FIXME: there used to be other branches that protected + // against unmounted host components. But RN host components don't + // define isMounted() anymore, so those checks didn't do anything. + // They caused false positive warning noise so we removed them: + // https://github.com/facebook/react-native/issues/18868#issuecomment-413579095 + // However, this means that the callback is NOT guaranteed to be safe + // for host components. The solution we should implement is to make + // UIManager.measure() and similar calls truly cancelable. Then we + // can change our own code calling them to cancel when something unmounts. + + + return callback.apply(context, arguments); + }; } -function markComponentPassiveEffectUnmountStarted(fiber) { +function warnForStyleProps(props, validAttributes) { { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectUnmountStarted === 'function') { - injectedProfilingHooks.markComponentPassiveEffectUnmountStarted(fiber); + for (var key in validAttributes.style) { + if (!(validAttributes[key] || props[key] === undefined)) { + error('You are setting the style `{ %s' + ': ... }` as a prop. You ' + 'should nest it in a style object. ' + 'E.g. `{ style: { %s' + ': ... } }`', key, key); + } } } } -function markComponentPassiveEffectUnmountStopped() { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectUnmountStopped === 'function') { - injectedProfilingHooks.markComponentPassiveEffectUnmountStopped(); + +var ReactNativeFiberHostComponent = /*#__PURE__*/function () { + function ReactNativeFiberHostComponent(tag, viewConfig, internalInstanceHandleDEV) { + this._children = void 0; + this._nativeTag = void 0; + this._internalFiberInstanceHandleDEV = void 0; + this.viewConfig = void 0; + this._nativeTag = tag; + this._children = []; + this.viewConfig = viewConfig; + + { + this._internalFiberInstanceHandleDEV = internalInstanceHandleDEV; } } -} -function markComponentLayoutEffectMountStarted(fiber) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectMountStarted === 'function') { - injectedProfilingHooks.markComponentLayoutEffectMountStarted(fiber); + + var _proto = ReactNativeFiberHostComponent.prototype; + + _proto.blur = function blur() { + ReactNativePrivateInterface.TextInputState.blurTextInput(this); + }; + + _proto.focus = function focus() { + ReactNativePrivateInterface.TextInputState.focusTextInput(this); + }; + + _proto.measure = function measure(callback) { + ReactNativePrivateInterface.UIManager.measure(this._nativeTag, mountSafeCallback_NOT_REALLY_SAFE(this, callback)); + }; + + _proto.measureInWindow = function measureInWindow(callback) { + ReactNativePrivateInterface.UIManager.measureInWindow(this._nativeTag, mountSafeCallback_NOT_REALLY_SAFE(this, callback)); + }; + + _proto.measureLayout = function measureLayout(relativeToNativeNode, onSuccess, onFail + /* currently unused */ + ) { + var relativeNode; + + if (typeof relativeToNativeNode === 'number') { + // Already a node handle + relativeNode = relativeToNativeNode; + } else { + var nativeNode = relativeToNativeNode; + + if (nativeNode._nativeTag) { + relativeNode = nativeNode._nativeTag; + } } - } -} -function markComponentLayoutEffectMountStopped() { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectMountStopped === 'function') { - injectedProfilingHooks.markComponentLayoutEffectMountStopped(); + + if (relativeNode == null) { + { + error('Warning: ref.measureLayout must be called with a node handle or a ref to a native component.'); + } + + return; } - } -} -function markComponentLayoutEffectUnmountStarted(fiber) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStarted === 'function') { - injectedProfilingHooks.markComponentLayoutEffectUnmountStarted(fiber); + + ReactNativePrivateInterface.UIManager.measureLayout(this._nativeTag, relativeNode, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess)); + }; + + _proto.setNativeProps = function setNativeProps(nativeProps) { + { + warnForStyleProps(nativeProps, this.viewConfig.validAttributes); } - } -} -function markComponentLayoutEffectUnmountStopped() { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStopped === 'function') { - injectedProfilingHooks.markComponentLayoutEffectUnmountStopped(); + + var updatePayload = create(nativeProps, this.viewConfig.validAttributes); // Avoid the overhead of bridge calls if there's no update. + // This is an expensive no-op for Android, and causes an unnecessary + // view invalidation for certain components (eg RCTTextInput) on iOS. + + if (updatePayload != null) { + ReactNativePrivateInterface.UIManager.updateView(this._nativeTag, this.viewConfig.uiViewClassName, updatePayload); } + }; + + return ReactNativeFiberHostComponent; +}(); + +// This module only exists as an ESM wrapper around the external CommonJS +var scheduleCallback$3 = Scheduler.unstable_scheduleCallback; +var cancelCallback$1 = Scheduler.unstable_cancelCallback; +var shouldYield = Scheduler.unstable_shouldYield; +var requestPaint = Scheduler.unstable_requestPaint; +var now$1 = Scheduler.unstable_now; +var ImmediatePriority = Scheduler.unstable_ImmediatePriority; +var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; +var NormalPriority$1 = Scheduler.unstable_NormalPriority; +var IdlePriority = Scheduler.unstable_IdlePriority; // this doesn't actually exist on the scheduler, but it *does* +// on scheduler/unstable_mock, which we'll need for internal testing + +var log$1 = Scheduler.log; +var unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue; + +var rendererID = null; +var injectedHook = null; +var injectedProfilingHooks = null; +var hasLoggedError = false; +var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'; +function injectInternals(internals) { + if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { + // No DevTools + return false; } -} -function markComponentErrored(fiber, thrownValue, lanes) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentErrored === 'function') { - injectedProfilingHooks.markComponentErrored(fiber, thrownValue, lanes); - } + + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + + if (hook.isDisabled) { + // This isn't a real property on the hook, but it can be set to opt out + // of DevTools integration and associated warnings and logs. + // https://github.com/facebook/react/issues/3877 + return true; } -} -function markComponentSuspended(fiber, wakeable, lanes) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentSuspended === 'function') { - injectedProfilingHooks.markComponentSuspended(fiber, wakeable, lanes); - } + + if (!hook.supportsFiber) { + { + error('The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://react.dev/link/react-devtools'); + } // DevTools exists, even though it doesn't support Fiber. + + + return true; } -} -function markLayoutEffectsStarted(lanes) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markLayoutEffectsStarted === 'function') { - injectedProfilingHooks.markLayoutEffectsStarted(lanes); + + try { + if (enableSchedulingProfiler) { + // Conditionally inject these hooks only if Timeline profiler is supported by this build. + // This gives DevTools a way to feature detect that isn't tied to version number + // (since profiling and timeline are controlled by different feature flags). + internals = assign({}, internals, { + getLaneLabelMap: getLaneLabelMap, + injectProfilingHooks: injectProfilingHooks + }); + } + + rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + + injectedHook = hook; + } catch (err) { + // Catch all errors because it is unsafe to throw during initialization. + { + error('React instrumentation encountered an error: %s.', err); } } + + if (hook.checkDCE) { + // This is the real DevTools. + return true; + } else { + // This is likely a hook installed by Fast Refresh runtime. + return false; + } } -function markLayoutEffectsStopped() { +function onScheduleRoot(root, children) { { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markLayoutEffectsStopped === 'function') { - injectedProfilingHooks.markLayoutEffectsStopped(); + if (injectedHook && typeof injectedHook.onScheduleFiberRoot === 'function') { + try { + injectedHook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } } } } -function markPassiveEffectsStarted(lanes) { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markPassiveEffectsStarted === 'function') { - injectedProfilingHooks.markPassiveEffectsStarted(lanes); +function onCommitRoot(root, eventPriority) { + if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') { + try { + var didError = (root.current.flags & DidCapture) === DidCapture; + + if (enableProfilerTimer) { + var schedulerPriority; + + switch (eventPriority) { + case DiscreteEventPriority: + schedulerPriority = ImmediatePriority; + break; + + case ContinuousEventPriority: + schedulerPriority = UserBlockingPriority; + break; + + case DefaultEventPriority: + schedulerPriority = NormalPriority$1; + break; + + case IdleEventPriority: + schedulerPriority = IdlePriority; + break; + + default: + schedulerPriority = NormalPriority$1; + break; + } + + injectedHook.onCommitFiberRoot(rendererID, root, schedulerPriority, didError); + } + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } } } } -function markPassiveEffectsStopped() { - { - if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markPassiveEffectsStopped === 'function') { - injectedProfilingHooks.markPassiveEffectsStopped(); +function onPostCommitRoot(root) { + if (injectedHook && typeof injectedHook.onPostCommitFiberRoot === 'function') { + try { + injectedHook.onPostCommitFiberRoot(rendererID, root); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } } } } -function markRenderStarted(lanes) { - { +function onCommitUnmount(fiber) { + if (injectedHook && typeof injectedHook.onCommitFiberUnmount === 'function') { + try { + injectedHook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } + } + } +} +function setIsStrictModeForDevtools(newIsStrictMode) { + if (consoleManagedByDevToolsDuringStrictMode) { + if (typeof log$1 === 'function') { + // We're in a test because Scheduler.log only exists + // in SchedulerMock. To reduce the noise in strict mode tests, + // suppress warnings and disable scheduler yielding during the double render + unstable_setDisableYieldValue(newIsStrictMode); + setSuppressWarning(newIsStrictMode); + } + + if (injectedHook && typeof injectedHook.setStrictMode === 'function') { + try { + injectedHook.setStrictMode(rendererID, newIsStrictMode); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } + } + } + } else { + if (newIsStrictMode) { + disableLogs(); + } else { + reenableLogs(); + } + } +} // Profiler API hooks + +function injectProfilingHooks(profilingHooks) { + injectedProfilingHooks = profilingHooks; +} + +function getLaneLabelMap() { + { + var map = new Map(); + var lane = 1; + + for (var index = 0; index < TotalLanes; index++) { + var label = getLabelForLane(lane); + map.set(lane, label); + lane *= 2; + } + + return map; + } +} + +function markCommitStarted(lanes) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStarted === 'function') { + injectedProfilingHooks.markCommitStarted(lanes); + } + } +} +function markCommitStopped() { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markCommitStopped === 'function') { + injectedProfilingHooks.markCommitStopped(); + } + } +} +function markComponentRenderStarted(fiber) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStarted === 'function') { + injectedProfilingHooks.markComponentRenderStarted(fiber); + } + } +} +function markComponentRenderStopped() { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentRenderStopped === 'function') { + injectedProfilingHooks.markComponentRenderStopped(); + } + } +} +function markComponentPassiveEffectMountStarted(fiber) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectMountStarted === 'function') { + injectedProfilingHooks.markComponentPassiveEffectMountStarted(fiber); + } + } +} +function markComponentPassiveEffectMountStopped() { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectMountStopped === 'function') { + injectedProfilingHooks.markComponentPassiveEffectMountStopped(); + } + } +} +function markComponentPassiveEffectUnmountStarted(fiber) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectUnmountStarted === 'function') { + injectedProfilingHooks.markComponentPassiveEffectUnmountStarted(fiber); + } + } +} +function markComponentPassiveEffectUnmountStopped() { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentPassiveEffectUnmountStopped === 'function') { + injectedProfilingHooks.markComponentPassiveEffectUnmountStopped(); + } + } +} +function markComponentLayoutEffectMountStarted(fiber) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectMountStarted === 'function') { + injectedProfilingHooks.markComponentLayoutEffectMountStarted(fiber); + } + } +} +function markComponentLayoutEffectMountStopped() { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectMountStopped === 'function') { + injectedProfilingHooks.markComponentLayoutEffectMountStopped(); + } + } +} +function markComponentLayoutEffectUnmountStarted(fiber) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStarted === 'function') { + injectedProfilingHooks.markComponentLayoutEffectUnmountStarted(fiber); + } + } +} +function markComponentLayoutEffectUnmountStopped() { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStopped === 'function') { + injectedProfilingHooks.markComponentLayoutEffectUnmountStopped(); + } + } +} +function markComponentErrored(fiber, thrownValue, lanes) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentErrored === 'function') { + injectedProfilingHooks.markComponentErrored(fiber, thrownValue, lanes); + } + } +} +function markComponentSuspended(fiber, wakeable, lanes) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markComponentSuspended === 'function') { + injectedProfilingHooks.markComponentSuspended(fiber, wakeable, lanes); + } + } +} +function markLayoutEffectsStarted(lanes) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markLayoutEffectsStarted === 'function') { + injectedProfilingHooks.markLayoutEffectsStarted(lanes); + } + } +} +function markLayoutEffectsStopped() { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markLayoutEffectsStopped === 'function') { + injectedProfilingHooks.markLayoutEffectsStopped(); + } + } +} +function markPassiveEffectsStarted(lanes) { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markPassiveEffectsStarted === 'function') { + injectedProfilingHooks.markPassiveEffectsStarted(lanes); + } + } +} +function markPassiveEffectsStopped() { + { + if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markPassiveEffectsStopped === 'function') { + injectedProfilingHooks.markPassiveEffectsStopped(); + } + } +} +function markRenderStarted(lanes) { + { if (injectedProfilingHooks !== null && typeof injectedProfilingHooks.markRenderStarted === 'function') { injectedProfilingHooks.markRenderStarted(lanes); } @@ -5267,645 +5658,301 @@ var fiberStack; var index = -1; -function createCursor(defaultValue) { - return { - current: defaultValue - }; -} - -function pop(cursor, fiber) { - if (index < 0) { - { - error('Unexpected pop.'); - } - - return; - } - - { - if (fiber !== fiberStack[index]) { - error('Unexpected Fiber popped.'); - } - } - - cursor.current = valueStack[index]; - valueStack[index] = null; - - { - fiberStack[index] = null; - } - - index--; -} - -function push(cursor, value, fiber) { - index++; - valueStack[index] = cursor.current; - - { - fiberStack[index] = fiber; - } - - cursor.current = value; -} - -var warnedAboutMissingGetChildContext; - -{ - warnedAboutMissingGetChildContext = {}; -} - -var emptyContextObject = {}; - -{ - Object.freeze(emptyContextObject); -} // A cursor to the current merged context object on the stack. - - -var contextStackCursor$1 = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. - -var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. -// We use this to get access to the parent context after we have already -// pushed the next context provider, and now need to merge their contexts. - -var previousContext = emptyContextObject; - -function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { - { - if (didPushOwnContextIfProvider && isContextProvider(Component)) { - // If the fiber is a context provider itself, when we read its context - // we may have already pushed its own child context on the stack. A context - // provider should not "see" its own child context. Therefore we read the - // previous (parent) context instead for a context provider. - return previousContext; - } - - return contextStackCursor$1.current; - } -} - -function cacheContext(workInProgress, unmaskedContext, maskedContext) { - { - var instance = workInProgress.stateNode; - instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; - instance.__reactInternalMemoizedMaskedChildContext = maskedContext; - } -} - -function getMaskedContext(workInProgress, unmaskedContext) { - { - var type = workInProgress.type; - var contextTypes = type.contextTypes; - - if (!contextTypes) { - return emptyContextObject; - } // Avoid recreating masked context unless unmasked context has changed. - // Failing to do this will result in unnecessary calls to componentWillReceiveProps. - // This may trigger infinite loops if componentWillReceiveProps calls setState. - - - var instance = workInProgress.stateNode; - - if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { - return instance.__reactInternalMemoizedMaskedChildContext; - } - - var context = {}; - - for (var key in contextTypes) { - context[key] = unmaskedContext[key]; - } // Cache unmasked context so we can avoid recreating masked context unless necessary. - // Context is created before the class component is instantiated so check for instance. - - - if (instance) { - cacheContext(workInProgress, unmaskedContext, context); - } - - return context; - } -} - -function hasContextChanged() { - { - return didPerformWorkStackCursor.current; - } -} - -function isContextProvider(type) { - { - var childContextTypes = type.childContextTypes; - return childContextTypes !== null && childContextTypes !== undefined; - } -} - -function popContext(fiber) { - { - pop(didPerformWorkStackCursor, fiber); - pop(contextStackCursor$1, fiber); - } -} - -function popTopLevelContextObject(fiber) { - { - pop(didPerformWorkStackCursor, fiber); - pop(contextStackCursor$1, fiber); - } -} - -function pushTopLevelContextObject(fiber, context, didChange) { - { - if (contextStackCursor$1.current !== emptyContextObject) { - throw new Error('Unexpected context found on stack. ' + 'This error is likely caused by a bug in React. Please file an issue.'); - } - - push(contextStackCursor$1, context, fiber); - push(didPerformWorkStackCursor, didChange, fiber); - } -} - -function processChildContext(fiber, type, parentContext) { - { - var instance = fiber.stateNode; - var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. - // It has only been added in Fiber to match the (unintentional) behavior in Stack. - - if (typeof instance.getChildContext !== 'function') { - { - var componentName = getComponentNameFromFiber(fiber) || 'Unknown'; - - if (!warnedAboutMissingGetChildContext[componentName]) { - warnedAboutMissingGetChildContext[componentName] = true; - - error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); - } - } - - return parentContext; - } - - var childContext = instance.getChildContext(); - - for (var contextKey in childContext) { - if (!(contextKey in childContextTypes)) { - throw new Error((getComponentNameFromFiber(fiber) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."); - } - } - - return assign({}, parentContext, childContext); - } -} - -function pushContextProvider(workInProgress) { - { - var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. - // If the instance does not exist yet, we will push null at first, - // and replace it on the stack later when invalidating the context. - - var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. - // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. - - previousContext = contextStackCursor$1.current; - push(contextStackCursor$1, memoizedMergedChildContext, workInProgress); - push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); - return true; - } -} - -function invalidateContextProvider(workInProgress, type, didChange) { - { - var instance = workInProgress.stateNode; - - if (!instance) { - throw new Error('Expected to have an instance by this point. ' + 'This error is likely caused by a bug in React. Please file an issue.'); - } - - if (didChange) { - // Merge parent and own context. - // Skip this if we're not updating due to sCU. - // This avoids unnecessarily recomputing memoized values. - var mergedContext = processChildContext(workInProgress, type, previousContext); - instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. - // It is important to unwind the context in the reverse order. - - pop(didPerformWorkStackCursor, workInProgress); - pop(contextStackCursor$1, workInProgress); // Now push the new context and mark that it has changed. - - push(contextStackCursor$1, mergedContext, workInProgress); - push(didPerformWorkStackCursor, didChange, workInProgress); - } else { - pop(didPerformWorkStackCursor, workInProgress); - push(didPerformWorkStackCursor, didChange, workInProgress); - } - } -} - -function findCurrentUnmaskedContext(fiber) { - { - // Currently this is only used with renderSubtreeIntoContainer; not sure if it - // makes sense elsewhere - if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) { - throw new Error('Expected subtree parent to be a mounted class component. ' + 'This error is likely caused by a bug in React. Please file an issue.'); - } - - var node = fiber; - - do { - switch (node.tag) { - case HostRoot: - return node.stateNode.context; - - case ClassComponent: - { - var Component = node.type; - - if (isContextProvider(Component)) { - return node.stateNode.__reactInternalMemoizedMergedChildContext; - } - - break; - } - } // $FlowFixMe[incompatible-type] we bail out when we get a null - - - node = node.return; - } while (node !== null); - - throw new Error('Found unexpected detached subtree parent. ' + 'This error is likely caused by a bug in React. Please file an issue.'); - } -} - -// We use the existence of the state object as an indicator that the component -// is hidden. -var OffscreenVisible = -/* */ -1; -var OffscreenDetached = -/* */ -2; -var OffscreenPassiveEffectsConnected = -/* */ -4; -function isOffscreenManual(offscreenFiber) { - return offscreenFiber.memoizedProps !== null && offscreenFiber.memoizedProps.mode === 'manual'; -} - -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ -function is(x, y) { - return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare - ; -} - -var objectIs = // $FlowFixMe[method-unbinding] -typeof Object.is === 'function' ? Object.is : is; - -var prefix; -function describeBuiltInComponentFrame(name) { - { - if (prefix === undefined) { - // Extract the VM specific prefix used by each line. - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = match && match[1] || ''; - } - } // We use the prefix to ensure our stacks line up with native stack frames. - - - return '\n' + prefix + name; - } -} -function describeDebugInfoFrame(name, env) { - return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : '')); -} -var reentry = false; -var componentFrameCache; - -{ - var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; - componentFrameCache = new PossiblyWeakMap$1(); -} -/** - * Leverages native browser/VM stack frames to get proper details (e.g. - * filename, line + col number) for a single component in a component stack. We - * do this by: - * (1) throwing and catching an error in the function - this will be our - * control error. - * (2) calling the component which will eventually throw an error that we'll - * catch - this will be our sample error. - * (3) diffing the control and sample error stacks to find the stack frame - * which represents our component. - */ - +function createCursor(defaultValue) { + return { + current: defaultValue + }; +} -function describeNativeComponentFrame(fn, construct) { - // If something asked for a stack inside a fake render, it should get ignored. - if (!fn || reentry) { - return ''; +function pop(cursor, fiber) { + if (index < 0) { + { + error('Unexpected pop.'); + } + + return; } { - var frame = componentFrameCache.get(fn); - - if (frame !== undefined) { - return frame; + if (fiber !== fiberStack[index]) { + error('Unexpected Fiber popped.'); } } - reentry = true; - var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. - - Error.prepareStackTrace = undefined; - var previousDispatcher = null; + cursor.current = valueStack[index]; + valueStack[index] = null; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function - // for warnings. - - ReactSharedInternals.H = null; - disableLogs(); + fiberStack[index] = null; } - /** - * Finding a common stack frame between sample and control errors can be - * tricky given the different types and levels of stack trace truncation from - * different JS VMs. So instead we'll attempt to control what that common - * frame should be through this object method: - * Having both the sample and control errors be in the function under the - * `DescribeNativeComponentFrameRoot` property, + setting the `name` and - * `displayName` properties of the function ensures that a stack - * frame exists that has the method name `DescribeNativeComponentFrameRoot` in - * it for both control and sample stacks. - */ + index--; +} - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - var control; +function push(cursor, value, fiber) { + index++; + valueStack[index] = cursor.current; - try { - // This should throw. - if (construct) { - // Something should be setting the props in the constructor. - var Fake = function () { - throw Error(); - }; // $FlowFixMe[prop-missing] + { + fiberStack[index] = fiber; + } + cursor.current = value; +} - Object.defineProperty(Fake.prototype, 'props', { - set: function () { - // We use a throwing setter instead of frozen or non-writable props - // because that won't throw in a non-strict mode function. - throw Error(); - } - }); +var warnedAboutMissingGetChildContext; - if (typeof Reflect === 'object' && Reflect.construct) { - // We construct a different control for this case to include any extra - // frames added by the construct call. - try { - Reflect.construct(Fake, []); - } catch (x) { - control = x; - } +{ + warnedAboutMissingGetChildContext = {}; +} - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x) { - control = x; - } // $FlowFixMe[prop-missing] found when upgrading Flow +var emptyContextObject = {}; +{ + Object.freeze(emptyContextObject); +} // A cursor to the current merged context object on the stack. - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x) { - control = x; - } // TODO(luna): This will currently only throw if the function component - // tries to access React/ReactDOM/props. We should probably make this throw - // in simple components too +var contextStackCursor$1 = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. - var maybePromise = fn(); // If the function component returns a promise, it's likely an async - // component, which we don't yet support. Attach a noop catch handler to - // silence the error. - // TODO: Implement component stacks for async client components? +var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. +// We use this to get access to the parent context after we have already +// pushed the next context provider, and now need to merge their contexts. - if (maybePromise && typeof maybePromise.catch === 'function') { - maybePromise.catch(function () {}); - } - } - } catch (sample) { - // This is inlined manually because closure doesn't do it for us. - if (sample && control && typeof sample.stack === 'string') { - return [sample.stack, control.stack]; - } - } +var previousContext = emptyContextObject; - return [null, null]; +function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { + { + if (didPushOwnContextIfProvider && isContextProvider(Component)) { + // If the fiber is a context provider itself, when we read its context + // we may have already pushed its own child context on the stack. A context + // provider should not "see" its own child context. Therefore we read the + // previous (parent) context instead for a context provider. + return previousContext; } - }; // $FlowFixMe[prop-missing] - RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; - var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable. + return contextStackCursor$1.current; + } +} - if (namePropDescriptor && namePropDescriptor.configurable) { - // V8 utilizes a function's `name` property when generating a stack trace. - Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor - // is set to `false`. - // $FlowFixMe[cannot-write] - 'name', { - value: 'DetermineComponentFrameRoot' - }); +function cacheContext(workInProgress, unmaskedContext, maskedContext) { + { + var instance = workInProgress.stateNode; + instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; + instance.__reactInternalMemoizedMaskedChildContext = maskedContext; } +} - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; +function getMaskedContext(workInProgress, unmaskedContext) { + { + var type = workInProgress.type; + var contextTypes = type.contextTypes; - if (sampleStack && controlStack) { - // This extracts the first frame from the sample that isn't also in the control. - // Skipping one frame that we assume is the frame that calls the two. - var sampleLines = sampleStack.split('\n'); - var controlLines = controlStack.split('\n'); - var s = 0; - var c = 0; + if (!contextTypes) { + return emptyContextObject; + } // Avoid recreating masked context unless unmasked context has changed. + // Failing to do this will result in unnecessary calls to componentWillReceiveProps. + // This may trigger infinite loops if componentWillReceiveProps calls setState. - while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { - s++; - } - while (c < controlLines.length && !controlLines[c].includes('DetermineComponentFrameRoot')) { - c++; - } // We couldn't find our intentionally injected common root frame, attempt - // to find another common root frame by search from the bottom of the - // control stack... + var instance = workInProgress.stateNode; + if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { + return instance.__reactInternalMemoizedMaskedChildContext; + } - if (s === sampleLines.length || c === controlLines.length) { - s = sampleLines.length - 1; - c = controlLines.length - 1; + var context = {}; - while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { - // We expect at least one stack frame to be shared. - // Typically this will be the root most one. However, stack frames may be - // cut off due to maximum stack limits. In this case, one maybe cut off - // earlier than the other. We assume that the sample is longer or the same - // and there for cut off earlier. So we should find the root most frame in - // the sample somewhere in the control. - c--; - } - } + for (var key in contextTypes) { + context[key] = unmaskedContext[key]; + } // Cache unmasked context so we can avoid recreating masked context unless necessary. + // Context is created before the class component is instantiated so check for instance. - for (; s >= 1 && c >= 0; s--, c--) { - // Next we find the first one that isn't the same which should be the - // frame that called our sample function and the control. - if (sampleLines[s] !== controlLines[c]) { - // In V8, the first line is describing the message but other VMs don't. - // If we're about to return the first line, and the control is also on the same - // line, that's a pretty good indicator that our sample threw at same line as - // the control. I.e. before we entered the sample frame. So we ignore this result. - // This can happen if you passed a class to function component, or non-function. - if (s !== 1 || c !== 1) { - do { - s--; - c--; // We may still have similar intermediate frames from the construct call. - // The next one that isn't the same should be our match though. - if (c < 0 || sampleLines[s] !== controlLines[c]) { - // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. - var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "" - // but we have a user-provided "displayName" - // splice it in to make the stack more readable. + if (instance) { + cacheContext(workInProgress, unmaskedContext, context); + } + + return context; + } +} + +function hasContextChanged() { + { + return didPerformWorkStackCursor.current; + } +} + +function isContextProvider(type) { + { + var childContextTypes = type.childContextTypes; + return childContextTypes !== null && childContextTypes !== undefined; + } +} + +function popContext(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor$1, fiber); + } +} + +function popTopLevelContextObject(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor$1, fiber); + } +} +function pushTopLevelContextObject(fiber, context, didChange) { + { + if (contextStackCursor$1.current !== emptyContextObject) { + throw new Error('Unexpected context found on stack. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + } - if (fn.displayName && _frame.includes('')) { - _frame = _frame.replace('', fn.displayName); - } + push(contextStackCursor$1, context, fiber); + push(didPerformWorkStackCursor, didChange, fiber); + } +} - if (true) { - if (typeof fn === 'function') { - componentFrameCache.set(fn, _frame); - } - } // Return the line we found. +function processChildContext(fiber, type, parentContext) { + { + var instance = fiber.stateNode; + var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. + // It has only been added in Fiber to match the (unintentional) behavior in Stack. + if (typeof instance.getChildContext !== 'function') { + { + var componentName = getComponentNameFromFiber(fiber) || 'Unknown'; - return _frame; - } - } while (s >= 1 && c >= 0); - } + if (!warnedAboutMissingGetChildContext[componentName]) { + warnedAboutMissingGetChildContext[componentName] = true; - break; + error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); } } - } - } finally { - reentry = false; - { - ReactSharedInternals.H = previousDispatcher; - reenableLogs(); + return parentContext; } - Error.prepareStackTrace = previousPrepareStackTrace; - } // Fallback to just using the name if we couldn't make it throw. - - - var name = fn ? fn.displayName || fn.name : ''; - var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; + var childContext = instance.getChildContext(); - { - if (typeof fn === 'function') { - componentFrameCache.set(fn, syntheticFrame); + for (var contextKey in childContext) { + if (!(contextKey in childContextTypes)) { + throw new Error((getComponentNameFromFiber(fiber) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."); + } } - } - return syntheticFrame; -} - -function describeClassComponentFrame(ctor) { - { - return describeNativeComponentFrame(ctor, true); - } -} -function describeFunctionComponentFrame(fn) { - { - return describeNativeComponentFrame(fn, false); + return assign({}, parentContext, childContext); } } -function describeFiber(fiber) { - switch (fiber.tag) { - case HostHoistable: - case HostSingleton: - case HostComponent: - return describeBuiltInComponentFrame(fiber.type); +function pushContextProvider(workInProgress) { + { + var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. + // If the instance does not exist yet, we will push null at first, + // and replace it on the stack later when invalidating the context. - case LazyComponent: - return describeBuiltInComponentFrame('Lazy'); + var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. + // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. - case SuspenseComponent: - return describeBuiltInComponentFrame('Suspense'); + previousContext = contextStackCursor$1.current; + push(contextStackCursor$1, memoizedMergedChildContext, workInProgress); + push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); + return true; + } +} - case SuspenseListComponent: - return describeBuiltInComponentFrame('SuspenseList'); +function invalidateContextProvider(workInProgress, type, didChange) { + { + var instance = workInProgress.stateNode; - case FunctionComponent: - case SimpleMemoComponent: - return describeFunctionComponentFrame(fiber.type); + if (!instance) { + throw new Error('Expected to have an instance by this point. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + } - case ForwardRef: - return describeFunctionComponentFrame(fiber.type.render); + if (didChange) { + // Merge parent and own context. + // Skip this if we're not updating due to sCU. + // This avoids unnecessarily recomputing memoized values. + var mergedContext = processChildContext(workInProgress, type, previousContext); + instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. + // It is important to unwind the context in the reverse order. - case ClassComponent: - return describeClassComponentFrame(fiber.type); + pop(didPerformWorkStackCursor, workInProgress); + pop(contextStackCursor$1, workInProgress); // Now push the new context and mark that it has changed. - default: - return ''; + push(contextStackCursor$1, mergedContext, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); + } else { + pop(didPerformWorkStackCursor, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); + } } } -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ''; - var node = workInProgress; +function findCurrentUnmaskedContext(fiber) { + { + // Currently this is only used with renderSubtreeIntoContainer; not sure if it + // makes sense elsewhere + if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) { + throw new Error('Expected subtree parent to be a mounted class component. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + } - do { - info += describeFiber(node); + var node = fiber; - if (true) { - // Add any Server Component stack frames in reverse order. - var debugInfo = node._debugInfo; + do { + switch (node.tag) { + case HostRoot: + return node.stateNode.context; - if (debugInfo) { - for (var i = debugInfo.length - 1; i >= 0; i--) { - var entry = debugInfo[i]; + case ClassComponent: + { + var Component = node.type; - if (typeof entry.name === 'string') { - info += describeDebugInfoFrame(entry.name, entry.env); + if (isContextProvider(Component)) { + return node.stateNode.__reactInternalMemoizedMergedChildContext; } + + break; } - } } // $FlowFixMe[incompatible-type] we bail out when we get a null node = node.return; - } while (node); + } while (node !== null); - return info; - } catch (x) { - return '\nError generating stack: ' + x.message + '\n' + x.stack; + throw new Error('Found unexpected detached subtree parent. ' + 'This error is likely caused by a bug in React. Please file an issue.'); } } +// We use the existence of the state object as an indicator that the component +// is hidden. +var OffscreenVisible = +/* */ +1; +var OffscreenDetached = +/* */ +2; +var OffscreenPassiveEffectsConnected = +/* */ +4; +function isOffscreenManual(offscreenFiber) { + return offscreenFiber.memoizedProps !== null && offscreenFiber.memoizedProps.mode === 'manual'; +} + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare + ; +} + +var objectIs = // $FlowFixMe[method-unbinding] +typeof Object.is === 'function' ? Object.is : is; + var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { // If the value is an error, call this function immediately after it is thrown @@ -7968,46 +8015,6 @@ function shallowEqual(objA, objB) { return true; } -var current = null; -var isRendering = false; - -function getCurrentFiberStackInDev() { - { - if (current === null) { - return ''; - } // Safe because if current fiber exists, we are reconciling, - // and it is guaranteed to be the work-in-progress version. - - - return getStackByFiberInDevAndProd(current); - } -} - -function resetCurrentFiber() { - { - ReactSharedInternals.getCurrentStack = null; - current = null; - isRendering = false; - } -} -function setCurrentFiber(fiber) { - { - ReactSharedInternals.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev; - current = fiber; - isRendering = false; - } -} -function getCurrentFiber() { - { - return current; - } -} -function setIsRendering(rendering) { - { - isRendering = rendering; - } -} - var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function (fiber, instance) {}, flushPendingUnsafeLifecycleWarnings: function () {}, @@ -8227,11 +8234,11 @@ var ReactStrictModeWarnings = { var sortedNames = setToSortedString(uniqueNames); try { - setCurrentFiber(firstFiber); + setCurrentDebugFiberInDEV(firstFiber); error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://react.dev/link/legacy-context', sortedNames); } finally { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } }); }; @@ -15142,7 +15149,6 @@ function updateForwardRef(current, workInProgress, Component, nextProps, renderL } { - setCurrentOwner(workInProgress); setIsRendering(true); nextChildren = renderWithHooks(current, workInProgress, render, propsWithoutRef, ref, renderLanes); setIsRendering(false); @@ -15612,7 +15618,6 @@ function updateFunctionComponent(current, workInProgress, Component, nextProps, } { - setCurrentOwner(workInProgress); setIsRendering(true); nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes); setIsRendering(false); @@ -15764,7 +15769,7 @@ function finishClassComponent(current, workInProgress, Component, shouldUpdate, var instance = workInProgress.stateNode; // Rerender { - setCurrentOwner(workInProgress); + setCurrentFiber(workInProgress); } var nextChildren; @@ -17070,7 +17075,6 @@ function updateContextConsumer(current, workInProgress, renderLanes) { var newChildren; { - setCurrentOwner(workInProgress); setIsRendering(true); newChildren = render(newValue); setIsRendering(false); @@ -19471,7 +19475,7 @@ function commitBeforeMutationEffects_begin() { function commitBeforeMutationEffects_complete() { while (nextEffect !== null) { var fiber = nextEffect; - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); try { commitBeforeMutationEffectsOnFiber(fiber); @@ -19479,7 +19483,7 @@ function commitBeforeMutationEffects_complete() { captureCommitPhaseError(fiber, fiber.return, error); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); var sibling = fiber.sibling; if (sibling !== null) { @@ -19497,7 +19501,7 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { var flags = finishedWork.flags; if ((flags & Snapshot) !== NoFlags$1) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); } switch (finishedWork.tag) { @@ -19578,7 +19582,7 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { } if ((flags & Snapshot) !== NoFlags$1) { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } @@ -20846,9 +20850,9 @@ function attachSuspenseRetryListeners(finishedWork, wakeables) { function commitMutationEffects(root, finishedWork, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); commitMutationEffectsOnFiber(finishedWork, root); - setCurrentFiber(finishedWork); + resetCurrentDebugFiberInDEV(); inProgressLanes = null; inProgressRoot = null; } @@ -20876,13 +20880,13 @@ function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitMutationEffectsOnFiber(child, root); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitMutationEffectsOnFiber(finishedWork, root, lanes) { @@ -21271,8 +21275,10 @@ function commitReconciliationEffects(finishedWork) { function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; + setCurrentDebugFiberInDEV(finishedWork); var current = finishedWork.alternate; commitLayoutEffectOnFiber(root, current, finishedWork); + resetCurrentDebugFiberInDEV(); inProgressLanes = null; inProgressRoot = null; } @@ -21284,14 +21290,14 @@ function recursivelyTraverseLayoutEffects(root, parentFiber, lanes) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); var current = child.alternate; commitLayoutEffectOnFiber(root, current, child); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function disappearLayoutEffects(finishedWork) { @@ -21501,7 +21507,7 @@ function recursivelyTraverseReappearLayoutEffects(finishedRoot, parentFiber, inc child = child.sibling; } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitHookPassiveMountEffects(finishedWork, hookFlags) { @@ -21579,9 +21585,9 @@ function commitCachePassiveMountEffect(current, finishedWork) { } function commitPassiveMountEffects(root, finishedWork, committedLanes, committedTransitions) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); commitPassiveMountOnFiber(root, finishedWork, committedLanes, committedTransitions); - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLanes, committedTransitions) { @@ -21591,13 +21597,13 @@ function recursivelyTraversePassiveMountEffects(root, parentFiber, committedLane var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitPassiveMountOnFiber(root, child, committedLanes, committedTransitions); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveMountOnFiber(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -21745,7 +21751,7 @@ function recursivelyTraverseReconnectPassiveEffects(finishedRoot, parentFiber, c child = child.sibling; } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function reconnectPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions, // This function visits both newly finished work and nodes that were re-used @@ -21856,13 +21862,13 @@ function recursivelyTraverseAtomicPassiveEffects(finishedRoot, parentFiber, comm var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitAtomicPassiveEffects(finishedRoot, child); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, committedTransitions) { @@ -21907,9 +21913,9 @@ function commitAtomicPassiveEffects(finishedRoot, finishedWork, committedLanes, } function commitPassiveUnmountEffects(finishedWork) { - setCurrentFiber(finishedWork); + setCurrentDebugFiberInDEV(finishedWork); commitPassiveUnmountOnFiber(finishedWork); - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } // If we're inside a brand new tree, or a tree that was already visible, then we // should only suspend host components that have a ShouldSuspendCommit flag. // Components without it haven't changed since the last commit, so we can skip @@ -22063,13 +22069,13 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); commitPassiveUnmountOnFiber(child); child = child.sibling; } } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function commitPassiveUnmountOnFiber(finishedWork) { @@ -22140,12 +22146,12 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber) { var child = parentFiber.child; while (child !== null) { - setCurrentFiber(child); + setCurrentDebugFiberInDEV(child); disconnectPassiveEffect(child); child = child.sibling; } - setCurrentFiber(prevDebugFiber); + setCurrentDebugFiberInDEV(prevDebugFiber); } function disconnectPassiveEffect(finishedWork) { @@ -22187,9 +22193,9 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(deletedSubtreeRoot var fiber = nextEffect; // Deletion effects fire in parent -> child order // TODO: Check if fiber has a PassiveStatic flag - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor); - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); var child = fiber.child; // TODO: Only traverse subtree if it has a PassiveStatic flag. if (child !== null) { @@ -22411,7 +22417,7 @@ var DefaultAsyncDispatcher = { { DefaultAsyncDispatcher.getOwner = function () { - return currentOwner; + return current; }; } @@ -23363,10 +23369,9 @@ function handleThrow(root, thrownValue) { // These should be reset immediately because they're only supposed to be set // when React is executing user code. resetHooksAfterThrow(); - resetCurrentFiber(); { - setCurrentOwner(null); + resetCurrentFiber(); } if (thrownValue === SuspenseException) { @@ -23997,7 +24002,7 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; - setCurrentFiber(unitOfWork); + setCurrentDebugFiberInDEV(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { @@ -24008,7 +24013,10 @@ function performUnitOfWork(unitOfWork) { next = beginWork(current, unitOfWork, entangledRenderLanes); } - resetCurrentFiber(); + { + resetCurrentFiber(); + } + unitOfWork.memoizedProps = unitOfWork.pendingProps; if (next === null) { @@ -24017,10 +24025,6 @@ function performUnitOfWork(unitOfWork) { } else { workInProgress = next; } - - { - setCurrentOwner(null); - } } function replaySuspendedUnitOfWork(unitOfWork) { @@ -24028,9 +24032,8 @@ function replaySuspendedUnitOfWork(unitOfWork) { // just suspended. // var current = unitOfWork.alternate; - setCurrentFiber(unitOfWork); + setCurrentDebugFiberInDEV(unitOfWork); var next; - setCurrentFiber(unitOfWork); var isProfilingMode = (unitOfWork.mode & ProfileMode) !== NoMode; if (isProfilingMode) { @@ -24108,7 +24111,10 @@ function replaySuspendedUnitOfWork(unitOfWork) { // normal work loop. - resetCurrentFiber(); + { + resetCurrentFiber(); + } + unitOfWork.memoizedProps = unitOfWork.pendingProps; if (next === null) { @@ -24117,10 +24123,6 @@ function replaySuspendedUnitOfWork(unitOfWork) { } else { workInProgress = next; } - - { - setCurrentOwner(null); - } } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -24207,7 +24209,7 @@ function completeUnitOfWork(unitOfWork) { var current = completedWork.alternate; var returnFiber = completedWork.return; - setCurrentFiber(completedWork); + setCurrentDebugFiberInDEV(completedWork); var next = void 0; if ((completedWork.mode & ProfileMode) === NoMode) { @@ -24219,7 +24221,7 @@ function completeUnitOfWork(unitOfWork) { stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); if (next !== null) { // Completing this fiber spawned new work. Work on that next. @@ -24446,18 +24448,13 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh var previousPriority = getCurrentUpdatePriority(); setCurrentUpdatePriority(DiscreteEventPriority); var prevExecutionContext = executionContext; - executionContext |= CommitContext; // Reset this to null before calling lifecycles - - { - setCurrentOwner(null); - } // The commit phase is broken into several sub-phases. We do a separate pass + executionContext |= CommitContext; // The commit phase is broken into several sub-phases. We do a separate pass // of the effect list for each phase: all mutation effects come before all // layout effects, and so on. // The first phase a "before mutation" phase. We use this phase to read the // state of the host tree right before we mutate it. This is where // getSnapshotBeforeUpdate is called. - commitBeforeMutationEffects(root, finishedWork); { @@ -25083,13 +25080,13 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.tag !== OffscreenComponent) { if (fiber.flags & PlacementDEV) { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); if (isInStrictMode) { doubleInvokeEffectsOnFiber(root, fiber, (fiber.mode & NoStrictPassiveEffectsMode) === NoMode); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } else { recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } @@ -25102,7 +25099,7 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) if (fiber.memoizedState === null) { // Only consider Offscreen that is visible. // TODO (Offscreen) Handle manual mode. - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); if (isInStrictMode && fiber.flags & Visibility) { // Double invoke effects on Offscreen's subtree only @@ -25114,7 +25111,7 @@ function doubleInvokeEffectsInDEVIfNecessary(root, fiber, parentIsInStrictMode) recursivelyTraverseAndDoubleInvokeEffectsInDEV(root, fiber, isInStrictMode); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } @@ -25138,7 +25135,7 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { // TODO (StrictEffects) Should we set a marker on the root if it contains strict effects // so we don't traverse unnecessarily? similar to subtreeFlags but just at the root level. // Maybe not a big deal since this is DEV only behavior. - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); invokeEffectsInDev(fiber, MountLayoutDev, invokeLayoutEffectUnmountInDEV); if (hasPassiveEffects) { @@ -25151,7 +25148,7 @@ function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { invokeEffectsInDev(fiber, MountPassiveDev, invokePassiveEffectMountInDEV); } - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { @@ -25214,14 +25211,14 @@ function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { var previousFiber = current; try { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); } finally { if (previousFiber) { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); } else { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } } @@ -25335,14 +25332,14 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { var previousFiber = current; try { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://react.dev/link/wrap-tests-with-act', getComponentNameFromFiber(fiber)); } finally { if (previousFiber) { - setCurrentFiber(fiber); + setCurrentDebugFiberInDEV(fiber); } else { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } } @@ -26395,7 +26392,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-rc-5945dec0'; +var ReactVersion = '19.0.0-rc-e935f1f2'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol @@ -26539,7 +26536,7 @@ function findHostInstanceWithWarning(component, methodName) { var previousFiber = current; try { - setCurrentFiber(hostFiber); + setCurrentDebugFiberInDEV(hostFiber); if (fiber.mode & StrictLegacyMode) { error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://react.dev/link/strict-mode-find-node', methodName, methodName, componentName); @@ -26550,9 +26547,9 @@ function findHostInstanceWithWarning(component, methodName) { // Ideally this should reset to previous but this shouldn't be called in // render and there's another warning for that anyway. if (previousFiber) { - setCurrentFiber(previousFiber); + setCurrentDebugFiberInDEV(previousFiber); } else { - resetCurrentFiber(); + resetCurrentDebugFiberInDEV(); } } } @@ -26945,9 +26942,9 @@ function injectIntoDevTools(devToolsConfig) { function findHostInstance_DEPRECATED(componentOrHandle) { { - var owner = currentOwner; + var owner = current; - if (owner !== null && owner.stateNode !== null) { + if (owner !== null && isRendering && owner.stateNode !== null) { if (!owner.stateNode._warnedAboutRefsInRender) { error('%s is accessing findNodeHandle inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentNameFromType(owner.type) || 'A component'); } @@ -26986,7 +26983,7 @@ function findHostInstance_DEPRECATED(componentOrHandle) { } function findNodeHandle(componentOrHandle) { { - var owner = currentOwner; + var owner = current; if (owner !== null && owner.stateNode !== null) { if (!owner.stateNode._warnedAboutRefsInRender) { diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 43bd14c7a8dd9..fb4d0929f9a1e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<733cad6c24612b99f66a888f11d7a0aa>> + * @generated SignedSource<> */ "use strict"; @@ -1255,6 +1255,188 @@ function getComponentNameFromFiber(fiber) { } return null; } +var ReactSharedInternals = + React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, + prefix; +function describeBuiltInComponentFrame(name) { + if (void 0 === prefix) + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = (match && match[1]) || ""; + } + return "\n" + prefix + name; +} +var reentry = !1; +function describeNativeComponentFrame(fn, construct) { + if (!fn || reentry) return ""; + reentry = !0; + var previousPrepareStackTrace = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + try { + if (construct) { + var Fake = function () { + throw Error(); + }; + Object.defineProperty(Fake.prototype, "props", { + set: function () { + throw Error(); + } + }); + if ("object" === typeof Reflect && Reflect.construct) { + try { + Reflect.construct(Fake, []); + } catch (x) { + var control = x; + } + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x$1) { + control = x$1; + } + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x$2) { + control = x$2; + } + (Fake = fn()) && + "function" === typeof Fake.catch && + Fake.catch(function () {}); + } + } catch (sample) { + if (sample && control && "string" === typeof sample.stack) + return [sample.stack, control.stack]; + } + return [null, null]; + } + }; + RunInRootFrame.DetermineComponentFrameRoot.displayName = + "DetermineComponentFrameRoot"; + var namePropDescriptor = Object.getOwnPropertyDescriptor( + RunInRootFrame.DetermineComponentFrameRoot, + "name" + ); + namePropDescriptor && + namePropDescriptor.configurable && + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { + value: "DetermineComponentFrameRoot" + }); + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; + if (sampleStack && controlStack) { + var sampleLines = sampleStack.split("\n"), + controlLines = controlStack.split("\n"); + for ( + namePropDescriptor = RunInRootFrame = 0; + RunInRootFrame < sampleLines.length && + !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); + + ) + RunInRootFrame++; + for ( + ; + namePropDescriptor < controlLines.length && + !controlLines[namePropDescriptor].includes( + "DetermineComponentFrameRoot" + ); + + ) + namePropDescriptor++; + if ( + RunInRootFrame === sampleLines.length || + namePropDescriptor === controlLines.length + ) + for ( + RunInRootFrame = sampleLines.length - 1, + namePropDescriptor = controlLines.length - 1; + 1 <= RunInRootFrame && + 0 <= namePropDescriptor && + sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; + + ) + namePropDescriptor--; + for ( + ; + 1 <= RunInRootFrame && 0 <= namePropDescriptor; + RunInRootFrame--, namePropDescriptor-- + ) + if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { + if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { + do + if ( + (RunInRootFrame--, + namePropDescriptor--, + 0 > namePropDescriptor || + sampleLines[RunInRootFrame] !== + controlLines[namePropDescriptor]) + ) { + var frame = + "\n" + + sampleLines[RunInRootFrame].replace(" at new ", " at "); + fn.displayName && + frame.includes("") && + (frame = frame.replace("", fn.displayName)); + return frame; + } + while (1 <= RunInRootFrame && 0 <= namePropDescriptor); + } + break; + } + } + } finally { + (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); + } + return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") + ? describeBuiltInComponentFrame(previousPrepareStackTrace) + : ""; +} +function describeFiber(fiber) { + switch (fiber.tag) { + case 26: + case 27: + case 5: + return describeBuiltInComponentFrame(fiber.type); + case 16: + return describeBuiltInComponentFrame("Lazy"); + case 13: + return describeBuiltInComponentFrame("Suspense"); + case 19: + return describeBuiltInComponentFrame("SuspenseList"); + case 0: + case 15: + return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; + case 11: + return ( + (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber + ); + case 1: + return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; + default: + return ""; + } +} +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} function getNearestMountedFiber(fiber) { var node = fiber, nearestMounted = fiber; @@ -1303,36 +1485,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$1 = parentA.child; child$1; ) { - if (child$1 === a) { + for (var didFindChild = !1, child$3 = parentA.child; child$3; ) { + if (child$3 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$1 === b) { + if (child$3 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$1 = child$1.sibling; + child$3 = child$3.sibling; } if (!didFindChild) { - for (child$1 = parentB.child; child$1; ) { - if (child$1 === a) { + for (child$3 = parentB.child; child$3; ) { + if (child$3 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$1 === b) { + if (child$3 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$1 = child$1.sibling; + child$3 = child$3.sibling; } if (!didFindChild) throw Error( @@ -1363,9 +1545,7 @@ function findCurrentHostFiberImpl(node) { } return null; } -var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, - emptyObject$1 = {}, +var emptyObject$1 = {}, removedKeys = null, removedKeyCount = 0, deepDifferOptions = { unsafelyIgnoreFunctions: !0 }; @@ -1568,19 +1748,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var propKey$3 in prevProps) - void 0 === nextProps[propKey$3] && - (!(attributeConfig = validAttributes[propKey$3]) || - (updatePayload && void 0 !== updatePayload[propKey$3]) || - ((prevProp = prevProps[propKey$3]), + for (var propKey$5 in prevProps) + void 0 === nextProps[propKey$5] && + (!(attributeConfig = validAttributes[propKey$5]) || + (updatePayload && void 0 !== updatePayload[propKey$5]) || + ((prevProp = prevProps[propKey$5]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[propKey$3] = null), + ? (((updatePayload || (updatePayload = {}))[propKey$5] = null), removedKeys || (removedKeys = {}), - removedKeys[propKey$3] || - ((removedKeys[propKey$3] = !0), removedKeyCount++)) + removedKeys[propKey$5] || + ((removedKeys[propKey$5] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1857,18 +2037,18 @@ function markRootFinished(root, remainingLanes, spawnedLane) { 0 < noLongerPendingLanes; ) { - var index$7 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$7; - remainingLanes[index$7] = 0; - expirationTimes[index$7] = -1; - var hiddenUpdatesForLane = hiddenUpdates[index$7]; + var index$9 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$9; + remainingLanes[index$9] = 0; + expirationTimes[index$9] = -1; + var hiddenUpdatesForLane = hiddenUpdates[index$9]; if (null !== hiddenUpdatesForLane) for ( - hiddenUpdates[index$7] = null, index$7 = 0; - index$7 < hiddenUpdatesForLane.length; - index$7++ + hiddenUpdates[index$9] = null, index$9 = 0; + index$9 < hiddenUpdatesForLane.length; + index$9++ ) { - var update = hiddenUpdatesForLane[index$7]; + var update = hiddenUpdatesForLane[index$9]; null !== update && (update.lane &= -536870913); } noLongerPendingLanes &= ~lane; @@ -1888,10 +2068,10 @@ function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) { function markRootEntangled(root, entangledLanes) { var rootEntangledLanes = (root.entangledLanes |= entangledLanes); for (root = root.entanglements; rootEntangledLanes; ) { - var index$8 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$8; - (lane & entangledLanes) | (root[index$8] & entangledLanes) && - (root[index$8] |= entangledLanes); + var index$10 = 31 - clz32(rootEntangledLanes), + lane = 1 << index$10; + (lane & entangledLanes) | (root[index$10] & entangledLanes) && + (root[index$10] |= entangledLanes); rootEntangledLanes &= ~lane; } } @@ -2054,187 +2234,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - prefix; -function describeBuiltInComponentFrame(name) { - if (void 0 === prefix) - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = (match && match[1]) || ""; - } - return "\n" + prefix + name; -} -var reentry = !1; -function describeNativeComponentFrame(fn, construct) { - if (!fn || reentry) return ""; - reentry = !0; - var previousPrepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - try { - if (construct) { - var Fake = function () { - throw Error(); - }; - Object.defineProperty(Fake.prototype, "props", { - set: function () { - throw Error(); - } - }); - if ("object" === typeof Reflect && Reflect.construct) { - try { - Reflect.construct(Fake, []); - } catch (x) { - var control = x; - } - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x$10) { - control = x$10; - } - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x$11) { - control = x$11; - } - (Fake = fn()) && - "function" === typeof Fake.catch && - Fake.catch(function () {}); - } - } catch (sample) { - if (sample && control && "string" === typeof sample.stack) - return [sample.stack, control.stack]; - } - return [null, null]; - } - }; - RunInRootFrame.DetermineComponentFrameRoot.displayName = - "DetermineComponentFrameRoot"; - var namePropDescriptor = Object.getOwnPropertyDescriptor( - RunInRootFrame.DetermineComponentFrameRoot, - "name" - ); - namePropDescriptor && - namePropDescriptor.configurable && - Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { - value: "DetermineComponentFrameRoot" - }); - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; - if (sampleStack && controlStack) { - var sampleLines = sampleStack.split("\n"), - controlLines = controlStack.split("\n"); - for ( - namePropDescriptor = RunInRootFrame = 0; - RunInRootFrame < sampleLines.length && - !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); - - ) - RunInRootFrame++; - for ( - ; - namePropDescriptor < controlLines.length && - !controlLines[namePropDescriptor].includes( - "DetermineComponentFrameRoot" - ); - - ) - namePropDescriptor++; - if ( - RunInRootFrame === sampleLines.length || - namePropDescriptor === controlLines.length - ) - for ( - RunInRootFrame = sampleLines.length - 1, - namePropDescriptor = controlLines.length - 1; - 1 <= RunInRootFrame && - 0 <= namePropDescriptor && - sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; - - ) - namePropDescriptor--; - for ( - ; - 1 <= RunInRootFrame && 0 <= namePropDescriptor; - RunInRootFrame--, namePropDescriptor-- - ) - if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { - if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { - do - if ( - (RunInRootFrame--, - namePropDescriptor--, - 0 > namePropDescriptor || - sampleLines[RunInRootFrame] !== - controlLines[namePropDescriptor]) - ) { - var frame = - "\n" + - sampleLines[RunInRootFrame].replace(" at new ", " at "); - fn.displayName && - frame.includes("") && - (frame = frame.replace("", fn.displayName)); - return frame; - } - while (1 <= RunInRootFrame && 0 <= namePropDescriptor); - } - break; - } - } - } finally { - (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); - } - return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") - ? describeBuiltInComponentFrame(previousPrepareStackTrace) - : ""; -} -function describeFiber(fiber) { - switch (fiber.tag) { - case 26: - case 27: - case 5: - return describeBuiltInComponentFrame(fiber.type); - case 16: - return describeBuiltInComponentFrame("Lazy"); - case 13: - return describeBuiltInComponentFrame("Suspense"); - case 19: - return describeBuiltInComponentFrame("SuspenseList"); - case 0: - case 15: - return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; - case 11: - return ( - (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber - ); - case 1: - return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; - default: - return ""; - } -} -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - do - (info += describeFiber(workInProgress)), - (workInProgress = workInProgress.return); - while (workInProgress); - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} -var CapturedStacks = new WeakMap(); + CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { if ("object" === typeof value && null !== value) { var stack = CapturedStacks.get(value); @@ -2441,12 +2441,12 @@ function scheduleTaskForRootDuringMicrotask(root, currentTime) { 0 < lanes; ) { - var index$5 = 31 - clz32(lanes), - lane = 1 << index$5, - expirationTime = expirationTimes[index$5]; + var index$7 = 31 - clz32(lanes), + lane = 1 << index$7, + expirationTime = expirationTimes[index$7]; if (-1 === expirationTime) { if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$5] = computeExpirationTime(lane, currentTime); + expirationTimes[index$7] = computeExpirationTime(lane, currentTime); } else expirationTime <= currentTime && (root.expiredLanes |= lane); lanes &= ~lane; } @@ -9418,9 +9418,9 @@ function markRootSuspended(root, suspendedLanes, spawnedLane) { 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6; - expirationTimes[index$6] = -1; + var index$8 = 31 - clz32(lanes), + lane = 1 << index$8; + expirationTimes[index$8] = -1; lanes &= ~lane; } 0 !== spawnedLane && @@ -9520,9 +9520,9 @@ function prepareFreshStack(root, lanes) { 0 < allEntangledLanes; ) { - var index$4 = 31 - clz32(allEntangledLanes), - lane = 1 << index$4; - lanes |= root[index$4]; + var index$6 = 31 - clz32(allEntangledLanes), + lane = 1 << index$6; + lanes |= root[index$6]; allEntangledLanes &= ~lane; } entangledRenderLanes = lanes; @@ -10747,7 +10747,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1187 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "19.0.0-rc-f0eeab6c", + version: "19.0.0-rc-56edf199", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10790,7 +10790,7 @@ var internals$jscomp$inline_1434 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-rc-f0eeab6c" + reconcilerVersion: "19.0.0-rc-56edf199" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1435 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 408e0afeab0d6..1e17c3f0e45b7 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<415326cd3925711de700d738458faf6c>> + * @generated SignedSource<<97a595a3f85a65f2977dfd3658e3254b>> */ "use strict"; @@ -1259,6 +1259,188 @@ function getComponentNameFromFiber(fiber) { } return null; } +var ReactSharedInternals = + React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, + prefix; +function describeBuiltInComponentFrame(name) { + if (void 0 === prefix) + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = (match && match[1]) || ""; + } + return "\n" + prefix + name; +} +var reentry = !1; +function describeNativeComponentFrame(fn, construct) { + if (!fn || reentry) return ""; + reentry = !0; + var previousPrepareStackTrace = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + try { + if (construct) { + var Fake = function () { + throw Error(); + }; + Object.defineProperty(Fake.prototype, "props", { + set: function () { + throw Error(); + } + }); + if ("object" === typeof Reflect && Reflect.construct) { + try { + Reflect.construct(Fake, []); + } catch (x) { + var control = x; + } + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x$1) { + control = x$1; + } + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x$2) { + control = x$2; + } + (Fake = fn()) && + "function" === typeof Fake.catch && + Fake.catch(function () {}); + } + } catch (sample) { + if (sample && control && "string" === typeof sample.stack) + return [sample.stack, control.stack]; + } + return [null, null]; + } + }; + RunInRootFrame.DetermineComponentFrameRoot.displayName = + "DetermineComponentFrameRoot"; + var namePropDescriptor = Object.getOwnPropertyDescriptor( + RunInRootFrame.DetermineComponentFrameRoot, + "name" + ); + namePropDescriptor && + namePropDescriptor.configurable && + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { + value: "DetermineComponentFrameRoot" + }); + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; + if (sampleStack && controlStack) { + var sampleLines = sampleStack.split("\n"), + controlLines = controlStack.split("\n"); + for ( + namePropDescriptor = RunInRootFrame = 0; + RunInRootFrame < sampleLines.length && + !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); + + ) + RunInRootFrame++; + for ( + ; + namePropDescriptor < controlLines.length && + !controlLines[namePropDescriptor].includes( + "DetermineComponentFrameRoot" + ); + + ) + namePropDescriptor++; + if ( + RunInRootFrame === sampleLines.length || + namePropDescriptor === controlLines.length + ) + for ( + RunInRootFrame = sampleLines.length - 1, + namePropDescriptor = controlLines.length - 1; + 1 <= RunInRootFrame && + 0 <= namePropDescriptor && + sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; + + ) + namePropDescriptor--; + for ( + ; + 1 <= RunInRootFrame && 0 <= namePropDescriptor; + RunInRootFrame--, namePropDescriptor-- + ) + if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { + if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { + do + if ( + (RunInRootFrame--, + namePropDescriptor--, + 0 > namePropDescriptor || + sampleLines[RunInRootFrame] !== + controlLines[namePropDescriptor]) + ) { + var frame = + "\n" + + sampleLines[RunInRootFrame].replace(" at new ", " at "); + fn.displayName && + frame.includes("") && + (frame = frame.replace("", fn.displayName)); + return frame; + } + while (1 <= RunInRootFrame && 0 <= namePropDescriptor); + } + break; + } + } + } finally { + (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); + } + return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") + ? describeBuiltInComponentFrame(previousPrepareStackTrace) + : ""; +} +function describeFiber(fiber) { + switch (fiber.tag) { + case 26: + case 27: + case 5: + return describeBuiltInComponentFrame(fiber.type); + case 16: + return describeBuiltInComponentFrame("Lazy"); + case 13: + return describeBuiltInComponentFrame("Suspense"); + case 19: + return describeBuiltInComponentFrame("SuspenseList"); + case 0: + case 15: + return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; + case 11: + return ( + (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber + ); + case 1: + return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; + default: + return ""; + } +} +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} function getNearestMountedFiber(fiber) { var node = fiber, nearestMounted = fiber; @@ -1307,36 +1489,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$1 = parentA.child; child$1; ) { - if (child$1 === a) { + for (var didFindChild = !1, child$3 = parentA.child; child$3; ) { + if (child$3 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$1 === b) { + if (child$3 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$1 = child$1.sibling; + child$3 = child$3.sibling; } if (!didFindChild) { - for (child$1 = parentB.child; child$1; ) { - if (child$1 === a) { + for (child$3 = parentB.child; child$3; ) { + if (child$3 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$1 === b) { + if (child$3 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$1 = child$1.sibling; + child$3 = child$3.sibling; } if (!didFindChild) throw Error( @@ -1367,9 +1549,7 @@ function findCurrentHostFiberImpl(node) { } return null; } -var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, - emptyObject$1 = {}, +var emptyObject$1 = {}, removedKeys = null, removedKeyCount = 0, deepDifferOptions = { unsafelyIgnoreFunctions: !0 }; @@ -1572,19 +1752,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var propKey$3 in prevProps) - void 0 === nextProps[propKey$3] && - (!(attributeConfig = validAttributes[propKey$3]) || - (updatePayload && void 0 !== updatePayload[propKey$3]) || - ((prevProp = prevProps[propKey$3]), + for (var propKey$5 in prevProps) + void 0 === nextProps[propKey$5] && + (!(attributeConfig = validAttributes[propKey$5]) || + (updatePayload && void 0 !== updatePayload[propKey$5]) || + ((prevProp = prevProps[propKey$5]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[propKey$3] = null), + ? (((updatePayload || (updatePayload = {}))[propKey$5] = null), removedKeys || (removedKeys = {}), - removedKeys[propKey$3] || - ((removedKeys[propKey$3] = !0), removedKeyCount++)) + removedKeys[propKey$5] || + ((removedKeys[propKey$5] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1715,7 +1895,7 @@ function injectProfilingHooks(profilingHooks) { injectedProfilingHooks = profilingHooks; } function getLaneLabelMap() { - for (var map = new Map(), lane = 1, index$4 = 0; 31 > index$4; index$4++) { + for (var map = new Map(), lane = 1, index$6 = 0; 31 > index$6; index$6++) { var label = getLabelForLane(lane); map.set(lane, label); lane *= 2; @@ -1949,18 +2129,18 @@ function markRootFinished(root, remainingLanes, spawnedLane) { 0 < noLongerPendingLanes; ) { - var index$8 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$8; - remainingLanes[index$8] = 0; - expirationTimes[index$8] = -1; - var hiddenUpdatesForLane = hiddenUpdates[index$8]; + var index$10 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$10; + remainingLanes[index$10] = 0; + expirationTimes[index$10] = -1; + var hiddenUpdatesForLane = hiddenUpdates[index$10]; if (null !== hiddenUpdatesForLane) for ( - hiddenUpdates[index$8] = null, index$8 = 0; - index$8 < hiddenUpdatesForLane.length; - index$8++ + hiddenUpdates[index$10] = null, index$10 = 0; + index$10 < hiddenUpdatesForLane.length; + index$10++ ) { - var update = hiddenUpdatesForLane[index$8]; + var update = hiddenUpdatesForLane[index$10]; null !== update && (update.lane &= -536870913); } noLongerPendingLanes &= ~lane; @@ -1980,19 +2160,19 @@ function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) { function markRootEntangled(root, entangledLanes) { var rootEntangledLanes = (root.entangledLanes |= entangledLanes); for (root = root.entanglements; rootEntangledLanes; ) { - var index$9 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$9; - (lane & entangledLanes) | (root[index$9] & entangledLanes) && - (root[index$9] |= entangledLanes); + var index$11 = 31 - clz32(rootEntangledLanes), + lane = 1 << index$11; + (lane & entangledLanes) | (root[index$11] & entangledLanes) && + (root[index$11] |= entangledLanes); rootEntangledLanes &= ~lane; } } function addFiberToLanesMap(root, fiber, lanes) { if (isDevToolsPresent) for (root = root.pendingUpdatersLaneMap; 0 < lanes; ) { - var index$10 = 31 - clz32(lanes), - lane = 1 << index$10; - root[index$10].add(fiber); + var index$12 = 31 - clz32(lanes), + lane = 1 << index$12; + root[index$12].add(fiber); lanes &= ~lane; } } @@ -2004,16 +2184,16 @@ function movePendingFibersToMemoized(root, lanes) { 0 < lanes; ) { - var index$11 = 31 - clz32(lanes); - root = 1 << index$11; - index$11 = pendingUpdatersLaneMap[index$11]; - 0 < index$11.size && - (index$11.forEach(function (fiber) { + var index$13 = 31 - clz32(lanes); + root = 1 << index$13; + index$13 = pendingUpdatersLaneMap[index$13]; + 0 < index$13.size && + (index$13.forEach(function (fiber) { var alternate = fiber.alternate; (null !== alternate && memoizedUpdaters.has(alternate)) || memoizedUpdaters.add(fiber); }), - index$11.clear()); + index$13.clear()); lanes &= ~root; } } @@ -2176,187 +2356,7 @@ function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } var objectIs = "function" === typeof Object.is ? Object.is : is, - prefix; -function describeBuiltInComponentFrame(name) { - if (void 0 === prefix) - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = (match && match[1]) || ""; - } - return "\n" + prefix + name; -} -var reentry = !1; -function describeNativeComponentFrame(fn, construct) { - if (!fn || reentry) return ""; - reentry = !0; - var previousPrepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - try { - if (construct) { - var Fake = function () { - throw Error(); - }; - Object.defineProperty(Fake.prototype, "props", { - set: function () { - throw Error(); - } - }); - if ("object" === typeof Reflect && Reflect.construct) { - try { - Reflect.construct(Fake, []); - } catch (x) { - var control = x; - } - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x$13) { - control = x$13; - } - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x$14) { - control = x$14; - } - (Fake = fn()) && - "function" === typeof Fake.catch && - Fake.catch(function () {}); - } - } catch (sample) { - if (sample && control && "string" === typeof sample.stack) - return [sample.stack, control.stack]; - } - return [null, null]; - } - }; - RunInRootFrame.DetermineComponentFrameRoot.displayName = - "DetermineComponentFrameRoot"; - var namePropDescriptor = Object.getOwnPropertyDescriptor( - RunInRootFrame.DetermineComponentFrameRoot, - "name" - ); - namePropDescriptor && - namePropDescriptor.configurable && - Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, "name", { - value: "DetermineComponentFrameRoot" - }); - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; - if (sampleStack && controlStack) { - var sampleLines = sampleStack.split("\n"), - controlLines = controlStack.split("\n"); - for ( - namePropDescriptor = RunInRootFrame = 0; - RunInRootFrame < sampleLines.length && - !sampleLines[RunInRootFrame].includes("DetermineComponentFrameRoot"); - - ) - RunInRootFrame++; - for ( - ; - namePropDescriptor < controlLines.length && - !controlLines[namePropDescriptor].includes( - "DetermineComponentFrameRoot" - ); - - ) - namePropDescriptor++; - if ( - RunInRootFrame === sampleLines.length || - namePropDescriptor === controlLines.length - ) - for ( - RunInRootFrame = sampleLines.length - 1, - namePropDescriptor = controlLines.length - 1; - 1 <= RunInRootFrame && - 0 <= namePropDescriptor && - sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]; - - ) - namePropDescriptor--; - for ( - ; - 1 <= RunInRootFrame && 0 <= namePropDescriptor; - RunInRootFrame--, namePropDescriptor-- - ) - if (sampleLines[RunInRootFrame] !== controlLines[namePropDescriptor]) { - if (1 !== RunInRootFrame || 1 !== namePropDescriptor) { - do - if ( - (RunInRootFrame--, - namePropDescriptor--, - 0 > namePropDescriptor || - sampleLines[RunInRootFrame] !== - controlLines[namePropDescriptor]) - ) { - var frame = - "\n" + - sampleLines[RunInRootFrame].replace(" at new ", " at "); - fn.displayName && - frame.includes("") && - (frame = frame.replace("", fn.displayName)); - return frame; - } - while (1 <= RunInRootFrame && 0 <= namePropDescriptor); - } - break; - } - } - } finally { - (reentry = !1), (Error.prepareStackTrace = previousPrepareStackTrace); - } - return (previousPrepareStackTrace = fn ? fn.displayName || fn.name : "") - ? describeBuiltInComponentFrame(previousPrepareStackTrace) - : ""; -} -function describeFiber(fiber) { - switch (fiber.tag) { - case 26: - case 27: - case 5: - return describeBuiltInComponentFrame(fiber.type); - case 16: - return describeBuiltInComponentFrame("Lazy"); - case 13: - return describeBuiltInComponentFrame("Suspense"); - case 19: - return describeBuiltInComponentFrame("SuspenseList"); - case 0: - case 15: - return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; - case 11: - return ( - (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber - ); - case 1: - return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; - default: - return ""; - } -} -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - do - (info += describeFiber(workInProgress)), - (workInProgress = workInProgress.return); - while (workInProgress); - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} -var CapturedStacks = new WeakMap(); + CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { if ("object" === typeof value && null !== value) { var stack = CapturedStacks.get(value); @@ -2563,12 +2563,12 @@ function scheduleTaskForRootDuringMicrotask(root, currentTime) { 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6, - expirationTime = expirationTimes[index$6]; + var index$8 = 31 - clz32(lanes), + lane = 1 << index$8, + expirationTime = expirationTimes[index$8]; if (-1 === expirationTime) { if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$6] = computeExpirationTime(lane, currentTime); + expirationTimes[index$8] = computeExpirationTime(lane, currentTime); } else expirationTime <= currentTime && (root.expiredLanes |= lane); lanes &= ~lane; } @@ -9949,9 +9949,9 @@ function markRootSuspended(root, suspendedLanes, spawnedLane) { 0 < lanes; ) { - var index$7 = 31 - clz32(lanes), - lane = 1 << index$7; - expirationTimes[index$7] = -1; + var index$9 = 31 - clz32(lanes), + lane = 1 << index$9; + expirationTimes[index$9] = -1; lanes &= ~lane; } 0 !== spawnedLane && @@ -10053,9 +10053,9 @@ function prepareFreshStack(root, lanes) { 0 < allEntangledLanes; ) { - var index$5 = 31 - clz32(allEntangledLanes), - lane = 1 << index$5; - lanes |= root[index$5]; + var index$7 = 31 - clz32(allEntangledLanes), + lane = 1 << index$7; + lanes |= root[index$7]; allEntangledLanes &= ~lane; } entangledRenderLanes = lanes; @@ -11453,7 +11453,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1267 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "19.0.0-rc-be316bc9", + version: "19.0.0-rc-18d64a29", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -11509,7 +11509,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-rc-be316bc9" + reconcilerVersion: "19.0.0-rc-18d64a29" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) {