diff --git a/package.json b/package.json index b2687437d474..92adbf572afe 100644 --- a/package.json +++ b/package.json @@ -108,8 +108,8 @@ "node-fetch": "^2.2.0", "nullthrows": "^1.1.1", "prettier": "3.9.4", - "react": "19.2.3", - "react-test-renderer": "19.2.3", + "react": "19.3.0", + "react-test-renderer": "19.3.0", "rimraf": "^3.0.2", "shelljs": "^0.8.5", "signedsource": "^2.0.0", diff --git a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js index daab0e35a8e5..615eb9178009 100644 --- a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js +++ b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<12e935271cee5bbb34114c56f570f060>> * * This file was sync'd from the facebook/react repository. */ @@ -33,43 +33,22 @@ __DEV__ && : emptyObject; } function createHierarchy(fiberHierarchy) { - return fiberHierarchy.map(function (fiber$jscomp$0) { + return fiberHierarchy.map(function (fiber) { return { - name: getComponentNameFromType(fiber$jscomp$0.type), + name: getComponentNameFromType(fiber.type), getInspectorData: function () { return { - props: getHostProps(fiber$jscomp$0), + props: getHostProps(fiber), measure: function (callback) { - var hostFiber = findCurrentHostFiber(fiber$jscomp$0); - if ( - (hostFiber = - null != hostFiber && - null !== hostFiber.stateNode && - hostFiber.stateNode.node) - ) - nativeFabricUIManager.measure(hostFiber, callback); - else { - hostFiber = ReactNativePrivateInterface.UIManager; - var JSCompiler_temp_const = hostFiber.measure, - JSCompiler_inline_result; - a: { - for (var fiber = fiber$jscomp$0; fiber; ) { - null !== fiber.stateNode && - 5 === fiber.tag && - (JSCompiler_inline_result = findNodeHandle( - fiber.stateNode - )); - if (JSCompiler_inline_result) break a; - fiber = fiber.child; - } - JSCompiler_inline_result = null; - } - return JSCompiler_temp_const.call( + var hostFiber = findCurrentHostFiber(fiber); + (hostFiber = + null != hostFiber && + null !== hostFiber.stateNode && + hostFiber.stateNode.node) && + reactPrivateInterface.fabricUIManager.measure( hostFiber, - JSCompiler_inline_result, callback ); - } } }; } @@ -181,6 +160,19 @@ __DEV__ && function batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); } + function currentTimeStamp() { + currentTimeStamp = + "object" === typeof performance && + null !== performance && + "function" === typeof performance.now + ? function () { + return performance.now(); + } + : function () { + return Date.now(); + }; + return currentTimeStamp(); + } function disabledLog() {} function disableLogs() { if (0 === disabledDepth) { @@ -302,7 +294,30 @@ __DEV__ && } catch (x$1) { control = x$1; } - fn.call(Fake.prototype); + Fake = !1; + try { + var prevProps = Object.getOwnPropertyDescriptor( + fn.prototype, + "props" + ); + Object.defineProperty(fn.prototype, "props", { + configurable: !0, + set: function () { + throw Error(); + } + }); + Fake = !0; + new fn(); + } finally { + Fake && + (void 0 !== prevProps + ? Object.defineProperty( + fn.prototype, + "props", + prevProps + ) + : delete fn.prototype.props); + } } } else { try { @@ -444,6 +459,8 @@ __DEV__ && return describeNativeComponentFrame(fiber.type, !0); case 31: return describeBuiltInComponentFrame("Activity"); + case 30: + return describeBuiltInComponentFrame("ViewTransition"); default: return ""; } @@ -522,6 +539,8 @@ __DEV__ && return "SuspenseList"; case REACT_ACTIVITY_TYPE: return "Activity"; + case REACT_VIEW_TRANSITION_TYPE: + return "ViewTransition"; } if ("object" === typeof type) switch ( @@ -597,7 +616,9 @@ __DEV__ && case 8: return type === REACT_STRICT_MODE_TYPE ? "StrictMode" : "Mode"; case 22: - return "Offscreen"; + if (null !== fiber.return) + return getComponentNameFromFiber(fiber.return); + break; case 12: return "Profiler"; case 21: @@ -609,6 +630,7 @@ __DEV__ && case 25: return "TracingMarker"; case 30: + return "ViewTransition"; case 17: case 28: case 1: @@ -651,6 +673,8 @@ __DEV__ && info += describeBuiltInComponentFrame("Activity"); break; case 30: + info += describeBuiltInComponentFrame("ViewTransition"); + break; case 0: case 15: case 1: @@ -730,11 +754,14 @@ __DEV__ && } function executeDispatch(event, listener, inst) { event.currentTarget = getNodeFromInstance$1(inst); + inst = global.event; + global.event = event; try { listener(event); } catch (error) { hasError || ((hasError = !0), (caughtError = error)); } + global.event = inst; event.currentTarget = null; } function executeDirectDispatch(event) { @@ -1257,49 +1284,70 @@ __DEV__ && e.isPersistent() || e.constructor.release(e); } } - function dispatchEvent(target, topLevelType, nativeEvent) { - var eventTarget = null; - if (null != target) { - var stateNode = target.stateNode; - null != stateNode && (eventTarget = getPublicInstance(stateNode)); - } + function dispatchEvent(target, topLevelType, nativeEventParam) { + var nativeEvent = + null != nativeEventParam && "object" === typeof nativeEventParam + ? nativeEventParam + : {}, + eventTarget = null; + null != target && + ((nativeEventParam = target.stateNode), + null != nativeEventParam && + (eventTarget = getPublicInstance(nativeEventParam))); batchedUpdates$1(function () { var event = { eventName: topLevelType, nativeEvent: nativeEvent }; - ReactNativePrivateInterface.RawEventEmitter.emit(topLevelType, event); - ReactNativePrivateInterface.RawEventEmitter.emit("*", event); - event = eventTarget; - for ( - var events = null, legacyPlugins = plugins, i = 0; - i < legacyPlugins.length; - i++ - ) { - var possiblePlugin = legacyPlugins[i]; - possiblePlugin && - (possiblePlugin = possiblePlugin.extractEvents( + reactPrivateInterface.RawEventEmitter.emit(topLevelType, event); + reactPrivateInterface.RawEventEmitter.emit("*", event); + null == _enableNativeEventTargetEventDispatching && + ((event = + null != reactPrivateInterface.ReactNativeFeatureFlags + ? reactPrivateInterface.ReactNativeFeatureFlags + .enableNativeEventTargetEventDispatching + : null), + (_enableNativeEventTargetEventDispatching = + "function" === typeof event && event())); + if (_enableNativeEventTargetEventDispatching) + null != eventTarget && + reactPrivateInterface.dispatchNativeEvent( + eventTarget, topLevelType, - target, - nativeEvent, - event - )) && - (events = accumulateInto(events, possiblePlugin)); - } - event = events; - null !== event && (eventQueue = accumulateInto(eventQueue, event)); - event = eventQueue; - eventQueue = null; - if (event) { - forEachAccumulated(event, executeDispatchesAndReleaseTopLevel); - if (eventQueue) - throw Error( - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ); - if (hasError) - throw ( - ((event = caughtError), - (hasError = !1), - (caughtError = null), - event) + nativeEvent ); + else { + event = eventTarget; + for ( + var events = null, legacyPlugins = plugins, i = 0; + i < legacyPlugins.length; + i++ + ) { + var possiblePlugin = legacyPlugins[i]; + possiblePlugin && + (possiblePlugin = possiblePlugin.extractEvents( + topLevelType, + target, + nativeEvent, + event + )) && + (events = accumulateInto(events, possiblePlugin)); + } + event = events; + null !== event && (eventQueue = accumulateInto(eventQueue, event)); + event = eventQueue; + eventQueue = null; + if (event) { + forEachAccumulated(event, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw Error( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasError) + throw ( + ((event = caughtError), + (hasError = !1), + (caughtError = null), + event) + ); + } } }); } @@ -1370,7 +1418,7 @@ __DEV__ && case 32768: case 65536: case 131072: - return lanes & 261888; + return lanes & -lanes; case 262144: case 524288: case 1048576: @@ -1449,6 +1497,22 @@ __DEV__ && renderLanes) ); } + function getEntangledLanes(root, renderLanes) { + 0 !== (renderLanes & 8) && (renderLanes |= renderLanes & 32); + var allEntangledLanes = root.entangledLanes; + if (0 !== allEntangledLanes) + for ( + root = root.entanglements, allEntangledLanes &= renderLanes; + 0 < allEntangledLanes; + + ) { + var index = 31 - clz32(allEntangledLanes), + lane = 1 << index; + renderLanes |= root[index]; + allEntangledLanes &= ~lane; + } + return renderLanes; + } function computeExpirationTime(lane, currentTime) { switch (lane) { case 1: @@ -1664,18 +1728,12 @@ __DEV__ && : DiscreteEventPriority; } function getNearestMountedFiber(fiber) { - var node = fiber, - nearestMounted = fiber; - if (fiber.alternate) for (; node.return; ) node = node.return; - else { - fiber = node; - do - (node = fiber), - 0 !== (node.flags & 4098) && (nearestMounted = node.return), - (fiber = node.return); - while (fiber); - } - return 3 === node.tag ? nearestMounted : null; + for (var node = fiber, nextNode = node; nextNode && !nextNode.alternate; ) + (node = nextNode), + 0 !== (node.flags & 4098) && (fiber = node.return), + (nextNode = node.return); + for (; node.return; ) node = node.return; + return 3 === node.tag ? fiber : null; } function assertIsMounted(fiber) { if (getNearestMountedFiber(fiber) !== fiber) @@ -1771,15 +1829,64 @@ __DEV__ && } return null; } - function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) + function traverseVisibleInstancesAndTextInstances( + child, + searchWithinHosts, + fn, + a, + b, + c + ) { + for (; null !== child; ) { + if ( + ((5 === child.tag || 27 === child.tag || 6 === child.tag) && + fn(child, a, b, c)) || + ((22 !== child.tag || null === child.memoizedState) && + (searchWithinHosts || (5 !== child.tag && 27 !== child.tag)) && + traverseVisibleInstancesAndTextInstances( + child.child, + searchWithinHosts, + fn, + a, + b, + c + )) + ) + return !0; + child = child.sibling; + } + return !1; + } + function getFragmentParentInstanceOrContainerFiber(fiber) { + for (fiber = fiber.return; null !== fiber; ) { + if (3 === fiber.tag || 5 === fiber.tag || 27 === fiber.tag) + return fiber; + fiber = fiber.return; + } + return null; + } + function findFragmentInstanceOrTextInstanceSiblings( + result, + self, + child, + state + ) { + for (; null !== child; ) { + if (child === self) state.foundSelf = !0; + else if (5 === child.tag || 27 === child.tag || 6 === child.tag) { + if (state.foundSelf) return (result[1] = child), !0; + result[0] = child; + } else if ( + (22 !== child.tag || null === child.memoizedState) && + findFragmentInstanceOrTextInstanceSiblings( + result, + self, + child.child, + state + ) + ) return !0; - childFiber = childFiber.return; + child = child.sibling; } return !1; } @@ -1802,11 +1909,45 @@ __DEV__ && fiberStack[index$jscomp$0] = fiber; cursor.current = value; } + function getViewTransitionName(props, instance) { + if (null != props.name && "auto" !== props.name) return props.name; + if (null !== instance.autoName) return instance.autoName; + props = pendingEffectsRoot.identifierPrefix; + var globalClientId = globalClientIdCounter$1++; + props = "_" + props + "t_" + globalClientId.toString(32) + "_"; + return (instance.autoName = props); + } + function getClassNameByType(classByType) { + if (null == classByType || "string" === typeof classByType) + return classByType; + var className = null, + activeTypes = pendingTransitionTypes; + if (null !== activeTypes) + for (var i = 0; i < activeTypes.length; i++) { + var match = classByType[activeTypes[i]]; + if (null != match) { + if ("none" === match) return "none"; + className = null == className ? match : className + (" " + match); + } + } + return null == className ? classByType.default : className; + } + function getViewTransitionClassName(defaultClass, eventClass) { + defaultClass = getClassNameByType(defaultClass); + eventClass = getClassNameByType(eventClass); + return null == eventClass + ? "auto" === defaultClass + ? null + : defaultClass + : "auto" === eventClass + ? null + : eventClass; + } function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } function getArrayKind(array) { - for (var kind = 0, i = 0; i < array.length; i++) { + for (var kind = 0, i = 0; i < array.length && 100 > i; i++) { var value = array[i]; if ("object" === typeof value && null !== value) if ( @@ -1821,7 +1962,8 @@ __DEV__ && if ( "function" === typeof value || ("string" === typeof value && 50 < value.length) || - (0 !== kind && 2 !== kind) + (0 !== kind && 2 !== kind) || + "bigint" === typeof value ) return 1; kind = 2; @@ -1830,10 +1972,31 @@ __DEV__ && return kind; } function addObjectToProperties(object, properties, indent, prefix) { - for (var key in object) - hasOwnProperty.call(object, key) && - "_" !== key[0] && - addValueToProperties(key, object[key], properties, indent, prefix); + if (!ArrayBuffer.isView(object)) { + var addedProperties = 0, + key; + for (key in object) + if ( + hasOwnProperty.call(object, key) && + "_" !== key[0] && + (addedProperties++, + addValueToProperties(key, object[key], properties, indent, prefix), + 100 <= addedProperties) + ) { + properties.push([ + prefix + + "\u00a0\u00a0".repeat(indent) + + "Only 100 properties are shown. React will not log more properties of this object.", + "" + ]); + break; + } + } + } + function readReactElementTypeof(value) { + return "$$typeof" in value && hasOwnProperty.call(value, "$$typeof") + ? value.$$typeof + : void 0; } function addValueToProperties( propertyName, @@ -1848,7 +2011,7 @@ __DEV__ && value = "null"; break; } else { - if (value.$$typeof === REACT_ELEMENT_TYPE) { + if (readReactElementTypeof(value) === REACT_ELEMENT_TYPE) { var typeName = getComponentNameFromType(value.type) || "\u2026", key = value.key; value = value.props; @@ -1880,21 +2043,27 @@ __DEV__ && prefix ); propertyName = !1; + key = 0; for (var propKey in value) - "children" === propKey - ? null != value.children && - (!isArrayImpl(value.children) || - 0 < value.children.length) && - (propertyName = !0) - : hasOwnProperty.call(value, propKey) && - "_" !== propKey[0] && - addValueToProperties( - propKey, - value[propKey], - properties, - indent + 1, - prefix - ); + if ( + (key++, + "children" === propKey + ? null != value.children && + (!isArrayImpl(value.children) || + 0 < value.children.length) && + (propertyName = !0) + : hasOwnProperty.call(value, propKey) && + "_" !== propKey[0] && + addValueToProperties( + propKey, + value[propKey], + properties, + indent + 1, + prefix + ), + 100 <= key) + ) + break; properties.push([ "", propertyName ? ">\u2026" : "/>" @@ -1903,21 +2072,32 @@ __DEV__ && } typeName = Object.prototype.toString.call(value); typeName = typeName.slice(8, typeName.length - 1); + if (ArrayBuffer.isView(value)) { + value = value.length; + value = + "number" === typeof value + ? typeName + "(" + value + ")" + : typeName; + break; + } if ("Array" === typeName) if ( - ((propKey = getArrayKind(value)), - 2 === propKey || 0 === propKey) + ((propKey = 100 < value.length), + (key = getArrayKind(value)), + 2 === key || 0 === key) ) { - value = JSON.stringify(value); + value = JSON.stringify( + propKey ? value.slice(0, 100).concat("\u2026") : value + ); break; - } else if (3 === propKey) { + } else if (3 === key) { properties.push([ prefix + "\u00a0\u00a0".repeat(indent) + propertyName, "" ]); for ( propertyName = 0; - propertyName < value.length; + propertyName < value.length && 100 > propertyName; propertyName++ ) (typeName = value[propertyName]), @@ -1928,6 +2108,14 @@ __DEV__ && indent + 1, prefix ); + propKey && + addValueToProperties( + (100).toString(), + "\u2026", + properties, + indent + 1, + prefix + ); return; } if ("Promise" === typeName) { @@ -1983,14 +2171,20 @@ __DEV__ && return; } case "function": - value = "" === value.name ? "() => {}" : value.name + "() {}"; + value = value.name; + value = + "" === value || "string" !== typeof value + ? "() => {}" + : value + "() {}"; break; case "string": value = "This object has been omitted by React in the console log to avoid sending too much data from the server. Try logging smaller or more specific objects." === value ? "\u2026" - : JSON.stringify(value); + : JSON.stringify( + 1024 <= value.length ? value.slice(0, 1023) + "\u2026" : value + ); break; case "undefined": value = "undefined"; @@ -2007,112 +2201,125 @@ __DEV__ && ]); } function addObjectDiffToProperties(prev, next, properties, indent) { - var isDeeplyEqual = !0; - for (key in prev) + var isDeeplyEqual = !0, + prevPropertiesChecked = 0; + for (key in prev) { + if (100 < prevPropertiesChecked) { + properties.push([ + "Previous object has more than 100 properties. React will not attempt to diff objects with too many properties.", + "" + ]); + isDeeplyEqual = !1; + break; + } key in next || (properties.push([ - "\u2013\u00a0" + "\u00a0\u00a0".repeat(indent) + key, + "-\u00a0" + "\u00a0\u00a0".repeat(indent) + key, "\u2026" ]), (isDeeplyEqual = !1)); - for (var _key in next) + prevPropertiesChecked++; + } + prevPropertiesChecked = 0; + for (var _key in next) { + if (100 < prevPropertiesChecked) { + properties.push([ + "Next object has more than 100 properties. React will not attempt to diff objects with too many properties.", + "" + ]); + isDeeplyEqual = !1; + break; + } if (_key in prev) { var key = prev[_key]; var nextValue = next[_key]; if (key !== nextValue) { - if (0 === indent && "children" === _key) - (isDeeplyEqual = "\u00a0\u00a0".repeat(indent) + _key), - properties.push( - ["\u2013\u00a0" + isDeeplyEqual, "\u2026"], - ["+\u00a0" + isDeeplyEqual, "\u2026"] - ); - else { - if (!(3 <= indent)) - if ( - "object" === typeof key && - "object" === typeof nextValue && - null !== key && - null !== nextValue && - key.$$typeof === nextValue.$$typeof - ) - if (nextValue.$$typeof === REACT_ELEMENT_TYPE) { - if ( - key.type === nextValue.type && - key.key === nextValue.key - ) { - key = - getComponentNameFromType(nextValue.type) || "\u2026"; - isDeeplyEqual = "\u00a0\u00a0".repeat(indent) + _key; - key = "<" + key + " \u2026 />"; - properties.push( - ["\u2013\u00a0" + isDeeplyEqual, key], - ["+\u00a0" + isDeeplyEqual, key] - ); - isDeeplyEqual = !1; - continue; - } - } else { - var prevKind = Object.prototype.toString.call(key), - nextKind = Object.prototype.toString.call(nextValue); - if ( - prevKind === nextKind && - ("[object Object]" === nextKind || - "[object Array]" === nextKind) - ) { - prevKind = [ - "\u2007\u00a0" + "\u00a0\u00a0".repeat(indent) + _key, - "[object Array]" === nextKind ? "Array" : "" - ]; - properties.push(prevKind); - nextKind = properties.length; - addObjectDiffToProperties( - key, - nextValue, - properties, - indent + 1 - ) - ? nextKind === properties.length && - (prevKind[1] = - "Referentially unequal but deeply equal objects. Consider memoization.") - : (isDeeplyEqual = !1); - continue; - } - } - else if ( - "function" === typeof key && - "function" === typeof nextValue && - key.name === nextValue.name && - key.length === nextValue.length && - ((prevKind = Function.prototype.toString.call(key)), - (nextKind = Function.prototype.toString.call(nextValue)), - prevKind === nextKind) - ) { - key = - "" === nextValue.name - ? "() => {}" - : nextValue.name + "() {}"; - properties.push([ - "\u2007\u00a0" + "\u00a0\u00a0".repeat(indent) + _key, - key + - " Referentially unequal function closure. Consider memoization." - ]); - continue; - } - addValueToProperties( - _key, - key, - properties, - indent, - "\u2013\u00a0" - ); - addValueToProperties( - _key, - nextValue, - properties, - indent, - "+\u00a0" + if (0 === indent && "children" === _key) { + isDeeplyEqual = "\u00a0\u00a0".repeat(indent) + _key; + properties.push( + ["-\u00a0" + isDeeplyEqual, "\u2026"], + ["+\u00a0" + isDeeplyEqual, "\u2026"] ); + isDeeplyEqual = !1; + continue; } + if (!(3 <= indent)) + if ( + "object" === typeof key && + "object" === typeof nextValue && + null !== key && + null !== nextValue && + readReactElementTypeof(key) === + readReactElementTypeof(nextValue) + ) + if (readReactElementTypeof(nextValue) === REACT_ELEMENT_TYPE) { + if ( + key.type === nextValue.type && + key.key === nextValue.key + ) { + key = getComponentNameFromType(nextValue.type) || "\u2026"; + isDeeplyEqual = "\u00a0\u00a0".repeat(indent) + _key; + key = "<" + key + " \u2026 />"; + properties.push( + ["-\u00a0" + isDeeplyEqual, key], + ["+\u00a0" + isDeeplyEqual, key] + ); + isDeeplyEqual = !1; + continue; + } + } else { + var prevKind = Object.prototype.toString.call(key), + nextKind = Object.prototype.toString.call(nextValue); + if ( + prevKind === nextKind && + ("[object Object]" === nextKind || + "[object Array]" === nextKind) + ) { + prevKind = [ + "\u2007\u00a0" + "\u00a0\u00a0".repeat(indent) + _key, + "[object Array]" === nextKind ? "Array" : "" + ]; + properties.push(prevKind); + nextKind = properties.length; + addObjectDiffToProperties( + key, + nextValue, + properties, + indent + 1 + ) + ? nextKind === properties.length && + (prevKind[1] = + "Referentially unequal but deeply equal objects. Consider memoization.") + : (isDeeplyEqual = !1); + continue; + } + } + else if ( + "function" === typeof key && + "function" === typeof nextValue && + key.name === nextValue.name && + key.length === nextValue.length && + ((prevKind = Function.prototype.toString.call(key)), + (nextKind = Function.prototype.toString.call(nextValue)), + prevKind === nextKind) + ) { + key = + "" === nextValue.name ? "() => {}" : nextValue.name + "() {}"; + properties.push([ + "\u2007\u00a0" + "\u00a0\u00a0".repeat(indent) + _key, + key + + " Referentially unequal function closure. Consider memoization." + ]); + continue; + } + addValueToProperties(_key, key, properties, indent, "-\u00a0"); + addValueToProperties( + _key, + nextValue, + properties, + indent, + "+\u00a0" + ); isDeeplyEqual = !1; } } else @@ -2121,6 +2328,8 @@ __DEV__ && "\u2026" ]), (isDeeplyEqual = !1); + prevPropertiesChecked++; + } return isDeeplyEqual; } function setCurrentTrackFromLanes(lanes) { @@ -2152,7 +2361,8 @@ __DEV__ && reusableComponentOptions ) ) - : performance.measure(trigger, reusableComponentOptions)); + : performance.measure(trigger, reusableComponentOptions), + performance.clearMeasures(trigger)); } function logComponentReappeared(fiber, startTime, endTime) { logComponentTrigger(fiber, startTime, endTime, "Reconnect"); @@ -2171,7 +2381,7 @@ __DEV__ && if (null === alternate || alternate.child !== fiber.child) for (var child = fiber.child; null !== child; child = child.sibling) selfTime -= child.actualDuration; - wasHydrated = + selfTime = 0.5 > selfTime ? wasHydrated ? "tertiary-light" @@ -2186,46 +2396,65 @@ __DEV__ && : "primary-dark" : "error"; var props = fiber.memoizedProps; - selfTime = fiber._debugTask; + wasHydrated = fiber._debugTask; null !== props && null !== alternate && alternate.memoizedProps !== props - ? ((child = [resuableChangedPropsEntry]), + ? ((child = [reusableChangedPropsEntry]), (props = addObjectDiffToProperties( alternate.memoizedProps, props, child, 0 )), - 1 < child.length && - (props && - !alreadyWarnedForDeepEquality && - 0 === (alternate.lanes & committedLanes) && - 100 < fiber.actualDuration - ? ((alreadyWarnedForDeepEquality = !0), - (child[0] = reusableDeeplyEqualPropsEntry), - (reusableComponentDevToolDetails.color = "warning"), - (reusableComponentDevToolDetails.tooltipText = - "This component received deeply equal props. It might benefit from useMemo or the React Compiler in its owner.")) - : ((reusableComponentDevToolDetails.color = wasHydrated), - (reusableComponentDevToolDetails.tooltipText = name)), - (reusableComponentDevToolDetails.properties = child), - (reusableComponentOptions.start = startTime), - (reusableComponentOptions.end = endTime), - null != selfTime - ? selfTime.run( - performance.measure.bind( - performance, - "\u200b" + name, - reusableComponentOptions + 1 < child.length + ? (props && + !alreadyWarnedForDeepEquality && + 0 === (alternate.lanes & committedLanes) && + 100 < fiber.actualDuration + ? ((alreadyWarnedForDeepEquality = !0), + (child[0] = reusableDeeplyEqualPropsEntry), + (reusableComponentDevToolDetails.color = "warning"), + (reusableComponentDevToolDetails.tooltipText = + "This component received deeply equal props. It might benefit from useMemo or the React Compiler in its owner.")) + : ((reusableComponentDevToolDetails.color = selfTime), + (reusableComponentDevToolDetails.tooltipText = name)), + (reusableComponentDevToolDetails.properties = child), + (reusableComponentOptions.start = startTime), + (reusableComponentOptions.end = endTime), + (fiber = "\u200b" + name), + null != wasHydrated + ? wasHydrated.run( + performance.measure.bind( + performance, + fiber, + reusableComponentOptions + ) + ) + : performance.measure(fiber, reusableComponentOptions), + performance.clearMeasures(fiber)) + : null != wasHydrated + ? wasHydrated.run( + console.timeStamp.bind( + console, + name, + startTime, + endTime, + "Components \u269b", + void 0, + selfTime ) ) - : performance.measure( - "\u200b" + name, - reusableComponentOptions - ))) - : null != selfTime - ? selfTime.run( + : console.timeStamp( + name, + startTime, + endTime, + "Components \u269b", + void 0, + selfTime + )) + : null != wasHydrated + ? wasHydrated.run( console.timeStamp.bind( console, name, @@ -2233,7 +2462,7 @@ __DEV__ && endTime, "Components \u269b", void 0, - wasHydrated + selfTime ) ) : console.timeStamp( @@ -2242,7 +2471,7 @@ __DEV__ && endTime, "Components \u269b", void 0, - wasHydrated + selfTime ); } } @@ -2289,11 +2518,11 @@ __DEV__ && } } }; + name = "\u200b" + name; debugTask - ? debugTask.run( - performance.measure.bind(performance, "\u200b" + name, fiber) - ) - : performance.measure("\u200b" + name, fiber); + ? debugTask.run(performance.measure.bind(performance, name, fiber)) + : performance.measure(name, fiber); + performance.clearMeasures(name); } } } @@ -2330,15 +2559,14 @@ __DEV__ && } } }; - (fiber = fiber._debugTask) + fiber = fiber._debugTask; + endTime = "\u200b" + name; + fiber ? fiber.run( - performance.measure.bind( - performance, - "\u200b" + name, - startTime - ) + performance.measure.bind(performance, endTime, startTime) ) - : performance.measure("\u200b" + name, startTime); + : performance.measure(endTime, startTime); + performance.clearMeasures(endTime); } } } else @@ -2374,38 +2602,6 @@ __DEV__ && errors )); } - function logRenderPhase(startTime, endTime, lanes, debugTask) { - if (supportsUserTiming && !(endTime <= startTime)) { - var color = - (lanes & 738197653) === lanes ? "tertiary-dark" : "primary-dark"; - lanes = - (lanes & 536870912) === lanes - ? "Prepared" - : (lanes & 201326741) === lanes - ? "Hydrated" - : "Render"; - debugTask - ? debugTask.run( - console.timeStamp.bind( - console, - lanes, - startTime, - endTime, - currentTrack, - "Scheduler \u269b", - color - ) - ) - : console.timeStamp( - lanes, - startTime, - endTime, - currentTrack, - "Scheduler \u269b", - color - ); - } - } function logSuspendedRenderPhase(startTime, endTime, lanes, debugTask) { !supportsUserTiming || endTime <= startTime || @@ -2458,49 +2654,6 @@ __DEV__ && lanes )); } - function logRecoveredRenderPhase( - startTime, - endTime, - lanes, - recoverableErrors, - hydrationFailed, - debugTask - ) { - if (supportsUserTiming && !(endTime <= startTime)) { - lanes = []; - for (var i = 0; i < recoverableErrors.length; i++) { - var error = recoverableErrors[i].value; - lanes.push([ - "Recoverable Error", - "object" === typeof error && - null !== error && - "string" === typeof error.message - ? String(error.message) - : String(error) - ]); - } - startTime = { - start: startTime, - end: endTime, - detail: { - devtools: { - color: "primary-dark", - track: currentTrack, - trackGroup: "Scheduler \u269b", - tooltipText: hydrationFailed - ? "Hydration Failed" - : "Recovered after Error", - properties: lanes - } - } - }; - debugTask - ? debugTask.run( - performance.measure.bind(performance, "Recovered", startTime) - ) - : performance.measure("Recovered", startTime); - } - } function logErroredRenderPhase(startTime, endTime, lanes, debugTask) { !supportsUserTiming || endTime <= startTime || @@ -2582,8 +2735,69 @@ __DEV__ && performance.measure.bind(performance, "Errored", startTime) ) : performance.measure("Errored", startTime); + performance.clearMeasures("Errored"); } } + function logCommitPhase( + startTime, + endTime, + errors, + abortedViewTransition, + debugTask + ) { + null !== errors + ? logCommitErrored(startTime, endTime, errors, !1, debugTask) + : !supportsUserTiming || + endTime <= startTime || + (debugTask + ? debugTask.run( + console.timeStamp.bind( + console, + abortedViewTransition + ? "Commit Interrupted View Transition" + : "Commit", + startTime, + endTime, + currentTrack, + "Scheduler \u269b", + abortedViewTransition ? "error" : "secondary-dark" + ) + ) + : console.timeStamp( + abortedViewTransition + ? "Commit Interrupted View Transition" + : "Commit", + startTime, + endTime, + currentTrack, + "Scheduler \u269b", + abortedViewTransition ? "error" : "secondary-dark" + )); + } + function logAnimatingPhase(startTime, endTime, debugTask) { + !supportsUserTiming || + endTime <= startTime || + (debugTask + ? debugTask.run( + console.timeStamp.bind( + console, + "Animating", + startTime, + endTime, + currentTrack, + "Scheduler \u269b", + "secondary-dark" + ) + ) + : console.timeStamp( + "Animating", + startTime, + endTime, + currentTrack, + "Scheduler \u269b", + "secondary-dark" + )); + } function createCapturedValueAtFiber(value, source) { if ("object" === typeof value && null !== value) { var existing = CapturedStacks.get(value); @@ -2623,21 +2837,24 @@ __DEV__ && pop(rootInstanceStackCursor, fiber); } function pushHostContext(fiber) { - null !== fiber.memoizedState && - push(hostTransitionProviderCursor, fiber, fiber); - var context = requiredContext(contextStackCursor.current); + var stateHook = fiber.memoizedState; + null !== stateHook && + ((HostTransitionContext._currentValue2 = stateHook.memoizedState), + push(hostTransitionProviderCursor, fiber, fiber)); + stateHook = requiredContext(contextStackCursor.current); var nextContext = fiber.type; nextContext = "AndroidTextInput" === nextContext || "RCTMultilineTextInputView" === nextContext || + "RCTSelectableText" === nextContext || "RCTSinglelineTextInputView" === nextContext || "RCTText" === nextContext || "RCTVirtualText" === nextContext; nextContext = - context.isInAParentText !== nextContext + stateHook.isInAParentText !== nextContext ? { isInAParentText: nextContext } - : context; - context !== nextContext && + : stateHook; + stateHook !== nextContext && (push(contextFiberStackCursor, fiber, fiber), push(contextStackCursor, nextContext, fiber)); } @@ -3218,7 +3435,21 @@ __DEV__ && workInProgress ); nextFiber = null; - } else nextFiber = fiber.child; + } else + 13 === fiber.tag && + null !== fiber.memoizedState && + null === fiber.memoizedState.dehydrated + ? ((fiber.lanes |= renderLanes), + (nextFiber = fiber.alternate), + null !== nextFiber && (nextFiber.lanes |= renderLanes), + scheduleContextWorkOnParentPath( + fiber.return, + renderLanes, + workInProgress + ), + (nextFiber = fiber.child), + (nextFiber = null !== nextFiber ? nextFiber.sibling : null)) + : (nextFiber = fiber.child); if (null !== nextFiber) nextFiber.return = fiber; else for (nextFiber = fiber; null !== nextFiber; ) { @@ -3284,6 +3515,7 @@ __DEV__ && forcePropagateEntireTree ); workInProgress.flags |= 262144; + return null !== current; } function checkIfContextChanged(currentDependencies) { for ( @@ -3362,22 +3594,39 @@ __DEV__ && cache.controller.abort(); }); } + function queueTransitionTypes(root, transitionTypes) { + if (0 !== (root.pendingLanes & 4194048)) { + var queued = root.transitionTypes; + null === queued && (queued = root.transitionTypes = []); + for (root = 0; root < transitionTypes.length; root++) { + var transitionType = transitionTypes[root]; + -1 === queued.indexOf(transitionType) && queued.push(transitionType); + } + } + } + function claimQueuedTransitionTypes(root) { + var claimed = root.transitionTypes; + root.transitionTypes = null; + return claimed; + } function startUpdateTimerByLane(lane, method, fiber) { - if (0 !== (lane & 127)) { - if (0 > blockingUpdateTime) { - blockingUpdateTime = now(); - blockingUpdateTask = createTask(method); - blockingUpdateMethodName = method; + if (0 !== (lane & 127)) + 0 > blockingUpdateTime && + ((blockingUpdateTime = now()), + (blockingUpdateTask = createTask(method)), + (blockingUpdateMethodName = method), null != fiber && - (blockingUpdateComponentName = getComponentNameFromFiber(fiber)); + (blockingUpdateComponentName = getComponentNameFromFiber(fiber)), (executionContext & (RenderContext | CommitContext)) !== NoContext && - ((componentEffectSpawnedUpdate = !0), (blockingUpdateType = 1)); - if (-1.1 !== blockingEventRepeatTime || null !== blockingEventType) - blockingEventRepeatTime = -1.1; - blockingEventTime = -1.1; - blockingEventType = null; - } - } else if ( + ((componentEffectSpawnedUpdate = !0), (blockingUpdateType = 1)), + (lane = resolveEventTimeStamp()), + (method = resolveEventType()), + lane !== blockingEventRepeatTime || method !== blockingEventType + ? (blockingEventRepeatTime = -1.1) + : null !== method && (blockingUpdateType = 1), + (blockingEventTime = lane), + (blockingEventType = method)); + else if ( 0 !== (lane & 4194048) && 0 > transitionUpdateTime && ((transitionUpdateTime = now()), @@ -3387,10 +3636,15 @@ __DEV__ && (transitionUpdateComponentName = getComponentNameFromFiber(fiber)), 0 > transitionStartTime) ) { - if (-1.1 !== transitionEventRepeatTime || null !== transitionEventType) + lane = resolveEventTimeStamp(); + method = resolveEventType(); + if ( + lane !== transitionEventRepeatTime || + method !== transitionEventType + ) transitionEventRepeatTime = -1.1; - transitionEventTime = -1.1; - transitionEventType = null; + transitionEventTime = lane; + transitionEventType = method; } } function pushNestedEffectDurations() { @@ -3543,6 +3797,7 @@ __DEV__ && } } function processRootScheduleInImmediateTask() { + schedulerEvent = global.event; processRootScheduleInMicrotask(); } function processRootScheduleInMicrotask() { @@ -3650,6 +3905,7 @@ __DEV__ && } function performWorkOnRootViaSchedulerTask(root, didTimeout) { nestedUpdateScheduled = currentUpdateIsNested = !1; + schedulerEvent = global.event; if ( pendingEffectsStatus !== NO_PENDING_EFFECTS && pendingEffectsStatus !== PENDING_PASSIVE_PHASE @@ -3698,19 +3954,14 @@ __DEV__ && processRootScheduleInMicrotask(); return null; }); - supportsMicrotasks - ? scheduleMicrotask(function () { - (executionContext & (RenderContext | CommitContext)) !== NoContext - ? scheduleCallback$3( - ImmediatePriority, - processRootScheduleInImmediateTask - ) - : processRootScheduleInMicrotask(); - }) - : scheduleCallback$3( - ImmediatePriority, - processRootScheduleInImmediateTask - ); + scheduleMicrotask(function () { + (executionContext & (RenderContext | CommitContext)) !== NoContext + ? scheduleCallback$3( + ImmediatePriority, + processRootScheduleInImmediateTask + ) + : processRootScheduleInMicrotask(); + }); } function requestTransitionLane() { if (0 === currentEventTransitionLane) { @@ -3745,6 +3996,7 @@ __DEV__ && if ( 0 === --currentEntangledPendingCount && (-1 < transitionUpdateTime || (transitionStartTime = -1.1), + (entangledTransitionTypes = null), null !== currentEntangledListeners) ) { null !== currentEntangledActionThenable && @@ -3842,15 +4094,35 @@ __DEV__ && )), thenable.then(noop, noop), (thenable = index)); + if (void 0 === thenable._debugInfo) { + thenableState = performance.now(); + trackedThenables = thenable.displayName; + var ioInfo = { + name: + "string" === typeof trackedThenables ? trackedThenables : "Promise", + start: thenableState, + end: thenableState, + value: thenable + }; + thenable._debugInfo = [{ awaited: ioInfo }]; + "fulfilled" !== thenable.status && + "rejected" !== thenable.status && + ((thenableState = function () { + ioInfo.end = performance.now(); + }), + thenable.then(thenableState, thenableState)); + } switch (thenable.status) { case "fulfilled": return thenable.value; case "rejected": - throw ( - ((thenableState = thenable.reason), - checkIfUseWrappedInAsyncCatch(thenableState), - thenableState) - ); + thenableState = thenable.reason; + checkIfUseWrappedInAsyncCatch(thenableState); + if (void 0 === thenableState && !("reason" in thenable)) + throw Error( + "A rejected Promise was passed to React without a `reason` property. React threw a generic error from where the Promise was used to assist in identifying the problematic Promise. Make sure that instrumented Promises correctly set the `reason` property when setting `status` to `'rejected'`." + ); + throw thenableState; default: if ("string" === typeof thenable.status) thenable.then(noop, noop); else { @@ -3950,7 +4222,7 @@ __DEV__ && function validateFragmentProps(element, fiber, returnFiber) { for (var keys = Object.keys(element.props), i = 0; i < keys.length; i++) { var key = keys[i]; - if ("children" !== key && "key" !== key) { + if ("children" !== key && "key" !== key && "ref" !== key) { null === fiber && ((fiber = createFiberFromElement(element, returnFiber.mode, 0)), (fiber._debugInfo = currentDebugInfo), @@ -3959,7 +4231,7 @@ __DEV__ && fiber, function (erroredKey) { console.error( - "Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", + "Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key`, `ref`, and `children` props.", erroredKey ); }, @@ -4075,9 +4347,9 @@ __DEV__ && } function mapRemainingChildren(currentFirstChild) { for (var existingChildren = new Map(); null !== currentFirstChild; ) - null !== currentFirstChild.key - ? existingChildren.set(currentFirstChild.key, currentFirstChild) - : existingChildren.set(currentFirstChild.index, currentFirstChild), + null === currentFirstChild.key + ? existingChildren.set(currentFirstChild.index, currentFirstChild) + : existingChildren.set(currentFirstChild.key, currentFirstChild), (currentFirstChild = currentFirstChild.sibling); return existingChildren; } @@ -4096,16 +4368,16 @@ __DEV__ && return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.flags |= 67108866), lastPlacedIndex) + ? ((newFiber.flags |= 2), lastPlacedIndex) : newIndex ); - newFiber.flags |= 67108866; + newFiber.flags |= 134217730; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.flags |= 67108866); + (newFiber.flags |= 134217730); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -4138,6 +4410,7 @@ __DEV__ && lanes, element.key )), + coerceRef(current, element), validateFragmentProps(element, current, returnFiber), current ); @@ -4593,10 +4866,11 @@ __DEV__ && knownKeys )), shouldTrackSideEffects && - null !== nextOldFiber.alternate && - oldFiber.delete( - null === nextOldFiber.key ? newIdx : nextOldFiber.key - ), + ((newFiber = nextOldFiber.alternate), + null !== newFiber && + oldFiber.delete( + null === newFiber.key ? newIdx : newFiber.key + )), (currentFirstChild = placeChild( nextOldFiber, currentFirstChild, @@ -4701,10 +4975,9 @@ __DEV__ && knownKeys )), shouldTrackSideEffects && - null !== nextOldFiber.alternate && - oldFiber.delete( - null === nextOldFiber.key ? newIdx : nextOldFiber.key - ), + ((step = nextOldFiber.alternate), + null !== step && + oldFiber.delete(null === step.key ? newIdx : step.key)), (currentFirstChild = placeChild( nextOldFiber, currentFirstChild, @@ -4730,6 +5003,7 @@ __DEV__ && null !== newChild && newChild.type === REACT_FRAGMENT_TYPE && null === newChild.key && + void 0 === newChild.props.ref && (validateFragmentProps(newChild, null, returnFiber), (newChild = newChild.props.children)); if ("object" === typeof newChild && null !== newChild) { @@ -4750,6 +5024,7 @@ __DEV__ && currentFirstChild, newChild.props.children ); + coerceRef(lanes, newChild); lanes.return = returnFiber; lanes._debugOwner = newChild._owner; lanes._debugInfo = currentDebugInfo; @@ -4792,6 +5067,7 @@ __DEV__ && lanes, newChild.key )), + coerceRef(lanes, newChild), (lanes.return = returnFiber), (lanes._debugOwner = returnFiber), (lanes._debugTask = returnFiber._debugTask), @@ -4869,32 +5145,26 @@ __DEV__ && ); } if (isArrayImpl(newChild)) - return ( - (prevDebugInfo = pushDebugInfo(newChild._debugInfo)), - (returnFiber = reconcileChildrenArray( - returnFiber, - currentFirstChild, - newChild, - lanes - )), - (currentDebugInfo = prevDebugInfo), - returnFiber + return reconcileChildrenArray( + returnFiber, + currentFirstChild, + newChild, + lanes ); if (getIteratorFn(newChild)) { - prevDebugInfo = pushDebugInfo(newChild._debugInfo); - key = getIteratorFn(newChild); - if ("function" !== typeof key) + prevDebugInfo = newChild; + newChild = getIteratorFn(prevDebugInfo); + if ("function" !== typeof newChild) throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." ); - var newChildren = key.call(newChild); - if (newChildren === newChild) { + key = newChild.call(prevDebugInfo); + if (key === prevDebugInfo) { if ( 0 !== returnFiber.tag || "[object GeneratorFunction]" !== Object.prototype.toString.call(returnFiber.type) || - "[object Generator]" !== - Object.prototype.toString.call(newChildren) + "[object Generator]" !== Object.prototype.toString.call(key) ) didWarnAboutGenerators || console.error( @@ -4902,20 +5172,18 @@ __DEV__ && ), (didWarnAboutGenerators = !0); } else - newChild.entries !== key || + prevDebugInfo.entries !== newChild || didWarnAboutMaps || (console.error( "Using Maps as children is not supported. Use an array of keyed ReactElements instead." ), (didWarnAboutMaps = !0)); - returnFiber = reconcileChildrenIterator( + return reconcileChildrenIterator( returnFiber, currentFirstChild, - newChildren, + key, lanes ); - currentDebugInfo = prevDebugInfo; - return returnFiber; } if ("function" === typeof newChild.then) return ( @@ -5486,6 +5754,19 @@ __DEV__ && shellBoundary === fiber && (shellBoundary = null); pop(suspenseStackCursor, fiber); } + function pushSuspenseListContext(fiber, newContext) { + push( + suspenseHandlerStackCursor, + suspenseHandlerStackCursor.current, + fiber + ); + push(suspenseStackCursor, newContext, fiber); + } + function popSuspenseListContext(fiber) { + pop(suspenseStackCursor, fiber); + pop(suspenseHandlerStackCursor, fiber); + shellBoundary === fiber && (shellBoundary = null); + } function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -5499,10 +5780,7 @@ __DEV__ && return node; } else if ( 19 === node.tag && - ("forwards" === node.memoizedProps.revealOrder || - "backwards" === node.memoizedProps.revealOrder || - "unstable_legacy-backwards" === node.memoizedProps.revealOrder || - "together" === node.memoizedProps.revealOrder) + "independent" !== node.memoizedProps.revealOrder ) { if (0 !== (node.flags & 128)) return node; } else if (null !== node.child) { @@ -5692,7 +5970,7 @@ __DEV__ && null; hookTypesUpdateIndexDev = -1; null !== current && - (current.flags & 65011712) !== (workInProgress.flags & 65011712) && + (current.flags & 1206910976) !== (workInProgress.flags & 1206910976) && 0 !== (current.mode & 1) && console.error( "Internal React error: Expected static flag was missing. Please notify the React team." @@ -5766,7 +6044,7 @@ __DEV__ && workInProgress.updateQueue = current.updateQueue; workInProgress.flags = 0 !== (workInProgress.mode & 16) - ? workInProgress.flags & -402655237 + ? workInProgress.flags & -805308421 : workInProgress.flags & -2053; current.lanes &= ~lanes; } @@ -5867,6 +6145,7 @@ __DEV__ && function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) return useThenable(usable); + if (usable.$$typeof === REACT_RECOVERABLE_TYPE) return; if (usable.$$typeof === REACT_CONTEXT_TYPE) return readContext(usable); } throw Error("An unsupported type was passed to use(): " + String(usable)); @@ -6150,25 +6429,19 @@ __DEV__ && hook = hook.queue; var create = subscribeToStore.bind(null, fiber, hook, subscribe); updateEffectImpl(2048, Passive, create, [subscribe]); - if ( + subscribe = hook.getSnapshot !== getSnapshot || cachedSnapshot || (null !== workInProgressHook && - workInProgressHook.memoizedState.tag & HasEffect) - ) { + (workInProgressHook.memoizedState.tag & HasEffect) !== NoFlags); + pushSimpleEffect( + subscribe ? HasEffect | Passive : Passive, + { destroy: void 0 }, + updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), + null + ); + if (subscribe) { fiber.flags |= 2048; - pushSimpleEffect( - HasEffect | Passive, - { destroy: void 0 }, - updateStoreInstance.bind( - null, - fiber, - hook, - nextSnapshot, - getSnapshot - ), - null - ); if (null === workInProgressRoot) throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." @@ -6295,7 +6568,7 @@ __DEV__ && payload ) { if (isRenderPhaseUpdate(fiber)) - throw Error("Cannot update form state while rendering."); + throw Error("Cannot update action state while rendering."); fiber = actionQueue.action; if (null !== fiber) { var actionNode = { @@ -6330,6 +6603,8 @@ __DEV__ && if (node.isTransition) { var prevTransition = ReactSharedInternals.T, currentTransition = {}; + currentTransition.types = + null !== prevTransition ? prevTransition.types : null; currentTransition._updatedFibers = new Set(); ReactSharedInternals.T = currentTransition; try { @@ -6564,7 +6839,7 @@ __DEV__ && } function mountEffect(create, deps) { 0 !== (currentlyRenderingFiber.mode & 16) - ? mountEffectImpl(276826112, Passive, create, deps) + ? mountEffectImpl(545261568, Passive, create, deps) : mountEffectImpl(8390656, Passive, create, deps); } function useEffectEventImpl(payload) { @@ -6606,7 +6881,7 @@ __DEV__ && } function mountLayoutEffect(create, deps) { var fiberFlags = 4194308; - 0 !== (currentlyRenderingFiber.mode & 16) && (fiberFlags |= 134217728); + 0 !== (currentlyRenderingFiber.mode & 16) && (fiberFlags |= 268435456); return mountEffectImpl(fiberFlags, Layout, create, deps); } function imperativeHandleEffect(create, ref) { @@ -6639,7 +6914,7 @@ __DEV__ && ); deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null; var fiberFlags = 4194308; - 0 !== (currentlyRenderingFiber.mode & 16) && (fiberFlags |= 134217728); + 0 !== (currentlyRenderingFiber.mode & 16) && (fiberFlags |= 268435456); mountEffectImpl( fiberFlags, Layout, @@ -6756,7 +7031,7 @@ __DEV__ && hook ); if ( - 0 === (renderLanes & 42) || + 0 === (renderLanes & 106) || (0 !== (renderLanes & 1073741824) && 0 === (workInProgressRootRenderLanes & 261930)) ) @@ -6783,6 +7058,8 @@ __DEV__ && : ContinuousEventPriority; var prevTransition = ReactSharedInternals.T, currentTransition = {}; + currentTransition.types = + null !== prevTransition ? prevTransition.types : null; currentTransition._updatedFibers = new Set(); ReactSharedInternals.T = currentTransition; dispatchOptimisticSetState(fiber, !1, queue, pendingState); @@ -7444,7 +7721,7 @@ __DEV__ && (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); - 0 !== (workInProgress.mode & 16) && (workInProgress.flags |= 134217728); + 0 !== (workInProgress.mode & 16) && (workInProgress.flags |= 268435456); } function resolveClassComponentProps(Component, baseProps) { var newProps = baseProps; @@ -7595,6 +7872,7 @@ __DEV__ && switch (currentSourceFiber.tag) { case 31: case 13: + case 19: return ( sourceFiber.mode & 1 && (null === shellBoundary @@ -7699,18 +7977,17 @@ __DEV__ && !1 ); case 1: + sourceFiber = returnFiber.type; + currentSourceFiber = returnFiber.stateNode; if ( - ((sourceFiber = returnFiber.type), - (currentSourceFiber = returnFiber.stateNode), 0 === (returnFiber.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === - typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== currentSourceFiber && + "function" === typeof currentSourceFiber.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has( + currentSourceFiber + )))) ) return ( (returnFiber.flags |= 65536), @@ -7726,6 +8003,10 @@ __DEV__ && enqueueCapturedUpdate(returnFiber, rootRenderLanes), !1 ); + break; + case 22: + if (null !== returnFiber.memoizedState) + return (returnFiber.flags |= 65536), !1; } returnFiber = returnFiber.return; } while (null !== returnFiber); @@ -7755,7 +8036,11 @@ __DEV__ && renderLanes ) { Component = Component.render; - var ref = workInProgress.ref; + var resolvedRender = resolveTypeForHotReloading(Component); + resolvedRender !== Component && + ((Component = resolvedRender), + null !== current && (didReceiveUpdate = !0)); + resolvedRender = workInProgress.ref; if ("ref" in nextProps) { var propsWithoutRef = {}; for (var key in nextProps) @@ -7767,7 +8052,7 @@ __DEV__ && workInProgress, Component, propsWithoutRef, - ref, + resolvedRender, renderLanes ); if (null !== current && !didReceiveUpdate) @@ -7795,7 +8080,7 @@ __DEV__ && null === Component.compare ) return ( - (Component = resolveFunctionForHotReloading(type)), + (Component = resolveTypeForHotReloading(type)), (workInProgress.tag = 15), (workInProgress.type = Component), validateFunctionComponentInDev(workInProgress, type), @@ -8228,11 +8513,11 @@ __DEV__ && "function" === typeof _instance.componentDidMount && (workInProgress.flags |= 4194308), 0 !== (workInProgress.mode & 16) && - (workInProgress.flags |= 134217728)) + (workInProgress.flags |= 268435456)) : ("function" === typeof _instance.componentDidMount && (workInProgress.flags |= 4194308), 0 !== (workInProgress.mode & 16) && - (workInProgress.flags |= 134217728), + (workInProgress.flags |= 268435456), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldContext)), (_instance.props = nextProps), @@ -8242,7 +8527,7 @@ __DEV__ && : ("function" === typeof _instance.componentDidMount && (workInProgress.flags |= 4194308), 0 !== (workInProgress.mode & 16) && - (workInProgress.flags |= 134217728), + (workInProgress.flags |= 268435456), (_instance = !1)); } else { _instance = workInProgress.stateNode; @@ -8466,216 +8751,97 @@ __DEV__ && JSCompiler_temp = 0 !== (workInProgress.flags & 32); workInProgress.flags &= -33; if (null === current) { - var nextPrimaryChildren = nextProps.children; + didSuspend = nextProps.children; nextProps = nextProps.fallback; - if (showFallback) - return ( - reuseSuspenseHandlerOnStack(workInProgress), - (showFallback = workInProgress.mode), - (didSuspend = workInProgress.child), - (nextPrimaryChildren = { - mode: "hidden", - children: nextPrimaryChildren - }), - 0 === (showFallback & 1) && null !== didSuspend - ? ((didSuspend.childLanes = 0), - (didSuspend.pendingProps = nextPrimaryChildren), - workInProgress.mode & 2 && - ((didSuspend.actualDuration = -0), - (didSuspend.actualStartTime = -1.1), - (didSuspend.selfBaseDuration = -0), - (didSuspend.treeBaseDuration = -0))) - : (didSuspend = mountWorkInProgressOffscreenFiber( - nextPrimaryChildren, - showFallback - )), - (nextProps = createFiberFromFragment( - nextProps, - showFallback, - renderLanes, - null - )), - (didSuspend.return = workInProgress), - (nextProps.return = workInProgress), - (didSuspend.sibling = nextProps), - (workInProgress.child = didSuspend), - (nextProps = workInProgress.child), - (nextProps.memoizedState = - mountSuspenseOffscreenState(renderLanes)), - (nextProps.childLanes = getRemainingWorkInPrimaryTree( - current, - JSCompiler_temp, - renderLanes - )), - (workInProgress.memoizedState = SUSPENDED_MARKER), - bailoutOffscreenComponent(null, nextProps) + if (showFallback) { + reuseSuspenseHandlerOnStack(workInProgress); + showFallback = workInProgress.mode; + var progressedPrimaryFragment = workInProgress.child; + didSuspend = { mode: "hidden", children: didSuspend }; + 0 === (showFallback & 1) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = didSuspend), + workInProgress.mode & 2 && + ((progressedPrimaryFragment.actualDuration = -0), + (progressedPrimaryFragment.actualStartTime = -1.1), + (progressedPrimaryFragment.selfBaseDuration = -0), + (progressedPrimaryFragment.treeBaseDuration = -0))) + : (progressedPrimaryFragment = mountWorkInProgressOffscreenFiber( + didSuspend, + showFallback + )); + nextProps = createFiberFromFragment( + nextProps, + showFallback, + renderLanes, + null ); + progressedPrimaryFragment.return = workInProgress; + nextProps.return = workInProgress; + progressedPrimaryFragment.sibling = nextProps; + workInProgress.child = progressedPrimaryFragment; + nextProps = workInProgress.child; + nextProps.memoizedState = mountSuspenseOffscreenState(renderLanes); + nextProps.childLanes = getRemainingWorkInPrimaryTree( + current, + JSCompiler_temp, + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; + return bailoutOffscreenComponent(null, nextProps); + } pushPrimaryTreeSuspenseHandler(workInProgress); - return mountSuspensePrimaryChildren( - workInProgress, - nextPrimaryChildren - ); + return mountSuspensePrimaryChildren(workInProgress, didSuspend); } - nextPrimaryChildren = current.memoizedState; - if ( - null !== nextPrimaryChildren && - null !== nextPrimaryChildren.dehydrated - ) { - if (didSuspend) - workInProgress.flags & 256 - ? (pushPrimaryTreeSuspenseHandler(workInProgress), - (workInProgress.flags &= -257), - (workInProgress = retrySuspenseComponentWithoutHydrating( - current, - workInProgress, - renderLanes - ))) - : null !== workInProgress.memoizedState - ? (reuseSuspenseHandlerOnStack(workInProgress), - (workInProgress.child = current.child), - (workInProgress.flags |= 128), - (workInProgress = null)) - : (reuseSuspenseHandlerOnStack(workInProgress), - (showFallback = nextProps.fallback), - (nextPrimaryChildren = workInProgress.mode), - (nextProps = mountWorkInProgressOffscreenFiber( - { mode: "visible", children: nextProps.children }, - nextPrimaryChildren - )), - (showFallback = createFiberFromFragment( - showFallback, - nextPrimaryChildren, - renderLanes, - null - )), - (showFallback.flags |= 2), - (nextProps.return = workInProgress), - (showFallback.return = workInProgress), - (nextProps.sibling = showFallback), - (workInProgress.child = nextProps), - 0 !== (workInProgress.mode & 1) && - reconcileChildFibers( - workInProgress, - current.child, - null, - renderLanes - ), - (nextProps = workInProgress.child), - (nextProps.memoizedState = - mountSuspenseOffscreenState(renderLanes)), - (nextProps.childLanes = getRemainingWorkInPrimaryTree( - current, - JSCompiler_temp, - renderLanes - )), - (workInProgress.memoizedState = SUSPENDED_MARKER), - (workInProgress = bailoutOffscreenComponent(null, nextProps))); - else if ( - (pushPrimaryTreeSuspenseHandler(workInProgress), - 0 !== (renderLanes & 536870912) && - markRenderDerivedCause(workInProgress), - isSuspenseInstanceFallback()) - ) - (nextPrimaryChildren = getSuspenseInstanceFallbackErrorDetails()), - (JSCompiler_temp = nextPrimaryChildren.digest), - (showFallback = nextPrimaryChildren.message), - (nextProps = nextPrimaryChildren.stack), - (nextPrimaryChildren = nextPrimaryChildren.componentStack), - (showFallback = showFallback - ? Error(showFallback) - : Error( - "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." - )), - (showFallback.stack = nextProps || ""), - (showFallback.digest = JSCompiler_temp), - (JSCompiler_temp = - void 0 === nextPrimaryChildren ? null : nextPrimaryChildren), - (nextProps = { - value: showFallback, - source: null, - stack: JSCompiler_temp - }), - "string" === typeof JSCompiler_temp && - CapturedStacks.set(showFallback, nextProps), - null === hydrationErrors - ? (hydrationErrors = [nextProps]) - : hydrationErrors.push(nextProps), - (workInProgress = retrySuspenseComponentWithoutHydrating( - current, - workInProgress, - renderLanes - )); - else if ( - (didReceiveUpdate || - propagateParentContextChanges( - current, - workInProgress, - renderLanes, - !1 - ), - (JSCompiler_temp = 0 !== (renderLanes & current.childLanes)), - didReceiveUpdate || JSCompiler_temp) - ) { - JSCompiler_temp = workInProgressRoot; - if ( - null !== JSCompiler_temp && - ((nextProps = getBumpedLaneForHydration( - JSCompiler_temp, - renderLanes - )), - 0 !== nextProps && nextProps !== nextPrimaryChildren.retryLane) - ) - throw ( - ((nextPrimaryChildren.retryLane = nextProps), - enqueueConcurrentRenderForLane(current, nextProps), - scheduleUpdateOnFiber(JSCompiler_temp, current, nextProps), - SelectiveHydrationException) - ); - isSuspenseInstancePending() || renderDidSuspendDelayIfPossible(); - workInProgress = retrySuspenseComponentWithoutHydrating( + progressedPrimaryFragment = current.memoizedState; + if (null !== progressedPrimaryFragment) { + var _dehydrated2 = progressedPrimaryFragment.dehydrated; + if (null !== _dehydrated2) + return updateDehydratedSuspenseComponent( current, workInProgress, + didSuspend, + JSCompiler_temp, + nextProps, + _dehydrated2, + progressedPrimaryFragment, renderLanes ); - } else - isSuspenseInstancePending() - ? ((workInProgress.flags |= 192), - (workInProgress.child = current.child), - (workInProgress = null)) - : ((workInProgress = mountSuspensePrimaryChildren( - workInProgress, - nextProps.children - )), - (workInProgress.flags |= 4096)); - return workInProgress; } if (showFallback) { reuseSuspenseHandlerOnStack(workInProgress); showFallback = nextProps.fallback; - nextPrimaryChildren = workInProgress.mode; - didSuspend = current.child; - var currentFallbackChildFragment = didSuspend.sibling, - primaryChildProps = { mode: "hidden", children: nextProps.children }; - 0 === (nextPrimaryChildren & 1) && workInProgress.child !== didSuspend + didSuspend = workInProgress.mode; + progressedPrimaryFragment = current.child; + _dehydrated2 = progressedPrimaryFragment.sibling; + var primaryChildProps = { + mode: "hidden", + children: nextProps.children + }; + 0 === (didSuspend & 1) && + workInProgress.child !== progressedPrimaryFragment ? ((nextProps = workInProgress.child), (nextProps.childLanes = 0), (nextProps.pendingProps = primaryChildProps), workInProgress.mode & 2 && ((nextProps.actualDuration = -0), (nextProps.actualStartTime = -1.1), - (nextProps.selfBaseDuration = didSuspend.selfBaseDuration), - (nextProps.treeBaseDuration = didSuspend.treeBaseDuration)), + (nextProps.selfBaseDuration = + progressedPrimaryFragment.selfBaseDuration), + (nextProps.treeBaseDuration = + progressedPrimaryFragment.treeBaseDuration)), (workInProgress.deletions = null)) - : ((nextProps = createWorkInProgress(didSuspend, primaryChildProps)), - (nextProps.subtreeFlags = didSuspend.subtreeFlags & 65011712)); - null !== currentFallbackChildFragment - ? (showFallback = createWorkInProgress( - currentFallbackChildFragment, - showFallback - )) + : ((nextProps = createWorkInProgress( + progressedPrimaryFragment, + primaryChildProps + )), + (nextProps.subtreeFlags = + progressedPrimaryFragment.subtreeFlags & 1206910976)); + null !== _dehydrated2 + ? (showFallback = createWorkInProgress(_dehydrated2, showFallback)) : ((showFallback = createFiberFromFragment( showFallback, - nextPrimaryChildren, + didSuspend, renderLanes, null )), @@ -8689,17 +8855,20 @@ __DEV__ && showFallback = current.child.memoizedState; null === showFallback ? (showFallback = mountSuspenseOffscreenState(renderLanes)) - : ((nextPrimaryChildren = showFallback.cachePool), - null !== nextPrimaryChildren - ? ((didSuspend = CacheContext._currentValue2), - (nextPrimaryChildren = - nextPrimaryChildren.parent !== didSuspend - ? { parent: didSuspend, pool: didSuspend } - : nextPrimaryChildren)) - : (nextPrimaryChildren = getSuspendedCache()), + : ((didSuspend = showFallback.cachePool), + null !== didSuspend + ? ((progressedPrimaryFragment = CacheContext._currentValue2), + (didSuspend = + didSuspend.parent !== progressedPrimaryFragment + ? { + parent: progressedPrimaryFragment, + pool: progressedPrimaryFragment + } + : didSuspend)) + : (didSuspend = getSuspendedCache()), (showFallback = { baseLanes: showFallback.baseLanes | renderLanes, - cachePool: nextPrimaryChildren + cachePool: didSuspend })); nextProps.memoizedState = showFallback; nextProps.childLanes = getRemainingWorkInPrimaryTree( @@ -8710,7 +8879,7 @@ __DEV__ && workInProgress.memoizedState = SUSPENDED_MARKER; return bailoutOffscreenComponent(current.child, nextProps); } - null !== nextPrimaryChildren && + null !== progressedPrimaryFragment && (renderLanes & 62914560) === renderLanes && 0 !== (renderLanes & current.lanes) && markRenderDerivedCause(workInProgress); @@ -8761,6 +8930,149 @@ __DEV__ && workInProgress.memoizedState = null; return current; } + function updateDehydratedSuspenseComponent( + current, + workInProgress, + didSuspend, + didPrimaryChildrenDefer, + nextProps, + suspenseInstance, + suspenseState, + renderLanes + ) { + if (didSuspend) { + if (workInProgress.flags & 256) + return ( + pushPrimaryTreeSuspenseHandler(workInProgress), + (workInProgress.flags &= -257), + retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ) + ); + if (null !== workInProgress.memoizedState) + return ( + reuseSuspenseHandlerOnStack(workInProgress), + (workInProgress.child = current.child), + (workInProgress.flags |= 128), + null + ); + reuseSuspenseHandlerOnStack(workInProgress); + suspenseState = nextProps.fallback; + didSuspend = workInProgress.mode; + nextProps = mountWorkInProgressOffscreenFiber( + { mode: "visible", children: nextProps.children }, + didSuspend + ); + suspenseState = createFiberFromFragment( + suspenseState, + didSuspend, + renderLanes, + null + ); + suspenseState.flags |= 2; + nextProps.return = workInProgress; + suspenseState.return = workInProgress; + nextProps.sibling = suspenseState; + workInProgress.child = nextProps; + 0 !== (workInProgress.mode & 1) && + reconcileChildFibers( + workInProgress, + current.child, + null, + renderLanes + ); + nextProps = workInProgress.child; + nextProps.memoizedState = mountSuspenseOffscreenState(renderLanes); + nextProps.childLanes = getRemainingWorkInPrimaryTree( + current, + didPrimaryChildrenDefer, + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; + return bailoutOffscreenComponent(null, nextProps); + } + pushPrimaryTreeSuspenseHandler(workInProgress); + 0 !== (renderLanes & 536870912) && markRenderDerivedCause(workInProgress); + if (isSuspenseInstanceFallback()) + return ( + (didSuspend = getSuspenseInstanceFallbackErrorDetails()), + (didPrimaryChildrenDefer = didSuspend.digest), + (suspenseState = didSuspend.message), + (nextProps = didSuspend.stack), + (didSuspend = didSuspend.componentStack), + didPrimaryChildrenDefer !== REACT_RECOVERABLE_DIGEST && + ((suspenseState = suspenseState + ? Error(suspenseState) + : Error( + "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." + )), + (suspenseState.stack = nextProps || ""), + (suspenseState.digest = didPrimaryChildrenDefer), + (didPrimaryChildrenDefer = + void 0 === didSuspend ? null : didSuspend), + (nextProps = { + value: suspenseState, + source: null, + stack: didPrimaryChildrenDefer + }), + "string" === typeof didPrimaryChildrenDefer && + CapturedStacks.set(suspenseState, nextProps), + null === hydrationErrors + ? (hydrationErrors = [nextProps]) + : hydrationErrors.push(nextProps)), + retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ) + ); + didReceiveUpdate || + propagateParentContextChanges(current, workInProgress, renderLanes, !1); + didPrimaryChildrenDefer = 0 !== (renderLanes & current.childLanes); + if (didReceiveUpdate || didPrimaryChildrenDefer) { + if (null !== currentTreeHiddenStackCursor.current) + return retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ); + didPrimaryChildrenDefer = workInProgressRoot; + if ( + null !== didPrimaryChildrenDefer && + ((nextProps = getBumpedLaneForHydration( + didPrimaryChildrenDefer, + renderLanes + )), + 0 !== nextProps && nextProps !== suspenseState.retryLane) + ) + throw ( + ((suspenseState.retryLane = nextProps), + enqueueConcurrentRenderForLane(current, nextProps), + scheduleUpdateOnFiber(didPrimaryChildrenDefer, current, nextProps), + SelectiveHydrationException) + ); + isSuspenseInstancePending() || renderDidSuspendDelayIfPossible(); + return retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ); + } + if (isSuspenseInstancePending()) + return ( + (workInProgress.flags |= 192), + (workInProgress.child = current.child), + null + ); + current = mountSuspensePrimaryChildren( + workInProgress, + nextProps.children + ); + current.flags |= 134221824; + return current; + } function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) { fiber.lanes |= renderLanes; var alternate = fiber.alternate; @@ -8771,6 +9083,16 @@ __DEV__ && propagationRoot ); } + function findLastContentRow(firstChild) { + for (var lastContentRow = null; null !== firstChild; ) { + var currentRow = firstChild.alternate; + null !== currentRow && + null === findFirstSuspended(currentRow) && + (lastContentRow = firstChild); + firstChild = firstChild.sibling; + } + return lastContentRow; + } function initSuspenseListRenderState( workInProgress, isBackwards, @@ -8798,39 +9120,45 @@ __DEV__ && (renderState.tailMode = tailMode), (renderState.treeForkCount = treeForkCount)); } + function reverseChildren(fiber) { + var row = fiber.child; + for (fiber.child = null; null !== row; ) { + var nextRow = row.sibling; + row.sibling = fiber.child; + fiber.child = row; + row = nextRow; + } + } function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; nextProps = nextProps.children; - var suspenseContext = suspenseStackCursor.current, - shouldForceFallback = 0 !== (suspenseContext & ForceSuspenseFallback); + var suspenseContext = suspenseStackCursor.current; + if (workInProgress.flags & 128) + return pushSuspenseListContext(workInProgress, suspenseContext), null; + var shouldForceFallback = 0 !== (suspenseContext & ForceSuspenseFallback); shouldForceFallback ? ((suspenseContext = (suspenseContext & SubtreeSuspenseContextMask) | ForceSuspenseFallback), (workInProgress.flags |= 128)) : (suspenseContext &= SubtreeSuspenseContextMask); - push(suspenseStackCursor, suspenseContext, workInProgress); + pushSuspenseListContext(workInProgress, suspenseContext); suspenseContext = null == revealOrder ? "null" : revealOrder; if ( + null != revealOrder && "forwards" !== revealOrder && + "backwards" !== revealOrder && "unstable_legacy-backwards" !== revealOrder && "together" !== revealOrder && "independent" !== revealOrder && !didWarnAboutRevealOrder[suspenseContext] ) if ( - ((didWarnAboutRevealOrder[suspenseContext] = !0), null == revealOrder) + ((didWarnAboutRevealOrder[suspenseContext] = !0), + "string" === typeof revealOrder) ) - console.error( - 'The default for the prop is changing. To be future compatible you must explictly specify either "independent" (the current default), "together", "forwards" or "legacy_unstable-backwards".' - ); - else if ("backwards" === revealOrder) - console.error( - 'The rendering order of is changing. To be future compatible you must specify revealOrder="legacy_unstable-backwards" instead.' - ); - else if ("string" === typeof revealOrder) switch (revealOrder.toLowerCase()) { case "together": case "forwards": @@ -8862,36 +9190,28 @@ __DEV__ && revealOrder ); suspenseContext = null == tailMode ? "null" : tailMode; - if (!didWarnAboutTailOptions[suspenseContext]) - if (null == tailMode) { - if ( - "forwards" === revealOrder || - "backwards" === revealOrder || - "unstable_legacy-backwards" === revealOrder - ) - (didWarnAboutTailOptions[suspenseContext] = !0), - console.error( - 'The default for the prop is changing. To be future compatible you must explictly specify either "visible" (the current default), "collapsed" or "hidden".' - ); - } else - "visible" !== tailMode && - "collapsed" !== tailMode && - "hidden" !== tailMode - ? ((didWarnAboutTailOptions[suspenseContext] = !0), - console.error( - '"%s" is not a supported value for tail on . Did you mean "visible", "collapsed" or "hidden"?', - tailMode - )) - : "forwards" !== revealOrder && - "backwards" !== revealOrder && - "unstable_legacy-backwards" !== revealOrder && - ((didWarnAboutTailOptions[suspenseContext] = !0), - console.error( - ' is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?', - tailMode - )); + didWarnAboutTailOptions[suspenseContext] || + null == tailMode || + ("visible" !== tailMode && + "collapsed" !== tailMode && + "hidden" !== tailMode + ? ((didWarnAboutTailOptions[suspenseContext] = !0), + console.error( + '"%s" is not a supported value for tail on . Did you mean "visible", "collapsed" or "hidden"?', + tailMode + )) + : null != revealOrder && + "forwards" !== revealOrder && + "backwards" !== revealOrder && + "unstable_legacy-backwards" !== revealOrder && + ((didWarnAboutTailOptions[suspenseContext] = !0), + console.error( + ' is only valid if revealOrder is "forwards" (default) or "backwards". Did you mean to specify revealOrder="forwards"?', + tailMode + ))); a: if ( - ("forwards" === revealOrder || + (null == revealOrder || + "forwards" === revealOrder || "backwards" === revealOrder || "unstable_legacy-backwards" === revealOrder) && void 0 !== nextProps && @@ -8930,7 +9250,11 @@ __DEV__ && 'A single row was passed to a . This is not useful since it needs multiple rows. Did you mean to pass multiple children or an array?', revealOrder ); - reconcileChildren(current, workInProgress, nextProps, renderLanes); + "backwards" === revealOrder && null !== current + ? (reverseChildren(current), + reconcileChildren(current, workInProgress, nextProps, renderLanes), + reverseChildren(current)) + : reconcileChildren(current, workInProgress, nextProps, renderLanes); if ( !shouldForceFallback && null !== current && @@ -8959,30 +9283,23 @@ __DEV__ && if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null; else switch (revealOrder) { - case "forwards": - renderLanes = workInProgress.child; - for (revealOrder = null; null !== renderLanes; ) - (current = renderLanes.alternate), - null !== current && - null === findFirstSuspended(current) && - (revealOrder = renderLanes), - (renderLanes = renderLanes.sibling); - renderLanes = revealOrder; + case "backwards": + renderLanes = findLastContentRow(workInProgress.child); null === renderLanes ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) : ((revealOrder = renderLanes.sibling), - (renderLanes.sibling = null)); + (renderLanes.sibling = null), + reverseChildren(workInProgress)); initSuspenseListRenderState( workInProgress, - !1, + !0, revealOrder, - renderLanes, + null, tailMode, 0 ); break; - case "backwards": case "unstable_legacy-backwards": renderLanes = null; revealOrder = workInProgress.child; @@ -9016,13 +9333,48 @@ __DEV__ && 0 ); break; - default: + case "independent": workInProgress.memoizedState = null; + break; + default: + (renderLanes = findLastContentRow(workInProgress.child)), + null === renderLanes + ? ((revealOrder = workInProgress.child), + (workInProgress.child = null)) + : ((revealOrder = renderLanes.sibling), + (renderLanes.sibling = null)), + initSuspenseListRenderState( + workInProgress, + !1, + revealOrder, + renderLanes, + tailMode, + 0 + ); } return workInProgress.child; } - function resetSuspendedCurrentOnMountInLegacyMode(current, workInProgress) { - 0 === (workInProgress.mode & 1) && + function updateContextProvider(current, workInProgress, renderLanes) { + var context = workInProgress.type, + newProps = workInProgress.pendingProps, + newValue = newProps.value; + "value" in newProps || + hasWarnedAboutUsingNoValuePropOnContextProvider || + ((hasWarnedAboutUsingNoValuePropOnContextProvider = !0), + console.error( + "The `value` prop is required for the ``. Did you misspell it or forget to pass it?" + )); + pushProvider(workInProgress, context, newValue); + reconcileChildren( + current, + workInProgress, + newProps.children, + renderLanes + ); + return workInProgress.child; + } + function resetSuspendedCurrentOnMountInLegacyMode(current, workInProgress) { + 0 === (workInProgress.mode & 1) && null !== current && ((current.alternate = null), (workInProgress.alternate = null), @@ -9128,7 +9480,14 @@ __DEV__ && (workInProgress.flags |= 128), null ); - if (0 !== (renderLanes & workInProgress.child.childLanes)) + stateNode = propagateParentContextChanges( + current, + workInProgress, + renderLanes, + !1 + ); + var primaryChildLanes = workInProgress.child.childLanes; + if (stateNode || 0 !== (renderLanes & primaryChildLanes)) return updateSuspenseComponent( current, workInProgress, @@ -9145,7 +9504,13 @@ __DEV__ && pushPrimaryTreeSuspenseHandler(workInProgress); break; case 19: - var didSuspendBefore = 0 !== (current.flags & 128); + if (workInProgress.flags & 128) + return updateSuspenseListComponent( + current, + workInProgress, + renderLanes + ); + primaryChildLanes = 0 !== (current.flags & 128); stateNode = 0 !== (renderLanes & workInProgress.childLanes); stateNode || (propagateParentContextChanges( @@ -9155,7 +9520,7 @@ __DEV__ && !1 ), (stateNode = 0 !== (renderLanes & workInProgress.childLanes))); - if (didSuspendBefore) { + if (primaryChildLanes) { if (stateNode) return updateSuspenseListComponent( current, @@ -9164,16 +9529,12 @@ __DEV__ && ); workInProgress.flags |= 128; } - didSuspendBefore = workInProgress.memoizedState; - null !== didSuspendBefore && - ((didSuspendBefore.rendering = null), - (didSuspendBefore.tail = null), - (didSuspendBefore.lastEffect = null)); - push( - suspenseStackCursor, - suspenseStackCursor.current, - workInProgress - ); + primaryChildLanes = workInProgress.memoizedState; + null !== primaryChildLanes && + ((primaryChildLanes.rendering = null), + (primaryChildLanes.tail = null), + (primaryChildLanes.lastEffect = null)); + pushSuspenseListContext(workInProgress, suspenseStackCursor.current); if (stateNode) break; else return null; case 22: @@ -9198,7 +9559,7 @@ __DEV__ && function beginWork(current, workInProgress, renderLanes) { if (workInProgress._debugNeedsRemount && null !== current) { renderLanes = createFiberFromTypeAndProps( - workInProgress.type, + resolveTypeForHotReloading(workInProgress.elementType), workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, @@ -9231,7 +9592,7 @@ __DEV__ && null === workInProgress ? ((returnFiber.deletions = [current]), (returnFiber.flags |= 16)) : workInProgress.push(current); - renderLanes.flags |= 2; + renderLanes.flags |= 134217730; return renderLanes; } if (null !== current) @@ -9264,6 +9625,7 @@ __DEV__ && resetSuspendedCurrentOnMountInLegacyMode(current, workInProgress), (returnFiber = workInProgress.pendingProps), (current = resolveLazy(prevSibling)), + (current = resolveTypeForHotReloading(current)), (workInProgress.type = current), "function" === typeof current) ) @@ -9273,8 +9635,6 @@ __DEV__ && returnFiber )), (workInProgress.tag = 1), - (workInProgress.type = current = - resolveFunctionForHotReloading(current)), (workInProgress = updateClassComponent( null, workInProgress, @@ -9284,8 +9644,6 @@ __DEV__ && ))) : ((workInProgress.tag = 0), validateFunctionComponentInDev(workInProgress, current), - (workInProgress.type = current = - resolveFunctionForHotReloading(current)), (workInProgress = updateFunctionComponent( null, workInProgress, @@ -9300,8 +9658,6 @@ __DEV__ && prevSibling === REACT_FORWARD_REF_TYPE) ) { workInProgress.tag = 11; - workInProgress.type = current = - resolveForwardRefForHotReloading(current); workInProgress = updateForwardRef( null, workInProgress, @@ -9320,6 +9676,15 @@ __DEV__ && renderLanes ); break a; + } else if (prevSibling === REACT_CONTEXT_TYPE) { + workInProgress.tag = 10; + workInProgress.type = current; + workInProgress = updateContextProvider( + null, + workInProgress, + renderLanes + ); + break a; } workInProgress = ""; null !== current && @@ -9458,10 +9823,12 @@ __DEV__ && ); case 7: return ( + (returnFiber = workInProgress.pendingProps), + markRef(current, workInProgress), reconcileChildren( current, workInProgress, - workInProgress.pendingProps, + returnFiber, renderLanes ), workInProgress.child @@ -9492,25 +9859,7 @@ __DEV__ && workInProgress.child ); case 10: - return ( - (returnFiber = workInProgress.type), - (prevSibling = workInProgress.pendingProps), - (nextProps = prevSibling.value), - "value" in prevSibling || - hasWarnedAboutUsingNoValuePropOnContextProvider || - ((hasWarnedAboutUsingNoValuePropOnContextProvider = !0), - console.error( - "The `value` prop is required for the ``. Did you misspell it or forget to pass it?" - )), - pushProvider(workInProgress, returnFiber, nextProps), - reconcileChildren( - current, - workInProgress, - prevSibling.children, - renderLanes - ), - workInProgress.child - ); + return updateContextProvider(current, workInProgress, renderLanes); case 9: return ( (prevSibling = workInProgress.type._context), @@ -9642,22 +9991,24 @@ __DEV__ && ); nextProps = 0 !== (renderLanes & current.childLanes); if (didReceiveUpdate || nextProps) { - prevSibling = workInProgressRoot; - if ( - null !== prevSibling && - ((nextProps = getBumpedLaneForHydration( - prevSibling, - renderLanes - )), - 0 !== nextProps && nextProps !== returnFiber.retryLane) - ) - throw ( - ((returnFiber.retryLane = nextProps), - enqueueConcurrentRenderForLane(current, nextProps), - scheduleUpdateOnFiber(prevSibling, current, nextProps), - SelectiveHydrationException) - ); - renderDidSuspendDelayIfPossible(); + if (null === currentTreeHiddenStackCursor.current) { + prevSibling = workInProgressRoot; + if ( + null !== prevSibling && + ((nextProps = getBumpedLaneForHydration( + prevSibling, + renderLanes + )), + 0 !== nextProps && nextProps !== returnFiber.retryLane) + ) + throw ( + ((returnFiber.retryLane = nextProps), + enqueueConcurrentRenderForLane(current, nextProps), + scheduleUpdateOnFiber(prevSibling, current, nextProps), + SelectiveHydrationException) + ); + renderDidSuspendDelayIfPossible(); + } workInProgress = retryActivityComponentWithoutHydrating( current, workInProgress, @@ -9668,7 +10019,7 @@ __DEV__ && workInProgress, prevSibling )), - (workInProgress.flags |= 4096); + (workInProgress.flags |= 134221824); } else (returnFiber = current.child), @@ -9746,6 +10097,42 @@ __DEV__ && ), workInProgress.child ); + case 30: + return ( + null === workInProgress.stateNode && + (workInProgress.stateNode = { + autoName: null, + paired: null, + clones: null, + ref: null + }), + (returnFiber = workInProgress.pendingProps), + null != returnFiber.name && + "auto" !== returnFiber.name && + (workInProgress.flags |= null === current ? 18882560 : 18874368), + void 0 !== returnFiber.className && + ((prevSibling = + "string" === typeof returnFiber.className + ? JSON.stringify(returnFiber.className) + : "{...}"), + didWarnAboutClassNameOnViewTransition[prevSibling] || + ((didWarnAboutClassNameOnViewTransition[prevSibling] = !0), + console.error( + ' doesn\'t accept a "className" prop. It has been renamed to "default".\n- \n+ ', + prevSibling, + prevSibling + ))), + null !== current && current.memoizedProps.name !== returnFiber.name + ? (workInProgress.flags |= 4194816) + : markRef(current, workInProgress), + reconcileChildren( + current, + workInProgress, + returnFiber.children, + renderLanes + ), + workInProgress.child + ); case 29: throw workInProgress.pendingProps; } @@ -9866,26 +10253,31 @@ __DEV__ && } function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { - case "hidden": - hasRenderedATailFallback = renderState.tail; - for (var lastTailNode = null; null !== hasRenderedATailFallback; ) - null !== hasRenderedATailFallback.alternate && - (lastTailNode = hasRenderedATailFallback), - (hasRenderedATailFallback = hasRenderedATailFallback.sibling); - null === lastTailNode - ? (renderState.tail = null) - : (lastTailNode.sibling = null); + case "visible": break; case "collapsed": - lastTailNode = renderState.tail; - for (var _lastTailNode = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (_lastTailNode = lastTailNode), - (lastTailNode = lastTailNode.sibling); - null === _lastTailNode + for ( + var tailNode = renderState.tail, lastTailNode = null; + null !== tailNode; + + ) + null !== tailNode.alternate && (lastTailNode = tailNode), + (tailNode = tailNode.sibling); + null === lastTailNode ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (_lastTailNode.sibling = null); + : (lastTailNode.sibling = null); + break; + default: + hasRenderedATailFallback = renderState.tail; + for (tailNode = null; null !== hasRenderedATailFallback; ) + null !== hasRenderedATailFallback.alternate && + (tailNode = hasRenderedATailFallback), + (hasRenderedATailFallback = hasRenderedATailFallback.sibling); + null === tailNode + ? (renderState.tail = null) + : (tailNode.sibling = null); } } function bubbleProperties(completedWork) { @@ -9903,8 +10295,8 @@ __DEV__ && ) (newChildLanes |= _child2.lanes | _child2.childLanes), - (subtreeFlags |= _child2.subtreeFlags & 65011712), - (subtreeFlags |= _child2.flags & 65011712), + (subtreeFlags |= _child2.subtreeFlags & 1206910976), + (subtreeFlags |= _child2.flags & 1206910976), (_treeBaseDuration += _child2.treeBaseDuration), (_child2 = _child2.sibling); completedWork.treeBaseDuration = _treeBaseDuration; @@ -9916,8 +10308,8 @@ __DEV__ && ) (newChildLanes |= _treeBaseDuration.lanes | _treeBaseDuration.childLanes), - (subtreeFlags |= _treeBaseDuration.subtreeFlags & 65011712), - (subtreeFlags |= _treeBaseDuration.flags & 65011712), + (subtreeFlags |= _treeBaseDuration.subtreeFlags & 1206910976), + (subtreeFlags |= _treeBaseDuration.flags & 1206910976), (_treeBaseDuration.return = completedWork), (_treeBaseDuration = _treeBaseDuration.sibling); else if (0 !== (completedWork.mode & 2)) { @@ -10001,7 +10393,7 @@ __DEV__ && requiredContext(contextStackCursor.current); b: { var keepChildren = !current; - _type2 = ReactNativePrivateInterface.diffAttributePayloads( + _type2 = reactPrivateInterface.diffAttributePayloads( _type2, newProps, renderLanes.canonical.viewConfig.validAttributes @@ -10036,19 +10428,19 @@ __DEV__ && "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); bubbleProperties(workInProgress); + workInProgress.subtreeFlags &= -33554433; return null; } requiredContext(contextStackCursor.current); current = requiredContext(rootInstanceStackCursor.current); - renderLanes = nextReactTag; - nextReactTag += 2; + renderLanes = allocateTag(); _type2 = getViewConfigForType(_type2); for (keepChildren in _type2.validAttributes) newProps.hasOwnProperty(keepChildren) && - ReactNativePrivateInterface.deepFreezeAndThrowOnMutationInDev( + reactPrivateInterface.deepFreezeAndThrowOnMutationInDev( newProps[keepChildren] ); - keepChildren = ReactNativePrivateInterface.createAttributePayload( + keepChildren = reactPrivateInterface.createAttributePayload( newProps, _type2.validAttributes ); @@ -10074,6 +10466,7 @@ __DEV__ && workInProgress.stateNode = current; } bubbleProperties(workInProgress); + workInProgress.subtreeFlags &= -33554433; workInProgress.flags &= -16777217; return null; case 6: @@ -10232,6 +10625,7 @@ __DEV__ && return ( popHostContainer(workInProgress), updateHostContainer(current, workInProgress), + (workInProgress.flags |= 67108864), bubbleProperties(workInProgress), null ); @@ -10244,14 +10638,13 @@ __DEV__ && case 17: return bubbleProperties(workInProgress), null; case 19: - pop(suspenseStackCursor, workInProgress); - keepChildren = workInProgress.memoizedState; - if (null === keepChildren) - return bubbleProperties(workInProgress), null; - newProps = 0 !== (workInProgress.flags & 128); - _type2 = keepChildren.rendering; + popSuspenseListContext(workInProgress); + newProps = workInProgress.memoizedState; + if (null === newProps) return bubbleProperties(workInProgress), null; + keepChildren = 0 !== (workInProgress.flags & 128); + _type2 = newProps.rendering; if (null === _type2) - if (newProps) cutOffTailIfNeeded(keepChildren, !1); + if (keepChildren) cutOffTailIfNeeded(newProps, !1); else { if ( workInProgressRootExitStatus !== RootInProgress || @@ -10261,7 +10654,7 @@ __DEV__ && _type2 = findFirstSuspended(current); if (null !== _type2) { workInProgress.flags |= 128; - cutOffTailIfNeeded(keepChildren, !1); + cutOffTailIfNeeded(newProps, !1); current = _type2.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); @@ -10270,71 +10663,90 @@ __DEV__ && for (newProps = workInProgress.child; null !== newProps; ) resetWorkInProgress(newProps, current), (newProps = newProps.sibling); - push( - suspenseStackCursor, + pushSuspenseListContext( + workInProgress, (suspenseStackCursor.current & SubtreeSuspenseContextMask) | - ForceSuspenseFallback, - workInProgress + ForceSuspenseFallback ); return workInProgress.child; } current = current.sibling; } - null !== keepChildren.tail && + null !== newProps.tail && now$1() > workInProgressRootRenderTargetTime && ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(keepChildren, !1), + (keepChildren = !0), + cutOffTailIfNeeded(newProps, !1), (workInProgress.lanes = 4194304)); } else { - if (!newProps) + if (!keepChildren) if (((current = findFirstSuspended(_type2)), null !== current)) { if ( ((workInProgress.flags |= 128), - (newProps = !0), + (keepChildren = !0), (current = current.updateQueue), (workInProgress.updateQueue = current), scheduleRetryEffect(workInProgress, current), - cutOffTailIfNeeded(keepChildren, !0), - null === keepChildren.tail && - "hidden" === keepChildren.tailMode && + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "collapsed" !== newProps.tailMode && + "visible" !== newProps.tailMode && !_type2.alternate) ) return bubbleProperties(workInProgress), null; } else - 2 * now$1() - keepChildren.renderingStartTime > + 2 * now$1() - newProps.renderingStartTime > workInProgressRootRenderTargetTime && 536870912 !== renderLanes && ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(keepChildren, !1), + (keepChildren = !0), + cutOffTailIfNeeded(newProps, !1), (workInProgress.lanes = 4194304)); - keepChildren.isBackwards + newProps.isBackwards ? ((_type2.sibling = workInProgress.child), (workInProgress.child = _type2)) - : ((current = keepChildren.last), + : ((current = newProps.last), null !== current ? (current.sibling = _type2) : (workInProgress.child = _type2), - (keepChildren.last = _type2)); + (newProps.last = _type2)); + } + if (null !== newProps.tail) { + current = newProps.tail; + a: { + for (renderLanes = current; null !== renderLanes; ) { + if (null !== renderLanes.alternate) { + renderLanes = !1; + break a; + } + renderLanes = renderLanes.sibling; + } + renderLanes = !0; + } + newProps.rendering = current; + newProps.tail = current.sibling; + newProps.renderingStartTime = now$1(); + current.sibling = null; + _type2 = suspenseStackCursor.current; + _type2 = keepChildren + ? (_type2 & SubtreeSuspenseContextMask) | ForceSuspenseFallback + : _type2 & SubtreeSuspenseContextMask; + "visible" !== newProps.tailMode && + "collapsed" !== newProps.tailMode && + renderLanes + ? ((newProps = _type2), + push( + suspenseHandlerStackCursor, + workInProgress, + workInProgress + ), + push(suspenseStackCursor, newProps, workInProgress), + null === shellBoundary && (shellBoundary = workInProgress)) + : pushSuspenseListContext(workInProgress, _type2); + return current; } - if (null !== keepChildren.tail) - return ( - (current = keepChildren.tail), - (keepChildren.rendering = current), - (keepChildren.tail = current.sibling), - (keepChildren.renderingStartTime = now$1()), - (current.sibling = null), - (renderLanes = suspenseStackCursor.current), - (renderLanes = newProps - ? (renderLanes & SubtreeSuspenseContextMask) | - ForceSuspenseFallback - : renderLanes & SubtreeSuspenseContextMask), - push(suspenseStackCursor, renderLanes, workInProgress), - current - ); bubbleProperties(workInProgress); return null; case 22: @@ -10383,7 +10795,11 @@ __DEV__ && case 25: return null; case 30: - return null; + return ( + (workInProgress.flags |= 33554432), + bubbleProperties(workInProgress), + null + ); case 29: return null; } @@ -10454,7 +10870,18 @@ __DEV__ && workInProgress) : null; case 19: - return pop(suspenseStackCursor, workInProgress), null; + return ( + popSuspenseListContext(workInProgress), + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), + (current = workInProgress.memoizedState), + null !== current && + ((current.rendering = null), (current.tail = null)), + (workInProgress.flags |= 4), + workInProgress) + : null + ); case 4: return popHostContainer(workInProgress), null; case 10: @@ -10503,7 +10930,7 @@ __DEV__ && popSuspenseHandler(interruptedWork); break; case 19: - pop(suspenseStackCursor, interruptedWork); + popSuspenseListContext(interruptedWork); break; case 10: popProvider(interruptedWork.type, interruptedWork); @@ -10795,6 +11222,27 @@ __DEV__ && break; case 30: instanceToUse = finishedWork.stateNode; + var name = getViewTransitionName( + finishedWork.memoizedProps, + instanceToUse + ); + if (null === instanceToUse.ref || instanceToUse.ref.name !== name) + instanceToUse.ref = createViewTransitionInstance(name); + instanceToUse = instanceToUse.ref; + break; + case 7: + null === finishedWork.stateNode && + ((instanceToUse = new FragmentInstance(finishedWork)), + traverseVisibleInstancesAndTextInstances( + finishedWork.child, + !1, + addFragmentHandleToFiber, + instanceToUse, + void 0, + void 0 + ), + (finishedWork.stateNode = instanceToUse)); + instanceToUse = finishedWork.stateNode; break; default: instanceToUse = finishedWork.stateNode; @@ -10903,6 +11351,39 @@ __DEV__ && commitStartTime ); } + function pushMutationContext() { + var prev = viewTransitionMutationContext; + viewTransitionMutationContext = !1; + return prev; + } + function commitFragmentInstanceInsertionEffects(fiber) { + for (var parent = fiber.return; null !== parent; ) { + isFragmentInstanceParent(parent) && + commitNewChildToFragmentInstance(fiber.stateNode, parent.stateNode); + if (isFragmentInstanceHostBoundary(parent)) break; + parent = parent.return; + } + } + function commitFragmentInstanceDeletionEffects(fiber) { + for (var parent = fiber.return; null !== parent; ) { + if (isFragmentInstanceParent(parent)) { + var childInstance = fiber.stateNode, + fragmentInstance = parent.stateNode; + null != childInstance.canonical && + ((childInstance = getPublicInstance(childInstance)), + null != childInstance.reactFragments && + childInstance.reactFragments.delete(fragmentInstance)); + } + if (isFragmentInstanceHostBoundary(parent)) break; + parent = parent.return; + } + } + function isFragmentInstanceHostBoundary(fiber) { + return 5 === fiber.tag || 3 === fiber.tag || !1; + } + function isFragmentInstanceParent(fiber) { + return fiber && 7 === fiber.tag && null !== fiber.stateNode; + } function commitHostMount(finishedWork) { var type = finishedWork.type, props = finishedWork.memoizedProps, @@ -10920,7 +11401,62 @@ __DEV__ && captureCommitPhaseError(finishedWork, finishedWork.return, error); } } - function commitPlacement() {} + function commitPlacement(finishedWork) { + for ( + var parentFragmentInstances = null, parent = finishedWork.return; + null !== parent; + + ) { + if (isFragmentInstanceParent(parent)) { + var fragmentInstance = parent.stateNode; + null === parentFragmentInstances + ? (parentFragmentInstances = [fragmentInstance]) + : parentFragmentInstances.push(fragmentInstance); + } + if (isFragmentInstanceHostBoundary(parent)) break; + parent = parent.return; + } + commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ); + } + function commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ) { + if (5 === finishedWork.tag) { + if ( + (5 === finishedWork.tag || + 27 === finishedWork.tag || + 6 === finishedWork.tag) && + null === finishedWork.alternate && + null !== parentFragmentInstances + ) + for (var i = 0; i < parentFragmentInstances.length; i++) + commitNewChildToFragmentInstance( + finishedWork.stateNode, + parentFragmentInstances[i] + ); + } else if ( + 4 !== finishedWork.tag && + ((finishedWork = finishedWork.child), null !== finishedWork) + ) + for ( + commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ), + finishedWork = finishedWork.sibling; + null !== finishedWork; + + ) + commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ), + (finishedWork = finishedWork.sibling); + } function commitHostPortalContainerChildren( portal, finishedWork, @@ -10938,6 +11474,230 @@ __DEV__ && captureCommitPhaseError(finishedWork, finishedWork.return, error); } } + function trackEnterViewTransitions(placement) { + if (30 === placement.tag || 0 !== (placement.subtreeFlags & 33554432)) + shouldStartViewTransition = !0; + } + function pushViewTransitionCancelableScope() { + var prevChildren = viewTransitionCancelableChildren; + viewTransitionCancelableChildren = null; + return prevChildren; + } + function applyViewTransitionToHostInstances() { + viewTransitionHostInstanceIdx = 0; + return !1; + } + function commitAppearingPairViewTransitions(placement) { + if (0 !== (placement.subtreeFlags & 18874368)) + for (placement = placement.child; null !== placement; ) { + if (22 !== placement.tag || null === placement.memoizedState) + if ( + (commitAppearingPairViewTransitions(placement), + 30 === placement.tag && + 0 !== (placement.flags & 18874368) && + placement.stateNode.paired) + ) { + var props = placement.memoizedProps; + if (null == props.name || "auto" === props.name) + throw Error( + "Found a pair with an auto name. This is a bug in React." + ); + "none" !== + getViewTransitionClassName(props.default, props.share) && + applyViewTransitionToHostInstances(placement); + } + placement = placement.sibling; + } + } + function commitEnterViewTransitions(placement, gesture) { + if (30 === placement.tag) { + var state = placement.stateNode, + props = placement.memoizedProps; + getViewTransitionName(props, state); + "none" !== + getViewTransitionClassName( + props.default, + state.paired ? props.share : props.enter + ) + ? applyViewTransitionToHostInstances(placement) && + (commitAppearingPairViewTransitions(placement), + state.paired || + gesture || + scheduleViewTransitionEvent(placement, props.onEnter)) + : commitAppearingPairViewTransitions(placement); + } else if (0 !== (placement.subtreeFlags & 33554432)) + for (placement = placement.child; null !== placement; ) + commitEnterViewTransitions(placement, gesture), + (placement = placement.sibling); + else commitAppearingPairViewTransitions(placement); + } + function commitDeletedPairViewTransitions(deletion) { + if ( + null !== appearingViewTransitions && + 0 !== appearingViewTransitions.size + ) { + var pairs = appearingViewTransitions; + if (0 !== (deletion.subtreeFlags & 18874368)) + for (deletion = deletion.child; null !== deletion; ) { + if (22 !== deletion.tag || null === deletion.memoizedState) { + if (30 === deletion.tag && 0 !== (deletion.flags & 18874368)) { + var props = deletion.memoizedProps, + name = props.name; + if (null != name && "auto" !== name) { + var pair = pairs.get(name); + if (void 0 !== pair) { + if ( + "none" !== + getViewTransitionClassName( + props.default, + props.share + ) && + applyViewTransitionToHostInstances(deletion) + ) { + var oldInstance = deletion.stateNode; + pair.paired = oldInstance; + oldInstance.paired = pair; + scheduleViewTransitionEvent(deletion, props.onShare); + } + pairs.delete(name); + if (0 === pairs.size) break; + } + } + } + commitDeletedPairViewTransitions(deletion); + } + deletion = deletion.sibling; + } + } + } + function commitExitViewTransitions(deletion) { + if (30 === deletion.tag) { + var props = deletion.memoizedProps, + name = getViewTransitionName(props, deletion.stateNode), + pair = + null !== appearingViewTransitions + ? appearingViewTransitions.get(name) + : void 0; + if ( + "none" !== + getViewTransitionClassName( + props.default, + void 0 !== pair ? props.share : props.exit + ) && + applyViewTransitionToHostInstances(deletion) + ) + if (void 0 !== pair) { + var oldInstance = deletion.stateNode; + pair.paired = oldInstance; + oldInstance.paired = pair; + appearingViewTransitions.delete(name); + scheduleViewTransitionEvent(deletion, props.onShare); + } else scheduleViewTransitionEvent(deletion, props.onExit); + null !== appearingViewTransitions && + commitDeletedPairViewTransitions(deletion); + } else if (0 !== (deletion.subtreeFlags & 33554432)) + for (deletion = deletion.child; null !== deletion; ) + commitExitViewTransitions(deletion), (deletion = deletion.sibling); + else + null !== appearingViewTransitions && + commitDeletedPairViewTransitions(deletion); + } + function commitNestedViewTransitions(changedParent) { + for (changedParent = changedParent.child; null !== changedParent; ) { + if (30 === changedParent.tag) { + var props = changedParent.memoizedProps, + name = getViewTransitionName(props, changedParent.stateNode); + props = getViewTransitionClassName(props.default, props.update); + changedParent.flags &= -5; + "none" !== props && + applyViewTransitionToHostInstances( + changedParent, + name, + props, + (changedParent.memoizedState = []) + ); + } else + 0 !== (changedParent.subtreeFlags & 33554432) && + commitNestedViewTransitions(changedParent); + changedParent = changedParent.sibling; + } + } + function restorePairedViewTransitions(parent) { + if (0 !== (parent.subtreeFlags & 18874368)) + for (parent = parent.child; null !== parent; ) { + if (22 !== parent.tag || null === parent.memoizedState) { + if (30 === parent.tag && 0 !== (parent.flags & 18874368)) { + var instance = parent.stateNode; + null !== instance.paired && (instance.paired = null); + } + restorePairedViewTransitions(parent); + } + parent = parent.sibling; + } + } + function restoreEnterOrExitViewTransitions(fiber) { + if (30 === fiber.tag) + (fiber.stateNode.paired = null), restorePairedViewTransitions(fiber); + else if (0 !== (fiber.subtreeFlags & 33554432)) + for (fiber = fiber.child; null !== fiber; ) + restoreEnterOrExitViewTransitions(fiber), (fiber = fiber.sibling); + else restorePairedViewTransitions(fiber); + } + function measureNestedViewTransitions(changedParent, gesture) { + for (changedParent = changedParent.child; null !== changedParent; ) { + if (30 === changedParent.tag) { + var props = changedParent.memoizedProps, + state = changedParent.stateNode; + getViewTransitionName(props, state); + getViewTransitionClassName(props.default, props.update); + gesture + ? ((props = state.clones), + null !== props && props.map(measureClonedInstance)) + : (changedParent.memoizedState = null); + viewTransitionHostInstanceIdx = 0; + } else + 0 !== (changedParent.subtreeFlags & 33554432) && + measureNestedViewTransitions(changedParent, gesture); + changedParent = changedParent.sibling; + } + } + function trackNamedViewTransition(fiber) { + var name = fiber.memoizedProps.name; + if (null != name && "auto" !== name) { + var existing = mountedNamedViewTransitions.get(name); + if (void 0 !== existing) { + if ( + existing !== fiber && + existing !== fiber.alternate && + !didWarnAboutName[name] + ) { + didWarnAboutName[name] = !0; + var stringifiedName = JSON.stringify(name); + runWithFiberInDEV(fiber, function () { + console.error( + "There are two components with the same name mounted at the same time. This is not supported and will cause View Transitions to error. Try to use a more unique name e.g. by using a namespace prefix and adding the id of an item to the name.", + stringifiedName + ); + }); + runWithFiberInDEV(existing, function () { + console.error( + "The existing duplicate has this stack trace.", + stringifiedName + ); + }); + } + } else mountedNamedViewTransitions.set(name, fiber); + } + } + function untrackNamedViewTransition(fiber) { + var name = fiber.memoizedProps.name; + if (null != name && "auto" !== name) { + var existing = mountedNamedViewTransitions.get(name); + void 0 === existing || + (existing !== fiber && existing !== fiber.alternate) || + mountedNamedViewTransitions.delete(name); + } + } function isHydratingParent(current, finishedWork) { return 31 === finishedWork.tag ? ((finishedWork = finishedWork.memoizedState), @@ -10953,62 +11713,113 @@ __DEV__ && 0 === (finishedWork.flags & 256) : !1; } - function commitBeforeMutationEffects(root, firstChild) { - for (nextEffect = firstChild; null !== nextEffect; ) + function commitBeforeMutationEffects(root, firstChild, committedLanes) { + root = (committedLanes & 335544064) === committedLanes; + nextEffect = firstChild; + for (firstChild = root ? 9270 : 1024; null !== nextEffect; ) { + committedLanes = nextEffect; + if (root) { + var deletions = committedLanes.deletions; + if (null !== deletions) + for (var i = 0; i < deletions.length; i++) + root && commitExitViewTransitions(deletions[i]); + } if ( - ((root = nextEffect), - (firstChild = root.child), - 0 !== (root.subtreeFlags & 1028) && null !== firstChild) + null === committedLanes.alternate && + 0 !== (committedLanes.flags & 2) ) - (firstChild.return = root), (nextEffect = firstChild); - else - for (; null !== nextEffect; ) { - firstChild = root = nextEffect; - var current = firstChild.alternate, - flags = firstChild.flags; - switch (firstChild.tag) { - case 0: - if ( - 0 !== (flags & 4) && - ((firstChild = firstChild.updateQueue), - (firstChild = null !== firstChild ? firstChild.events : null), - null !== firstChild) - ) - for (current = 0; current < firstChild.length; current++) - (flags = firstChild[current]), - (flags.ref.impl = flags.nextImpl); - break; - case 11: - case 15: - break; - case 1: - 0 !== (flags & 1024) && - null !== current && - commitClassSnapshot(firstChild, current); - break; - case 3: - break; - case 5: - case 26: - case 27: - case 6: - case 4: - case 17: - break; - default: - if (0 !== (flags & 1024)) - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - firstChild = root.sibling; - if (null !== firstChild) { - firstChild.return = root.return; - nextEffect = firstChild; - break; + root && trackEnterViewTransitions(committedLanes), + commitBeforeMutationEffects_complete(root); + else { + if (22 === committedLanes.tag && 0 !== (committedLanes.mode & 1)) + if ( + ((deletions = committedLanes.alternate), + null !== committedLanes.memoizedState) + ) { + null !== deletions && + null === deletions.memoizedState && + root && + commitExitViewTransitions(deletions); + commitBeforeMutationEffects_complete(root); + continue; + } else if (null !== deletions && null !== deletions.memoizedState) { + root && trackEnterViewTransitions(committedLanes); + commitBeforeMutationEffects_complete(root); + continue; } - nextEffect = root.return; - } + deletions = committedLanes.child; + 0 !== (committedLanes.subtreeFlags & firstChild) && null !== deletions + ? ((deletions.return = committedLanes), (nextEffect = deletions)) + : (root && commitNestedViewTransitions(committedLanes), + commitBeforeMutationEffects_complete(root)); + } + } + appearingViewTransitions = null; + } + function commitBeforeMutationEffects_complete( + isViewTransitionEligible$jscomp$0 + ) { + for (; null !== nextEffect; ) { + var fiber = nextEffect, + finishedWork = fiber, + isViewTransitionEligible = isViewTransitionEligible$jscomp$0, + current = finishedWork.alternate, + flags = finishedWork.flags; + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + break; + case 1: + 0 !== (flags & 1024) && + null !== current && + commitClassSnapshot(finishedWork, current); + break; + case 3: + break; + case 5: + case 26: + case 27: + case 6: + case 4: + case 17: + break; + case 30: + isViewTransitionEligible && + null !== current && + ((isViewTransitionEligible = current), + (current = finishedWork), + (finishedWork = getViewTransitionName( + isViewTransitionEligible.memoizedProps, + isViewTransitionEligible.stateNode + )), + (current = current.memoizedProps), + (current = getViewTransitionClassName( + current.default, + current.update + )), + "none" !== current && + applyViewTransitionToHostInstances( + isViewTransitionEligible, + finishedWork, + current, + (isViewTransitionEligible.memoizedState = []) + )); + break; + default: + if (0 !== (flags & 1024)) + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + isViewTransitionEligible = fiber.sibling; + if (null !== isViewTransitionEligible) { + isViewTransitionEligible.return = fiber.return; + nextEffect = isViewTransitionEligible; + break; + } + nextEffect = fiber.return; + } } function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { var prevEffectStart = pushComponentEffectStart(), @@ -11199,18 +12010,21 @@ __DEV__ && offscreenSubtreeIsHidden), !flags) ) { - current = + var newOffscreenSubtreeWasHidden = (null !== current && null !== current.memoizedState) || offscreenSubtreeWasHidden; - prevProps = offscreenSubtreeIsHidden; - var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; + current = offscreenSubtreeIsHidden; + prevProps = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = flags; - (offscreenSubtreeWasHidden = current) && - !prevOffscreenSubtreeWasHidden - ? (recursivelyTraverseReappearLayoutEffects( + (offscreenSubtreeWasHidden = newOffscreenSubtreeWasHidden) && + !prevProps + ? ((flags = NoLayoutEffectTraversalFlags), + 0 !== (finishedWork.subtreeFlags & 8772) && + (flags |= IncludeWorkInProgressEffects), + recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - 0 !== (finishedWork.subtreeFlags & 8772) + flags ), 0 !== (finishedWork.mode & 2) && 0 <= componentEffectStartTime && @@ -11222,13 +12036,18 @@ __DEV__ && componentEffectEndTime )) : recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); - offscreenSubtreeIsHidden = prevProps; - offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; + offscreenSubtreeIsHidden = current; + offscreenSubtreeWasHidden = prevProps; } } else recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); break; case 30: + flags & 18874368 && trackNamedViewTransition(finishedWork); + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + flags & 512 && safelyAttachRef(finishedWork, finishedWork.return); break; + case 7: + flags & 512 && safelyAttachRef(finishedWork, finishedWork.return); default: recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); } @@ -11320,8 +12139,11 @@ __DEV__ && case 27: case 5: offscreenSubtreeWasHidden || - safelyDetachRef(deletedFiber, nearestMountedAncestor); + safelyDetachRef(deletedFiber, nearestMountedAncestor), + commitFragmentInstanceDeletionEffects(deletedFiber); case 6: + 6 === deletedFiber.tag && + commitFragmentInstanceDeletionEffects(deletedFiber); recursivelyTraverseDeletionEffects( finishedRoot, nearestMountedAncestor, @@ -11346,12 +12168,11 @@ __DEV__ && case 11: case 14: case 15: - offscreenSubtreeWasHidden || - commitHookEffectListUnmount( - Insertion, - deletedFiber, - nearestMountedAncestor - ); + commitHookEffectListUnmount( + Insertion, + deletedFiber, + nearestMountedAncestor + ); offscreenSubtreeWasHidden || commitHookLayoutUnmountEffects( deletedFiber, @@ -11405,6 +12226,25 @@ __DEV__ && deletedFiber ); break; + case 30: + deletedFiber.flags & 18874368 && + untrackNamedViewTransition(deletedFiber); + safelyDetachRef(deletedFiber, nearestMountedAncestor); + recursivelyTraverseDeletionEffects( + finishedRoot, + nearestMountedAncestor, + deletedFiber + ); + break; + case 7: + offscreenSubtreeWasHidden || + safelyDetachRef(deletedFiber, nearestMountedAncestor); + recursivelyTraverseDeletionEffects( + finishedRoot, + nearestMountedAncestor, + deletedFiber + ); + break; default: recursivelyTraverseDeletionEffects( finishedRoot, @@ -11470,7 +12310,11 @@ __DEV__ && } }); } - function recursivelyTraverseMutationEffects(root$jscomp$0, parentFiber) { + function recursivelyTraverseMutationEffects( + root$jscomp$0, + parentFiber, + lanes + ) { var deletions = parentFiber.deletions; if (null !== deletions) for (var i = 0; i < deletions.length; i++) { @@ -11497,10 +12341,10 @@ __DEV__ && } if (parentFiber.subtreeFlags & 13886) for (parentFiber = parentFiber.child; null !== parentFiber; ) - commitMutationEffectsOnFiber(parentFiber, root$jscomp$0), + commitMutationEffectsOnFiber(parentFiber, root$jscomp$0, lanes), (parentFiber = parentFiber.sibling); } - function commitMutationEffectsOnFiber(finishedWork, root) { + function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevEffectStart = pushComponentEffectStart(), prevEffectDuration = pushComponentEffectDuration(), prevEffectErrors = pushComponentEffectErrors(), @@ -11512,7 +12356,17 @@ __DEV__ && case 11: case 14: case 15: - recursivelyTraverseMutationEffects(root, finishedWork); + if ( + flags & 4 && + ((current = finishedWork.updateQueue), + (current = null !== current ? current.events : null), + null !== current) + ) + for (var ii = 0; ii < current.length; ii++) { + var _eventPayloads$ii2 = current[ii]; + _eventPayloads$ii2.ref.impl = _eventPayloads$ii2.nextImpl; + } + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 4 && (commitHookEffectListUnmount( @@ -11528,7 +12382,7 @@ __DEV__ && )); break; case 1: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 512 && (offscreenSubtreeWasHidden || @@ -11538,16 +12392,16 @@ __DEV__ && offscreenSubtreeIsHidden && ((root = finishedWork.updateQueue), null !== root && - ((flags = root.callbacks), - null !== flags && - ((current = root.shared.hiddenCallbacks), + ((lanes = root.callbacks), + null !== lanes && + ((flags = root.shared.hiddenCallbacks), (root.shared.hiddenCallbacks = - null === current ? flags : current.concat(flags))))); + null === flags ? lanes : flags.concat(lanes))))); break; case 26: case 27: case 5: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 512 && (offscreenSubtreeWasHidden || @@ -11557,32 +12411,40 @@ __DEV__ && (finishedWork.alternate.stateNode = finishedWork.stateNode); break; case 6: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); break; case 3: current = pushNestedEffectDurations(); - recursivelyTraverseMutationEffects(root, finishedWork); + viewTransitionMutationContext = !1; + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & 4) { - flags = root.containerInfo; - var pendingChildren = root.pendingChildren; + lanes = root.containerInfo; + flags = root.pendingChildren; try { runWithFiberInDEV( finishedWork, replaceContainerChildren, - flags, - pendingChildren - ); + lanes, + flags + ), + (viewTransitionMutationContext = !0); } catch (error) { captureCommitPhaseError(finishedWork, finishedWork.return, error); } } root.effectDuration += popNestedEffectDurations(current); + viewTransitionMutationContext = !1; break; case 4: - recursivelyTraverseMutationEffects(root, finishedWork); + current = pushMutationContext(); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); + viewTransitionMutationContext && + inUpdateViewTransition && + (rootViewTransitionAffected = !0); + viewTransitionMutationContext = current; flags & 4 && commitHostPortalContainerChildren( finishedWork.stateNode, @@ -11592,13 +12454,13 @@ __DEV__ && break; case 12: flags = pushNestedEffectDurations(); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); finishedWork.stateNode.effectDuration += bubbleNestedEffectDurations(flags); break; case 31: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 4 && ((root = finishedWork.updateQueue), @@ -11607,7 +12469,7 @@ __DEV__ && attachSuspenseRetryListeners(finishedWork, root))); break; case 13: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); finishedWork.child.flags & 8192 && ((root = null !== current && null !== current.memoizedState), @@ -11621,20 +12483,20 @@ __DEV__ && attachSuspenseRetryListeners(finishedWork, root))); break; case 22: - pendingChildren = null !== finishedWork.memoizedState; - var wasHidden = null !== current && null !== current.memoizedState; + ii = null !== finishedWork.memoizedState; + _eventPayloads$ii2 = + null !== current && null !== current.memoizedState; if (finishedWork.mode & 1) { var prevOffscreenSubtreeIsHidden = offscreenSubtreeIsHidden, prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; - offscreenSubtreeIsHidden = - prevOffscreenSubtreeIsHidden || pendingChildren; + offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || ii; offscreenSubtreeWasHidden = - prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + prevOffscreenSubtreeWasHidden || _eventPayloads$ii2; + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; - wasHidden && - !pendingChildren && + _eventPayloads$ii2 && + !ii && !prevOffscreenSubtreeIsHidden && !prevOffscreenSubtreeWasHidden && 0 !== (finishedWork.mode & 2) && @@ -11646,20 +12508,25 @@ __DEV__ && componentEffectStartTime, componentEffectEndTime ); - } else recursivelyTraverseMutationEffects(root, finishedWork); + } else recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 8192 && ((root = finishedWork.stateNode), - (root._visibility = pendingChildren + (root._visibility = ii ? root._visibility & ~OffscreenVisible : root._visibility | OffscreenVisible), - !pendingChildren || + !ii || null === current || - wasHidden || + _eventPayloads$ii2 || offscreenSubtreeIsHidden || offscreenSubtreeWasHidden || 0 === (finishedWork.mode & 1) || - (recursivelyTraverseDisappearLayoutEffects(finishedWork), + ((root = _eventPayloads$ii2 || offscreenSubtreeWasHidden), + (lanes = offscreenSubtreeIsHidden), + (current = offscreenSubtreeWasHidden), + (offscreenSubtreeIsHidden = ii || offscreenSubtreeIsHidden), + (offscreenSubtreeWasHidden = root), + recursivelyTraverseDisappearLayoutEffects(finishedWork), 0 !== (finishedWork.mode & 2) && 0 <= componentEffectStartTime && 0 <= componentEffectEndTime && @@ -11669,17 +12536,19 @@ __DEV__ && componentEffectStartTime, componentEffectEndTime, "Disconnect" - ))); + ), + (offscreenSubtreeIsHidden = lanes), + (offscreenSubtreeWasHidden = current))); flags & 4 && ((root = finishedWork.updateQueue), null !== root && - ((flags = root.retryQueue), - null !== flags && + ((lanes = root.retryQueue), + null !== lanes && ((root.retryQueue = null), - attachSuspenseRetryListeners(finishedWork, flags)))); + attachSuspenseRetryListeners(finishedWork, lanes)))); break; case 19: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 4 && ((root = finishedWork.updateQueue), @@ -11688,11 +12557,42 @@ __DEV__ && attachSuspenseRetryListeners(finishedWork, root))); break; case 30: + flags & 512 && + (offscreenSubtreeWasHidden || + null === current || + safelyDetachRef(current, current.return)); + flags = pushMutationContext(); + ii = inUpdateViewTransition; + _eventPayloads$ii2 = (lanes & 335544064) === lanes; + prevOffscreenSubtreeIsHidden = finishedWork.memoizedProps; + inUpdateViewTransition = + _eventPayloads$ii2 && + "none" !== + getViewTransitionClassName( + prevOffscreenSubtreeIsHidden.default, + prevOffscreenSubtreeIsHidden.update + ); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); + commitReconciliationEffects(finishedWork); + _eventPayloads$ii2 && + null !== current && + viewTransitionMutationContext && + (finishedWork.flags |= 4); + inUpdateViewTransition = ii; + viewTransitionMutationContext = flags; break; case 21: break; + case 7: + flags & 512 && + (offscreenSubtreeWasHidden || + null === current || + safelyDetachRef(current, current.return)), + current && + null !== current.stateNode && + (current.stateNode._fragmentFiber = finishedWork); default: - recursivelyTraverseMutationEffects(root, finishedWork), + recursivelyTraverseMutationEffects(root, finishedWork, lanes), commitReconciliationEffects(finishedWork); } 0 !== (finishedWork.mode & 2) && @@ -11737,6 +12637,80 @@ __DEV__ && } flags & 4096 && (finishedWork.flags &= -4097); } + function recursivelyTraverseAfterMutationEffects(root, parentFiber) { + if (parentFiber.subtreeFlags & 9270) + for (parentFiber = parentFiber.child; null !== parentFiber; ) + commitAfterMutationEffectsOnFiber(parentFiber, root), + (parentFiber = parentFiber.sibling); + else measureNestedViewTransitions(parentFiber, !1); + } + function commitAfterMutationEffectsOnFiber(finishedWork, root) { + var current = finishedWork.alternate; + if (null === current) commitEnterViewTransitions(finishedWork, !1); + else + switch (finishedWork.tag) { + case 3: + viewTransitionContextChanged = !1; + pushViewTransitionCancelableScope(); + recursivelyTraverseAfterMutationEffects(root, finishedWork); + if ( + !viewTransitionContextChanged && + !rootViewTransitionAffected && + ((finishedWork = viewTransitionCancelableChildren), + null !== finishedWork) + ) + for (current = 0; current < finishedWork.length; current += 3) + console.warn("cancelViewTransitionName is not implemented"); + viewTransitionCancelableChildren = null; + break; + case 5: + recursivelyTraverseAfterMutationEffects(root, finishedWork); + break; + case 4: + current = viewTransitionContextChanged; + viewTransitionContextChanged = !1; + recursivelyTraverseAfterMutationEffects(root, finishedWork); + viewTransitionContextChanged && (rootViewTransitionAffected = !0); + viewTransitionContextChanged = current; + break; + case 22: + 0 !== (finishedWork.mode & 1) + ? null === finishedWork.memoizedState && + (null !== current.memoizedState + ? commitEnterViewTransitions(finishedWork, !1) + : recursivelyTraverseAfterMutationEffects(root, finishedWork)) + : recursivelyTraverseAfterMutationEffects(root, finishedWork); + break; + case 30: + var _prevContextChanged = viewTransitionContextChanged, + prevCancelableChildren = pushViewTransitionCancelableScope(); + viewTransitionContextChanged = !1; + recursivelyTraverseAfterMutationEffects(root, finishedWork); + viewTransitionContextChanged && (finishedWork.flags |= 4); + root = finishedWork.memoizedProps; + var state = finishedWork.stateNode; + getViewTransitionName(root, state); + getViewTransitionName(current.memoizedProps, state); + "none" !== getViewTransitionClassName(root.default, root.update) && + ((root = current.memoizedState), + (current.memoizedState = null), + (viewTransitionHostInstanceIdx = 0), + viewTransitionHostInstanceIdx !== + (null === root ? 0 : root.length) && + (finishedWork.flags |= 32)); + null !== prevCancelableChildren && + (prevCancelableChildren.push.apply( + prevCancelableChildren, + viewTransitionCancelableChildren + ), + (viewTransitionCancelableChildren = prevCancelableChildren)); + viewTransitionContextChanged = + 0 !== (finishedWork.flags & 32) ? !0 : _prevContextChanged; + break; + default: + recursivelyTraverseAfterMutationEffects(root, finishedWork); + } + } function recursivelyTraverseLayoutEffects(root, parentFiber) { if (parentFiber.subtreeFlags & 8772) for (parentFiber = parentFiber.child; null !== parentFiber; ) @@ -11772,8 +12746,16 @@ __DEV__ && recursivelyTraverseDisappearLayoutEffects(finishedWork); break; case 27: - case 26: case 5: + safelyDetachRef(finishedWork, finishedWork.return); + (5 !== finishedWork.tag && 27 !== finishedWork.tag) || + commitFragmentInstanceDeletionEffects(finishedWork); + recursivelyTraverseDisappearLayoutEffects(finishedWork); + break; + case 6: + commitFragmentInstanceDeletionEffects(finishedWork); + break; + case 26: safelyDetachRef(finishedWork, finishedWork.return); recursivelyTraverseDisappearLayoutEffects(finishedWork); break; @@ -11782,8 +12764,13 @@ __DEV__ && recursivelyTraverseDisappearLayoutEffects(finishedWork); break; case 30: + finishedWork.flags & 18874368 && + untrackNamedViewTransition(finishedWork); + safelyDetachRef(finishedWork, finishedWork.return); recursivelyTraverseDisappearLayoutEffects(finishedWork); break; + case 7: + safelyDetachRef(finishedWork, finishedWork.return); default: recursivelyTraverseDisappearLayoutEffects(finishedWork); } @@ -11812,13 +12799,16 @@ __DEV__ && finishedRoot, current, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ) { var prevEffectStart = pushComponentEffectStart(), prevEffectDuration = pushComponentEffectDuration(), prevEffectErrors = pushComponentEffectErrors(), prevEffectDidSpawnUpdate = pushComponentEffectDidSpawnUpdate(), - flags = finishedWork.flags; + flags = finishedWork.flags, + includeWorkInProgressEffects = + (layoutEffectTraversalFlags & IncludeWorkInProgressEffects) !== + NoLayoutEffectTraversalFlags; switch (finishedWork.tag) { case 0: case 11: @@ -11826,7 +12816,7 @@ __DEV__ && recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); commitHookLayoutEffects(finishedWork, Layout); break; @@ -11834,7 +12824,7 @@ __DEV__ && recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); commitClassDidMount(finishedWork); current = finishedWork.updateQueue; @@ -11857,12 +12847,28 @@ __DEV__ && safelyAttachRef(finishedWork, finishedWork.return); break; case 27: - case 26: case 5: + (5 !== finishedWork.tag && 27 !== finishedWork.tag) || + commitFragmentInstanceInsertionEffects(finishedWork); + recursivelyTraverseReappearLayoutEffects( + finishedRoot, + finishedWork, + layoutEffectTraversalFlags + ); + includeWorkInProgressEffects && + null === current && + flags & 4 && + commitHostMount(finishedWork); + safelyAttachRef(finishedWork, finishedWork.return); + break; + case 6: + commitFragmentInstanceInsertionEffects(finishedWork); + break; + case 26: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); includeWorkInProgressEffects && null === current && @@ -11876,7 +12882,7 @@ __DEV__ && recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); includeWorkInProgressEffects = finishedWork.stateNode; includeWorkInProgressEffects.effectDuration += @@ -11897,21 +12903,21 @@ __DEV__ && recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); break; case 31: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); break; case 13: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); break; case 22: @@ -11919,17 +12925,26 @@ __DEV__ && recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); safelyAttachRef(finishedWork, finishedWork.return); break; case 30: + recursivelyTraverseReappearLayoutEffects( + finishedRoot, + finishedWork, + layoutEffectTraversalFlags + ); + flags & 18874368 && trackNamedViewTransition(finishedWork); + safelyAttachRef(finishedWork, finishedWork.return); break; + case 7: + safelyAttachRef(finishedWork, finishedWork.return); default: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); } 0 !== (finishedWork.mode & 2) && @@ -11951,16 +12966,18 @@ __DEV__ && function recursivelyTraverseReappearLayoutEffects( finishedRoot, parentFiber, - includeWorkInProgressEffects + layoutEffectTraversalFlags ) { - includeWorkInProgressEffects = - includeWorkInProgressEffects && 0 !== (parentFiber.subtreeFlags & 8772); + layoutEffectTraversalFlags = + 0 !== (parentFiber.subtreeFlags & 8772) + ? layoutEffectTraversalFlags + : layoutEffectTraversalFlags & ~IncludeWorkInProgressEffects; for (parentFiber = parentFiber.child; null !== parentFiber; ) reappearLayoutEffects( finishedRoot, parentFiber.alternate, parentFiber, - includeWorkInProgressEffects + layoutEffectTraversalFlags ), (parentFiber = parentFiber.sibling); } @@ -11994,7 +13011,8 @@ __DEV__ && endTime ) { if ( - parentFiber.subtreeFlags & 10256 || + parentFiber.subtreeFlags & + ((committedLanes & 335544064) === committedLanes ? 10262 : 10256) || (0 !== parentFiber.actualDuration && (null === parentFiber.alternate || parentFiber.alternate.child !== parentFiber.child)) @@ -12023,7 +13041,14 @@ __DEV__ && prevEffectErrors = pushComponentEffectErrors(), prevEffectDidSpawnUpdate = pushComponentEffectDidSpawnUpdate(), prevDeepEquality = alreadyWarnedForDeepEquality, - flags = finishedWork.flags; + isViewTransitionEligible = + (committedLanes & 335544064) === committedLanes; + isViewTransitionEligible && + null === finishedWork.alternate && + null !== finishedWork.return && + null !== finishedWork.return.alternate && + restoreEnterOrExitViewTransitions(finishedWork); + var flags = finishedWork.flags; switch (finishedWork.tag) { case 0: case 11: @@ -12075,8 +13100,8 @@ __DEV__ && ); break; case 3: - var prevProfilerEffectDuration = pushNestedEffectDurations(), - wasInHydratedSubtree = inHydratedSubtree; + var prevProfilerEffectDuration = pushNestedEffectDurations(); + isViewTransitionEligible = inHydratedSubtree; inHydratedSubtree = null !== finishedWork.alternate && finishedWork.alternate.memoizedState.isDehydrated && @@ -12088,7 +13113,7 @@ __DEV__ && committedTransitions, endTime ); - inHydratedSubtree = wasInHydratedSubtree; + inHydratedSubtree = isViewTransitionEligible; flags & 2048 && ((committedLanes = null), null !== finishedWork.alternate && @@ -12141,12 +13166,13 @@ __DEV__ && null !== finishedWork.alternate ? finishedWork.alternate.memoizedState : null; - wasInHydratedSubtree = finishedWork.memoizedState; - null !== prevProfilerEffectDuration && null === wasInHydratedSubtree - ? ((wasInHydratedSubtree = finishedWork.deletions), - null !== wasInHydratedSubtree && - 0 < wasInHydratedSubtree.length && - 18 === wasInHydratedSubtree[0].tag + isViewTransitionEligible = finishedWork.memoizedState; + null !== prevProfilerEffectDuration && + null === isViewTransitionEligible + ? ((isViewTransitionEligible = finishedWork.deletions), + null !== isViewTransitionEligible && + 0 < isViewTransitionEligible.length && + 18 === isViewTransitionEligible[0].tag ? ((inHydratedSubtree = !1), (prevProfilerEffectDuration = prevProfilerEffectDuration.hydrationErrors), @@ -12174,16 +13200,16 @@ __DEV__ && null !== finishedWork.alternate ? finishedWork.alternate.memoizedState : null; - wasInHydratedSubtree = finishedWork.memoizedState; + isViewTransitionEligible = finishedWork.memoizedState; null === prevProfilerEffectDuration || null === prevProfilerEffectDuration.dehydrated || - (null !== wasInHydratedSubtree && - null !== wasInHydratedSubtree.dehydrated) + (null !== isViewTransitionEligible && + null !== isViewTransitionEligible.dehydrated) ? (inHydratedSubtree = !1) - : ((wasInHydratedSubtree = finishedWork.deletions), - null !== wasInHydratedSubtree && - 0 < wasInHydratedSubtree.length && - 18 === wasInHydratedSubtree[0].tag + : ((isViewTransitionEligible = finishedWork.deletions), + null !== isViewTransitionEligible && + 0 < isViewTransitionEligible.length && + 18 === isViewTransitionEligible[0].tag ? ((inHydratedSubtree = !1), (prevProfilerEffectDuration = prevProfilerEffectDuration.hydrationErrors), @@ -12207,71 +13233,81 @@ __DEV__ && case 23: break; case 22: - wasInHydratedSubtree = finishedWork.stateNode; + var _instance3 = finishedWork.stateNode; prevProfilerEffectDuration = finishedWork.alternate; null !== finishedWork.memoizedState - ? wasInHydratedSubtree._visibility & - OffscreenPassiveEffectsConnected - ? recursivelyTraversePassiveMountEffects( - finishedRoot, - finishedWork, - committedLanes, - committedTransitions, - endTime - ) - : finishedWork.mode & 1 - ? recursivelyTraverseAtomicPassiveEffects( + ? (isViewTransitionEligible && + null !== prevProfilerEffectDuration && + null === prevProfilerEffectDuration.memoizedState && + restoreEnterOrExitViewTransitions(prevProfilerEffectDuration), + _instance3._visibility & OffscreenPassiveEffectsConnected + ? recursivelyTraversePassiveMountEffects( finishedRoot, finishedWork, committedLanes, committedTransitions, endTime ) - : ((wasInHydratedSubtree._visibility |= - OffscreenPassiveEffectsConnected), - recursivelyTraversePassiveMountEffects( + : finishedWork.mode & 1 + ? recursivelyTraverseAtomicPassiveEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions, + endTime + ) + : ((_instance3._visibility |= + OffscreenPassiveEffectsConnected), + recursivelyTraversePassiveMountEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions, + endTime + ))) + : (isViewTransitionEligible && + null !== prevProfilerEffectDuration && + null !== prevProfilerEffectDuration.memoizedState && + restoreEnterOrExitViewTransitions(finishedWork), + _instance3._visibility & OffscreenPassiveEffectsConnected + ? recursivelyTraversePassiveMountEffects( finishedRoot, finishedWork, committedLanes, committedTransitions, endTime - )) - : wasInHydratedSubtree._visibility & - OffscreenPassiveEffectsConnected - ? recursivelyTraversePassiveMountEffects( - finishedRoot, - finishedWork, - committedLanes, - committedTransitions, - endTime - ) - : ((wasInHydratedSubtree._visibility |= - OffscreenPassiveEffectsConnected), - recursivelyTraverseReconnectPassiveEffects( - finishedRoot, - finishedWork, - committedLanes, - committedTransitions, - 0 !== (finishedWork.subtreeFlags & 10256) || - (0 !== finishedWork.actualDuration && - (null === finishedWork.alternate || - finishedWork.alternate.child !== finishedWork.child)), - endTime - ), - 0 === (finishedWork.mode & 2) || - inHydratedSubtree || - ((finishedRoot = finishedWork.actualStartTime), - 0 <= finishedRoot && - 0.05 < endTime - finishedRoot && - logComponentReappeared(finishedWork, finishedRoot, endTime), - 0 <= componentEffectStartTime && - 0 <= componentEffectEndTime && - 0.05 < componentEffectEndTime - componentEffectStartTime && - logComponentReappeared( - finishedWork, - componentEffectStartTime, - componentEffectEndTime - ))); + ) + : ((_instance3._visibility |= OffscreenPassiveEffectsConnected), + recursivelyTraverseReconnectPassiveEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions, + 0 !== (finishedWork.subtreeFlags & 10256) || + (0 !== finishedWork.actualDuration && + (null === finishedWork.alternate || + finishedWork.alternate.child !== finishedWork.child)), + endTime + ), + 0 === (finishedWork.mode & 2) || + inHydratedSubtree || + ((finishedRoot = finishedWork.actualStartTime), + 0 <= finishedRoot && + 0.05 < endTime - finishedRoot && + logComponentReappeared( + finishedWork, + finishedRoot, + endTime + ), + 0 <= componentEffectStartTime && + 0 <= componentEffectEndTime && + 0.05 < + componentEffectEndTime - componentEffectStartTime && + logComponentReappeared( + finishedWork, + componentEffectStartTime, + componentEffectEndTime + )))); flags & 2048 && commitOffscreenPassiveMountEffects( prevProfilerEffectDuration, @@ -12289,6 +13325,15 @@ __DEV__ && flags & 2048 && commitCachePassiveMountEffect(finishedWork.alternate, finishedWork); break; + case 30: + recursivelyTraversePassiveMountEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions, + endTime + ); + break; default: recursivelyTraversePassiveMountEffects( finishedRoot, @@ -12409,9 +13454,9 @@ __DEV__ && case 23: break; case 22: - var _instance2 = finishedWork.stateNode; + var _instance4 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? _instance2._visibility & OffscreenPassiveEffectsConnected + ? _instance4._visibility & OffscreenPassiveEffectsConnected ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -12428,7 +13473,7 @@ __DEV__ && committedTransitions, endTime ) - : ((_instance2._visibility |= OffscreenPassiveEffectsConnected), + : ((_instance4._visibility |= OffscreenPassiveEffectsConnected), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -12437,7 +13482,7 @@ __DEV__ && includeWorkInProgressEffects, endTime )) - : ((_instance2._visibility |= OffscreenPassiveEffectsConnected), + : ((_instance4._visibility |= OffscreenPassiveEffectsConnected), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -12595,6 +13640,20 @@ __DEV__ && : recursivelyAccumulateSuspenseyCommit(fiber); } break; + case 30: + if ( + 0 !== (fiber.flags & suspenseyCommitFlag) && + ((current = fiber.memoizedProps.name), + null != current && "auto" !== current) + ) { + var state = fiber.stateNode; + state.paired = null; + null === appearingViewTransitions && + (appearingViewTransitions = new Map()); + appearingViewTransitions.set(current, state); + } + recursivelyAccumulateSuspenseyCommit(fiber); + break; default: recursivelyAccumulateSuspenseyCommit(fiber); } @@ -12934,6 +13993,20 @@ __DEV__ && null !== lane && (lane.flags |= 32); return workInProgressDeferredLane; } + function scheduleViewTransitionEvent(fiber, callback) { + if (null != callback) { + var state = fiber.stateNode, + instance = state.ref; + null === instance && + (instance = state.ref = + createViewTransitionInstance( + getViewTransitionName(fiber.memoizedProps, state) + )); + null === pendingViewTransitionEvents && + (pendingViewTransitionEvents = []); + pendingViewTransitionEvents.push(callback.bind(null, instance)); + } + } function scheduleUpdateOnFiber(root, fiber, lane) { isRunningInsertionEffect && console.error("useInsertionEffect must not schedule updates."); @@ -13158,7 +14231,10 @@ __DEV__ && exitStatus = workInProgressRootConcurrentErrors; var wasRootDehydrated = supportsHydration; startTime = renderRootSync(yieldedFiber, startTime, !1); - if (startTime !== RootErrored) { + if ( + startTime !== RootErrored && + startTime !== RootSuspendedAtTheShell + ) { if ( workInProgressRootDidAttachPingListener && !wasRootDehydrated @@ -13208,7 +14284,8 @@ __DEV__ && case RootFatalErrored: throw Error("Root did not complete. This is a bug in React."); case RootSuspendedWithDelay: - if ((lanes & 4194048) !== lanes) break; + if ((lanes & 4194048) !== lanes && (lanes & 62914560) !== lanes) + break; case RootSuspendedAtTheShell: setCurrentTrackFromLanes(lanes); logSuspendedRenderPhase( @@ -13240,7 +14317,7 @@ __DEV__ && throw Error("Unknown root exit status."); } if (null !== ReactSharedInternals.actQueue) - commitRoot( + completeRoot$1( forceSync, yieldEndTime, lanes, @@ -13250,6 +14327,7 @@ __DEV__ && workInProgressDeferredLane, workInProgressRootInterleavedUpdatedLanes, workInProgressSuspendedRetryLanes, + workInProgressRootDidSkipSuspendedSiblings, startTime, null, null, @@ -13275,7 +14353,7 @@ __DEV__ && if (0 !== getNextLanes(forceSync, 0, !0)) break a; pendingEffectsLanes = lanes; forceSync.timeoutHandle = scheduleTimeout( - commitRootWhenReady.bind( + completeRootWhenReady.bind( null, forceSync, yieldEndTime, @@ -13296,7 +14374,7 @@ __DEV__ && ); break a; } - commitRootWhenReady( + completeRootWhenReady( forceSync, yieldEndTime, workInProgressRootRecoverableErrors, @@ -13319,7 +14397,7 @@ __DEV__ && } while (1); ensureRootIsScheduled(root); } - function commitRootWhenReady( + function completeRootWhenReady( root, finishedWork, recoverableErrors, @@ -13336,20 +14414,25 @@ __DEV__ && completedRenderEndTime ) { root.timeoutHandle = noTimeout; - didSkipSuspendedSiblings = finishedWork.subtreeFlags; - var suspendedState = null; + var subtreeFlags = finishedWork.subtreeFlags, + isViewTransitionEligible = (lanes & 335544064) === lanes, + suspendedState = null; if ( - didSkipSuspendedSiblings & 8192 || - 16785408 === (didSkipSuspendedSiblings & 16785408) + isViewTransitionEligible || + subtreeFlags & 8192 || + 16785408 === (subtreeFlags & 16785408) ) - (suspendedState = null), + (appearingViewTransitions = suspendedState = null), accumulateSuspenseyCommitOnFiber(finishedWork), + isViewTransitionEligible && + null != fabricSuspendOnActiveViewTransition && + fabricSuspendOnActiveViewTransition(), (lanes & 62914560) === lanes ? globalMostRecentFallbackTime - now$1() : (lanes & 4194048) === lanes ? globalMostRecentTransitionTime - now$1() : 0; - commitRoot( + completeRoot$1( root, finishedWork, lanes, @@ -13359,6 +14442,7 @@ __DEV__ && spawnedLane, updatedLanes, suspendedRetryLanes, + didSkipSuspendedSiblings, exitStatus, suspendedState, suspendedCommitReason, @@ -13406,6 +14490,7 @@ __DEV__ && spawnedLane, didAttemptEntireTree ) { + suspendedLanes = getEntangledLanes(root, suspendedLanes); suspendedLanes &= ~workInProgressRootPingedLanes; suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes; root.suspendedLanes |= suspendedLanes; @@ -13446,6 +14531,8 @@ __DEV__ && function finalizeRender(lanes, finalizationTime) { 0 !== (lanes & 127) && (blockingClampTime = finalizationTime); 0 !== (lanes & 4194048) && (transitionClampTime = finalizationTime); + 0 !== (lanes & 62914560) && (retryClampTime = finalizationTime); + 0 !== (lanes & 2080374784) && (idleClampTime = finalizationTime); } function prepareFreshStack(root, lanes) { supportsUserTiming && @@ -13547,14 +14634,17 @@ __DEV__ && : blockingEventTime; color = 0 <= endTime ? endTime : 0 <= debugTask ? debugTask : renderStartTime; - 0 <= blockingSuspendedTime && - (setCurrentTrackFromLanes(2), - logSuspendedWithDelayPhase( - blockingSuspendedTime, - color, - lanes, - previousRenderStartTime - )); + 0 <= blockingSuspendedTime + ? (setCurrentTrackFromLanes(2), + logSuspendedWithDelayPhase( + blockingSuspendedTime, + color, + lanes, + previousRenderStartTime + )) + : 0 !== (animatingLanes & 127) && + (setCurrentTrackFromLanes(2), + logAnimatingPhase(blockingClampTime, color, animatingTask)); previousRenderStartTime = debugTask; var eventTime = endTime, eventType = blockingEventType, @@ -13634,7 +14724,8 @@ __DEV__ && previousRenderStartTime ) ) - : performance.measure(isSpawnedUpdate, previousRenderStartTime)); + : performance.measure(isSpawnedUpdate, previousRenderStartTime), + performance.clearMeasures(isSpawnedUpdate)); } blockingUpdateTime = -1.1; blockingUpdateType = 0; @@ -13665,14 +14756,17 @@ __DEV__ && : 0 <= previousRenderStartTime ? previousRenderStartTime : renderStartTime), - 0 <= transitionSuspendedTime && - (setCurrentTrackFromLanes(256), - logSuspendedWithDelayPhase( - transitionSuspendedTime, - color, - lanes, - workInProgressUpdateTask - )), + 0 <= transitionSuspendedTime + ? (setCurrentTrackFromLanes(256), + logSuspendedWithDelayPhase( + transitionSuspendedTime, + color, + lanes, + workInProgressUpdateTask + )) + : 0 !== (animatingLanes & 4194048) && + (setCurrentTrackFromLanes(256), + logAnimatingPhase(transitionClampTime, color, animatingTask)), (isPingedUpdate = endTime), (eventTime = transitionEventType), (eventType = 0 < transitionEventRepeatTime), @@ -13768,13 +14862,22 @@ __DEV__ && previousRenderStartTime ) ) - : performance.measure(debugTask, previousRenderStartTime))), + : performance.measure(debugTask, previousRenderStartTime), + performance.clearMeasures(debugTask))), (transitionUpdateTime = transitionStartTime = -1.1), (transitionUpdateType = 0), (transitionSuspendedTime = -1.1), (transitionEventRepeatTime = transitionEventTime), (transitionEventTime = -1.1), (transitionClampTime = now())); + 0 !== (lanes & 62914560) && + 0 !== (animatingLanes & 62914560) && + (setCurrentTrackFromLanes(4194304), + logAnimatingPhase(retryClampTime, renderStartTime, animatingTask)); + 0 !== (lanes & 2080374784) && + 0 !== (animatingLanes & 2080374784) && + (setCurrentTrackFromLanes(268435456), + logAnimatingPhase(idleClampTime, renderStartTime, animatingTask)); previousRenderStartTime = root.timeoutHandle; previousRenderStartTime !== noTimeout && ((root.timeoutHandle = noTimeout), @@ -13805,15 +14908,7 @@ __DEV__ && workInProgressRootRecoverableErrors = workInProgressRootConcurrentErrors = null; workInProgressRootDidIncludeRecursiveRenderUpdate = !1; - 0 !== (lanes & 8) && (lanes |= lanes & 32); - endTime = root.entangledLanes; - if (0 !== endTime) - for (root = root.entanglements, endTime &= lanes; 0 < endTime; ) - (debugTask = 31 - clz32(endTime)), - (color = 1 << debugTask), - (lanes |= root[debugTask]), - (endTime &= ~color); - entangledRenderLanes = lanes; + entangledRenderLanes = getEntangledLanes(root, lanes); finishQueueingConcurrentUpdates(); root = getCurrentTime(); 1e3 < root - lastResetTime && @@ -14322,7 +15417,7 @@ __DEV__ && workInProgressRootExitStatus = RootSuspendedAtTheShell; workInProgress = null; } - function commitRoot( + function completeRoot$1( root, finishedWork, lanes, @@ -14332,6 +15427,7 @@ __DEV__ && spawnedLane, updatedLanes, suspendedRetryLanes, + didSkipSuspendedSiblings, exitStatus, suspendedState, suspendedCommitReason, @@ -14346,31 +15442,94 @@ __DEV__ && if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); setCurrentTrackFromLanes(lanes); - exitStatus === RootErrored - ? logErroredRenderPhase( - completedRenderStartTime, - completedRenderEndTime, - lanes, - workInProgressUpdateTask - ) - : null !== recoverableErrors - ? logRecoveredRenderPhase( - completedRenderStartTime, - completedRenderEndTime, - lanes, - recoverableErrors, - null !== finishedWork && - null !== finishedWork.alternate && - finishedWork.alternate.memoizedState.isDehydrated && - 0 !== (finishedWork.flags & 256), - workInProgressUpdateTask - ) - : logRenderPhase( - completedRenderStartTime, - completedRenderEndTime, - lanes, - workInProgressUpdateTask - ); + if (exitStatus === RootErrored) + logErroredRenderPhase( + completedRenderStartTime, + completedRenderEndTime, + lanes, + workInProgressUpdateTask + ); + else if (null !== recoverableErrors) { + if ( + ((didSkipSuspendedSiblings = + null !== finishedWork && + null !== finishedWork.alternate && + finishedWork.alternate.memoizedState.isDehydrated && + 0 !== (finishedWork.flags & 256)), + (didIncludeRenderPhaseUpdate = workInProgressUpdateTask), + supportsUserTiming && + !(completedRenderEndTime <= completedRenderStartTime)) + ) { + exitStatus = []; + for (var i = 0; i < recoverableErrors.length; i++) { + var error = recoverableErrors[i].value; + exitStatus.push([ + "Recoverable Error", + "object" === typeof error && + null !== error && + "string" === typeof error.message + ? String(error.message) + : String(error) + ]); + } + completedRenderStartTime = { + start: completedRenderStartTime, + end: completedRenderEndTime, + detail: { + devtools: { + color: "primary-dark", + track: currentTrack, + trackGroup: "Scheduler \u269b", + tooltipText: didSkipSuspendedSiblings + ? "Hydration Failed" + : "Recovered after Error", + properties: exitStatus + } + } + }; + didIncludeRenderPhaseUpdate + ? didIncludeRenderPhaseUpdate.run( + performance.measure.bind( + performance, + "Recovered", + completedRenderStartTime + ) + ) + : performance.measure("Recovered", completedRenderStartTime); + performance.clearMeasures("Recovered"); + } + } else + (didIncludeRenderPhaseUpdate = workInProgressUpdateTask), + !supportsUserTiming || + completedRenderEndTime <= completedRenderStartTime || + ((didSkipSuspendedSiblings = + (lanes & 738197653) === lanes ? "tertiary-dark" : "primary-dark"), + (exitStatus = + (lanes & 536870912) === lanes + ? "Prepared" + : (lanes & 201326741) === lanes + ? "Hydrated" + : "Render"), + didIncludeRenderPhaseUpdate + ? didIncludeRenderPhaseUpdate.run( + console.timeStamp.bind( + console, + exitStatus, + completedRenderStartTime, + completedRenderEndTime, + currentTrack, + "Scheduler \u269b", + didSkipSuspendedSiblings + ) + ) + : console.timeStamp( + exitStatus, + completedRenderStartTime, + completedRenderEndTime, + currentTrack, + "Scheduler \u269b", + didSkipSuspendedSiblings + )); if (null !== finishedWork) { 0 === lanes && console.error( @@ -14380,73 +15539,167 @@ __DEV__ && throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - didIncludeRenderPhaseUpdate = - finishedWork.lanes | finishedWork.childLanes; - didIncludeRenderPhaseUpdate |= concurrentlyUpdatedLanes; - markRootFinished( - root, - lanes, - didIncludeRenderPhaseUpdate, - spawnedLane, - updatedLanes, - suspendedRetryLanes - ); root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); pendingFinishedWork = finishedWork; pendingEffectsRoot = root; pendingEffectsLanes = lanes; - pendingEffectsRemainingLanes = didIncludeRenderPhaseUpdate; pendingPassiveTransitions = transitions; pendingRecoverableErrors = recoverableErrors; pendingEffectsRenderEndTime = completedRenderEndTime; pendingSuspendedCommitReason = suspendedCommitReason; pendingDelayedCommitReason = IMMEDIATE_COMMIT; pendingSuspendedViewTransitionReason = null; - 0 !== finishedWork.actualDuration || - 0 !== (finishedWork.subtreeFlags & 10256) || - 0 !== (finishedWork.flags & 10256) - ? ((root.callbackNode = null), - (root.callbackPriority = 0), - scheduleCallback(NormalPriority$1, function () { - pendingDelayedCommitReason === IMMEDIATE_COMMIT && - (pendingDelayedCommitReason = DELAYED_PASSIVE_COMMIT); - flushPassiveEffects(); - return null; - })) - : ((root.callbackNode = null), (root.callbackPriority = 0)); - commitErrors = null; - commitStartTime = now(); - null !== suspendedCommitReason && - logSuspendedCommitPhase( - completedRenderEndTime, - commitStartTime, - suspendedCommitReason, - workInProgressUpdateTask - ); - recoverableErrors = 0 !== (finishedWork.flags & 13878); - if (0 !== (finishedWork.subtreeFlags & 13878) || recoverableErrors) { - recoverableErrors = ReactSharedInternals.T; - ReactSharedInternals.T = null; - transitions = currentUpdatePriority; - currentUpdatePriority = DiscreteEventPriority; - spawnedLane = executionContext; - executionContext |= CommitContext; - try { - commitBeforeMutationEffects(root, finishedWork, lanes); - } finally { - (executionContext = spawnedLane), - (currentUpdatePriority = transitions), - (ReactSharedInternals.T = recoverableErrors); - } + commitRoot( + root, + finishedWork, + lanes, + spawnedLane, + updatedLanes, + suspendedRetryLanes, + suspendedState, + suspendedCommitReason, + completedRenderEndTime + ); + } + } + function commitRoot( + root, + finishedWork, + lanes, + spawnedLane, + updatedLanes, + suspendedRetryLanes, + suspendedState, + suspendedCommitReason, + completedRenderEndTime + ) { + var remainingLanes = finishedWork.lanes | finishedWork.childLanes; + pendingEffectsRemainingLanes = remainingLanes; + remainingLanes |= concurrentlyUpdatedLanes; + markRootFinished( + root, + lanes, + remainingLanes, + spawnedLane, + updatedLanes, + suspendedRetryLanes + ); + pendingViewTransitionEvents = null; + (lanes & 335544064) === lanes + ? ((pendingTransitionTypes = claimQueuedTransitionTypes(root)), + (spawnedLane = 10262)) + : ((pendingTransitionTypes = null), (spawnedLane = 10256)); + 0 !== finishedWork.actualDuration || + 0 !== (finishedWork.subtreeFlags & spawnedLane) || + 0 !== (finishedWork.flags & spawnedLane) + ? ((root.callbackNode = null), + (root.callbackPriority = 0), + scheduleCallback(NormalPriority$1, function () { + schedulerEvent = global.event; + pendingDelayedCommitReason === IMMEDIATE_COMMIT && + (pendingDelayedCommitReason = DELAYED_PASSIVE_COMMIT); + flushPassiveEffects(); + return null; + })) + : ((root.callbackNode = null), (root.callbackPriority = 0)); + commitErrors = null; + commitStartTime = now(); + null !== suspendedCommitReason && + logSuspendedCommitPhase( + completedRenderEndTime, + commitStartTime, + suspendedCommitReason, + workInProgressUpdateTask + ); + shouldStartViewTransition = !1; + suspendedCommitReason = 0 !== (finishedWork.flags & 13878); + if (0 !== (finishedWork.subtreeFlags & 13878) || suspendedCommitReason) { + suspendedCommitReason = ReactSharedInternals.T; + ReactSharedInternals.T = null; + completedRenderEndTime = currentUpdatePriority; + currentUpdatePriority = DiscreteEventPriority; + spawnedLane = executionContext; + executionContext |= CommitContext; + try { + commitBeforeMutationEffects(root, finishedWork, lanes); + } finally { + (executionContext = spawnedLane), + (currentUpdatePriority = completedRenderEndTime), + (ReactSharedInternals.T = suspendedCommitReason); } - pendingEffectsStatus = PENDING_MUTATION_PHASE; - flushMutationEffects(); - flushLayoutEffects(); - flushSpawnedWork(); + } + pendingEffectsStatus = PENDING_MUTATION_PHASE; + shouldStartViewTransition + ? ((animatingLanes |= lanes), + (animatingTask = null), + (pendingViewTransition = startViewTransition( + suspendedState, + root.containerInfo, + pendingTransitionTypes, + flushMutationEffects, + flushLayoutEffects, + flushAfterMutationEffects, + flushSpawnedWork, + flushPassiveEffects, + reportViewTransitionError, + suspendedViewTransition, + finishedViewTransition.bind(null, lanes) + ))) + : (flushMutationEffects(), flushLayoutEffects(), flushSpawnedWork()); + } + function reportViewTransitionError(error) { + if (pendingEffectsStatus !== NO_PENDING_EFFECTS) { + var onRecoverableError = pendingEffectsRoot.onRecoverableError; + onRecoverableError(error, makeErrorInfo(null)); + } + } + function suspendedViewTransition(reason) { + commitEndTime = now(); + logCommitPhase( + null === pendingSuspendedCommitReason + ? pendingEffectsRenderEndTime + : commitStartTime, + commitEndTime, + commitErrors, + pendingDelayedCommitReason === ABORTED_VIEW_TRANSITION_COMMIT, + workInProgressUpdateTask + ); + pendingSuspendedCommitReason = pendingSuspendedViewTransitionReason = + reason; + } + function finishedViewTransition(lanes) { + if (0 !== (animatingLanes & lanes)) { + var task = animatingTask; + animatingLanes &= ~lanes; + animatingTask = null; + 0 !== (lanes & 4194048) && + 0 === (workInProgressRootRenderLanes & 4194048) && + 0 === (pendingEffectsLanes & 4194048) && + (setCurrentTrackFromLanes(256), + logAnimatingPhase(transitionClampTime, now$1(), task)); + 0 !== (lanes & 62914560) && + 0 === (workInProgressRootRenderLanes & 62914560) && + 0 === (pendingEffectsLanes & 62914560) && + (setCurrentTrackFromLanes(4194304), + logAnimatingPhase(retryClampTime, now$1(), task)); + 0 !== (lanes & 2080374784) && + 0 === (workInProgressRootRenderLanes & 2080374784) && + 0 === (pendingEffectsLanes & 2080374784) && + (setCurrentTrackFromLanes(268435456), + logAnimatingPhase(idleClampTime, now$1(), task)); } } + function flushAfterMutationEffects() { + pendingEffectsStatus === PENDING_AFTER_MUTATION_PHASE && + ((pendingEffectsStatus = NO_PENDING_EFFECTS), + commitAfterMutationEffectsOnFiber( + pendingFinishedWork, + pendingEffectsRoot + ), + (pendingEffectsStatus = PENDING_SPAWNED_WORK)); + } function flushMutationEffects() { if (pendingEffectsStatus === PENDING_MUTATION_PHASE) { pendingEffectsStatus = NO_PENDING_EFFECTS; @@ -14467,8 +15720,9 @@ __DEV__ && try { (inProgressLanes = lanes), (inProgressRoot = root), + (inUpdateViewTransition = rootViewTransitionAffected = !1), resetComponentEffectTimers(), - commitMutationEffectsOnFiber(finishedWork, root), + commitMutationEffectsOnFiber(finishedWork, root, lanes), (inProgressRoot = inProgressLanes = null); } finally { (executionContext = prevExecutionContext), @@ -14542,41 +15796,13 @@ __DEV__ && suspendedViewTransitionReason = pendingEffectsRenderEndTime; startTime = pendingSuspendedCommitReason; commitEndTime = now(); - suspendedViewTransitionReason = - null === startTime ? suspendedViewTransitionReason : commitStartTime; - startTime = commitEndTime; - endTime = pendingDelayedCommitReason === ABORTED_VIEW_TRANSITION_COMMIT; - rootHasLayoutEffect = workInProgressUpdateTask; - null !== commitErrors - ? logCommitErrored( - suspendedViewTransitionReason, - startTime, - commitErrors, - !1, - rootHasLayoutEffect - ) - : !supportsUserTiming || - startTime <= suspendedViewTransitionReason || - (rootHasLayoutEffect - ? rootHasLayoutEffect.run( - console.timeStamp.bind( - console, - endTime ? "Commit Interrupted View Transition" : "Commit", - suspendedViewTransitionReason, - startTime, - currentTrack, - "Scheduler \u269b", - endTime ? "error" : "secondary-dark" - ) - ) - : console.timeStamp( - endTime ? "Commit Interrupted View Transition" : "Commit", - suspendedViewTransitionReason, - startTime, - currentTrack, - "Scheduler \u269b", - endTime ? "error" : "secondary-dark" - )); + logCommitPhase( + null === startTime ? suspendedViewTransitionReason : commitStartTime, + commitEndTime, + commitErrors, + pendingDelayedCommitReason === ABORTED_VIEW_TRANSITION_COMMIT, + workInProgressUpdateTask + ); pendingEffectsStatus = PENDING_AFTER_MUTATION_PHASE; } } @@ -14621,30 +15847,31 @@ __DEV__ && (pendingDelayedCommitReason = ANIMATION_STARTED_COMMIT); } pendingEffectsStatus = NO_PENDING_EFFECTS; + startViewTransitionStartTime = pendingViewTransition; + pendingViewTransition = null; requestPaint(); - startViewTransitionStartTime = pendingEffectsRoot; + endTime = pendingEffectsRoot; var finishedWork = pendingFinishedWork; - endTime = pendingEffectsLanes; - abortedViewTransition = pendingRecoverableErrors; - var rootDidHavePassiveEffects = + abortedViewTransition = pendingEffectsLanes; + var recoverableErrors = pendingRecoverableErrors, + passiveSubtreeMask = + (abortedViewTransition & 335544064) === abortedViewTransition + ? 10262 + : 10256; + (passiveSubtreeMask = 0 !== finishedWork.actualDuration || - 0 !== (finishedWork.subtreeFlags & 10256) || - 0 !== (finishedWork.flags & 10256); - rootDidHavePassiveEffects + 0 !== (finishedWork.subtreeFlags & passiveSubtreeMask) || + 0 !== (finishedWork.flags & passiveSubtreeMask)) ? (pendingEffectsStatus = PENDING_PASSIVE_PHASE) : ((pendingEffectsStatus = NO_PENDING_EFFECTS), (pendingFinishedWork = pendingEffectsRoot = null), - releaseRootPooledCache( - startViewTransitionStartTime, - startViewTransitionStartTime.pendingLanes - ), + releaseRootPooledCache(endTime, endTime.pendingLanes), (nestedPassiveUpdateCount = 0), (rootWithPassiveNestedUpdates = null)); - var remainingLanes = startViewTransitionStartTime.pendingLanes; + var remainingLanes = endTime.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); - rootDidHavePassiveEffects || - commitDoubleInvokeEffectsInDEV(startViewTransitionStartTime, !1); - remainingLanes = lanesToEventPriority(endTime); + passiveSubtreeMask || commitDoubleInvokeEffectsInDEV(endTime, !1); + remainingLanes = lanesToEventPriority(abortedViewTransition); finishedWork = finishedWork.stateNode; if ( injectedHook && @@ -14682,22 +15909,20 @@ __DEV__ && err )); } - isDevToolsPresent && - startViewTransitionStartTime.memoizedUpdaters.clear(); - if (null !== abortedViewTransition) { + isDevToolsPresent && endTime.memoizedUpdaters.clear(); + if (null !== recoverableErrors) { didError = ReactSharedInternals.T; schedulerPriority = currentUpdatePriority; currentUpdatePriority = DiscreteEventPriority; ReactSharedInternals.T = null; try { - var onRecoverableError = - startViewTransitionStartTime.onRecoverableError; + var onRecoverableError = endTime.onRecoverableError; for ( finishedWork = 0; - finishedWork < abortedViewTransition.length; + finishedWork < recoverableErrors.length; finishedWork++ ) { - var recoverableError = abortedViewTransition[finishedWork], + var recoverableError = recoverableErrors[finishedWork], errorInfo = makeErrorInfo(recoverableError.stack); runWithFiberInDEV( recoverableError.source, @@ -14711,19 +15936,40 @@ __DEV__ && (currentUpdatePriority = schedulerPriority); } } + onRecoverableError = pendingViewTransitionEvents; + recoverableError = pendingTransitionTypes; + pendingTransitionTypes = null; + if ( + null !== onRecoverableError && + ((pendingViewTransitionEvents = null), + null === recoverableError && (recoverableError = []), + null !== startViewTransitionStartTime) + ) + for ( + errorInfo = 0; + errorInfo < onRecoverableError.length; + errorInfo++ + ) + (recoverableErrors = (0, onRecoverableError[errorInfo])( + recoverableError + )), + void 0 !== recoverableErrors && + startViewTransitionStartTime.finished.finally( + recoverableErrors + ); 0 !== (pendingEffectsLanes & 3) && - 0 !== startViewTransitionStartTime.tag && + 0 !== endTime.tag && flushPendingEffects(); - ensureRootIsScheduled(startViewTransitionStartTime); - remainingLanes = startViewTransitionStartTime.pendingLanes; - 0 !== (endTime & 261930) && 0 !== (remainingLanes & 42) + ensureRootIsScheduled(endTime); + remainingLanes = endTime.pendingLanes; + 0 !== (abortedViewTransition & 261930) && 0 !== (remainingLanes & 42) ? ((nestedUpdateScheduled = !0), - startViewTransitionStartTime === rootWithNestedUpdates + endTime === rootWithNestedUpdates ? nestedUpdateCount++ - : ((nestedUpdateCount = 0), - (rootWithNestedUpdates = startViewTransitionStartTime))) - : (nestedUpdateCount = 0); - rootDidHavePassiveEffects || finalizeRender(endTime, commitEndTime); + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = endTime))) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = null)); + passiveSubtreeMask || + finalizeRender(abortedViewTransition, commitEndTime); flushSyncWorkAcrossRoots_impl(0, !1); } } @@ -14745,6 +15991,15 @@ __DEV__ && ((root.pooledCache = null), releaseCache(remainingLanes))); } function flushPendingEffects() { + null !== pendingViewTransition && + (console.warn("stopViewTransition is not implemented"), + didWarnAboutInterruptedViewTransitions || + ((didWarnAboutInterruptedViewTransitions = !0), + console.warn( + "A flushSync update cancelled a View Transition because it was called while the View Transition was still preparing. To preserve the synchronous semantics, React had to skip the View Transition. If you can, try to avoid flushSync() in a scenario that's likely to interfere." + )), + (pendingViewTransition = null), + (pendingDelayedCommitReason = ABORTED_VIEW_TRANSITION_COMMIT)); flushMutationEffects(); flushLayoutEffects(); flushSpawnedWork(); @@ -14780,36 +16035,17 @@ __DEV__ && var passiveEffectStartTime = 0; commitErrors = null; passiveEffectStartTime = now$1(); - if (pendingDelayedCommitReason === ANIMATION_STARTED_COMMIT) { + if (pendingDelayedCommitReason === ANIMATION_STARTED_COMMIT) + logAnimatingPhase( + commitEndTime, + passiveEffectStartTime, + animatingTask + ); + else { var startTime = commitEndTime, - endTime = passiveEffectStartTime; - !supportsUserTiming || - endTime <= startTime || - (animatingTask - ? animatingTask.run( - console.timeStamp.bind( - console, - "Animating", - startTime, - endTime, - currentTrack, - "Scheduler \u269b", - "secondary-dark" - ) - ) - : console.timeStamp( - "Animating", - startTime, - endTime, - currentTrack, - "Scheduler \u269b", - "secondary-dark" - )); - } else { - startTime = commitEndTime; - endTime = passiveEffectStartTime; - var delayedUntilPaint = - pendingDelayedCommitReason === DELAYED_PASSIVE_COMMIT; + endTime = passiveEffectStartTime, + delayedUntilPaint = + pendingDelayedCommitReason === DELAYED_PASSIVE_COMMIT; !supportsUserTiming || endTime <= startTime || (workInProgressUpdateTask @@ -15020,8 +16256,9 @@ __DEV__ && (workInProgressRootRenderLanes & 62914560) === workInProgressRootRenderLanes && now$1() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) - ? (executionContext & RenderContext) === NoContext && - prepareFreshStack(root, 0) + ? (executionContext & RenderContext) === NoContext + ? prepareFreshStack(root, 0) + : (workInProgressRootPingedLanes |= pingedLanes) : (workInProgressRootPingedLanes |= pingedLanes), workInProgressSuspendedRetryLanes === workInProgressRootRenderLanes && (workInProgressSuspendedRetryLanes = 0)); @@ -15069,14 +16306,14 @@ __DEV__ && parentFiber, isInStrictMode ) { - if (0 !== (parentFiber.subtreeFlags & 67117056)) + if (0 !== (parentFiber.subtreeFlags & 134225920)) for (parentFiber = parentFiber.child; null !== parentFiber; ) { var root = root$jscomp$0, fiber = parentFiber, isStrictModeFiber = fiber.type === REACT_STRICT_MODE_TYPE; isStrictModeFiber = isInStrictMode || isStrictModeFiber; 22 !== fiber.tag - ? fiber.flags & 67108864 + ? fiber.flags & 134217728 ? isStrictModeFiber && runWithFiberInDEV( fiber, @@ -15090,14 +16327,14 @@ __DEV__ && isStrictModeFiber ) : null === fiber.memoizedState && - (isStrictModeFiber && fiber.flags & 8192 + (isStrictModeFiber && fiber.flags & 134225920 ? runWithFiberInDEV( fiber, doubleInvokeEffectsOnFiber, root, fiber ) - : fiber.subtreeFlags & 67108864 && + : fiber.subtreeFlags & 134217728 && runWithFiberInDEV( fiber, recursivelyTraverseAndDoubleInvokeEffectsInDEV, @@ -15113,7 +16350,12 @@ __DEV__ && try { disappearLayoutEffects(fiber), disconnectPassiveEffect(fiber), - reappearLayoutEffects(root, fiber.alternate, fiber, !1), + reappearLayoutEffects( + root, + fiber.alternate, + fiber, + NoLayoutEffectTraversalFlags + ), reconnectPassiveEffects(root, fiber, 0, null, !1, 0); } finally { setIsStrictModeForDevtools(!1); @@ -15136,12 +16378,12 @@ __DEV__ && ); } function legacyCommitDoubleInvokeEffectsInDEV(fiber, hasPassiveEffects) { - invokeEffectsInDev(fiber, 134217728, invokeLayoutEffectUnmountInDEV); + invokeEffectsInDev(fiber, 268435456, invokeLayoutEffectUnmountInDEV); hasPassiveEffects && - invokeEffectsInDev(fiber, 268435456, invokePassiveEffectUnmountInDEV); - invokeEffectsInDev(fiber, 134217728, invokeLayoutEffectMountInDEV); + invokeEffectsInDev(fiber, 536870912, invokePassiveEffectUnmountInDEV); + invokeEffectsInDev(fiber, 268435456, invokeLayoutEffectMountInDEV); hasPassiveEffects && - invokeEffectsInDev(fiber, 268435456, invokePassiveEffectMountInDEV); + invokeEffectsInDev(fiber, 536870912, invokePassiveEffectMountInDEV); } function invokeEffectsInDev(firstChild, fiberFlags, invokeEffectFn) { for (var subtreeRoot = null; null != firstChild; ) { @@ -15217,30 +16459,15 @@ __DEV__ && ); }); } - function resolveFunctionForHotReloading(type) { + function resolveTypeForHotReloading(type) { if (null === resolveFamily) return type; var family = resolveFamily(type); return void 0 === family ? type : family.current; } - function resolveForwardRefForHotReloading(type) { - if (null === resolveFamily) return type; - var family = resolveFamily(type); - return void 0 === family - ? null !== type && - void 0 !== type && - "function" === typeof type.render && - ((family = resolveFunctionForHotReloading(type.render)), - type.render !== family) - ? ((family = { $$typeof: REACT_FORWARD_REF_TYPE, render: family }), - void 0 !== type.displayName && - (family.displayName = type.displayName), - family) - : type - : family.current; - } function isCompatibleFamilyForHotReloading(fiber, element) { if (null === resolveFamily) return !1; - var prevType = fiber.elementType; + var resolve = resolveFamily, + prevType = fiber.elementType; element = element.type; var needsCompareFamilies = !1, $$typeofNextType = @@ -15274,8 +16501,8 @@ __DEV__ && return !1; } return needsCompareFamilies && - ((fiber = resolveFamily(prevType)), - void 0 !== fiber && fiber === resolveFamily(element)) + ((fiber = resolve(prevType)), + void 0 !== fiber && fiber === resolve(element)) ? !0 : !1; } @@ -15295,39 +16522,58 @@ __DEV__ && alternate = _fiber.alternate, child = _fiber.child, sibling = _fiber.sibling, - tag = _fiber.tag; - _fiber = _fiber.type; - var candidateType = null; + tag = _fiber.tag, + type = _fiber.type, + elementType = _fiber.elementType, + candidateType = null; + _fiber = null; switch (tag) { case 0: - case 15: case 1: - candidateType = _fiber; + candidateType = type; + break; + case 15: + candidateType = type; + _fiber = elementType; + break; + case 14: + _fiber = elementType; break; case 11: - candidateType = _fiber.render; + (candidateType = type.render), (_fiber = elementType); } if (null === resolveFamily) throw Error("Expected resolveFamily to be set during hot reload."); - var needsRender = !1; - _fiber = !1; + var resolve = resolveFamily; + type = elementType = !1; null !== candidateType && - ((candidateType = resolveFamily(candidateType)), + ((candidateType = resolve(candidateType)), void 0 !== candidateType && (staleFamilies.has(candidateType) - ? (_fiber = !0) + ? (type = !0) : updatedFamilies.has(candidateType) && - (1 === tag ? (_fiber = !0) : (needsRender = !0)))); + (1 === tag ? (type = !0) : (elementType = !0)))); + type || + null === _fiber || + ((tag = resolve(_fiber)), + void 0 !== tag && staleFamilies.has(tag) + ? (type = !0) + : "object" === typeof _fiber && + _fiber.$$typeof === REACT_LAZY_TYPE && + ((tag = _fiber._payload), + 1 === tag._status && + ((tag = resolve(tag._result.default)), + void 0 !== tag && staleFamilies.has(tag) && (type = !0)))); null !== failedBoundaries && (failedBoundaries.has(fiber) || (null !== alternate && failedBoundaries.has(alternate))) && - (_fiber = !0); - _fiber && (fiber._debugNeedsRemount = !0); - if (_fiber || needsRender) + (type = !0); + type && (fiber._debugNeedsRemount = !0); + if (type || elementType) (alternate = enqueueConcurrentRenderForLane(fiber, 2)), null !== alternate && scheduleUpdateOnFiber(alternate, fiber, 2); null === child || - _fiber || + type || scheduleFibersWithFamiliesRecursively( child, updatedFamilies, @@ -15403,7 +16649,7 @@ __DEV__ && (workInProgress.deletions = null), (workInProgress.actualDuration = -0), (workInProgress.actualStartTime = -1.1)); - workInProgress.flags = current.flags & 65011712; + workInProgress.flags = current.flags & 1206910976; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -15430,18 +16676,15 @@ __DEV__ && switch (workInProgress.tag) { case 0: case 15: - workInProgress.type = resolveFunctionForHotReloading(current.type); - break; + case 14: case 1: - workInProgress.type = resolveFunctionForHotReloading(current.type); - break; case 11: - workInProgress.type = resolveForwardRefForHotReloading(current.type); + workInProgress.type = resolveTypeForHotReloading(current.type); } return workInProgress; } function resetWorkInProgress(workInProgress, renderLanes) { - workInProgress.flags &= 65011714; + workInProgress.flags &= 1206910978; var current = workInProgress.alternate; null === current ? ((workInProgress.childLanes = 0), @@ -15485,14 +16728,13 @@ __DEV__ && mode, lanes ) { - var fiberTag = 0, - resolvedType = type; - if ("function" === typeof type) - shouldConstruct(type) && (fiberTag = 1), - (resolvedType = resolveFunctionForHotReloading(resolvedType)); - else if ("string" === typeof type) fiberTag = 5; + var fiberTag = 0; + var resolvedType = resolveTypeForHotReloading(type); + if ("function" === typeof resolvedType) + shouldConstruct(resolvedType) && (fiberTag = 1); + else if ("string" === typeof resolvedType) fiberTag = 5; else - a: switch (type) { + a: switch (resolvedType) { case REACT_ACTIVITY_TYPE: return ( (key = createFiber(31, pendingProps, key, mode)), @@ -15541,9 +16783,24 @@ __DEV__ && (key.lanes = lanes), key ); + case REACT_LEGACY_HIDDEN_TYPE: + case REACT_VIEW_TRANSITION_TYPE: + return ( + (type = mode | 32), + (key = createFiber(30, pendingProps, key, type)), + (key.elementType = REACT_VIEW_TRANSITION_TYPE), + (key.lanes = lanes), + (key.stateNode = { + autoName: null, + paired: null, + clones: null, + ref: null + }), + key + ); default: - if ("object" === typeof type && null !== type) - switch (type.$$typeof) { + if ("object" === typeof resolvedType && null !== resolvedType) + switch (resolvedType.$$typeof) { case REACT_CONTEXT_TYPE: fiberTag = 10; break a; @@ -15552,7 +16809,6 @@ __DEV__ && break a; case REACT_FORWARD_REF_TYPE: fiberTag = 11; - resolvedType = resolveForwardRefForHotReloading(resolvedType); break a; case REACT_MEMO_TYPE: fiberTag = 14; @@ -15562,27 +16818,27 @@ __DEV__ && resolvedType = null; break a; } - resolvedType = ""; + pendingProps = ""; if ( void 0 === type || ("object" === typeof type && null !== type && 0 === Object.keys(type).length) ) - resolvedType += + pendingProps += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."; null === type - ? (pendingProps = "null") + ? (resolvedType = "null") : isArrayImpl(type) - ? (pendingProps = "array") + ? (resolvedType = "array") : void 0 !== type && type.$$typeof === REACT_ELEMENT_TYPE - ? ((pendingProps = + ? ((resolvedType = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />"), - (resolvedType = + (pendingProps = " Did you accidentally export a JSX literal instead of a component?")) - : (pendingProps = typeof type); + : (resolvedType = typeof type); fiberTag = owner ? "number" === typeof owner.tag ? getComponentNameFromFiber(owner) @@ -15591,12 +16847,12 @@ __DEV__ && : null : null; fiberTag && - (resolvedType += + (pendingProps += "\n\nCheck the render method of `" + fiberTag + "`."); fiberTag = 29; pendingProps = Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + - (pendingProps + "." + resolvedType) + (resolvedType + "." + pendingProps) ); resolvedType = null; } @@ -15687,6 +16943,7 @@ __DEV__ && this.pooledCache = null; this.pooledCacheLanes = 0; this.formState = formState; + this.transitionTypes = null; this.incompleteTransitions = new Map(); this.passiveEffectDuration = this.effectDuration = -0; this.memoizedUpdaters = new Set(); @@ -15707,25 +16964,30 @@ __DEV__ && function createPortal$1(children, containerInfo, implementation) { var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; - try { - testStringCoercion(key); - var JSCompiler_inline_result = !1; - } catch (e$7) { - JSCompiler_inline_result = !0; + if (null == key) key = null; + else if (key === REACT_OPTIMISTIC_KEY) key = REACT_OPTIMISTIC_KEY; + else { + try { + testStringCoercion(key); + var JSCompiler_inline_result = !1; + } catch (e$7) { + JSCompiler_inline_result = !0; + } + JSCompiler_inline_result && + (console.error( + "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", + ("function" === typeof Symbol && + Symbol.toStringTag && + key[Symbol.toStringTag]) || + key.constructor.name || + "Object" + ), + testStringCoercion(key)); + key = "" + key; } - JSCompiler_inline_result && - (console.error( - "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", - ("function" === typeof Symbol && - Symbol.toStringTag && - key[Symbol.toStringTag]) || - key.constructor.name || - "Object" - ), - testStringCoercion(key)); return { $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, + key: key, children: children, containerInfo: containerInfo, implementation: implementation @@ -15831,44 +17093,6 @@ __DEV__ && function getCurrentFiberForDevTools() { return current; } - function findNodeHandle(componentOrHandle) { - var owner = current; - null !== owner && - isRendering && - null !== owner.stateNode && - (owner.stateNode._warnedAboutRefsInRender || - console.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" - ), - (owner.stateNode._warnedAboutRefsInRender = !0)); - if (null == componentOrHandle) return null; - if ("number" === typeof componentOrHandle) return componentOrHandle; - if (componentOrHandle._nativeTag) return componentOrHandle._nativeTag; - if ( - null != componentOrHandle.canonical && - null != componentOrHandle.canonical.nativeTag - ) - return componentOrHandle.canonical.nativeTag; - if ( - (owner = - ReactNativePrivateInterface.getNativeTagFromPublicInstance( - componentOrHandle - )) - ) - return owner; - componentOrHandle = findHostInstanceWithWarning( - componentOrHandle, - "findNodeHandle" - ); - return null == componentOrHandle - ? componentOrHandle - : null != componentOrHandle._nativeTag - ? componentOrHandle._nativeTag - : ReactNativePrivateInterface.getNativeTagFromPublicInstance( - componentOrHandle - ); - } function getNodeFromInternalInstanceHandle(internalInstanceHandle) { return ( internalInstanceHandle && @@ -15886,6 +17110,67 @@ __DEV__ && "The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue." ); } + function ViewTransitionPseudoElement(pseudo, name) { + this._pseudo = pseudo; + this._name = name; + } + function measureClonedInstance() { + console.warn("measureClonedInstance is not implemented"); + return { + rect: { x: 0, y: 0, width: 0, height: 0 }, + abs: !1, + clip: !1, + view: !0 + }; + } + function createViewTransitionInstance(name) { + var tag = allocateTag(); + fabricCreateViewTransitionInstance(name, tag); + return { + name: name, + old: new ViewTransitionPseudoElement("old", name), + new: new ViewTransitionPseudoElement("new", name) + }; + } + function startViewTransition( + suspendedState, + rootContainer, + transitionTypes, + mutationCallback, + layoutCallback, + afterMutationCallback, + spawnedWorkCallback, + passiveCallback + ) { + suspendedState = fabricStartViewTransition(function () { + mutationCallback(); + layoutCallback(); + afterMutationCallback(); + }); + if (null == suspendedState) + return ( + console.warn( + "startViewTransition didn't kick off transition in Fabric, the ViewTransition ReactNativeFeatureFlag might not be enabled." + ), + mutationCallback(), + layoutCallback(), + spawnedWorkCallback(), + null + ); + suspendedState.ready.then(function () { + spawnedWorkCallback(); + fabricStartViewTransitionReadyFinished(); + }); + suspendedState.finished.finally(function () { + passiveCallback(); + }); + return suspendedState; + } + function allocateTag() { + var tag = nextReactTag; + nextReactTag += 2; + return tag; + } function createTextInstance( text, rootContainerInstance, @@ -15896,8 +17181,7 @@ __DEV__ && console.error( "Text strings must be rendered within a component." ); - hostContext = nextReactTag; - nextReactTag += 2; + hostContext = allocateTag(); return { node: createNode( hostContext, @@ -15913,7 +17197,7 @@ __DEV__ && if (null == instance.canonical.publicInstance) { var $jscomp$nullish$tmp0; instance.canonical.publicInstance = - ReactNativePrivateInterface.createPublicInstance( + reactPrivateInterface.createPublicInstance( instance.canonical.nativeTag, instance.canonical.viewConfig, instance.canonical.internalInstanceHandle, @@ -15926,12 +17210,15 @@ __DEV__ && } return instance.canonical.publicInstance; } - return null != instance.containerInfo && - null != instance.containerInfo.publicInstance + return null != instance.containerInfo ? instance.containerInfo.publicInstance - : null != instance._nativeTag - ? instance - : null; + : null; + } + function getPublicInstanceFromHostFiber(fiber) { + fiber = getPublicInstance(fiber.stateNode); + if (null === fiber) + throw Error("Expected to find a host node. This is a bug in React."); + return fiber; } function resolveUpdatePriority() { if (0 !== currentUpdatePriority) return currentUpdatePriority; @@ -15949,9 +17236,32 @@ __DEV__ && } return DefaultEventPriority; } + function resolveEventType() { + var event = global.event; + event && event !== schedulerEvent + ? event.type + ? (event = event.type) + : ((event = event.dispatchConfig), + (event = + null == event || null == event.phasedRegistrationNames + ? null + : (event = + event.phasedRegistrationNames.bubbled || + event.phasedRegistrationNames.captured) + ? event.startsWith("on") + ? event.slice(2).toLowerCase() + : event.toLowerCase() + : null)) + : (event = null); + return event; + } + function resolveEventTimeStamp() { + var event = global.event; + return event && event !== schedulerEvent ? event.timeStamp : -1.1; + } function cloneHiddenInstance(instance) { var node = instance.node, - updatePayload = ReactNativePrivateInterface.createAttributePayload( + updatePayload = reactPrivateInterface.createAttributePayload( { style: { display: "none" } }, instance.canonical.viewConfig.validAttributes ); @@ -15963,9 +17273,56 @@ __DEV__ && function replaceContainerChildren(container, newChildren) { completeRoot(container.containerTag, newChildren); } + function FragmentInstance(fragmentFiber) { + this._fragmentFiber = fragmentFiber; + this._observers = null; + } + function observeChild(child, observer) { + child = getPublicInstanceFromHostFiber(child); + observer.observe(child); + return !1; + } + function unobserveChild(child, observer) { + child = getPublicInstanceFromHostFiber(child); + observer.unobserve(child); + return !1; + } + function collectChildren(child, collection) { + collection.push(child); + return !1; + } + function collectClientRects(child, rects) { + child = getPublicInstanceFromHostFiber(child); + rects.push(child.getBoundingClientRect()); + return !1; + } + function addFragmentHandleToFiber(child, fragmentInstance) { + child = getPublicInstanceFromHostFiber(child); + null != child && addFragmentHandleToInstance(child, fragmentInstance); + return !1; + } + function addFragmentHandleToInstance(instance, fragmentInstance) { + null == instance.reactFragments && (instance.reactFragments = new Set()); + instance.reactFragments.add(fragmentInstance); + } + function commitNewChildToFragmentInstance(childInstance, fragmentInstance) { + if (null != childInstance.canonical) { + var publicInstance = getPublicInstance(childInstance); + if (null !== fragmentInstance._observers) { + if (null == publicInstance) + throw Error( + "Expected to find a host node. This is a bug in React." + ); + fragmentInstance._observers.forEach(function (observer) { + observer.observe(publicInstance); + }); + } + addFragmentHandleToInstance(publicInstance, fragmentInstance); + } + } function nativeOnUncaughtError(error, errorInfo) { !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + reactPrivateInterface.ReactFiberErrorDialog.showErrorDialog({ errorBoundary: null, error: error, componentStack: @@ -15983,7 +17340,7 @@ __DEV__ && function nativeOnCaughtError(error, errorInfo) { if ( !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + reactPrivateInterface.ReactFiberErrorDialog.showErrorDialog({ errorBoundary: errorInfo.errorBoundary, error: error, componentStack: @@ -16027,9 +17384,9 @@ __DEV__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); - require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); + require("react-native/setup-env"); var React = require("react"), - ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"), + reactPrivateInterface = require("react-native/react-private-interface"), Scheduler = require("scheduler"), isArrayImpl = Array.isArray, ReactSharedInternals = @@ -16064,12 +17421,14 @@ __DEV__ && REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"); Symbol.for("react.scope"); - var REACT_ACTIVITY_TYPE = Symbol.for("react.activity"); - Symbol.for("react.legacy_hidden"); + var REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), + REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden"); Symbol.for("react.tracing_marker"); - var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"); - Symbol.for("react.view_transition"); - var MAYBE_ITERATOR_SYMBOL = Symbol.iterator, + var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"), + REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"), + REACT_RECOVERABLE_TYPE = Symbol.for("react.recoverable"), + MAYBE_ITERATOR_SYMBOL = Symbol.iterator, + REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), current = null, isRendering = !1, @@ -16158,7 +17517,7 @@ __DEV__ && bubbles: null, cancelable: null, timeStamp: function (event) { - return event.timeStamp || Date.now(); + return event.timeStamp || event.timestamp || currentTimeStamp(); }, defaultPrevented: null, isTrusted: null @@ -16621,10 +17980,10 @@ __DEV__ && eventNameDispatchConfigs = {}, registrationNameModules = {}, customBubblingEventTypes = - ReactNativePrivateInterface.ReactNativeViewConfigRegistry + reactPrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = - ReactNativePrivateInterface.ReactNativeViewConfigRegistry + reactPrivateInterface.ReactNativeViewConfigRegistry .customDirectEventTypes; if (eventPluginOrder) throw Error( @@ -16705,6 +18064,7 @@ __DEV__ && }); var isInsideEventHandler = !1, eventQueue = null, + _enableNativeEventTargetEventDispatching = null, scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, @@ -16730,14 +18090,14 @@ __DEV__ && ContinuousEventPriority = 8, DefaultEventPriority = 32, IdleEventPriority = 268435456, - instanceCache = new Map(), bind = Function.prototype.bind, valueStack = []; var fiberStack = []; var index$jscomp$0 = -1, emptyContextObject = {}; Object.freeze(emptyContextObject); - var lastResetTime = 0; + var globalClientIdCounter$1 = 0, + lastResetTime = 0; if ( "object" === typeof performance && "function" === typeof performance.now @@ -16801,7 +18161,7 @@ __DEV__ && end: -0, detail: { devtools: reusableComponentDevToolDetails } }, - resuableChangedPropsEntry = ["Changed Props", ""], + reusableChangedPropsEntry = ["Changed Props", ""], reusableDeeplyEqualPropsEntry = [ "Changed Props", "This component received deeply equal props. It might benefit from useMemo or the React Compiler in its owner." @@ -16850,6 +18210,7 @@ __DEV__ && _currentRenderer: null, _currentRenderer2: null }, + entangledTransitionTypes = null, now = Scheduler.unstable_now, createTask = console.createTask ? console.createTask @@ -16888,6 +18249,9 @@ __DEV__ && transitionEventType = null, transitionEventRepeatTime = -1.1, transitionSuspendedTime = -1.1, + retryClampTime = -0, + idleClampTime = -0, + animatingLanes = 0, animatingTask = null, yieldReason = 0, yieldStartTime = -1.1, @@ -16915,16 +18279,38 @@ __DEV__ && ) { if (0 > transitionStartTime && 0 > transitionUpdateTime) { transitionStartTime = now(); + var newEventTime = resolveEventTimeStamp(), + newEventType = resolveEventType(); if ( - -1.1 !== transitionEventRepeatTime || - null !== transitionEventType + newEventTime !== transitionEventRepeatTime || + newEventType !== transitionEventType ) transitionEventRepeatTime = -1.1; - transitionEventTime = -1.1; - transitionEventType = null; + transitionEventTime = newEventTime; + transitionEventType = newEventType; } entangleAsyncAction(transition, returnValue); } + if (null !== entangledTransitionTypes) + for (newEventTime = firstScheduledRoot; null !== newEventTime; ) + queueTransitionTypes(newEventTime, entangledTransitionTypes), + (newEventTime = newEventTime.next); + newEventTime = transition.types; + if (null !== newEventTime) { + for (newEventType = firstScheduledRoot; null !== newEventType; ) + queueTransitionTypes(newEventType, newEventTime), + (newEventType = newEventType.next); + if (0 !== currentEntangledLane) { + newEventType = entangledTransitionTypes; + null === newEventType && + (newEventType = entangledTransitionTypes = []); + for (var i = 0; i < newEventTime.length; i++) { + var transitionType = newEventTime[i]; + -1 === newEventType.indexOf(transitionType) && + newEventType.push(transitionType); + } + } + } null !== prevOnStartTransitionFinish && prevOnStartTransitionFinish(transition, returnValue); }; @@ -17122,7 +18508,8 @@ __DEV__ && pendingUNSAFE_ComponentWillUpdateWarnings = []; pendingLegacyContextWarning = new Map(); }; - var callComponent = { + var REACT_RECOVERABLE_DIGEST = "", + callComponent = { react_stack_bottom_frame: function (Component, props, secondArg) { var wasRendering = isRendering; isRendering = !0; @@ -17386,10 +18773,10 @@ __DEV__ && useActionState: throwInvalidHookError, useOptimistic: throwInvalidHookError, useMemoCache: throwInvalidHookError, - useCacheRefresh: throwInvalidHookError - }; - ContextOnlyDispatcher.useEffectEvent = throwInvalidHookError; - var HooksDispatcherOnMountInDEV = null, + useCacheRefresh: throwInvalidHookError, + useEffectEvent: throwInvalidHookError + }, + HooksDispatcherOnMountInDEV = null, HooksDispatcherOnMountWithHookTypesInDEV = null, HooksDispatcherOnUpdateInDEV = null, HooksDispatcherOnRerenderInDEV = null, @@ -18429,6 +19816,7 @@ __DEV__ && var didWarnAboutReassigningProps = !1; var didWarnAboutRevealOrder = {}; var didWarnAboutTailOptions = {}; + var didWarnAboutClassNameOnViewTransition = {}; var SUSPENDED_MARKER = { dehydrated: null, treeContext: null, @@ -18438,12 +19826,24 @@ __DEV__ && hasWarnedAboutUsingNoValuePropOnContextProvider = !1, didWarnAboutUndefinedSnapshotBeforeUpdate = null; didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); - var offscreenSubtreeIsHidden = !1, + var viewTransitionMutationContext = !1, + shouldStartViewTransition = !1, + appearingViewTransitions = null, + viewTransitionCancelableChildren = null, + viewTransitionHostInstanceIdx = 0, + mountedNamedViewTransitions = new Map(), + didWarnAboutName = {}, + NoLayoutEffectTraversalFlags = 0, + IncludeWorkInProgressEffects = 1, + offscreenSubtreeIsHidden = !1, offscreenSubtreeWasHidden = !1, PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set, nextEffect = null, inProgressLanes = null, inProgressRoot = null, + viewTransitionContextChanged = !1, + inUpdateViewTransition = !1, + rootViewTransitionAffected = !1, inHydratedSubtree = !1, suspenseyCommitFlag = 8192, DefaultAsyncDispatcher = { @@ -18536,6 +19936,9 @@ __DEV__ && pendingEffectsRenderEndTime = -0, pendingPassiveTransitions = null, pendingRecoverableErrors = null, + pendingViewTransition = null, + pendingViewTransitionEvents = null, + pendingTransitionTypes = null, pendingSuspendedCommitReason = null, pendingDelayedCommitReason = IMMEDIATE_COMMIT, pendingSuspendedViewTransitionReason = null, @@ -18548,6 +19951,7 @@ __DEV__ && nestedPassiveUpdateCount = 0, rootWithPassiveNestedUpdates = null, isRunningInsertionEffect = !1, + didWarnAboutInterruptedViewTransitions = !1, didWarnStateUpdateForNotYetMountedComponent = null, didWarnAboutUpdateInRender = !1; var didWarnAboutUpdateInRenderForAnotherComponent = new Set(); @@ -18691,44 +20095,49 @@ __DEV__ && commitHydratedInstance = shim$1, preloadResource = shim, suspendResource = shim, - _nativeFabricUIManage = nativeFabricUIManager, - createNode = _nativeFabricUIManage.createNode, - cloneNodeWithNewChildren = _nativeFabricUIManage.cloneNodeWithNewChildren, + fabricCreateViewTransitionInstance = + reactPrivateInterface.fabricUIManager.createViewTransitionInstance, + fabricStartViewTransition = + reactPrivateInterface.fabricUIManager.startViewTransition, + fabricStartViewTransitionReadyFinished = + reactPrivateInterface.fabricUIManager.startViewTransitionReadyFinished, + createNode = reactPrivateInterface.fabricUIManager.createNode, + cloneNodeWithNewChildren = + reactPrivateInterface.fabricUIManager.cloneNodeWithNewChildren, cloneNodeWithNewChildrenAndProps = - _nativeFabricUIManage.cloneNodeWithNewChildrenAndProps, - cloneNodeWithNewProps = _nativeFabricUIManage.cloneNodeWithNewProps, - createChildNodeSet = _nativeFabricUIManage.createChildSet, - appendChildNode = _nativeFabricUIManage.appendChild, - appendChildNodeToSet = _nativeFabricUIManage.appendChildToSet, - completeRoot = _nativeFabricUIManage.completeRoot, - registerEventHandler = _nativeFabricUIManage.registerEventHandler, + reactPrivateInterface.fabricUIManager.cloneNodeWithNewChildrenAndProps, + cloneNodeWithNewProps = + reactPrivateInterface.fabricUIManager.cloneNodeWithNewProps, + createChildNodeSet = reactPrivateInterface.fabricUIManager.createChildSet, + appendChildNode = reactPrivateInterface.fabricUIManager.appendChild, + appendChildNodeToSet = + reactPrivateInterface.fabricUIManager.appendChildToSet, + completeRoot = reactPrivateInterface.fabricUIManager.completeRoot, + registerEventHandler = + reactPrivateInterface.fabricUIManager.registerEventHandler, FabricDiscretePriority = - _nativeFabricUIManage.unstable_DiscreteEventPriority, + reactPrivateInterface.fabricUIManager.unstable_DiscreteEventPriority, FabricContinuousPriority = - _nativeFabricUIManage.unstable_ContinuousEventPriority, - FabricIdlePriority = _nativeFabricUIManage.unstable_IdleEventPriority, + reactPrivateInterface.fabricUIManager.unstable_ContinuousEventPriority, + FabricIdlePriority = + reactPrivateInterface.fabricUIManager.unstable_IdleEventPriority, fabricGetCurrentEventPriority = - _nativeFabricUIManage.unstable_getCurrentEventPriority, + reactPrivateInterface.fabricUIManager.unstable_getCurrentEventPriority, + fabricSuspendOnActiveViewTransition = + reactPrivateInterface.fabricUIManager.suspendOnActiveViewTransition, extraDevToolsConfig = { getInspectorDataForInstance: getInspectorDataForInstance, - getInspectorDataForViewTag: function (viewTag) { - viewTag = instanceCache.get(viewTag) || null; - return getInspectorDataForInstance(viewTag); - }, getInspectorDataForViewAtPoint: function ( inspectedView, locationX, locationY, callback ) { - var closestInstance = null, - fabricNode = - ReactNativePrivateInterface.getNodeFromPublicInstance( - inspectedView - ); - fabricNode - ? nativeFabricUIManager.findNodeAtPoint( - fabricNode, + var closestInstance = null; + (inspectedView = + reactPrivateInterface.getNodeFromPublicInstance(inspectedView)) + ? reactPrivateInterface.fabricUIManager.findNodeAtPoint( + inspectedView, locationX, locationY, function (internalInstanceHandle) { @@ -18757,7 +20166,7 @@ __DEV__ && .publicInstance, nativeViewTag = internalInstanceHandle.stateNode.canonical.nativeTag; - nativeFabricUIManager.measure( + reactPrivateInterface.fabricUIManager.measure( node, function (x, y, width, height, pageX, pageY) { x = getInspectorDataForInstance(closestInstance); @@ -18779,44 +20188,135 @@ __DEV__ && } } ) - : null != inspectedView._internalFiberInstanceHandleDEV - ? ReactNativePrivateInterface.UIManager.findSubviewIn( - findNodeHandle(inspectedView), - [locationX, locationY], - function (nativeViewTag, left, top, width, height) { - var inspectorData = getInspectorDataForInstance( - instanceCache.get(nativeViewTag) || null - ); - callback( - assign({}, inspectorData, { - pointerY: locationY, - frame: { - left: left, - top: top, - width: width, - height: height - }, - touchedViewTag: nativeViewTag, - closestPublicInstance: nativeViewTag - }) - ); - } - ) - : console.error( - "getInspectorDataForViewAtPoint expects to receive a host component" - ); + : console.error( + "getInspectorDataForViewAtPoint expects to receive a host component" + ); } }, getViewConfigForType = - ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get, + reactPrivateInterface.ReactNativeViewConfigRegistry.get, nextReactTag = 2; registerEventHandler && registerEventHandler(dispatchEvent); var currentUpdatePriority = 0, + schedulerEvent = void 0, warnsIfNotActing = !1, scheduleTimeout = setTimeout, cancelTimeout = clearTimeout, - noTimeout = -1, - NotPendingTransition = null, + noTimeout = -1; + FragmentInstance.prototype.observeUsing = function (observer) { + null === this._observers && (this._observers = new Set()); + this._observers.add(observer); + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + observeChild, + observer, + void 0, + void 0 + ); + }; + FragmentInstance.prototype.unobserveUsing = function (observer) { + var observers = this._observers; + null !== observers && observers.has(observer) + ? (observers.delete(observer), + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + unobserveChild, + observer, + void 0, + void 0 + )) + : console.error( + "You are calling unobserveUsing() with an observer that is not being observed with this fragment instance. First attach the observer with observeUsing()" + ); + }; + FragmentInstance.prototype.compareDocumentPosition = function (otherNode) { + var parentHostFiber = getFragmentParentInstanceOrContainerFiber( + this._fragmentFiber + ); + if (null === parentHostFiber) return Node.DOCUMENT_POSITION_DISCONNECTED; + var children = []; + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + collectChildren, + children, + void 0, + void 0 + ); + if (0 === children.length) { + var parentHostInstance = + getPublicInstanceFromHostFiber(parentHostFiber); + children = this._fragmentFiber; + parentHostFiber = getPublicInstanceFromHostFiber; + var parentResult = + parentHostInstance.compareDocumentPosition(otherNode); + var result = parentResult; + parentHostInstance === otherNode + ? (result = Node.DOCUMENT_POSITION_CONTAINS) + : parentResult & Node.DOCUMENT_POSITION_CONTAINED_BY && + ((parentHostInstance = [null, null]), + (result = getFragmentParentInstanceOrContainerFiber(children)), + null !== result && + findFragmentInstanceOrTextInstanceSiblings( + parentHostInstance, + children, + result.child, + { foundSelf: !1 } + ), + (children = parentHostInstance[1]), + null === children + ? (result = Node.DOCUMENT_POSITION_PRECEDING) + : ((otherNode = + parentHostFiber(children).compareDocumentPosition(otherNode)), + (result = + 0 === otherNode || + otherNode & Node.DOCUMENT_POSITION_FOLLOWING + ? Node.DOCUMENT_POSITION_FOLLOWING + : Node.DOCUMENT_POSITION_PRECEDING))); + return (result |= Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + } + parentHostFiber = getPublicInstanceFromHostFiber(children[0]); + children = getPublicInstanceFromHostFiber(children[children.length - 1]); + parentHostInstance = parentHostFiber.compareDocumentPosition(otherNode); + parentResult = children.compareDocumentPosition(otherNode); + result = + parentHostInstance & Node.DOCUMENT_POSITION_CONTAINED_BY || + parentResult & Node.DOCUMENT_POSITION_CONTAINED_BY; + parentResult = + parentHostInstance & Node.DOCUMENT_POSITION_FOLLOWING && + parentResult & Node.DOCUMENT_POSITION_PRECEDING; + return parentHostFiber === otherNode || + children === otherNode || + result || + parentResult + ? Node.DOCUMENT_POSITION_CONTAINED_BY + : parentHostInstance; + }; + FragmentInstance.prototype.getRootNode = function (getRootNodeOptions) { + var parentHostFiber = getFragmentParentInstanceOrContainerFiber( + this._fragmentFiber + ); + return null === parentHostFiber + ? this + : getPublicInstanceFromHostFiber(parentHostFiber).getRootNode( + getRootNodeOptions + ); + }; + FragmentInstance.prototype.getClientRects = function () { + var rects = []; + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + collectClientRects, + rects, + void 0, + void 0 + ); + return rects; + }; + var NotPendingTransition = null, HostTransitionContext = { $$typeof: REACT_CONTEXT_TYPE, Provider: null, @@ -18825,9 +20325,6 @@ __DEV__ && _currentValue2: NotPendingTransition, _threadCount: 0 }, - supportsMicrotasks = - "undefined" !== typeof RN$enableMicrotasksInReact && - !!RN$enableMicrotasksInReact, scheduleMicrotask = "function" === typeof queueMicrotask ? queueMicrotask : scheduleTimeout; (function ( @@ -18863,14 +20360,14 @@ __DEV__ && onChange: function (from, to, blockNativeResponder) { from && from.stateNode && - nativeFabricUIManager.setIsJSResponder( + reactPrivateInterface.fabricUIManager.setIsJSResponder( from.stateNode.node, !1, blockNativeResponder || !1 ); to && to.stateNode && - nativeFabricUIManager.setIsJSResponder( + reactPrivateInterface.fabricUIManager.setIsJSResponder( to.stateNode.node, !0, blockNativeResponder || !1 @@ -18879,7 +20376,7 @@ __DEV__ && }); if ( "function" !== - typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog + typeof reactPrivateInterface.ReactFiberErrorDialog.showErrorDialog ) throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." @@ -18901,10 +20398,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.2.3", + version: "19.3.0", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.3" + reconcilerVersion: "19.3.0" }; null !== extraDevToolsConfig && (internals.rendererConfig = extraDevToolsConfig); @@ -18933,23 +20430,16 @@ __DEV__ && ); }; exports.dispatchCommand = function (handle, command, args) { - var nativeTag = - null != handle._nativeTag - ? handle._nativeTag - : ReactNativePrivateInterface.getNativeTagFromPublicInstance(handle); - null == nativeTag - ? console.error( - "dispatchCommand was called with a ref that isn't a native component. Use React.forwardRef to get access to the underlying native component" + handle = reactPrivateInterface.getNodeFromPublicInstance(handle); + null != handle + ? reactPrivateInterface.fabricUIManager.dispatchCommand( + handle, + command, + args ) - : ((handle = - ReactNativePrivateInterface.getNodeFromPublicInstance(handle)), - null != handle - ? nativeFabricUIManager.dispatchCommand(handle, command, args) - : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( - nativeTag, - command, - args - )); + : console.error( + "dispatchCommand was called with a ref that isn't a native component. Use React.forwardRef to get access to the underlying native component" + ); }; exports.findHostInstance_DEPRECATED = function (componentOrHandle) { var owner = current; @@ -18967,14 +20457,46 @@ __DEV__ && : componentOrHandle.canonical && componentOrHandle.canonical.publicInstance ? componentOrHandle.canonical.publicInstance - : componentOrHandle._nativeTag - ? componentOrHandle - : findHostInstanceWithWarning( - componentOrHandle, - "findHostInstance_DEPRECATED" - ); + : findHostInstanceWithWarning( + componentOrHandle, + "findHostInstance_DEPRECATED" + ); + }; + exports.findNodeHandle = function (componentOrHandle) { + var owner = current; + null !== owner && + isRendering && + null !== owner.stateNode && + (owner.stateNode._warnedAboutRefsInRender || + console.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" + ), + (owner.stateNode._warnedAboutRefsInRender = !0)); + if (null == componentOrHandle) return null; + if ("number" === typeof componentOrHandle) return componentOrHandle; + if ( + null != componentOrHandle.canonical && + null != componentOrHandle.canonical.nativeTag + ) + return componentOrHandle.canonical.nativeTag; + if ( + (owner = + reactPrivateInterface.getNativeTagFromPublicInstance( + componentOrHandle + )) + ) + return owner; + componentOrHandle = findHostInstanceWithWarning( + componentOrHandle, + "findNodeHandle" + ); + return null == componentOrHandle + ? componentOrHandle + : reactPrivateInterface.getNativeTagFromPublicInstance( + componentOrHandle + ); }; - exports.findNodeHandle = findNodeHandle; exports.getNodeFromInternalInstanceHandle = getNodeFromInternalInstanceHandle; exports.getPublicInstanceFromInternalInstanceHandle = function ( @@ -18986,7 +20508,7 @@ __DEV__ && : 6 === internalInstanceHandle.tag ? (null == instance.publicInstance && (instance.publicInstance = - ReactNativePrivateInterface.createPublicTextInstance( + reactPrivateInterface.createPublicTextInstance( internalInstanceHandle )), instance.publicInstance) @@ -18998,25 +20520,35 @@ __DEV__ && : null; }; exports.isChildPublicInstance = function (parentInstance, childInstance) { - if ( - parentInstance._internalFiberInstanceHandleDEV && - childInstance._internalFiberInstanceHandleDEV - ) - return doesFiberContain( - parentInstance._internalFiberInstanceHandleDEV, - childInstance._internalFiberInstanceHandleDEV - ); parentInstance = - ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance( + reactPrivateInterface.getInternalInstanceHandleFromPublicInstance( parentInstance ); childInstance = - ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance( + reactPrivateInterface.getInternalInstanceHandleFromPublicInstance( childInstance ); - return null != parentInstance && null != childInstance - ? doesFiberContain(parentInstance, childInstance) - : !1; + if (null != parentInstance && null != childInstance) { + a: { + for ( + var parentFiberAlternate = parentInstance.alternate; + null !== childInstance; + + ) { + if ( + childInstance === parentInstance || + childInstance === parentFiberAlternate + ) { + parentInstance = !0; + break a; + } + childInstance = childInstance.return; + } + parentInstance = !1; + } + return parentInstance; + } + return !1; }; exports.render = function ( element, @@ -19041,7 +20573,7 @@ __DEV__ && (onRecoverableError = options.onRecoverableError); options = { publicInstance: - ReactNativePrivateInterface.createPublicRootInstance(containerTag), + reactPrivateInterface.createPublicRootInstance(containerTag), containerTag: containerTag }; concurrentRoot = concurrentRoot ? 1 : 0; @@ -19086,22 +20618,15 @@ __DEV__ && return element; }; exports.sendAccessibilityEvent = function (handle, eventType) { - var nativeTag = - null != handle._nativeTag - ? handle._nativeTag - : ReactNativePrivateInterface.getNativeTagFromPublicInstance(handle); - null == nativeTag - ? console.error( - "sendAccessibilityEvent was called with a ref that isn't a native component. Use React.forwardRef to get access to the underlying native component" + handle = reactPrivateInterface.getNodeFromPublicInstance(handle); + null != handle + ? reactPrivateInterface.fabricUIManager.sendAccessibilityEvent( + handle, + eventType ) - : ((handle = - ReactNativePrivateInterface.getNodeFromPublicInstance(handle)), - null != handle - ? nativeFabricUIManager.sendAccessibilityEvent(handle, eventType) - : ReactNativePrivateInterface.legacySendAccessibilityEvent( - nativeTag, - eventType - )); + : console.error( + "sendAccessibilityEvent was called with a ref that isn't a native component. Use React.forwardRef to get access to the underlying native component" + ); }; exports.stopSurface = function (containerTag) { var root = roots.get(containerTag); diff --git a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js index 2625bf690ab0..bf3cacd4395c 100644 --- a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js +++ b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js @@ -7,14 +7,14 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<8d29d23a1c540d7502dd188e691eb725>> + * @generated SignedSource<<3c59d85aa170213f7f757b2501b0b2f6>> * * This file was sync'd from the facebook/react repository. */ "use strict"; -require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); -var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"), +require("react-native/setup-env"); +var reactPrivateInterface = require("react-native/react-private-interface"), React = require("react"), Scheduler = require("scheduler"), isArrayImpl = Array.isArray, @@ -71,7 +71,26 @@ function describeNativeComponentFrame(fn, construct) { } catch (x$1) { control = x$1; } - fn.call(Fake.prototype); + Fake = !1; + try { + var prevProps = Object.getOwnPropertyDescriptor( + fn.prototype, + "props" + ); + Object.defineProperty(fn.prototype, "props", { + configurable: !0, + set: function () { + throw Error(); + } + }); + Fake = !0; + new fn(); + } finally { + Fake && + (void 0 !== prevProps + ? Object.defineProperty(fn.prototype, "props", prevProps) + : delete fn.prototype.props); + } } } else { try { @@ -196,6 +215,8 @@ function describeFiber(fiber, childFiber) { return describeNativeComponentFrame(fiber.type, !0); case 31: return describeBuiltInComponentFrame("Activity"); + case 30: + return describeBuiltInComponentFrame("ViewTransition"); default: return ""; } @@ -228,12 +249,13 @@ var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"); Symbol.for("react.scope"); -var REACT_ACTIVITY_TYPE = Symbol.for("react.activity"); -Symbol.for("react.legacy_hidden"); +var REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), + REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden"); Symbol.for("react.tracing_marker"); -var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"); -Symbol.for("react.view_transition"); -var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; +var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"), + REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"), + REACT_RECOVERABLE_TYPE = Symbol.for("react.recoverable"), + MAYBE_ITERATOR_SYMBOL = Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -241,7 +263,8 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); +var REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key"), + REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); function getComponentNameFromType(type) { if (null == type) return null; if ("function" === typeof type) @@ -262,6 +285,8 @@ function getComponentNameFromType(type) { return "SuspenseList"; case REACT_ACTIVITY_TYPE: return "Activity"; + case REACT_VIEW_TRANSITION_TYPE: + return "ViewTransition"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -301,11 +326,14 @@ var hasError = !1, getNodeFromInstance$1 = null; function executeDispatch(event, listener, inst) { event.currentTarget = getNodeFromInstance$1(inst); + inst = global.event; + global.event = event; try { listener(event); } catch (error) { hasError || ((hasError = !0), (caughtError = error)); } + global.event = inst; event.currentTarget = null; } function executeDirectDispatch(event) { @@ -321,6 +349,19 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } +function currentTimeStamp() { + currentTimeStamp = + "object" === typeof performance && + null !== performance && + "function" === typeof performance.now + ? function () { + return performance.now(); + } + : function () { + return Date.now(); + }; + return currentTimeStamp(); +} function functionThatReturnsTrue() { return !0; } @@ -397,7 +438,7 @@ SyntheticEvent.Interface = { bubbles: null, cancelable: null, timeStamp: function (event) { - return event.timeStamp || Date.now(); + return event.timeStamp || event.timestamp || currentTimeStamp(); }, defaultPrevented: null, isTrusted: null @@ -1100,11 +1141,10 @@ function getListener(inst, registrationName) { return inst; } var customBubblingEventTypes = - ReactNativePrivateInterface.ReactNativeViewConfigRegistry + reactPrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = - ReactNativePrivateInterface.ReactNativeViewConfigRegistry - .customDirectEventTypes; + reactPrivateInterface.ReactNativeViewConfigRegistry.customDirectEventTypes; function accumulateDirectionalDispatches(inst, phase, event) { if ( (phase = getListener( @@ -1169,7 +1209,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_277 = { +var injectedNamesToPlugins$jscomp$inline_294 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -1215,32 +1255,32 @@ var injectedNamesToPlugins$jscomp$inline_277 = { } } }, - isOrderingDirty$jscomp$inline_278 = !1, - pluginName$jscomp$inline_279; -for (pluginName$jscomp$inline_279 in injectedNamesToPlugins$jscomp$inline_277) + isOrderingDirty$jscomp$inline_295 = !1, + pluginName$jscomp$inline_296; +for (pluginName$jscomp$inline_296 in injectedNamesToPlugins$jscomp$inline_294) if ( - injectedNamesToPlugins$jscomp$inline_277.hasOwnProperty( - pluginName$jscomp$inline_279 + injectedNamesToPlugins$jscomp$inline_294.hasOwnProperty( + pluginName$jscomp$inline_296 ) ) { - var pluginModule$jscomp$inline_280 = - injectedNamesToPlugins$jscomp$inline_277[pluginName$jscomp$inline_279]; + var pluginModule$jscomp$inline_297 = + injectedNamesToPlugins$jscomp$inline_294[pluginName$jscomp$inline_296]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_279) || - namesToPlugins[pluginName$jscomp$inline_279] !== - pluginModule$jscomp$inline_280 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_296) || + namesToPlugins[pluginName$jscomp$inline_296] !== + pluginModule$jscomp$inline_297 ) { - if (namesToPlugins[pluginName$jscomp$inline_279]) + if (namesToPlugins[pluginName$jscomp$inline_296]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_279 + "`.") + (pluginName$jscomp$inline_296 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_279] = - pluginModule$jscomp$inline_280; - isOrderingDirty$jscomp$inline_278 = !0; + namesToPlugins[pluginName$jscomp$inline_296] = + pluginModule$jscomp$inline_297; + isOrderingDirty$jscomp$inline_295 = !0; } } -isOrderingDirty$jscomp$inline_278 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_295 && recomputePluginOrdering(); function batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); } @@ -1274,46 +1314,71 @@ function executeDispatchesAndReleaseTopLevel(e) { e.isPersistent() || e.constructor.release(e); } } -function dispatchEvent(target, topLevelType, nativeEvent) { - var eventTarget = null; - if (null != target) { - var stateNode = target.stateNode; - null != stateNode && (eventTarget = getPublicInstance(stateNode)); - } +var _enableNativeEventTargetEventDispatching = null; +function dispatchEvent(target, topLevelType, nativeEventParam) { + var nativeEvent = + null != nativeEventParam && "object" === typeof nativeEventParam + ? nativeEventParam + : {}, + eventTarget = null; + null != target && + ((nativeEventParam = target.stateNode), + null != nativeEventParam && + (eventTarget = getPublicInstance(nativeEventParam))); batchedUpdates$1(function () { var event = { eventName: topLevelType, nativeEvent: nativeEvent }; - ReactNativePrivateInterface.RawEventEmitter.emit(topLevelType, event); - ReactNativePrivateInterface.RawEventEmitter.emit("*", event); - event = eventTarget; - for ( - var events = null, legacyPlugins = plugins, i = 0; - i < legacyPlugins.length; - i++ - ) { - var possiblePlugin = legacyPlugins[i]; - possiblePlugin && - (possiblePlugin = possiblePlugin.extractEvents( + reactPrivateInterface.RawEventEmitter.emit(topLevelType, event); + reactPrivateInterface.RawEventEmitter.emit("*", event); + null == _enableNativeEventTargetEventDispatching && + ((event = + null != reactPrivateInterface.ReactNativeFeatureFlags + ? reactPrivateInterface.ReactNativeFeatureFlags + .enableNativeEventTargetEventDispatching + : null), + (_enableNativeEventTargetEventDispatching = + "function" === typeof event && event())); + if (_enableNativeEventTargetEventDispatching) + null != eventTarget && + reactPrivateInterface.dispatchNativeEvent( + eventTarget, topLevelType, - target, - nativeEvent, - event - )) && - (events = accumulateInto(events, possiblePlugin)); - } - event = events; - null !== event && (eventQueue = accumulateInto(eventQueue, event)); - event = eventQueue; - eventQueue = null; - if (event) { - forEachAccumulated(event, executeDispatchesAndReleaseTopLevel); - if (eventQueue) - throw Error( - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ); - if (hasError) - throw ( - ((event = caughtError), (hasError = !1), (caughtError = null), event) + nativeEvent ); + else { + event = eventTarget; + for ( + var events = null, legacyPlugins = plugins, i = 0; + i < legacyPlugins.length; + i++ + ) { + var possiblePlugin = legacyPlugins[i]; + possiblePlugin && + (possiblePlugin = possiblePlugin.extractEvents( + topLevelType, + target, + nativeEvent, + event + )) && + (events = accumulateInto(events, possiblePlugin)); + } + event = events; + null !== event && (eventQueue = accumulateInto(eventQueue, event)); + event = eventQueue; + eventQueue = null; + if (event) { + forEachAccumulated(event, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw Error( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasError) + throw ( + ((event = caughtError), + (hasError = !1), + (caughtError = null), + event) + ); + } } }); } @@ -1377,7 +1442,7 @@ function getHighestPriorityLanes(lanes) { case 32768: case 65536: case 131072: - return lanes & 261888; + return lanes & -lanes; case 262144: case 524288: case 1048576: @@ -1450,6 +1515,22 @@ function checkIfRootIsPrerendering(root, renderLanes) { renderLanes) ); } +function getEntangledLanes(root, renderLanes) { + 0 !== (renderLanes & 8) && (renderLanes |= renderLanes & 32); + var allEntangledLanes = root.entangledLanes; + if (0 !== allEntangledLanes) + for ( + root = root.entanglements, allEntangledLanes &= renderLanes; + 0 < allEntangledLanes; + + ) { + var index$6 = 31 - clz32(allEntangledLanes), + lane = 1 << index$6; + renderLanes |= root[index$6]; + allEntangledLanes &= ~lane; + } + return renderLanes; +} function computeExpirationTime(lane, currentTime) { switch (lane) { case 1: @@ -1628,18 +1709,12 @@ function lanesToEventPriority(lanes) { : 2; } function getNearestMountedFiber(fiber) { - var node = fiber, - nearestMounted = fiber; - if (fiber.alternate) for (; node.return; ) node = node.return; - else { - fiber = node; - do - (node = fiber), - 0 !== (node.flags & 4098) && (nearestMounted = node.return), - (fiber = node.return); - while (fiber); - } - return 3 === node.tag ? nearestMounted : null; + for (var node = fiber, nextNode = node; nextNode && !nextNode.alternate; ) + (node = nextNode), + 0 !== (node.flags & 4098) && (fiber = node.return), + (nextNode = node.return); + for (; node.return; ) node = node.return; + return 3 === node.tag ? fiber : null; } function assertIsMounted(fiber) { if (getNearestMountedFiber(fiber) !== fiber) @@ -1731,6 +1806,66 @@ function findCurrentHostFiberImpl(node) { } return null; } +function traverseVisibleInstancesAndTextInstances( + child, + searchWithinHosts, + fn, + a, + b, + c +) { + for (; null !== child; ) { + if ( + ((5 === child.tag || 27 === child.tag || 6 === child.tag) && + fn(child, a, b, c)) || + ((22 !== child.tag || null === child.memoizedState) && + (searchWithinHosts || (5 !== child.tag && 27 !== child.tag)) && + traverseVisibleInstancesAndTextInstances( + child.child, + searchWithinHosts, + fn, + a, + b, + c + )) + ) + return !0; + child = child.sibling; + } + return !1; +} +function getFragmentParentInstanceOrContainerFiber(fiber) { + for (fiber = fiber.return; null !== fiber; ) { + if (3 === fiber.tag || 5 === fiber.tag || 27 === fiber.tag) return fiber; + fiber = fiber.return; + } + return null; +} +function findFragmentInstanceOrTextInstanceSiblings( + result, + self, + child, + state +) { + for (; null !== child; ) { + if (child === self) state.foundSelf = !0; + else if (5 === child.tag || 27 === child.tag || 6 === child.tag) { + if (state.foundSelf) return (result[1] = child), !0; + result[0] = child; + } else if ( + (22 !== child.tag || null === child.memoizedState) && + findFragmentInstanceOrTextInstanceSiblings( + result, + self, + child.child, + state + ) + ) + return !0; + child = child.sibling; + } + return !1; +} var valueStack = [], index = -1; function createCursor(defaultValue) { @@ -1745,7 +1880,42 @@ function push(cursor, value) { valueStack[index] = cursor.current; cursor.current = value; } -var emptyContextObject = {}; +var emptyContextObject = {}, + globalClientIdCounter$1 = 0; +function getViewTransitionName(props, instance) { + if (null != props.name && "auto" !== props.name) return props.name; + if (null !== instance.autoName) return instance.autoName; + props = pendingEffectsRoot.identifierPrefix; + var globalClientId = globalClientIdCounter$1++; + props = "_" + props + "t_" + globalClientId.toString(32) + "_"; + return (instance.autoName = props); +} +function getClassNameByType(classByType) { + if (null == classByType || "string" === typeof classByType) + return classByType; + var className = null, + activeTypes = pendingTransitionTypes; + if (null !== activeTypes) + for (var i = 0; i < activeTypes.length; i++) { + var match = classByType[activeTypes[i]]; + if (null != match) { + if ("none" === match) return "none"; + className = null == className ? match : className + (" " + match); + } + } + return null == className ? classByType.default : className; +} +function getViewTransitionClassName(defaultClass, eventClass) { + defaultClass = getClassNameByType(defaultClass); + eventClass = getClassNameByType(eventClass); + return null == eventClass + ? "auto" === defaultClass + ? null + : defaultClass + : "auto" === eventClass + ? null + : eventClass; +} function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -1817,10 +1987,13 @@ function popHostContainer() { pop(rootInstanceStackCursor); } function pushHostContext(fiber) { - null !== fiber.memoizedState && push(hostTransitionProviderCursor, fiber); - var context = contextStackCursor.current; - context !== context && - (push(contextFiberStackCursor, fiber), push(contextStackCursor, context)); + var stateHook = fiber.memoizedState; + null !== stateHook && + ((HostTransitionContext._currentValue2 = stateHook.memoizedState), + push(hostTransitionProviderCursor, fiber)); + stateHook = contextStackCursor.current; + stateHook !== stateHook && + (push(contextFiberStackCursor, fiber), push(contextStackCursor, stateHook)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && @@ -1908,7 +2081,21 @@ function propagateContextChanges( null !== list && (list.lanes |= renderLanes); scheduleContextWorkOnParentPath(nextFiber, renderLanes, workInProgress); nextFiber = null; - } else nextFiber = fiber.child; + } else + 13 === fiber.tag && + null !== fiber.memoizedState && + null === fiber.memoizedState.dehydrated + ? ((fiber.lanes |= renderLanes), + (nextFiber = fiber.alternate), + null !== nextFiber && (nextFiber.lanes |= renderLanes), + scheduleContextWorkOnParentPath( + fiber.return, + renderLanes, + workInProgress + ), + (nextFiber = fiber.child), + (nextFiber = null !== nextFiber ? nextFiber.sibling : null)) + : (nextFiber = fiber.child); if (null !== nextFiber) nextFiber.return = fiber; else for (nextFiber = fiber; null !== nextFiber; ) { @@ -1972,6 +2159,7 @@ function propagateParentContextChanges( forcePropagateEntireTree ); workInProgress.flags |= 262144; + return null !== current; } function checkIfContextChanged(currentDependencies) { for ( @@ -2059,6 +2247,22 @@ function releaseCache(cache) { cache.controller.abort(); }); } +function queueTransitionTypes(root, transitionTypes) { + if (0 !== (root.pendingLanes & 4194048)) { + var queued = root.transitionTypes; + null === queued && (queued = root.transitionTypes = []); + for (root = 0; root < transitionTypes.length; root++) { + var transitionType = transitionTypes[root]; + -1 === queued.indexOf(transitionType) && queued.push(transitionType); + } + } +} +var entangledTransitionTypes = null; +function claimQueuedTransitionTypes(root) { + var claimed = root.transitionTypes; + root.transitionTypes = null; + return claimed; +} function noop() {} var firstScheduledRoot = null, lastScheduledRoot = null, @@ -2240,16 +2444,14 @@ function performSyncWorkOnRoot(root, lanes) { performWorkOnRoot(root, lanes, !0); } function scheduleImmediateRootScheduleTask() { - supportsMicrotasks - ? scheduleMicrotask(function () { - 0 !== (executionContext & 6) - ? scheduleCallback$3( - ImmediatePriority, - processRootScheduleInImmediateTask - ) - : processRootScheduleInMicrotask(); - }) - : scheduleCallback$3(ImmediatePriority, processRootScheduleInImmediateTask); + scheduleMicrotask(function () { + 0 !== (executionContext & 6) + ? scheduleCallback$3( + ImmediatePriority, + processRootScheduleInImmediateTask + ) + : processRootScheduleInMicrotask(); + }); } function requestTransitionLane() { if (0 === currentEventTransitionLane) { @@ -2287,7 +2489,7 @@ function entangleAsyncAction(transition, thenable) { function pingEngtangledActionScope() { if ( 0 === --currentEntangledPendingCount && - null !== currentEntangledListeners + ((entangledTransitionTypes = null), null !== currentEntangledListeners) ) { null !== currentEntangledActionThenable && (currentEntangledActionThenable.status = "fulfilled"); @@ -2330,6 +2532,22 @@ ReactSharedInternals.S = function (transition, returnValue) { null !== returnValue && "function" === typeof returnValue.then && entangleAsyncAction(transition, returnValue); + if (null !== entangledTransitionTypes) + for (var root = firstScheduledRoot; null !== root; ) + queueTransitionTypes(root, entangledTransitionTypes), (root = root.next); + root = transition.types; + if (null !== root) { + for (var root$18 = firstScheduledRoot; null !== root$18; ) + queueTransitionTypes(root$18, root), (root$18 = root$18.next); + if (0 !== currentEntangledLane) { + root$18 = entangledTransitionTypes; + null === root$18 && (root$18 = entangledTransitionTypes = []); + for (var i = 0; i < root.length; i++) { + var transitionType = root[i]; + -1 === root$18.indexOf(transitionType) && root$18.push(transitionType); + } + } + } null !== prevOnStartTransitionFinish && prevOnStartTransitionFinish(transition, returnValue); }; @@ -2396,11 +2614,13 @@ function trackUsedThenable(thenableState, thenable, index) { case "fulfilled": return thenable.value; case "rejected": - throw ( - ((thenableState = thenable.reason), - checkIfUseWrappedInAsyncCatch(thenableState), - thenableState) - ); + thenableState = thenable.reason; + checkIfUseWrappedInAsyncCatch(thenableState); + if (void 0 === thenableState && !("reason" in thenable)) + throw Error( + "A rejected Promise was passed to React without a `reason` property. React threw a generic error from where the Promise was used to assist in identifying the problematic Promise. Make sure that instrumented Promises correctly set the `reason` property when setting `status` to `'rejected'`." + ); + throw thenableState; default: if ("string" === typeof thenable.status) thenable.then(noop, noop); else { @@ -2515,9 +2735,9 @@ function createChildReconciler(shouldTrackSideEffects) { } function mapRemainingChildren(currentFirstChild) { for (var existingChildren = new Map(); null !== currentFirstChild; ) - null !== currentFirstChild.key - ? existingChildren.set(currentFirstChild.key, currentFirstChild) - : existingChildren.set(currentFirstChild.index, currentFirstChild), + null === currentFirstChild.key + ? existingChildren.set(currentFirstChild.index, currentFirstChild) + : existingChildren.set(currentFirstChild.key, currentFirstChild), (currentFirstChild = currentFirstChild.sibling); return existingChildren; } @@ -2536,16 +2756,16 @@ function createChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.flags |= 67108866), lastPlacedIndex) + ? ((newFiber.flags |= 2), lastPlacedIndex) : newIndex ); - newFiber.flags |= 67108866; + newFiber.flags |= 134217730; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.flags |= 67108866); + (newFiber.flags |= 134217730); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -2562,12 +2782,16 @@ function createChildReconciler(shouldTrackSideEffects) { function updateElement(returnFiber, current, element, lanes) { var elementType = element.type; if (elementType === REACT_FRAGMENT_TYPE) - return updateFragment( - returnFiber, - current, - element.props.children, - lanes, - element.key + return ( + (returnFiber = updateFragment( + returnFiber, + current, + element.props.children, + lanes, + element.key + )), + coerceRef(returnFiber, element), + returnFiber ); if ( null !== current && @@ -2888,10 +3112,9 @@ function createChildReconciler(shouldTrackSideEffects) { )), null !== nextOldFiber && (shouldTrackSideEffects && - null !== nextOldFiber.alternate && - oldFiber.delete( - null === nextOldFiber.key ? newIdx : nextOldFiber.key - ), + ((newFiber = nextOldFiber.alternate), + null !== newFiber && + oldFiber.delete(null === newFiber.key ? newIdx : newFiber.key)), (currentFirstChild = placeChild( nextOldFiber, currentFirstChild, @@ -2967,8 +3190,11 @@ function createChildReconciler(shouldTrackSideEffects) { (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && (shouldTrackSideEffects && - null !== step.alternate && - oldFiber.delete(null === step.key ? newIdx : step.key), + ((nextOldFiber = step.alternate), + null !== nextOldFiber && + oldFiber.delete( + null === nextOldFiber.key ? newIdx : nextOldFiber.key + )), (currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber ? (resultingFirstChild = step) @@ -2990,6 +3216,7 @@ function createChildReconciler(shouldTrackSideEffects) { null !== newChild && newChild.type === REACT_FRAGMENT_TYPE && null === newChild.key && + void 0 === newChild.props.ref && (newChild = newChild.props.children); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -3008,6 +3235,7 @@ function createChildReconciler(shouldTrackSideEffects) { currentFirstChild, newChild.props.children ); + coerceRef(lanes, newChild); lanes.return = returnFiber; returnFiber = lanes; break a; @@ -3041,6 +3269,7 @@ function createChildReconciler(shouldTrackSideEffects) { lanes, newChild.key )), + coerceRef(lanes, newChild), (lanes.return = returnFiber), (returnFiber = lanes)) : ((lanes = createFiberFromTypeAndProps( @@ -3553,7 +3782,7 @@ function pushOffscreenSuspenseHandler(fiber) { ? (push(suspenseStackCursor, suspenseStackCursor.current), push(suspenseHandlerStackCursor, fiber), null === shellBoundary && (shellBoundary = fiber)) - : reuseSuspenseHandlerOnStack(fiber); + : reuseSuspenseHandlerOnStack(); } function reuseSuspenseHandlerOnStack() { push(suspenseStackCursor, suspenseStackCursor.current); @@ -3565,6 +3794,15 @@ function popSuspenseHandler(fiber) { pop(suspenseStackCursor); } var suspenseStackCursor = createCursor(0); +function pushSuspenseListContext(fiber, newContext) { + push(suspenseHandlerStackCursor, suspenseHandlerStackCursor.current); + push(suspenseStackCursor, newContext); +} +function popSuspenseListContext(fiber) { + pop(suspenseStackCursor); + pop(suspenseHandlerStackCursor); + shellBoundary === fiber && (shellBoundary = null); +} function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3573,10 +3811,7 @@ function findFirstSuspended(row) { return node; } else if ( 19 === node.tag && - ("forwards" === node.memoizedProps.revealOrder || - "backwards" === node.memoizedProps.revealOrder || - "unstable_legacy-backwards" === node.memoizedProps.revealOrder || - "together" === node.memoizedProps.revealOrder) + "independent" !== node.memoizedProps.revealOrder ) { if (0 !== (node.flags & 128)) return node; } else if (null !== node.child) { @@ -3797,6 +4032,7 @@ function useThenable(thenable) { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) return useThenable(usable); + if (usable.$$typeof === REACT_RECOVERABLE_TYPE) return; if (usable.$$typeof === REACT_CONTEXT_TYPE) return readContext(usable); } throw Error("An unsupported type was passed to use(): " + String(usable)); @@ -3867,7 +4103,7 @@ function updateReducerImpl(hook, current, reducer) { var newBaseQueueFirst = (baseFirst = null), newBaseQueueLast = null, update = current, - didReadFromEntangledAsyncAction$46 = !1; + didReadFromEntangledAsyncAction$48 = !1; do { var updateLane = update.lane & -536870913; if ( @@ -3889,11 +4125,11 @@ function updateReducerImpl(hook, current, reducer) { next: null }), updateLane === currentEntangledLane && - (didReadFromEntangledAsyncAction$46 = !0); + (didReadFromEntangledAsyncAction$48 = !0); else if ((renderLanes & revertLane) === revertLane) { update = update.next; revertLane === currentEntangledLane && - (didReadFromEntangledAsyncAction$46 = !0); + (didReadFromEntangledAsyncAction$48 = !0); continue; } else (updateLane = { @@ -3941,7 +4177,7 @@ function updateReducerImpl(hook, current, reducer) { if ( !objectIs(pendingQueue, hook.memoizedState) && ((didReceiveUpdate = !0), - didReadFromEntangledAsyncAction$46 && + didReadFromEntangledAsyncAction$48 && ((reducer = currentEntangledActionThenable), null !== reducer)) ) throw reducer; @@ -3990,18 +4226,19 @@ function updateSyncExternalStore(subscribe, getSnapshot) { updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [ subscribe ]); - if ( + subscribe = hook.getSnapshot !== getSnapshot || snapshotChanged || - (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1) - ) { + (null !== workInProgressHook && + 0 !== (workInProgressHook.memoizedState.tag & 1)); + pushSimpleEffect( + subscribe ? 9 : 8, + { destroy: void 0 }, + updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), + null + ); + if (subscribe) { fiber.flags |= 2048; - pushSimpleEffect( - 9, - { destroy: void 0 }, - updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), - null - ); if (null === workInProgressRoot) throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." @@ -4088,7 +4325,7 @@ function dispatchActionState( payload ) { if (isRenderPhaseUpdate(fiber)) - throw Error("Cannot update form state while rendering."); + throw Error("Cannot update action state while rendering."); fiber = actionQueue.action; if (null !== fiber) { var actionNode = { @@ -4123,6 +4360,8 @@ function runActionStateAction(actionQueue, node) { if (node.isTransition) { var prevTransition = ReactSharedInternals.T, currentTransition = {}; + currentTransition.types = + null !== prevTransition ? prevTransition.types : null; ReactSharedInternals.T = currentTransition; try { var returnValue = action(prevState, payload), @@ -4142,8 +4381,8 @@ function runActionStateAction(actionQueue, node) { try { (prevTransition = action(prevState, payload)), handleActionReturnValue(actionQueue, node, prevTransition); - } catch (error$50) { - onActionError(actionQueue, node, error$50); + } catch (error$52) { + onActionError(actionQueue, node, error$52); } } function handleActionReturnValue(actionQueue, node, returnValue) { @@ -4437,7 +4676,7 @@ function updateDeferredValueImpl(hook, prevValue, value, initialValue) { hook ); if ( - 0 === (renderLanes & 42) || + 0 === (renderLanes & 106) || (0 !== (renderLanes & 1073741824) && 0 === (workInProgressRootRenderLanes & 261930)) ) @@ -4453,6 +4692,8 @@ function startTransition(fiber, queue, pendingState, finishedState, callback) { 0 !== previousPriority && 8 > previousPriority ? previousPriority : 8; var prevTransition = ReactSharedInternals.T, currentTransition = {}; + currentTransition.types = + null !== prevTransition ? prevTransition.types : null; ReactSharedInternals.T = currentTransition; dispatchOptimisticSetState(fiber, !1, queue, pendingState); try { @@ -4637,32 +4878,32 @@ function entangleTransitionUpdate(root, queue, lane) { } } var ContextOnlyDispatcher = { - readContext: readContext, - use: use, - useCallback: throwInvalidHookError, - useContext: throwInvalidHookError, - useEffect: throwInvalidHookError, - useImperativeHandle: throwInvalidHookError, - useLayoutEffect: throwInvalidHookError, - useInsertionEffect: throwInvalidHookError, - useMemo: throwInvalidHookError, - useReducer: throwInvalidHookError, - useRef: throwInvalidHookError, - useState: throwInvalidHookError, - useDebugValue: throwInvalidHookError, - useDeferredValue: throwInvalidHookError, - useTransition: throwInvalidHookError, - useSyncExternalStore: throwInvalidHookError, - useId: throwInvalidHookError, - useHostTransitionStatus: throwInvalidHookError, - useFormState: throwInvalidHookError, - useActionState: throwInvalidHookError, - useOptimistic: throwInvalidHookError, - useMemoCache: throwInvalidHookError, - useCacheRefresh: throwInvalidHookError -}; -ContextOnlyDispatcher.useEffectEvent = throwInvalidHookError; -var HooksDispatcherOnMount = { + readContext: readContext, + use: use, + useCallback: throwInvalidHookError, + useContext: throwInvalidHookError, + useEffect: throwInvalidHookError, + useImperativeHandle: throwInvalidHookError, + useLayoutEffect: throwInvalidHookError, + useInsertionEffect: throwInvalidHookError, + useMemo: throwInvalidHookError, + useReducer: throwInvalidHookError, + useRef: throwInvalidHookError, + useState: throwInvalidHookError, + useDebugValue: throwInvalidHookError, + useDeferredValue: throwInvalidHookError, + useTransition: throwInvalidHookError, + useSyncExternalStore: throwInvalidHookError, + useId: throwInvalidHookError, + useHostTransitionStatus: throwInvalidHookError, + useFormState: throwInvalidHookError, + useActionState: throwInvalidHookError, + useOptimistic: throwInvalidHookError, + useMemoCache: throwInvalidHookError, + useCacheRefresh: throwInvalidHookError, + useEffectEvent: throwInvalidHookError + }, + HooksDispatcherOnMount = { readContext: readContext, use: use, useCallback: function (callback, deps) { @@ -4883,62 +5124,62 @@ var HooksDispatcherOnMount = { return updateOptimisticImpl(hook, currentHook, passthrough, reducer); }, useMemoCache: useMemoCache, - useCacheRefresh: updateRefresh - }; -HooksDispatcherOnUpdate.useEffectEvent = updateEvent; -var HooksDispatcherOnRerender = { - readContext: readContext, - use: use, - useCallback: updateCallback, - useContext: readContext, - useEffect: updateEffect, - useImperativeHandle: updateImperativeHandle, - useInsertionEffect: updateInsertionEffect, - useLayoutEffect: updateLayoutEffect, - useMemo: updateMemo, - useReducer: rerenderReducer, - useRef: updateRef, - useState: function () { - return rerenderReducer(basicStateReducer); - }, - useDebugValue: mountDebugValue, - useDeferredValue: function (value, initialValue) { - var hook = updateWorkInProgressHook(); - return null === currentHook - ? mountDeferredValueImpl(hook, value, initialValue) - : updateDeferredValueImpl( - hook, - currentHook.memoizedState, - value, - initialValue - ); + useCacheRefresh: updateRefresh, + useEffectEvent: updateEvent }, - useTransition: function () { - var booleanOrThenable = rerenderReducer(basicStateReducer)[0], - start = updateWorkInProgressHook().memoizedState; - return [ - "boolean" === typeof booleanOrThenable - ? booleanOrThenable - : useThenable(booleanOrThenable), - start - ]; - }, - useSyncExternalStore: updateSyncExternalStore, - useId: updateId, - useHostTransitionStatus: useHostTransitionStatus, - useFormState: rerenderActionState, - useActionState: rerenderActionState, - useOptimistic: function (passthrough, reducer) { - var hook = updateWorkInProgressHook(); - if (null !== currentHook) - return updateOptimisticImpl(hook, currentHook, passthrough, reducer); - hook.baseState = passthrough; - return [passthrough, hook.queue.dispatch]; - }, - useMemoCache: useMemoCache, - useCacheRefresh: updateRefresh -}; -HooksDispatcherOnRerender.useEffectEvent = updateEvent; + HooksDispatcherOnRerender = { + readContext: readContext, + use: use, + useCallback: updateCallback, + useContext: readContext, + useEffect: updateEffect, + useImperativeHandle: updateImperativeHandle, + useInsertionEffect: updateInsertionEffect, + useLayoutEffect: updateLayoutEffect, + useMemo: updateMemo, + useReducer: rerenderReducer, + useRef: updateRef, + useState: function () { + return rerenderReducer(basicStateReducer); + }, + useDebugValue: mountDebugValue, + useDeferredValue: function (value, initialValue) { + var hook = updateWorkInProgressHook(); + return null === currentHook + ? mountDeferredValueImpl(hook, value, initialValue) + : updateDeferredValueImpl( + hook, + currentHook.memoizedState, + value, + initialValue + ); + }, + useTransition: function () { + var booleanOrThenable = rerenderReducer(basicStateReducer)[0], + start = updateWorkInProgressHook().memoizedState; + return [ + "boolean" === typeof booleanOrThenable + ? booleanOrThenable + : useThenable(booleanOrThenable), + start + ]; + }, + useSyncExternalStore: updateSyncExternalStore, + useId: updateId, + useHostTransitionStatus: useHostTransitionStatus, + useFormState: rerenderActionState, + useActionState: rerenderActionState, + useOptimistic: function (passthrough, reducer) { + var hook = updateWorkInProgressHook(); + if (null !== currentHook) + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + hook.baseState = passthrough; + return [passthrough, hook.queue.dispatch]; + }, + useMemoCache: useMemoCache, + useCacheRefresh: updateRefresh, + useEffectEvent: updateEvent + }; function applyDerivedStateFromProps( workInProgress, ctor, @@ -5077,9 +5318,9 @@ function resolveClassComponentProps(Component, baseProps) { } if ((Component = Component.defaultProps)) { newProps === baseProps && (newProps = assign({}, newProps)); - for (var propName$52 in Component) - void 0 === newProps[propName$52] && - (newProps[propName$52] = Component[propName$52]); + for (var propName$54 in Component) + void 0 === newProps[propName$54] && + (newProps[propName$54] = Component[propName$54]); } return newProps; } @@ -5186,6 +5427,7 @@ function throwException( switch (currentSourceFiber.tag) { case 31: case 13: + case 19: return ( sourceFiber.mode & 1 && (null === shellBoundary @@ -5285,17 +5527,17 @@ function throwException( !1 ); case 1: + sourceFiber = returnFiber.type; + currentSourceFiber = returnFiber.stateNode; if ( - ((sourceFiber = returnFiber.type), - (currentSourceFiber = returnFiber.stateNode), 0 === (returnFiber.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== currentSourceFiber && + "function" === typeof currentSourceFiber.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has( + currentSourceFiber + )))) ) return ( (returnFiber.flags |= 65536), @@ -5311,6 +5553,10 @@ function throwException( enqueueCapturedUpdate(returnFiber, rootRenderLanes), !1 ); + break; + case 22: + if (null !== returnFiber.memoizedState) + return (returnFiber.flags |= 65536), !1; } returnFiber = returnFiber.return; } while (null !== returnFiber); @@ -5515,11 +5761,11 @@ function updateOffscreenComponent( null !== prevState ? (pushTransition(workInProgress, prevState.cachePool), pushHiddenContext(workInProgress, prevState), - reuseSuspenseHandlerOnStack(workInProgress), + reuseSuspenseHandlerOnStack(), (workInProgress.memoizedState = null)) : (null !== current && pushTransition(workInProgress, null), reuseHiddenContextOnStack(), - reuseSuspenseHandlerOnStack(workInProgress)); + reuseSuspenseHandlerOnStack()); reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -5906,172 +6152,81 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { JSCompiler_temp = 0 !== (workInProgress.flags & 32); workInProgress.flags &= -33; if (null === current) { - var nextPrimaryChildren = nextProps.children; + didSuspend = nextProps.children; nextProps = nextProps.fallback; - if (showFallback) - return ( - reuseSuspenseHandlerOnStack(workInProgress), - (showFallback = workInProgress.mode), - (didSuspend = workInProgress.child), - (nextPrimaryChildren = { - mode: "hidden", - children: nextPrimaryChildren - }), - 0 === (showFallback & 1) && null !== didSuspend - ? ((didSuspend.childLanes = 0), - (didSuspend.pendingProps = nextPrimaryChildren)) - : (didSuspend = mountWorkInProgressOffscreenFiber( - nextPrimaryChildren, - showFallback - )), - (nextProps = createFiberFromFragment( - nextProps, - showFallback, - renderLanes, - null - )), - (didSuspend.return = workInProgress), - (nextProps.return = workInProgress), - (didSuspend.sibling = nextProps), - (workInProgress.child = didSuspend), - (nextProps = workInProgress.child), - (nextProps.memoizedState = mountSuspenseOffscreenState(renderLanes)), - (nextProps.childLanes = getRemainingWorkInPrimaryTree( - current, - JSCompiler_temp, - renderLanes - )), - (workInProgress.memoizedState = SUSPENDED_MARKER), - bailoutOffscreenComponent(null, nextProps) + if (showFallback) { + reuseSuspenseHandlerOnStack(); + showFallback = workInProgress.mode; + var progressedPrimaryFragment = workInProgress.child; + didSuspend = { mode: "hidden", children: didSuspend }; + 0 === (showFallback & 1) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = didSuspend)) + : (progressedPrimaryFragment = mountWorkInProgressOffscreenFiber( + didSuspend, + showFallback + )); + nextProps = createFiberFromFragment( + nextProps, + showFallback, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + nextProps.return = workInProgress; + progressedPrimaryFragment.sibling = nextProps; + workInProgress.child = progressedPrimaryFragment; + nextProps = workInProgress.child; + nextProps.memoizedState = mountSuspenseOffscreenState(renderLanes); + nextProps.childLanes = getRemainingWorkInPrimaryTree( + current, + JSCompiler_temp, + renderLanes ); + workInProgress.memoizedState = SUSPENDED_MARKER; + return bailoutOffscreenComponent(null, nextProps); + } pushPrimaryTreeSuspenseHandler(workInProgress); - return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren); - } - nextPrimaryChildren = current.memoizedState; - if (null !== nextPrimaryChildren && null !== nextPrimaryChildren.dehydrated) { - if (didSuspend) - workInProgress.flags & 256 - ? (pushPrimaryTreeSuspenseHandler(workInProgress), - (workInProgress.flags &= -257), - (workInProgress = retrySuspenseComponentWithoutHydrating( - current, - workInProgress, - renderLanes - ))) - : null !== workInProgress.memoizedState - ? (reuseSuspenseHandlerOnStack(workInProgress), - (workInProgress.child = current.child), - (workInProgress.flags |= 128), - (workInProgress = null)) - : (reuseSuspenseHandlerOnStack(workInProgress), - (showFallback = nextProps.fallback), - (nextPrimaryChildren = workInProgress.mode), - (nextProps = mountWorkInProgressOffscreenFiber( - { mode: "visible", children: nextProps.children }, - nextPrimaryChildren - )), - (showFallback = createFiberFromFragment( - showFallback, - nextPrimaryChildren, - renderLanes, - null - )), - (showFallback.flags |= 2), - (nextProps.return = workInProgress), - (showFallback.return = workInProgress), - (nextProps.sibling = showFallback), - (workInProgress.child = nextProps), - 0 !== (workInProgress.mode & 1) && - reconcileChildFibers( - workInProgress, - current.child, - null, - renderLanes - ), - (nextProps = workInProgress.child), - (nextProps.memoizedState = - mountSuspenseOffscreenState(renderLanes)), - (nextProps.childLanes = getRemainingWorkInPrimaryTree( - current, - JSCompiler_temp, - renderLanes - )), - (workInProgress.memoizedState = SUSPENDED_MARKER), - (workInProgress = bailoutOffscreenComponent(null, nextProps))); - else if ((pushPrimaryTreeSuspenseHandler(workInProgress), shim$1())) - (JSCompiler_temp = shim$1().digest), - (nextProps = Error( - "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." - )), - (nextProps.stack = ""), - (nextProps.digest = JSCompiler_temp), - (JSCompiler_temp = { value: nextProps, source: null, stack: null }), - null === hydrationErrors - ? (hydrationErrors = [JSCompiler_temp]) - : hydrationErrors.push(JSCompiler_temp), - (workInProgress = retrySuspenseComponentWithoutHydrating( - current, - workInProgress, - renderLanes - )); - else if ( - (didReceiveUpdate || - propagateParentContextChanges(current, workInProgress, renderLanes, !1), - (JSCompiler_temp = 0 !== (renderLanes & current.childLanes)), - didReceiveUpdate || JSCompiler_temp) - ) { - JSCompiler_temp = workInProgressRoot; - if ( - null !== JSCompiler_temp && - ((nextProps = getBumpedLaneForHydration(JSCompiler_temp, renderLanes)), - 0 !== nextProps && nextProps !== nextPrimaryChildren.retryLane) - ) - throw ( - ((nextPrimaryChildren.retryLane = nextProps), - enqueueConcurrentRenderForLane(current, nextProps), - scheduleUpdateOnFiber(JSCompiler_temp, current, nextProps), - SelectiveHydrationException) - ); - shim$1() || renderDidSuspendDelayIfPossible(); - workInProgress = retrySuspenseComponentWithoutHydrating( + return mountSuspensePrimaryChildren(workInProgress, didSuspend); + } + progressedPrimaryFragment = current.memoizedState; + if (null !== progressedPrimaryFragment) { + var dehydrated = progressedPrimaryFragment.dehydrated; + if (null !== dehydrated) + return updateDehydratedSuspenseComponent( current, workInProgress, + didSuspend, + JSCompiler_temp, + nextProps, + dehydrated, + progressedPrimaryFragment, renderLanes ); - } else - shim$1() - ? ((workInProgress.flags |= 192), - (workInProgress.child = current.child), - (workInProgress = null)) - : ((workInProgress = mountSuspensePrimaryChildren( - workInProgress, - nextProps.children - )), - (workInProgress.flags |= 4096)); - return workInProgress; } if (showFallback) { - reuseSuspenseHandlerOnStack(workInProgress); + reuseSuspenseHandlerOnStack(); showFallback = nextProps.fallback; - nextPrimaryChildren = workInProgress.mode; - didSuspend = current.child; - var currentFallbackChildFragment = didSuspend.sibling, - primaryChildProps = { mode: "hidden", children: nextProps.children }; - 0 === (nextPrimaryChildren & 1) && workInProgress.child !== didSuspend + didSuspend = workInProgress.mode; + progressedPrimaryFragment = current.child; + dehydrated = progressedPrimaryFragment.sibling; + var primaryChildProps = { mode: "hidden", children: nextProps.children }; + 0 === (didSuspend & 1) && workInProgress.child !== progressedPrimaryFragment ? ((nextProps = workInProgress.child), (nextProps.childLanes = 0), (nextProps.pendingProps = primaryChildProps), (workInProgress.deletions = null)) - : ((nextProps = createWorkInProgress(didSuspend, primaryChildProps)), - (nextProps.subtreeFlags = didSuspend.subtreeFlags & 65011712)); - null !== currentFallbackChildFragment - ? (showFallback = createWorkInProgress( - currentFallbackChildFragment, - showFallback - )) + : ((nextProps = createWorkInProgress( + progressedPrimaryFragment, + primaryChildProps + )), + (nextProps.subtreeFlags = + progressedPrimaryFragment.subtreeFlags & 1206910976)); + null !== dehydrated + ? (showFallback = createWorkInProgress(dehydrated, showFallback)) : ((showFallback = createFiberFromFragment( showFallback, - nextPrimaryChildren, + didSuspend, renderLanes, null )), @@ -6085,17 +6240,20 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { showFallback = current.child.memoizedState; null === showFallback ? (showFallback = mountSuspenseOffscreenState(renderLanes)) - : ((nextPrimaryChildren = showFallback.cachePool), - null !== nextPrimaryChildren - ? ((didSuspend = CacheContext._currentValue2), - (nextPrimaryChildren = - nextPrimaryChildren.parent !== didSuspend - ? { parent: didSuspend, pool: didSuspend } - : nextPrimaryChildren)) - : (nextPrimaryChildren = getSuspendedCache()), + : ((didSuspend = showFallback.cachePool), + null !== didSuspend + ? ((progressedPrimaryFragment = CacheContext._currentValue2), + (didSuspend = + didSuspend.parent !== progressedPrimaryFragment + ? { + parent: progressedPrimaryFragment, + pool: progressedPrimaryFragment + } + : didSuspend)) + : (didSuspend = getSuspendedCache()), (showFallback = { baseLanes: showFallback.baseLanes | renderLanes, - cachePool: nextPrimaryChildren + cachePool: didSuspend })); nextProps.memoizedState = showFallback; nextProps.childLanes = getRemainingWorkInPrimaryTree( @@ -6152,57 +6310,206 @@ function retrySuspenseComponentWithoutHydrating( workInProgress.memoizedState = null; return current; } -function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) { - fiber.lanes |= renderLanes; - var alternate = fiber.alternate; - null !== alternate && (alternate.lanes |= renderLanes); - scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot); -} -function initSuspenseListRenderState( +function updateDehydratedSuspenseComponent( + current, workInProgress, - isBackwards, - tail, - lastContentRow, - tailMode, - treeForkCount + didSuspend, + didPrimaryChildrenDefer, + nextProps, + suspenseInstance, + suspenseState, + renderLanes ) { - var renderState = workInProgress.memoizedState; - null === renderState - ? (workInProgress.memoizedState = { - isBackwards: isBackwards, - rendering: null, - renderingStartTime: 0, - last: lastContentRow, - tail: tail, - tailMode: tailMode, - treeForkCount: treeForkCount - }) - : ((renderState.isBackwards = isBackwards), - (renderState.rendering = null), - (renderState.renderingStartTime = 0), - (renderState.last = lastContentRow), - (renderState.tail = tail), - (renderState.tailMode = tailMode), - (renderState.treeForkCount = treeForkCount)); -} -function updateSuspenseListComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps, - revealOrder = nextProps.revealOrder, - tailMode = nextProps.tail; - nextProps = nextProps.children; - var suspenseContext = suspenseStackCursor.current, - shouldForceFallback = 0 !== (suspenseContext & 2); - shouldForceFallback - ? ((suspenseContext = (suspenseContext & 1) | 2), - (workInProgress.flags |= 128)) - : (suspenseContext &= 1); - push(suspenseStackCursor, suspenseContext); - reconcileChildren(current, workInProgress, nextProps, renderLanes); - if (!shouldForceFallback && null !== current && 0 !== (current.flags & 128)) - a: for (current = workInProgress.child; null !== current; ) { - if (13 === current.tag) - null !== current.memoizedState && - scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress); + if (didSuspend) { + if (workInProgress.flags & 256) + return ( + pushPrimaryTreeSuspenseHandler(workInProgress), + (workInProgress.flags &= -257), + retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ) + ); + if (null !== workInProgress.memoizedState) + return ( + reuseSuspenseHandlerOnStack(), + (workInProgress.child = current.child), + (workInProgress.flags |= 128), + null + ); + reuseSuspenseHandlerOnStack(); + suspenseState = nextProps.fallback; + didSuspend = workInProgress.mode; + nextProps = mountWorkInProgressOffscreenFiber( + { mode: "visible", children: nextProps.children }, + didSuspend + ); + suspenseState = createFiberFromFragment( + suspenseState, + didSuspend, + renderLanes, + null + ); + suspenseState.flags |= 2; + nextProps.return = workInProgress; + suspenseState.return = workInProgress; + nextProps.sibling = suspenseState; + workInProgress.child = nextProps; + 0 !== (workInProgress.mode & 1) && + reconcileChildFibers(workInProgress, current.child, null, renderLanes); + nextProps = workInProgress.child; + nextProps.memoizedState = mountSuspenseOffscreenState(renderLanes); + nextProps.childLanes = getRemainingWorkInPrimaryTree( + current, + didPrimaryChildrenDefer, + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; + return bailoutOffscreenComponent(null, nextProps); + } + pushPrimaryTreeSuspenseHandler(workInProgress); + if (shim$1()) + return ( + (didPrimaryChildrenDefer = shim$1().digest), + "" !== didPrimaryChildrenDefer && + ((nextProps = Error( + "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." + )), + (nextProps.stack = ""), + (nextProps.digest = didPrimaryChildrenDefer), + (didPrimaryChildrenDefer = { + value: nextProps, + source: null, + stack: null + }), + null === hydrationErrors + ? (hydrationErrors = [didPrimaryChildrenDefer]) + : hydrationErrors.push(didPrimaryChildrenDefer)), + retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ) + ); + didReceiveUpdate || + propagateParentContextChanges(current, workInProgress, renderLanes, !1); + didPrimaryChildrenDefer = 0 !== (renderLanes & current.childLanes); + if (didReceiveUpdate || didPrimaryChildrenDefer) { + if (null !== currentTreeHiddenStackCursor.current) + return retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ); + didPrimaryChildrenDefer = workInProgressRoot; + if ( + null !== didPrimaryChildrenDefer && + ((nextProps = getBumpedLaneForHydration( + didPrimaryChildrenDefer, + renderLanes + )), + 0 !== nextProps && nextProps !== suspenseState.retryLane) + ) + throw ( + ((suspenseState.retryLane = nextProps), + enqueueConcurrentRenderForLane(current, nextProps), + scheduleUpdateOnFiber(didPrimaryChildrenDefer, current, nextProps), + SelectiveHydrationException) + ); + shim$1() || renderDidSuspendDelayIfPossible(); + return retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ); + } + if (shim$1()) + return ( + (workInProgress.flags |= 192), + (workInProgress.child = current.child), + null + ); + current = mountSuspensePrimaryChildren(workInProgress, nextProps.children); + current.flags |= 134221824; + return current; +} +function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) { + fiber.lanes |= renderLanes; + var alternate = fiber.alternate; + null !== alternate && (alternate.lanes |= renderLanes); + scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot); +} +function findLastContentRow(firstChild) { + for (var lastContentRow = null; null !== firstChild; ) { + var currentRow = firstChild.alternate; + null !== currentRow && + null === findFirstSuspended(currentRow) && + (lastContentRow = firstChild); + firstChild = firstChild.sibling; + } + return lastContentRow; +} +function initSuspenseListRenderState( + workInProgress, + isBackwards, + tail, + lastContentRow, + tailMode, + treeForkCount +) { + var renderState = workInProgress.memoizedState; + null === renderState + ? (workInProgress.memoizedState = { + isBackwards: isBackwards, + rendering: null, + renderingStartTime: 0, + last: lastContentRow, + tail: tail, + tailMode: tailMode, + treeForkCount: treeForkCount + }) + : ((renderState.isBackwards = isBackwards), + (renderState.rendering = null), + (renderState.renderingStartTime = 0), + (renderState.last = lastContentRow), + (renderState.tail = tail), + (renderState.tailMode = tailMode), + (renderState.treeForkCount = treeForkCount)); +} +function reverseChildren(fiber) { + var row = fiber.child; + for (fiber.child = null; null !== row; ) { + var nextRow = row.sibling; + row.sibling = fiber.child; + fiber.child = row; + row = nextRow; + } +} +function updateSuspenseListComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps, + revealOrder = nextProps.revealOrder, + tailMode = nextProps.tail; + nextProps = nextProps.children; + var suspenseContext = suspenseStackCursor.current; + if (workInProgress.flags & 128) + return pushSuspenseListContext(workInProgress, suspenseContext), null; + var shouldForceFallback = 0 !== (suspenseContext & 2); + shouldForceFallback + ? ((suspenseContext = (suspenseContext & 1) | 2), + (workInProgress.flags |= 128)) + : (suspenseContext &= 1); + pushSuspenseListContext(workInProgress, suspenseContext); + "backwards" === revealOrder && null !== current + ? (reverseChildren(current), + reconcileChildren(current, workInProgress, nextProps, renderLanes), + reverseChildren(current)) + : reconcileChildren(current, workInProgress, nextProps, renderLanes); + if (!shouldForceFallback && null !== current && 0 !== (current.flags & 128)) + a: for (current = workInProgress.child; null !== current; ) { + if (13 === current.tag) + null !== current.memoizedState && + scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress); else if (19 === current.tag) scheduleSuspenseWorkOnFiber(current, renderLanes, workInProgress); else if (null !== current.child) { @@ -6222,29 +6529,23 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null; else switch (revealOrder) { - case "forwards": - renderLanes = workInProgress.child; - for (revealOrder = null; null !== renderLanes; ) - (current = renderLanes.alternate), - null !== current && - null === findFirstSuspended(current) && - (revealOrder = renderLanes), - (renderLanes = renderLanes.sibling); - renderLanes = revealOrder; + case "backwards": + renderLanes = findLastContentRow(workInProgress.child); null === renderLanes ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); + : ((revealOrder = renderLanes.sibling), + (renderLanes.sibling = null), + reverseChildren(workInProgress)); initSuspenseListRenderState( workInProgress, - !1, + !0, revealOrder, - renderLanes, + null, tailMode, 0 ); break; - case "backwards": case "unstable_legacy-backwards": renderLanes = null; revealOrder = workInProgress.child; @@ -6271,11 +6572,33 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { case "together": initSuspenseListRenderState(workInProgress, !1, null, null, void 0, 0); break; - default: + case "independent": workInProgress.memoizedState = null; + break; + default: + (renderLanes = findLastContentRow(workInProgress.child)), + null === renderLanes + ? ((revealOrder = workInProgress.child), + (workInProgress.child = null)) + : ((revealOrder = renderLanes.sibling), + (renderLanes.sibling = null)), + initSuspenseListRenderState( + workInProgress, + !1, + revealOrder, + renderLanes, + tailMode, + 0 + ); } return workInProgress.child; } +function updateContextProvider(current, workInProgress, renderLanes) { + var newProps = workInProgress.pendingProps; + pushProvider(workInProgress, workInProgress.type, newProps.value); + reconcileChildren(current, workInProgress, newProps.children, renderLanes); + return workInProgress.child; +} function resetSuspendedCurrentOnMountInLegacyMode(current, workInProgress) { 0 === (workInProgress.mode & 1) && null !== current && @@ -6352,15 +6675,22 @@ function attemptEarlyBailoutIfNoScheduledUpdate( ); break; case 13: - var state$72 = workInProgress.memoizedState; - if (null !== state$72) { - if (null !== state$72.dehydrated) + var state$76 = workInProgress.memoizedState; + if (null !== state$76) { + if (null !== state$76.dehydrated) return ( pushPrimaryTreeSuspenseHandler(workInProgress), (workInProgress.flags |= 128), null ); - if (0 !== (renderLanes & workInProgress.child.childLanes)) + state$76 = propagateParentContextChanges( + current, + workInProgress, + renderLanes, + !1 + ); + var primaryChildLanes = workInProgress.child.childLanes; + if (state$76 || 0 !== (renderLanes & primaryChildLanes)) return updateSuspenseComponent(current, workInProgress, renderLanes); pushPrimaryTreeSuspenseHandler(workInProgress); current = bailoutOnAlreadyFinishedWork( @@ -6373,18 +6703,24 @@ function attemptEarlyBailoutIfNoScheduledUpdate( pushPrimaryTreeSuspenseHandler(workInProgress); break; case 19: - var didSuspendBefore = 0 !== (current.flags & 128); - state$72 = 0 !== (renderLanes & workInProgress.childLanes); - state$72 || + if (workInProgress.flags & 128) + return updateSuspenseListComponent( + current, + workInProgress, + renderLanes + ); + primaryChildLanes = 0 !== (current.flags & 128); + state$76 = 0 !== (renderLanes & workInProgress.childLanes); + state$76 || (propagateParentContextChanges( current, workInProgress, renderLanes, !1 ), - (state$72 = 0 !== (renderLanes & workInProgress.childLanes))); - if (didSuspendBefore) { - if (state$72) + (state$76 = 0 !== (renderLanes & workInProgress.childLanes))); + if (primaryChildLanes) { + if (state$76) return updateSuspenseListComponent( current, workInProgress, @@ -6392,13 +6728,13 @@ function attemptEarlyBailoutIfNoScheduledUpdate( ); workInProgress.flags |= 128; } - didSuspendBefore = workInProgress.memoizedState; - null !== didSuspendBefore && - ((didSuspendBefore.rendering = null), - (didSuspendBefore.tail = null), - (didSuspendBefore.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (state$72) break; + primaryChildLanes = workInProgress.memoizedState; + null !== primaryChildLanes && + ((primaryChildLanes.rendering = null), + (primaryChildLanes.tail = null), + (primaryChildLanes.lastEffect = null)); + pushSuspenseListContext(workInProgress, suspenseStackCursor.current); + if (state$76) break; else return null; case 22: return ( @@ -6487,6 +6823,15 @@ function beginWork(current, workInProgress, renderLanes) { renderLanes ); break a; + } else if ($$typeof === REACT_CONTEXT_TYPE) { + workInProgress.tag = 10; + workInProgress.type = elementType; + workInProgress = updateContextProvider( + null, + workInProgress, + renderLanes + ); + break a; } } workInProgress = getComponentNameFromType(elementType) || elementType; @@ -6606,12 +6951,9 @@ function beginWork(current, workInProgress, renderLanes) { ); case 7: return ( - reconcileChildren( - current, - workInProgress, - workInProgress.pendingProps, - renderLanes - ), + (elementType = workInProgress.pendingProps), + markRef(current, workInProgress), + reconcileChildren(current, workInProgress, elementType, renderLanes), workInProgress.child ); case 8: @@ -6635,17 +6977,7 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress.child ); case 10: - return ( - (elementType = workInProgress.pendingProps), - pushProvider(workInProgress, workInProgress.type, elementType.value), - reconcileChildren( - current, - workInProgress, - elementType.children, - renderLanes - ), - workInProgress.child - ); + return updateContextProvider(current, workInProgress, renderLanes); case 9: return ( ($$typeof = workInProgress.type._context), @@ -6751,19 +7083,21 @@ function beginWork(current, workInProgress, renderLanes) { ); nextProps = 0 !== (renderLanes & current.childLanes); if (didReceiveUpdate || nextProps) { - $$typeof = workInProgressRoot; - if ( - null !== $$typeof && - ((nextProps = getBumpedLaneForHydration($$typeof, renderLanes)), - 0 !== nextProps && nextProps !== elementType.retryLane) - ) - throw ( - ((elementType.retryLane = nextProps), - enqueueConcurrentRenderForLane(current, nextProps), - scheduleUpdateOnFiber($$typeof, current, nextProps), - SelectiveHydrationException) - ); - renderDidSuspendDelayIfPossible(); + if (null === currentTreeHiddenStackCursor.current) { + $$typeof = workInProgressRoot; + if ( + null !== $$typeof && + ((nextProps = getBumpedLaneForHydration($$typeof, renderLanes)), + 0 !== nextProps && nextProps !== elementType.retryLane) + ) + throw ( + ((elementType.retryLane = nextProps), + enqueueConcurrentRenderForLane(current, nextProps), + scheduleUpdateOnFiber($$typeof, current, nextProps), + SelectiveHydrationException) + ); + renderDidSuspendDelayIfPossible(); + } workInProgress = retryActivityComponentWithoutHydrating( current, workInProgress, @@ -6771,7 +7105,7 @@ function beginWork(current, workInProgress, renderLanes) { ); } else (workInProgress = mountActivityChildren(workInProgress, $$typeof)), - (workInProgress.flags |= 4096); + (workInProgress.flags |= 134221824); } else (renderLanes = createWorkInProgress(current.child, { @@ -6840,6 +7174,30 @@ function beginWork(current, workInProgress, renderLanes) { ), workInProgress.child ); + case 30: + return ( + null === workInProgress.stateNode && + (workInProgress.stateNode = { + autoName: null, + paired: null, + clones: null, + ref: null + }), + (elementType = workInProgress.pendingProps), + null != elementType.name && + "auto" !== elementType.name && + (workInProgress.flags |= null === current ? 18882560 : 18874368), + null !== current && current.memoizedProps.name !== elementType.name + ? (workInProgress.flags |= 4194816) + : markRef(current, workInProgress), + reconcileChildren( + current, + workInProgress, + elementType.children, + renderLanes + ), + workInProgress.child + ); case 29: throw workInProgress.pendingProps; } @@ -6960,26 +7318,29 @@ function scheduleRetryEffect(workInProgress, retryQueue) { } function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { - case "hidden": - hasRenderedATailFallback = renderState.tail; - for (var lastTailNode = null; null !== hasRenderedATailFallback; ) - null !== hasRenderedATailFallback.alternate && - (lastTailNode = hasRenderedATailFallback), - (hasRenderedATailFallback = hasRenderedATailFallback.sibling); - null === lastTailNode - ? (renderState.tail = null) - : (lastTailNode.sibling = null); + case "visible": break; case "collapsed": - lastTailNode = renderState.tail; - for (var lastTailNode$84 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$84 = lastTailNode), - (lastTailNode = lastTailNode.sibling); - null === lastTailNode$84 + for ( + var tailNode = renderState.tail, lastTailNode = null; + null !== tailNode; + + ) + null !== tailNode.alternate && (lastTailNode = tailNode), + (tailNode = tailNode.sibling); + null === lastTailNode ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$84.sibling = null); + : (lastTailNode.sibling = null); + break; + default: + hasRenderedATailFallback = renderState.tail; + for (tailNode = null; null !== hasRenderedATailFallback; ) + null !== hasRenderedATailFallback.alternate && + (tailNode = hasRenderedATailFallback), + (hasRenderedATailFallback = hasRenderedATailFallback.sibling); + null === tailNode ? (renderState.tail = null) : (tailNode.sibling = null); } } function bubbleProperties(completedWork) { @@ -6989,19 +7350,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$85 = completedWork.child; null !== child$85; ) - (newChildLanes |= child$85.lanes | child$85.childLanes), - (subtreeFlags |= child$85.subtreeFlags & 65011712), - (subtreeFlags |= child$85.flags & 65011712), - (child$85.return = completedWork), - (child$85 = child$85.sibling); + for (var child$89 = completedWork.child; null !== child$89; ) + (newChildLanes |= child$89.lanes | child$89.childLanes), + (subtreeFlags |= child$89.subtreeFlags & 1206910976), + (subtreeFlags |= child$89.flags & 1206910976), + (child$89.return = completedWork), + (child$89 = child$89.sibling); else - for (child$85 = completedWork.child; null !== child$85; ) - (newChildLanes |= child$85.lanes | child$85.childLanes), - (subtreeFlags |= child$85.subtreeFlags), - (subtreeFlags |= child$85.flags), - (child$85.return = completedWork), - (child$85 = child$85.sibling); + for (child$89 = completedWork.child; null !== child$89; ) + (newChildLanes |= child$89.lanes | child$89.childLanes), + (subtreeFlags |= child$89.subtreeFlags), + (subtreeFlags |= child$89.flags), + (child$89.return = completedWork), + (child$89 = child$89.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -7023,66 +7384,63 @@ function completeWork(current, workInProgress, renderLanes) { case 1: return bubbleProperties(workInProgress), null; case 3: - return ( - (newProps = workInProgress.stateNode), - (renderLanes = null), - null !== current && (renderLanes = current.memoizedState.cache), - workInProgress.memoizedState.cache !== renderLanes && - (workInProgress.flags |= 2048), - popProvider(CacheContext), - popHostContainer(), - newProps.pendingContext && - ((newProps.context = newProps.pendingContext), - (newProps.pendingContext = null)), - (null !== current && null !== current.child) || - null === current || - (current.memoizedState.isDehydrated && - 0 === (workInProgress.flags & 256)) || - ((workInProgress.flags |= 1024), - upgradeHydrationErrorsToRecoverable()), - updateHostContainer(current, workInProgress), - bubbleProperties(workInProgress), - null - ); + newProps = workInProgress.stateNode; + var previousCache = null; + null !== current && (previousCache = current.memoizedState.cache); + workInProgress.memoizedState.cache !== previousCache && + (workInProgress.flags |= 2048); + popProvider(CacheContext); + popHostContainer(); + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)); + (null !== current && null !== current.child) || + null === current || + (current.memoizedState.isDehydrated && + 0 === (workInProgress.flags & 256)) || + ((workInProgress.flags |= 1024), upgradeHydrationErrorsToRecoverable()); + updateHostContainer(current, workInProgress); + bubbleProperties(workInProgress); + return null; case 26: case 27: case 5: popHostContext(workInProgress); - var type = workInProgress.type; + renderLanes = workInProgress.type; if (null !== current && null != workInProgress.stateNode) if ( - ((renderLanes = current.stateNode), - (type = current.memoizedProps), + ((previousCache = current.stateNode), + (renderLanes = current.memoizedProps), (current = doesRequireClone(current, workInProgress)) || - type !== newProps) + renderLanes !== newProps) ) { b: { - type = ReactNativePrivateInterface.diffAttributePayloads( - type, + renderLanes = reactPrivateInterface.diffAttributePayloads( + renderLanes, newProps, - renderLanes.canonical.viewConfig.validAttributes + previousCache.canonical.viewConfig.validAttributes ); - renderLanes.canonical.currentProps = newProps; - newProps = renderLanes.node; + previousCache.canonical.currentProps = newProps; + newProps = previousCache.node; if (current) newProps = - null !== type - ? cloneNodeWithNewChildrenAndProps(newProps, type) + null !== renderLanes + ? cloneNodeWithNewChildrenAndProps(newProps, renderLanes) : cloneNodeWithNewChildren(newProps); - else if (null !== type) - newProps = cloneNodeWithNewProps(newProps, type); + else if (null !== renderLanes) + newProps = cloneNodeWithNewProps(newProps, renderLanes); else { - newProps = renderLanes; + newProps = previousCache; break b; } - newProps = { node: newProps, canonical: renderLanes.canonical }; + newProps = { node: newProps, canonical: previousCache.canonical }; } - newProps === renderLanes - ? (workInProgress.stateNode = renderLanes) + newProps === previousCache + ? (workInProgress.stateNode = previousCache) : ((workInProgress.flags |= 8), (workInProgress.stateNode = newProps), current && appendAllChildren(newProps, workInProgress, !1, !1)); - } else workInProgress.stateNode = renderLanes; + } else workInProgress.stateNode = previousCache; else { if (!newProps) { if (null === workInProgress.stateNode) @@ -7090,27 +7448,27 @@ function completeWork(current, workInProgress, renderLanes) { "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); bubbleProperties(workInProgress); + workInProgress.subtreeFlags &= -33554433; return null; } current = rootInstanceStackCursor.current; - renderLanes = nextReactTag; - nextReactTag += 2; - type = getViewConfigForType(type); - var updatePayload = ReactNativePrivateInterface.createAttributePayload( + previousCache = allocateTag(); + renderLanes = getViewConfigForType(renderLanes); + var updatePayload = reactPrivateInterface.createAttributePayload( newProps, - type.validAttributes + renderLanes.validAttributes ); current = { node: createNode( - renderLanes, - type.uiViewClassName, + previousCache, + renderLanes.uiViewClassName, current.containerTag, updatePayload, workInProgress ), canonical: { - nativeTag: renderLanes, - viewConfig: type, + nativeTag: previousCache, + viewConfig: renderLanes, currentProps: newProps, internalInstanceHandle: workInProgress, publicInstance: null, @@ -7122,18 +7480,19 @@ function completeWork(current, workInProgress, renderLanes) { workInProgress.stateNode = current; } bubbleProperties(workInProgress); + workInProgress.subtreeFlags &= -33554433; workInProgress.flags &= -16777217; return null; case 6: if (current && null != workInProgress.stateNode) current.memoizedProps !== newProps ? ((current = rootInstanceStackCursor.current), - (renderLanes = contextStackCursor.current), + (previousCache = contextStackCursor.current), (workInProgress.flags |= 8), (workInProgress.stateNode = createTextInstance( newProps, current, - renderLanes, + previousCache, workInProgress ))) : (workInProgress.stateNode = current.stateNode); @@ -7143,12 +7502,12 @@ function completeWork(current, workInProgress, renderLanes) { "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); current = rootInstanceStackCursor.current; - renderLanes = contextStackCursor.current; + previousCache = contextStackCursor.current; workInProgress.flags |= 8; workInProgress.stateNode = createTextInstance( newProps, current, - renderLanes, + previousCache, workInProgress ); } @@ -7210,14 +7569,14 @@ function completeWork(current, workInProgress, renderLanes) { (workInProgress.memoizedState = null); workInProgress.flags |= 4; bubbleProperties(workInProgress); - type = !1; + previousCache = !1; } else - (type = upgradeHydrationErrorsToRecoverable()), + (previousCache = upgradeHydrationErrorsToRecoverable()), null !== current && null !== current.memoizedState && - (current.memoizedState.hydrationErrors = type), - (type = !0); - if (!type) { + (current.memoizedState.hydrationErrors = previousCache), + (previousCache = !0); + if (!previousCache) { if (workInProgress.flags & 256) return popSuspenseHandler(workInProgress), workInProgress; popSuspenseHandler(workInProgress); @@ -7230,17 +7589,17 @@ function completeWork(current, workInProgress, renderLanes) { newProps = null !== newProps; current = null !== current && null !== current.memoizedState; newProps && - ((renderLanes = workInProgress.child), - (type = null), - null !== renderLanes.alternate && - null !== renderLanes.alternate.memoizedState && - null !== renderLanes.alternate.memoizedState.cachePool && - (type = renderLanes.alternate.memoizedState.cachePool.pool), + ((previousCache = workInProgress.child), + (renderLanes = null), + null !== previousCache.alternate && + null !== previousCache.alternate.memoizedState && + null !== previousCache.alternate.memoizedState.cachePool && + (renderLanes = previousCache.alternate.memoizedState.cachePool.pool), (updatePayload = null), - null !== renderLanes.memoizedState && - null !== renderLanes.memoizedState.cachePool && - (updatePayload = renderLanes.memoizedState.cachePool.pool), - updatePayload !== type && (renderLanes.flags |= 2048)); + null !== previousCache.memoizedState && + null !== previousCache.memoizedState.cachePool && + (updatePayload = previousCache.memoizedState.cachePool.pool), + updatePayload !== renderLanes && (previousCache.flags |= 2048)); newProps !== current && newProps && (workInProgress.child.flags |= 8192); scheduleRetryEffect(workInProgress, workInProgress.updateQueue); bubbleProperties(workInProgress); @@ -7249,6 +7608,7 @@ function completeWork(current, workInProgress, renderLanes) { return ( popHostContainer(), updateHostContainer(current, workInProgress), + (workInProgress.flags |= 67108864), bubbleProperties(workInProgress), null ); @@ -7259,13 +7619,13 @@ function completeWork(current, workInProgress, renderLanes) { case 17: return bubbleProperties(workInProgress), null; case 19: - pop(suspenseStackCursor); - type = workInProgress.memoizedState; - if (null === type) return bubbleProperties(workInProgress), null; - newProps = 0 !== (workInProgress.flags & 128); - updatePayload = type.rendering; + popSuspenseListContext(workInProgress); + newProps = workInProgress.memoizedState; + if (null === newProps) return bubbleProperties(workInProgress), null; + previousCache = 0 !== (workInProgress.flags & 128); + updatePayload = newProps.rendering; if (null === updatePayload) - if (newProps) cutOffTailIfNeeded(type, !1); + if (previousCache) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || @@ -7275,7 +7635,7 @@ function completeWork(current, workInProgress, renderLanes) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { workInProgress.flags |= 128; - cutOffTailIfNeeded(type, !1); + cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); @@ -7284,66 +7644,86 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) resetWorkInProgress(newProps, current), (newProps = newProps.sibling); - push( - suspenseStackCursor, + pushSuspenseListContext( + workInProgress, (suspenseStackCursor.current & 1) | 2 ); return workInProgress.child; } current = current.sibling; } - null !== type.tail && + null !== newProps.tail && now() > workInProgressRootRenderTargetTime && ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), + (previousCache = !0), + cutOffTailIfNeeded(newProps, !1), (workInProgress.lanes = 4194304)); } else { - if (!newProps) + if (!previousCache) if ( ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( ((workInProgress.flags |= 128), - (newProps = !0), + (previousCache = !0), (current = current.updateQueue), (workInProgress.updateQueue = current), scheduleRetryEffect(workInProgress, current), - cutOffTailIfNeeded(type, !0), - null === type.tail && - "hidden" === type.tailMode && + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "collapsed" !== newProps.tailMode && + "visible" !== newProps.tailMode && !updatePayload.alternate) ) return bubbleProperties(workInProgress), null; } else - 2 * now() - type.renderingStartTime > + 2 * now() - newProps.renderingStartTime > workInProgressRootRenderTargetTime && 536870912 !== renderLanes && ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), + (previousCache = !0), + cutOffTailIfNeeded(newProps, !1), (workInProgress.lanes = 4194304)); - type.isBackwards + newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) - : ((current = type.last), + : ((current = newProps.last), null !== current ? (current.sibling = updatePayload) : (workInProgress.child = updatePayload), - (type.last = updatePayload)); + (newProps.last = updatePayload)); + } + if (null !== newProps.tail) { + current = newProps.tail; + a: { + for (renderLanes = current; null !== renderLanes; ) { + if (null !== renderLanes.alternate) { + renderLanes = !1; + break a; + } + renderLanes = renderLanes.sibling; + } + renderLanes = !0; + } + newProps.rendering = current; + newProps.tail = current.sibling; + newProps.renderingStartTime = now(); + current.sibling = null; + updatePayload = suspenseStackCursor.current; + updatePayload = previousCache + ? (updatePayload & 1) | 2 + : updatePayload & 1; + "visible" !== newProps.tailMode && + "collapsed" !== newProps.tailMode && + renderLanes + ? ((newProps = updatePayload), + push(suspenseHandlerStackCursor, workInProgress), + push(suspenseStackCursor, newProps), + null === shellBoundary && (shellBoundary = workInProgress)) + : pushSuspenseListContext(workInProgress, updatePayload); + return current; } - if (null !== type.tail) - return ( - (workInProgress = type.tail), - (type.rendering = workInProgress), - (type.tail = workInProgress.sibling), - (type.renderingStartTime = now()), - (workInProgress.sibling = null), - (current = suspenseStackCursor.current), - push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1), - workInProgress - ); bubbleProperties(workInProgress); return null; case 22: @@ -7370,11 +7750,11 @@ function completeWork(current, workInProgress, renderLanes) { null !== current.memoizedState && null !== current.memoizedState.cachePool && (newProps = current.memoizedState.cachePool.pool), - (renderLanes = null), + (previousCache = null), null !== workInProgress.memoizedState && null !== workInProgress.memoizedState.cachePool && - (renderLanes = workInProgress.memoizedState.cachePool.pool), - renderLanes !== newProps && (workInProgress.flags |= 2048), + (previousCache = workInProgress.memoizedState.cachePool.pool), + previousCache !== newProps && (workInProgress.flags |= 2048), null !== current && pop(resumedCache), null ); @@ -7391,7 +7771,11 @@ function completeWork(current, workInProgress, renderLanes) { case 25: return null; case 30: - return null; + return ( + (workInProgress.flags |= 33554432), + bubbleProperties(workInProgress), + null + ); case 29: return null; } @@ -7451,7 +7835,18 @@ function unwindWork(current, workInProgress) { ? ((workInProgress.flags = (current & -65537) | 128), workInProgress) : null; case 19: - return pop(suspenseStackCursor), null; + return ( + popSuspenseListContext(workInProgress), + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), + (current = workInProgress.memoizedState), + null !== current && + ((current.rendering = null), (current.tail = null)), + (workInProgress.flags |= 4), + workInProgress) + : null + ); case 4: return popHostContainer(), null; case 10: @@ -7497,7 +7892,7 @@ function unwindInterruptedWork(current, interruptedWork) { popSuspenseHandler(interruptedWork); break; case 19: - pop(suspenseStackCursor); + popSuspenseListContext(interruptedWork); break; case 10: popProvider(interruptedWork.type); @@ -7610,6 +8005,25 @@ function safelyAttachRef(current, nearestMountedAncestor) { var instanceToUse = getPublicInstance(current.stateNode); break; case 30: + var instance = current.stateNode, + name = getViewTransitionName(current.memoizedProps, instance); + if (null === instance.ref || instance.ref.name !== name) + instance.ref = createViewTransitionInstance(name); + instanceToUse = instance.ref; + break; + case 7: + if (null === current.stateNode) { + var fragmentInstance = new FragmentInstance(current); + traverseVisibleInstancesAndTextInstances( + current.child, + !1, + addFragmentHandleToFiber, + fragmentInstance, + void 0, + void 0 + ); + current.stateNode = fragmentInstance; + } instanceToUse = current.stateNode; break; default: @@ -7640,11 +8054,45 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$111) { - captureCommitPhaseError(current, nearestMountedAncestor, error$111); + } catch (error$117) { + captureCommitPhaseError(current, nearestMountedAncestor, error$117); } else ref.current = null; } +var viewTransitionMutationContext = !1; +function pushMutationContext() { + var prev = viewTransitionMutationContext; + viewTransitionMutationContext = !1; + return prev; +} +function commitFragmentInstanceInsertionEffects(fiber) { + for (var parent = fiber.return; null !== parent; ) { + isFragmentInstanceParent(parent) && + commitNewChildToFragmentInstance(fiber.stateNode, parent.stateNode); + if (isFragmentInstanceHostBoundary(parent)) break; + parent = parent.return; + } +} +function commitFragmentInstanceDeletionEffects(fiber) { + for (var parent = fiber.return; null !== parent; ) { + if (isFragmentInstanceParent(parent)) { + var fragmentInstance = parent.stateNode; + var childInstance = fiber.stateNode; + null != childInstance.canonical && + ((childInstance = getPublicInstance(childInstance)), + null != childInstance.reactFragments && + childInstance.reactFragments.delete(fragmentInstance)); + } + if (isFragmentInstanceHostBoundary(parent)) break; + parent = parent.return; + } +} +function isFragmentInstanceHostBoundary(fiber) { + return 5 === fiber.tag || 3 === fiber.tag || !1; +} +function isFragmentInstanceParent(fiber) { + return fiber && 7 === fiber.tag && null !== fiber.stateNode; +} function commitHostMount(finishedWork) { try { throw Error( @@ -7654,6 +8102,42 @@ function commitHostMount(finishedWork) { captureCommitPhaseError(finishedWork, finishedWork.return, error); } } +function commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances +) { + if (5 === finishedWork.tag) { + if ( + (5 === finishedWork.tag || + 27 === finishedWork.tag || + 6 === finishedWork.tag) && + null === finishedWork.alternate && + null !== parentFragmentInstances + ) + for (var i = 0; i < parentFragmentInstances.length; i++) + commitNewChildToFragmentInstance( + finishedWork.stateNode, + parentFragmentInstances[i] + ); + } else if ( + 4 !== finishedWork.tag && + ((finishedWork = finishedWork.child), null !== finishedWork) + ) + for ( + commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ), + finishedWork = finishedWork.sibling; + null !== finishedWork; + + ) + commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ), + (finishedWork = finishedWork.sibling); +} function commitHostPortalContainerChildren( portal, finishedWork, @@ -7666,84 +8150,313 @@ function commitHostPortalContainerChildren( captureCommitPhaseError(finishedWork, finishedWork.return, error); } } -var offscreenSubtreeIsHidden = !1, - offscreenSubtreeWasHidden = !1, - PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set, - nextEffect = null; -function commitBeforeMutationEffects(root, firstChild) { - for (nextEffect = firstChild; null !== nextEffect; ) - if ( - ((root = nextEffect), - (firstChild = root.child), - 0 !== (root.subtreeFlags & 1028) && null !== firstChild) +var shouldStartViewTransition = !1, + appearingViewTransitions = null; +function trackEnterViewTransitions(placement) { + if (30 === placement.tag || 0 !== (placement.subtreeFlags & 33554432)) + shouldStartViewTransition = !0; +} +var viewTransitionCancelableChildren = null; +function pushViewTransitionCancelableScope() { + var prevChildren = viewTransitionCancelableChildren; + viewTransitionCancelableChildren = null; + return prevChildren; +} +var viewTransitionHostInstanceIdx = 0; +function applyViewTransitionToHostInstances() { + viewTransitionHostInstanceIdx = 0; + return !1; +} +function commitAppearingPairViewTransitions(placement) { + if (0 !== (placement.subtreeFlags & 18874368)) + for (placement = placement.child; null !== placement; ) { + if (22 !== placement.tag || null === placement.memoizedState) + if ( + (commitAppearingPairViewTransitions(placement), + 30 === placement.tag && + 0 !== (placement.flags & 18874368) && + placement.stateNode.paired) + ) { + var props = placement.memoizedProps; + if (null == props.name || "auto" === props.name) + throw Error( + "Found a pair with an auto name. This is a bug in React." + ); + "none" !== getViewTransitionClassName(props.default, props.share) && + applyViewTransitionToHostInstances(); + } + placement = placement.sibling; + } +} +function commitEnterViewTransitions(placement, gesture) { + if (30 === placement.tag) { + var state = placement.stateNode, + props = placement.memoizedProps; + getViewTransitionName(props, state); + "none" !== + getViewTransitionClassName( + props.default, + state.paired ? props.share : props.enter ) - (firstChild.return = root), (nextEffect = firstChild); - else - for (; null !== nextEffect; ) { - root = nextEffect; - var current = root.alternate; - firstChild = root.flags; - switch (root.tag) { - case 0: - if ( - 0 !== (firstChild & 4) && - ((firstChild = root.updateQueue), - (firstChild = null !== firstChild ? firstChild.events : null), - null !== firstChild) - ) - for (var ii = 0; ii < firstChild.length; ii++) { - var _eventPayloads$ii = firstChild[ii]; - _eventPayloads$ii.ref.impl = _eventPayloads$ii.nextImpl; - } - break; - case 11: - case 15: - break; - case 1: - if (0 !== (firstChild & 1024) && null !== current) { - firstChild = void 0; - ii = root; - _eventPayloads$ii = current.memoizedProps; - current = current.memoizedState; - var instance = ii.stateNode; - try { - var resolvedPrevProps = resolveClassComponentProps( - ii.type, - _eventPayloads$ii - ); - firstChild = instance.getSnapshotBeforeUpdate( - resolvedPrevProps, - current - ); - instance.__reactInternalSnapshotBeforeUpdate = firstChild; - } catch (error) { - captureCommitPhaseError(ii, ii.return, error); + ? applyViewTransitionToHostInstances() && + (commitAppearingPairViewTransitions(placement), + state.paired || + gesture || + scheduleViewTransitionEvent(placement, props.onEnter)) + : commitAppearingPairViewTransitions(placement); + } else if (0 !== (placement.subtreeFlags & 33554432)) + for (placement = placement.child; null !== placement; ) + commitEnterViewTransitions(placement, gesture), + (placement = placement.sibling); + else commitAppearingPairViewTransitions(placement); +} +function commitDeletedPairViewTransitions(deletion) { + if ( + null !== appearingViewTransitions && + 0 !== appearingViewTransitions.size + ) { + var pairs = appearingViewTransitions; + if (0 !== (deletion.subtreeFlags & 18874368)) + for (deletion = deletion.child; null !== deletion; ) { + if (22 !== deletion.tag || null === deletion.memoizedState) { + if (30 === deletion.tag && 0 !== (deletion.flags & 18874368)) { + var props = deletion.memoizedProps, + name = props.name; + if (null != name && "auto" !== name) { + var pair = pairs.get(name); + if (void 0 !== pair) { + if ( + "none" !== + getViewTransitionClassName(props.default, props.share) && + applyViewTransitionToHostInstances() + ) { + var oldInstance = deletion.stateNode; + pair.paired = oldInstance; + oldInstance.paired = pair; + scheduleViewTransitionEvent(deletion, props.onShare); + } + pairs.delete(name); + if (0 === pairs.size) break; } } - break; - case 3: - break; - case 5: - case 26: - case 27: - case 6: - case 4: - case 17: - break; - default: - if (0 !== (firstChild & 1024)) - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); + } + commitDeletedPairViewTransitions(deletion); } - firstChild = root.sibling; - if (null !== firstChild) { - firstChild.return = root.return; - nextEffect = firstChild; - break; + deletion = deletion.sibling; + } + } +} +function commitExitViewTransitions(deletion) { + if (30 === deletion.tag) { + var props = deletion.memoizedProps, + name = getViewTransitionName(props, deletion.stateNode), + pair = + null !== appearingViewTransitions + ? appearingViewTransitions.get(name) + : void 0; + if ( + "none" !== + getViewTransitionClassName( + props.default, + void 0 !== pair ? props.share : props.exit + ) && + applyViewTransitionToHostInstances() + ) + if (void 0 !== pair) { + var oldInstance = deletion.stateNode; + pair.paired = oldInstance; + oldInstance.paired = pair; + appearingViewTransitions.delete(name); + scheduleViewTransitionEvent(deletion, props.onShare); + } else scheduleViewTransitionEvent(deletion, props.onExit); + null !== appearingViewTransitions && + commitDeletedPairViewTransitions(deletion); + } else if (0 !== (deletion.subtreeFlags & 33554432)) + for (deletion = deletion.child; null !== deletion; ) + commitExitViewTransitions(deletion), (deletion = deletion.sibling); + else + null !== appearingViewTransitions && + commitDeletedPairViewTransitions(deletion); +} +function commitNestedViewTransitions(changedParent) { + for (changedParent = changedParent.child; null !== changedParent; ) { + if (30 === changedParent.tag) { + var props = changedParent.memoizedProps, + name = getViewTransitionName(props, changedParent.stateNode); + props = getViewTransitionClassName(props.default, props.update); + changedParent.flags &= -5; + "none" !== props && + applyViewTransitionToHostInstances( + changedParent, + name, + props, + (changedParent.memoizedState = []) + ); + } else + 0 !== (changedParent.subtreeFlags & 33554432) && + commitNestedViewTransitions(changedParent); + changedParent = changedParent.sibling; + } +} +function restorePairedViewTransitions(parent) { + if (0 !== (parent.subtreeFlags & 18874368)) + for (parent = parent.child; null !== parent; ) { + if (22 !== parent.tag || null === parent.memoizedState) { + if (30 === parent.tag && 0 !== (parent.flags & 18874368)) { + var instance = parent.stateNode; + null !== instance.paired && (instance.paired = null); } - nextEffect = root.return; + restorePairedViewTransitions(parent); } + parent = parent.sibling; + } +} +function restoreEnterOrExitViewTransitions(fiber) { + if (30 === fiber.tag) + (fiber.stateNode.paired = null), restorePairedViewTransitions(fiber); + else if (0 !== (fiber.subtreeFlags & 33554432)) + for (fiber = fiber.child; null !== fiber; ) + restoreEnterOrExitViewTransitions(fiber), (fiber = fiber.sibling); + else restorePairedViewTransitions(fiber); +} +function measureNestedViewTransitions(changedParent, gesture) { + for (changedParent = changedParent.child; null !== changedParent; ) { + if (30 === changedParent.tag) { + var props = changedParent.memoizedProps, + state = changedParent.stateNode; + getViewTransitionName(props, state); + getViewTransitionClassName(props.default, props.update); + gesture + ? ((props = state.clones), + null !== props && props.map(measureClonedInstance)) + : (changedParent.memoizedState = null); + viewTransitionHostInstanceIdx = 0; + } else + 0 !== (changedParent.subtreeFlags & 33554432) && + measureNestedViewTransitions(changedParent, gesture); + changedParent = changedParent.sibling; + } +} +var offscreenSubtreeIsHidden = !1, + offscreenSubtreeWasHidden = !1, + PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set, + nextEffect = null, + viewTransitionContextChanged = !1; +function commitBeforeMutationEffects(root, firstChild, committedLanes) { + root = (committedLanes & 335544064) === committedLanes; + nextEffect = firstChild; + for (firstChild = root ? 9270 : 1024; null !== nextEffect; ) { + committedLanes = nextEffect; + if (root) { + var deletions = committedLanes.deletions; + if (null !== deletions) + for (var i = 0; i < deletions.length; i++) + root && commitExitViewTransitions(deletions[i]); + } + if (null === committedLanes.alternate && 0 !== (committedLanes.flags & 2)) + root && trackEnterViewTransitions(committedLanes), + commitBeforeMutationEffects_complete(root); + else { + if (22 === committedLanes.tag && 0 !== (committedLanes.mode & 1)) + if ( + ((deletions = committedLanes.alternate), + null !== committedLanes.memoizedState) + ) { + null !== deletions && + null === deletions.memoizedState && + root && + commitExitViewTransitions(deletions); + commitBeforeMutationEffects_complete(root); + continue; + } else if (null !== deletions && null !== deletions.memoizedState) { + root && trackEnterViewTransitions(committedLanes); + commitBeforeMutationEffects_complete(root); + continue; + } + deletions = committedLanes.child; + 0 !== (committedLanes.subtreeFlags & firstChild) && null !== deletions + ? ((deletions.return = committedLanes), (nextEffect = deletions)) + : (root && commitNestedViewTransitions(committedLanes), + commitBeforeMutationEffects_complete(root)); + } + } + appearingViewTransitions = null; +} +function commitBeforeMutationEffects_complete( + isViewTransitionEligible$jscomp$0 +) { + for (; null !== nextEffect; ) { + var fiber = nextEffect, + isViewTransitionEligible = isViewTransitionEligible$jscomp$0, + current = fiber.alternate, + flags = fiber.flags; + switch (fiber.tag) { + case 0: + case 11: + case 15: + break; + case 1: + if (0 !== (flags & 1024) && null !== current) { + isViewTransitionEligible = void 0; + flags = current.memoizedProps; + current = current.memoizedState; + var instance = fiber.stateNode; + try { + var resolvedPrevProps = resolveClassComponentProps( + fiber.type, + flags + ); + isViewTransitionEligible = instance.getSnapshotBeforeUpdate( + resolvedPrevProps, + current + ); + instance.__reactInternalSnapshotBeforeUpdate = + isViewTransitionEligible; + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); + } + } + break; + case 3: + break; + case 5: + case 26: + case 27: + case 6: + case 4: + case 17: + break; + case 30: + isViewTransitionEligible && + null !== current && + ((isViewTransitionEligible = getViewTransitionName( + current.memoizedProps, + current.stateNode + )), + (flags = fiber.memoizedProps), + (flags = getViewTransitionClassName(flags.default, flags.update)), + "none" !== flags && + applyViewTransitionToHostInstances( + current, + isViewTransitionEligible, + flags, + (current.memoizedState = []) + )); + break; + default: + if (0 !== (flags & 1024)) + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + current = fiber.sibling; + if (null !== current) { + current.return = fiber.return; + nextEffect = current; + break; + } + nextEffect = fiber.return; + } } function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { var flags = finishedWork.flags; @@ -7775,11 +8488,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$110) { + } catch (error$115) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$110 + error$115 ); } } @@ -7845,27 +8558,33 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { null !== finishedWork.memoizedState || offscreenSubtreeIsHidden), !flags) ) { - current = + var newOffscreenSubtreeWasHidden = (null !== current && null !== current.memoizedState) || offscreenSubtreeWasHidden; - prevProps = offscreenSubtreeIsHidden; - var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; + current = offscreenSubtreeIsHidden; + prevProps = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = flags; - (offscreenSubtreeWasHidden = current) && - !prevOffscreenSubtreeWasHidden - ? recursivelyTraverseReappearLayoutEffects( + (offscreenSubtreeWasHidden = newOffscreenSubtreeWasHidden) && + !prevProps + ? ((flags = 0), + 0 !== (finishedWork.subtreeFlags & 8772) && (flags |= 1), + recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - 0 !== (finishedWork.subtreeFlags & 8772) - ) + flags + )) : recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); - offscreenSubtreeIsHidden = prevProps; - offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; + offscreenSubtreeIsHidden = current; + offscreenSubtreeWasHidden = prevProps; } } else recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); break; case 30: + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + flags & 512 && safelyAttachRef(finishedWork, finishedWork.return); break; + case 7: + flags & 512 && safelyAttachRef(finishedWork, finishedWork.return); default: recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); } @@ -7909,8 +8628,11 @@ function commitDeletionEffectsOnFiber( case 27: case 5: offscreenSubtreeWasHidden || - safelyDetachRef(deletedFiber, nearestMountedAncestor); + safelyDetachRef(deletedFiber, nearestMountedAncestor), + commitFragmentInstanceDeletionEffects(deletedFiber); case 6: + 6 === deletedFiber.tag && + commitFragmentInstanceDeletionEffects(deletedFiber); recursivelyTraverseDeletionEffects( finishedRoot, nearestMountedAncestor, @@ -7935,8 +8657,7 @@ function commitDeletionEffectsOnFiber( case 11: case 14: case 15: - offscreenSubtreeWasHidden || - commitHookEffectListUnmount(2, deletedFiber, nearestMountedAncestor); + commitHookEffectListUnmount(2, deletedFiber, nearestMountedAncestor); offscreenSubtreeWasHidden || commitHookEffectListUnmount(4, deletedFiber, nearestMountedAncestor); recursivelyTraverseDeletionEffects( @@ -7986,6 +8707,23 @@ function commitDeletionEffectsOnFiber( deletedFiber ); break; + case 30: + safelyDetachRef(deletedFiber, nearestMountedAncestor); + recursivelyTraverseDeletionEffects( + finishedRoot, + nearestMountedAncestor, + deletedFiber + ); + break; + case 7: + offscreenSubtreeWasHidden || + safelyDetachRef(deletedFiber, nearestMountedAncestor); + recursivelyTraverseDeletionEffects( + finishedRoot, + nearestMountedAncestor, + deletedFiber + ); + break; default: recursivelyTraverseDeletionEffects( finishedRoot, @@ -8029,7 +8767,7 @@ function attachSuspenseRetryListeners(finishedWork, wakeables) { } }); } -function recursivelyTraverseMutationEffects(root, parentFiber) { +function recursivelyTraverseMutationEffects(root, parentFiber, lanes) { var deletions = parentFiber.deletions; if (null !== deletions) for (var i = 0; i < deletions.length; i++) { @@ -8041,10 +8779,10 @@ function recursivelyTraverseMutationEffects(root, parentFiber) { } if (parentFiber.subtreeFlags & 13886) for (parentFiber = parentFiber.child; null !== parentFiber; ) - commitMutationEffectsOnFiber(parentFiber, root), + commitMutationEffectsOnFiber(parentFiber, root, lanes), (parentFiber = parentFiber.sibling); } -function commitMutationEffectsOnFiber(finishedWork, root) { +function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var current = finishedWork.alternate, flags = finishedWork.flags; switch (finishedWork.tag) { @@ -8052,7 +8790,17 @@ function commitMutationEffectsOnFiber(finishedWork, root) { case 11: case 14: case 15: - recursivelyTraverseMutationEffects(root, finishedWork); + if ( + flags & 4 && + ((current = finishedWork.updateQueue), + (current = null !== current ? current.events : null), + null !== current) + ) + for (var ii = 0; ii < current.length; ii++) { + var _eventPayloads$ii2 = current[ii]; + _eventPayloads$ii2.ref.impl = _eventPayloads$ii2.nextImpl; + } + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 4 && (commitHookEffectListUnmount(3, finishedWork, finishedWork.return), @@ -8060,7 +8808,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) { commitHookEffectListUnmount(5, finishedWork, finishedWork.return)); break; case 1: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 512 && (offscreenSubtreeWasHidden || @@ -8079,7 +8827,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) { case 26: case 27: case 5: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 512 && (offscreenSubtreeWasHidden || @@ -8089,25 +8837,30 @@ function commitMutationEffectsOnFiber(finishedWork, root) { (finishedWork.alternate.stateNode = finishedWork.stateNode); break; case 6: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); break; case 3: - recursivelyTraverseMutationEffects(root, finishedWork); + viewTransitionMutationContext = !1; + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & 4) { flags = root.containerInfo; root = root.pendingChildren; try { - completeRoot(flags.containerTag, root); + completeRoot(flags.containerTag, root), + (viewTransitionMutationContext = !0); } catch (error) { captureCommitPhaseError(finishedWork, finishedWork.return, error); } } + viewTransitionMutationContext = !1; break; case 4: - recursivelyTraverseMutationEffects(root, finishedWork); + current = pushMutationContext(); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); + viewTransitionMutationContext = current; flags & 4 && commitHostPortalContainerChildren( finishedWork.stateNode, @@ -8116,11 +8869,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { ); break; case 12: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); break; case 31: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 4 && ((flags = finishedWork.updateQueue), @@ -8129,7 +8882,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) { attachSuspenseRetryListeners(finishedWork, flags))); break; case 13: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); finishedWork.child.flags & 8192 && ((root = null !== current && null !== current.memoizedState), @@ -8143,30 +8896,36 @@ function commitMutationEffectsOnFiber(finishedWork, root) { attachSuspenseRetryListeners(finishedWork, flags))); break; case 22: - var isHidden = null !== finishedWork.memoizedState, - wasHidden = null !== current && null !== current.memoizedState; + ii = null !== finishedWork.memoizedState; + _eventPayloads$ii2 = null !== current && null !== current.memoizedState; if (finishedWork.mode & 1) { var prevOffscreenSubtreeIsHidden = offscreenSubtreeIsHidden, prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; - offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || isHidden; - offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || ii; + offscreenSubtreeWasHidden = + prevOffscreenSubtreeWasHidden || _eventPayloads$ii2; + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; - } else recursivelyTraverseMutationEffects(root, finishedWork); + } else recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 8192 && ((root = finishedWork.stateNode), - (root._visibility = isHidden - ? root._visibility & -2 - : root._visibility | 1), - isHidden && - (null === current || - wasHidden || - offscreenSubtreeIsHidden || - offscreenSubtreeWasHidden || - (0 !== (finishedWork.mode & 1) && - recursivelyTraverseDisappearLayoutEffects(finishedWork)))); + (root._visibility = ii ? root._visibility & -2 : root._visibility | 1), + !ii || + null === current || + _eventPayloads$ii2 || + offscreenSubtreeIsHidden || + offscreenSubtreeWasHidden || + 0 === (finishedWork.mode & 1) || + ((root = _eventPayloads$ii2 || offscreenSubtreeWasHidden), + (lanes = offscreenSubtreeIsHidden), + (current = offscreenSubtreeWasHidden), + (offscreenSubtreeIsHidden = ii || offscreenSubtreeIsHidden), + (offscreenSubtreeWasHidden = root), + recursivelyTraverseDisappearLayoutEffects(finishedWork), + (offscreenSubtreeIsHidden = lanes), + (offscreenSubtreeWasHidden = current))); flags & 4 && ((flags = finishedWork.updateQueue), null !== flags && @@ -8176,7 +8935,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) { attachSuspenseRetryListeners(finishedWork, root)))); break; case 19: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 4 && ((flags = finishedWork.updateQueue), @@ -8185,19 +8944,135 @@ function commitMutationEffectsOnFiber(finishedWork, root) { attachSuspenseRetryListeners(finishedWork, flags))); break; case 30: + flags & 512 && + (offscreenSubtreeWasHidden || + null === current || + safelyDetachRef(current, current.return)); + flags = pushMutationContext(); + ii = (lanes & 335544064) === lanes; + _eventPayloads$ii2 = finishedWork.memoizedProps; + ii && + "none" !== + getViewTransitionClassName( + _eventPayloads$ii2.default, + _eventPayloads$ii2.update + ); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); + commitReconciliationEffects(finishedWork); + ii && + null !== current && + viewTransitionMutationContext && + (finishedWork.flags |= 4); + viewTransitionMutationContext = flags; break; case 21: break; + case 7: + flags & 512 && + (offscreenSubtreeWasHidden || + null === current || + safelyDetachRef(current, current.return)), + current && + null !== current.stateNode && + (current.stateNode._fragmentFiber = finishedWork); default: - recursivelyTraverseMutationEffects(root, finishedWork), + recursivelyTraverseMutationEffects(root, finishedWork, lanes), commitReconciliationEffects(finishedWork); } } function commitReconciliationEffects(finishedWork) { var flags = finishedWork.flags; - flags & 2 && (finishedWork.flags &= -3); + if (flags & 2) { + try { + for ( + var parentFragmentInstances = null, parent = finishedWork.return; + null !== parent; + + ) { + if (isFragmentInstanceParent(parent)) { + var fragmentInstance = parent.stateNode; + null === parentFragmentInstances + ? (parentFragmentInstances = [fragmentInstance]) + : parentFragmentInstances.push(fragmentInstance); + } + if (isFragmentInstanceHostBoundary(parent)) break; + parent = parent.return; + } + commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ); + } catch (error) { + captureCommitPhaseError(finishedWork, finishedWork.return, error); + } + finishedWork.flags &= -3; + } flags & 4096 && (finishedWork.flags &= -4097); } +function recursivelyTraverseAfterMutationEffects(root, parentFiber) { + if (parentFiber.subtreeFlags & 9270) + for (parentFiber = parentFiber.child; null !== parentFiber; ) + commitAfterMutationEffectsOnFiber(parentFiber, root), + (parentFiber = parentFiber.sibling); + else measureNestedViewTransitions(parentFiber, !1); +} +function commitAfterMutationEffectsOnFiber(finishedWork, root) { + var current = finishedWork.alternate; + if (null === current) commitEnterViewTransitions(finishedWork, !1); + else + switch (finishedWork.tag) { + case 3: + viewTransitionContextChanged = !1; + pushViewTransitionCancelableScope(); + recursivelyTraverseAfterMutationEffects(root, finishedWork); + viewTransitionCancelableChildren = null; + break; + case 5: + recursivelyTraverseAfterMutationEffects(root, finishedWork); + break; + case 4: + current = viewTransitionContextChanged; + viewTransitionContextChanged = !1; + recursivelyTraverseAfterMutationEffects(root, finishedWork); + viewTransitionContextChanged = current; + break; + case 22: + 0 !== (finishedWork.mode & 1) + ? null === finishedWork.memoizedState && + (null !== current.memoizedState + ? commitEnterViewTransitions(finishedWork, !1) + : recursivelyTraverseAfterMutationEffects(root, finishedWork)) + : recursivelyTraverseAfterMutationEffects(root, finishedWork); + break; + case 30: + var prevContextChanged$126 = viewTransitionContextChanged, + prevCancelableChildren = pushViewTransitionCancelableScope(); + viewTransitionContextChanged = !1; + recursivelyTraverseAfterMutationEffects(root, finishedWork); + viewTransitionContextChanged && (finishedWork.flags |= 4); + root = finishedWork.memoizedProps; + var state = finishedWork.stateNode; + getViewTransitionName(root, state); + getViewTransitionName(current.memoizedProps, state); + "none" !== getViewTransitionClassName(root.default, root.update) && + ((root = current.memoizedState), + (current.memoizedState = null), + (viewTransitionHostInstanceIdx = 0), + viewTransitionHostInstanceIdx !== (null === root ? 0 : root.length) && + (finishedWork.flags |= 32)); + null !== prevCancelableChildren && + (prevCancelableChildren.push.apply( + prevCancelableChildren, + viewTransitionCancelableChildren + ), + (viewTransitionCancelableChildren = prevCancelableChildren)); + viewTransitionContextChanged = + 0 !== (finishedWork.flags & 32) ? !0 : prevContextChanged$126; + break; + default: + recursivelyTraverseAfterMutationEffects(root, finishedWork); + } +} function recursivelyTraverseLayoutEffects(root, parentFiber) { if (parentFiber.subtreeFlags & 8772) for (parentFiber = parentFiber.child; null !== parentFiber; ) @@ -8226,9 +9101,17 @@ function recursivelyTraverseDisappearLayoutEffects(parentFiber) { ); recursivelyTraverseDisappearLayoutEffects(finishedWork); break; - case 27: + case 27: + case 5: + safelyDetachRef(finishedWork, finishedWork.return); + (5 !== finishedWork.tag && 27 !== finishedWork.tag) || + commitFragmentInstanceDeletionEffects(finishedWork); + recursivelyTraverseDisappearLayoutEffects(finishedWork); + break; + case 6: + commitFragmentInstanceDeletionEffects(finishedWork); + break; case 26: - case 5: safelyDetachRef(finishedWork, finishedWork.return); recursivelyTraverseDisappearLayoutEffects(finishedWork); break; @@ -8237,8 +9120,11 @@ function recursivelyTraverseDisappearLayoutEffects(parentFiber) { recursivelyTraverseDisappearLayoutEffects(finishedWork); break; case 30: + safelyDetachRef(finishedWork, finishedWork.return); recursivelyTraverseDisappearLayoutEffects(finishedWork); break; + case 7: + safelyDetachRef(finishedWork, finishedWork.return); default: recursivelyTraverseDisappearLayoutEffects(finishedWork); } @@ -8248,15 +9134,18 @@ function recursivelyTraverseDisappearLayoutEffects(parentFiber) { function recursivelyTraverseReappearLayoutEffects( finishedRoot$jscomp$0, parentFiber, - includeWorkInProgressEffects + layoutEffectTraversalFlags ) { - includeWorkInProgressEffects = - includeWorkInProgressEffects && 0 !== (parentFiber.subtreeFlags & 8772); + layoutEffectTraversalFlags = + 0 !== (parentFiber.subtreeFlags & 8772) + ? layoutEffectTraversalFlags + : layoutEffectTraversalFlags & -2; for (parentFiber = parentFiber.child; null !== parentFiber; ) { var current = parentFiber.alternate, finishedRoot = finishedRoot$jscomp$0, finishedWork = parentFiber, - flags = finishedWork.flags; + flags = finishedWork.flags, + includeWorkInProgressEffects = 0 !== (layoutEffectTraversalFlags & 1); switch (finishedWork.tag) { case 0: case 11: @@ -8264,7 +9153,7 @@ function recursivelyTraverseReappearLayoutEffects( recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); commitHookEffectListMount(4, finishedWork); break; @@ -8272,7 +9161,7 @@ function recursivelyTraverseReappearLayoutEffects( recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); current = finishedWork; finishedRoot = current.stateNode; @@ -8305,12 +9194,28 @@ function recursivelyTraverseReappearLayoutEffects( safelyAttachRef(finishedWork, finishedWork.return); break; case 27: - case 26: case 5: + (5 !== finishedWork.tag && 27 !== finishedWork.tag) || + commitFragmentInstanceInsertionEffects(finishedWork); recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags + ); + includeWorkInProgressEffects && + null === current && + flags & 4 && + commitHostMount(finishedWork); + safelyAttachRef(finishedWork, finishedWork.return); + break; + case 6: + commitFragmentInstanceInsertionEffects(finishedWork); + break; + case 26: + recursivelyTraverseReappearLayoutEffects( + finishedRoot, + finishedWork, + layoutEffectTraversalFlags ); includeWorkInProgressEffects && null === current && @@ -8322,21 +9227,21 @@ function recursivelyTraverseReappearLayoutEffects( recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); break; case 31: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); break; case 13: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); break; case 22: @@ -8344,17 +9249,25 @@ function recursivelyTraverseReappearLayoutEffects( recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); safelyAttachRef(finishedWork, finishedWork.return); break; case 30: + recursivelyTraverseReappearLayoutEffects( + finishedRoot, + finishedWork, + layoutEffectTraversalFlags + ); + safelyAttachRef(finishedWork, finishedWork.return); break; + case 7: + safelyAttachRef(finishedWork, finishedWork.return); default: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); } parentFiber = parentFiber.sibling; @@ -8388,7 +9301,10 @@ function recursivelyTraversePassiveMountEffects( committedLanes, committedTransitions ) { - if (parentFiber.subtreeFlags & 10256) + if ( + parentFiber.subtreeFlags & + ((committedLanes & 335544064) === committedLanes ? 10262 : 10256) + ) for (parentFiber = parentFiber.child; null !== parentFiber; ) commitPassiveMountOnFiber( root, @@ -8404,6 +9320,13 @@ function commitPassiveMountOnFiber( committedLanes, committedTransitions ) { + var isViewTransitionEligible = + (committedLanes & 335544064) === committedLanes; + isViewTransitionEligible && + null === finishedWork.alternate && + null !== finishedWork.return && + null !== finishedWork.return.alternate && + restoreEnterOrExitViewTransitions(finishedWork); var flags = finishedWork.flags; switch (finishedWork.tag) { case 0: @@ -8494,40 +9417,48 @@ function commitPassiveMountOnFiber( _finishedWork$memoize2 = finishedWork.stateNode; id = finishedWork.alternate; null !== finishedWork.memoizedState - ? _finishedWork$memoize2._visibility & 2 - ? recursivelyTraversePassiveMountEffects( - finishedRoot, - finishedWork, - committedLanes, - committedTransitions - ) - : finishedWork.mode & 1 - ? recursivelyTraverseAtomicPassiveEffects( + ? (isViewTransitionEligible && + null !== id && + null === id.memoizedState && + restoreEnterOrExitViewTransitions(id), + _finishedWork$memoize2._visibility & 2 + ? recursivelyTraversePassiveMountEffects( finishedRoot, - finishedWork + finishedWork, + committedLanes, + committedTransitions ) - : ((_finishedWork$memoize2._visibility |= 2), - recursivelyTraversePassiveMountEffects( + : finishedWork.mode & 1 + ? recursivelyTraverseAtomicPassiveEffects( + finishedRoot, + finishedWork + ) + : ((_finishedWork$memoize2._visibility |= 2), + recursivelyTraversePassiveMountEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions + ))) + : (isViewTransitionEligible && + null !== id && + null !== id.memoizedState && + restoreEnterOrExitViewTransitions(finishedWork), + _finishedWork$memoize2._visibility & 2 + ? recursivelyTraversePassiveMountEffects( finishedRoot, finishedWork, committedLanes, committedTransitions - )) - : _finishedWork$memoize2._visibility & 2 - ? recursivelyTraversePassiveMountEffects( - finishedRoot, - finishedWork, - committedLanes, - committedTransitions - ) - : ((_finishedWork$memoize2._visibility |= 2), - recursivelyTraverseReconnectPassiveEffects( - finishedRoot, - finishedWork, - committedLanes, - committedTransitions, - 0 !== (finishedWork.subtreeFlags & 10256) || !1 - )); + ) + : ((_finishedWork$memoize2._visibility |= 2), + recursivelyTraverseReconnectPassiveEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions, + 0 !== (finishedWork.subtreeFlags & 10256) || !1 + ))); flags & 2048 && commitOffscreenPassiveMountEffects(id, finishedWork); break; case 24: @@ -8540,6 +9471,14 @@ function commitPassiveMountOnFiber( flags & 2048 && commitCachePassiveMountEffect(finishedWork.alternate, finishedWork); break; + case 30: + recursivelyTraversePassiveMountEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions + ); + break; default: recursivelyTraversePassiveMountEffects( finishedRoot, @@ -8705,6 +9644,20 @@ function accumulateSuspenseyCommitOnFiber(fiber) { : recursivelyAccumulateSuspenseyCommit(fiber); } break; + case 30: + if ( + 0 !== (fiber.flags & suspenseyCommitFlag) && + ((current = fiber.memoizedProps.name), + null != current && "auto" !== current) + ) { + var state = fiber.stateNode; + state.paired = null; + null === appearingViewTransitions && + (appearingViewTransitions = new Map()); + appearingViewTransitions.set(current, state); + } + recursivelyAccumulateSuspenseyCommit(fiber); + break; default: recursivelyAccumulateSuspenseyCommit(fiber); } @@ -8896,6 +9849,9 @@ var DefaultAsyncDispatcher = { pendingEffectsRemainingLanes = 0, pendingPassiveTransitions = null, pendingRecoverableErrors = null, + pendingViewTransition = null, + pendingViewTransitionEvents = null, + pendingTransitionTypes = null, nestedUpdateCount = 0, rootWithNestedUpdates = null; function requestUpdateLane(fiber) { @@ -8922,6 +9878,19 @@ function requestDeferredLane() { null !== lane && (lane.flags |= 32); return workInProgressDeferredLane; } +function scheduleViewTransitionEvent(fiber, callback) { + if (null != callback) { + var state = fiber.stateNode, + instance = state.ref; + null === instance && + (instance = state.ref = + createViewTransitionInstance( + getViewTransitionName(fiber.memoizedProps, state) + )); + null === pendingViewTransitionEvents && (pendingViewTransitionEvents = []); + pendingViewTransitionEvents.push(callback.bind(null, instance)); + } +} function scheduleUpdateOnFiber(root, fiber, lane) { if ( (root === workInProgressRoot && @@ -9005,7 +9974,10 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { JSCompiler_inline_result, !1 ); - if (2 !== JSCompiler_inline_result) { + if ( + 2 !== JSCompiler_inline_result && + 6 !== JSCompiler_inline_result + ) { if (workInProgressRootDidAttachPingListener) { root.errorRecoveryDisabledLanes |= renderWasConcurrent; workInProgressRootInterleavedUpdatedLanes |= @@ -9042,7 +10014,8 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { case 1: throw Error("Root did not complete. This is a bug in React."); case 4: - if ((lanes & 4194048) !== lanes) break; + if ((lanes & 4194048) !== lanes && (lanes & 62914560) !== lanes) + break; case 6: markRootSuspended( shouldTimeSlice, @@ -9075,7 +10048,7 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { if (0 !== getNextLanes(shouldTimeSlice, 0, !0)) break a; pendingEffectsLanes = lanes; shouldTimeSlice.timeoutHandle = scheduleTimeout( - commitRootWhenReady.bind( + completeRootWhenReady.bind( null, shouldTimeSlice, forceSync, @@ -9096,7 +10069,7 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { ); break a; } - commitRootWhenReady( + completeRootWhenReady( shouldTimeSlice, forceSync, workInProgressRootRecoverableErrors, @@ -9105,7 +10078,9 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { lanes, workInProgressDeferredLane, workInProgressRootInterleavedUpdatedLanes, - workInProgressSuspendedRetryLanes + workInProgressSuspendedRetryLanes, + workInProgressRootDidSkipSuspendedSiblings, + renderWasConcurrent ); } } @@ -9113,7 +10088,7 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { } while (1); ensureRootIsScheduled(root$jscomp$0); } -function commitRootWhenReady( +function completeRootWhenReady( root, finishedWork, recoverableErrors, @@ -9125,25 +10100,53 @@ function commitRootWhenReady( suspendedRetryLanes ) { root.timeoutHandle = -1; - var subtreeFlags = finishedWork.subtreeFlags; - if (subtreeFlags & 8192 || 16785408 === (subtreeFlags & 16785408)) - accumulateSuspenseyCommitOnFiber(finishedWork), + didIncludeRenderPhaseUpdate = finishedWork.subtreeFlags; + var isViewTransitionEligible = (lanes & 335544064) === lanes, + suspendedState = null; + if ( + isViewTransitionEligible || + didIncludeRenderPhaseUpdate & 8192 || + 16785408 === (didIncludeRenderPhaseUpdate & 16785408) + ) + (appearingViewTransitions = suspendedState = null), + accumulateSuspenseyCommitOnFiber(finishedWork), + isViewTransitionEligible && + null != fabricSuspendOnActiveViewTransition && + fabricSuspendOnActiveViewTransition(), (lanes & 62914560) === lanes ? globalMostRecentFallbackTime - now() : (lanes & 4194048) === lanes ? globalMostRecentTransitionTime - now() : 0; - commitRoot( - root, - finishedWork, - lanes, - recoverableErrors, - transitions, - didIncludeRenderPhaseUpdate, - spawnedLane, - updatedLanes, - suspendedRetryLanes - ); + didIncludeRenderPhaseUpdate = suspendedState; + root.cancelPendingCommit = null; + do flushPendingEffects(); + while (0 !== pendingEffectsStatus); + if (0 !== (executionContext & 6)) + throw Error("Should not already be working."); + if (null !== finishedWork) { + if (finishedWork === root.current) + throw Error( + "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." + ); + root === workInProgressRoot && + ((workInProgress = workInProgressRoot = null), + (workInProgressRootRenderLanes = 0)); + pendingFinishedWork = finishedWork; + pendingEffectsRoot = root; + pendingEffectsLanes = lanes; + pendingPassiveTransitions = transitions; + pendingRecoverableErrors = recoverableErrors; + commitRoot( + root, + finishedWork, + lanes, + spawnedLane, + updatedLanes, + suspendedRetryLanes, + didIncludeRenderPhaseUpdate + ); + } } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { @@ -9185,6 +10188,7 @@ function markRootSuspended( spawnedLane, didAttemptEntireTree ) { + suspendedLanes = getEntangledLanes(root, suspendedLanes); suspendedLanes &= ~workInProgressRootPingedLanes; suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes; root.suspendedLanes |= suspendedLanes; @@ -9244,20 +10248,7 @@ function prepareFreshStack(root, lanes) { workInProgressRootRecoverableErrors = workInProgressRootConcurrentErrors = null; workInProgressRootDidIncludeRecursiveRenderUpdate = !1; - 0 !== (lanes & 8) && (lanes |= lanes & 32); - var allEntangledLanes = root.entangledLanes; - if (0 !== allEntangledLanes) - for ( - root = root.entanglements, allEntangledLanes &= lanes; - 0 < allEntangledLanes; - - ) { - var index$6 = 31 - clz32(allEntangledLanes), - lane = 1 << index$6; - lanes |= root[index$6]; - allEntangledLanes &= ~lane; - } - entangledRenderLanes = lanes; + entangledRenderLanes = getEntangledLanes(root, lanes); finishQueueingConcurrentUpdates(); return timeoutHandle; } @@ -9359,8 +10350,8 @@ function renderRootSync(root, lanes, shouldYieldForPrerendering) { workLoopSync(); exitStatus = workInProgressRootExitStatus; break; - } catch (thrownValue$124) { - handleThrow(root, thrownValue$124); + } catch (thrownValue$135) { + handleThrow(root, thrownValue$135); } while (1); lanes && root.shellSuspendCounter++; @@ -9475,8 +10466,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrentByScheduler(); break; - } catch (thrownValue$126) { - handleThrow(root, thrownValue$126); + } catch (thrownValue$137) { + handleThrow(root, thrownValue$137); } while (1); lastContextDependency = currentlyRenderingFiber$1 = null; @@ -9650,78 +10641,79 @@ function commitRoot( root, finishedWork, lanes, - recoverableErrors, - transitions, - didIncludeRenderPhaseUpdate, spawnedLane, updatedLanes, - suspendedRetryLanes + suspendedRetryLanes, + suspendedState ) { - root.cancelPendingCommit = null; - do flushPendingEffects(); - while (0 !== pendingEffectsStatus); - if (0 !== (executionContext & 6)) - throw Error("Should not already be working."); - if (null !== finishedWork) { - if (finishedWork === root.current) - throw Error( - "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." - ); - didIncludeRenderPhaseUpdate = finishedWork.lanes | finishedWork.childLanes; - didIncludeRenderPhaseUpdate |= concurrentlyUpdatedLanes; - markRootFinished( - root, - lanes, - didIncludeRenderPhaseUpdate, - spawnedLane, - updatedLanes, - suspendedRetryLanes - ); - root === workInProgressRoot && - ((workInProgress = workInProgressRoot = null), - (workInProgressRootRenderLanes = 0)); - pendingFinishedWork = finishedWork; - pendingEffectsRoot = root; - pendingEffectsLanes = lanes; - pendingEffectsRemainingLanes = didIncludeRenderPhaseUpdate; - pendingPassiveTransitions = transitions; - pendingRecoverableErrors = recoverableErrors; - 0 !== (finishedWork.subtreeFlags & 10256) || - 0 !== (finishedWork.flags & 10256) - ? ((root.callbackNode = null), - (root.callbackPriority = 0), - scheduleCallback(NormalPriority$1, function () { - flushPassiveEffects(); - return null; - })) - : ((root.callbackNode = null), (root.callbackPriority = 0)); - recoverableErrors = 0 !== (finishedWork.flags & 13878); - if (0 !== (finishedWork.subtreeFlags & 13878) || recoverableErrors) { - recoverableErrors = ReactSharedInternals.T; - ReactSharedInternals.T = null; - transitions = currentUpdatePriority; - currentUpdatePriority = 2; - spawnedLane = executionContext; - executionContext |= 4; - try { - commitBeforeMutationEffects(root, finishedWork, lanes); - } finally { - (executionContext = spawnedLane), - (currentUpdatePriority = transitions), - (ReactSharedInternals.T = recoverableErrors); - } + var remainingLanes = finishedWork.lanes | finishedWork.childLanes; + pendingEffectsRemainingLanes = remainingLanes; + remainingLanes |= concurrentlyUpdatedLanes; + markRootFinished( + root, + lanes, + remainingLanes, + spawnedLane, + updatedLanes, + suspendedRetryLanes + ); + pendingViewTransitionEvents = null; + (lanes & 335544064) === lanes + ? ((pendingTransitionTypes = claimQueuedTransitionTypes(root)), + (spawnedLane = 10262)) + : ((pendingTransitionTypes = null), (spawnedLane = 10256)); + 0 !== (finishedWork.subtreeFlags & spawnedLane) || + 0 !== (finishedWork.flags & spawnedLane) + ? ((root.callbackNode = null), + (root.callbackPriority = 0), + scheduleCallback(NormalPriority$1, function () { + flushPassiveEffects(); + return null; + })) + : ((root.callbackNode = null), (root.callbackPriority = 0)); + shouldStartViewTransition = !1; + spawnedLane = 0 !== (finishedWork.flags & 13878); + if (0 !== (finishedWork.subtreeFlags & 13878) || spawnedLane) { + spawnedLane = ReactSharedInternals.T; + ReactSharedInternals.T = null; + updatedLanes = currentUpdatePriority; + currentUpdatePriority = 2; + suspendedRetryLanes = executionContext; + executionContext |= 4; + try { + commitBeforeMutationEffects(root, finishedWork, lanes); + } finally { + (executionContext = suspendedRetryLanes), + (currentUpdatePriority = updatedLanes), + (ReactSharedInternals.T = spawnedLane); } - pendingEffectsStatus = 1; - flushMutationEffects(); - flushLayoutEffects(); - flushSpawnedWork(); } + pendingEffectsStatus = 1; + shouldStartViewTransition + ? (pendingViewTransition = startViewTransition( + suspendedState, + root.containerInfo, + pendingTransitionTypes, + flushMutationEffects, + flushLayoutEffects, + flushAfterMutationEffects, + flushSpawnedWork, + flushPassiveEffects + )) + : (flushMutationEffects(), flushLayoutEffects(), flushSpawnedWork()); +} +function flushAfterMutationEffects() { + 3 === pendingEffectsStatus && + ((pendingEffectsStatus = 0), + commitAfterMutationEffectsOnFiber(pendingFinishedWork, pendingEffectsRoot), + (pendingEffectsStatus = 4)); } function flushMutationEffects() { if (1 === pendingEffectsStatus) { pendingEffectsStatus = 0; var root = pendingEffectsRoot, finishedWork = pendingFinishedWork, + lanes = pendingEffectsLanes, rootMutationHasEffect = 0 !== (finishedWork.flags & 13878); if (0 !== (finishedWork.subtreeFlags & 13878) || rootMutationHasEffect) { rootMutationHasEffect = ReactSharedInternals.T; @@ -9731,7 +10723,7 @@ function flushMutationEffects() { var prevExecutionContext = executionContext; executionContext |= 4; try { - commitMutationEffectsOnFiber(finishedWork, root); + commitMutationEffectsOnFiber(finishedWork, root, lanes); } finally { (executionContext = prevExecutionContext), (currentUpdatePriority = previousPriority), @@ -9769,19 +10761,22 @@ function flushLayoutEffects() { function flushSpawnedWork() { if (4 === pendingEffectsStatus || 3 === pendingEffectsStatus) { pendingEffectsStatus = 0; + var committedViewTransition = pendingViewTransition; + pendingViewTransition = null; requestPaint(); var root = pendingEffectsRoot, finishedWork = pendingFinishedWork, lanes = pendingEffectsLanes, - recoverableErrors = pendingRecoverableErrors; - 0 !== (finishedWork.subtreeFlags & 10256) || - 0 !== (finishedWork.flags & 10256) + recoverableErrors = pendingRecoverableErrors, + passiveSubtreeMask = (lanes & 335544064) === lanes ? 10262 : 10256; + 0 !== (finishedWork.subtreeFlags & passiveSubtreeMask) || + 0 !== (finishedWork.flags & passiveSubtreeMask) ? (pendingEffectsStatus = 5) : ((pendingEffectsStatus = 0), (pendingFinishedWork = pendingEffectsRoot = null), releaseRootPooledCache(root, root.pendingLanes)); - var remainingLanes = root.pendingLanes; - 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); + passiveSubtreeMask = root.pendingLanes; + 0 === passiveSubtreeMask && (legacyErrorBoundariesThatAlreadyFailed = null); lanesToEventPriority(lanes); finishedWork = finishedWork.stateNode; if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) @@ -9795,7 +10790,7 @@ function flushSpawnedWork() { } catch (err) {} if (null !== recoverableErrors) { finishedWork = ReactSharedInternals.T; - remainingLanes = currentUpdatePriority; + passiveSubtreeMask = currentUpdatePriority; currentUpdatePriority = 2; ReactSharedInternals.T = null; try { @@ -9811,17 +10806,36 @@ function flushSpawnedWork() { } } finally { (ReactSharedInternals.T = finishedWork), - (currentUpdatePriority = remainingLanes); + (currentUpdatePriority = passiveSubtreeMask); } } + recoverableErrors = pendingViewTransitionEvents; + onRecoverableError = pendingTransitionTypes; + pendingTransitionTypes = null; + if ( + null !== recoverableErrors && + ((pendingViewTransitionEvents = null), + null === onRecoverableError && (onRecoverableError = []), + null !== committedViewTransition) + ) + for ( + recoverableError = 0; + recoverableError < recoverableErrors.length; + recoverableError++ + ) + (finishedWork = (0, recoverableErrors[recoverableError])( + onRecoverableError + )), + void 0 !== finishedWork && + committedViewTransition.finished.finally(finishedWork); 0 !== (pendingEffectsLanes & 3) && 0 !== root.tag && flushPendingEffects(); ensureRootIsScheduled(root); - remainingLanes = root.pendingLanes; - 0 !== (lanes & 261930) && 0 !== (remainingLanes & 42) + passiveSubtreeMask = root.pendingLanes; + 0 !== (lanes & 261930) && 0 !== (passiveSubtreeMask & 42) ? root === rootWithNestedUpdates ? nestedUpdateCount++ : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) - : (nestedUpdateCount = 0); + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = null)); flushSyncWorkAcrossRoots_impl(0, !1); } } @@ -9832,6 +10846,7 @@ function releaseRootPooledCache(root, remainingLanes) { ((root.pooledCache = null), releaseCache(remainingLanes))); } function flushPendingEffects() { + null !== pendingViewTransition && (pendingViewTransition = null); flushMutationEffects(); flushLayoutEffects(); flushSpawnedWork(); @@ -9956,7 +10971,9 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { (workInProgressRootRenderLanes & 62914560) === workInProgressRootRenderLanes && 300 > now() - globalMostRecentFallbackTime) - ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) + ? 0 === (executionContext & 2) + ? prepareFreshStack(root, 0) + : (workInProgressRootPingedLanes |= pingedLanes) : (workInProgressRootPingedLanes |= pingedLanes), workInProgressSuspendedRetryLanes === workInProgressRootRenderLanes && (workInProgressSuspendedRetryLanes = 0)); @@ -10052,7 +11069,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.flags = 0), (workInProgress.subtreeFlags = 0), (workInProgress.deletions = null)); - workInProgress.flags = current.flags & 65011712; + workInProgress.flags = current.flags & 1206910976; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -10071,7 +11088,7 @@ function createWorkInProgress(current, pendingProps) { return workInProgress; } function resetWorkInProgress(workInProgress, renderLanes) { - workInProgress.flags &= 65011714; + workInProgress.flags &= 1206910978; var current = workInProgress.alternate; null === current ? ((workInProgress.childLanes = 0), @@ -10112,10 +11129,10 @@ function createFiberFromTypeAndProps( ) { var fiberTag = 0; owner = type; - if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); - else if ("string" === typeof type) fiberTag = 5; + if ("function" === typeof owner) shouldConstruct(owner) && (fiberTag = 1); + else if ("string" === typeof owner) fiberTag = 5; else - a: switch (type) { + a: switch (owner) { case REACT_ACTIVITY_TYPE: return ( (type = createFiberImplClass(31, pendingProps, key, mode)), @@ -10151,9 +11168,24 @@ function createFiberFromTypeAndProps( (type.lanes = lanes), type ); + case REACT_LEGACY_HIDDEN_TYPE: + case REACT_VIEW_TRANSITION_TYPE: + return ( + (type = mode | 32), + (type = createFiberImplClass(30, pendingProps, key, type)), + (type.elementType = REACT_VIEW_TRANSITION_TYPE), + (type.lanes = lanes), + (type.stateNode = { + autoName: null, + paired: null, + clones: null, + ref: null + }), + type + ); default: - if ("object" === typeof type && null !== type) - switch (type.$$typeof) { + if ("object" === typeof owner && null !== owner) + switch (owner.$$typeof) { case REACT_CONTEXT_TYPE: fiberTag = 10; break a; @@ -10250,6 +11282,7 @@ function FiberRootNode( this.pooledCache = null; this.pooledCacheLanes = 0; this.formState = formState; + this.transitionTypes = null; this.incompleteTransitions = new Map(); } function createPortal$1(children, containerInfo, implementation) { @@ -10257,7 +11290,12 @@ function createPortal$1(children, containerInfo, implementation) { 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; return { $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, + key: + null == key + ? null + : key === REACT_OPTIMISTIC_KEY + ? REACT_OPTIMISTIC_KEY + : "" + key, children: children, containerInfo: containerInfo, implementation: implementation @@ -10303,30 +11341,84 @@ function shim() { "The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue." ); } -var _nativeFabricUIManage = nativeFabricUIManager, - createNode = _nativeFabricUIManage.createNode, - cloneNodeWithNewChildren = _nativeFabricUIManage.cloneNodeWithNewChildren, +var fabricCreateViewTransitionInstance = + reactPrivateInterface.fabricUIManager.createViewTransitionInstance, + fabricStartViewTransition = + reactPrivateInterface.fabricUIManager.startViewTransition, + fabricStartViewTransitionReadyFinished = + reactPrivateInterface.fabricUIManager.startViewTransitionReadyFinished; +function ViewTransitionPseudoElement(pseudo, name) { + this._pseudo = pseudo; + this._name = name; +} +function measureClonedInstance() { + return { + rect: { x: 0, y: 0, width: 0, height: 0 }, + abs: !1, + clip: !1, + view: !0 + }; +} +function createViewTransitionInstance(name) { + var tag = allocateTag(); + fabricCreateViewTransitionInstance(name, tag); + return { + name: name, + old: new ViewTransitionPseudoElement("old", name), + new: new ViewTransitionPseudoElement("new", name) + }; +} +function startViewTransition( + suspendedState, + rootContainer, + transitionTypes, + mutationCallback, + layoutCallback, + afterMutationCallback, + spawnedWorkCallback, + passiveCallback +) { + suspendedState = fabricStartViewTransition(function () { + mutationCallback(); + layoutCallback(); + afterMutationCallback(); + }); + if (null == suspendedState) + return mutationCallback(), layoutCallback(), spawnedWorkCallback(), null; + suspendedState.ready.then(function () { + spawnedWorkCallback(); + fabricStartViewTransitionReadyFinished(); + }); + suspendedState.finished.finally(function () { + passiveCallback(); + }); + return suspendedState; +} +var createNode = reactPrivateInterface.fabricUIManager.createNode, + cloneNodeWithNewChildren = + reactPrivateInterface.fabricUIManager.cloneNodeWithNewChildren, cloneNodeWithNewChildrenAndProps = - _nativeFabricUIManage.cloneNodeWithNewChildrenAndProps, - cloneNodeWithNewProps = _nativeFabricUIManage.cloneNodeWithNewProps, - createChildNodeSet = _nativeFabricUIManage.createChildSet, - appendChildNode = _nativeFabricUIManage.appendChild, - appendChildNodeToSet = _nativeFabricUIManage.appendChildToSet, - completeRoot = _nativeFabricUIManage.completeRoot, - registerEventHandler = _nativeFabricUIManage.registerEventHandler, - FabricDiscretePriority = _nativeFabricUIManage.unstable_DiscreteEventPriority, + reactPrivateInterface.fabricUIManager.cloneNodeWithNewChildrenAndProps, + cloneNodeWithNewProps = + reactPrivateInterface.fabricUIManager.cloneNodeWithNewProps, + createChildNodeSet = reactPrivateInterface.fabricUIManager.createChildSet, + appendChildNode = reactPrivateInterface.fabricUIManager.appendChild, + appendChildNodeToSet = reactPrivateInterface.fabricUIManager.appendChildToSet, + completeRoot = reactPrivateInterface.fabricUIManager.completeRoot, + registerEventHandler = + reactPrivateInterface.fabricUIManager.registerEventHandler, + FabricDiscretePriority = + reactPrivateInterface.fabricUIManager.unstable_DiscreteEventPriority, FabricContinuousPriority = - _nativeFabricUIManage.unstable_ContinuousEventPriority, - FabricIdlePriority = _nativeFabricUIManage.unstable_IdleEventPriority, + reactPrivateInterface.fabricUIManager.unstable_ContinuousEventPriority, + FabricIdlePriority = + reactPrivateInterface.fabricUIManager.unstable_IdleEventPriority, fabricGetCurrentEventPriority = - _nativeFabricUIManage.unstable_getCurrentEventPriority, + reactPrivateInterface.fabricUIManager.unstable_getCurrentEventPriority, + fabricSuspendOnActiveViewTransition = + reactPrivateInterface.fabricUIManager.suspendOnActiveViewTransition, extraDevToolsConfig = { getInspectorDataForInstance: void 0, - getInspectorDataForViewTag: function () { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, getInspectorDataForViewAtPoint: function () { throw Error( "getInspectorDataForViewAtPoint() is not available in production." @@ -10334,8 +11426,13 @@ var _nativeFabricUIManage = nativeFabricUIManager, } }, getViewConfigForType = - ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get, + reactPrivateInterface.ReactNativeViewConfigRegistry.get, nextReactTag = 2; +function allocateTag() { + var tag = nextReactTag; + nextReactTag += 2; + return tag; +} registerEventHandler && registerEventHandler(dispatchEvent); var PROD_HOST_CONTEXT = { isInAParentText: !0 }; function createTextInstance( @@ -10344,8 +11441,7 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - hostContext = nextReactTag; - nextReactTag += 2; + hostContext = allocateTag(); return { node: createNode( hostContext, @@ -10361,7 +11457,7 @@ function getPublicInstance(instance) { if (null == instance.canonical.publicInstance) { var $jscomp$nullish$tmp0; instance.canonical.publicInstance = - ReactNativePrivateInterface.createPublicInstance( + reactPrivateInterface.createPublicInstance( instance.canonical.nativeTag, instance.canonical.viewConfig, instance.canonical.internalInstanceHandle, @@ -10373,12 +11469,15 @@ function getPublicInstance(instance) { } return instance.canonical.publicInstance; } - return null != instance.containerInfo && - null != instance.containerInfo.publicInstance + return null != instance.containerInfo ? instance.containerInfo.publicInstance - : null != instance._nativeTag - ? instance - : null; + : null; +} +function getPublicInstanceFromHostFiber(fiber) { + fiber = getPublicInstance(fiber.stateNode); + if (null === fiber) + throw Error("Expected to find a host node. This is a bug in React."); + return fiber; } var currentUpdatePriority = 0; function resolveUpdatePriority() { @@ -10401,7 +11500,7 @@ var scheduleTimeout = setTimeout, cancelTimeout = clearTimeout; function cloneHiddenInstance(instance) { var node = instance.node, - updatePayload = ReactNativePrivateInterface.createAttributePayload( + updatePayload = reactPrivateInterface.createAttributePayload( { style: { display: "none" } }, instance.canonical.viewConfig.validAttributes ); @@ -10410,6 +11509,159 @@ function cloneHiddenInstance(instance) { canonical: instance.canonical }; } +function FragmentInstance(fragmentFiber) { + this._fragmentFiber = fragmentFiber; + this._observers = null; +} +FragmentInstance.prototype.observeUsing = function (observer) { + null === this._observers && (this._observers = new Set()); + this._observers.add(observer); + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + observeChild, + observer, + void 0, + void 0 + ); +}; +function observeChild(child, observer) { + child = getPublicInstanceFromHostFiber(child); + observer.observe(child); + return !1; +} +FragmentInstance.prototype.unobserveUsing = function (observer) { + var observers = this._observers; + null !== observers && + observers.has(observer) && + (observers.delete(observer), + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + unobserveChild, + observer, + void 0, + void 0 + )); +}; +function unobserveChild(child, observer) { + child = getPublicInstanceFromHostFiber(child); + observer.unobserve(child); + return !1; +} +FragmentInstance.prototype.compareDocumentPosition = function (otherNode) { + var parentHostFiber = getFragmentParentInstanceOrContainerFiber( + this._fragmentFiber + ); + if (null === parentHostFiber) return Node.DOCUMENT_POSITION_DISCONNECTED; + var children = []; + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + collectChildren, + children, + void 0, + void 0 + ); + if (0 === children.length) { + var parentHostInstance = getPublicInstanceFromHostFiber(parentHostFiber); + children = this._fragmentFiber; + parentHostFiber = getPublicInstanceFromHostFiber; + var parentResult = parentHostInstance.compareDocumentPosition(otherNode); + var result = parentResult; + parentHostInstance === otherNode + ? (result = Node.DOCUMENT_POSITION_CONTAINS) + : parentResult & Node.DOCUMENT_POSITION_CONTAINED_BY && + ((parentHostInstance = [null, null]), + (result = getFragmentParentInstanceOrContainerFiber(children)), + null !== result && + findFragmentInstanceOrTextInstanceSiblings( + parentHostInstance, + children, + result.child, + { foundSelf: !1 } + ), + (children = parentHostInstance[1]), + null === children + ? (result = Node.DOCUMENT_POSITION_PRECEDING) + : ((otherNode = + parentHostFiber(children).compareDocumentPosition(otherNode)), + (result = + 0 === otherNode || otherNode & Node.DOCUMENT_POSITION_FOLLOWING + ? Node.DOCUMENT_POSITION_FOLLOWING + : Node.DOCUMENT_POSITION_PRECEDING))); + return (result |= Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + } + parentHostFiber = getPublicInstanceFromHostFiber(children[0]); + children = getPublicInstanceFromHostFiber(children[children.length - 1]); + parentHostInstance = parentHostFiber.compareDocumentPosition(otherNode); + parentResult = children.compareDocumentPosition(otherNode); + result = + parentHostInstance & Node.DOCUMENT_POSITION_CONTAINED_BY || + parentResult & Node.DOCUMENT_POSITION_CONTAINED_BY; + parentResult = + parentHostInstance & Node.DOCUMENT_POSITION_FOLLOWING && + parentResult & Node.DOCUMENT_POSITION_PRECEDING; + return parentHostFiber === otherNode || + children === otherNode || + result || + parentResult + ? Node.DOCUMENT_POSITION_CONTAINED_BY + : parentHostInstance; +}; +function collectChildren(child, collection) { + collection.push(child); + return !1; +} +FragmentInstance.prototype.getRootNode = function (getRootNodeOptions) { + var parentHostFiber = getFragmentParentInstanceOrContainerFiber( + this._fragmentFiber + ); + return null === parentHostFiber + ? this + : getPublicInstanceFromHostFiber(parentHostFiber).getRootNode( + getRootNodeOptions + ); +}; +FragmentInstance.prototype.getClientRects = function () { + var rects = []; + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + collectClientRects, + rects, + void 0, + void 0 + ); + return rects; +}; +function collectClientRects(child, rects) { + child = getPublicInstanceFromHostFiber(child); + rects.push(child.getBoundingClientRect()); + return !1; +} +function addFragmentHandleToFiber(child, fragmentInstance) { + child = getPublicInstanceFromHostFiber(child); + null != child && addFragmentHandleToInstance(child, fragmentInstance); + return !1; +} +function addFragmentHandleToInstance(instance, fragmentInstance) { + null == instance.reactFragments && (instance.reactFragments = new Set()); + instance.reactFragments.add(fragmentInstance); +} +function commitNewChildToFragmentInstance(childInstance, fragmentInstance) { + if (null != childInstance.canonical) { + var publicInstance = getPublicInstance(childInstance); + if (null !== fragmentInstance._observers) { + if (null == publicInstance) + throw Error("Expected to find a host node. This is a bug in React."); + fragmentInstance._observers.forEach(function (observer) { + observer.observe(publicInstance); + }); + } + addFragmentHandleToInstance(publicInstance, fragmentInstance); + } +} var HostTransitionContext = { $$typeof: REACT_CONTEXT_TYPE, Provider: null, @@ -10418,9 +11670,6 @@ var HostTransitionContext = { _currentValue2: null, _threadCount: 0 }, - supportsMicrotasks = - "undefined" !== typeof RN$enableMicrotasksInReact && - !!RN$enableMicrotasksInReact, scheduleMicrotask = "function" === typeof queueMicrotask ? queueMicrotask : scheduleTimeout; getFiberCurrentPropsFromNode$1 = function (instance) { @@ -10440,14 +11689,14 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ onChange: function (from, to, blockNativeResponder) { from && from.stateNode && - nativeFabricUIManager.setIsJSResponder( + reactPrivateInterface.fabricUIManager.setIsJSResponder( from.stateNode.node, !1, blockNativeResponder || !1 ); to && to.stateNode && - nativeFabricUIManager.setIsJSResponder( + reactPrivateInterface.fabricUIManager.setIsJSResponder( to.stateNode.node, !0, blockNativeResponder || !1 @@ -10456,14 +11705,14 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ }); if ( "function" !== - typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog + typeof reactPrivateInterface.ReactFiberErrorDialog.showErrorDialog ) throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); function nativeOnUncaughtError(error, errorInfo) { !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + reactPrivateInterface.ReactFiberErrorDialog.showErrorDialog({ errorBoundary: null, error: error, componentStack: @@ -10472,7 +11721,7 @@ function nativeOnUncaughtError(error, errorInfo) { } function nativeOnCaughtError(error, errorInfo) { !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + reactPrivateInterface.ReactFiberErrorDialog.showErrorDialog({ errorBoundary: errorInfo.errorBoundary, error: error, componentStack: @@ -10493,26 +11742,26 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - internals$jscomp$inline_1245 = { + internals$jscomp$inline_1347 = { bundleType: 0, - version: "19.2.3", + version: "19.3.0", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.3" + reconcilerVersion: "19.3.0" }; null !== extraDevToolsConfig && - (internals$jscomp$inline_1245.rendererConfig = extraDevToolsConfig); + (internals$jscomp$inline_1347.rendererConfig = extraDevToolsConfig); if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1553 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1663 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1553.isDisabled && - hook$jscomp$inline_1553.supportsFiber + !hook$jscomp$inline_1663.isDisabled && + hook$jscomp$inline_1663.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1553.inject( - internals$jscomp$inline_1245 + (rendererID = hook$jscomp$inline_1663.inject( + internals$jscomp$inline_1347 )), - (injectedHook = hook$jscomp$inline_1553); + (injectedHook = hook$jscomp$inline_1663); } catch (err) {} } exports.createPortal = function (children, containerTag) { @@ -10524,51 +11773,36 @@ exports.createPortal = function (children, containerTag) { ); }; exports.dispatchCommand = function (handle, command, args) { - var nativeTag = - null != handle._nativeTag - ? handle._nativeTag - : ReactNativePrivateInterface.getNativeTagFromPublicInstance(handle); - null != nativeTag && - ((handle = ReactNativePrivateInterface.getNodeFromPublicInstance(handle)), - null != handle - ? nativeFabricUIManager.dispatchCommand(handle, command, args) - : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( - nativeTag, - command, - args - )); + handle = reactPrivateInterface.getNodeFromPublicInstance(handle); + null != handle && + reactPrivateInterface.fabricUIManager.dispatchCommand( + handle, + command, + args + ); }; exports.findHostInstance_DEPRECATED = function (componentOrHandle) { return null == componentOrHandle ? null : componentOrHandle.canonical && componentOrHandle.canonical.publicInstance ? componentOrHandle.canonical.publicInstance - : componentOrHandle._nativeTag - ? componentOrHandle - : findHostInstance(componentOrHandle); + : findHostInstance(componentOrHandle); }; exports.findNodeHandle = function (componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; - if (componentOrHandle._nativeTag) return componentOrHandle._nativeTag; if ( null != componentOrHandle.canonical && null != componentOrHandle.canonical.nativeTag ) return componentOrHandle.canonical.nativeTag; var nativeTag = - ReactNativePrivateInterface.getNativeTagFromPublicInstance( - componentOrHandle - ); + reactPrivateInterface.getNativeTagFromPublicInstance(componentOrHandle); if (nativeTag) return nativeTag; componentOrHandle = findHostInstance(componentOrHandle); return null == componentOrHandle ? componentOrHandle - : null != componentOrHandle._nativeTag - ? componentOrHandle._nativeTag - : ReactNativePrivateInterface.getNativeTagFromPublicInstance( - componentOrHandle - ); + : reactPrivateInterface.getNativeTagFromPublicInstance(componentOrHandle); }; exports.getNodeFromInternalInstanceHandle = function (internalInstanceHandle) { return ( @@ -10586,7 +11820,7 @@ exports.getPublicInstanceFromInternalInstanceHandle = function ( : 6 === internalInstanceHandle.tag ? (null == instance.publicInstance && (instance.publicInstance = - ReactNativePrivateInterface.createPublicTextInstance( + reactPrivateInterface.createPublicTextInstance( internalInstanceHandle )), instance.publicInstance) @@ -10623,7 +11857,7 @@ exports.render = function ( (onRecoverableError = options.onRecoverableError); options = { publicInstance: - ReactNativePrivateInterface.createPublicRootInstance(containerTag), + reactPrivateInterface.createPublicRootInstance(containerTag), containerTag: containerTag }; concurrentRoot = concurrentRoot ? 1 : 0; @@ -10672,18 +11906,12 @@ exports.render = function ( return element; }; exports.sendAccessibilityEvent = function (handle, eventType) { - var nativeTag = - null != handle._nativeTag - ? handle._nativeTag - : ReactNativePrivateInterface.getNativeTagFromPublicInstance(handle); - null != nativeTag && - ((handle = ReactNativePrivateInterface.getNodeFromPublicInstance(handle)), - null != handle - ? nativeFabricUIManager.sendAccessibilityEvent(handle, eventType) - : ReactNativePrivateInterface.legacySendAccessibilityEvent( - nativeTag, - eventType - )); + handle = reactPrivateInterface.getNodeFromPublicInstance(handle); + null != handle && + reactPrivateInterface.fabricUIManager.sendAccessibilityEvent( + handle, + eventType + ); }; exports.stopSurface = function (containerTag) { var root = roots.get(containerTag); diff --git a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js index 544c75406ef2..1934f48a23dc 100644 --- a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js +++ b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> * * This file was sync'd from the facebook/react repository. */ @@ -17,8 +17,8 @@ "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); -require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); -var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"), +require("react-native/setup-env"); +var reactPrivateInterface = require("react-native/react-private-interface"), Scheduler = require("scheduler"), React = require("react"), isArrayImpl = Array.isArray, @@ -75,7 +75,26 @@ function describeNativeComponentFrame(fn, construct) { } catch (x$1) { control = x$1; } - fn.call(Fake.prototype); + Fake = !1; + try { + var prevProps = Object.getOwnPropertyDescriptor( + fn.prototype, + "props" + ); + Object.defineProperty(fn.prototype, "props", { + configurable: !0, + set: function () { + throw Error(); + } + }); + Fake = !0; + new fn(); + } finally { + Fake && + (void 0 !== prevProps + ? Object.defineProperty(fn.prototype, "props", prevProps) + : delete fn.prototype.props); + } } } else { try { @@ -200,6 +219,8 @@ function describeFiber(fiber, childFiber) { return describeNativeComponentFrame(fiber.type, !0); case 31: return describeBuiltInComponentFrame("Activity"); + case 30: + return describeBuiltInComponentFrame("ViewTransition"); default: return ""; } @@ -232,12 +253,13 @@ var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"); Symbol.for("react.scope"); -var REACT_ACTIVITY_TYPE = Symbol.for("react.activity"); -Symbol.for("react.legacy_hidden"); +var REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), + REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden"); Symbol.for("react.tracing_marker"); -var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"); -Symbol.for("react.view_transition"); -var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; +var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"), + REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"), + REACT_RECOVERABLE_TYPE = Symbol.for("react.recoverable"), + MAYBE_ITERATOR_SYMBOL = Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -245,7 +267,8 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); +var REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key"), + REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); function getComponentNameFromType(type) { if (null == type) return null; if ("function" === typeof type) @@ -266,6 +289,8 @@ function getComponentNameFromType(type) { return "SuspenseList"; case REACT_ACTIVITY_TYPE: return "Activity"; + case REACT_VIEW_TRANSITION_TYPE: + return "ViewTransition"; } if ("object" === typeof type) switch (type.$$typeof) { @@ -335,7 +360,8 @@ function getComponentNameFromFiber(fiber) { case 8: return type === REACT_STRICT_MODE_TYPE ? "StrictMode" : "Mode"; case 22: - return "Offscreen"; + if (null !== fiber.return) return getComponentNameFromFiber(fiber.return); + break; case 12: return "Profiler"; case 21: @@ -347,6 +373,7 @@ function getComponentNameFromFiber(fiber) { case 25: return "TracingMarker"; case 30: + return "ViewTransition"; case 17: case 28: case 1: @@ -366,11 +393,14 @@ var hasError = !1, getNodeFromInstance$1 = null; function executeDispatch(event, listener, inst) { event.currentTarget = getNodeFromInstance$1(inst); + inst = global.event; + global.event = event; try { listener(event); } catch (error) { hasError || ((hasError = !0), (caughtError = error)); } + global.event = inst; event.currentTarget = null; } function executeDirectDispatch(event) { @@ -386,6 +416,19 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } +function currentTimeStamp() { + currentTimeStamp = + "object" === typeof performance && + null !== performance && + "function" === typeof performance.now + ? function () { + return performance.now(); + } + : function () { + return Date.now(); + }; + return currentTimeStamp(); +} function functionThatReturnsTrue() { return !0; } @@ -462,7 +505,7 @@ SyntheticEvent.Interface = { bubbles: null, cancelable: null, timeStamp: function (event) { - return event.timeStamp || Date.now(); + return event.timeStamp || event.timestamp || currentTimeStamp(); }, defaultPrevented: null, isTrusted: null @@ -1165,11 +1208,10 @@ function getListener(inst, registrationName) { return inst; } var customBubblingEventTypes = - ReactNativePrivateInterface.ReactNativeViewConfigRegistry + reactPrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = - ReactNativePrivateInterface.ReactNativeViewConfigRegistry - .customDirectEventTypes; + reactPrivateInterface.ReactNativeViewConfigRegistry.customDirectEventTypes; function accumulateDirectionalDispatches(inst, phase, event) { if ( (phase = getListener( @@ -1234,7 +1276,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_320 = { +var injectedNamesToPlugins$jscomp$inline_336 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -1280,32 +1322,32 @@ var injectedNamesToPlugins$jscomp$inline_320 = { } } }, - isOrderingDirty$jscomp$inline_321 = !1, - pluginName$jscomp$inline_322; -for (pluginName$jscomp$inline_322 in injectedNamesToPlugins$jscomp$inline_320) + isOrderingDirty$jscomp$inline_337 = !1, + pluginName$jscomp$inline_338; +for (pluginName$jscomp$inline_338 in injectedNamesToPlugins$jscomp$inline_336) if ( - injectedNamesToPlugins$jscomp$inline_320.hasOwnProperty( - pluginName$jscomp$inline_322 + injectedNamesToPlugins$jscomp$inline_336.hasOwnProperty( + pluginName$jscomp$inline_338 ) ) { - var pluginModule$jscomp$inline_323 = - injectedNamesToPlugins$jscomp$inline_320[pluginName$jscomp$inline_322]; + var pluginModule$jscomp$inline_339 = + injectedNamesToPlugins$jscomp$inline_336[pluginName$jscomp$inline_338]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_322) || - namesToPlugins[pluginName$jscomp$inline_322] !== - pluginModule$jscomp$inline_323 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_338) || + namesToPlugins[pluginName$jscomp$inline_338] !== + pluginModule$jscomp$inline_339 ) { - if (namesToPlugins[pluginName$jscomp$inline_322]) + if (namesToPlugins[pluginName$jscomp$inline_338]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_322 + "`.") + (pluginName$jscomp$inline_338 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_322] = - pluginModule$jscomp$inline_323; - isOrderingDirty$jscomp$inline_321 = !0; + namesToPlugins[pluginName$jscomp$inline_338] = + pluginModule$jscomp$inline_339; + isOrderingDirty$jscomp$inline_337 = !0; } } -isOrderingDirty$jscomp$inline_321 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_337 && recomputePluginOrdering(); function batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); } @@ -1339,46 +1381,71 @@ function executeDispatchesAndReleaseTopLevel(e) { e.isPersistent() || e.constructor.release(e); } } -function dispatchEvent(target, topLevelType, nativeEvent) { - var eventTarget = null; - if (null != target) { - var stateNode = target.stateNode; - null != stateNode && (eventTarget = getPublicInstance(stateNode)); - } +var _enableNativeEventTargetEventDispatching = null; +function dispatchEvent(target, topLevelType, nativeEventParam) { + var nativeEvent = + null != nativeEventParam && "object" === typeof nativeEventParam + ? nativeEventParam + : {}, + eventTarget = null; + null != target && + ((nativeEventParam = target.stateNode), + null != nativeEventParam && + (eventTarget = getPublicInstance(nativeEventParam))); batchedUpdates$1(function () { var event = { eventName: topLevelType, nativeEvent: nativeEvent }; - ReactNativePrivateInterface.RawEventEmitter.emit(topLevelType, event); - ReactNativePrivateInterface.RawEventEmitter.emit("*", event); - event = eventTarget; - for ( - var events = null, legacyPlugins = plugins, i = 0; - i < legacyPlugins.length; - i++ - ) { - var possiblePlugin = legacyPlugins[i]; - possiblePlugin && - (possiblePlugin = possiblePlugin.extractEvents( + reactPrivateInterface.RawEventEmitter.emit(topLevelType, event); + reactPrivateInterface.RawEventEmitter.emit("*", event); + null == _enableNativeEventTargetEventDispatching && + ((event = + null != reactPrivateInterface.ReactNativeFeatureFlags + ? reactPrivateInterface.ReactNativeFeatureFlags + .enableNativeEventTargetEventDispatching + : null), + (_enableNativeEventTargetEventDispatching = + "function" === typeof event && event())); + if (_enableNativeEventTargetEventDispatching) + null != eventTarget && + reactPrivateInterface.dispatchNativeEvent( + eventTarget, topLevelType, - target, - nativeEvent, - event - )) && - (events = accumulateInto(events, possiblePlugin)); - } - event = events; - null !== event && (eventQueue = accumulateInto(eventQueue, event)); - event = eventQueue; - eventQueue = null; - if (event) { - forEachAccumulated(event, executeDispatchesAndReleaseTopLevel); - if (eventQueue) - throw Error( - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ); - if (hasError) - throw ( - ((event = caughtError), (hasError = !1), (caughtError = null), event) + nativeEvent ); + else { + event = eventTarget; + for ( + var events = null, legacyPlugins = plugins, i = 0; + i < legacyPlugins.length; + i++ + ) { + var possiblePlugin = legacyPlugins[i]; + possiblePlugin && + (possiblePlugin = possiblePlugin.extractEvents( + topLevelType, + target, + nativeEvent, + event + )) && + (events = accumulateInto(events, possiblePlugin)); + } + event = events; + null !== event && (eventQueue = accumulateInto(eventQueue, event)); + event = eventQueue; + eventQueue = null; + if (event) { + forEachAccumulated(event, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw Error( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasError) + throw ( + ((event = caughtError), + (hasError = !1), + (caughtError = null), + event) + ); + } } }); } @@ -1443,7 +1510,7 @@ function getHighestPriorityLanes(lanes) { case 32768: case 65536: case 131072: - return lanes & 261888; + return lanes & -lanes; case 262144: case 524288: case 1048576: @@ -1516,6 +1583,22 @@ function checkIfRootIsPrerendering(root, renderLanes) { renderLanes) ); } +function getEntangledLanes(root, renderLanes) { + 0 !== (renderLanes & 8) && (renderLanes |= renderLanes & 32); + var allEntangledLanes = root.entangledLanes; + if (0 !== allEntangledLanes) + for ( + root = root.entanglements, allEntangledLanes &= renderLanes; + 0 < allEntangledLanes; + + ) { + var index$6 = 31 - clz32(allEntangledLanes), + lane = 1 << index$6; + renderLanes |= root[index$6]; + allEntangledLanes &= ~lane; + } + return renderLanes; +} function computeExpirationTime(lane, currentTime) { switch (lane) { case 1: @@ -1724,18 +1807,12 @@ function lanesToEventPriority(lanes) { : 2; } function getNearestMountedFiber(fiber) { - var node = fiber, - nearestMounted = fiber; - if (fiber.alternate) for (; node.return; ) node = node.return; - else { - fiber = node; - do - (node = fiber), - 0 !== (node.flags & 4098) && (nearestMounted = node.return), - (fiber = node.return); - while (fiber); - } - return 3 === node.tag ? nearestMounted : null; + for (var node = fiber, nextNode = node; nextNode && !nextNode.alternate; ) + (node = nextNode), + 0 !== (node.flags & 4098) && (fiber = node.return), + (nextNode = node.return); + for (; node.return; ) node = node.return; + return 3 === node.tag ? fiber : null; } function assertIsMounted(fiber) { if (getNearestMountedFiber(fiber) !== fiber) @@ -1827,6 +1904,66 @@ function findCurrentHostFiberImpl(node) { } return null; } +function traverseVisibleInstancesAndTextInstances( + child, + searchWithinHosts, + fn, + a, + b, + c +) { + for (; null !== child; ) { + if ( + ((5 === child.tag || 27 === child.tag || 6 === child.tag) && + fn(child, a, b, c)) || + ((22 !== child.tag || null === child.memoizedState) && + (searchWithinHosts || (5 !== child.tag && 27 !== child.tag)) && + traverseVisibleInstancesAndTextInstances( + child.child, + searchWithinHosts, + fn, + a, + b, + c + )) + ) + return !0; + child = child.sibling; + } + return !1; +} +function getFragmentParentInstanceOrContainerFiber(fiber) { + for (fiber = fiber.return; null !== fiber; ) { + if (3 === fiber.tag || 5 === fiber.tag || 27 === fiber.tag) return fiber; + fiber = fiber.return; + } + return null; +} +function findFragmentInstanceOrTextInstanceSiblings( + result, + self, + child, + state +) { + for (; null !== child; ) { + if (child === self) state.foundSelf = !0; + else if (5 === child.tag || 27 === child.tag || 6 === child.tag) { + if (state.foundSelf) return (result[1] = child), !0; + result[0] = child; + } else if ( + (22 !== child.tag || null === child.memoizedState) && + findFragmentInstanceOrTextInstanceSiblings( + result, + self, + child.child, + state + ) + ) + return !0; + child = child.sibling; + } + return !1; +} var valueStack = [], index = -1; function createCursor(defaultValue) { @@ -1841,7 +1978,42 @@ function push(cursor, value) { valueStack[index] = cursor.current; cursor.current = value; } -var emptyContextObject = {}; +var emptyContextObject = {}, + globalClientIdCounter$1 = 0; +function getViewTransitionName(props, instance) { + if (null != props.name && "auto" !== props.name) return props.name; + if (null !== instance.autoName) return instance.autoName; + props = pendingEffectsRoot.identifierPrefix; + var globalClientId = globalClientIdCounter$1++; + props = "_" + props + "t_" + globalClientId.toString(32) + "_"; + return (instance.autoName = props); +} +function getClassNameByType(classByType) { + if (null == classByType || "string" === typeof classByType) + return classByType; + var className = null, + activeTypes = pendingTransitionTypes; + if (null !== activeTypes) + for (var i = 0; i < activeTypes.length; i++) { + var match = classByType[activeTypes[i]]; + if (null != match) { + if ("none" === match) return "none"; + className = null == className ? match : className + (" " + match); + } + } + return null == className ? classByType.default : className; +} +function getViewTransitionClassName(defaultClass, eventClass) { + defaultClass = getClassNameByType(defaultClass); + eventClass = getClassNameByType(eventClass); + return null == eventClass + ? "auto" === defaultClass + ? null + : defaultClass + : "auto" === eventClass + ? null + : eventClass; +} function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -1902,7 +2074,8 @@ function logComponentTrigger(fiber, startTime, endTime, trigger) { (reusableComponentDevToolDetails.color = "warning"), (reusableComponentDevToolDetails.tooltipText = trigger), (reusableComponentDevToolDetails.properties = null), - performance.measure(trigger, reusableComponentOptions)); + performance.measure(trigger, reusableComponentOptions), + performance.clearMeasures(trigger)); } function logComponentReappeared(fiber, startTime, endTime) { logComponentTrigger(fiber, startTime, endTime, "Reconnect"); @@ -2040,6 +2213,32 @@ function logCommitErrored(startTime, endTime) { "error" ); } +function logCommitPhase(startTime, endTime, errors, abortedViewTransition) { + null !== errors + ? logCommitErrored(startTime, endTime) + : !supportsUserTiming || + endTime <= startTime || + console.timeStamp( + abortedViewTransition ? "Commit Interrupted View Transition" : "Commit", + startTime, + endTime, + currentTrack, + "Scheduler \u269b", + abortedViewTransition ? "error" : "secondary-dark" + ); +} +function logAnimatingPhase(startTime, endTime) { + !supportsUserTiming || + endTime <= startTime || + console.timeStamp( + "Animating", + startTime, + endTime, + currentTrack, + "Scheduler \u269b", + "secondary-dark" + ); +} var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { if ("object" === typeof value && null !== value) { @@ -2077,10 +2276,13 @@ function popHostContainer() { pop(rootInstanceStackCursor); } function pushHostContext(fiber) { - null !== fiber.memoizedState && push(hostTransitionProviderCursor, fiber); - var context = contextStackCursor.current; - context !== context && - (push(contextFiberStackCursor, fiber), push(contextStackCursor, context)); + var stateHook = fiber.memoizedState; + null !== stateHook && + ((HostTransitionContext._currentValue2 = stateHook.memoizedState), + push(hostTransitionProviderCursor, fiber)); + stateHook = contextStackCursor.current; + stateHook !== stateHook && + (push(contextFiberStackCursor, fiber), push(contextStackCursor, stateHook)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && @@ -2168,7 +2370,21 @@ function propagateContextChanges( null !== list && (list.lanes |= renderLanes); scheduleContextWorkOnParentPath(nextFiber, renderLanes, workInProgress); nextFiber = null; - } else nextFiber = fiber.child; + } else + 13 === fiber.tag && + null !== fiber.memoizedState && + null === fiber.memoizedState.dehydrated + ? ((fiber.lanes |= renderLanes), + (nextFiber = fiber.alternate), + null !== nextFiber && (nextFiber.lanes |= renderLanes), + scheduleContextWorkOnParentPath( + fiber.return, + renderLanes, + workInProgress + ), + (nextFiber = fiber.child), + (nextFiber = null !== nextFiber ? nextFiber.sibling : null)) + : (nextFiber = fiber.child); if (null !== nextFiber) nextFiber.return = fiber; else for (nextFiber = fiber; null !== nextFiber; ) { @@ -2232,6 +2448,7 @@ function propagateParentContextChanges( forcePropagateEntireTree ); workInProgress.flags |= 262144; + return null !== current; } function checkIfContextChanged(currentDependencies) { for ( @@ -2319,6 +2536,22 @@ function releaseCache(cache) { cache.controller.abort(); }); } +function queueTransitionTypes(root, transitionTypes) { + if (0 !== (root.pendingLanes & 4194048)) { + var queued = root.transitionTypes; + null === queued && (queued = root.transitionTypes = []); + for (root = 0; root < transitionTypes.length; root++) { + var transitionType = transitionTypes[root]; + -1 === queued.indexOf(transitionType) && queued.push(transitionType); + } + } +} +var entangledTransitionTypes = null; +function claimQueuedTransitionTypes(root) { + var claimed = root.transitionTypes; + root.transitionTypes = null; + return claimed; +} var now = Scheduler.unstable_now, renderStartTime = -0, commitStartTime = -0, @@ -2346,6 +2579,9 @@ var now = Scheduler.unstable_now, transitionEventType = null, transitionEventRepeatTime = -1.1, transitionSuspendedTime = -1.1, + retryClampTime = -0, + idleClampTime = -0, + animatingLanes = 0, yieldReason = 0, yieldStartTime = -1.1; function startUpdateTimerByLane(lane) { @@ -2354,20 +2590,28 @@ function startUpdateTimerByLane(lane) { blockingUpdateTime = now(); 0 !== (executionContext & 6) && ((componentEffectSpawnedUpdate = !0), (blockingUpdateType = 1)); - if (-1.1 !== blockingEventRepeatTime || null !== blockingEventType) - blockingEventRepeatTime = -1.1; - blockingEventTime = -1.1; - blockingEventType = null; + lane = resolveEventTimeStamp(); + var newEventType$19 = resolveEventType(); + lane !== blockingEventRepeatTime || newEventType$19 !== blockingEventType + ? (blockingEventRepeatTime = -1.1) + : null !== newEventType$19 && (blockingUpdateType = 1); + blockingEventTime = lane; + blockingEventType = newEventType$19; } } else if ( 0 !== (lane & 4194048) && 0 > transitionUpdateTime && ((transitionUpdateTime = now()), 0 > transitionStartTime) ) { - if (-1.1 !== transitionEventRepeatTime || null !== transitionEventType) + lane = resolveEventTimeStamp(); + newEventType$19 = resolveEventType(); + if ( + lane !== transitionEventRepeatTime || + newEventType$19 !== transitionEventType + ) transitionEventRepeatTime = -1.1; - transitionEventTime = -1.1; - transitionEventType = null; + transitionEventTime = lane; + transitionEventType = newEventType$19; } } function pushNestedEffectDurations() { @@ -2522,6 +2766,7 @@ function flushSyncWorkAcrossRoots_impl(syncTransitionLanes, onlyLegacy) { } } function processRootScheduleInImmediateTask() { + schedulerEvent = global.event; processRootScheduleInMicrotask(); } function processRootScheduleInMicrotask() { @@ -2619,6 +2864,7 @@ function scheduleTaskForRootDuringMicrotask(root, currentTime) { } function performWorkOnRootViaSchedulerTask(root, didTimeout) { nestedUpdateScheduled = currentUpdateIsNested = !1; + schedulerEvent = global.event; if (0 !== pendingEffectsStatus && 5 !== pendingEffectsStatus) return (root.callbackNode = null), (root.callbackPriority = 0), null; var originalCallbackNode = root.callbackNode; @@ -2645,16 +2891,14 @@ function performSyncWorkOnRoot(root, lanes) { performWorkOnRoot(root, lanes, !0); } function scheduleImmediateRootScheduleTask() { - supportsMicrotasks - ? scheduleMicrotask(function () { - 0 !== (executionContext & 6) - ? scheduleCallback$3( - ImmediatePriority, - processRootScheduleInImmediateTask - ) - : processRootScheduleInMicrotask(); - }) - : scheduleCallback$3(ImmediatePriority, processRootScheduleInImmediateTask); + scheduleMicrotask(function () { + 0 !== (executionContext & 6) + ? scheduleCallback$3( + ImmediatePriority, + processRootScheduleInImmediateTask + ) + : processRootScheduleInMicrotask(); + }); } function requestTransitionLane() { if (0 === currentEventTransitionLane) { @@ -2693,6 +2937,7 @@ function pingEngtangledActionScope() { if ( 0 === --currentEntangledPendingCount && (-1 < transitionUpdateTime || (transitionStartTime = -1.1), + (entangledTransitionTypes = null), null !== currentEntangledListeners) ) { null !== currentEntangledActionThenable && @@ -2739,13 +2984,37 @@ ReactSharedInternals.S = function (transition, returnValue) { ) { if (0 > transitionStartTime && 0 > transitionUpdateTime) { transitionStartTime = now(); - if (-1.1 !== transitionEventRepeatTime || null !== transitionEventType) + var newEventTime = resolveEventTimeStamp(), + newEventType = resolveEventType(); + if ( + newEventTime !== transitionEventRepeatTime || + newEventType !== transitionEventType + ) transitionEventRepeatTime = -1.1; - transitionEventTime = -1.1; - transitionEventType = null; + transitionEventTime = newEventTime; + transitionEventType = newEventType; } entangleAsyncAction(transition, returnValue); } + if (null !== entangledTransitionTypes) + for (newEventTime = firstScheduledRoot; null !== newEventTime; ) + queueTransitionTypes(newEventTime, entangledTransitionTypes), + (newEventTime = newEventTime.next); + newEventTime = transition.types; + if (null !== newEventTime) { + for (newEventType = firstScheduledRoot; null !== newEventType; ) + queueTransitionTypes(newEventType, newEventTime), + (newEventType = newEventType.next); + if (0 !== currentEntangledLane) { + newEventType = entangledTransitionTypes; + null === newEventType && (newEventType = entangledTransitionTypes = []); + for (var i = 0; i < newEventTime.length; i++) { + var transitionType = newEventTime[i]; + -1 === newEventType.indexOf(transitionType) && + newEventType.push(transitionType); + } + } + } null !== prevOnStartTransitionFinish && prevOnStartTransitionFinish(transition, returnValue); }; @@ -2812,11 +3081,13 @@ function trackUsedThenable(thenableState, thenable, index) { case "fulfilled": return thenable.value; case "rejected": - throw ( - ((thenableState = thenable.reason), - checkIfUseWrappedInAsyncCatch(thenableState), - thenableState) - ); + thenableState = thenable.reason; + checkIfUseWrappedInAsyncCatch(thenableState); + if (void 0 === thenableState && !("reason" in thenable)) + throw Error( + "A rejected Promise was passed to React without a `reason` property. React threw a generic error from where the Promise was used to assist in identifying the problematic Promise. Make sure that instrumented Promises correctly set the `reason` property when setting `status` to `'rejected'`." + ); + throw thenableState; default: if ("string" === typeof thenable.status) thenable.then(noop, noop); else { @@ -2931,9 +3202,9 @@ function createChildReconciler(shouldTrackSideEffects) { } function mapRemainingChildren(currentFirstChild) { for (var existingChildren = new Map(); null !== currentFirstChild; ) - null !== currentFirstChild.key - ? existingChildren.set(currentFirstChild.key, currentFirstChild) - : existingChildren.set(currentFirstChild.index, currentFirstChild), + null === currentFirstChild.key + ? existingChildren.set(currentFirstChild.index, currentFirstChild) + : existingChildren.set(currentFirstChild.key, currentFirstChild), (currentFirstChild = currentFirstChild.sibling); return existingChildren; } @@ -2952,16 +3223,16 @@ function createChildReconciler(shouldTrackSideEffects) { return ( (newIndex = newIndex.index), newIndex < lastPlacedIndex - ? ((newFiber.flags |= 67108866), lastPlacedIndex) + ? ((newFiber.flags |= 2), lastPlacedIndex) : newIndex ); - newFiber.flags |= 67108866; + newFiber.flags |= 134217730; return lastPlacedIndex; } function placeSingleChild(newFiber) { shouldTrackSideEffects && null === newFiber.alternate && - (newFiber.flags |= 67108866); + (newFiber.flags |= 134217730); return newFiber; } function updateTextNode(returnFiber, current, textContent, lanes) { @@ -2978,12 +3249,16 @@ function createChildReconciler(shouldTrackSideEffects) { function updateElement(returnFiber, current, element, lanes) { var elementType = element.type; if (elementType === REACT_FRAGMENT_TYPE) - return updateFragment( - returnFiber, - current, - element.props.children, - lanes, - element.key + return ( + (returnFiber = updateFragment( + returnFiber, + current, + element.props.children, + lanes, + element.key + )), + coerceRef(returnFiber, element), + returnFiber ); if ( null !== current && @@ -3304,10 +3579,9 @@ function createChildReconciler(shouldTrackSideEffects) { )), null !== nextOldFiber && (shouldTrackSideEffects && - null !== nextOldFiber.alternate && - oldFiber.delete( - null === nextOldFiber.key ? newIdx : nextOldFiber.key - ), + ((newFiber = nextOldFiber.alternate), + null !== newFiber && + oldFiber.delete(null === newFiber.key ? newIdx : newFiber.key)), (currentFirstChild = placeChild( nextOldFiber, currentFirstChild, @@ -3383,8 +3657,11 @@ function createChildReconciler(shouldTrackSideEffects) { (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && (shouldTrackSideEffects && - null !== step.alternate && - oldFiber.delete(null === step.key ? newIdx : step.key), + ((nextOldFiber = step.alternate), + null !== nextOldFiber && + oldFiber.delete( + null === nextOldFiber.key ? newIdx : nextOldFiber.key + )), (currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber ? (resultingFirstChild = step) @@ -3406,6 +3683,7 @@ function createChildReconciler(shouldTrackSideEffects) { null !== newChild && newChild.type === REACT_FRAGMENT_TYPE && null === newChild.key && + void 0 === newChild.props.ref && (newChild = newChild.props.children); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -3424,6 +3702,7 @@ function createChildReconciler(shouldTrackSideEffects) { currentFirstChild, newChild.props.children ); + coerceRef(lanes, newChild); lanes.return = returnFiber; returnFiber = lanes; break a; @@ -3457,6 +3736,7 @@ function createChildReconciler(shouldTrackSideEffects) { lanes, newChild.key )), + coerceRef(lanes, newChild), (lanes.return = returnFiber), (returnFiber = lanes)) : ((lanes = createFiberFromTypeAndProps( @@ -3969,7 +4249,7 @@ function pushOffscreenSuspenseHandler(fiber) { ? (push(suspenseStackCursor, suspenseStackCursor.current), push(suspenseHandlerStackCursor, fiber), null === shellBoundary && (shellBoundary = fiber)) - : reuseSuspenseHandlerOnStack(fiber); + : reuseSuspenseHandlerOnStack(); } function reuseSuspenseHandlerOnStack() { push(suspenseStackCursor, suspenseStackCursor.current); @@ -3981,6 +4261,15 @@ function popSuspenseHandler(fiber) { pop(suspenseStackCursor); } var suspenseStackCursor = createCursor(0); +function pushSuspenseListContext(fiber, newContext) { + push(suspenseHandlerStackCursor, suspenseHandlerStackCursor.current); + push(suspenseStackCursor, newContext); +} +function popSuspenseListContext(fiber) { + pop(suspenseStackCursor); + pop(suspenseHandlerStackCursor); + shellBoundary === fiber && (shellBoundary = null); +} function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3989,10 +4278,7 @@ function findFirstSuspended(row) { return node; } else if ( 19 === node.tag && - ("forwards" === node.memoizedProps.revealOrder || - "backwards" === node.memoizedProps.revealOrder || - "unstable_legacy-backwards" === node.memoizedProps.revealOrder || - "together" === node.memoizedProps.revealOrder) + "independent" !== node.memoizedProps.revealOrder ) { if (0 !== (node.flags & 128)) return node; } else if (null !== node.child) { @@ -4213,6 +4499,7 @@ function useThenable(thenable) { function use(usable) { if (null !== usable && "object" === typeof usable) { if ("function" === typeof usable.then) return useThenable(usable); + if (usable.$$typeof === REACT_RECOVERABLE_TYPE) return; if (usable.$$typeof === REACT_CONTEXT_TYPE) return readContext(usable); } throw Error("An unsupported type was passed to use(): " + String(usable)); @@ -4283,7 +4570,7 @@ function updateReducerImpl(hook, current, reducer) { var newBaseQueueFirst = (baseFirst = null), newBaseQueueLast = null, update = current, - didReadFromEntangledAsyncAction$53 = !1; + didReadFromEntangledAsyncAction$55 = !1; do { var updateLane = update.lane & -536870913; if ( @@ -4305,11 +4592,11 @@ function updateReducerImpl(hook, current, reducer) { next: null }), updateLane === currentEntangledLane && - (didReadFromEntangledAsyncAction$53 = !0); + (didReadFromEntangledAsyncAction$55 = !0); else if ((renderLanes & revertLane) === revertLane) { update = update.next; revertLane === currentEntangledLane && - (didReadFromEntangledAsyncAction$53 = !0); + (didReadFromEntangledAsyncAction$55 = !0); continue; } else (updateLane = { @@ -4357,7 +4644,7 @@ function updateReducerImpl(hook, current, reducer) { if ( !objectIs(pendingQueue, hook.memoizedState) && ((didReceiveUpdate = !0), - didReadFromEntangledAsyncAction$53 && + didReadFromEntangledAsyncAction$55 && ((reducer = currentEntangledActionThenable), null !== reducer)) ) throw reducer; @@ -4406,18 +4693,19 @@ function updateSyncExternalStore(subscribe, getSnapshot) { updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [ subscribe ]); - if ( + subscribe = hook.getSnapshot !== getSnapshot || snapshotChanged || - (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1) - ) { + (null !== workInProgressHook && + 0 !== (workInProgressHook.memoizedState.tag & 1)); + pushSimpleEffect( + subscribe ? 9 : 8, + { destroy: void 0 }, + updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), + null + ); + if (subscribe) { fiber.flags |= 2048; - pushSimpleEffect( - 9, - { destroy: void 0 }, - updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), - null - ); if (null === workInProgressRoot) throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." @@ -4505,7 +4793,7 @@ function dispatchActionState( payload ) { if (isRenderPhaseUpdate(fiber)) - throw Error("Cannot update form state while rendering."); + throw Error("Cannot update action state while rendering."); fiber = actionQueue.action; if (null !== fiber) { var actionNode = { @@ -4540,6 +4828,8 @@ function runActionStateAction(actionQueue, node) { if (node.isTransition) { var prevTransition = ReactSharedInternals.T, currentTransition = {}; + currentTransition.types = + null !== prevTransition ? prevTransition.types : null; ReactSharedInternals.T = currentTransition; try { var returnValue = action(prevState, payload), @@ -4559,8 +4849,8 @@ function runActionStateAction(actionQueue, node) { try { (prevTransition = action(prevState, payload)), handleActionReturnValue(actionQueue, node, prevTransition); - } catch (error$57) { - onActionError(actionQueue, node, error$57); + } catch (error$59) { + onActionError(actionQueue, node, error$59); } } function handleActionReturnValue(actionQueue, node, returnValue) { @@ -4854,7 +5144,7 @@ function updateDeferredValueImpl(hook, prevValue, value, initialValue) { hook ); if ( - 0 === (renderLanes & 42) || + 0 === (renderLanes & 106) || (0 !== (renderLanes & 1073741824) && 0 === (workInProgressRootRenderLanes & 261930)) ) @@ -4870,6 +5160,8 @@ function startTransition(fiber, queue, pendingState, finishedState, callback) { 0 !== previousPriority && 8 > previousPriority ? previousPriority : 8; var prevTransition = ReactSharedInternals.T, currentTransition = {}; + currentTransition.types = + null !== prevTransition ? prevTransition.types : null; ReactSharedInternals.T = currentTransition; dispatchOptimisticSetState(fiber, !1, queue, pendingState); try { @@ -5058,32 +5350,32 @@ function entangleTransitionUpdate(root, queue, lane) { } } var ContextOnlyDispatcher = { - readContext: readContext, - use: use, - useCallback: throwInvalidHookError, - useContext: throwInvalidHookError, - useEffect: throwInvalidHookError, - useImperativeHandle: throwInvalidHookError, - useLayoutEffect: throwInvalidHookError, - useInsertionEffect: throwInvalidHookError, - useMemo: throwInvalidHookError, - useReducer: throwInvalidHookError, - useRef: throwInvalidHookError, - useState: throwInvalidHookError, - useDebugValue: throwInvalidHookError, - useDeferredValue: throwInvalidHookError, - useTransition: throwInvalidHookError, - useSyncExternalStore: throwInvalidHookError, - useId: throwInvalidHookError, - useHostTransitionStatus: throwInvalidHookError, - useFormState: throwInvalidHookError, - useActionState: throwInvalidHookError, - useOptimistic: throwInvalidHookError, - useMemoCache: throwInvalidHookError, - useCacheRefresh: throwInvalidHookError -}; -ContextOnlyDispatcher.useEffectEvent = throwInvalidHookError; -var HooksDispatcherOnMount = { + readContext: readContext, + use: use, + useCallback: throwInvalidHookError, + useContext: throwInvalidHookError, + useEffect: throwInvalidHookError, + useImperativeHandle: throwInvalidHookError, + useLayoutEffect: throwInvalidHookError, + useInsertionEffect: throwInvalidHookError, + useMemo: throwInvalidHookError, + useReducer: throwInvalidHookError, + useRef: throwInvalidHookError, + useState: throwInvalidHookError, + useDebugValue: throwInvalidHookError, + useDeferredValue: throwInvalidHookError, + useTransition: throwInvalidHookError, + useSyncExternalStore: throwInvalidHookError, + useId: throwInvalidHookError, + useHostTransitionStatus: throwInvalidHookError, + useFormState: throwInvalidHookError, + useActionState: throwInvalidHookError, + useOptimistic: throwInvalidHookError, + useMemoCache: throwInvalidHookError, + useCacheRefresh: throwInvalidHookError, + useEffectEvent: throwInvalidHookError + }, + HooksDispatcherOnMount = { readContext: readContext, use: use, useCallback: function (callback, deps) { @@ -5304,62 +5596,62 @@ var HooksDispatcherOnMount = { return updateOptimisticImpl(hook, currentHook, passthrough, reducer); }, useMemoCache: useMemoCache, - useCacheRefresh: updateRefresh - }; -HooksDispatcherOnUpdate.useEffectEvent = updateEvent; -var HooksDispatcherOnRerender = { - readContext: readContext, - use: use, - useCallback: updateCallback, - useContext: readContext, - useEffect: updateEffect, - useImperativeHandle: updateImperativeHandle, - useInsertionEffect: updateInsertionEffect, - useLayoutEffect: updateLayoutEffect, - useMemo: updateMemo, - useReducer: rerenderReducer, - useRef: updateRef, - useState: function () { - return rerenderReducer(basicStateReducer); - }, - useDebugValue: mountDebugValue, - useDeferredValue: function (value, initialValue) { - var hook = updateWorkInProgressHook(); - return null === currentHook - ? mountDeferredValueImpl(hook, value, initialValue) - : updateDeferredValueImpl( - hook, - currentHook.memoizedState, - value, - initialValue - ); - }, - useTransition: function () { - var booleanOrThenable = rerenderReducer(basicStateReducer)[0], - start = updateWorkInProgressHook().memoizedState; - return [ - "boolean" === typeof booleanOrThenable - ? booleanOrThenable - : useThenable(booleanOrThenable), - start - ]; + useCacheRefresh: updateRefresh, + useEffectEvent: updateEvent }, - useSyncExternalStore: updateSyncExternalStore, - useId: updateId, - useHostTransitionStatus: useHostTransitionStatus, - useFormState: rerenderActionState, - useActionState: rerenderActionState, - useOptimistic: function (passthrough, reducer) { - var hook = updateWorkInProgressHook(); - if (null !== currentHook) - return updateOptimisticImpl(hook, currentHook, passthrough, reducer); - hook.baseState = passthrough; - return [passthrough, hook.queue.dispatch]; - }, - useMemoCache: useMemoCache, - useCacheRefresh: updateRefresh -}; -HooksDispatcherOnRerender.useEffectEvent = updateEvent; + HooksDispatcherOnRerender = { + readContext: readContext, + use: use, + useCallback: updateCallback, + useContext: readContext, + useEffect: updateEffect, + useImperativeHandle: updateImperativeHandle, + useInsertionEffect: updateInsertionEffect, + useLayoutEffect: updateLayoutEffect, + useMemo: updateMemo, + useReducer: rerenderReducer, + useRef: updateRef, + useState: function () { + return rerenderReducer(basicStateReducer); + }, + useDebugValue: mountDebugValue, + useDeferredValue: function (value, initialValue) { + var hook = updateWorkInProgressHook(); + return null === currentHook + ? mountDeferredValueImpl(hook, value, initialValue) + : updateDeferredValueImpl( + hook, + currentHook.memoizedState, + value, + initialValue + ); + }, + useTransition: function () { + var booleanOrThenable = rerenderReducer(basicStateReducer)[0], + start = updateWorkInProgressHook().memoizedState; + return [ + "boolean" === typeof booleanOrThenable + ? booleanOrThenable + : useThenable(booleanOrThenable), + start + ]; + }, + useSyncExternalStore: updateSyncExternalStore, + useId: updateId, + useHostTransitionStatus: useHostTransitionStatus, + useFormState: rerenderActionState, + useActionState: rerenderActionState, + useOptimistic: function (passthrough, reducer) { + var hook = updateWorkInProgressHook(); + if (null !== currentHook) + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + hook.baseState = passthrough; + return [passthrough, hook.queue.dispatch]; + }, + useMemoCache: useMemoCache, + useCacheRefresh: updateRefresh, + useEffectEvent: updateEvent + }; function applyDerivedStateFromProps( workInProgress, ctor, @@ -5501,9 +5793,9 @@ function resolveClassComponentProps(Component, baseProps) { } if ((Component = Component.defaultProps)) { newProps === baseProps && (newProps = assign({}, newProps)); - for (var propName$59 in Component) - void 0 === newProps[propName$59] && - (newProps[propName$59] = Component[propName$59]); + for (var propName$61 in Component) + void 0 === newProps[propName$61] && + (newProps[propName$61] = Component[propName$61]); } return newProps; } @@ -5611,6 +5903,7 @@ function throwException( switch (currentSourceFiber.tag) { case 31: case 13: + case 19: return ( sourceFiber.mode & 1 && (null === shellBoundary @@ -5710,17 +6003,17 @@ function throwException( !1 ); case 1: + sourceFiber = returnFiber.type; + currentSourceFiber = returnFiber.stateNode; if ( - ((sourceFiber = returnFiber.type), - (currentSourceFiber = returnFiber.stateNode), 0 === (returnFiber.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== currentSourceFiber && + "function" === typeof currentSourceFiber.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has( + currentSourceFiber + )))) ) return ( (returnFiber.flags |= 65536), @@ -5736,6 +6029,10 @@ function throwException( enqueueCapturedUpdate(returnFiber, rootRenderLanes), !1 ); + break; + case 22: + if (null !== returnFiber.memoizedState) + return (returnFiber.flags |= 65536), !1; } returnFiber = returnFiber.return; } while (null !== returnFiber); @@ -5940,11 +6237,11 @@ function updateOffscreenComponent( null !== prevState ? (pushTransition(workInProgress, prevState.cachePool), pushHiddenContext(workInProgress, prevState), - reuseSuspenseHandlerOnStack(workInProgress), + reuseSuspenseHandlerOnStack(), (workInProgress.memoizedState = null)) : (null !== current && pushTransition(workInProgress, null), reuseHiddenContextOnStack(), - reuseSuspenseHandlerOnStack(workInProgress)); + reuseSuspenseHandlerOnStack()); reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -6330,182 +6627,93 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { JSCompiler_temp = 0 !== (workInProgress.flags & 32); workInProgress.flags &= -33; if (null === current) { - var nextPrimaryChildren = nextProps.children; + didSuspend = nextProps.children; nextProps = nextProps.fallback; - if (showFallback) - return ( - reuseSuspenseHandlerOnStack(workInProgress), - (showFallback = workInProgress.mode), - (didSuspend = workInProgress.child), - (nextPrimaryChildren = { - mode: "hidden", - children: nextPrimaryChildren - }), - 0 === (showFallback & 1) && null !== didSuspend - ? ((didSuspend.childLanes = 0), - (didSuspend.pendingProps = nextPrimaryChildren), - workInProgress.mode & 2 && - ((didSuspend.actualDuration = -0), - (didSuspend.actualStartTime = -1.1), - (didSuspend.selfBaseDuration = -0), - (didSuspend.treeBaseDuration = -0))) - : (didSuspend = mountWorkInProgressOffscreenFiber( - nextPrimaryChildren, - showFallback - )), - (nextProps = createFiberFromFragment( - nextProps, - showFallback, - renderLanes, - null - )), - (didSuspend.return = workInProgress), - (nextProps.return = workInProgress), - (didSuspend.sibling = nextProps), - (workInProgress.child = didSuspend), - (nextProps = workInProgress.child), - (nextProps.memoizedState = mountSuspenseOffscreenState(renderLanes)), - (nextProps.childLanes = getRemainingWorkInPrimaryTree( - current, - JSCompiler_temp, - renderLanes - )), - (workInProgress.memoizedState = SUSPENDED_MARKER), - bailoutOffscreenComponent(null, nextProps) + if (showFallback) { + reuseSuspenseHandlerOnStack(); + showFallback = workInProgress.mode; + var progressedPrimaryFragment = workInProgress.child; + didSuspend = { mode: "hidden", children: didSuspend }; + 0 === (showFallback & 1) && null !== progressedPrimaryFragment + ? ((progressedPrimaryFragment.childLanes = 0), + (progressedPrimaryFragment.pendingProps = didSuspend), + workInProgress.mode & 2 && + ((progressedPrimaryFragment.actualDuration = -0), + (progressedPrimaryFragment.actualStartTime = -1.1), + (progressedPrimaryFragment.selfBaseDuration = -0), + (progressedPrimaryFragment.treeBaseDuration = -0))) + : (progressedPrimaryFragment = mountWorkInProgressOffscreenFiber( + didSuspend, + showFallback + )); + nextProps = createFiberFromFragment( + nextProps, + showFallback, + renderLanes, + null + ); + progressedPrimaryFragment.return = workInProgress; + nextProps.return = workInProgress; + progressedPrimaryFragment.sibling = nextProps; + workInProgress.child = progressedPrimaryFragment; + nextProps = workInProgress.child; + nextProps.memoizedState = mountSuspenseOffscreenState(renderLanes); + nextProps.childLanes = getRemainingWorkInPrimaryTree( + current, + JSCompiler_temp, + renderLanes ); + workInProgress.memoizedState = SUSPENDED_MARKER; + return bailoutOffscreenComponent(null, nextProps); + } pushPrimaryTreeSuspenseHandler(workInProgress); - return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren); - } - nextPrimaryChildren = current.memoizedState; - if (null !== nextPrimaryChildren && null !== nextPrimaryChildren.dehydrated) { - if (didSuspend) - workInProgress.flags & 256 - ? (pushPrimaryTreeSuspenseHandler(workInProgress), - (workInProgress.flags &= -257), - (workInProgress = retrySuspenseComponentWithoutHydrating( - current, - workInProgress, - renderLanes - ))) - : null !== workInProgress.memoizedState - ? (reuseSuspenseHandlerOnStack(workInProgress), - (workInProgress.child = current.child), - (workInProgress.flags |= 128), - (workInProgress = null)) - : (reuseSuspenseHandlerOnStack(workInProgress), - (showFallback = nextProps.fallback), - (nextPrimaryChildren = workInProgress.mode), - (nextProps = mountWorkInProgressOffscreenFiber( - { mode: "visible", children: nextProps.children }, - nextPrimaryChildren - )), - (showFallback = createFiberFromFragment( - showFallback, - nextPrimaryChildren, - renderLanes, - null - )), - (showFallback.flags |= 2), - (nextProps.return = workInProgress), - (showFallback.return = workInProgress), - (nextProps.sibling = showFallback), - (workInProgress.child = nextProps), - 0 !== (workInProgress.mode & 1) && - reconcileChildFibers( - workInProgress, - current.child, - null, - renderLanes - ), - (nextProps = workInProgress.child), - (nextProps.memoizedState = - mountSuspenseOffscreenState(renderLanes)), - (nextProps.childLanes = getRemainingWorkInPrimaryTree( - current, - JSCompiler_temp, - renderLanes - )), - (workInProgress.memoizedState = SUSPENDED_MARKER), - (workInProgress = bailoutOffscreenComponent(null, nextProps))); - else if ((pushPrimaryTreeSuspenseHandler(workInProgress), shim$1())) - (JSCompiler_temp = shim$1().digest), - (nextProps = Error( - "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." - )), - (nextProps.stack = ""), - (nextProps.digest = JSCompiler_temp), - (JSCompiler_temp = { value: nextProps, source: null, stack: null }), - null === hydrationErrors - ? (hydrationErrors = [JSCompiler_temp]) - : hydrationErrors.push(JSCompiler_temp), - (workInProgress = retrySuspenseComponentWithoutHydrating( - current, - workInProgress, - renderLanes - )); - else if ( - (didReceiveUpdate || - propagateParentContextChanges(current, workInProgress, renderLanes, !1), - (JSCompiler_temp = 0 !== (renderLanes & current.childLanes)), - didReceiveUpdate || JSCompiler_temp) - ) { - JSCompiler_temp = workInProgressRoot; - if ( - null !== JSCompiler_temp && - ((nextProps = getBumpedLaneForHydration(JSCompiler_temp, renderLanes)), - 0 !== nextProps && nextProps !== nextPrimaryChildren.retryLane) - ) - throw ( - ((nextPrimaryChildren.retryLane = nextProps), - enqueueConcurrentRenderForLane(current, nextProps), - scheduleUpdateOnFiber(JSCompiler_temp, current, nextProps), - SelectiveHydrationException) - ); - shim$1() || renderDidSuspendDelayIfPossible(); - workInProgress = retrySuspenseComponentWithoutHydrating( + return mountSuspensePrimaryChildren(workInProgress, didSuspend); + } + progressedPrimaryFragment = current.memoizedState; + if (null !== progressedPrimaryFragment) { + var dehydrated = progressedPrimaryFragment.dehydrated; + if (null !== dehydrated) + return updateDehydratedSuspenseComponent( current, workInProgress, + didSuspend, + JSCompiler_temp, + nextProps, + dehydrated, + progressedPrimaryFragment, renderLanes ); - } else - shim$1() - ? ((workInProgress.flags |= 192), - (workInProgress.child = current.child), - (workInProgress = null)) - : ((workInProgress = mountSuspensePrimaryChildren( - workInProgress, - nextProps.children - )), - (workInProgress.flags |= 4096)); - return workInProgress; } if (showFallback) { - reuseSuspenseHandlerOnStack(workInProgress); + reuseSuspenseHandlerOnStack(); showFallback = nextProps.fallback; - nextPrimaryChildren = workInProgress.mode; - didSuspend = current.child; - var currentFallbackChildFragment = didSuspend.sibling, - primaryChildProps = { mode: "hidden", children: nextProps.children }; - 0 === (nextPrimaryChildren & 1) && workInProgress.child !== didSuspend + didSuspend = workInProgress.mode; + progressedPrimaryFragment = current.child; + dehydrated = progressedPrimaryFragment.sibling; + var primaryChildProps = { mode: "hidden", children: nextProps.children }; + 0 === (didSuspend & 1) && workInProgress.child !== progressedPrimaryFragment ? ((nextProps = workInProgress.child), (nextProps.childLanes = 0), (nextProps.pendingProps = primaryChildProps), workInProgress.mode & 2 && ((nextProps.actualDuration = -0), (nextProps.actualStartTime = -1.1), - (nextProps.selfBaseDuration = didSuspend.selfBaseDuration), - (nextProps.treeBaseDuration = didSuspend.treeBaseDuration)), + (nextProps.selfBaseDuration = + progressedPrimaryFragment.selfBaseDuration), + (nextProps.treeBaseDuration = + progressedPrimaryFragment.treeBaseDuration)), (workInProgress.deletions = null)) - : ((nextProps = createWorkInProgress(didSuspend, primaryChildProps)), - (nextProps.subtreeFlags = didSuspend.subtreeFlags & 65011712)); - null !== currentFallbackChildFragment - ? (showFallback = createWorkInProgress( - currentFallbackChildFragment, - showFallback - )) + : ((nextProps = createWorkInProgress( + progressedPrimaryFragment, + primaryChildProps + )), + (nextProps.subtreeFlags = + progressedPrimaryFragment.subtreeFlags & 1206910976)); + null !== dehydrated + ? (showFallback = createWorkInProgress(dehydrated, showFallback)) : ((showFallback = createFiberFromFragment( showFallback, - nextPrimaryChildren, + didSuspend, renderLanes, null )), @@ -6519,17 +6727,20 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { showFallback = current.child.memoizedState; null === showFallback ? (showFallback = mountSuspenseOffscreenState(renderLanes)) - : ((nextPrimaryChildren = showFallback.cachePool), - null !== nextPrimaryChildren - ? ((didSuspend = CacheContext._currentValue2), - (nextPrimaryChildren = - nextPrimaryChildren.parent !== didSuspend - ? { parent: didSuspend, pool: didSuspend } - : nextPrimaryChildren)) - : (nextPrimaryChildren = getSuspendedCache()), + : ((didSuspend = showFallback.cachePool), + null !== didSuspend + ? ((progressedPrimaryFragment = CacheContext._currentValue2), + (didSuspend = + didSuspend.parent !== progressedPrimaryFragment + ? { + parent: progressedPrimaryFragment, + pool: progressedPrimaryFragment + } + : didSuspend)) + : (didSuspend = getSuspendedCache()), (showFallback = { baseLanes: showFallback.baseLanes | renderLanes, - cachePool: nextPrimaryChildren + cachePool: didSuspend })); nextProps.memoizedState = showFallback; nextProps.childLanes = getRemainingWorkInPrimaryTree( @@ -6586,52 +6797,201 @@ function retrySuspenseComponentWithoutHydrating( workInProgress.memoizedState = null; return current; } -function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) { - fiber.lanes |= renderLanes; - var alternate = fiber.alternate; - null !== alternate && (alternate.lanes |= renderLanes); - scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot); -} -function initSuspenseListRenderState( +function updateDehydratedSuspenseComponent( + current, workInProgress, - isBackwards, - tail, - lastContentRow, - tailMode, - treeForkCount + didSuspend, + didPrimaryChildrenDefer, + nextProps, + suspenseInstance, + suspenseState, + renderLanes ) { - var renderState = workInProgress.memoizedState; - null === renderState - ? (workInProgress.memoizedState = { - isBackwards: isBackwards, - rendering: null, - renderingStartTime: 0, - last: lastContentRow, - tail: tail, - tailMode: tailMode, - treeForkCount: treeForkCount - }) - : ((renderState.isBackwards = isBackwards), - (renderState.rendering = null), - (renderState.renderingStartTime = 0), - (renderState.last = lastContentRow), - (renderState.tail = tail), - (renderState.tailMode = tailMode), - (renderState.treeForkCount = treeForkCount)); + if (didSuspend) { + if (workInProgress.flags & 256) + return ( + pushPrimaryTreeSuspenseHandler(workInProgress), + (workInProgress.flags &= -257), + retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ) + ); + if (null !== workInProgress.memoizedState) + return ( + reuseSuspenseHandlerOnStack(), + (workInProgress.child = current.child), + (workInProgress.flags |= 128), + null + ); + reuseSuspenseHandlerOnStack(); + suspenseState = nextProps.fallback; + didSuspend = workInProgress.mode; + nextProps = mountWorkInProgressOffscreenFiber( + { mode: "visible", children: nextProps.children }, + didSuspend + ); + suspenseState = createFiberFromFragment( + suspenseState, + didSuspend, + renderLanes, + null + ); + suspenseState.flags |= 2; + nextProps.return = workInProgress; + suspenseState.return = workInProgress; + nextProps.sibling = suspenseState; + workInProgress.child = nextProps; + 0 !== (workInProgress.mode & 1) && + reconcileChildFibers(workInProgress, current.child, null, renderLanes); + nextProps = workInProgress.child; + nextProps.memoizedState = mountSuspenseOffscreenState(renderLanes); + nextProps.childLanes = getRemainingWorkInPrimaryTree( + current, + didPrimaryChildrenDefer, + renderLanes + ); + workInProgress.memoizedState = SUSPENDED_MARKER; + return bailoutOffscreenComponent(null, nextProps); + } + pushPrimaryTreeSuspenseHandler(workInProgress); + if (shim$1()) + return ( + (didPrimaryChildrenDefer = shim$1().digest), + "" !== didPrimaryChildrenDefer && + ((nextProps = Error( + "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." + )), + (nextProps.stack = ""), + (nextProps.digest = didPrimaryChildrenDefer), + (didPrimaryChildrenDefer = { + value: nextProps, + source: null, + stack: null + }), + null === hydrationErrors + ? (hydrationErrors = [didPrimaryChildrenDefer]) + : hydrationErrors.push(didPrimaryChildrenDefer)), + retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ) + ); + didReceiveUpdate || + propagateParentContextChanges(current, workInProgress, renderLanes, !1); + didPrimaryChildrenDefer = 0 !== (renderLanes & current.childLanes); + if (didReceiveUpdate || didPrimaryChildrenDefer) { + if (null !== currentTreeHiddenStackCursor.current) + return retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ); + didPrimaryChildrenDefer = workInProgressRoot; + if ( + null !== didPrimaryChildrenDefer && + ((nextProps = getBumpedLaneForHydration( + didPrimaryChildrenDefer, + renderLanes + )), + 0 !== nextProps && nextProps !== suspenseState.retryLane) + ) + throw ( + ((suspenseState.retryLane = nextProps), + enqueueConcurrentRenderForLane(current, nextProps), + scheduleUpdateOnFiber(didPrimaryChildrenDefer, current, nextProps), + SelectiveHydrationException) + ); + shim$1() || renderDidSuspendDelayIfPossible(); + return retrySuspenseComponentWithoutHydrating( + current, + workInProgress, + renderLanes + ); + } + if (shim$1()) + return ( + (workInProgress.flags |= 192), + (workInProgress.child = current.child), + null + ); + current = mountSuspensePrimaryChildren(workInProgress, nextProps.children); + current.flags |= 134221824; + return current; +} +function scheduleSuspenseWorkOnFiber(fiber, renderLanes, propagationRoot) { + fiber.lanes |= renderLanes; + var alternate = fiber.alternate; + null !== alternate && (alternate.lanes |= renderLanes); + scheduleContextWorkOnParentPath(fiber.return, renderLanes, propagationRoot); +} +function findLastContentRow(firstChild) { + for (var lastContentRow = null; null !== firstChild; ) { + var currentRow = firstChild.alternate; + null !== currentRow && + null === findFirstSuspended(currentRow) && + (lastContentRow = firstChild); + firstChild = firstChild.sibling; + } + return lastContentRow; +} +function initSuspenseListRenderState( + workInProgress, + isBackwards, + tail, + lastContentRow, + tailMode, + treeForkCount +) { + var renderState = workInProgress.memoizedState; + null === renderState + ? (workInProgress.memoizedState = { + isBackwards: isBackwards, + rendering: null, + renderingStartTime: 0, + last: lastContentRow, + tail: tail, + tailMode: tailMode, + treeForkCount: treeForkCount + }) + : ((renderState.isBackwards = isBackwards), + (renderState.rendering = null), + (renderState.renderingStartTime = 0), + (renderState.last = lastContentRow), + (renderState.tail = tail), + (renderState.tailMode = tailMode), + (renderState.treeForkCount = treeForkCount)); +} +function reverseChildren(fiber) { + var row = fiber.child; + for (fiber.child = null; null !== row; ) { + var nextRow = row.sibling; + row.sibling = fiber.child; + fiber.child = row; + row = nextRow; + } } function updateSuspenseListComponent(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; nextProps = nextProps.children; - var suspenseContext = suspenseStackCursor.current, - shouldForceFallback = 0 !== (suspenseContext & 2); + var suspenseContext = suspenseStackCursor.current; + if (workInProgress.flags & 128) + return pushSuspenseListContext(workInProgress, suspenseContext), null; + var shouldForceFallback = 0 !== (suspenseContext & 2); shouldForceFallback ? ((suspenseContext = (suspenseContext & 1) | 2), (workInProgress.flags |= 128)) : (suspenseContext &= 1); - push(suspenseStackCursor, suspenseContext); - reconcileChildren(current, workInProgress, nextProps, renderLanes); + pushSuspenseListContext(workInProgress, suspenseContext); + "backwards" === revealOrder && null !== current + ? (reverseChildren(current), + reconcileChildren(current, workInProgress, nextProps, renderLanes), + reverseChildren(current)) + : reconcileChildren(current, workInProgress, nextProps, renderLanes); if (!shouldForceFallback && null !== current && 0 !== (current.flags & 128)) a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) @@ -6656,29 +7016,23 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { if (0 === (workInProgress.mode & 1)) workInProgress.memoizedState = null; else switch (revealOrder) { - case "forwards": - renderLanes = workInProgress.child; - for (revealOrder = null; null !== renderLanes; ) - (current = renderLanes.alternate), - null !== current && - null === findFirstSuspended(current) && - (revealOrder = renderLanes), - (renderLanes = renderLanes.sibling); - renderLanes = revealOrder; + case "backwards": + renderLanes = findLastContentRow(workInProgress.child); null === renderLanes ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); + : ((revealOrder = renderLanes.sibling), + (renderLanes.sibling = null), + reverseChildren(workInProgress)); initSuspenseListRenderState( workInProgress, - !1, + !0, revealOrder, - renderLanes, + null, tailMode, 0 ); break; - case "backwards": case "unstable_legacy-backwards": renderLanes = null; revealOrder = workInProgress.child; @@ -6705,11 +7059,33 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { case "together": initSuspenseListRenderState(workInProgress, !1, null, null, void 0, 0); break; - default: + case "independent": workInProgress.memoizedState = null; + break; + default: + (renderLanes = findLastContentRow(workInProgress.child)), + null === renderLanes + ? ((revealOrder = workInProgress.child), + (workInProgress.child = null)) + : ((revealOrder = renderLanes.sibling), + (renderLanes.sibling = null)), + initSuspenseListRenderState( + workInProgress, + !1, + revealOrder, + renderLanes, + tailMode, + 0 + ); } return workInProgress.child; } +function updateContextProvider(current, workInProgress, renderLanes) { + var newProps = workInProgress.pendingProps; + pushProvider(workInProgress, workInProgress.type, newProps.value); + reconcileChildren(current, workInProgress, newProps.children, renderLanes); + return workInProgress.child; +} function resetSuspendedCurrentOnMountInLegacyMode(current, workInProgress) { 0 === (workInProgress.mode & 1) && null !== current && @@ -6803,7 +7179,14 @@ function attemptEarlyBailoutIfNoScheduledUpdate( (workInProgress.flags |= 128), null ); - if (0 !== (renderLanes & workInProgress.child.childLanes)) + stateNode = propagateParentContextChanges( + current, + workInProgress, + renderLanes, + !1 + ); + var primaryChildLanes = workInProgress.child.childLanes; + if (stateNode || 0 !== (renderLanes & primaryChildLanes)) return updateSuspenseComponent(current, workInProgress, renderLanes); pushPrimaryTreeSuspenseHandler(workInProgress); current = bailoutOnAlreadyFinishedWork( @@ -6816,7 +7199,13 @@ function attemptEarlyBailoutIfNoScheduledUpdate( pushPrimaryTreeSuspenseHandler(workInProgress); break; case 19: - var didSuspendBefore = 0 !== (current.flags & 128); + if (workInProgress.flags & 128) + return updateSuspenseListComponent( + current, + workInProgress, + renderLanes + ); + primaryChildLanes = 0 !== (current.flags & 128); stateNode = 0 !== (renderLanes & workInProgress.childLanes); stateNode || (propagateParentContextChanges( @@ -6826,7 +7215,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate( !1 ), (stateNode = 0 !== (renderLanes & workInProgress.childLanes))); - if (didSuspendBefore) { + if (primaryChildLanes) { if (stateNode) return updateSuspenseListComponent( current, @@ -6835,12 +7224,12 @@ function attemptEarlyBailoutIfNoScheduledUpdate( ); workInProgress.flags |= 128; } - didSuspendBefore = workInProgress.memoizedState; - null !== didSuspendBefore && - ((didSuspendBefore.rendering = null), - (didSuspendBefore.tail = null), - (didSuspendBefore.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); + primaryChildLanes = workInProgress.memoizedState; + null !== primaryChildLanes && + ((primaryChildLanes.rendering = null), + (primaryChildLanes.tail = null), + (primaryChildLanes.lastEffect = null)); + pushSuspenseListContext(workInProgress, suspenseStackCursor.current); if (stateNode) break; else return null; case 22: @@ -6930,6 +7319,15 @@ function beginWork(current, workInProgress, renderLanes) { renderLanes ); break a; + } else if ($$typeof === REACT_CONTEXT_TYPE) { + workInProgress.tag = 10; + workInProgress.type = elementType; + workInProgress = updateContextProvider( + null, + workInProgress, + renderLanes + ); + break a; } } workInProgress = getComponentNameFromType(elementType) || elementType; @@ -7049,12 +7447,9 @@ function beginWork(current, workInProgress, renderLanes) { ); case 7: return ( - reconcileChildren( - current, - workInProgress, - workInProgress.pendingProps, - renderLanes - ), + (elementType = workInProgress.pendingProps), + markRef(current, workInProgress), + reconcileChildren(current, workInProgress, elementType, renderLanes), workInProgress.child ); case 8: @@ -7083,17 +7478,7 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress.child ); case 10: - return ( - (elementType = workInProgress.pendingProps), - pushProvider(workInProgress, workInProgress.type, elementType.value), - reconcileChildren( - current, - workInProgress, - elementType.children, - renderLanes - ), - workInProgress.child - ); + return updateContextProvider(current, workInProgress, renderLanes); case 9: return ( ($$typeof = workInProgress.type._context), @@ -7199,19 +7584,21 @@ function beginWork(current, workInProgress, renderLanes) { ); nextProps = 0 !== (renderLanes & current.childLanes); if (didReceiveUpdate || nextProps) { - $$typeof = workInProgressRoot; - if ( - null !== $$typeof && - ((nextProps = getBumpedLaneForHydration($$typeof, renderLanes)), - 0 !== nextProps && nextProps !== elementType.retryLane) - ) - throw ( - ((elementType.retryLane = nextProps), - enqueueConcurrentRenderForLane(current, nextProps), - scheduleUpdateOnFiber($$typeof, current, nextProps), - SelectiveHydrationException) - ); - renderDidSuspendDelayIfPossible(); + if (null === currentTreeHiddenStackCursor.current) { + $$typeof = workInProgressRoot; + if ( + null !== $$typeof && + ((nextProps = getBumpedLaneForHydration($$typeof, renderLanes)), + 0 !== nextProps && nextProps !== elementType.retryLane) + ) + throw ( + ((elementType.retryLane = nextProps), + enqueueConcurrentRenderForLane(current, nextProps), + scheduleUpdateOnFiber($$typeof, current, nextProps), + SelectiveHydrationException) + ); + renderDidSuspendDelayIfPossible(); + } workInProgress = retryActivityComponentWithoutHydrating( current, workInProgress, @@ -7219,7 +7606,7 @@ function beginWork(current, workInProgress, renderLanes) { ); } else (workInProgress = mountActivityChildren(workInProgress, $$typeof)), - (workInProgress.flags |= 4096); + (workInProgress.flags |= 134221824); } else (renderLanes = createWorkInProgress(current.child, { @@ -7288,6 +7675,30 @@ function beginWork(current, workInProgress, renderLanes) { ), workInProgress.child ); + case 30: + return ( + null === workInProgress.stateNode && + (workInProgress.stateNode = { + autoName: null, + paired: null, + clones: null, + ref: null + }), + (elementType = workInProgress.pendingProps), + null != elementType.name && + "auto" !== elementType.name && + (workInProgress.flags |= null === current ? 18882560 : 18874368), + null !== current && current.memoizedProps.name !== elementType.name + ? (workInProgress.flags |= 4194816) + : markRef(current, workInProgress), + reconcileChildren( + current, + workInProgress, + elementType.children, + renderLanes + ), + workInProgress.child + ); case 29: throw workInProgress.pendingProps; } @@ -7408,26 +7819,29 @@ function scheduleRetryEffect(workInProgress, retryQueue) { } function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { switch (renderState.tailMode) { - case "hidden": - hasRenderedATailFallback = renderState.tail; - for (var lastTailNode = null; null !== hasRenderedATailFallback; ) - null !== hasRenderedATailFallback.alternate && - (lastTailNode = hasRenderedATailFallback), - (hasRenderedATailFallback = hasRenderedATailFallback.sibling); - null === lastTailNode - ? (renderState.tail = null) - : (lastTailNode.sibling = null); + case "visible": break; case "collapsed": - lastTailNode = renderState.tail; - for (var lastTailNode$92 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$92 = lastTailNode), - (lastTailNode = lastTailNode.sibling); - null === lastTailNode$92 + for ( + var tailNode = renderState.tail, lastTailNode = null; + null !== tailNode; + + ) + null !== tailNode.alternate && (lastTailNode = tailNode), + (tailNode = tailNode.sibling); + null === lastTailNode ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$92.sibling = null); + : (lastTailNode.sibling = null); + break; + default: + hasRenderedATailFallback = renderState.tail; + for (tailNode = null; null !== hasRenderedATailFallback; ) + null !== hasRenderedATailFallback.alternate && + (tailNode = hasRenderedATailFallback), + (hasRenderedATailFallback = hasRenderedATailFallback.sibling); + null === tailNode ? (renderState.tail = null) : (tailNode.sibling = null); } } function bubbleProperties(completedWork) { @@ -7439,53 +7853,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$94 = completedWork.selfBaseDuration, - child$95 = completedWork.child; - null !== child$95; + var treeBaseDuration$98 = completedWork.selfBaseDuration, + child$99 = completedWork.child; + null !== child$99; ) - (newChildLanes |= child$95.lanes | child$95.childLanes), - (subtreeFlags |= child$95.subtreeFlags & 65011712), - (subtreeFlags |= child$95.flags & 65011712), - (treeBaseDuration$94 += child$95.treeBaseDuration), - (child$95 = child$95.sibling); - completedWork.treeBaseDuration = treeBaseDuration$94; + (newChildLanes |= child$99.lanes | child$99.childLanes), + (subtreeFlags |= child$99.subtreeFlags & 1206910976), + (subtreeFlags |= child$99.flags & 1206910976), + (treeBaseDuration$98 += child$99.treeBaseDuration), + (child$99 = child$99.sibling); + completedWork.treeBaseDuration = treeBaseDuration$98; } else for ( - treeBaseDuration$94 = completedWork.child; - null !== treeBaseDuration$94; + treeBaseDuration$98 = completedWork.child; + null !== treeBaseDuration$98; ) (newChildLanes |= - treeBaseDuration$94.lanes | treeBaseDuration$94.childLanes), - (subtreeFlags |= treeBaseDuration$94.subtreeFlags & 65011712), - (subtreeFlags |= treeBaseDuration$94.flags & 65011712), - (treeBaseDuration$94.return = completedWork), - (treeBaseDuration$94 = treeBaseDuration$94.sibling); + treeBaseDuration$98.lanes | treeBaseDuration$98.childLanes), + (subtreeFlags |= treeBaseDuration$98.subtreeFlags & 1206910976), + (subtreeFlags |= treeBaseDuration$98.flags & 1206910976), + (treeBaseDuration$98.return = completedWork), + (treeBaseDuration$98 = treeBaseDuration$98.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$94 = completedWork.actualDuration; - child$95 = completedWork.selfBaseDuration; + treeBaseDuration$98 = completedWork.actualDuration; + child$99 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$94 += child.actualDuration), - (child$95 += child.treeBaseDuration), + (treeBaseDuration$98 += child.actualDuration), + (child$99 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$94; - completedWork.treeBaseDuration = child$95; + completedWork.actualDuration = treeBaseDuration$98; + completedWork.treeBaseDuration = child$99; } else for ( - treeBaseDuration$94 = completedWork.child; - null !== treeBaseDuration$94; + treeBaseDuration$98 = completedWork.child; + null !== treeBaseDuration$98; ) (newChildLanes |= - treeBaseDuration$94.lanes | treeBaseDuration$94.childLanes), - (subtreeFlags |= treeBaseDuration$94.subtreeFlags), - (subtreeFlags |= treeBaseDuration$94.flags), - (treeBaseDuration$94.return = completedWork), - (treeBaseDuration$94 = treeBaseDuration$94.sibling); + treeBaseDuration$98.lanes | treeBaseDuration$98.childLanes), + (subtreeFlags |= treeBaseDuration$98.subtreeFlags), + (subtreeFlags |= treeBaseDuration$98.flags), + (treeBaseDuration$98.return = completedWork), + (treeBaseDuration$98 = treeBaseDuration$98.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -7541,7 +7955,7 @@ function completeWork(current, workInProgress, renderLanes) { type !== newProps) ) { b: { - type = ReactNativePrivateInterface.diffAttributePayloads( + type = reactPrivateInterface.diffAttributePayloads( type, newProps, renderLanes.canonical.viewConfig.validAttributes @@ -7574,13 +7988,13 @@ function completeWork(current, workInProgress, renderLanes) { "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); bubbleProperties(workInProgress); + workInProgress.subtreeFlags &= -33554433; return null; } current = rootInstanceStackCursor.current; - renderLanes = nextReactTag; - nextReactTag += 2; + renderLanes = allocateTag(); type = getViewConfigForType(type); - var updatePayload = ReactNativePrivateInterface.createAttributePayload( + var updatePayload = reactPrivateInterface.createAttributePayload( newProps, type.validAttributes ); @@ -7606,6 +8020,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgress.stateNode = current; } bubbleProperties(workInProgress); + workInProgress.subtreeFlags &= -33554433; workInProgress.flags &= -16777217; return null; case 6: @@ -7756,6 +8171,7 @@ function completeWork(current, workInProgress, renderLanes) { return ( popHostContainer(), updateHostContainer(current, workInProgress), + (workInProgress.flags |= 67108864), bubbleProperties(workInProgress), null ); @@ -7766,13 +8182,13 @@ function completeWork(current, workInProgress, renderLanes) { case 17: return bubbleProperties(workInProgress), null; case 19: - pop(suspenseStackCursor); - type = workInProgress.memoizedState; - if (null === type) return bubbleProperties(workInProgress), null; - newProps = 0 !== (workInProgress.flags & 128); - updatePayload = type.rendering; + popSuspenseListContext(workInProgress); + newProps = workInProgress.memoizedState; + if (null === newProps) return bubbleProperties(workInProgress), null; + type = 0 !== (workInProgress.flags & 128); + updatePayload = newProps.rendering; if (null === updatePayload) - if (newProps) cutOffTailIfNeeded(type, !1); + if (type) cutOffTailIfNeeded(newProps, !1); else { if ( 0 !== workInProgressRootExitStatus || @@ -7782,7 +8198,7 @@ function completeWork(current, workInProgress, renderLanes) { updatePayload = findFirstSuspended(current); if (null !== updatePayload) { workInProgress.flags |= 128; - cutOffTailIfNeeded(type, !1); + cutOffTailIfNeeded(newProps, !1); current = updatePayload.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); @@ -7791,66 +8207,84 @@ function completeWork(current, workInProgress, renderLanes) { for (renderLanes = workInProgress.child; null !== renderLanes; ) resetWorkInProgress(renderLanes, current), (renderLanes = renderLanes.sibling); - push( - suspenseStackCursor, + pushSuspenseListContext( + workInProgress, (suspenseStackCursor.current & 1) | 2 ); return workInProgress.child; } current = current.sibling; } - null !== type.tail && + null !== newProps.tail && now$1() > workInProgressRootRenderTargetTime && ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), + (type = !0), + cutOffTailIfNeeded(newProps, !1), (workInProgress.lanes = 4194304)); } else { - if (!newProps) + if (!type) if ( ((current = findFirstSuspended(updatePayload)), null !== current) ) { if ( ((workInProgress.flags |= 128), - (newProps = !0), + (type = !0), (current = current.updateQueue), (workInProgress.updateQueue = current), scheduleRetryEffect(workInProgress, current), - cutOffTailIfNeeded(type, !0), - null === type.tail && - "hidden" === type.tailMode && + cutOffTailIfNeeded(newProps, !0), + null === newProps.tail && + "collapsed" !== newProps.tailMode && + "visible" !== newProps.tailMode && !updatePayload.alternate) ) return bubbleProperties(workInProgress), null; } else - 2 * now$1() - type.renderingStartTime > + 2 * now$1() - newProps.renderingStartTime > workInProgressRootRenderTargetTime && 536870912 !== renderLanes && ((workInProgress.flags |= 128), - (newProps = !0), - cutOffTailIfNeeded(type, !1), + (type = !0), + cutOffTailIfNeeded(newProps, !1), (workInProgress.lanes = 4194304)); - type.isBackwards + newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) - : ((current = type.last), + : ((current = newProps.last), null !== current ? (current.sibling = updatePayload) : (workInProgress.child = updatePayload), - (type.last = updatePayload)); + (newProps.last = updatePayload)); + } + if (null !== newProps.tail) { + current = newProps.tail; + a: { + for (renderLanes = current; null !== renderLanes; ) { + if (null !== renderLanes.alternate) { + renderLanes = !1; + break a; + } + renderLanes = renderLanes.sibling; + } + renderLanes = !0; + } + newProps.rendering = current; + newProps.tail = current.sibling; + newProps.renderingStartTime = now$1(); + current.sibling = null; + updatePayload = suspenseStackCursor.current; + updatePayload = type ? (updatePayload & 1) | 2 : updatePayload & 1; + "visible" !== newProps.tailMode && + "collapsed" !== newProps.tailMode && + renderLanes + ? ((renderLanes = updatePayload), + push(suspenseHandlerStackCursor, workInProgress), + push(suspenseStackCursor, renderLanes), + null === shellBoundary && (shellBoundary = workInProgress)) + : pushSuspenseListContext(workInProgress, updatePayload); + return current; } - if (null !== type.tail) - return ( - (workInProgress = type.tail), - (type.rendering = workInProgress), - (type.tail = workInProgress.sibling), - (type.renderingStartTime = now$1()), - (workInProgress.sibling = null), - (current = suspenseStackCursor.current), - push(suspenseStackCursor, newProps ? (current & 1) | 2 : current & 1), - workInProgress - ); bubbleProperties(workInProgress); return null; case 22: @@ -7898,7 +8332,11 @@ function completeWork(current, workInProgress, renderLanes) { case 25: return null; case 30: - return null; + return ( + (workInProgress.flags |= 33554432), + bubbleProperties(workInProgress), + null + ); case 29: return null; } @@ -7967,7 +8405,18 @@ function unwindWork(current, workInProgress) { workInProgress) : null; case 19: - return pop(suspenseStackCursor), null; + return ( + popSuspenseListContext(workInProgress), + (current = workInProgress.flags), + current & 65536 + ? ((workInProgress.flags = (current & -65537) | 128), + (current = workInProgress.memoizedState), + null !== current && + ((current.rendering = null), (current.tail = null)), + (workInProgress.flags |= 4), + workInProgress) + : null + ); case 4: return popHostContainer(), null; case 10: @@ -8016,7 +8465,7 @@ function unwindInterruptedWork(current, interruptedWork) { popSuspenseHandler(interruptedWork); break; case 19: - pop(suspenseStackCursor); + popSuspenseListContext(interruptedWork); break; case 10: popProvider(interruptedWork.type); @@ -8178,8 +8627,8 @@ function safelyCallComponentWillUnmount( } else try { instance.componentWillUnmount(); - } catch (error$128) { - captureCommitPhaseError(current, nearestMountedAncestor, error$128); + } catch (error$133) { + captureCommitPhaseError(current, nearestMountedAncestor, error$133); } } function safelyAttachRef(current, nearestMountedAncestor) { @@ -8193,6 +8642,25 @@ function safelyAttachRef(current, nearestMountedAncestor) { var instanceToUse = getPublicInstance(current.stateNode); break; case 30: + var instance = current.stateNode, + name = getViewTransitionName(current.memoizedProps, instance); + if (null === instance.ref || instance.ref.name !== name) + instance.ref = createViewTransitionInstance(name); + instanceToUse = instance.ref; + break; + case 7: + if (null === current.stateNode) { + var fragmentInstance = new FragmentInstance(current); + traverseVisibleInstancesAndTextInstances( + current.child, + !1, + addFragmentHandleToFiber, + fragmentInstance, + void 0, + void 0 + ); + current.stateNode = fragmentInstance; + } instanceToUse = current.stateNode; break; default: @@ -8241,8 +8709,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordEffectDuration(current); } else ref(null); - } catch (error$129) { - captureCommitPhaseError(current, nearestMountedAncestor, error$129); + } catch (error$135) { + captureCommitPhaseError(current, nearestMountedAncestor, error$135); } else ref.current = null; } @@ -8274,6 +8742,40 @@ function commitProfilerUpdate( captureCommitPhaseError(finishedWork, finishedWork.return, error); } } +var viewTransitionMutationContext = !1; +function pushMutationContext() { + var prev = viewTransitionMutationContext; + viewTransitionMutationContext = !1; + return prev; +} +function commitFragmentInstanceInsertionEffects(fiber) { + for (var parent = fiber.return; null !== parent; ) { + isFragmentInstanceParent(parent) && + commitNewChildToFragmentInstance(fiber.stateNode, parent.stateNode); + if (isFragmentInstanceHostBoundary(parent)) break; + parent = parent.return; + } +} +function commitFragmentInstanceDeletionEffects(fiber) { + for (var parent = fiber.return; null !== parent; ) { + if (isFragmentInstanceParent(parent)) { + var fragmentInstance = parent.stateNode; + var childInstance = fiber.stateNode; + null != childInstance.canonical && + ((childInstance = getPublicInstance(childInstance)), + null != childInstance.reactFragments && + childInstance.reactFragments.delete(fragmentInstance)); + } + if (isFragmentInstanceHostBoundary(parent)) break; + parent = parent.return; + } +} +function isFragmentInstanceHostBoundary(fiber) { + return 5 === fiber.tag || 3 === fiber.tag || !1; +} +function isFragmentInstanceParent(fiber) { + return fiber && 7 === fiber.tag && null !== fiber.stateNode; +} function commitHostMount(finishedWork) { try { throw Error( @@ -8283,6 +8785,42 @@ function commitHostMount(finishedWork) { captureCommitPhaseError(finishedWork, finishedWork.return, error); } } +function commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances +) { + if (5 === finishedWork.tag) { + if ( + (5 === finishedWork.tag || + 27 === finishedWork.tag || + 6 === finishedWork.tag) && + null === finishedWork.alternate && + null !== parentFragmentInstances + ) + for (var i = 0; i < parentFragmentInstances.length; i++) + commitNewChildToFragmentInstance( + finishedWork.stateNode, + parentFragmentInstances[i] + ); + } else if ( + 4 !== finishedWork.tag && + ((finishedWork = finishedWork.child), null !== finishedWork) + ) + for ( + commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ), + finishedWork = finishedWork.sibling; + null !== finishedWork; + + ) + commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ), + (finishedWork = finishedWork.sibling); +} function commitHostPortalContainerChildren( portal, finishedWork, @@ -8295,12 +8833,200 @@ function commitHostPortalContainerChildren( captureCommitPhaseError(finishedWork, finishedWork.return, error); } } +var shouldStartViewTransition = !1, + appearingViewTransitions = null; +function trackEnterViewTransitions(placement) { + if (30 === placement.tag || 0 !== (placement.subtreeFlags & 33554432)) + shouldStartViewTransition = !0; +} +var viewTransitionCancelableChildren = null; +function pushViewTransitionCancelableScope() { + var prevChildren = viewTransitionCancelableChildren; + viewTransitionCancelableChildren = null; + return prevChildren; +} +var viewTransitionHostInstanceIdx = 0; +function applyViewTransitionToHostInstances() { + viewTransitionHostInstanceIdx = 0; + return !1; +} +function commitAppearingPairViewTransitions(placement) { + if (0 !== (placement.subtreeFlags & 18874368)) + for (placement = placement.child; null !== placement; ) { + if (22 !== placement.tag || null === placement.memoizedState) + if ( + (commitAppearingPairViewTransitions(placement), + 30 === placement.tag && + 0 !== (placement.flags & 18874368) && + placement.stateNode.paired) + ) { + var props = placement.memoizedProps; + if (null == props.name || "auto" === props.name) + throw Error( + "Found a pair with an auto name. This is a bug in React." + ); + "none" !== getViewTransitionClassName(props.default, props.share) && + applyViewTransitionToHostInstances(); + } + placement = placement.sibling; + } +} +function commitEnterViewTransitions(placement, gesture) { + if (30 === placement.tag) { + var state = placement.stateNode, + props = placement.memoizedProps; + getViewTransitionName(props, state); + "none" !== + getViewTransitionClassName( + props.default, + state.paired ? props.share : props.enter + ) + ? applyViewTransitionToHostInstances() && + (commitAppearingPairViewTransitions(placement), + state.paired || + gesture || + scheduleViewTransitionEvent(placement, props.onEnter)) + : commitAppearingPairViewTransitions(placement); + } else if (0 !== (placement.subtreeFlags & 33554432)) + for (placement = placement.child; null !== placement; ) + commitEnterViewTransitions(placement, gesture), + (placement = placement.sibling); + else commitAppearingPairViewTransitions(placement); +} +function commitDeletedPairViewTransitions(deletion) { + if ( + null !== appearingViewTransitions && + 0 !== appearingViewTransitions.size + ) { + var pairs = appearingViewTransitions; + if (0 !== (deletion.subtreeFlags & 18874368)) + for (deletion = deletion.child; null !== deletion; ) { + if (22 !== deletion.tag || null === deletion.memoizedState) { + if (30 === deletion.tag && 0 !== (deletion.flags & 18874368)) { + var props = deletion.memoizedProps, + name = props.name; + if (null != name && "auto" !== name) { + var pair = pairs.get(name); + if (void 0 !== pair) { + if ( + "none" !== + getViewTransitionClassName(props.default, props.share) && + applyViewTransitionToHostInstances() + ) { + var oldInstance = deletion.stateNode; + pair.paired = oldInstance; + oldInstance.paired = pair; + scheduleViewTransitionEvent(deletion, props.onShare); + } + pairs.delete(name); + if (0 === pairs.size) break; + } + } + } + commitDeletedPairViewTransitions(deletion); + } + deletion = deletion.sibling; + } + } +} +function commitExitViewTransitions(deletion) { + if (30 === deletion.tag) { + var props = deletion.memoizedProps, + name = getViewTransitionName(props, deletion.stateNode), + pair = + null !== appearingViewTransitions + ? appearingViewTransitions.get(name) + : void 0; + if ( + "none" !== + getViewTransitionClassName( + props.default, + void 0 !== pair ? props.share : props.exit + ) && + applyViewTransitionToHostInstances() + ) + if (void 0 !== pair) { + var oldInstance = deletion.stateNode; + pair.paired = oldInstance; + oldInstance.paired = pair; + appearingViewTransitions.delete(name); + scheduleViewTransitionEvent(deletion, props.onShare); + } else scheduleViewTransitionEvent(deletion, props.onExit); + null !== appearingViewTransitions && + commitDeletedPairViewTransitions(deletion); + } else if (0 !== (deletion.subtreeFlags & 33554432)) + for (deletion = deletion.child; null !== deletion; ) + commitExitViewTransitions(deletion), (deletion = deletion.sibling); + else + null !== appearingViewTransitions && + commitDeletedPairViewTransitions(deletion); +} +function commitNestedViewTransitions(changedParent) { + for (changedParent = changedParent.child; null !== changedParent; ) { + if (30 === changedParent.tag) { + var props = changedParent.memoizedProps, + name = getViewTransitionName(props, changedParent.stateNode); + props = getViewTransitionClassName(props.default, props.update); + changedParent.flags &= -5; + "none" !== props && + applyViewTransitionToHostInstances( + changedParent, + name, + props, + (changedParent.memoizedState = []) + ); + } else + 0 !== (changedParent.subtreeFlags & 33554432) && + commitNestedViewTransitions(changedParent); + changedParent = changedParent.sibling; + } +} +function restorePairedViewTransitions(parent) { + if (0 !== (parent.subtreeFlags & 18874368)) + for (parent = parent.child; null !== parent; ) { + if (22 !== parent.tag || null === parent.memoizedState) { + if (30 === parent.tag && 0 !== (parent.flags & 18874368)) { + var instance = parent.stateNode; + null !== instance.paired && (instance.paired = null); + } + restorePairedViewTransitions(parent); + } + parent = parent.sibling; + } +} +function restoreEnterOrExitViewTransitions(fiber) { + if (30 === fiber.tag) + (fiber.stateNode.paired = null), restorePairedViewTransitions(fiber); + else if (0 !== (fiber.subtreeFlags & 33554432)) + for (fiber = fiber.child; null !== fiber; ) + restoreEnterOrExitViewTransitions(fiber), (fiber = fiber.sibling); + else restorePairedViewTransitions(fiber); +} +function measureNestedViewTransitions(changedParent, gesture) { + for (changedParent = changedParent.child; null !== changedParent; ) { + if (30 === changedParent.tag) { + var props = changedParent.memoizedProps, + state = changedParent.stateNode; + getViewTransitionName(props, state); + getViewTransitionClassName(props.default, props.update); + gesture + ? ((props = state.clones), + null !== props && props.map(measureClonedInstance)) + : (changedParent.memoizedState = null); + viewTransitionHostInstanceIdx = 0; + } else + 0 !== (changedParent.subtreeFlags & 33554432) && + measureNestedViewTransitions(changedParent, gesture); + changedParent = changedParent.sibling; + } +} var offscreenSubtreeIsHidden = !1, offscreenSubtreeWasHidden = !1, PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set, nextEffect = null, inProgressLanes = null, - inProgressRoot = null; + inProgressRoot = null, + viewTransitionContextChanged = !1; function isHydratingParent(current, finishedWork) { return 31 === finishedWork.tag ? ((finishedWork = finishedWork.memoizedState), @@ -8315,80 +9041,121 @@ function isHydratingParent(current, finishedWork) { ? current.memoizedState.isDehydrated && 0 === (finishedWork.flags & 256) : !1; } -function commitBeforeMutationEffects(root, firstChild) { - for (nextEffect = firstChild; null !== nextEffect; ) - if ( - ((root = nextEffect), - (firstChild = root.child), - 0 !== (root.subtreeFlags & 1028) && null !== firstChild) - ) - (firstChild.return = root), (nextEffect = firstChild); - else - for (; null !== nextEffect; ) { - root = nextEffect; - var current = root.alternate; - firstChild = root.flags; - switch (root.tag) { - case 0: - if ( - 0 !== (firstChild & 4) && - ((firstChild = root.updateQueue), - (firstChild = null !== firstChild ? firstChild.events : null), - null !== firstChild) - ) - for (var ii = 0; ii < firstChild.length; ii++) { - var _eventPayloads$ii = firstChild[ii]; - _eventPayloads$ii.ref.impl = _eventPayloads$ii.nextImpl; - } - break; - case 11: - case 15: - break; - case 1: - if (0 !== (firstChild & 1024) && null !== current) { - firstChild = void 0; - ii = root; - _eventPayloads$ii = current.memoizedProps; - current = current.memoizedState; - var instance = ii.stateNode; - try { - var resolvedPrevProps = resolveClassComponentProps( - ii.type, - _eventPayloads$ii - ); - firstChild = instance.getSnapshotBeforeUpdate( - resolvedPrevProps, - current - ); - instance.__reactInternalSnapshotBeforeUpdate = firstChild; - } catch (error) { - captureCommitPhaseError(ii, ii.return, error); - } - } - break; - case 3: - break; - case 5: - case 26: - case 27: - case 6: - case 4: - case 17: - break; - default: - if (0 !== (firstChild & 1024)) - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); +function commitBeforeMutationEffects(root, firstChild, committedLanes) { + root = (committedLanes & 335544064) === committedLanes; + nextEffect = firstChild; + for (firstChild = root ? 9270 : 1024; null !== nextEffect; ) { + committedLanes = nextEffect; + if (root) { + var deletions = committedLanes.deletions; + if (null !== deletions) + for (var i = 0; i < deletions.length; i++) + root && commitExitViewTransitions(deletions[i]); + } + if (null === committedLanes.alternate && 0 !== (committedLanes.flags & 2)) + root && trackEnterViewTransitions(committedLanes), + commitBeforeMutationEffects_complete(root); + else { + if (22 === committedLanes.tag && 0 !== (committedLanes.mode & 1)) + if ( + ((deletions = committedLanes.alternate), + null !== committedLanes.memoizedState) + ) { + null !== deletions && + null === deletions.memoizedState && + root && + commitExitViewTransitions(deletions); + commitBeforeMutationEffects_complete(root); + continue; + } else if (null !== deletions && null !== deletions.memoizedState) { + root && trackEnterViewTransitions(committedLanes); + commitBeforeMutationEffects_complete(root); + continue; } - firstChild = root.sibling; - if (null !== firstChild) { - firstChild.return = root.return; - nextEffect = firstChild; - break; + deletions = committedLanes.child; + 0 !== (committedLanes.subtreeFlags & firstChild) && null !== deletions + ? ((deletions.return = committedLanes), (nextEffect = deletions)) + : (root && commitNestedViewTransitions(committedLanes), + commitBeforeMutationEffects_complete(root)); + } + } + appearingViewTransitions = null; +} +function commitBeforeMutationEffects_complete( + isViewTransitionEligible$jscomp$0 +) { + for (; null !== nextEffect; ) { + var fiber = nextEffect, + isViewTransitionEligible = isViewTransitionEligible$jscomp$0, + current = fiber.alternate, + flags = fiber.flags; + switch (fiber.tag) { + case 0: + case 11: + case 15: + break; + case 1: + if (0 !== (flags & 1024) && null !== current) { + isViewTransitionEligible = void 0; + flags = current.memoizedProps; + current = current.memoizedState; + var instance = fiber.stateNode; + try { + var resolvedPrevProps = resolveClassComponentProps( + fiber.type, + flags + ); + isViewTransitionEligible = instance.getSnapshotBeforeUpdate( + resolvedPrevProps, + current + ); + instance.__reactInternalSnapshotBeforeUpdate = + isViewTransitionEligible; + } catch (error) { + captureCommitPhaseError(fiber, fiber.return, error); + } } - nextEffect = root.return; - } + break; + case 3: + break; + case 5: + case 26: + case 27: + case 6: + case 4: + case 17: + break; + case 30: + isViewTransitionEligible && + null !== current && + ((isViewTransitionEligible = getViewTransitionName( + current.memoizedProps, + current.stateNode + )), + (flags = fiber.memoizedProps), + (flags = getViewTransitionClassName(flags.default, flags.update)), + "none" !== flags && + applyViewTransitionToHostInstances( + current, + isViewTransitionEligible, + flags, + (current.memoizedState = []) + )); + break; + default: + if (0 !== (flags & 1024)) + throw Error( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + current = fiber.sibling; + if (null !== current) { + current.return = fiber.return; + nextEffect = current; + break; + } + nextEffect = fiber.return; + } } function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { var prevEffectStart = pushComponentEffectStart(), @@ -8418,11 +9185,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { } else try { finishedRoot.componentDidMount(); - } catch (error$125) { + } catch (error$130) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$125 + error$130 ); } else { @@ -8439,11 +9206,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$126) { + } catch (error$131) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$126 + error$131 ); } recordEffectDuration(); @@ -8454,11 +9221,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$127) { + } catch (error$132) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$127 + error$132 ); } } @@ -8537,18 +9304,20 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { null !== finishedWork.memoizedState || offscreenSubtreeIsHidden), !flags) ) { - current = + var newOffscreenSubtreeWasHidden = (null !== current && null !== current.memoizedState) || offscreenSubtreeWasHidden; - prevProps = offscreenSubtreeIsHidden; - var prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; + current = offscreenSubtreeIsHidden; + prevProps = offscreenSubtreeWasHidden; offscreenSubtreeIsHidden = flags; - (offscreenSubtreeWasHidden = current) && - !prevOffscreenSubtreeWasHidden - ? (recursivelyTraverseReappearLayoutEffects( + (offscreenSubtreeWasHidden = newOffscreenSubtreeWasHidden) && + !prevProps + ? ((flags = 0), + 0 !== (finishedWork.subtreeFlags & 8772) && (flags |= 1), + recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - 0 !== (finishedWork.subtreeFlags & 8772) + flags ), 0 !== (finishedWork.mode & 2) && 0 <= componentEffectStartTime && @@ -8560,13 +9329,17 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { componentEffectEndTime )) : recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); - offscreenSubtreeIsHidden = prevProps; - offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; + offscreenSubtreeIsHidden = current; + offscreenSubtreeWasHidden = prevProps; } } else recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); break; case 30: + recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); + flags & 512 && safelyAttachRef(finishedWork, finishedWork.return); break; + case 7: + flags & 512 && safelyAttachRef(finishedWork, finishedWork.return); default: recursivelyTraverseLayoutEffects(finishedRoot, finishedWork); } @@ -8640,8 +9413,11 @@ function commitDeletionEffectsOnFiber( case 27: case 5: offscreenSubtreeWasHidden || - safelyDetachRef(deletedFiber, nearestMountedAncestor); + safelyDetachRef(deletedFiber, nearestMountedAncestor), + commitFragmentInstanceDeletionEffects(deletedFiber); case 6: + 6 === deletedFiber.tag && + commitFragmentInstanceDeletionEffects(deletedFiber); recursivelyTraverseDeletionEffects( finishedRoot, nearestMountedAncestor, @@ -8666,8 +9442,7 @@ function commitDeletionEffectsOnFiber( case 11: case 14: case 15: - offscreenSubtreeWasHidden || - commitHookEffectListUnmount(2, deletedFiber, nearestMountedAncestor); + commitHookEffectListUnmount(2, deletedFiber, nearestMountedAncestor); offscreenSubtreeWasHidden || commitHookLayoutUnmountEffects(deletedFiber, nearestMountedAncestor, 4); recursivelyTraverseDeletionEffects( @@ -8717,6 +9492,23 @@ function commitDeletionEffectsOnFiber( deletedFiber ); break; + case 30: + safelyDetachRef(deletedFiber, nearestMountedAncestor); + recursivelyTraverseDeletionEffects( + finishedRoot, + nearestMountedAncestor, + deletedFiber + ); + break; + case 7: + offscreenSubtreeWasHidden || + safelyDetachRef(deletedFiber, nearestMountedAncestor); + recursivelyTraverseDeletionEffects( + finishedRoot, + nearestMountedAncestor, + deletedFiber + ); + break; default: recursivelyTraverseDeletionEffects( finishedRoot, @@ -8782,7 +9574,7 @@ function attachSuspenseRetryListeners(finishedWork, wakeables) { } }); } -function recursivelyTraverseMutationEffects(root$jscomp$0, parentFiber) { +function recursivelyTraverseMutationEffects(root$jscomp$0, parentFiber, lanes) { var deletions = parentFiber.deletions; if (null !== deletions) for (var i = 0; i < deletions.length; i++) { @@ -8808,10 +9600,10 @@ function recursivelyTraverseMutationEffects(root$jscomp$0, parentFiber) { } if (parentFiber.subtreeFlags & 13886) for (parentFiber = parentFiber.child; null !== parentFiber; ) - commitMutationEffectsOnFiber(parentFiber, root$jscomp$0), + commitMutationEffectsOnFiber(parentFiber, root$jscomp$0, lanes), (parentFiber = parentFiber.sibling); } -function commitMutationEffectsOnFiber(finishedWork, root) { +function commitMutationEffectsOnFiber(finishedWork, root, lanes) { var prevEffectStart = pushComponentEffectStart(), prevEffectDuration = pushComponentEffectDuration(), prevEffectErrors = pushComponentEffectErrors(), @@ -8823,7 +9615,17 @@ function commitMutationEffectsOnFiber(finishedWork, root) { case 11: case 14: case 15: - recursivelyTraverseMutationEffects(root, finishedWork); + if ( + flags & 4 && + ((current = finishedWork.updateQueue), + (current = null !== current ? current.events : null), + null !== current) + ) + for (var ii = 0; ii < current.length; ii++) { + var _eventPayloads$ii2 = current[ii]; + _eventPayloads$ii2.ref.impl = _eventPayloads$ii2.nextImpl; + } + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 4 && (commitHookEffectListUnmount(3, finishedWork, finishedWork.return), @@ -8831,7 +9633,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) { commitHookLayoutUnmountEffects(finishedWork, finishedWork.return, 5)); break; case 1: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 512 && (offscreenSubtreeWasHidden || @@ -8843,14 +9645,14 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== root && ((flags = root.callbacks), null !== flags && - ((current = root.shared.hiddenCallbacks), + ((lanes = root.shared.hiddenCallbacks), (root.shared.hiddenCallbacks = - null === current ? flags : current.concat(flags))))); + null === lanes ? flags : lanes.concat(flags))))); break; case 26: case 27: case 5: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 512 && (offscreenSubtreeWasHidden || @@ -8860,27 +9662,32 @@ function commitMutationEffectsOnFiber(finishedWork, root) { (finishedWork.alternate.stateNode = finishedWork.stateNode); break; case 6: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); break; case 3: current = pushNestedEffectDurations(); - recursivelyTraverseMutationEffects(root, finishedWork); + viewTransitionMutationContext = !1; + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); if (flags & 4) { flags = root.containerInfo; - var pendingChildren = root.pendingChildren; + lanes = root.pendingChildren; try { - completeRoot(flags.containerTag, pendingChildren); + completeRoot(flags.containerTag, lanes), + (viewTransitionMutationContext = !0); } catch (error) { captureCommitPhaseError(finishedWork, finishedWork.return, error); } } root.effectDuration += popNestedEffectDurations(current); + viewTransitionMutationContext = !1; break; case 4: - recursivelyTraverseMutationEffects(root, finishedWork); + current = pushMutationContext(); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); + viewTransitionMutationContext = current; flags & 4 && commitHostPortalContainerChildren( finishedWork.stateNode, @@ -8890,13 +9697,13 @@ function commitMutationEffectsOnFiber(finishedWork, root) { break; case 12: flags = pushNestedEffectDurations(); - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); finishedWork.stateNode.effectDuration += bubbleNestedEffectDurations(flags); break; case 31: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 4 && ((root = finishedWork.updateQueue), @@ -8905,7 +9712,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) { attachSuspenseRetryListeners(finishedWork, root))); break; case 13: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); finishedWork.child.flags & 8192 && ((root = null !== current && null !== current.memoizedState), @@ -8919,19 +9726,19 @@ function commitMutationEffectsOnFiber(finishedWork, root) { attachSuspenseRetryListeners(finishedWork, root))); break; case 22: - pendingChildren = null !== finishedWork.memoizedState; - var wasHidden = null !== current && null !== current.memoizedState; + ii = null !== finishedWork.memoizedState; + _eventPayloads$ii2 = null !== current && null !== current.memoizedState; if (finishedWork.mode & 1) { var prevOffscreenSubtreeIsHidden = offscreenSubtreeIsHidden, prevOffscreenSubtreeWasHidden = offscreenSubtreeWasHidden; - offscreenSubtreeIsHidden = - prevOffscreenSubtreeIsHidden || pendingChildren; - offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden || wasHidden; - recursivelyTraverseMutationEffects(root, finishedWork); + offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden || ii; + offscreenSubtreeWasHidden = + prevOffscreenSubtreeWasHidden || _eventPayloads$ii2; + recursivelyTraverseMutationEffects(root, finishedWork, lanes); offscreenSubtreeWasHidden = prevOffscreenSubtreeWasHidden; offscreenSubtreeIsHidden = prevOffscreenSubtreeIsHidden; - wasHidden && - !pendingChildren && + _eventPayloads$ii2 && + !ii && !prevOffscreenSubtreeIsHidden && !prevOffscreenSubtreeWasHidden && 0 !== (finishedWork.mode & 2) && @@ -8943,20 +9750,23 @@ function commitMutationEffectsOnFiber(finishedWork, root) { componentEffectStartTime, componentEffectEndTime ); - } else recursivelyTraverseMutationEffects(root, finishedWork); + } else recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 8192 && ((root = finishedWork.stateNode), - (root._visibility = pendingChildren - ? root._visibility & -2 - : root._visibility | 1), - !pendingChildren || + (root._visibility = ii ? root._visibility & -2 : root._visibility | 1), + !ii || null === current || - wasHidden || + _eventPayloads$ii2 || offscreenSubtreeIsHidden || offscreenSubtreeWasHidden || 0 === (finishedWork.mode & 1) || - (recursivelyTraverseDisappearLayoutEffects(finishedWork), + ((root = _eventPayloads$ii2 || offscreenSubtreeWasHidden), + (lanes = offscreenSubtreeIsHidden), + (current = offscreenSubtreeWasHidden), + (offscreenSubtreeIsHidden = ii || offscreenSubtreeIsHidden), + (offscreenSubtreeWasHidden = root), + recursivelyTraverseDisappearLayoutEffects(finishedWork), 0 !== (finishedWork.mode & 2) && 0 <= componentEffectStartTime && 0 <= componentEffectEndTime && @@ -8966,7 +9776,9 @@ function commitMutationEffectsOnFiber(finishedWork, root) { componentEffectStartTime, componentEffectEndTime, "Disconnect" - ))); + ), + (offscreenSubtreeIsHidden = lanes), + (offscreenSubtreeWasHidden = current))); flags & 4 && ((root = finishedWork.updateQueue), null !== root && @@ -8976,7 +9788,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) { attachSuspenseRetryListeners(finishedWork, flags)))); break; case 19: - recursivelyTraverseMutationEffects(root, finishedWork); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); commitReconciliationEffects(finishedWork); flags & 4 && ((root = finishedWork.updateQueue), @@ -8985,11 +9797,39 @@ function commitMutationEffectsOnFiber(finishedWork, root) { attachSuspenseRetryListeners(finishedWork, root))); break; case 30: + flags & 512 && + (offscreenSubtreeWasHidden || + null === current || + safelyDetachRef(current, current.return)); + flags = pushMutationContext(); + ii = (lanes & 335544064) === lanes; + _eventPayloads$ii2 = finishedWork.memoizedProps; + ii && + "none" !== + getViewTransitionClassName( + _eventPayloads$ii2.default, + _eventPayloads$ii2.update + ); + recursivelyTraverseMutationEffects(root, finishedWork, lanes); + commitReconciliationEffects(finishedWork); + ii && + null !== current && + viewTransitionMutationContext && + (finishedWork.flags |= 4); + viewTransitionMutationContext = flags; break; case 21: break; + case 7: + flags & 512 && + (offscreenSubtreeWasHidden || + null === current || + safelyDetachRef(current, current.return)), + current && + null !== current.stateNode && + (current.stateNode._fragmentFiber = finishedWork); default: - recursivelyTraverseMutationEffects(root, finishedWork), + recursivelyTraverseMutationEffects(root, finishedWork, lanes), commitReconciliationEffects(finishedWork); } 0 !== (finishedWork.mode & 2) && @@ -9021,9 +9861,97 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } function commitReconciliationEffects(finishedWork) { var flags = finishedWork.flags; - flags & 2 && (finishedWork.flags &= -3); + if (flags & 2) { + try { + for ( + var parentFragmentInstances = null, parent = finishedWork.return; + null !== parent; + + ) { + if (isFragmentInstanceParent(parent)) { + var fragmentInstance = parent.stateNode; + null === parentFragmentInstances + ? (parentFragmentInstances = [fragmentInstance]) + : parentFragmentInstances.push(fragmentInstance); + } + if (isFragmentInstanceHostBoundary(parent)) break; + parent = parent.return; + } + commitImmutablePlacementNodeToFragmentInstances( + finishedWork, + parentFragmentInstances + ); + } catch (error) { + captureCommitPhaseError(finishedWork, finishedWork.return, error); + } + finishedWork.flags &= -3; + } flags & 4096 && (finishedWork.flags &= -4097); } +function recursivelyTraverseAfterMutationEffects(root, parentFiber) { + if (parentFiber.subtreeFlags & 9270) + for (parentFiber = parentFiber.child; null !== parentFiber; ) + commitAfterMutationEffectsOnFiber(parentFiber, root), + (parentFiber = parentFiber.sibling); + else measureNestedViewTransitions(parentFiber, !1); +} +function commitAfterMutationEffectsOnFiber(finishedWork, root) { + var current = finishedWork.alternate; + if (null === current) commitEnterViewTransitions(finishedWork, !1); + else + switch (finishedWork.tag) { + case 3: + viewTransitionContextChanged = !1; + pushViewTransitionCancelableScope(); + recursivelyTraverseAfterMutationEffects(root, finishedWork); + viewTransitionCancelableChildren = null; + break; + case 5: + recursivelyTraverseAfterMutationEffects(root, finishedWork); + break; + case 4: + current = viewTransitionContextChanged; + viewTransitionContextChanged = !1; + recursivelyTraverseAfterMutationEffects(root, finishedWork); + viewTransitionContextChanged = current; + break; + case 22: + 0 !== (finishedWork.mode & 1) + ? null === finishedWork.memoizedState && + (null !== current.memoizedState + ? commitEnterViewTransitions(finishedWork, !1) + : recursivelyTraverseAfterMutationEffects(root, finishedWork)) + : recursivelyTraverseAfterMutationEffects(root, finishedWork); + break; + case 30: + var prevContextChanged$148 = viewTransitionContextChanged, + prevCancelableChildren = pushViewTransitionCancelableScope(); + viewTransitionContextChanged = !1; + recursivelyTraverseAfterMutationEffects(root, finishedWork); + viewTransitionContextChanged && (finishedWork.flags |= 4); + root = finishedWork.memoizedProps; + var state = finishedWork.stateNode; + getViewTransitionName(root, state); + getViewTransitionName(current.memoizedProps, state); + "none" !== getViewTransitionClassName(root.default, root.update) && + ((root = current.memoizedState), + (current.memoizedState = null), + (viewTransitionHostInstanceIdx = 0), + viewTransitionHostInstanceIdx !== (null === root ? 0 : root.length) && + (finishedWork.flags |= 32)); + null !== prevCancelableChildren && + (prevCancelableChildren.push.apply( + prevCancelableChildren, + viewTransitionCancelableChildren + ), + (viewTransitionCancelableChildren = prevCancelableChildren)); + viewTransitionContextChanged = + 0 !== (finishedWork.flags & 32) ? !0 : prevContextChanged$148; + break; + default: + recursivelyTraverseAfterMutationEffects(root, finishedWork); + } +} function recursivelyTraverseLayoutEffects(root, parentFiber) { if (parentFiber.subtreeFlags & 8772) for (parentFiber = parentFiber.child; null !== parentFiber; ) @@ -9057,8 +9985,16 @@ function recursivelyTraverseDisappearLayoutEffects(parentFiber) { recursivelyTraverseDisappearLayoutEffects(finishedWork); break; case 27: - case 26: case 5: + safelyDetachRef(finishedWork, finishedWork.return); + (5 !== finishedWork.tag && 27 !== finishedWork.tag) || + commitFragmentInstanceDeletionEffects(finishedWork); + recursivelyTraverseDisappearLayoutEffects(finishedWork); + break; + case 6: + commitFragmentInstanceDeletionEffects(finishedWork); + break; + case 26: safelyDetachRef(finishedWork, finishedWork.return); recursivelyTraverseDisappearLayoutEffects(finishedWork); break; @@ -9067,8 +10003,11 @@ function recursivelyTraverseDisappearLayoutEffects(parentFiber) { recursivelyTraverseDisappearLayoutEffects(finishedWork); break; case 30: + safelyDetachRef(finishedWork, finishedWork.return); recursivelyTraverseDisappearLayoutEffects(finishedWork); break; + case 7: + safelyDetachRef(finishedWork, finishedWork.return); default: recursivelyTraverseDisappearLayoutEffects(finishedWork); } @@ -9093,10 +10032,12 @@ function recursivelyTraverseDisappearLayoutEffects(parentFiber) { function recursivelyTraverseReappearLayoutEffects( finishedRoot$jscomp$0, parentFiber, - includeWorkInProgressEffects + layoutEffectTraversalFlags ) { - includeWorkInProgressEffects = - includeWorkInProgressEffects && 0 !== (parentFiber.subtreeFlags & 8772); + layoutEffectTraversalFlags = + 0 !== (parentFiber.subtreeFlags & 8772) + ? layoutEffectTraversalFlags + : layoutEffectTraversalFlags & -2; for (parentFiber = parentFiber.child; null !== parentFiber; ) { var current = parentFiber.alternate, finishedRoot = finishedRoot$jscomp$0, @@ -9105,7 +10046,8 @@ function recursivelyTraverseReappearLayoutEffects( prevEffectDuration = pushComponentEffectDuration(), prevEffectErrors = pushComponentEffectErrors(), prevEffectDidSpawnUpdate = pushComponentEffectDidSpawnUpdate(), - flags = finishedWork.flags; + flags = finishedWork.flags, + includeWorkInProgressEffects = 0 !== (layoutEffectTraversalFlags & 1); switch (finishedWork.tag) { case 0: case 11: @@ -9113,7 +10055,7 @@ function recursivelyTraverseReappearLayoutEffects( recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); commitHookLayoutEffects(finishedWork, 4); break; @@ -9121,7 +10063,7 @@ function recursivelyTraverseReappearLayoutEffects( recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); current = finishedWork; finishedRoot = current.stateNode; @@ -9154,12 +10096,28 @@ function recursivelyTraverseReappearLayoutEffects( safelyAttachRef(finishedWork, finishedWork.return); break; case 27: - case 26: case 5: + (5 !== finishedWork.tag && 27 !== finishedWork.tag) || + commitFragmentInstanceInsertionEffects(finishedWork); + recursivelyTraverseReappearLayoutEffects( + finishedRoot, + finishedWork, + layoutEffectTraversalFlags + ); + includeWorkInProgressEffects && + null === current && + flags & 4 && + commitHostMount(finishedWork); + safelyAttachRef(finishedWork, finishedWork.return); + break; + case 6: + commitFragmentInstanceInsertionEffects(finishedWork); + break; + case 26: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); includeWorkInProgressEffects && null === current && @@ -9173,34 +10131,35 @@ function recursivelyTraverseReappearLayoutEffects( recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ), - (finishedRoot = finishedWork.stateNode), - (finishedRoot.effectDuration += bubbleNestedEffectDurations(flags)), + (includeWorkInProgressEffects = finishedWork.stateNode), + (includeWorkInProgressEffects.effectDuration += + bubbleNestedEffectDurations(flags)), commitProfilerUpdate( finishedWork, current, commitStartTime, - finishedRoot.effectDuration + includeWorkInProgressEffects.effectDuration )) : recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); break; case 31: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); break; case 13: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); break; case 22: @@ -9208,17 +10167,25 @@ function recursivelyTraverseReappearLayoutEffects( recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); safelyAttachRef(finishedWork, finishedWork.return); break; case 30: + recursivelyTraverseReappearLayoutEffects( + finishedRoot, + finishedWork, + layoutEffectTraversalFlags + ); + safelyAttachRef(finishedWork, finishedWork.return); break; + case 7: + safelyAttachRef(finishedWork, finishedWork.return); default: recursivelyTraverseReappearLayoutEffects( finishedRoot, finishedWork, - includeWorkInProgressEffects + layoutEffectTraversalFlags ); } 0 !== (finishedWork.mode & 2) && @@ -9269,7 +10236,8 @@ function recursivelyTraversePassiveMountEffects( endTime ) { if ( - parentFiber.subtreeFlags & 10256 || + parentFiber.subtreeFlags & + ((committedLanes & 335544064) === committedLanes ? 10262 : 10256) || (0 !== parentFiber.actualDuration && (null === parentFiber.alternate || parentFiber.alternate.child !== parentFiber.child)) @@ -9298,7 +10266,13 @@ function commitPassiveMountOnFiber( prevEffectDuration = pushComponentEffectDuration(), prevEffectErrors = pushComponentEffectErrors(), prevEffectDidSpawnUpdate = pushComponentEffectDidSpawnUpdate(), - flags = finishedWork.flags; + isViewTransitionEligible = (committedLanes & 335544064) === committedLanes; + isViewTransitionEligible && + null === finishedWork.alternate && + null !== finishedWork.return && + null !== finishedWork.return.alternate && + restoreEnterOrExitViewTransitions(finishedWork); + var flags = finishedWork.flags; switch (finishedWork.tag) { case 0: case 11: @@ -9346,8 +10320,8 @@ function commitPassiveMountOnFiber( ); break; case 3: - var prevProfilerEffectDuration = pushNestedEffectDurations(), - wasInHydratedSubtree = inHydratedSubtree; + isViewTransitionEligible = pushNestedEffectDurations(); + var wasInHydratedSubtree = inHydratedSubtree; inHydratedSubtree = null !== finishedWork.alternate && finishedWork.alternate.memoizedState.isDehydrated && @@ -9369,7 +10343,7 @@ function commitPassiveMountOnFiber( (committedTransitions.refCount++, null != committedLanes && releaseCache(committedLanes))); finishedRoot.passiveEffectDuration += popNestedEffectDurations( - prevProfilerEffectDuration + isViewTransitionEligible ); break; case 12: @@ -9386,14 +10360,14 @@ function commitPassiveMountOnFiber( finishedRoot.passiveEffectDuration += bubbleNestedEffectDurations(flags); try { - prevProfilerEffectDuration = finishedWork.memoizedProps; - wasInHydratedSubtree = prevProfilerEffectDuration.id; - var onPostCommit = prevProfilerEffectDuration.onPostCommit, + wasInHydratedSubtree = finishedWork.memoizedProps; + var id = wasInHydratedSubtree.id, + onPostCommit = wasInHydratedSubtree.onPostCommit, phase = null === finishedWork.alternate ? "mount" : "update"; currentUpdateIsNested && (phase = "nested-update"); "function" === typeof onPostCommit && onPostCommit( - wasInHydratedSubtree, + id, phase, finishedRoot.passiveEffectDuration, commitStartTime @@ -9412,18 +10386,18 @@ function commitPassiveMountOnFiber( break; case 31: flags = inHydratedSubtree; - prevProfilerEffectDuration = + isViewTransitionEligible = null !== finishedWork.alternate ? finishedWork.alternate.memoizedState : null; wasInHydratedSubtree = finishedWork.memoizedState; - null !== prevProfilerEffectDuration && null === wasInHydratedSubtree + null !== isViewTransitionEligible && null === wasInHydratedSubtree ? ((wasInHydratedSubtree = finishedWork.deletions), null !== wasInHydratedSubtree && 0 < wasInHydratedSubtree.length && 18 === wasInHydratedSubtree[0].tag ? ((inHydratedSubtree = !1), - null !== prevProfilerEffectDuration.hydrationErrors && + null !== isViewTransitionEligible.hydrationErrors && logComponentErrored( finishedWork, finishedWork.actualStartTime, @@ -9442,13 +10416,13 @@ function commitPassiveMountOnFiber( break; case 13: flags = inHydratedSubtree; - prevProfilerEffectDuration = + isViewTransitionEligible = null !== finishedWork.alternate ? finishedWork.alternate.memoizedState : null; wasInHydratedSubtree = finishedWork.memoizedState; - null === prevProfilerEffectDuration || - null === prevProfilerEffectDuration.dehydrated || + null === isViewTransitionEligible || + null === isViewTransitionEligible.dehydrated || (null !== wasInHydratedSubtree && null !== wasInHydratedSubtree.dehydrated) ? (inHydratedSubtree = !1) @@ -9457,7 +10431,7 @@ function commitPassiveMountOnFiber( 0 < wasInHydratedSubtree.length && 18 === wasInHydratedSubtree[0].tag ? ((inHydratedSubtree = !1), - null !== prevProfilerEffectDuration.hydrationErrors && + null !== isViewTransitionEligible.hydrationErrors && logComponentErrored( finishedWork, finishedWork.actualStartTime, @@ -9476,72 +10450,77 @@ function commitPassiveMountOnFiber( case 23: break; case 22: - wasInHydratedSubtree = finishedWork.stateNode; - prevProfilerEffectDuration = finishedWork.alternate; + id = finishedWork.stateNode; + wasInHydratedSubtree = finishedWork.alternate; null !== finishedWork.memoizedState - ? wasInHydratedSubtree._visibility & 2 - ? recursivelyTraversePassiveMountEffects( - finishedRoot, - finishedWork, - committedLanes, - committedTransitions, - endTime - ) - : finishedWork.mode & 1 - ? recursivelyTraverseAtomicPassiveEffects( + ? (isViewTransitionEligible && + null !== wasInHydratedSubtree && + null === wasInHydratedSubtree.memoizedState && + restoreEnterOrExitViewTransitions(wasInHydratedSubtree), + id._visibility & 2 + ? recursivelyTraversePassiveMountEffects( finishedRoot, finishedWork, committedLanes, committedTransitions, endTime ) - : ((wasInHydratedSubtree._visibility |= 2), - recursivelyTraversePassiveMountEffects( + : finishedWork.mode & 1 + ? recursivelyTraverseAtomicPassiveEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions, + endTime + ) + : ((id._visibility |= 2), + recursivelyTraversePassiveMountEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions, + endTime + ))) + : (isViewTransitionEligible && + null !== wasInHydratedSubtree && + null !== wasInHydratedSubtree.memoizedState && + restoreEnterOrExitViewTransitions(finishedWork), + id._visibility & 2 + ? recursivelyTraversePassiveMountEffects( finishedRoot, finishedWork, committedLanes, committedTransitions, endTime - )) - : wasInHydratedSubtree._visibility & 2 - ? recursivelyTraversePassiveMountEffects( - finishedRoot, - finishedWork, - committedLanes, - committedTransitions, - endTime - ) - : ((wasInHydratedSubtree._visibility |= 2), - recursivelyTraverseReconnectPassiveEffects( - finishedRoot, - finishedWork, - committedLanes, - committedTransitions, - 0 !== (finishedWork.subtreeFlags & 10256) || - (0 !== finishedWork.actualDuration && - (null === finishedWork.alternate || - finishedWork.alternate.child !== finishedWork.child)), - endTime - ), - 0 === (finishedWork.mode & 2) || - inHydratedSubtree || - ((finishedRoot = finishedWork.actualStartTime), - 0 <= finishedRoot && - 0.05 < endTime - finishedRoot && - logComponentReappeared(finishedWork, finishedRoot, endTime), - 0 <= componentEffectStartTime && - 0 <= componentEffectEndTime && - 0.05 < componentEffectEndTime - componentEffectStartTime && - logComponentReappeared( - finishedWork, - componentEffectStartTime, - componentEffectEndTime - ))); + ) + : ((id._visibility |= 2), + recursivelyTraverseReconnectPassiveEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions, + 0 !== (finishedWork.subtreeFlags & 10256) || + (0 !== finishedWork.actualDuration && + (null === finishedWork.alternate || + finishedWork.alternate.child !== finishedWork.child)), + endTime + ), + 0 === (finishedWork.mode & 2) || + inHydratedSubtree || + ((finishedRoot = finishedWork.actualStartTime), + 0 <= finishedRoot && + 0.05 < endTime - finishedRoot && + logComponentReappeared(finishedWork, finishedRoot, endTime), + 0 <= componentEffectStartTime && + 0 <= componentEffectEndTime && + 0.05 < componentEffectEndTime - componentEffectStartTime && + logComponentReappeared( + finishedWork, + componentEffectStartTime, + componentEffectEndTime + )))); flags & 2048 && - commitOffscreenPassiveMountEffects( - prevProfilerEffectDuration, - finishedWork - ); + commitOffscreenPassiveMountEffects(wasInHydratedSubtree, finishedWork); break; case 24: recursivelyTraversePassiveMountEffects( @@ -9554,6 +10533,15 @@ function commitPassiveMountOnFiber( flags & 2048 && commitCachePassiveMountEffect(finishedWork.alternate, finishedWork); break; + case 30: + recursivelyTraversePassiveMountEffects( + finishedRoot, + finishedWork, + committedLanes, + committedTransitions, + endTime + ); + break; default: recursivelyTraversePassiveMountEffects( finishedRoot, @@ -9831,6 +10819,20 @@ function accumulateSuspenseyCommitOnFiber(fiber) { : recursivelyAccumulateSuspenseyCommit(fiber); } break; + case 30: + if ( + 0 !== (fiber.flags & suspenseyCommitFlag) && + ((current = fiber.memoizedProps.name), + null != current && "auto" !== current) + ) { + var state = fiber.stateNode; + state.paired = null; + null === appearingViewTransitions && + (appearingViewTransitions = new Map()); + appearingViewTransitions.set(current, state); + } + recursivelyAccumulateSuspenseyCommit(fiber); + break; default: recursivelyAccumulateSuspenseyCommit(fiber); } @@ -10120,6 +11122,9 @@ var DefaultAsyncDispatcher = { pendingEffectsRenderEndTime = -0, pendingPassiveTransitions = null, pendingRecoverableErrors = null, + pendingViewTransition = null, + pendingViewTransitionEvents = null, + pendingTransitionTypes = null, pendingSuspendedCommitReason = null, pendingDelayedCommitReason = 0, pendingSuspendedViewTransitionReason = null, @@ -10149,6 +11154,19 @@ function requestDeferredLane() { null !== lane && (lane.flags |= 32); return workInProgressDeferredLane; } +function scheduleViewTransitionEvent(fiber, callback) { + if (null != callback) { + var state = fiber.stateNode, + instance = state.ref; + null === instance && + (instance = state.ref = + createViewTransitionInstance( + getViewTransitionName(fiber.memoizedProps, state) + )); + null === pendingViewTransitionEvents && (pendingViewTransitionEvents = []); + pendingViewTransitionEvents.push(callback.bind(null, instance)); + } +} function scheduleUpdateOnFiber(root, fiber, lane) { if ( (root === workInProgressRoot && @@ -10294,6 +11312,7 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { yieldDuration = workInProgressRootConcurrentErrors; exitStatus = renderRootSync(root, JSCompiler_inline_result, !1); 2 !== exitStatus && + 6 !== exitStatus && (workInProgressRootDidAttachPingListener ? ((root.errorRecoveryDisabledLanes |= renderWasConcurrent), (workInProgressRootInterleavedUpdatedLanes |= @@ -10330,7 +11349,8 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { case 1: throw Error("Root did not complete. This is a bug in React."); case 4: - if ((lanes & 4194048) !== lanes) break; + if ((lanes & 4194048) !== lanes && (lanes & 62914560) !== lanes) + break; case 6: setCurrentTrackFromLanes(lanes); logSuspendedRenderPhase(renderStartTime, yieldDuration, lanes); @@ -10371,7 +11391,7 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { if (0 !== getNextLanes(yieldEndTime, 0, !0)) break a; pendingEffectsLanes = lanes; yieldEndTime.timeoutHandle = scheduleTimeout( - commitRootWhenReady.bind( + completeRootWhenReady.bind( null, yieldEndTime, forceSync, @@ -10392,7 +11412,7 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { ); break a; } - commitRootWhenReady( + completeRootWhenReady( yieldEndTime, forceSync, workInProgressRootRecoverableErrors, @@ -10414,7 +11434,7 @@ function performWorkOnRoot(root$jscomp$0, lanes, forceSync) { } while (1); ensureRootIsScheduled(root$jscomp$0); } -function commitRootWhenReady( +function completeRootWhenReady( root, finishedWork, recoverableErrors, @@ -10431,35 +11451,87 @@ function commitRootWhenReady( completedRenderEndTime ) { root.timeoutHandle = -1; - didSkipSuspendedSiblings = finishedWork.subtreeFlags; + didIncludeRenderPhaseUpdate = finishedWork.subtreeFlags; + didSkipSuspendedSiblings = (lanes & 335544064) === lanes; var suspendedState = null; if ( - didSkipSuspendedSiblings & 8192 || - 16785408 === (didSkipSuspendedSiblings & 16785408) + didSkipSuspendedSiblings || + didIncludeRenderPhaseUpdate & 8192 || + 16785408 === (didIncludeRenderPhaseUpdate & 16785408) ) - (suspendedState = null), + (appearingViewTransitions = suspendedState = null), accumulateSuspenseyCommitOnFiber(finishedWork), + didSkipSuspendedSiblings && + null != fabricSuspendOnActiveViewTransition && + fabricSuspendOnActiveViewTransition(), (lanes & 62914560) === lanes ? globalMostRecentFallbackTime - now$1() : (lanes & 4194048) === lanes ? globalMostRecentTransitionTime - now$1() : 0; - commitRoot( - root, - finishedWork, - lanes, - recoverableErrors, - transitions, - didIncludeRenderPhaseUpdate, - spawnedLane, - updatedLanes, - suspendedRetryLanes, - exitStatus, - suspendedState, - suspendedCommitReason, - completedRenderStartTime, - completedRenderEndTime - ); + didIncludeRenderPhaseUpdate = suspendedState; + root.cancelPendingCommit = null; + do flushPendingEffects(); + while (0 !== pendingEffectsStatus); + if (0 !== (executionContext & 6)) + throw Error("Should not already be working."); + setCurrentTrackFromLanes(lanes); + 2 === exitStatus + ? logErroredRenderPhase(completedRenderStartTime, completedRenderEndTime) + : null !== recoverableErrors + ? !supportsUserTiming || + completedRenderEndTime <= completedRenderStartTime || + console.timeStamp( + "Recovered", + completedRenderStartTime, + completedRenderEndTime, + currentTrack, + "Scheduler \u269b", + "error" + ) + : !supportsUserTiming || + completedRenderEndTime <= completedRenderStartTime || + console.timeStamp( + (lanes & 536870912) === lanes + ? "Prepared" + : (lanes & 201326741) === lanes + ? "Hydrated" + : "Render", + completedRenderStartTime, + completedRenderEndTime, + currentTrack, + "Scheduler \u269b", + (lanes & 738197653) === lanes ? "tertiary-dark" : "primary-dark" + ); + if (null !== finishedWork) { + if (finishedWork === root.current) + throw Error( + "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." + ); + root === workInProgressRoot && + ((workInProgress = workInProgressRoot = null), + (workInProgressRootRenderLanes = 0)); + pendingFinishedWork = finishedWork; + pendingEffectsRoot = root; + pendingEffectsLanes = lanes; + pendingPassiveTransitions = transitions; + pendingRecoverableErrors = recoverableErrors; + pendingEffectsRenderEndTime = completedRenderEndTime; + pendingSuspendedCommitReason = suspendedCommitReason; + pendingDelayedCommitReason = 0; + pendingSuspendedViewTransitionReason = null; + commitRoot( + root, + finishedWork, + lanes, + spawnedLane, + updatedLanes, + suspendedRetryLanes, + didIncludeRenderPhaseUpdate, + suspendedCommitReason, + completedRenderEndTime + ); + } } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { @@ -10501,6 +11573,7 @@ function markRootSuspended( spawnedLane, didAttemptEntireTree ) { + suspendedLanes = getEntangledLanes(root, suspendedLanes); suspendedLanes &= ~workInProgressRootPingedLanes; suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes; root.suspendedLanes |= suspendedLanes; @@ -10536,6 +11609,8 @@ function resetWorkInProgressStack() { function finalizeRender(lanes, finalizationTime) { 0 !== (lanes & 127) && (blockingClampTime = finalizationTime); 0 !== (lanes & 4194048) && (transitionClampTime = finalizationTime); + 0 !== (lanes & 62914560) && (retryClampTime = finalizationTime); + 0 !== (lanes & 2080374784) && (idleClampTime = finalizationTime); } function prepareFreshStack(root, lanes) { supportsUserTiming && @@ -10608,20 +11683,23 @@ function prepareFreshStack(root, lanes) { 0 <= blockingEventTime && blockingEventTime < blockingClampTime ? blockingClampTime : blockingEventTime; - var clampedRenderStartTime$160 = + var clampedRenderStartTime$171 = 0 <= endTime ? endTime : 0 <= previousRenderStartTime ? previousRenderStartTime : renderStartTime; - 0 <= blockingSuspendedTime && - (setCurrentTrackFromLanes(2), - logSuspendedWithDelayPhase( - blockingSuspendedTime, - clampedRenderStartTime$160, - lanes - )); - clampedRenderStartTime$160 = blockingEventType; + 0 <= blockingSuspendedTime + ? (setCurrentTrackFromLanes(2), + logSuspendedWithDelayPhase( + blockingSuspendedTime, + clampedRenderStartTime$171, + lanes + )) + : 0 !== (animatingLanes & 127) && + (setCurrentTrackFromLanes(2), + logAnimatingPhase(blockingClampTime, clampedRenderStartTime$171)); + clampedRenderStartTime$171 = blockingEventType; var eventIsRepeat = 0 < blockingEventRepeatTime, isSpawnedUpdate = 1 === blockingUpdateType, isPingedUpdate = 2 === blockingUpdateType, @@ -10636,12 +11714,12 @@ function prepareFreshStack(root, lanes) { ? endTime > previousRenderStartTime && (endTime = previousRenderStartTime) : (endTime = previousRenderStartTime), - null !== clampedRenderStartTime$160 && + null !== clampedRenderStartTime$171 && previousRenderStartTime > endTime && console.timeStamp( eventIsRepeat ? "Consecutive" - : "Event: " + clampedRenderStartTime$160, + : "Event: " + clampedRenderStartTime$171, endTime, previousRenderStartTime, currentTrack, @@ -10683,23 +11761,26 @@ function prepareFreshStack(root, lanes) { 0 <= transitionUpdateTime && transitionUpdateTime < transitionClampTime ? transitionClampTime : transitionUpdateTime), - (clampedRenderStartTime$160 = + (clampedRenderStartTime$171 = 0 <= transitionEventTime && transitionEventTime < transitionClampTime ? transitionClampTime : transitionEventTime), (eventIsRepeat = - 0 <= clampedRenderStartTime$160 - ? clampedRenderStartTime$160 + 0 <= clampedRenderStartTime$171 + ? clampedRenderStartTime$171 : 0 <= endTime ? endTime : renderStartTime), - 0 <= transitionSuspendedTime && - (setCurrentTrackFromLanes(256), - logSuspendedWithDelayPhase( - transitionSuspendedTime, - eventIsRepeat, - lanes - )), + 0 <= transitionSuspendedTime + ? (setCurrentTrackFromLanes(256), + logSuspendedWithDelayPhase( + transitionSuspendedTime, + eventIsRepeat, + lanes + )) + : 0 !== (animatingLanes & 4194048) && + (setCurrentTrackFromLanes(256), + logAnimatingPhase(transitionClampTime, eventIsRepeat)), (eventIsRepeat = transitionEventType), (isSpawnedUpdate = 0 < transitionEventRepeatTime), (isPingedUpdate = 2 === transitionUpdateType), @@ -10714,15 +11795,15 @@ function prepareFreshStack(root, lanes) { ? previousRenderStartTime > endTime && (previousRenderStartTime = endTime) : (previousRenderStartTime = endTime), - 0 < clampedRenderStartTime$160 - ? clampedRenderStartTime$160 > previousRenderStartTime && - (clampedRenderStartTime$160 = previousRenderStartTime) - : (clampedRenderStartTime$160 = previousRenderStartTime), - previousRenderStartTime > clampedRenderStartTime$160 && + 0 < clampedRenderStartTime$171 + ? clampedRenderStartTime$171 > previousRenderStartTime && + (clampedRenderStartTime$171 = previousRenderStartTime) + : (clampedRenderStartTime$171 = previousRenderStartTime), + previousRenderStartTime > clampedRenderStartTime$171 && null !== eventIsRepeat && console.timeStamp( isSpawnedUpdate ? "Consecutive" : "Event: " + eventIsRepeat, - clampedRenderStartTime$160, + clampedRenderStartTime$171, previousRenderStartTime, currentTrack, "Scheduler \u269b", @@ -10756,6 +11837,14 @@ function prepareFreshStack(root, lanes) { (transitionEventRepeatTime = transitionEventTime), (transitionEventTime = -1.1), (transitionClampTime = now())); + 0 !== (lanes & 62914560) && + 0 !== (animatingLanes & 62914560) && + (setCurrentTrackFromLanes(4194304), + logAnimatingPhase(retryClampTime, renderStartTime)); + 0 !== (lanes & 2080374784) && + 0 !== (animatingLanes & 2080374784) && + (setCurrentTrackFromLanes(268435456), + logAnimatingPhase(idleClampTime, renderStartTime)); previousRenderStartTime = root.timeoutHandle; -1 !== previousRenderStartTime && ((root.timeoutHandle = -1), cancelTimeout(previousRenderStartTime)); @@ -10785,15 +11874,7 @@ function prepareFreshStack(root, lanes) { workInProgressRootRecoverableErrors = workInProgressRootConcurrentErrors = null; workInProgressRootDidIncludeRecursiveRenderUpdate = !1; - 0 !== (lanes & 8) && (lanes |= lanes & 32); - endTime = root.entangledLanes; - if (0 !== endTime) - for (root = root.entanglements, endTime &= lanes; 0 < endTime; ) - (clampedRenderStartTime$160 = 31 - clz32(endTime)), - (eventIsRepeat = 1 << clampedRenderStartTime$160), - (lanes |= root[clampedRenderStartTime$160]), - (endTime &= ~eventIsRepeat); - entangledRenderLanes = lanes; + entangledRenderLanes = getEntangledLanes(root, lanes); finishQueueingConcurrentUpdates(); return previousRenderStartTime; } @@ -10907,8 +11988,8 @@ function renderRootSync(root, lanes, shouldYieldForPrerendering) { workLoopSync(); memoizedUpdaters = workInProgressRootExitStatus; break; - } catch (thrownValue$165) { - handleThrow(root, thrownValue$165); + } catch (thrownValue$176) { + handleThrow(root, thrownValue$176); } while (1); lanes && root.shellSuspendCounter++; @@ -11029,8 +12110,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrentByScheduler(); break; - } catch (thrownValue$167) { - handleThrow(root, thrownValue$167); + } catch (thrownValue$178) { + handleThrow(root, thrownValue$178); } while (1); lastContextDependency = currentlyRenderingFiber$1 = null; @@ -11222,124 +12303,131 @@ function commitRoot( root, finishedWork, lanes, - recoverableErrors, - transitions, - didIncludeRenderPhaseUpdate, spawnedLane, updatedLanes, suspendedRetryLanes, - exitStatus, suspendedState, suspendedCommitReason, - completedRenderStartTime, completedRenderEndTime ) { - root.cancelPendingCommit = null; - do flushPendingEffects(); - while (0 !== pendingEffectsStatus); - if (0 !== (executionContext & 6)) - throw Error("Should not already be working."); - setCurrentTrackFromLanes(lanes); - 2 === exitStatus - ? logErroredRenderPhase(completedRenderStartTime, completedRenderEndTime) - : null !== recoverableErrors - ? !supportsUserTiming || - completedRenderEndTime <= completedRenderStartTime || - console.timeStamp( - "Recovered", - completedRenderStartTime, - completedRenderEndTime, - currentTrack, - "Scheduler \u269b", - "error" - ) - : !supportsUserTiming || - completedRenderEndTime <= completedRenderStartTime || - console.timeStamp( - (lanes & 536870912) === lanes - ? "Prepared" - : (lanes & 201326741) === lanes - ? "Hydrated" - : "Render", - completedRenderStartTime, - completedRenderEndTime, - currentTrack, - "Scheduler \u269b", - (lanes & 738197653) === lanes ? "tertiary-dark" : "primary-dark" - ); - if (null !== finishedWork) { - if (finishedWork === root.current) - throw Error( - "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." - ); - didIncludeRenderPhaseUpdate = finishedWork.lanes | finishedWork.childLanes; - didIncludeRenderPhaseUpdate |= concurrentlyUpdatedLanes; - markRootFinished( - root, - lanes, - didIncludeRenderPhaseUpdate, - spawnedLane, - updatedLanes, - suspendedRetryLanes - ); - root === workInProgressRoot && - ((workInProgress = workInProgressRoot = null), - (workInProgressRootRenderLanes = 0)); - pendingFinishedWork = finishedWork; - pendingEffectsRoot = root; - pendingEffectsLanes = lanes; - pendingEffectsRemainingLanes = didIncludeRenderPhaseUpdate; - pendingPassiveTransitions = transitions; - pendingRecoverableErrors = recoverableErrors; - pendingEffectsRenderEndTime = completedRenderEndTime; - pendingSuspendedCommitReason = suspendedCommitReason; - pendingDelayedCommitReason = 0; - pendingSuspendedViewTransitionReason = null; - 0 !== finishedWork.actualDuration || - 0 !== (finishedWork.subtreeFlags & 10256) || - 0 !== (finishedWork.flags & 10256) - ? ((root.callbackNode = null), - (root.callbackPriority = 0), - scheduleCallback(NormalPriority$1, function () { - 0 === pendingDelayedCommitReason && (pendingDelayedCommitReason = 2); - flushPassiveEffects(); - return null; - })) - : ((root.callbackNode = null), (root.callbackPriority = 0)); - commitErrors = null; - commitStartTime = now(); - null !== suspendedCommitReason && - (!supportsUserTiming || - commitStartTime <= completedRenderEndTime || - console.timeStamp( - suspendedCommitReason, - completedRenderEndTime, - commitStartTime, - currentTrack, - "Scheduler \u269b", - "secondary-light" - )); - recoverableErrors = 0 !== (finishedWork.flags & 13878); - if (0 !== (finishedWork.subtreeFlags & 13878) || recoverableErrors) { - recoverableErrors = ReactSharedInternals.T; - ReactSharedInternals.T = null; - transitions = currentUpdatePriority; - currentUpdatePriority = 2; - spawnedLane = executionContext; - executionContext |= 4; - try { - commitBeforeMutationEffects(root, finishedWork, lanes); - } finally { - (executionContext = spawnedLane), - (currentUpdatePriority = transitions), - (ReactSharedInternals.T = recoverableErrors); - } + var remainingLanes = finishedWork.lanes | finishedWork.childLanes; + pendingEffectsRemainingLanes = remainingLanes; + remainingLanes |= concurrentlyUpdatedLanes; + markRootFinished( + root, + lanes, + remainingLanes, + spawnedLane, + updatedLanes, + suspendedRetryLanes + ); + pendingViewTransitionEvents = null; + (lanes & 335544064) === lanes + ? ((pendingTransitionTypes = claimQueuedTransitionTypes(root)), + (spawnedLane = 10262)) + : ((pendingTransitionTypes = null), (spawnedLane = 10256)); + 0 !== finishedWork.actualDuration || + 0 !== (finishedWork.subtreeFlags & spawnedLane) || + 0 !== (finishedWork.flags & spawnedLane) + ? ((root.callbackNode = null), + (root.callbackPriority = 0), + scheduleCallback(NormalPriority$1, function () { + schedulerEvent = global.event; + 0 === pendingDelayedCommitReason && (pendingDelayedCommitReason = 2); + flushPassiveEffects(); + return null; + })) + : ((root.callbackNode = null), (root.callbackPriority = 0)); + commitErrors = null; + commitStartTime = now(); + null !== suspendedCommitReason && + (!supportsUserTiming || + commitStartTime <= completedRenderEndTime || + console.timeStamp( + suspendedCommitReason, + completedRenderEndTime, + commitStartTime, + currentTrack, + "Scheduler \u269b", + "secondary-light" + )); + shouldStartViewTransition = !1; + suspendedCommitReason = 0 !== (finishedWork.flags & 13878); + if (0 !== (finishedWork.subtreeFlags & 13878) || suspendedCommitReason) { + suspendedCommitReason = ReactSharedInternals.T; + ReactSharedInternals.T = null; + completedRenderEndTime = currentUpdatePriority; + currentUpdatePriority = 2; + spawnedLane = executionContext; + executionContext |= 4; + try { + commitBeforeMutationEffects(root, finishedWork, lanes); + } finally { + (executionContext = spawnedLane), + (currentUpdatePriority = completedRenderEndTime), + (ReactSharedInternals.T = suspendedCommitReason); } - pendingEffectsStatus = 1; - flushMutationEffects(); - flushLayoutEffects(); - flushSpawnedWork(); } + pendingEffectsStatus = 1; + shouldStartViewTransition + ? ((animatingLanes |= lanes), + (pendingViewTransition = startViewTransition( + suspendedState, + root.containerInfo, + pendingTransitionTypes, + flushMutationEffects, + flushLayoutEffects, + flushAfterMutationEffects, + flushSpawnedWork, + flushPassiveEffects, + reportViewTransitionError, + suspendedViewTransition, + finishedViewTransition.bind(null, lanes) + ))) + : (flushMutationEffects(), flushLayoutEffects(), flushSpawnedWork()); +} +function reportViewTransitionError(error) { + if (0 !== pendingEffectsStatus) { + var onRecoverableError = pendingEffectsRoot.onRecoverableError; + onRecoverableError(error, { componentStack: null }); + } +} +function suspendedViewTransition(reason) { + commitEndTime = now(); + logCommitPhase( + null === pendingSuspendedCommitReason + ? pendingEffectsRenderEndTime + : commitStartTime, + commitEndTime, + commitErrors, + 1 === pendingDelayedCommitReason + ); + pendingSuspendedCommitReason = pendingSuspendedViewTransitionReason = reason; +} +function finishedViewTransition(lanes) { + 0 !== (animatingLanes & lanes) && + ((animatingLanes &= ~lanes), + 0 !== (lanes & 4194048) && + 0 === (workInProgressRootRenderLanes & 4194048) && + 0 === (pendingEffectsLanes & 4194048) && + (setCurrentTrackFromLanes(256), + logAnimatingPhase(transitionClampTime, now$1())), + 0 !== (lanes & 62914560) && + 0 === (workInProgressRootRenderLanes & 62914560) && + 0 === (pendingEffectsLanes & 62914560) && + (setCurrentTrackFromLanes(4194304), + logAnimatingPhase(retryClampTime, now$1())), + 0 !== (lanes & 2080374784) && + 0 === (workInProgressRootRenderLanes & 2080374784) && + 0 === (pendingEffectsLanes & 2080374784) && + (setCurrentTrackFromLanes(268435456), + logAnimatingPhase(idleClampTime, now$1()))); +} +function flushAfterMutationEffects() { + 3 === pendingEffectsStatus && + ((pendingEffectsStatus = 0), + commitAfterMutationEffectsOnFiber(pendingFinishedWork, pendingEffectsRoot), + (pendingEffectsStatus = 4)); } function flushMutationEffects() { if (1 === pendingEffectsStatus) { @@ -11359,7 +12447,7 @@ function flushMutationEffects() { (inProgressLanes = lanes), (inProgressRoot = root), resetComponentEffectTimers(), - commitMutationEffectsOnFiber(finishedWork, root), + commitMutationEffectsOnFiber(finishedWork, root, lanes), (inProgressRoot = inProgressLanes = null); } finally { (executionContext = prevExecutionContext), @@ -11417,22 +12505,12 @@ function flushLayoutEffects() { suspendedViewTransitionReason = pendingEffectsRenderEndTime; finishedWork = pendingSuspendedCommitReason; commitEndTime = now(); - suspendedViewTransitionReason = - null === finishedWork ? suspendedViewTransitionReason : commitStartTime; - finishedWork = commitEndTime; - lanes = 1 === pendingDelayedCommitReason; - null !== commitErrors - ? logCommitErrored(suspendedViewTransitionReason, finishedWork) - : !supportsUserTiming || - finishedWork <= suspendedViewTransitionReason || - console.timeStamp( - lanes ? "Commit Interrupted View Transition" : "Commit", - suspendedViewTransitionReason, - finishedWork, - currentTrack, - "Scheduler \u269b", - lanes ? "error" : "secondary-dark" - ); + logCommitPhase( + null === finishedWork ? suspendedViewTransitionReason : commitStartTime, + commitEndTime, + commitErrors, + 1 === pendingDelayedCommitReason + ); pendingEffectsStatus = 3; } } @@ -11457,26 +12535,28 @@ function flushSpawnedWork() { 1 !== pendingDelayedCommitReason && (pendingDelayedCommitReason = 3); } pendingEffectsStatus = 0; + startViewTransitionStartTime = pendingViewTransition; + pendingViewTransition = null; requestPaint(); - startViewTransitionStartTime = pendingEffectsRoot; - var finishedWork = pendingFinishedWork; - abortedViewTransition = pendingEffectsLanes; - var recoverableErrors = pendingRecoverableErrors, - rootDidHavePassiveEffects = - 0 !== finishedWork.actualDuration || - 0 !== (finishedWork.subtreeFlags & 10256) || - 0 !== (finishedWork.flags & 10256); - rootDidHavePassiveEffects + abortedViewTransition = pendingEffectsRoot; + var finishedWork = pendingFinishedWork, + lanes = pendingEffectsLanes, + recoverableErrors = pendingRecoverableErrors, + passiveSubtreeMask = (lanes & 335544064) === lanes ? 10262 : 10256; + (passiveSubtreeMask = + 0 !== finishedWork.actualDuration || + 0 !== (finishedWork.subtreeFlags & passiveSubtreeMask) || + 0 !== (finishedWork.flags & passiveSubtreeMask)) ? (pendingEffectsStatus = 5) : ((pendingEffectsStatus = 0), (pendingFinishedWork = pendingEffectsRoot = null), releaseRootPooledCache( - startViewTransitionStartTime, - startViewTransitionStartTime.pendingLanes + abortedViewTransition, + abortedViewTransition.pendingLanes )); - var remainingLanes = startViewTransitionStartTime.pendingLanes; + var remainingLanes = abortedViewTransition.pendingLanes; 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); - remainingLanes = lanesToEventPriority(abortedViewTransition); + remainingLanes = lanesToEventPriority(lanes); finishedWork = finishedWork.stateNode; if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) try { @@ -11504,15 +12584,14 @@ function flushSpawnedWork() { didError ); } catch (err) {} - isDevToolsPresent && startViewTransitionStartTime.memoizedUpdaters.clear(); + isDevToolsPresent && abortedViewTransition.memoizedUpdaters.clear(); if (null !== recoverableErrors) { didError = ReactSharedInternals.T; schedulerPriority = currentUpdatePriority; currentUpdatePriority = 2; ReactSharedInternals.T = null; try { - var onRecoverableError = - startViewTransitionStartTime.onRecoverableError; + var onRecoverableError = abortedViewTransition.onRecoverableError; for ( finishedWork = 0; finishedWork < recoverableErrors.length; @@ -11528,20 +12607,38 @@ function flushSpawnedWork() { (currentUpdatePriority = schedulerPriority); } } + onRecoverableError = pendingViewTransitionEvents; + recoverableError = pendingTransitionTypes; + pendingTransitionTypes = null; + if ( + null !== onRecoverableError && + ((pendingViewTransitionEvents = null), + null === recoverableError && (recoverableError = []), + null !== startViewTransitionStartTime) + ) + for ( + recoverableErrors = 0; + recoverableErrors < onRecoverableError.length; + recoverableErrors++ + ) + (didError = (0, onRecoverableError[recoverableErrors])( + recoverableError + )), + void 0 !== didError && + startViewTransitionStartTime.finished.finally(didError); 0 !== (pendingEffectsLanes & 3) && - 0 !== startViewTransitionStartTime.tag && + 0 !== abortedViewTransition.tag && flushPendingEffects(); - ensureRootIsScheduled(startViewTransitionStartTime); - remainingLanes = startViewTransitionStartTime.pendingLanes; - 0 !== (abortedViewTransition & 261930) && 0 !== (remainingLanes & 42) + ensureRootIsScheduled(abortedViewTransition); + remainingLanes = abortedViewTransition.pendingLanes; + 0 !== (lanes & 261930) && 0 !== (remainingLanes & 42) ? ((nestedUpdateScheduled = !0), - startViewTransitionStartTime === rootWithNestedUpdates + abortedViewTransition === rootWithNestedUpdates ? nestedUpdateCount++ : ((nestedUpdateCount = 0), - (rootWithNestedUpdates = startViewTransitionStartTime))) - : (nestedUpdateCount = 0); - rootDidHavePassiveEffects || - finalizeRender(abortedViewTransition, commitEndTime); + (rootWithNestedUpdates = abortedViewTransition))) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = null)); + passiveSubtreeMask || finalizeRender(lanes, commitEndTime); flushSyncWorkAcrossRoots_impl(0, !1); } } @@ -11552,6 +12649,8 @@ function releaseRootPooledCache(root, remainingLanes) { ((root.pooledCache = null), releaseCache(remainingLanes))); } function flushPendingEffects() { + null !== pendingViewTransition && + ((pendingViewTransition = null), (pendingDelayedCommitReason = 1)); flushMutationEffects(); flushLayoutEffects(); flushSpawnedWork(); @@ -11582,16 +12681,7 @@ function flushPassiveEffects() { commitErrors = null; passiveEffectStartTime = now$1(); 3 === pendingDelayedCommitReason - ? !supportsUserTiming || - passiveEffectStartTime <= commitEndTime || - console.timeStamp( - "Animating", - commitEndTime, - passiveEffectStartTime, - currentTrack, - "Scheduler \u269b", - "secondary-dark" - ) + ? logAnimatingPhase(commitEndTime, passiveEffectStartTime) : !supportsUserTiming || passiveEffectStartTime <= commitEndTime || console.timeStamp( @@ -11736,7 +12826,9 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { (workInProgressRootRenderLanes & 62914560) === workInProgressRootRenderLanes && 300 > now$1() - globalMostRecentFallbackTime) - ? 0 === (executionContext & 2) && prepareFreshStack(root, 0) + ? 0 === (executionContext & 2) + ? prepareFreshStack(root, 0) + : (workInProgressRootPingedLanes |= pingedLanes) : (workInProgressRootPingedLanes |= pingedLanes), workInProgressSuspendedRetryLanes === workInProgressRootRenderLanes && (workInProgressSuspendedRetryLanes = 0)); @@ -11843,7 +12935,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.deletions = null), (workInProgress.actualDuration = -0), (workInProgress.actualStartTime = -1.1)); - workInProgress.flags = current.flags & 65011712; + workInProgress.flags = current.flags & 1206910976; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -11864,7 +12956,7 @@ function createWorkInProgress(current, pendingProps) { return workInProgress; } function resetWorkInProgress(workInProgress, renderLanes) { - workInProgress.flags &= 65011714; + workInProgress.flags &= 1206910978; var current = workInProgress.alternate; null === current ? ((workInProgress.childLanes = 0), @@ -11909,10 +13001,10 @@ function createFiberFromTypeAndProps( ) { var fiberTag = 0; owner = type; - if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); - else if ("string" === typeof type) fiberTag = 5; + if ("function" === typeof owner) shouldConstruct(owner) && (fiberTag = 1); + else if ("string" === typeof owner) fiberTag = 5; else - a: switch (type) { + a: switch (owner) { case REACT_ACTIVITY_TYPE: return ( (type = createFiberImplClass(31, pendingProps, key, mode)), @@ -11949,9 +13041,24 @@ function createFiberFromTypeAndProps( (type.lanes = lanes), type ); + case REACT_LEGACY_HIDDEN_TYPE: + case REACT_VIEW_TRANSITION_TYPE: + return ( + (type = mode | 32), + (type = createFiberImplClass(30, pendingProps, key, type)), + (type.elementType = REACT_VIEW_TRANSITION_TYPE), + (type.lanes = lanes), + (type.stateNode = { + autoName: null, + paired: null, + clones: null, + ref: null + }), + type + ); default: - if ("object" === typeof type && null !== type) - switch (type.$$typeof) { + if ("object" === typeof owner && null !== owner) + switch (owner.$$typeof) { case REACT_CONTEXT_TYPE: fiberTag = 10; break a; @@ -12048,6 +13155,7 @@ function FiberRootNode( this.pooledCache = null; this.pooledCacheLanes = 0; this.formState = formState; + this.transitionTypes = null; this.incompleteTransitions = new Map(); this.passiveEffectDuration = this.effectDuration = -0; this.memoizedUpdaters = new Set(); @@ -12059,7 +13167,12 @@ function createPortal$1(children, containerInfo, implementation) { 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; return { $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, + key: + null == key + ? null + : key === REACT_OPTIMISTIC_KEY + ? REACT_OPTIMISTIC_KEY + : "" + key, children: children, containerInfo: containerInfo, implementation: implementation @@ -12106,30 +13219,84 @@ function shim() { "The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue." ); } -var _nativeFabricUIManage = nativeFabricUIManager, - createNode = _nativeFabricUIManage.createNode, - cloneNodeWithNewChildren = _nativeFabricUIManage.cloneNodeWithNewChildren, +var fabricCreateViewTransitionInstance = + reactPrivateInterface.fabricUIManager.createViewTransitionInstance, + fabricStartViewTransition = + reactPrivateInterface.fabricUIManager.startViewTransition, + fabricStartViewTransitionReadyFinished = + reactPrivateInterface.fabricUIManager.startViewTransitionReadyFinished; +function ViewTransitionPseudoElement(pseudo, name) { + this._pseudo = pseudo; + this._name = name; +} +function measureClonedInstance() { + return { + rect: { x: 0, y: 0, width: 0, height: 0 }, + abs: !1, + clip: !1, + view: !0 + }; +} +function createViewTransitionInstance(name) { + var tag = allocateTag(); + fabricCreateViewTransitionInstance(name, tag); + return { + name: name, + old: new ViewTransitionPseudoElement("old", name), + new: new ViewTransitionPseudoElement("new", name) + }; +} +function startViewTransition( + suspendedState, + rootContainer, + transitionTypes, + mutationCallback, + layoutCallback, + afterMutationCallback, + spawnedWorkCallback, + passiveCallback +) { + suspendedState = fabricStartViewTransition(function () { + mutationCallback(); + layoutCallback(); + afterMutationCallback(); + }); + if (null == suspendedState) + return mutationCallback(), layoutCallback(), spawnedWorkCallback(), null; + suspendedState.ready.then(function () { + spawnedWorkCallback(); + fabricStartViewTransitionReadyFinished(); + }); + suspendedState.finished.finally(function () { + passiveCallback(); + }); + return suspendedState; +} +var createNode = reactPrivateInterface.fabricUIManager.createNode, + cloneNodeWithNewChildren = + reactPrivateInterface.fabricUIManager.cloneNodeWithNewChildren, cloneNodeWithNewChildrenAndProps = - _nativeFabricUIManage.cloneNodeWithNewChildrenAndProps, - cloneNodeWithNewProps = _nativeFabricUIManage.cloneNodeWithNewProps, - createChildNodeSet = _nativeFabricUIManage.createChildSet, - appendChildNode = _nativeFabricUIManage.appendChild, - appendChildNodeToSet = _nativeFabricUIManage.appendChildToSet, - completeRoot = _nativeFabricUIManage.completeRoot, - registerEventHandler = _nativeFabricUIManage.registerEventHandler, - FabricDiscretePriority = _nativeFabricUIManage.unstable_DiscreteEventPriority, + reactPrivateInterface.fabricUIManager.cloneNodeWithNewChildrenAndProps, + cloneNodeWithNewProps = + reactPrivateInterface.fabricUIManager.cloneNodeWithNewProps, + createChildNodeSet = reactPrivateInterface.fabricUIManager.createChildSet, + appendChildNode = reactPrivateInterface.fabricUIManager.appendChild, + appendChildNodeToSet = reactPrivateInterface.fabricUIManager.appendChildToSet, + completeRoot = reactPrivateInterface.fabricUIManager.completeRoot, + registerEventHandler = + reactPrivateInterface.fabricUIManager.registerEventHandler, + FabricDiscretePriority = + reactPrivateInterface.fabricUIManager.unstable_DiscreteEventPriority, FabricContinuousPriority = - _nativeFabricUIManage.unstable_ContinuousEventPriority, - FabricIdlePriority = _nativeFabricUIManage.unstable_IdleEventPriority, + reactPrivateInterface.fabricUIManager.unstable_ContinuousEventPriority, + FabricIdlePriority = + reactPrivateInterface.fabricUIManager.unstable_IdleEventPriority, fabricGetCurrentEventPriority = - _nativeFabricUIManage.unstable_getCurrentEventPriority, + reactPrivateInterface.fabricUIManager.unstable_getCurrentEventPriority, + fabricSuspendOnActiveViewTransition = + reactPrivateInterface.fabricUIManager.suspendOnActiveViewTransition, extraDevToolsConfig = { getInspectorDataForInstance: void 0, - getInspectorDataForViewTag: function () { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, getInspectorDataForViewAtPoint: function () { throw Error( "getInspectorDataForViewAtPoint() is not available in production." @@ -12137,8 +13304,13 @@ var _nativeFabricUIManage = nativeFabricUIManager, } }, getViewConfigForType = - ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get, + reactPrivateInterface.ReactNativeViewConfigRegistry.get, nextReactTag = 2; +function allocateTag() { + var tag = nextReactTag; + nextReactTag += 2; + return tag; +} registerEventHandler && registerEventHandler(dispatchEvent); var PROD_HOST_CONTEXT = { isInAParentText: !0 }; function createTextInstance( @@ -12147,8 +13319,7 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - hostContext = nextReactTag; - nextReactTag += 2; + hostContext = allocateTag(); return { node: createNode( hostContext, @@ -12164,7 +13335,7 @@ function getPublicInstance(instance) { if (null == instance.canonical.publicInstance) { var $jscomp$nullish$tmp0; instance.canonical.publicInstance = - ReactNativePrivateInterface.createPublicInstance( + reactPrivateInterface.createPublicInstance( instance.canonical.nativeTag, instance.canonical.viewConfig, instance.canonical.internalInstanceHandle, @@ -12176,12 +13347,15 @@ function getPublicInstance(instance) { } return instance.canonical.publicInstance; } - return null != instance.containerInfo && - null != instance.containerInfo.publicInstance + return null != instance.containerInfo ? instance.containerInfo.publicInstance - : null != instance._nativeTag - ? instance - : null; + : null; +} +function getPublicInstanceFromHostFiber(fiber) { + fiber = getPublicInstance(fiber.stateNode); + if (null === fiber) + throw Error("Expected to find a host node. This is a bug in React."); + return fiber; } var currentUpdatePriority = 0; function resolveUpdatePriority() { @@ -12200,11 +13374,35 @@ function resolveUpdatePriority() { } return 32; } +var schedulerEvent = void 0; +function resolveEventType() { + var event = global.event; + event && event !== schedulerEvent + ? event.type + ? (event = event.type) + : ((event = event.dispatchConfig), + (event = + null == event || null == event.phasedRegistrationNames + ? null + : (event = + event.phasedRegistrationNames.bubbled || + event.phasedRegistrationNames.captured) + ? event.startsWith("on") + ? event.slice(2).toLowerCase() + : event.toLowerCase() + : null)) + : (event = null); + return event; +} +function resolveEventTimeStamp() { + var event = global.event; + return event && event !== schedulerEvent ? event.timeStamp : -1.1; +} var scheduleTimeout = setTimeout, cancelTimeout = clearTimeout; function cloneHiddenInstance(instance) { var node = instance.node, - updatePayload = ReactNativePrivateInterface.createAttributePayload( + updatePayload = reactPrivateInterface.createAttributePayload( { style: { display: "none" } }, instance.canonical.viewConfig.validAttributes ); @@ -12213,6 +13411,159 @@ function cloneHiddenInstance(instance) { canonical: instance.canonical }; } +function FragmentInstance(fragmentFiber) { + this._fragmentFiber = fragmentFiber; + this._observers = null; +} +FragmentInstance.prototype.observeUsing = function (observer) { + null === this._observers && (this._observers = new Set()); + this._observers.add(observer); + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + observeChild, + observer, + void 0, + void 0 + ); +}; +function observeChild(child, observer) { + child = getPublicInstanceFromHostFiber(child); + observer.observe(child); + return !1; +} +FragmentInstance.prototype.unobserveUsing = function (observer) { + var observers = this._observers; + null !== observers && + observers.has(observer) && + (observers.delete(observer), + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + unobserveChild, + observer, + void 0, + void 0 + )); +}; +function unobserveChild(child, observer) { + child = getPublicInstanceFromHostFiber(child); + observer.unobserve(child); + return !1; +} +FragmentInstance.prototype.compareDocumentPosition = function (otherNode) { + var parentHostFiber = getFragmentParentInstanceOrContainerFiber( + this._fragmentFiber + ); + if (null === parentHostFiber) return Node.DOCUMENT_POSITION_DISCONNECTED; + var children = []; + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + collectChildren, + children, + void 0, + void 0 + ); + if (0 === children.length) { + var parentHostInstance = getPublicInstanceFromHostFiber(parentHostFiber); + children = this._fragmentFiber; + parentHostFiber = getPublicInstanceFromHostFiber; + var parentResult = parentHostInstance.compareDocumentPosition(otherNode); + var result = parentResult; + parentHostInstance === otherNode + ? (result = Node.DOCUMENT_POSITION_CONTAINS) + : parentResult & Node.DOCUMENT_POSITION_CONTAINED_BY && + ((parentHostInstance = [null, null]), + (result = getFragmentParentInstanceOrContainerFiber(children)), + null !== result && + findFragmentInstanceOrTextInstanceSiblings( + parentHostInstance, + children, + result.child, + { foundSelf: !1 } + ), + (children = parentHostInstance[1]), + null === children + ? (result = Node.DOCUMENT_POSITION_PRECEDING) + : ((otherNode = + parentHostFiber(children).compareDocumentPosition(otherNode)), + (result = + 0 === otherNode || otherNode & Node.DOCUMENT_POSITION_FOLLOWING + ? Node.DOCUMENT_POSITION_FOLLOWING + : Node.DOCUMENT_POSITION_PRECEDING))); + return (result |= Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + } + parentHostFiber = getPublicInstanceFromHostFiber(children[0]); + children = getPublicInstanceFromHostFiber(children[children.length - 1]); + parentHostInstance = parentHostFiber.compareDocumentPosition(otherNode); + parentResult = children.compareDocumentPosition(otherNode); + result = + parentHostInstance & Node.DOCUMENT_POSITION_CONTAINED_BY || + parentResult & Node.DOCUMENT_POSITION_CONTAINED_BY; + parentResult = + parentHostInstance & Node.DOCUMENT_POSITION_FOLLOWING && + parentResult & Node.DOCUMENT_POSITION_PRECEDING; + return parentHostFiber === otherNode || + children === otherNode || + result || + parentResult + ? Node.DOCUMENT_POSITION_CONTAINED_BY + : parentHostInstance; +}; +function collectChildren(child, collection) { + collection.push(child); + return !1; +} +FragmentInstance.prototype.getRootNode = function (getRootNodeOptions) { + var parentHostFiber = getFragmentParentInstanceOrContainerFiber( + this._fragmentFiber + ); + return null === parentHostFiber + ? this + : getPublicInstanceFromHostFiber(parentHostFiber).getRootNode( + getRootNodeOptions + ); +}; +FragmentInstance.prototype.getClientRects = function () { + var rects = []; + traverseVisibleInstancesAndTextInstances( + this._fragmentFiber.child, + !1, + collectClientRects, + rects, + void 0, + void 0 + ); + return rects; +}; +function collectClientRects(child, rects) { + child = getPublicInstanceFromHostFiber(child); + rects.push(child.getBoundingClientRect()); + return !1; +} +function addFragmentHandleToFiber(child, fragmentInstance) { + child = getPublicInstanceFromHostFiber(child); + null != child && addFragmentHandleToInstance(child, fragmentInstance); + return !1; +} +function addFragmentHandleToInstance(instance, fragmentInstance) { + null == instance.reactFragments && (instance.reactFragments = new Set()); + instance.reactFragments.add(fragmentInstance); +} +function commitNewChildToFragmentInstance(childInstance, fragmentInstance) { + if (null != childInstance.canonical) { + var publicInstance = getPublicInstance(childInstance); + if (null !== fragmentInstance._observers) { + if (null == publicInstance) + throw Error("Expected to find a host node. This is a bug in React."); + fragmentInstance._observers.forEach(function (observer) { + observer.observe(publicInstance); + }); + } + addFragmentHandleToInstance(publicInstance, fragmentInstance); + } +} var HostTransitionContext = { $$typeof: REACT_CONTEXT_TYPE, Provider: null, @@ -12221,9 +13572,6 @@ var HostTransitionContext = { _currentValue2: null, _threadCount: 0 }, - supportsMicrotasks = - "undefined" !== typeof RN$enableMicrotasksInReact && - !!RN$enableMicrotasksInReact, scheduleMicrotask = "function" === typeof queueMicrotask ? queueMicrotask : scheduleTimeout; getFiberCurrentPropsFromNode$1 = function (instance) { @@ -12243,14 +13591,14 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ onChange: function (from, to, blockNativeResponder) { from && from.stateNode && - nativeFabricUIManager.setIsJSResponder( + reactPrivateInterface.fabricUIManager.setIsJSResponder( from.stateNode.node, !1, blockNativeResponder || !1 ); to && to.stateNode && - nativeFabricUIManager.setIsJSResponder( + reactPrivateInterface.fabricUIManager.setIsJSResponder( to.stateNode.node, !0, blockNativeResponder || !1 @@ -12259,14 +13607,14 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ }); if ( "function" !== - typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog + typeof reactPrivateInterface.ReactFiberErrorDialog.showErrorDialog ) throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); function nativeOnUncaughtError(error, errorInfo) { !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + reactPrivateInterface.ReactFiberErrorDialog.showErrorDialog({ errorBoundary: null, error: error, componentStack: @@ -12275,7 +13623,7 @@ function nativeOnUncaughtError(error, errorInfo) { } function nativeOnCaughtError(error, errorInfo) { !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ + reactPrivateInterface.ReactFiberErrorDialog.showErrorDialog({ errorBoundary: errorInfo.errorBoundary, error: error, componentStack: @@ -12296,26 +13644,26 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - internals$jscomp$inline_1537 = { + internals$jscomp$inline_1630 = { bundleType: 0, - version: "19.2.3", + version: "19.3.0", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.3" + reconcilerVersion: "19.3.0" }; null !== extraDevToolsConfig && - (internals$jscomp$inline_1537.rendererConfig = extraDevToolsConfig); + (internals$jscomp$inline_1630.rendererConfig = extraDevToolsConfig); if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1855 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1972 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1855.isDisabled && - hook$jscomp$inline_1855.supportsFiber + !hook$jscomp$inline_1972.isDisabled && + hook$jscomp$inline_1972.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1855.inject( - internals$jscomp$inline_1537 + (rendererID = hook$jscomp$inline_1972.inject( + internals$jscomp$inline_1630 )), - (injectedHook = hook$jscomp$inline_1855); + (injectedHook = hook$jscomp$inline_1972); } catch (err) {} } exports.createPortal = function (children, containerTag) { @@ -12327,51 +13675,36 @@ exports.createPortal = function (children, containerTag) { ); }; exports.dispatchCommand = function (handle, command, args) { - var nativeTag = - null != handle._nativeTag - ? handle._nativeTag - : ReactNativePrivateInterface.getNativeTagFromPublicInstance(handle); - null != nativeTag && - ((handle = ReactNativePrivateInterface.getNodeFromPublicInstance(handle)), - null != handle - ? nativeFabricUIManager.dispatchCommand(handle, command, args) - : ReactNativePrivateInterface.UIManager.dispatchViewManagerCommand( - nativeTag, - command, - args - )); + handle = reactPrivateInterface.getNodeFromPublicInstance(handle); + null != handle && + reactPrivateInterface.fabricUIManager.dispatchCommand( + handle, + command, + args + ); }; exports.findHostInstance_DEPRECATED = function (componentOrHandle) { return null == componentOrHandle ? null : componentOrHandle.canonical && componentOrHandle.canonical.publicInstance ? componentOrHandle.canonical.publicInstance - : componentOrHandle._nativeTag - ? componentOrHandle - : findHostInstance(componentOrHandle); + : findHostInstance(componentOrHandle); }; exports.findNodeHandle = function (componentOrHandle) { if (null == componentOrHandle) return null; if ("number" === typeof componentOrHandle) return componentOrHandle; - if (componentOrHandle._nativeTag) return componentOrHandle._nativeTag; if ( null != componentOrHandle.canonical && null != componentOrHandle.canonical.nativeTag ) return componentOrHandle.canonical.nativeTag; var nativeTag = - ReactNativePrivateInterface.getNativeTagFromPublicInstance( - componentOrHandle - ); + reactPrivateInterface.getNativeTagFromPublicInstance(componentOrHandle); if (nativeTag) return nativeTag; componentOrHandle = findHostInstance(componentOrHandle); return null == componentOrHandle ? componentOrHandle - : null != componentOrHandle._nativeTag - ? componentOrHandle._nativeTag - : ReactNativePrivateInterface.getNativeTagFromPublicInstance( - componentOrHandle - ); + : reactPrivateInterface.getNativeTagFromPublicInstance(componentOrHandle); }; exports.getNodeFromInternalInstanceHandle = function (internalInstanceHandle) { return ( @@ -12389,7 +13722,7 @@ exports.getPublicInstanceFromInternalInstanceHandle = function ( : 6 === internalInstanceHandle.tag ? (null == instance.publicInstance && (instance.publicInstance = - ReactNativePrivateInterface.createPublicTextInstance( + reactPrivateInterface.createPublicTextInstance( internalInstanceHandle )), instance.publicInstance) @@ -12426,7 +13759,7 @@ exports.render = function ( (onRecoverableError = options.onRecoverableError); options = { publicInstance: - ReactNativePrivateInterface.createPublicRootInstance(containerTag), + reactPrivateInterface.createPublicRootInstance(containerTag), containerTag: containerTag }; concurrentRoot = concurrentRoot ? 1 : 0; @@ -12472,18 +13805,12 @@ exports.render = function ( return element; }; exports.sendAccessibilityEvent = function (handle, eventType) { - var nativeTag = - null != handle._nativeTag - ? handle._nativeTag - : ReactNativePrivateInterface.getNativeTagFromPublicInstance(handle); - null != nativeTag && - ((handle = ReactNativePrivateInterface.getNodeFromPublicInstance(handle)), - null != handle - ? nativeFabricUIManager.sendAccessibilityEvent(handle, eventType) - : ReactNativePrivateInterface.legacySendAccessibilityEvent( - nativeTag, - eventType - )); + handle = reactPrivateInterface.getNodeFromPublicInstance(handle); + null != handle && + reactPrivateInterface.fabricUIManager.sendAccessibilityEvent( + handle, + eventType + ); }; exports.stopSurface = function (containerTag) { var root = roots.get(containerTag); diff --git a/packages/react-native/package.json b/packages/react-native/package.json index a09745bf963c..62f2dd368fcc 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -143,7 +143,7 @@ }, "peerDependencies": { "@types/react": "^19.1.1", - "react": "^19.2.3" + "react": "^19.3.0" }, "peerDependenciesMeta": { "@types/react": { @@ -173,7 +173,7 @@ "react-devtools-core": "^6.1.5", "react-refresh": "^0.14.0", "regenerator-runtime": "^0.13.2", - "scheduler": "0.27.0", + "scheduler": "0.28.0", "semver": "^7.1.3", "stacktrace-parser": "^0.1.10", "tinyglobby": "^0.2.15", diff --git a/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-benchmark-itest.js b/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-benchmark-itest.js index 2b2614bca945..c5955a43bd84 100644 --- a/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-benchmark-itest.js +++ b/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-benchmark-itest.js @@ -62,188 +62,206 @@ function createNestedViewsWithLayout( ); } -const {isOSS} = Fantom.getConstants(); - -if (isOSS) { - it('is not supported in OSS yet', () => { - expect(true).toBe(true); - }); -} else { - Fantom.unstable_benchmark - .suite('Event Dispatching') - .test( - 'dispatch event, flat (1 handler)', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); - }, - { - beforeAll: () => { - ref = React.createRef(); - }, - beforeEach: () => { - root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render( - {}} - style={{width: 10, height: 10}} - />, - ); - }); - }, - afterEach: () => { - root.destroy(); +Fantom.unstable_benchmark + .suite('Event Dispatching') + .test( + 'dispatch event, flat (1 handler)', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); }, - ) - .test( - 'dispatch event, nested 10 deep (bubbling)', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + beforeEach: () => { + root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render( + {}} + style={{width: 10, height: 10}} + />, + ); + }); }, - { - beforeAll: () => { - ref = React.createRef(); - }, - beforeEach: () => { - root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render(createNestedViews(10, ref)); - }); - }, - afterEach: () => { - root.destroy(); + afterEach: () => { + root.destroy(); + }, + }, + ) + .test( + 'dispatch event, nested 10 deep (bubbling)', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); }, - ) - .test( - 'dispatch event, nested 50 deep (bubbling)', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + beforeEach: () => { + root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(createNestedViews(10, ref)); + }); }, - { - beforeAll: () => { - ref = React.createRef(); - }, - beforeEach: () => { - root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render(createNestedViews(50, ref)); - }); - }, - afterEach: () => { - root.destroy(); + afterEach: () => { + root.destroy(); + }, + }, + ) + .test( + 'dispatch event, nested 50 deep (bubbling)', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); }, - ) - .test( - 'dispatch event, nested 10 deep (no handlers on ancestors)', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + beforeEach: () => { + root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(createNestedViews(50, ref)); + }); }, - { - beforeAll: () => { - ref = React.createRef(); - }, - beforeEach: () => { - root = Fantom.createRoot(); - Fantom.runTask(() => { - let views: React.MixedElement = ( - {}} - style={{width: 10, height: 10}} - /> - ); - for (let i = 0; i < 10; i++) { - views = {views}; - } - root.render(views); - }); - }, - afterEach: () => { - root.destroy(); + afterEach: () => { + root.destroy(); + }, + }, + ) + .test( + 'dispatch event, nested 10 deep (no handlers on ancestors)', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); }, - ) - .test( - 'dispatch event with stopPropagation, nested 10 deep', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + beforeEach: () => { + root = Fantom.createRoot(); + Fantom.runTask(() => { + let views: React.MixedElement = ( + {}} + style={{width: 10, height: 10}} + /> + ); + for (let i = 0; i < 10; i++) { + views = {views}; + } + root.render(views); + }); + }, + afterEach: () => { + root.destroy(); }, - { - beforeAll: () => { - ref = React.createRef(); + }, + ) + .test( + 'dispatch event with stopPropagation, nested 10 deep', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, }, - beforeEach: () => { - root = Fantom.createRoot(); - Fantom.runTask(() => { - let views: React.MixedElement = ( - { - e.stopPropagation(); - }} - style={{width: 10, height: 10}} - /> + ); + }, + { + beforeAll: () => { + ref = React.createRef(); + }, + beforeEach: () => { + root = Fantom.createRoot(); + Fantom.runTask(() => { + let views: React.MixedElement = ( + { + e.stopPropagation(); + }} + style={{width: 10, height: 10}} + /> + ); + for (let i = 0; i < 10; i++) { + views = ( + {}}> + {views} + ); - for (let i = 0; i < 10; i++) { - views = ( - {}}> - {views} - - ); - } - root.render(views); - }); - }, - afterEach: () => { - root.destroy(); + } + root.render(views); + }); + }, + afterEach: () => { + root.destroy(); + }, + }, + ) + .test( + 'render + dispatch, flat (handler update cost)', + () => { + Fantom.runTask(() => { + root.render( + {}} + style={{width: 10, height: 10}} + />, + ); + }); + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); }, - ) - .test( - 'render + dispatch, flat (handler update cost)', - () => { + beforeEach: () => { + root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); }, - { - beforeAll: () => { - ref = React.createRef(); - }, - beforeEach: () => { - root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render( - {}} - style={{width: 10, height: 10}} - />, - ); - }); - }, - afterEach: () => { - root.destroy(); - }, + afterEach: () => { + root.destroy(); }, - ) - .test( - 'dispatch event, nested 50 deep (bubbling), stable tree', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); - }, - { - beforeAll: () => { - ref = React.createRef(); - root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render(createNestedViews(50, ref)); - }); - }, - afterAll: () => { - root.destroy(); + }, + ) + .test( + 'dispatch event, nested 50 deep (bubbling), stable tree', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); + root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(createNestedViews(50, ref)); + }); }, - ) - .test( - 'dispatch event, nested 50 deep (no handlers on ancestors), stable tree', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + afterAll: () => { + root.destroy(); }, - { - beforeAll: () => { - ref = React.createRef(); - root = Fantom.createRoot(); - Fantom.runTask(() => { - let views: React.MixedElement = ( - {}} - style={{width: 10, height: 10}} - /> - ); - for (let i = 0; i < 50; i++) { - views = {views}; - } - root.render(views); - }); - }, - afterAll: () => { - root.destroy(); + }, + ) + .test( + 'dispatch event, nested 50 deep (no handlers on ancestors), stable tree', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); + root = Fantom.createRoot(); + Fantom.runTask(() => { + let views: React.MixedElement = ( + {}} + style={{width: 10, height: 10}} + /> + ); + for (let i = 0; i < 50; i++) { + views = {views}; + } + root.render(views); + }); }, - ) - .test( - 'dispatch onLayout event, flat (1 handler)', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onLayout', - {layout: {x: 0, y: 0, width: 100, height: 50}}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + afterAll: () => { + root.destroy(); }, - { - beforeAll: () => { - ref = React.createRef(); - root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render( - {}} - style={{width: 10, height: 10}} - />, - ); - }); - // Flush the layout events emitted during the initial layout pass so - // they are not measured as part of the dispatched event below. - Fantom.flushAllNativeEvents(); - }, - afterAll: () => { - root.destroy(); + }, + ) + .test( + 'dispatch onLayout event, flat (1 handler)', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onLayout', + {layout: {x: 0, y: 0, width: 100, height: 50}}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); + root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render( + {}} + style={{width: 10, height: 10}} + />, + ); + }); + // Flush the layout events emitted during the initial layout pass so + // they are not measured as part of the dispatched event below. + Fantom.flushAllNativeEvents(); }, - ) - .test( - 'dispatch onLayout event, nested 10 deep (direct, no bubbling)', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onLayout', - {layout: {x: 0, y: 0, width: 100, height: 50}}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + afterAll: () => { + root.destroy(); }, - { - beforeAll: () => { - ref = React.createRef(); - root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render(createNestedViewsWithLayout(10, ref)); - }); - Fantom.flushAllNativeEvents(); - }, - afterAll: () => { - root.destroy(); + }, + ) + .test( + 'dispatch onLayout event, nested 10 deep (direct, no bubbling)', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onLayout', + {layout: {x: 0, y: 0, width: 100, height: 50}}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); + root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(createNestedViewsWithLayout(10, ref)); + }); + Fantom.flushAllNativeEvents(); }, - ) - .test( - 'dispatch onLayout event, nested 50 deep (direct, no bubbling)', - () => { - Fantom.dispatchNativeEvent( - ref, - 'onLayout', - {layout: {x: 0, y: 0, width: 100, height: 50}}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + afterAll: () => { + root.destroy(); }, - { - beforeAll: () => { - ref = React.createRef(); - root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render(createNestedViewsWithLayout(50, ref)); - }); - Fantom.flushAllNativeEvents(); - }, - afterAll: () => { - root.destroy(); + }, + ) + .test( + 'dispatch onLayout event, nested 50 deep (direct, no bubbling)', + () => { + Fantom.dispatchNativeEvent( + ref, + 'onLayout', + {layout: {x: 0, y: 0, width: 100, height: 50}}, + { + category: Fantom.NativeEventCategory.Discrete, }, + ); + }, + { + beforeAll: () => { + ref = React.createRef(); + root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(createNestedViewsWithLayout(50, ref)); + }); + Fantom.flushAllNativeEvents(); }, - ); -} + afterAll: () => { + root.destroy(); + }, + }, + ); diff --git a/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js b/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js index 46339e19f518..39eaf48e52d1 100644 --- a/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js +++ b/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js @@ -20,112 +20,106 @@ import * as FabricUIManager from 'react-native/Libraries/ReactNative/FabricUIMan const UIManager = nullthrows(FabricUIManager.getFabricUIManager()); describe('Event Dispatching', () => { - // The OSS renderer hasn't been synced yet to have these changes - // TODO(next-major) Remove this condition - if (!Fantom.getConstants().isOSS) { - it('provides the native event timeStamp (camel case) when available', () => { - const root = Fantom.createRoot(); + it('provides the native event timeStamp (camel case) when available', () => { + const root = Fantom.createRoot(); - const ref = React.createRef>(); + const ref = React.createRef>(); - const onPointerUp = jest.fn((e: PointerEvent) => { - e.persist(); - }); + const onPointerUp = jest.fn((e: PointerEvent) => { + e.persist(); + }); - Fantom.runTask(() => { - root.render(); - }); + Fantom.runTask(() => { + root.render(); + }); - expect(onPointerUp).toHaveBeenCalledTimes(0); + expect(onPointerUp).toHaveBeenCalledTimes(0); - const NATIVE_EVENT_TIMESTAMP = 1234; + const NATIVE_EVENT_TIMESTAMP = 1234; - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0, timeStamp: NATIVE_EVENT_TIMESTAMP}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0, timeStamp: NATIVE_EVENT_TIMESTAMP}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - expect(onPointerUp).toHaveBeenCalledTimes(1); - expect(onPointerUp.mock.calls[0][0].timeStamp).toBe( - NATIVE_EVENT_TIMESTAMP, - ); - }); + expect(onPointerUp).toHaveBeenCalledTimes(1); + expect(onPointerUp.mock.calls[0][0].timeStamp).toBe(NATIVE_EVENT_TIMESTAMP); + }); - it('provides a default timeStamp when the native event timeStamp is NOT available', () => { - const root = Fantom.createRoot(); + it('provides a default timeStamp when the native event timeStamp is NOT available', () => { + const root = Fantom.createRoot(); - const ref = React.createRef>(); + const ref = React.createRef>(); - const onPointerUp = jest.fn((e: PointerEvent) => { - e.persist(); - }); + const onPointerUp = jest.fn((e: PointerEvent) => { + e.persist(); + }); - Fantom.runTask(() => { - root.render(); - }); + Fantom.runTask(() => { + root.render(); + }); - expect(onPointerUp).toHaveBeenCalledTimes(0); + expect(onPointerUp).toHaveBeenCalledTimes(0); - const lowerBound = performance.now(); + const lowerBound = performance.now(); - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - const upperBound = performance.now(); + const upperBound = performance.now(); - expect(onPointerUp).toHaveBeenCalledTimes(1); - expect(onPointerUp.mock.calls[0][0].timeStamp).toBeGreaterThanOrEqual( - lowerBound, - ); - expect(onPointerUp.mock.calls[0][0].timeStamp).toBeLessThanOrEqual( - upperBound, - ); - }); + expect(onPointerUp).toHaveBeenCalledTimes(1); + expect(onPointerUp.mock.calls[0][0].timeStamp).toBeGreaterThanOrEqual( + lowerBound, + ); + expect(onPointerUp.mock.calls[0][0].timeStamp).toBeLessThanOrEqual( + upperBound, + ); + }); - it('exposes dispatched events in the global scope', () => { - const root = Fantom.createRoot(); + it('exposes dispatched events in the global scope', () => { + const root = Fantom.createRoot(); - const ref = React.createRef>(); + const ref = React.createRef>(); - let globalEventIsDispatchedEvent: boolean = false; + let globalEventIsDispatchedEvent: boolean = false; - const onPointerUp = jest.fn((e: PointerEvent) => { - globalEventIsDispatchedEvent = global.event === e; - }); + const onPointerUp = jest.fn((e: PointerEvent) => { + globalEventIsDispatchedEvent = global.event === e; + }); - Fantom.runTask(() => { - root.render(); - }); + Fantom.runTask(() => { + root.render(); + }); - const globalEventValueBeforeDispatch = {type: 'some-event'}; - global.event = globalEventValueBeforeDispatch; + const globalEventValueBeforeDispatch = {type: 'some-event'}; + global.event = globalEventValueBeforeDispatch; - expect(onPointerUp).toHaveBeenCalledTimes(0); + expect(onPointerUp).toHaveBeenCalledTimes(0); - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - expect(onPointerUp).toHaveBeenCalledTimes(1); - expect(globalEventIsDispatchedEvent).toBe(true); - expect(global.event).toBe(globalEventValueBeforeDispatch); - }); - } + expect(onPointerUp).toHaveBeenCalledTimes(1); + expect(globalEventIsDispatchedEvent).toBe(true); + expect(global.event).toBe(globalEventValueBeforeDispatch); + }); it('dispatches events with discrete priority', () => { const root = Fantom.createRoot(); diff --git a/packages/react-native/src/private/renderer/core/__tests__/EventTargetDispatching-itest.js b/packages/react-native/src/private/renderer/core/__tests__/EventTargetDispatching-itest.js index 9f3fd6984f49..6f29ab14d718 100644 --- a/packages/react-native/src/private/renderer/core/__tests__/EventTargetDispatching-itest.js +++ b/packages/react-native/src/private/renderer/core/__tests__/EventTargetDispatching-itest.js @@ -56,51 +56,482 @@ function createNestedViewsWithLayout( ); } -const {isOSS} = Fantom.getConstants(); +describe('EventTarget-based Event Dispatching', () => { + it('dispatches basic press event to handler', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + const onPointerUp = jest.fn(); + + Fantom.runTask(() => { + root.render(); + }); + + expect(onPointerUp).toHaveBeenCalledTimes(0); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 10, y: 20}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(onPointerUp).toHaveBeenCalledTimes(1); + }); + + it('event bubbles from child to parent', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const parentHandler = jest.fn(); + + Fantom.runTask(() => { + root.render( + + + , + ); + }); + + expect(parentHandler).toHaveBeenCalledTimes(0); + + Fantom.dispatchNativeEvent( + childRef, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(parentHandler).toHaveBeenCalledTimes(1); + }); + + it('capture phase fires before bubble phase', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const order: Array = []; + + Fantom.runTask(() => { + root.render( + { + order.push('parent-capture'); + }} + onPointerUp={() => { + order.push('parent-bubble'); + }}> + { + order.push('child-capture'); + }} + onPointerUp={() => { + order.push('child-bubble'); + }} + /> + , + ); + }); + + Fantom.dispatchNativeEvent( + childRef, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(order).toEqual([ + 'parent-capture', + 'child-capture', + 'child-bubble', + 'parent-bubble', + ]); + }); + + it('stopPropagation prevents parent handler from firing', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const parentHandler = jest.fn(); + const childHandler = jest.fn((e: PointerEvent) => { + e.stopPropagation(); + }); + + Fantom.runTask(() => { + root.render( + + + , + ); + }); + + Fantom.dispatchNativeEvent( + childRef, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(childHandler).toHaveBeenCalledTimes(1); + expect(parentHandler).toHaveBeenCalledTimes(0); + }); + + it('event object has correct nativeEvent property', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + let capturedNativeEvent: NativePointerEvent | null = null; + + const onPointerUp = jest.fn((e: PointerEvent) => { + // Capture nativeEvent inside the handler because legacy SyntheticEvent + // nullifies properties after dispatch. + capturedNativeEvent = e.nativeEvent; + }); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 42, y: 99}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(onPointerUp).toHaveBeenCalledTimes(1); + expect(capturedNativeEvent?.x).toBe(42); + expect(capturedNativeEvent?.y).toBe(99); + }); + + it('handler updates correctly when prop changes', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + const firstHandler = jest.fn(); + const secondHandler = jest.fn(); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(firstHandler).toHaveBeenCalledTimes(1); + expect(secondHandler).toHaveBeenCalledTimes(0); + + // Re-render with a new handler + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(firstHandler).toHaveBeenCalledTimes(1); + expect(secondHandler).toHaveBeenCalledTimes(1); + }); + + it('handler removal stops event dispatch', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + const handler = jest.fn(); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); + + // Re-render without the handler + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); + }); + + it('multiple event types on the same element dispatch correctly', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + const onPointerUp = jest.fn(); + const onPointerMove = jest.fn(); + + Fantom.runTask(() => { + root.render( + , + ); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(onPointerUp).toHaveBeenCalledTimes(1); + expect(onPointerMove).toHaveBeenCalledTimes(0); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerMove', + {x: 1, y: 1}, + { + category: Fantom.NativeEventCategory.Continuous, + }, + ); + + expect(onPointerUp).toHaveBeenCalledTimes(1); + expect(onPointerMove).toHaveBeenCalledTimes(1); + }); + + it('preventDefault sets defaultPrevented to true', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + let defaultPrevented: ?boolean = false; + + const handler = jest.fn((e: PointerEvent) => { + e.preventDefault(); + defaultPrevented = e.defaultPrevented; + }); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); + expect(defaultPrevented).toBe(true); + }); + + it('isDefaultPrevented() returns true after preventDefault()', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + let result = false; + + const handler = jest.fn((e: PointerEvent) => { + e.preventDefault(); + result = e.isDefaultPrevented(); + }); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); + expect(result).toBe(true); + }); + + it('isDefaultPrevented() returns false when preventDefault() was not called', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + let result = true; + + const handler = jest.fn((e: PointerEvent) => { + result = e.isDefaultPrevented(); + }); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); + expect(result).toBe(false); + }); + + it('isPropagationStopped() returns true after stopPropagation()', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + let result = false; + + const handler = jest.fn((e: PointerEvent) => { + e.stopPropagation(); + result = e.isPropagationStopped(); + }); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); + expect(result).toBe(true); + }); + + it('isPropagationStopped() returns false when stopPropagation() was not called', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + let result = true; + + const handler = jest.fn((e: PointerEvent) => { + result = e.isPropagationStopped(); + }); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); + expect(result).toBe(false); + }); + + it('persist() is callable and does not throw', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); -(isOSS ? describe.skip : describe)( - 'EventTarget-based Event Dispatching', - () => { - it('dispatches basic press event to handler', () => { + const handler = jest.fn((e: PointerEvent) => { + e.persist(); + }); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); + }); + + // --- addEventListener / removeEventListener on refs --- + // These tests require both `enableNativeEventTargetEventDispatching` and + // `enableImperativeEvents` to be enabled, since the public `addEventListener` + // API on element refs is only available when both flags are on. They are + // skipped for the other flag combinations. + + (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() && + ReactNativeFeatureFlags.enableImperativeEvents() + ? describe + : describe.skip)('addEventListener / removeEventListener', () => { + it('addEventListener on a ref receives dispatched events', () => { const root = Fantom.createRoot(); const ref = React.createRef>(); - const onPointerUp = jest.fn(); + const handler = jest.fn(); Fantom.runTask(() => { - root.render(); + root.render(); }); - expect(onPointerUp).toHaveBeenCalledTimes(0); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(ref.current).addEventListener('pointerup', handler); Fantom.dispatchNativeEvent( ref, 'onPointerUp', - {x: 10, y: 20}, + {x: 0, y: 0}, { category: Fantom.NativeEventCategory.Discrete, }, ); - expect(onPointerUp).toHaveBeenCalledTimes(1); + expect(handler).toHaveBeenCalledTimes(1); }); - it('event bubbles from child to parent', () => { + it('removeEventListener stops receiving events', () => { const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const parentHandler = jest.fn(); + const ref = React.createRef>(); + const handler = jest.fn(); Fantom.runTask(() => { - root.render( - - - , - ); + root.render(); }); - expect(parentHandler).toHaveBeenCalledTimes(0); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(ref.current).addEventListener('pointerup', handler); Fantom.dispatchNativeEvent( - childRef, + ref, 'onPointerUp', {x: 0, y: 0}, { @@ -108,28 +539,33 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(parentHandler).toHaveBeenCalledTimes(1); + expect(handler).toHaveBeenCalledTimes(1); + + asEventTarget(ref.current).removeEventListener('pointerup', handler); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); }); - it('capture phase fires before bubble phase', () => { + it('addEventListener with capture option fires during capture phase', () => { const root = Fantom.createRoot(); + const parentRef = React.createRef>(); const childRef = React.createRef>(); const order: Array = []; Fantom.runTask(() => { root.render( - { - order.push('parent-capture'); - }} - onPointerUp={() => { - order.push('parent-bubble'); - }}> + { - order.push('child-capture'); - }} onPointerUp={() => { order.push('child-bubble'); }} @@ -138,6 +574,15 @@ const {isOSS} = Fantom.getConstants(); ); }); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(parentRef.current).addEventListener( + 'pointerup', + () => { + order.push('parent-capture'); + }, + {capture: true}, + ); + Fantom.dispatchNativeEvent( childRef, 'onPointerUp', @@ -147,30 +592,26 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(order).toEqual([ - 'parent-capture', - 'child-capture', - 'child-bubble', - 'parent-bubble', - ]); + expect(order).toEqual(['parent-capture', 'child-bubble']); }); - it('stopPropagation prevents parent handler from firing', () => { + it('addEventListener receives events that bubble from children', () => { const root = Fantom.createRoot(); + const parentRef = React.createRef>(); const childRef = React.createRef>(); - const parentHandler = jest.fn(); - const childHandler = jest.fn((e: PointerEvent) => { - e.stopPropagation(); - }); + const handler = jest.fn(); Fantom.runTask(() => { root.render( - - + + , ); }); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(parentRef.current).addEventListener('pointerup', handler); + Fantom.dispatchNativeEvent( childRef, 'onPointerUp', @@ -180,68 +621,73 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(childHandler).toHaveBeenCalledTimes(1); - expect(parentHandler).toHaveBeenCalledTimes(0); + expect(handler).toHaveBeenCalledTimes(1); }); - it('event object has correct nativeEvent property', () => { + // --- Declarative (prop) vs imperative (addEventListener) ordering --- + + it('declarative prop handler fires before imperative addEventListener listener', () => { const root = Fantom.createRoot(); const ref = React.createRef>(); - let capturedNativeEvent: NativePointerEvent | null = null; + const order: Array = []; - const onPointerUp = jest.fn((e: PointerEvent) => { - // Capture nativeEvent inside the handler because legacy SyntheticEvent - // nullifies properties after dispatch. - capturedNativeEvent = e.nativeEvent; + Fantom.runTask(() => { + root.render( + { + order.push('prop'); + }} + />, + ); }); - Fantom.runTask(() => { - root.render(); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(ref.current).addEventListener('pointerup', () => { + order.push('addEventListener'); }); Fantom.dispatchNativeEvent( ref, 'onPointerUp', - {x: 42, y: 99}, + {x: 0, y: 0}, { category: Fantom.NativeEventCategory.Discrete, }, ); - expect(onPointerUp).toHaveBeenCalledTimes(1); - expect(capturedNativeEvent?.x).toBe(42); - expect(capturedNativeEvent?.y).toBe(99); + expect(order).toEqual(['prop', 'addEventListener']); }); - it('handler updates correctly when prop changes', () => { + it('declarative capture prop fires before imperative capture addEventListener', () => { const root = Fantom.createRoot(); - const ref = React.createRef>(); - const firstHandler = jest.fn(); - const secondHandler = jest.fn(); + const parentRef = React.createRef>(); + const childRef = React.createRef>(); + const order: Array = []; Fantom.runTask(() => { - root.render(); + root.render( + { + order.push('parent-prop-capture'); + }}> + + , + ); }); - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(parentRef.current).addEventListener( + 'pointerup', + () => { + order.push('parent-imperative-capture'); }, + {capture: true}, ); - expect(firstHandler).toHaveBeenCalledTimes(1); - expect(secondHandler).toHaveBeenCalledTimes(0); - - // Re-render with a new handler - Fantom.runTask(() => { - root.render(); - }); - Fantom.dispatchNativeEvent( - ref, + childRef, 'onPointerUp', {x: 0, y: 0}, { @@ -249,35 +695,34 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(firstHandler).toHaveBeenCalledTimes(1); - expect(secondHandler).toHaveBeenCalledTimes(1); + expect(order).toEqual([ + 'parent-prop-capture', + 'parent-imperative-capture', + ]); }); - it('handler removal stops event dispatch', () => { + it('stopImmediatePropagation in prop handler prevents addEventListener listeners', () => { const root = Fantom.createRoot(); const ref = React.createRef>(); - const handler = jest.fn(); + const imperativeHandler = jest.fn(); Fantom.runTask(() => { - root.render(); + root.render( + { + e.stopImmediatePropagation(); + }} + />, + ); }); - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(ref.current).addEventListener( + 'pointerup', + imperativeHandler, ); - expect(handler).toHaveBeenCalledTimes(1); - - // Re-render without the handler - Fantom.runTask(() => { - root.render(); - }); - Fantom.dispatchNativeEvent( ref, 'onPointerUp', @@ -287,25 +732,26 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(handler).toHaveBeenCalledTimes(1); + expect(imperativeHandler).toHaveBeenCalledTimes(0); }); - it('multiple event types on the same element dispatch correctly', () => { + it('stopImmediatePropagation in addEventListener does not affect prop handler', () => { const root = Fantom.createRoot(); const ref = React.createRef>(); - const onPointerUp = jest.fn(); - const onPointerMove = jest.fn(); + const propHandler = jest.fn(); Fantom.runTask(() => { - root.render( - , - ); + root.render(); }); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(ref.current).addEventListener( + 'pointerup', + (e: $FlowFixMe) => { + e.stopImmediatePropagation(); + }, + ); + Fantom.dispatchNativeEvent( ref, 'onPointerUp', @@ -315,38 +761,66 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(onPointerUp).toHaveBeenCalledTimes(1); - expect(onPointerMove).toHaveBeenCalledTimes(0); + // Prop handler fires first, so it is not affected + expect(propHandler).toHaveBeenCalledTimes(1); + }); - Fantom.dispatchNativeEvent( - ref, - 'onPointerMove', - {x: 1, y: 1}, - { - category: Fantom.NativeEventCategory.Continuous, - }, - ); - - expect(onPointerUp).toHaveBeenCalledTimes(1); - expect(onPointerMove).toHaveBeenCalledTimes(1); - }); - - it('preventDefault sets defaultPrevented to true', () => { + it('full dispatch order: capture props, capture imperative, bubble props, bubble imperative', () => { const root = Fantom.createRoot(); - const ref = React.createRef>(); - let defaultPrevented: ?boolean = false; + const parentRef = React.createRef>(); + const childRef = React.createRef>(); + const order: Array = []; - const handler = jest.fn((e: PointerEvent) => { - e.preventDefault(); - defaultPrevented = e.defaultPrevented; + Fantom.runTask(() => { + root.render( + { + order.push('parent-prop-capture'); + }} + onPointerUp={() => { + order.push('parent-prop-bubble'); + }}> + { + order.push('child-prop-capture'); + }} + onPointerUp={() => { + order.push('child-prop-bubble'); + }} + /> + , + ); }); - Fantom.runTask(() => { - root.render(); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(parentRef.current).addEventListener( + 'pointerup', + () => { + order.push('parent-imperative-capture'); + }, + {capture: true}, + ); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(parentRef.current).addEventListener('pointerup', () => { + order.push('parent-imperative-bubble'); + }); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(childRef.current).addEventListener( + 'pointerup', + () => { + order.push('child-imperative-capture'); + }, + {capture: true}, + ); + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(childRef.current).addEventListener('pointerup', () => { + order.push('child-imperative-bubble'); }); Fantom.dispatchNativeEvent( - ref, + childRef, 'onPointerUp', {x: 0, y: 0}, { @@ -354,26 +828,93 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(handler).toHaveBeenCalledTimes(1); - expect(defaultPrevented).toBe(true); + expect(order).toEqual([ + 'parent-prop-capture', + 'parent-imperative-capture', + 'child-prop-capture', + 'child-imperative-capture', + 'child-prop-bubble', + 'child-imperative-bubble', + 'parent-prop-bubble', + 'parent-imperative-bubble', + ]); }); + }); - it('isDefaultPrevented() returns true after preventDefault()', () => { - const root = Fantom.createRoot(); - const ref = React.createRef>(); - let result = false; + it('event has type and bubbles properties when using EventTarget dispatching', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + let eventType: unknown = null; + let eventBubbles: unknown = null; - const handler = jest.fn((e: PointerEvent) => { - e.preventDefault(); - result = e.isDefaultPrevented(); - }); + const handler = jest.fn((e: PointerEvent) => { + eventType = e.type; + eventBubbles = e.bubbles; + }); + + Fantom.runTask(() => { + root.render(); + }); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(handler).toHaveBeenCalledTimes(1); + // The legacy SyntheticEvent does not set type/bubbles as standard + // DOM Event properties. The new EventTarget-based path does. + if (eventType != null) { + expect(eventType).toBe('pointerup'); + expect(eventBubbles).toBe(true); + } + }); + + (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() + ? it + : it.skip)( + 'event.target points to the original target and event.currentTarget changes at each step', + () => { + const root = Fantom.createRoot(); + const parentRef = React.createRef>(); + const childRef = React.createRef>(); + const targets: Array<{target: unknown, currentTarget: unknown}> = []; Fantom.runTask(() => { - root.render(); + root.render( + { + targets.push({ + target: e.target, + currentTarget: e.currentTarget, + }); + }} + onPointerUp={(e: $FlowFixMe) => { + targets.push({ + target: e.target, + currentTarget: e.currentTarget, + }); + }}> + { + targets.push({ + target: e.target, + currentTarget: e.currentTarget, + }); + }} + /> + , + ); }); Fantom.dispatchNativeEvent( - ref, + childRef, 'onPointerUp', {x: 0, y: 0}, { @@ -381,25 +922,92 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(handler).toHaveBeenCalledTimes(1); - expect(result).toBe(true); - }); + expect(targets).toHaveLength(3); - it('isDefaultPrevented() returns false when preventDefault() was not called', () => { + // event.target is always the original target element + expect(targets[0].target).toBe(childRef.current); + expect(targets[1].target).toBe(childRef.current); + expect(targets[2].target).toBe(childRef.current); + + // event.currentTarget changes at each propagation step + // Capture: parent + expect(targets[0].currentTarget).toBe(parentRef.current); + // Bubble: child, then parent + expect(targets[1].currentTarget).toBe(childRef.current); + expect(targets[2].currentTarget).toBe(parentRef.current); + }, + ); + + (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() && + ReactNativeFeatureFlags.enableImperativeEvents() + ? it + : it.skip)( + 'direct (non-bubbling) events do not propagate via addEventListener', + () => { const root = Fantom.createRoot(); - const ref = React.createRef>(); - let result = true; + const parentRef = React.createRef>(); + const childRef = React.createRef>(); + const childHandler = jest.fn(); + const parentImperativeHandler = jest.fn(); - const handler = jest.fn((e: PointerEvent) => { - result = e.isDefaultPrevented(); + Fantom.runTask(() => { + root.render( + + + , + ); }); + // Add an imperative listener on the parent for the 'layout' event. + // Since 'layout' is a direct (non-bubbling) event, this should NOT + // fire when we dispatch onLayout on the child. + // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag + asEventTarget(parentRef.current).addEventListener( + 'layout', + parentImperativeHandler, + ); + + const childCallsBefore = childHandler.mock.calls.length; + + Fantom.dispatchNativeEvent( + childRef, + 'onLayout', + {layout: {x: 0, y: 0, width: 100, height: 50}}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + // Child handler fires + expect(childHandler.mock.calls.length - childCallsBefore).toBeGreaterThan( + 0, + ); + // Parent's addEventListener listener does NOT fire because layout + // is a non-bubbling (direct) event + expect(parentImperativeHandler).toHaveBeenCalledTimes(0); + }, + ); + + (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() && + ReactNativeFeatureFlags.enableImperativeEvents() + ? describe + : describe.skip)('bubbling to document element and document', () => { + it('event bubbles from child up to the document element', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const documentElementHandler = jest.fn(); + Fantom.runTask(() => { - root.render(); + root.render(); }); + asEventTarget(root.document.documentElement).addEventListener( + 'pointerup', + documentElementHandler, + ); + Fantom.dispatchNativeEvent( - ref, + childRef, 'onPointerUp', {x: 0, y: 0}, { @@ -407,26 +1015,25 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(handler).toHaveBeenCalledTimes(1); - expect(result).toBe(false); + expect(documentElementHandler).toHaveBeenCalledTimes(1); }); - it('isPropagationStopped() returns true after stopPropagation()', () => { + it('event bubbles from child up to the document', () => { const root = Fantom.createRoot(); - const ref = React.createRef>(); - let result = false; - - const handler = jest.fn((e: PointerEvent) => { - e.stopPropagation(); - result = e.isPropagationStopped(); - }); + const childRef = React.createRef>(); + const documentHandler = jest.fn(); Fantom.runTask(() => { - root.render(); + root.render(); }); + asEventTarget(root.document).addEventListener( + 'pointerup', + documentHandler, + ); + Fantom.dispatchNativeEvent( - ref, + childRef, 'onPointerUp', {x: 0, y: 0}, { @@ -434,25 +1041,38 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(handler).toHaveBeenCalledTimes(1); - expect(result).toBe(true); + expect(documentHandler).toHaveBeenCalledTimes(1); }); - it('isPropagationStopped() returns false when stopPropagation() was not called', () => { + it('event bubbles from a deeply nested child up to document element and document', () => { const root = Fantom.createRoot(); - const ref = React.createRef>(); - let result = true; - - const handler = jest.fn((e: PointerEvent) => { - result = e.isPropagationStopped(); - }); + const childRef = React.createRef>(); + const documentElementHandler = jest.fn(); + const documentHandler = jest.fn(); Fantom.runTask(() => { - root.render(); + root.render( + + + + + + + , + ); }); + asEventTarget(root.document.documentElement).addEventListener( + 'pointerup', + documentElementHandler, + ); + asEventTarget(root.document).addEventListener( + 'pointerup', + documentHandler, + ); + Fantom.dispatchNativeEvent( - ref, + childRef, 'onPointerUp', {x: 0, y: 0}, { @@ -460,24 +1080,55 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(handler).toHaveBeenCalledTimes(1); - expect(result).toBe(false); + expect(documentElementHandler).toHaveBeenCalledTimes(1); + expect(documentHandler).toHaveBeenCalledTimes(1); }); - it('persist() is callable and does not throw', () => { + it('capture phase on document fires before capture phase on document element', () => { const root = Fantom.createRoot(); - const ref = React.createRef>(); + const childRef = React.createRef>(); + const order: Array = []; - const handler = jest.fn((e: PointerEvent) => { - e.persist(); + Fantom.runTask(() => { + root.render( + { + order.push('child-capture'); + }} + onPointerUp={() => { + order.push('child-bubble'); + }} + />, + ); }); - Fantom.runTask(() => { - root.render(); + asEventTarget(root.document).addEventListener( + 'pointerup', + () => { + order.push('document-capture'); + }, + {capture: true}, + ); + asEventTarget(root.document.documentElement).addEventListener( + 'pointerup', + () => { + order.push('documentElement-capture'); + }, + {capture: true}, + ); + asEventTarget(root.document.documentElement).addEventListener( + 'pointerup', + () => { + order.push('documentElement-bubble'); + }, + ); + asEventTarget(root.document).addEventListener('pointerup', () => { + order.push('document-bubble'); }); Fantom.dispatchNativeEvent( - ref, + childRef, 'onPointerUp', {x: 0, y: 0}, { @@ -485,344 +1136,233 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(handler).toHaveBeenCalledTimes(1); + expect(order).toEqual([ + 'document-capture', + 'documentElement-capture', + 'child-capture', + 'child-bubble', + 'documentElement-bubble', + 'document-bubble', + ]); }); - // --- addEventListener / removeEventListener on refs --- - // These tests require both `enableNativeEventTargetEventDispatching` and - // `enableImperativeEvents` to be enabled, since the public `addEventListener` - // API on element refs is only available when both flags are on. They are - // skipped for the other flag combinations. + it('event.target points to the original child and event.currentTarget transitions through document element and document', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const targets: Array<{target: unknown, currentTarget: unknown}> = []; - (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() && - ReactNativeFeatureFlags.enableImperativeEvents() - ? describe - : describe.skip)('addEventListener / removeEventListener', () => { - it('addEventListener on a ref receives dispatched events', () => { - const root = Fantom.createRoot(); - const ref = React.createRef>(); - const handler = jest.fn(); + Fantom.runTask(() => { + root.render(); + }); - Fantom.runTask(() => { - root.render(); - }); + asEventTarget(root.document.documentElement).addEventListener( + 'pointerup', + (e: $FlowFixMe) => { + targets.push({target: e.target, currentTarget: e.currentTarget}); + }, + ); + asEventTarget(root.document).addEventListener( + 'pointerup', + (e: $FlowFixMe) => { + targets.push({target: e.target, currentTarget: e.currentTarget}); + }, + ); - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(ref.current).addEventListener('pointerup', handler); + Fantom.dispatchNativeEvent( + childRef, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + expect(targets).toHaveLength(2); - expect(handler).toHaveBeenCalledTimes(1); - }); + // event.target is always the original target element + expect(targets[0].target).toBe(childRef.current); + expect(targets[1].target).toBe(childRef.current); - it('removeEventListener stops receiving events', () => { - const root = Fantom.createRoot(); - const ref = React.createRef>(); - const handler = jest.fn(); + // event.currentTarget changes at each propagation step + expect(targets[0].currentTarget).toBe(root.document.documentElement); + expect(targets[1].currentTarget).toBe(root.document); + }); - Fantom.runTask(() => { - root.render(); - }); + it('stopPropagation on document element prevents document handler from firing', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const documentHandler = jest.fn(); + const documentElementHandler = jest.fn((e: $FlowFixMe) => { + e.stopPropagation(); + }); - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(ref.current).addEventListener('pointerup', handler); + Fantom.runTask(() => { + root.render(); + }); - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + asEventTarget(root.document.documentElement).addEventListener( + 'pointerup', + documentElementHandler, + ); + asEventTarget(root.document).addEventListener( + 'pointerup', + documentHandler, + ); - expect(handler).toHaveBeenCalledTimes(1); + Fantom.dispatchNativeEvent( + childRef, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - asEventTarget(ref.current).removeEventListener('pointerup', handler); + expect(documentElementHandler).toHaveBeenCalledTimes(1); + expect(documentHandler).toHaveBeenCalledTimes(0); + }); - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + it('removeEventListener on document element stops events from being received', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const documentElementHandler = jest.fn(); - expect(handler).toHaveBeenCalledTimes(1); + Fantom.runTask(() => { + root.render(); }); - it('addEventListener with capture option fires during capture phase', () => { - const root = Fantom.createRoot(); - const parentRef = React.createRef>(); - const childRef = React.createRef>(); - const order: Array = []; - - Fantom.runTask(() => { - root.render( - - { - order.push('child-bubble'); - }} - /> - , - ); - }); - - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(parentRef.current).addEventListener( - 'pointerup', - () => { - order.push('parent-capture'); - }, - {capture: true}, - ); + asEventTarget(root.document.documentElement).addEventListener( + 'pointerup', + documentElementHandler, + ); - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + Fantom.dispatchNativeEvent( + childRef, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - expect(order).toEqual(['parent-capture', 'child-bubble']); - }); + expect(documentElementHandler).toHaveBeenCalledTimes(1); - it('addEventListener receives events that bubble from children', () => { - const root = Fantom.createRoot(); - const parentRef = React.createRef>(); - const childRef = React.createRef>(); - const handler = jest.fn(); + asEventTarget(root.document.documentElement).removeEventListener( + 'pointerup', + documentElementHandler, + ); - Fantom.runTask(() => { - root.render( - - - , - ); - }); + Fantom.dispatchNativeEvent( + childRef, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(parentRef.current).addEventListener('pointerup', handler); + expect(documentElementHandler).toHaveBeenCalledTimes(1); + }); - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + it('direct (non-bubbling) events do not reach the document element or document', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const childHandler = jest.fn(); + const documentElementHandler = jest.fn(); + const documentHandler = jest.fn(); - expect(handler).toHaveBeenCalledTimes(1); + Fantom.runTask(() => { + root.render(); }); - // --- Declarative (prop) vs imperative (addEventListener) ordering --- - - it('declarative prop handler fires before imperative addEventListener listener', () => { - const root = Fantom.createRoot(); - const ref = React.createRef>(); - const order: Array = []; + asEventTarget(root.document.documentElement).addEventListener( + 'layout', + documentElementHandler, + ); + asEventTarget(root.document).addEventListener('layout', documentHandler); - Fantom.runTask(() => { - root.render( - { - order.push('prop'); - }} - />, - ); - }); + const childCallsBefore = childHandler.mock.calls.length; - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(ref.current).addEventListener('pointerup', () => { - order.push('addEventListener'); - }); - - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + Fantom.dispatchNativeEvent( + childRef, + 'onLayout', + {layout: {x: 0, y: 0, width: 100, height: 50}}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - expect(order).toEqual(['prop', 'addEventListener']); - }); + // Child handler fires + expect(childHandler.mock.calls.length - childCallsBefore).toBeGreaterThan( + 0, + ); + // Non-bubbling events don't reach the document element or the document + expect(documentElementHandler).toHaveBeenCalledTimes(0); + expect(documentHandler).toHaveBeenCalledTimes(0); + }); + }); - it('declarative capture prop fires before imperative capture addEventListener', () => { - const root = Fantom.createRoot(); - const parentRef = React.createRef>(); - const childRef = React.createRef>(); - const order: Array = []; + it('stopPropagation in capture phase prevents all bubble-phase handlers', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const order: Array = []; - Fantom.runTask(() => { - root.render( - { - order.push('parent-prop-capture'); - }}> - - , - ); - }); - - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(parentRef.current).addEventListener( - 'pointerup', - () => { - order.push('parent-imperative-capture'); - }, - {capture: true}, - ); + Fantom.runTask(() => { + root.render( + { + order.push('parent-capture'); + e.stopPropagation(); + }} + onPointerUp={() => { + order.push('parent-bubble'); + }}> + { + order.push('child-capture'); + }} + onPointerUp={() => { + order.push('child-bubble'); + }} + /> + , + ); + }); - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + Fantom.dispatchNativeEvent( + childRef, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - expect(order).toEqual([ - 'parent-prop-capture', - 'parent-imperative-capture', - ]); - }); + // Only the parent capture handler should fire; everything else is stopped + expect(order).toEqual(['parent-capture']); + }); - it('stopImmediatePropagation in prop handler prevents addEventListener listeners', () => { - const root = Fantom.createRoot(); - const ref = React.createRef>(); - const imperativeHandler = jest.fn(); + describe('error handling', () => { + it('error in event handler does not break dispatch to subsequent listeners', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const parentHandler = jest.fn(); - Fantom.runTask(() => { - root.render( + Fantom.runTask(() => { + root.render( + { - e.stopImmediatePropagation(); + ref={childRef} + onPointerUp={() => { + throw new Error('handler error'); }} - />, - ); - }); - - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(ref.current).addEventListener( - 'pointerup', - imperativeHandler, - ); - - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); - - expect(imperativeHandler).toHaveBeenCalledTimes(0); - }); - - it('stopImmediatePropagation in addEventListener does not affect prop handler', () => { - const root = Fantom.createRoot(); - const ref = React.createRef>(); - const propHandler = jest.fn(); - - Fantom.runTask(() => { - root.render(); - }); - - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(ref.current).addEventListener( - 'pointerup', - (e: $FlowFixMe) => { - e.stopImmediatePropagation(); - }, - ); - - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, + /> + , ); - - // Prop handler fires first, so it is not affected - expect(propHandler).toHaveBeenCalledTimes(1); }); - it('full dispatch order: capture props, capture imperative, bubble props, bubble imperative', () => { - const root = Fantom.createRoot(); - const parentRef = React.createRef>(); - const childRef = React.createRef>(); - const order: Array = []; - - Fantom.runTask(() => { - root.render( - { - order.push('parent-prop-capture'); - }} - onPointerUp={() => { - order.push('parent-prop-bubble'); - }}> - { - order.push('child-prop-capture'); - }} - onPointerUp={() => { - order.push('child-prop-bubble'); - }} - /> - , - ); - }); - - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(parentRef.current).addEventListener( - 'pointerup', - () => { - order.push('parent-imperative-capture'); - }, - {capture: true}, - ); - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(parentRef.current).addEventListener('pointerup', () => { - order.push('parent-imperative-bubble'); - }); - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(childRef.current).addEventListener( - 'pointerup', - () => { - order.push('child-imperative-capture'); - }, - {capture: true}, - ); - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(childRef.current).addEventListener('pointerup', () => { - order.push('child-imperative-bubble'); - }); - + const dispatch = () => Fantom.dispatchNativeEvent( childRef, 'onPointerUp', @@ -832,948 +1372,396 @@ const {isOSS} = Fantom.getConstants(); }, ); - expect(order).toEqual([ - 'parent-prop-capture', - 'parent-imperative-capture', - 'child-prop-capture', - 'child-imperative-capture', - 'child-prop-bubble', - 'child-imperative-bubble', - 'parent-prop-bubble', - 'parent-imperative-bubble', - ]); - }); + expect(dispatch).toThrow('handler error'); + + // The parent bubble handler should still fire despite child's error + expect(parentHandler).toHaveBeenCalledTimes(1); }); + }); - it('event has type and bubbles properties when using EventTarget dispatching', () => { + (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() + ? describe + : describe.skip)('event timestamps', () => { + it('event preserves native timestamp from nativeEvent.timeStamp', () => { const root = Fantom.createRoot(); const ref = React.createRef>(); - let eventType: unknown = null; - let eventBubbles: unknown = null; - - const handler = jest.fn((e: PointerEvent) => { - eventType = e.type; - eventBubbles = e.bubbles; - }); + let eventTimeStamp: unknown = null; Fantom.runTask(() => { - root.render(); + root.render( + { + eventTimeStamp = e.timeStamp; + }} + />, + ); }); + const nativeTimestamp = 12345.678; Fantom.dispatchNativeEvent( ref, 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, + {x: 0, y: 0, timeStamp: nativeTimestamp}, + {category: Fantom.NativeEventCategory.Discrete}, ); - expect(handler).toHaveBeenCalledTimes(1); - // The legacy SyntheticEvent does not set type/bubbles as standard - // DOM Event properties. The new EventTarget-based path does. - if (eventType != null) { - expect(eventType).toBe('pointerup'); - expect(eventBubbles).toBe(true); - } + expect(eventTimeStamp).toBe(nativeTimestamp); }); + }); - (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() - ? it - : it.skip)( - 'event.target points to the original target and event.currentTarget changes at each step', - () => { - const root = Fantom.createRoot(); - const parentRef = React.createRef>(); - const childRef = React.createRef>(); - const targets: Array<{target: unknown, currentTarget: unknown}> = []; - - Fantom.runTask(() => { - root.render( - { - targets.push({ - target: e.target, - currentTarget: e.currentTarget, - }); - }} - onPointerUp={(e: $FlowFixMe) => { - targets.push({ - target: e.target, - currentTarget: e.currentTarget, - }); - }}> - { - targets.push({ - target: e.target, - currentTarget: e.currentTarget, - }); - }} - /> - , - ); - }); - - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); - - expect(targets).toHaveLength(3); - - // event.target is always the original target element - expect(targets[0].target).toBe(childRef.current); - expect(targets[1].target).toBe(childRef.current); - expect(targets[2].target).toBe(childRef.current); - - // event.currentTarget changes at each propagation step - // Capture: parent - expect(targets[0].currentTarget).toBe(parentRef.current); - // Bubble: child, then parent - expect(targets[1].currentTarget).toBe(childRef.current); - expect(targets[2].currentTarget).toBe(parentRef.current); - }, - ); - - (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() && - ReactNativeFeatureFlags.enableImperativeEvents() - ? it - : it.skip)( - 'direct (non-bubbling) events do not propagate via addEventListener', - () => { - const root = Fantom.createRoot(); - const parentRef = React.createRef>(); - const childRef = React.createRef>(); - const childHandler = jest.fn(); - const parentImperativeHandler = jest.fn(); - - Fantom.runTask(() => { - root.render( - - - , - ); - }); - - // Add an imperative listener on the parent for the 'layout' event. - // Since 'layout' is a direct (non-bubbling) event, this should NOT - // fire when we dispatch onLayout on the child. - // Temporary: ReadOnlyNode extends EventTarget at runtime behind feature flag - asEventTarget(parentRef.current).addEventListener( - 'layout', - parentImperativeHandler, - ); - - const childCallsBefore = childHandler.mock.calls.length; - - Fantom.dispatchNativeEvent( - childRef, - 'onLayout', - {layout: {x: 0, y: 0, width: 100, height: 50}}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); - - // Child handler fires - expect( - childHandler.mock.calls.length - childCallsBefore, - ).toBeGreaterThan(0); - // Parent's addEventListener listener does NOT fire because layout - // is a non-bubbling (direct) event - expect(parentImperativeHandler).toHaveBeenCalledTimes(0); - }, - ); + // --- dispatchConfig --- - (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() && - ReactNativeFeatureFlags.enableImperativeEvents() - ? describe - : describe.skip)('bubbling to document element and document', () => { - it('event bubbles from child up to the document element', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const documentElementHandler = jest.fn(); - - Fantom.runTask(() => { - root.render(); - }); - - asEventTarget(root.document.documentElement).addEventListener( - 'pointerup', - documentElementHandler, - ); + describe('dispatchConfig', () => { + it('includes phasedRegistrationNames on bubbling events', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + let capturedDispatchConfig: $FlowFixMe = null; - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, + Fantom.runTask(() => { + root.render( + { + capturedDispatchConfig = e.dispatchConfig; + }} + />, ); - - expect(documentElementHandler).toHaveBeenCalledTimes(1); }); - it('event bubbles from child up to the document', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const documentHandler = jest.fn(); + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + {category: Fantom.NativeEventCategory.Discrete}, + ); - Fantom.runTask(() => { - root.render(); - }); + expect(capturedDispatchConfig).not.toBeNull(); + expect(capturedDispatchConfig.phasedRegistrationNames.bubbled).toBe( + 'onPointerUp', + ); + expect(capturedDispatchConfig.phasedRegistrationNames.captured).toBe( + 'onPointerUpCapture', + ); + }); - asEventTarget(root.document).addEventListener( - 'pointerup', - documentHandler, - ); + it('includes registrationName on direct events', () => { + const root = Fantom.createRoot(); + const ref = React.createRef>(); + let capturedDispatchConfig: $FlowFixMe = null; - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, + Fantom.runTask(() => { + root.render( + { + capturedDispatchConfig = e.dispatchConfig; + }} + />, ); - - expect(documentHandler).toHaveBeenCalledTimes(1); }); - it('event bubbles from a deeply nested child up to document element and document', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const documentElementHandler = jest.fn(); - const documentHandler = jest.fn(); - - Fantom.runTask(() => { - root.render( - - - - - - - , - ); - }); + Fantom.dispatchNativeEvent( + ref, + 'onLayout', + {x: 0, y: 0, width: 100, height: 50}, + {category: Fantom.NativeEventCategory.Discrete}, + ); - asEventTarget(root.document.documentElement).addEventListener( - 'pointerup', - documentElementHandler, - ); - asEventTarget(root.document).addEventListener( - 'pointerup', - documentHandler, - ); + expect(capturedDispatchConfig).not.toBeNull(); + expect(capturedDispatchConfig.registrationName).toBe('onLayout'); + }); + }); - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + // --- skipBubbling --- - expect(documentElementHandler).toHaveBeenCalledTimes(1); - expect(documentHandler).toHaveBeenCalledTimes(1); - }); + describe('skipBubbling (pointerenter / pointerleave)', () => { + it('does not bubble onPointerEnter to ancestor views', () => { + const root = Fantom.createRoot(); - it('capture phase on document fires before capture phase on document element', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const order: Array = []; + const childRef = React.createRef>(); - Fantom.runTask(() => { - root.render( - { - order.push('child-capture'); - }} - onPointerUp={() => { - order.push('child-bubble'); - }} - />, - ); - }); - - asEventTarget(root.document).addEventListener( - 'pointerup', - () => { - order.push('document-capture'); - }, - {capture: true}, - ); - asEventTarget(root.document.documentElement).addEventListener( - 'pointerup', - () => { - order.push('documentElement-capture'); - }, - {capture: true}, - ); - asEventTarget(root.document.documentElement).addEventListener( - 'pointerup', - () => { - order.push('documentElement-bubble'); - }, - ); - asEventTarget(root.document).addEventListener('pointerup', () => { - order.push('document-bubble'); - }); + const parentSpy = jest.fn((_e: PointerEvent) => {}); + const childSpy = jest.fn((_e: PointerEvent) => {}); - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, + Fantom.runTask(() => { + root.render( + + + , ); - - expect(order).toEqual([ - 'document-capture', - 'documentElement-capture', - 'child-capture', - 'child-bubble', - 'documentElement-bubble', - 'document-bubble', - ]); }); - it('event.target points to the original child and event.currentTarget transitions through document element and document', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const targets: Array<{target: unknown, currentTarget: unknown}> = []; - - Fantom.runTask(() => { - root.render(); - }); - - asEventTarget(root.document.documentElement).addEventListener( - 'pointerup', - (e: $FlowFixMe) => { - targets.push({target: e.target, currentTarget: e.currentTarget}); - }, - ); - asEventTarget(root.document).addEventListener( - 'pointerup', - (e: $FlowFixMe) => { - targets.push({target: e.target, currentTarget: e.currentTarget}); - }, - ); - - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + Fantom.dispatchNativeEvent( + childRef, + 'onPointerEnter', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.ContinuousStart, + }, + ); - expect(targets).toHaveLength(2); + expect(childSpy).toHaveBeenCalledTimes(1); + expect(parentSpy).toHaveBeenCalledTimes(0); + }); - // event.target is always the original target element - expect(targets[0].target).toBe(childRef.current); - expect(targets[1].target).toBe(childRef.current); + it('does not bubble onPointerLeave to ancestor views', () => { + const root = Fantom.createRoot(); - // event.currentTarget changes at each propagation step - expect(targets[0].currentTarget).toBe(root.document.documentElement); - expect(targets[1].currentTarget).toBe(root.document); - }); + const childRef = React.createRef>(); - it('stopPropagation on document element prevents document handler from firing', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const documentHandler = jest.fn(); - const documentElementHandler = jest.fn((e: $FlowFixMe) => { - e.stopPropagation(); - }); - - Fantom.runTask(() => { - root.render(); - }); - - asEventTarget(root.document.documentElement).addEventListener( - 'pointerup', - documentElementHandler, - ); - asEventTarget(root.document).addEventListener( - 'pointerup', - documentHandler, - ); + const parentSpy = jest.fn((_e: PointerEvent) => {}); + const childSpy = jest.fn((_e: PointerEvent) => {}); - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, + Fantom.runTask(() => { + root.render( + + + , ); - - expect(documentElementHandler).toHaveBeenCalledTimes(1); - expect(documentHandler).toHaveBeenCalledTimes(0); }); - it('removeEventListener on document element stops events from being received', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const documentElementHandler = jest.fn(); - - Fantom.runTask(() => { - root.render(); - }); - - asEventTarget(root.document.documentElement).addEventListener( - 'pointerup', - documentElementHandler, - ); - - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + Fantom.dispatchNativeEvent( + childRef, + 'onPointerLeave', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.ContinuousEnd, + }, + ); - expect(documentElementHandler).toHaveBeenCalledTimes(1); + expect(childSpy).toHaveBeenCalledTimes(1); + expect(parentSpy).toHaveBeenCalledTimes(0); + }); - asEventTarget(root.document.documentElement).removeEventListener( - 'pointerup', - documentElementHandler, - ); + it('still fires onPointerEnterCapture on ancestors during the capture phase', () => { + const root = Fantom.createRoot(); - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + const childRef = React.createRef>(); - expect(documentElementHandler).toHaveBeenCalledTimes(1); + const callOrder: Array = []; + const parentCaptureSpy = jest.fn((_e: PointerEvent) => { + callOrder.push('parentCapture'); }); - - it('direct (non-bubbling) events do not reach the document element or document', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const childHandler = jest.fn(); - const documentElementHandler = jest.fn(); - const documentHandler = jest.fn(); - - Fantom.runTask(() => { - root.render(); - }); - - asEventTarget(root.document.documentElement).addEventListener( - 'layout', - documentElementHandler, - ); - asEventTarget(root.document).addEventListener( - 'layout', - documentHandler, - ); - - const childCallsBefore = childHandler.mock.calls.length; - - Fantom.dispatchNativeEvent( - childRef, - 'onLayout', - {layout: {x: 0, y: 0, width: 100, height: 50}}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); - - // Child handler fires - expect( - childHandler.mock.calls.length - childCallsBefore, - ).toBeGreaterThan(0); - // Non-bubbling events don't reach the document element or the document - expect(documentElementHandler).toHaveBeenCalledTimes(0); - expect(documentHandler).toHaveBeenCalledTimes(0); + const childSpy = jest.fn((_e: PointerEvent) => { + callOrder.push('child'); }); - }); - - it('stopPropagation in capture phase prevents all bubble-phase handlers', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const order: Array = []; Fantom.runTask(() => { root.render( - { - order.push('parent-capture'); - e.stopPropagation(); - }} - onPointerUp={() => { - order.push('parent-bubble'); - }}> - { - order.push('child-capture'); - }} - onPointerUp={() => { - order.push('child-bubble'); - }} - /> + + , ); }); Fantom.dispatchNativeEvent( childRef, - 'onPointerUp', + 'onPointerEnter', {x: 0, y: 0}, { - category: Fantom.NativeEventCategory.Discrete, + category: Fantom.NativeEventCategory.ContinuousStart, }, ); - // Only the parent capture handler should fire; everything else is stopped - expect(order).toEqual(['parent-capture']); - }); - - describe('error handling', () => { - it('error in event handler does not break dispatch to subsequent listeners', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const parentHandler = jest.fn(); - - Fantom.runTask(() => { - root.render( - - { - throw new Error('handler error'); - }} - /> - , - ); - }); - - const dispatch = () => - Fantom.dispatchNativeEvent( - childRef, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); - - expect(dispatch).toThrow('handler error'); - - // The parent bubble handler should still fire despite child's error - expect(parentHandler).toHaveBeenCalledTimes(1); - }); + expect(parentCaptureSpy).toHaveBeenCalledTimes(1); + expect(childSpy).toHaveBeenCalledTimes(1); + expect(callOrder).toEqual(['parentCapture', 'child']); }); - (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() - ? describe - : describe.skip)('event timestamps', () => { - it('event preserves native timestamp from nativeEvent.timeStamp', () => { - const root = Fantom.createRoot(); - const ref = React.createRef>(); - let eventTimeStamp: unknown = null; - - Fantom.runTask(() => { - root.render( - { - eventTimeStamp = e.timeStamp; - }} - />, - ); - }); - - const nativeTimestamp = 12345.678; - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0, timeStamp: nativeTimestamp}, - {category: Fantom.NativeEventCategory.Discrete}, - ); - - expect(eventTimeStamp).toBe(nativeTimestamp); - }); - }); - - // --- dispatchConfig --- - - describe('dispatchConfig', () => { - it('includes phasedRegistrationNames on bubbling events', () => { - const root = Fantom.createRoot(); - const ref = React.createRef>(); - let capturedDispatchConfig: $FlowFixMe = null; + it('still bubbles non-skipBubbling events (onPointerDown) to ancestor views', () => { + const root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render( - { - capturedDispatchConfig = e.dispatchConfig; - }} - />, - ); - }); + const childRef = React.createRef>(); - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - {category: Fantom.NativeEventCategory.Discrete}, - ); + const parentSpy = jest.fn((_e: PointerEvent) => {}); + const childSpy = jest.fn((_e: PointerEvent) => {}); - expect(capturedDispatchConfig).not.toBeNull(); - expect(capturedDispatchConfig.phasedRegistrationNames.bubbled).toBe( - 'onPointerUp', - ); - expect(capturedDispatchConfig.phasedRegistrationNames.captured).toBe( - 'onPointerUpCapture', + Fantom.runTask(() => { + root.render( + + + , ); }); - it('includes registrationName on direct events', () => { - const root = Fantom.createRoot(); - const ref = React.createRef>(); - let capturedDispatchConfig: $FlowFixMe = null; - - Fantom.runTask(() => { - root.render( - { - capturedDispatchConfig = e.dispatchConfig; - }} - />, - ); - }); - - Fantom.dispatchNativeEvent( - ref, - 'onLayout', - {x: 0, y: 0, width: 100, height: 50}, - {category: Fantom.NativeEventCategory.Discrete}, - ); + Fantom.dispatchNativeEvent( + childRef, + 'onPointerDown', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - expect(capturedDispatchConfig).not.toBeNull(); - expect(capturedDispatchConfig.registrationName).toBe('onLayout'); - }); + expect(childSpy).toHaveBeenCalledTimes(1); + expect(parentSpy).toHaveBeenCalledTimes(1); }); + }); - // --- skipBubbling --- - - describe('skipBubbling (pointerenter / pointerleave)', () => { - it('does not bubble onPointerEnter to ancestor views', () => { - const root = Fantom.createRoot(); - - const childRef = React.createRef>(); - - const parentSpy = jest.fn((_e: PointerEvent) => {}); - const childSpy = jest.fn((_e: PointerEvent) => {}); - - Fantom.runTask(() => { - root.render( - - - , - ); - }); - - Fantom.dispatchNativeEvent( - childRef, - 'onPointerEnter', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.ContinuousStart, - }, - ); - - expect(childSpy).toHaveBeenCalledTimes(1); - expect(parentSpy).toHaveBeenCalledTimes(0); - }); - - it('does not bubble onPointerLeave to ancestor views', () => { - const root = Fantom.createRoot(); - - const childRef = React.createRef>(); + describe('direct events (onLayout)', () => { + it('does not bubble onLayout to ancestor views via the onLayout prop', () => { + const root = Fantom.createRoot(); - const parentSpy = jest.fn((_e: PointerEvent) => {}); - const childSpy = jest.fn((_e: PointerEvent) => {}); + const childRef = React.createRef>(); - Fantom.runTask(() => { - root.render( - - - , - ); - }); + const parentSpy = jest.fn(); + const childSpy = jest.fn(); - Fantom.dispatchNativeEvent( - childRef, - 'onPointerLeave', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.ContinuousEnd, - }, + Fantom.runTask(() => { + root.render( + + + , ); - - expect(childSpy).toHaveBeenCalledTimes(1); - expect(parentSpy).toHaveBeenCalledTimes(0); }); - it('still fires onPointerEnterCapture on ancestors during the capture phase', () => { - const root = Fantom.createRoot(); + // Flush the layout events emitted for both views during the initial + // layout pass so they are not conflated with the dispatch below. + Fantom.flushAllNativeEvents(); - const childRef = React.createRef>(); - - const callOrder: Array = []; - const parentCaptureSpy = jest.fn((_e: PointerEvent) => { - callOrder.push('parentCapture'); - }); - const childSpy = jest.fn((_e: PointerEvent) => { - callOrder.push('child'); - }); - - Fantom.runTask(() => { - root.render( - - - , - ); - }); - - Fantom.dispatchNativeEvent( - childRef, - 'onPointerEnter', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.ContinuousStart, - }, - ); + // Both onLayout handlers fired for their own layout during mount. + const childCallsBefore = childSpy.mock.calls.length; + const parentCallsBefore = parentSpy.mock.calls.length; - expect(parentCaptureSpy).toHaveBeenCalledTimes(1); - expect(childSpy).toHaveBeenCalledTimes(1); - expect(callOrder).toEqual(['parentCapture', 'child']); - }); + Fantom.dispatchNativeEvent( + childRef, + 'onLayout', + {layout: {x: 0, y: 0, width: 100, height: 50}}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); - it('still bubbles non-skipBubbling events (onPointerDown) to ancestor views', () => { - const root = Fantom.createRoot(); + // Child's onLayout handler fires for the dispatched event + expect(childSpy.mock.calls.length - childCallsBefore).toBeGreaterThan(0); + // Parent's onLayout prop handler does NOT fire from the child's event + // because layout is a direct (non-bubbling) event + expect(parentSpy.mock.calls.length - parentCallsBefore).toBe(0); + }); + }); - const childRef = React.createRef>(); + describe('direct events (rnIsDirect) — Event construction validation', () => { + it('allows constructing a direct event that does not bubble', () => { + const event = new Event('layout', {rnIsDirect: true}); + expect(event.rnIsDirect).toBe(true); + expect(event.bubbles).toBe(false); + }); - const parentSpy = jest.fn((_e: PointerEvent) => {}); - const childSpy = jest.fn((_e: PointerEvent) => {}); + it('defaults rnIsDirect to false', () => { + const event = new Event('layout'); + expect(event.rnIsDirect).toBe(false); + }); - Fantom.runTask(() => { - root.render( - - - , - ); - }); + it('throws when rnIsDirect and bubbles are both true', () => { + expect(() => { + // eslint-disable-next-line no-new + new Event('layout', {rnIsDirect: true, bubbles: true}); + }).toThrow( + "Failed to construct 'Event': 'rnIsDirect' cannot be true when 'bubbles' is also true.", + ); + }); + }); + + // The dispatch-behavior tests use `addEventListener` on refs and the + // document element, which is only available when both + // `enableNativeEventTargetEventDispatching` and `enableImperativeEvents` + // are enabled. + (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() && + ReactNativeFeatureFlags.enableImperativeEvents() + ? describe + : describe.skip)('direct events (rnIsDirect) — dispatch behavior', () => { + it('dispatches onLayout to the target but never to ancestor onLayout props or bubble listeners', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const childHandler = jest.fn(); + const parentPropHandler = jest.fn(); + const parentImperativeBubble = jest.fn(); - Fantom.dispatchNativeEvent( - childRef, - 'onPointerDown', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, + Fantom.runTask(() => { + root.render( + + + + + + + , ); - - expect(childSpy).toHaveBeenCalledTimes(1); - expect(parentSpy).toHaveBeenCalledTimes(1); }); - }); - describe('direct events (onLayout)', () => { - it('does not bubble onLayout to ancestor views via the onLayout prop', () => { - const root = Fantom.createRoot(); - - const childRef = React.createRef>(); - - const parentSpy = jest.fn(); - const childSpy = jest.fn(); - - Fantom.runTask(() => { - root.render( - - - , - ); - }); + asEventTarget(root.document.documentElement).addEventListener( + 'layout', + parentImperativeBubble, + ); - // Flush the layout events emitted for both views during the initial - // layout pass so they are not conflated with the dispatch below. - Fantom.flushAllNativeEvents(); + // Drain mount-time layout events. + Fantom.flushAllNativeEvents(); - // Both onLayout handlers fired for their own layout during mount. - const childCallsBefore = childSpy.mock.calls.length; - const parentCallsBefore = parentSpy.mock.calls.length; + const childBefore = childHandler.mock.calls.length; + const parentBefore = parentPropHandler.mock.calls.length; + const parentBubbleBefore = parentImperativeBubble.mock.calls.length; - Fantom.dispatchNativeEvent( - childRef, - 'onLayout', - {layout: {x: 0, y: 0, width: 100, height: 50}}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); + Fantom.dispatchNativeEvent( + childRef, + 'onLayout', + {layout: {x: 0, y: 0, width: 100, height: 50}}, + {category: Fantom.NativeEventCategory.Discrete}, + ); - // Child's onLayout handler fires for the dispatched event - expect(childSpy.mock.calls.length - childCallsBefore).toBeGreaterThan( - 0, - ); - // Parent's onLayout prop handler does NOT fire from the child's event - // because layout is a direct (non-bubbling) event - expect(parentSpy.mock.calls.length - parentCallsBefore).toBe(0); - }); + // The target's own onLayout fires exactly once. + expect(childHandler.mock.calls.length - childBefore).toBe(1); + // A direct (non-bubbling) event never reaches an ancestor's onLayout + // prop or an ancestor's bubble-phase listener, regardless of the fast + // path. + expect(parentPropHandler.mock.calls.length - parentBefore).toBe(0); + expect( + parentImperativeBubble.mock.calls.length - parentBubbleBefore, + ).toBe(0); }); - describe('direct events (rnIsDirect) — Event construction validation', () => { - it('allows constructing a direct event that does not bubble', () => { - const event = new Event('layout', {rnIsDirect: true}); - expect(event.rnIsDirect).toBe(true); - expect(event.bubbles).toBe(false); - }); - - it('defaults rnIsDirect to false', () => { - const event = new Event('layout'); - expect(event.rnIsDirect).toBe(false); - }); - - it('throws when rnIsDirect and bubbles are both true', () => { - expect(() => { - // eslint-disable-next-line no-new - new Event('layout', {rnIsDirect: true, bubbles: true}); - }).toThrow( - "Failed to construct 'Event': 'rnIsDirect' cannot be true when 'bubbles' is also true.", - ); + it('restricts the event path to the target (AT_TARGET only, no ancestor capture listeners)', () => { + const root = Fantom.createRoot(); + const childRef = React.createRef>(); + const ancestorCapture = jest.fn(); + let observedPhase: number | null = null; + let observedPathLength: number | null = null; + let observedCurrentIsTarget: boolean | null = null; + + const handler = jest.fn((e: $FlowFixMe) => { + observedPhase = e.eventPhase; + observedPathLength = e.composedPath().length; + observedCurrentIsTarget = e.currentTarget === childRef.current; }); - }); - - // The dispatch-behavior tests use `addEventListener` on refs and the - // document element, which is only available when both - // `enableNativeEventTargetEventDispatching` and `enableImperativeEvents` - // are enabled. - (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() && - ReactNativeFeatureFlags.enableImperativeEvents() - ? describe - : describe.skip)('direct events (rnIsDirect) — dispatch behavior', () => { - it('dispatches onLayout to the target but never to ancestor onLayout props or bubble listeners', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const childHandler = jest.fn(); - const parentPropHandler = jest.fn(); - const parentImperativeBubble = jest.fn(); - - Fantom.runTask(() => { - root.render( - - - - - - - , - ); - }); - - asEventTarget(root.document.documentElement).addEventListener( - 'layout', - parentImperativeBubble, - ); - - // Drain mount-time layout events. - Fantom.flushAllNativeEvents(); - - const childBefore = childHandler.mock.calls.length; - const parentBefore = parentPropHandler.mock.calls.length; - const parentBubbleBefore = parentImperativeBubble.mock.calls.length; - Fantom.dispatchNativeEvent( - childRef, - 'onLayout', - {layout: {x: 0, y: 0, width: 100, height: 50}}, - {category: Fantom.NativeEventCategory.Discrete}, - ); - - // The target's own onLayout fires exactly once. - expect(childHandler.mock.calls.length - childBefore).toBe(1); - // A direct (non-bubbling) event never reaches an ancestor's onLayout - // prop or an ancestor's bubble-phase listener, regardless of the fast - // path. - expect(parentPropHandler.mock.calls.length - parentBefore).toBe(0); - expect( - parentImperativeBubble.mock.calls.length - parentBubbleBefore, - ).toBe(0); + Fantom.runTask(() => { + root.render(createNestedViewsWithLayout(5, childRef, () => {})); }); - it('restricts the event path to the target (AT_TARGET only, no ancestor capture listeners)', () => { - const root = Fantom.createRoot(); - const childRef = React.createRef>(); - const ancestorCapture = jest.fn(); - let observedPhase: number | null = null; - let observedPathLength: number | null = null; - let observedCurrentIsTarget: boolean | null = null; - - const handler = jest.fn((e: $FlowFixMe) => { - observedPhase = e.eventPhase; - observedPathLength = e.composedPath().length; - observedCurrentIsTarget = e.currentTarget === childRef.current; - }); - - Fantom.runTask(() => { - root.render(createNestedViewsWithLayout(5, childRef, () => {})); - }); - - asEventTarget(childRef.current).addEventListener('layout', handler); - asEventTarget(root.document.documentElement).addEventListener( - 'layout', - ancestorCapture, - {capture: true}, - ); - Fantom.flushAllNativeEvents(); + asEventTarget(childRef.current).addEventListener('layout', handler); + asEventTarget(root.document.documentElement).addEventListener( + 'layout', + ancestorCapture, + {capture: true}, + ); + Fantom.flushAllNativeEvents(); - const ancestorCaptureBefore = ancestorCapture.mock.calls.length; + const ancestorCaptureBefore = ancestorCapture.mock.calls.length; - Fantom.dispatchNativeEvent( - childRef, - 'onLayout', - {layout: {x: 0, y: 0, width: 100, height: 50}}, - {category: Fantom.NativeEventCategory.Discrete}, - ); + Fantom.dispatchNativeEvent( + childRef, + 'onLayout', + {layout: {x: 0, y: 0, width: 100, height: 50}}, + {category: Fantom.NativeEventCategory.Discrete}, + ); - expect(handler).toHaveBeenCalled(); - expect(observedPhase).toBe(Event.AT_TARGET); - // Event path is just the target node. - expect(observedPathLength).toBe(1); - expect(observedCurrentIsTarget).toBe(true); - // With the fast path, the capture phase does not traverse ancestors. - expect(ancestorCapture.mock.calls.length - ancestorCaptureBefore).toBe( - 0, - ); - }); + expect(handler).toHaveBeenCalled(); + expect(observedPhase).toBe(Event.AT_TARGET); + // Event path is just the target node. + expect(observedPathLength).toBe(1); + expect(observedCurrentIsTarget).toBe(true); + // With the fast path, the capture phase does not traverse ancestors. + expect(ancestorCapture.mock.calls.length - ancestorCaptureBefore).toBe(0); }); - }, -); + }); +}); diff --git a/packages/react-native/src/private/renderer/core/__tests__/ResponderEventTarget-itest.js b/packages/react-native/src/private/renderer/core/__tests__/ResponderEventTarget-itest.js index 58672b16e954..605d90317e3f 100644 --- a/packages/react-native/src/private/renderer/core/__tests__/ResponderEventTarget-itest.js +++ b/packages/react-native/src/private/renderer/core/__tests__/ResponderEventTarget-itest.js @@ -46,9 +46,7 @@ function touchEnd( }; } -const {isOSS} = Fantom.getConstants(); - -(isOSS ? describe.skip : describe)('Responder System', () => { +describe('Responder System', () => { // --- Basic Grant / Release --- it('grants responder on touch start when onStartShouldSetResponder returns true', () => { diff --git a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js index 63770292a848..b3b59967177e 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js +++ b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js @@ -1698,8 +1698,6 @@ describe('ReactNativeElement', () => { // EventTarget API is gated behind `enableImperativeEvents`: when it is off // the methods are removed from this final class, when it is on they are // available. - const {isOSS} = Fantom.getConstants(); - if (!ReactNativeFeatureFlags.enableImperativeEvents()) { describe('when `enableImperativeEvents` is off (default)', () => { it('removes the public EventTarget methods', () => { @@ -1720,31 +1718,28 @@ describe('ReactNativeElement', () => { // Removing the public API must not affect native/prop event delivery, // which goes through the internal (symbol-keyed) dispatch path. - (isOSS ? it.skip : it)( - 'still delivers native events to prop handlers', - () => { - const ref = createRef(); - const onPointerUp = jest.fn(); - const root = Fantom.createRoot(); - - Fantom.runTask(() => { - root.render(); - }); - - expect(onPointerUp).toHaveBeenCalledTimes(0); - - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); - - expect(onPointerUp).toHaveBeenCalledTimes(1); - }, - ); + it('still delivers native events to prop handlers', () => { + const ref = createRef(); + const onPointerUp = jest.fn(); + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render(); + }); + + expect(onPointerUp).toHaveBeenCalledTimes(0); + + Fantom.dispatchNativeEvent( + ref, + 'onPointerUp', + {x: 0, y: 0}, + { + category: Fantom.NativeEventCategory.Discrete, + }, + ); + + expect(onPointerUp).toHaveBeenCalledTimes(1); + }); }); } diff --git a/packages/rn-tester/package.json b/packages/rn-tester/package.json index 0373d7f79395..e6708798546c 100644 --- a/packages/rn-tester/package.json +++ b/packages/rn-tester/package.json @@ -35,7 +35,7 @@ "react-native-test-library-common": "0.87.0-main" }, "peerDependencies": { - "react": "19.2.3", + "react": "19.3.0", "react-native": "1000.0.0" }, "codegenConfig": { diff --git a/packages/virtualized-lists/package.json b/packages/virtualized-lists/package.json index b08b6df9dec6..e6cf8c9eca19 100644 --- a/packages/virtualized-lists/package.json +++ b/packages/virtualized-lists/package.json @@ -48,7 +48,7 @@ "nullthrows": "^1.1.1" }, "devDependencies": { - "react-test-renderer": "19.2.3" + "react-test-renderer": "19.3.0" }, "peerDependencies": { "@types/react": "^19.2.0", diff --git a/private/helloworld/package.json b/private/helloworld/package.json index d75b1f9e56ae..60a9176d6104 100644 --- a/private/helloworld/package.json +++ b/private/helloworld/package.json @@ -12,7 +12,7 @@ "test": "jest" }, "dependencies": { - "react": "19.2.3", + "react": "19.3.0", "react-native": "1000.0.0" }, "devDependencies": { @@ -30,7 +30,7 @@ "eslint": "^8.19.0", "jest": "^29.7.0", "listr2": "^8.2.1", - "react-test-renderer": "19.2.3", + "react-test-renderer": "19.3.0", "rxjs": "^7.8.1" }, "engines": { diff --git a/yarn.lock b/yarn.lock index 2fce7f831892..6a5a91f83e20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7876,7 +7876,7 @@ react-devtools-core@^6.1.5: shell-quote "^1.6.1" ws "^7" -react-is@19.2.3, react-is@^16.13.1, react-is@^18.0.0, react-is@^19.2.3: +react-is@19.2.3, react-is@^16.13.1, react-is@^18.0.0, react-is@^19.2.3, react-is@^19.3.0: version "19.2.3" resolved "https://registry.yarnpkg.com/react-is/-/react-is-19.2.3.tgz#eec2feb69c7fb31f77d0b5c08c10ae1c88886b29" integrity sha512-qJNJfu81ByyabuG7hPFEbXqNcWSU3+eVus+KJs+0ncpGfMyYdvSmxiJxbWR65lYi1I+/0HBcliO029gc4F+PnA== @@ -7894,10 +7894,18 @@ react-test-renderer@19.2.3: react-is "^19.2.3" scheduler "^0.27.0" -react@19.2.3: - version "19.2.3" - resolved "https://registry.yarnpkg.com/react/-/react-19.2.3.tgz#d83e5e8e7a258cf6b4fe28640515f99b87cd19b8" - integrity sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA== +react-test-renderer@19.3.0: + version "19.3.0" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-19.3.0.tgz#ee5aa54edb563245649f1143aa33f05a48f8de0c" + integrity sha512-AUxgv+hRbqjRgx4xVwiWL6cvDDKPAva1VWLXQIMoevqQn9us//C5TX9LEnBGH47D0zvJpjwjxb1umzgOMvE8Wg== + dependencies: + react-is "^19.3.0" + scheduler "^0.28.0" + +react@19.3.0: + version "19.3.0" + resolved "https://registry.yarnpkg.com/react/-/react-19.3.0.tgz#e20aa3a14687075ce863351b5878b0608c3fbfb2" + integrity sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog== readable-stream@^3.4.0: version "3.6.2" @@ -8232,7 +8240,12 @@ safe-regex-test@^1.1.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -scheduler@0.27.0, scheduler@^0.27.0: +scheduler@0.28.0, scheduler@^0.28.0: + version "0.28.0" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.28.0.tgz#03d3ca348aeaf8b7502f64468f217b27523f9695" + integrity sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw== + +scheduler@^0.27.0: version "0.27.0" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.27.0.tgz#0c4ef82d67d1e5c1e359e8fc76d3a87f045fe5bd" integrity sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==