From 60928e358caee8cf9e2be6be56503fa216e01ae7 Mon Sep 17 00:00:00 2001 From: kassens Date: Thu, 11 Apr 2024 18:03:18 +0000 Subject: [PATCH] Remove defaultProps support (except for classes) (#28733) This removes defaultProps support for all component types except for classes. We've chosen to continue supporting defaultProps for classes because lots of older code relies on it, and unlike function components, (which can use default params), there's no straightforward alternative. By implication, it also removes support for setting defaultProps on `React.lazy` wrapper. So this will not work: ```js const MyClassComponent = React.lazy(() => import('./MyClassComponent')); // MyClassComponent is not actually a class; it's a lazy wrapper. So // defaultProps does not work. MyClassComponent.defaultProps = { foo: 'bar' }; ``` However, if you set the default props on the class itself, then it's fine. For classes, this change also moves where defaultProps are resolved. Previously, defaultProps were resolved by the JSX runtime. This change is only observable if you introspect a JSX element, which is relatively rare but does happen. In other words, previously `.props.aDefaultProp` would resolve to the default prop value, but now it does not. DiffTrain build for [48b4ecc9012638ed51b275aad24b2086b8215e32](https://github.com/facebook/react/commit/48b4ecc9012638ed51b275aad24b2086b8215e32) --- .../facebook-www/JSXDEVRuntime-dev.classic.js | 400 +- .../facebook-www/JSXDEVRuntime-dev.modern.js | 402 +- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/React-dev.classic.js | 631 +- compiled/facebook-www/React-dev.modern.js | 623 +- compiled/facebook-www/React-prod.classic.js | 177 +- compiled/facebook-www/React-prod.modern.js | 177 +- .../facebook-www/React-profiling.classic.js | 177 +- .../facebook-www/React-profiling.modern.js | 177 +- compiled/facebook-www/ReactART-dev.classic.js | 890 +- compiled/facebook-www/ReactART-dev.modern.js | 886 +- .../facebook-www/ReactART-prod.classic.js | 493 +- compiled/facebook-www/ReactART-prod.modern.js | 468 +- compiled/facebook-www/ReactDOM-dev.classic.js | 2054 +- compiled/facebook-www/ReactDOM-dev.modern.js | 21346 ++++++++------- .../facebook-www/ReactDOM-prod.classic.js | 1307 +- compiled/facebook-www/ReactDOM-prod.modern.js | 9099 +++---- .../ReactDOM-profiling.classic.js | 1293 +- .../facebook-www/ReactDOM-profiling.modern.js | 9551 +++---- .../ReactDOMServer-dev.classic.js | 201 +- .../facebook-www/ReactDOMServer-dev.modern.js | 201 +- .../ReactDOMServer-prod.classic.js | 189 +- .../ReactDOMServer-prod.modern.js | 168 +- .../ReactDOMServerStreaming-dev.modern.js | 209 +- .../ReactDOMServerStreaming-prod.modern.js | 172 +- .../ReactDOMTesting-dev.classic.js | 2214 +- .../ReactDOMTesting-dev.modern.js | 21624 ++++++++-------- .../ReactDOMTesting-prod.classic.js | 1456 +- .../ReactDOMTesting-prod.modern.js | 9764 +++---- .../ReactFlightDOMClient-dev.modern.js | 339 +- .../ReactFlightDOMClient-prod.modern.js | 156 +- .../ReactFlightDOMServer-dev.modern.js | 277 +- .../ReactFlightDOMServer-prod.modern.js | 68 +- .../facebook-www/ReactServer-dev.modern.js | 549 +- .../facebook-www/ReactServer-prod.modern.js | 193 +- .../ReactTestRenderer-dev.classic.js | 858 +- .../ReactTestRenderer-dev.modern.js | 858 +- .../ReactTestUtils-dev.classic.js | 11 +- .../facebook-www/ReactTestUtils-dev.modern.js | 11 +- .../__test_utils__/ReactAllWarnings.js | 5 +- .../ReactBrowserEventEmitter_DO_NOT_USE.js | 4 +- 41 files changed, 43882 insertions(+), 45798 deletions(-) diff --git a/compiled/facebook-www/JSXDEVRuntime-dev.classic.js b/compiled/facebook-www/JSXDEVRuntime-dev.classic.js index e48944ee2c..6c0ef234f5 100644 --- a/compiled/facebook-www/JSXDEVRuntime-dev.classic.js +++ b/compiled/facebook-www/JSXDEVRuntime-dev.classic.js @@ -84,10 +84,12 @@ if (__DEV__) { var React = require("react"); var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; // Defensive in case this is fired before React is initialized. + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Defensive in case this is fired before React is initialized. if (ReactSharedInternals != null) { - var stack = ReactSharedInternals.getStackAddendum(); + var ReactDebugCurrentFrame = + ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { format += "%s"; @@ -110,11 +112,8 @@ if (__DEV__) { enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses; // On WWW, false is used for a new modern build. - // because JSX is an extremely hot path. - var disableStringRefs = false; - - function getWrappedName$1(outerType, innerType, wrapperName) { + function getWrappedName(outerType, innerType, wrapperName) { var displayName = outerType.displayName; if (displayName) { @@ -127,7 +126,7 @@ if (__DEV__) { : wrapperName; } // Keep in sync with react-reconciler/getComponentNameFromFiber - function getContextName$1(type) { + function getContextName(type) { return type.displayName || "Context"; } @@ -194,28 +193,28 @@ if (__DEV__) { return null; } else { var provider = type; - return getContextName$1(provider._context) + ".Provider"; + return getContextName(provider._context) + ".Provider"; } case REACT_CONTEXT_TYPE: var context = type; if (enableRenderableContext) { - return getContextName$1(context) + ".Provider"; + return getContextName(context) + ".Provider"; } else { - return getContextName$1(context) + ".Consumer"; + return getContextName(context) + ".Consumer"; } case REACT_CONSUMER_TYPE: if (enableRenderableContext) { var consumer = type; - return getContextName$1(consumer._context) + ".Consumer"; + return getContextName(consumer._context) + ".Consumer"; } else { return null; } case REACT_FORWARD_REF_TYPE: - return getWrappedName$1(type, type.render, "ForwardRef"); + return getWrappedName(type, type.render, "ForwardRef"); case REACT_MEMO_TYPE: var outerName = type.displayName || null; @@ -244,7 +243,7 @@ if (__DEV__) { } var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // $FlowFixMe[method-unbinding] var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -324,20 +323,6 @@ if (__DEV__) { } } } - function checkPropStringCoercion(value, propName) { - { - if (willCoercionThrow(value)) { - error( - "The provided `%s` prop is an unsupported type %s." + - " This value must be coerced to a string before using it here.", - propName, - typeName(value) - ); - - return testStringCoercion(value); // throw (to help callers find troubleshooting comments) - } - } - } var REACT_CLIENT_REFERENCE$1 = Symbol.for("react.client.reference"); function isValidElementType(type) { @@ -484,8 +469,9 @@ if (__DEV__) { } } + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; var prefix; - function describeBuiltInComponentFrame(name) { + function describeBuiltInComponentFrame(name, ownerFn) { { if (prefix === undefined) { // Extract the VM specific prefix used by each line. @@ -537,13 +523,13 @@ if (__DEV__) { var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. Error.prepareStackTrace = undefined; - var previousDispatcher = null; + var previousDispatcher; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function // for warnings. - ReactSharedInternals.H = null; + ReactCurrentDispatcher.current = null; disableLogs(); } /** @@ -736,7 +722,7 @@ if (__DEV__) { reentry = false; { - ReactSharedInternals.H = previousDispatcher; + ReactCurrentDispatcher.current = previousDispatcher; reenableLogs(); } @@ -754,7 +740,7 @@ if (__DEV__) { return syntheticFrame; } - function describeFunctionComponentFrame(fn) { + function describeFunctionComponentFrame(fn, ownerFn) { { return describeNativeComponentFrame(fn, false); } @@ -765,7 +751,7 @@ if (__DEV__) { return !!(prototype && prototype.isReactComponent); } - function describeUnknownElementTypeFrameInDEV(type) { + function describeUnknownElementTypeFrameInDEV(type, ownerFn) { if (type == null) { return ""; } @@ -795,7 +781,7 @@ if (__DEV__) { case REACT_MEMO_TYPE: // Memo may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(type.type); + return describeUnknownElementTypeFrameInDEV(type.type, ownerFn); case REACT_LAZY_TYPE: { var lazyComponent = type; @@ -804,7 +790,10 @@ if (__DEV__) { try { // Lazy may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(init(payload)); + return describeUnknownElementTypeFrameInDEV( + init(payload), + ownerFn + ); } catch (x) {} } } @@ -813,157 +802,8 @@ if (__DEV__) { return ""; } - var FunctionComponent = 0; - var ClassComponent = 1; - var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - - var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - - var HostComponent = 5; - var HostText = 6; - var Fragment = 7; - var Mode = 8; - var ContextConsumer = 9; - var ContextProvider = 10; - var ForwardRef = 11; - var Profiler = 12; - var SuspenseComponent = 13; - var MemoComponent = 14; - var SimpleMemoComponent = 15; - var LazyComponent = 16; - var IncompleteClassComponent = 17; - var DehydratedFragment = 18; - var SuspenseListComponent = 19; - var ScopeComponent = 21; - var OffscreenComponent = 22; - var LegacyHiddenComponent = 23; - var CacheComponent = 24; - var TracingMarkerComponent = 25; - var HostHoistable = 26; - var HostSingleton = 27; - var IncompleteFunctionComponent = 28; - - function getWrappedName(outerType, innerType, wrapperName) { - var functionName = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - (functionName !== "" - ? wrapperName + "(" + functionName + ")" - : wrapperName) - ); - } // Keep in sync with shared/getComponentNameFromType - - function getContextName(type) { - return type.displayName || "Context"; - } - function getComponentNameFromFiber(fiber) { - var tag = fiber.tag, - type = fiber.type; - - switch (tag) { - case CacheComponent: - return "Cache"; - - case ContextConsumer: - if (enableRenderableContext) { - var consumer = type; - return getContextName(consumer._context) + ".Consumer"; - } else { - var context = type; - return getContextName(context) + ".Consumer"; - } - - case ContextProvider: - if (enableRenderableContext) { - var _context = type; - return getContextName(_context) + ".Provider"; - } else { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } - - case DehydratedFragment: - return "DehydratedFragment"; - - case ForwardRef: - return getWrappedName(type, type.render, "ForwardRef"); - - case Fragment: - return "Fragment"; - - case HostHoistable: - case HostSingleton: - case HostComponent: - // Host component type is the display name (e.g. "div", "View") - return type; - - case HostPortal: - return "Portal"; - - case HostRoot: - return "Root"; - - case HostText: - return "Text"; - - case LazyComponent: - // Name comes from the type in this case; we don't have a tag. - return getComponentNameFromType(type); - - case Mode: - if (type === REACT_STRICT_MODE_TYPE) { - // Don't be less specific than shared/getComponentNameFromType - return "StrictMode"; - } - - return "Mode"; - - case OffscreenComponent: - return "Offscreen"; - - case Profiler: - return "Profiler"; - - case ScopeComponent: - return "Scope"; - - case SuspenseComponent: - return "Suspense"; - - case SuspenseListComponent: - return "SuspenseList"; - - case TracingMarkerComponent: - return "TracingMarker"; - // The display name for these tags come from the user-provided type: - - case IncompleteClassComponent: - case IncompleteFunctionComponent: - - // Fallthrough - - case ClassComponent: - case FunctionComponent: - case MemoComponent: - case SimpleMemoComponent: - if (typeof type === "function") { - return type.displayName || type.name || null; - } - - if (typeof type === "string") { - return type; - } - - break; - - case LegacyHiddenComponent: { - return "LegacyHidden"; - } - } - - return null; - } - + var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); var specialPropKeyWarningShown; var specialPropRefWarningShown; @@ -1007,12 +847,12 @@ if (__DEV__) { { if ( typeof config.ref === "string" && - ReactSharedInternals.owner && + ReactCurrentOwner.current && self && - ReactSharedInternals.owner.stateNode !== self + ReactCurrentOwner.current.stateNode !== self ) { var componentName = getComponentNameFromType( - ReactSharedInternals.owner.type + ReactCurrentOwner.current.type ); if (!didWarnAboutStringRefs[componentName]) { @@ -1023,7 +863,7 @@ if (__DEV__) { "We ask you to manually fix this case by using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + "https://react.dev/link/strict-mode-string-ref", - getComponentNameFromType(ReactSharedInternals.owner.type), + getComponentNameFromType(ReactCurrentOwner.current.type), config.ref ); @@ -1347,6 +1187,9 @@ if (__DEV__) { } } + var propName; // Reserved names are extracted + + var props = {}; var key = null; var ref = null; // Currently, key can be spread in as a prop. This causes a potential // issue if key is also explicitly declared (ie.
@@ -1374,49 +1217,20 @@ if (__DEV__) { if (hasValidRef(config)) { if (!enableRefAsProp) { ref = config.ref; - - { - ref = coerceStringRef(ref, ReactSharedInternals.owner, type); - } } { warnIfStringRefCannotBeAutoConverted(config, self); } - } + } // Remaining properties are added to a new props object - var props; - - if (enableRefAsProp && disableStringRefs && !("key" in config)) { - // If key was not spread in, we can reuse the original props object. This - // only works for `jsx`, not `createElement`, because `jsx` is a compiler - // target and the compiler always passes a new object. For `createElement`, - // we can't assume a new object is passed every time because it can be - // called manually. - // - // Spreading key is a warning in dev. In a future release, we will not - // remove a spread key from the props object. (But we'll still warn.) We'll - // always pass the object straight through. - props = config; - } else { - // We need to remove reserved props (key, prop, ref). Create a fresh props - // object and copy over all the non-reserved props. We don't use `delete` - // because in V8 it will deopt the object to dictionary mode. - props = {}; - - for (var propName in config) { - // Skip over reserved prop names - if (propName !== "key" && (enableRefAsProp || propName !== "ref")) { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - ); - } else { - props[propName] = config[propName]; - } - } + for (propName in config) { + if ( + hasOwnProperty.call(config, propName) && // Skip over reserved prop names + propName !== "key" && + (enableRefAsProp || propName !== "ref") + ) { + props[propName] = config[propName]; } } @@ -1425,9 +1239,9 @@ if (__DEV__) { if (type && type.defaultProps) { var defaultProps = type.defaultProps; - for (var _propName2 in defaultProps) { - if (props[_propName2] === undefined) { - props[_propName2] = defaultProps[_propName2]; + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; } } } @@ -1454,7 +1268,7 @@ if (__DEV__) { ref, self, source, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); @@ -1468,8 +1282,8 @@ if (__DEV__) { function getDeclarationErrorAddendum() { { - if (ReactSharedInternals.owner) { - var name = getComponentNameFromType(ReactSharedInternals.owner.type); + if (ReactCurrentOwner.current) { + var name = getComponentNameFromType(ReactCurrentOwner.current.type); if (name) { return "\n\nCheck the render method of `" + name + "`."; @@ -1583,18 +1397,14 @@ if (__DEV__) { if ( element && - element._owner != null && - element._owner !== ReactSharedInternals.owner + element._owner && + element._owner !== ReactCurrentOwner.current ) { - var ownerName = null; - - if (typeof element._owner.tag === "number") { - ownerName = getComponentNameFromType(element._owner.type); - } else if (typeof element._owner.name === "string") { - ownerName = element._owner.name; - } // Give the component that originally created this child. - - childOwner = " It was passed a child from " + ownerName + "."; + // Give the component that originally created this child. + childOwner = + " It was passed a child from " + + getComponentNameFromType(element._owner.type) + + "."; } setCurrentlyValidatingElement(element); @@ -1613,10 +1423,14 @@ if (__DEV__) { function setCurrentlyValidatingElement(element) { { if (element) { - var stack = describeUnknownElementTypeFrameInDEV(element.type); - ReactSharedInternals.setExtraStackFrame(stack); + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV( + element.type, + owner ? owner.type : null + ); + ReactDebugCurrentFrame.setExtraStackFrame(stack); } else { - ReactSharedInternals.setExtraStackFrame(null); + ReactDebugCurrentFrame.setExtraStackFrame(null); } } } @@ -1674,96 +1488,6 @@ if (__DEV__) { } } - function coerceStringRef(mixedRef, owner, type) { - var stringRef; - - if (typeof mixedRef === "string") { - stringRef = mixedRef; - } else { - if (typeof mixedRef === "number" || typeof mixedRef === "boolean") { - { - checkPropStringCoercion(mixedRef, "ref"); - } - - stringRef = "" + mixedRef; - } else { - return mixedRef; - } - } - - return stringRefAsCallbackRef.bind(null, stringRef, type, owner); - } - - function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) { - throw new Error( - "Element ref was specified as a string (" + - stringRef + - ") but no owner was set. This could happen for one of" + - " the following reasons:\n" + - "1. You may be adding a ref to a function component\n" + - "2. You may be adding a ref to a component that was not created inside a component's render method\n" + - "3. You have multiple copies of React loaded\n" + - "See https://react.dev/link/refs-must-have-owner for more information." - ); - } - - if (owner.tag !== ClassComponent) { - throw new Error( - "Function components cannot have string refs. " + - "We recommend using useRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref" - ); - } - - { - if ( - // Will already warn with "Function components cannot be given refs" - !(typeof type === "function" && !isReactClass(type)) - ) { - var componentName = getComponentNameFromFiber(owner) || "Component"; - - if (!didWarnAboutStringRefs[componentName]) { - error( - 'Component "%s" contains the string ref "%s". Support for string refs ' + - "will be removed in a future major release. We recommend using " + - "useRef() or createRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref", - componentName, - stringRef - ); - - didWarnAboutStringRefs[componentName] = true; - } - } - } - - var inst = owner.stateNode; - - if (!inst) { - throw new Error( - "Missing owner for string ref " + - stringRef + - ". This error is likely caused by a " + - "bug in React. Please file an issue." - ); - } - - var refs = inst.refs; - - if (value === null) { - delete refs[stringRef]; - } else { - refs[stringRef] = value; - } - } - - function isReactClass(type) { - return type.prototype && type.prototype.isReactComponent; - } - var jsxDEV = jsxDEV$1; exports.Fragment = REACT_FRAGMENT_TYPE; diff --git a/compiled/facebook-www/JSXDEVRuntime-dev.modern.js b/compiled/facebook-www/JSXDEVRuntime-dev.modern.js index 6652f28ef8..fed4994b37 100644 --- a/compiled/facebook-www/JSXDEVRuntime-dev.modern.js +++ b/compiled/facebook-www/JSXDEVRuntime-dev.modern.js @@ -84,10 +84,12 @@ if (__DEV__) { var React = require("react"); var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; // Defensive in case this is fired before React is initialized. + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Defensive in case this is fired before React is initialized. if (ReactSharedInternals != null) { - var stack = ReactSharedInternals.getStackAddendum(); + var ReactDebugCurrentFrame = + ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { format += "%s"; @@ -110,11 +112,8 @@ if (__DEV__) { enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses; // On WWW, true is used for a new modern build. - // because JSX is an extremely hot path. - var disableStringRefs = false; - - function getWrappedName$1(outerType, innerType, wrapperName) { + function getWrappedName(outerType, innerType, wrapperName) { var displayName = outerType.displayName; if (displayName) { @@ -127,7 +126,7 @@ if (__DEV__) { : wrapperName; } // Keep in sync with react-reconciler/getComponentNameFromFiber - function getContextName$1(type) { + function getContextName(type) { return type.displayName || "Context"; } @@ -194,28 +193,28 @@ if (__DEV__) { return null; } else { var provider = type; - return getContextName$1(provider._context) + ".Provider"; + return getContextName(provider._context) + ".Provider"; } case REACT_CONTEXT_TYPE: var context = type; if (enableRenderableContext) { - return getContextName$1(context) + ".Provider"; + return getContextName(context) + ".Provider"; } else { - return getContextName$1(context) + ".Consumer"; + return getContextName(context) + ".Consumer"; } case REACT_CONSUMER_TYPE: if (enableRenderableContext) { var consumer = type; - return getContextName$1(consumer._context) + ".Consumer"; + return getContextName(consumer._context) + ".Consumer"; } else { return null; } case REACT_FORWARD_REF_TYPE: - return getWrappedName$1(type, type.render, "ForwardRef"); + return getWrappedName(type, type.render, "ForwardRef"); case REACT_MEMO_TYPE: var outerName = type.displayName || null; @@ -244,7 +243,7 @@ if (__DEV__) { } var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // $FlowFixMe[method-unbinding] var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -324,20 +323,6 @@ if (__DEV__) { } } } - function checkPropStringCoercion(value, propName) { - { - if (willCoercionThrow(value)) { - error( - "The provided `%s` prop is an unsupported type %s." + - " This value must be coerced to a string before using it here.", - propName, - typeName(value) - ); - - return testStringCoercion(value); // throw (to help callers find troubleshooting comments) - } - } - } var REACT_CLIENT_REFERENCE$1 = Symbol.for("react.client.reference"); function isValidElementType(type) { @@ -484,8 +469,9 @@ if (__DEV__) { } } + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; var prefix; - function describeBuiltInComponentFrame(name) { + function describeBuiltInComponentFrame(name, ownerFn) { { if (prefix === undefined) { // Extract the VM specific prefix used by each line. @@ -537,13 +523,13 @@ if (__DEV__) { var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. Error.prepareStackTrace = undefined; - var previousDispatcher = null; + var previousDispatcher; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function // for warnings. - ReactSharedInternals.H = null; + ReactCurrentDispatcher.current = null; disableLogs(); } /** @@ -736,7 +722,7 @@ if (__DEV__) { reentry = false; { - ReactSharedInternals.H = previousDispatcher; + ReactCurrentDispatcher.current = previousDispatcher; reenableLogs(); } @@ -754,7 +740,7 @@ if (__DEV__) { return syntheticFrame; } - function describeFunctionComponentFrame(fn) { + function describeFunctionComponentFrame(fn, ownerFn) { { return describeNativeComponentFrame(fn, false); } @@ -765,7 +751,7 @@ if (__DEV__) { return !!(prototype && prototype.isReactComponent); } - function describeUnknownElementTypeFrameInDEV(type) { + function describeUnknownElementTypeFrameInDEV(type, ownerFn) { if (type == null) { return ""; } @@ -795,7 +781,7 @@ if (__DEV__) { case REACT_MEMO_TYPE: // Memo may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(type.type); + return describeUnknownElementTypeFrameInDEV(type.type, ownerFn); case REACT_LAZY_TYPE: { var lazyComponent = type; @@ -804,7 +790,10 @@ if (__DEV__) { try { // Lazy may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(init(payload)); + return describeUnknownElementTypeFrameInDEV( + init(payload), + ownerFn + ); } catch (x) {} } } @@ -813,159 +802,8 @@ if (__DEV__) { return ""; } - var FunctionComponent = 0; - var ClassComponent = 1; - var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - - var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - - var HostComponent = 5; - var HostText = 6; - var Fragment = 7; - var Mode = 8; - var ContextConsumer = 9; - var ContextProvider = 10; - var ForwardRef = 11; - var Profiler = 12; - var SuspenseComponent = 13; - var MemoComponent = 14; - var SimpleMemoComponent = 15; - var LazyComponent = 16; - var IncompleteClassComponent = 17; - var DehydratedFragment = 18; - var SuspenseListComponent = 19; - var ScopeComponent = 21; - var OffscreenComponent = 22; - var LegacyHiddenComponent = 23; - var CacheComponent = 24; - var TracingMarkerComponent = 25; - var HostHoistable = 26; - var HostSingleton = 27; - var IncompleteFunctionComponent = 28; - - function getWrappedName(outerType, innerType, wrapperName) { - var functionName = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - (functionName !== "" - ? wrapperName + "(" + functionName + ")" - : wrapperName) - ); - } // Keep in sync with shared/getComponentNameFromType - - function getContextName(type) { - return type.displayName || "Context"; - } - function getComponentNameFromFiber(fiber) { - var tag = fiber.tag, - type = fiber.type; - - switch (tag) { - case CacheComponent: - return "Cache"; - - case ContextConsumer: - if (enableRenderableContext) { - var consumer = type; - return getContextName(consumer._context) + ".Consumer"; - } else { - var context = type; - return getContextName(context) + ".Consumer"; - } - - case ContextProvider: - if (enableRenderableContext) { - var _context = type; - return getContextName(_context) + ".Provider"; - } else { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } - - case DehydratedFragment: - return "DehydratedFragment"; - - case ForwardRef: - return getWrappedName(type, type.render, "ForwardRef"); - - case Fragment: - return "Fragment"; - - case HostHoistable: - case HostSingleton: - case HostComponent: - // Host component type is the display name (e.g. "div", "View") - return type; - - case HostPortal: - return "Portal"; - - case HostRoot: - return "Root"; - - case HostText: - return "Text"; - - case LazyComponent: - // Name comes from the type in this case; we don't have a tag. - return getComponentNameFromType(type); - - case Mode: - if (type === REACT_STRICT_MODE_TYPE) { - // Don't be less specific than shared/getComponentNameFromType - return "StrictMode"; - } - - return "Mode"; - - case OffscreenComponent: - return "Offscreen"; - - case Profiler: - return "Profiler"; - - case ScopeComponent: - return "Scope"; - - case SuspenseComponent: - return "Suspense"; - - case SuspenseListComponent: - return "SuspenseList"; - - case TracingMarkerComponent: - return "TracingMarker"; - // The display name for these tags come from the user-provided type: - - case IncompleteClassComponent: - case IncompleteFunctionComponent: { - break; - } - - // Fallthrough - - case ClassComponent: - case FunctionComponent: - case MemoComponent: - case SimpleMemoComponent: - if (typeof type === "function") { - return type.displayName || type.name || null; - } - - if (typeof type === "string") { - return type; - } - - break; - - case LegacyHiddenComponent: { - return "LegacyHidden"; - } - } - - return null; - } - + var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); var specialPropKeyWarningShown; var specialPropRefWarningShown; @@ -1009,12 +847,12 @@ if (__DEV__) { { if ( typeof config.ref === "string" && - ReactSharedInternals.owner && + ReactCurrentOwner.current && self && - ReactSharedInternals.owner.stateNode !== self + ReactCurrentOwner.current.stateNode !== self ) { var componentName = getComponentNameFromType( - ReactSharedInternals.owner.type + ReactCurrentOwner.current.type ); if (!didWarnAboutStringRefs[componentName]) { @@ -1025,7 +863,7 @@ if (__DEV__) { "We ask you to manually fix this case by using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + "https://react.dev/link/strict-mode-string-ref", - getComponentNameFromType(ReactSharedInternals.owner.type), + getComponentNameFromType(ReactCurrentOwner.current.type), config.ref ); @@ -1349,6 +1187,9 @@ if (__DEV__) { } } + var propName; // Reserved names are extracted + + var props = {}; var key = null; var ref = null; // Currently, key can be spread in as a prop. This causes a potential // issue if key is also explicitly declared (ie.
@@ -1376,49 +1217,20 @@ if (__DEV__) { if (hasValidRef(config)) { if (!enableRefAsProp) { ref = config.ref; - - { - ref = coerceStringRef(ref, ReactSharedInternals.owner, type); - } } { warnIfStringRefCannotBeAutoConverted(config, self); } - } + } // Remaining properties are added to a new props object - var props; - - if (enableRefAsProp && disableStringRefs && !("key" in config)) { - // If key was not spread in, we can reuse the original props object. This - // only works for `jsx`, not `createElement`, because `jsx` is a compiler - // target and the compiler always passes a new object. For `createElement`, - // we can't assume a new object is passed every time because it can be - // called manually. - // - // Spreading key is a warning in dev. In a future release, we will not - // remove a spread key from the props object. (But we'll still warn.) We'll - // always pass the object straight through. - props = config; - } else { - // We need to remove reserved props (key, prop, ref). Create a fresh props - // object and copy over all the non-reserved props. We don't use `delete` - // because in V8 it will deopt the object to dictionary mode. - props = {}; - - for (var propName in config) { - // Skip over reserved prop names - if (propName !== "key" && (enableRefAsProp || propName !== "ref")) { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - ); - } else { - props[propName] = config[propName]; - } - } + for (propName in config) { + if ( + hasOwnProperty.call(config, propName) && // Skip over reserved prop names + propName !== "key" && + (enableRefAsProp || propName !== "ref") + ) { + props[propName] = config[propName]; } } @@ -1427,9 +1239,9 @@ if (__DEV__) { if (type && type.defaultProps) { var defaultProps = type.defaultProps; - for (var _propName2 in defaultProps) { - if (props[_propName2] === undefined) { - props[_propName2] = defaultProps[_propName2]; + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; } } } @@ -1456,7 +1268,7 @@ if (__DEV__) { ref, self, source, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); @@ -1470,8 +1282,8 @@ if (__DEV__) { function getDeclarationErrorAddendum() { { - if (ReactSharedInternals.owner) { - var name = getComponentNameFromType(ReactSharedInternals.owner.type); + if (ReactCurrentOwner.current) { + var name = getComponentNameFromType(ReactCurrentOwner.current.type); if (name) { return "\n\nCheck the render method of `" + name + "`."; @@ -1585,18 +1397,14 @@ if (__DEV__) { if ( element && - element._owner != null && - element._owner !== ReactSharedInternals.owner + element._owner && + element._owner !== ReactCurrentOwner.current ) { - var ownerName = null; - - if (typeof element._owner.tag === "number") { - ownerName = getComponentNameFromType(element._owner.type); - } else if (typeof element._owner.name === "string") { - ownerName = element._owner.name; - } // Give the component that originally created this child. - - childOwner = " It was passed a child from " + ownerName + "."; + // Give the component that originally created this child. + childOwner = + " It was passed a child from " + + getComponentNameFromType(element._owner.type) + + "."; } setCurrentlyValidatingElement(element); @@ -1615,10 +1423,14 @@ if (__DEV__) { function setCurrentlyValidatingElement(element) { { if (element) { - var stack = describeUnknownElementTypeFrameInDEV(element.type); - ReactSharedInternals.setExtraStackFrame(stack); + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV( + element.type, + owner ? owner.type : null + ); + ReactDebugCurrentFrame.setExtraStackFrame(stack); } else { - ReactSharedInternals.setExtraStackFrame(null); + ReactDebugCurrentFrame.setExtraStackFrame(null); } } } @@ -1676,96 +1488,6 @@ if (__DEV__) { } } - function coerceStringRef(mixedRef, owner, type) { - var stringRef; - - if (typeof mixedRef === "string") { - stringRef = mixedRef; - } else { - if (typeof mixedRef === "number" || typeof mixedRef === "boolean") { - { - checkPropStringCoercion(mixedRef, "ref"); - } - - stringRef = "" + mixedRef; - } else { - return mixedRef; - } - } - - return stringRefAsCallbackRef.bind(null, stringRef, type, owner); - } - - function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) { - throw new Error( - "Element ref was specified as a string (" + - stringRef + - ") but no owner was set. This could happen for one of" + - " the following reasons:\n" + - "1. You may be adding a ref to a function component\n" + - "2. You may be adding a ref to a component that was not created inside a component's render method\n" + - "3. You have multiple copies of React loaded\n" + - "See https://react.dev/link/refs-must-have-owner for more information." - ); - } - - if (owner.tag !== ClassComponent) { - throw new Error( - "Function components cannot have string refs. " + - "We recommend using useRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref" - ); - } - - { - if ( - // Will already warn with "Function components cannot be given refs" - !(typeof type === "function" && !isReactClass(type)) - ) { - var componentName = getComponentNameFromFiber(owner) || "Component"; - - if (!didWarnAboutStringRefs[componentName]) { - error( - 'Component "%s" contains the string ref "%s". Support for string refs ' + - "will be removed in a future major release. We recommend using " + - "useRef() or createRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref", - componentName, - stringRef - ); - - didWarnAboutStringRefs[componentName] = true; - } - } - } - - var inst = owner.stateNode; - - if (!inst) { - throw new Error( - "Missing owner for string ref " + - stringRef + - ". This error is likely caused by a " + - "bug in React. Please file an issue." - ); - } - - var refs = inst.refs; - - if (value === null) { - delete refs[stringRef]; - } else { - refs[stringRef] = value; - } - } - - function isReactClass(type) { - return type.prototype && type.prototype.isReactComponent; - } - var jsxDEV = jsxDEV$1; exports.Fragment = REACT_FRAGMENT_TYPE; diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 04046fbcb4..efcac2c6f9 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -da69b6af9697b8042834644b14d0e715d4ace18a +48b4ecc9012638ed51b275aad24b2086b8215e32 diff --git a/compiled/facebook-www/React-dev.classic.js b/compiled/facebook-www/React-dev.classic.js index 0a528e65d4..2afafcfb99 100644 --- a/compiled/facebook-www/React-dev.classic.js +++ b/compiled/facebook-www/React-dev.classic.js @@ -24,7 +24,7 @@ if (__DEV__) { ) { __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); } - var ReactVersion = "19.0.0-www-classic-e2f5fe42"; + var ReactVersion = "19.0.0-www-classic-b9e0eea7"; // ATTENTION // When adding new symbols to this file, @@ -109,10 +109,12 @@ if (__DEV__) { var React = require("react"); var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; // Defensive in case this is fired before React is initialized. + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Defensive in case this is fired before React is initialized. if (ReactSharedInternals != null) { - var stack = ReactSharedInternals.getStackAddendum(); + var ReactDebugCurrentFrame = + ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { format += "%s"; @@ -466,20 +468,6 @@ if (__DEV__) { } } } - function checkPropStringCoercion(value, propName) { - { - if (willCoercionThrow(value)) { - error( - "The provided `%s` prop is an unsupported type %s." + - " This value must be coerced to a string before using it here.", - propName, - typeName(value) - ); - - return testStringCoercion(value); // throw (to help callers find troubleshooting comments) - } - } - } // Re-export dynamic flags from the www version. var dynamicFeatureFlags = require("ReactFeatureFlags"); @@ -490,12 +478,9 @@ if (__DEV__) { enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses; // On WWW, false is used for a new modern build. - // because JSX is an extremely hot path. - - var disableStringRefs = false; var disableLegacyMode = false; - function getWrappedName$1(outerType, innerType, wrapperName) { + function getWrappedName(outerType, innerType, wrapperName) { var displayName = outerType.displayName; if (displayName) { @@ -508,7 +493,7 @@ if (__DEV__) { : wrapperName; } // Keep in sync with react-reconciler/getComponentNameFromFiber - function getContextName$1(type) { + function getContextName(type) { return type.displayName || "Context"; } @@ -575,28 +560,28 @@ if (__DEV__) { return null; } else { var provider = type; - return getContextName$1(provider._context) + ".Provider"; + return getContextName(provider._context) + ".Provider"; } case REACT_CONTEXT_TYPE: var context = type; if (enableRenderableContext) { - return getContextName$1(context) + ".Provider"; + return getContextName(context) + ".Provider"; } else { - return getContextName$1(context) + ".Consumer"; + return getContextName(context) + ".Consumer"; } case REACT_CONSUMER_TYPE: if (enableRenderableContext) { var consumer = type; - return getContextName$1(consumer._context) + ".Consumer"; + return getContextName(consumer._context) + ".Consumer"; } else { return null; } case REACT_FORWARD_REF_TYPE: - return getWrappedName$1(type, type.render, "ForwardRef"); + return getWrappedName(type, type.render, "ForwardRef"); case REACT_MEMO_TYPE: var outerName = type.displayName || null; @@ -624,38 +609,75 @@ if (__DEV__) { return null; } - var ReactSharedInternals = { - H: null, - C: null, - T: null + /** + * Keeps track of the current dispatcher. + */ + var ReactCurrentDispatcher$1 = { + current: null }; - { - ReactSharedInternals.owner = null; - } + /** + * Keeps track of the current Cache dispatcher. + */ + var ReactCurrentCache = { + current: null + }; + + /** + * Keeps track of the current batch's configuration such as how long an update + * should suspend for if it needs to. + */ + var ReactCurrentBatchConfig = { + transition: null + }; + + var ReactCurrentActQueue = { + current: null, + // Used to reproduce behavior of `batchedUpdates` in legacy mode. + isBatchingLegacy: false, + didScheduleLegacyUpdate: false, + // Tracks whether something called `use` during the current batch of work. + // Determines whether we should yield to microtasks to unwrap already resolved + // promises without suspending. + didUsePromise: false, + // Track first uncaught error within this act + thrownErrors: [] + }; + + /** + * Keeps track of the current owner. + * + * The current owner is the component who should own any components that are + * currently being constructed. + */ + var ReactCurrentOwner$1 = { + /** + * @internal + * @type {ReactComponent} + */ + current: null + }; + + var ReactDebugCurrentFrame$1 = {}; + var currentExtraStackFrame = null; { - ReactSharedInternals.actQueue = null; - ReactSharedInternals.isBatchingLegacy = false; - ReactSharedInternals.didScheduleLegacyUpdate = false; - ReactSharedInternals.didUsePromise = false; - ReactSharedInternals.thrownErrors = []; - var currentExtraStackFrame = null; - - ReactSharedInternals.setExtraStackFrame = function (stack) { - currentExtraStackFrame = stack; + ReactDebugCurrentFrame$1.setExtraStackFrame = function (stack) { + { + currentExtraStackFrame = stack; + } }; // Stack implementation injected by the current renderer. - ReactSharedInternals.getCurrentStack = null; + ReactDebugCurrentFrame$1.getCurrentStack = null; - ReactSharedInternals.getStackAddendum = function () { + ReactDebugCurrentFrame$1.getStackAddendum = function () { var stack = ""; // Add an extra top frame while an element is being validated if (currentExtraStackFrame) { stack += currentExtraStackFrame; } // Delegate to the injected renderer-specific implementation - var impl = ReactSharedInternals.getCurrentStack; + var impl = ReactDebugCurrentFrame$1.getCurrentStack; if (impl) { stack += impl() || ""; @@ -665,6 +687,18 @@ if (__DEV__) { }; } + var ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher$1, + ReactCurrentCache: ReactCurrentCache, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: ReactCurrentOwner$1 + }; + + { + ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame$1; + ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue; + } + // $FlowFixMe[method-unbinding] var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -807,8 +841,9 @@ if (__DEV__) { } } + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; var prefix; - function describeBuiltInComponentFrame(name) { + function describeBuiltInComponentFrame(name, ownerFn) { { if (prefix === undefined) { // Extract the VM specific prefix used by each line. @@ -860,13 +895,13 @@ if (__DEV__) { var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. Error.prepareStackTrace = undefined; - var previousDispatcher = null; + var previousDispatcher; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function // for warnings. - ReactSharedInternals.H = null; + ReactCurrentDispatcher.current = null; disableLogs(); } /** @@ -1059,7 +1094,7 @@ if (__DEV__) { reentry = false; { - ReactSharedInternals.H = previousDispatcher; + ReactCurrentDispatcher.current = previousDispatcher; reenableLogs(); } @@ -1077,7 +1112,7 @@ if (__DEV__) { return syntheticFrame; } - function describeFunctionComponentFrame(fn) { + function describeFunctionComponentFrame(fn, ownerFn) { { return describeNativeComponentFrame(fn, false); } @@ -1088,7 +1123,7 @@ if (__DEV__) { return !!(prototype && prototype.isReactComponent); } - function describeUnknownElementTypeFrameInDEV(type) { + function describeUnknownElementTypeFrameInDEV(type, ownerFn) { if (type == null) { return ""; } @@ -1118,7 +1153,7 @@ if (__DEV__) { case REACT_MEMO_TYPE: // Memo may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(type.type); + return describeUnknownElementTypeFrameInDEV(type.type, ownerFn); case REACT_LAZY_TYPE: { var lazyComponent = type; @@ -1127,7 +1162,10 @@ if (__DEV__) { try { // Lazy may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(init(payload)); + return describeUnknownElementTypeFrameInDEV( + init(payload), + ownerFn + ); } catch (x) {} } } @@ -1136,163 +1174,13 @@ if (__DEV__) { return ""; } - var FunctionComponent = 0; - var ClassComponent = 1; - var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - - var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - - var HostComponent = 5; - var HostText = 6; - var Fragment = 7; - var Mode = 8; - var ContextConsumer = 9; - var ContextProvider = 10; - var ForwardRef = 11; - var Profiler = 12; - var SuspenseComponent = 13; - var MemoComponent = 14; - var SimpleMemoComponent = 15; - var LazyComponent = 16; - var IncompleteClassComponent = 17; - var DehydratedFragment = 18; - var SuspenseListComponent = 19; - var ScopeComponent = 21; - var OffscreenComponent = 22; - var LegacyHiddenComponent = 23; - var CacheComponent = 24; - var TracingMarkerComponent = 25; - var HostHoistable = 26; - var HostSingleton = 27; - var IncompleteFunctionComponent = 28; - - function getWrappedName(outerType, innerType, wrapperName) { - var functionName = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - (functionName !== "" - ? wrapperName + "(" + functionName + ")" - : wrapperName) - ); - } // Keep in sync with shared/getComponentNameFromType - - function getContextName(type) { - return type.displayName || "Context"; - } - function getComponentNameFromFiber(fiber) { - var tag = fiber.tag, - type = fiber.type; - - switch (tag) { - case CacheComponent: - return "Cache"; - - case ContextConsumer: - if (enableRenderableContext) { - var consumer = type; - return getContextName(consumer._context) + ".Consumer"; - } else { - var context = type; - return getContextName(context) + ".Consumer"; - } - - case ContextProvider: - if (enableRenderableContext) { - var _context = type; - return getContextName(_context) + ".Provider"; - } else { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } - - case DehydratedFragment: - return "DehydratedFragment"; - - case ForwardRef: - return getWrappedName(type, type.render, "ForwardRef"); - - case Fragment: - return "Fragment"; - - case HostHoistable: - case HostSingleton: - case HostComponent: - // Host component type is the display name (e.g. "div", "View") - return type; - - case HostPortal: - return "Portal"; - - case HostRoot: - return "Root"; - - case HostText: - return "Text"; - - case LazyComponent: - // Name comes from the type in this case; we don't have a tag. - return getComponentNameFromType(type); - - case Mode: - if (type === REACT_STRICT_MODE_TYPE) { - // Don't be less specific than shared/getComponentNameFromType - return "StrictMode"; - } - - return "Mode"; - - case OffscreenComponent: - return "Offscreen"; - - case Profiler: - return "Profiler"; - - case ScopeComponent: - return "Scope"; - - case SuspenseComponent: - return "Suspense"; - - case SuspenseListComponent: - return "SuspenseList"; - - case TracingMarkerComponent: - return "TracingMarker"; - // The display name for these tags come from the user-provided type: - - case IncompleteClassComponent: - case IncompleteFunctionComponent: - - // Fallthrough - - case ClassComponent: - case FunctionComponent: - case MemoComponent: - case SimpleMemoComponent: - if (typeof type === "function") { - return type.displayName || type.name || null; - } - - if (typeof type === "string") { - return type; - } - - break; - - case LegacyHiddenComponent: { - return "LegacyHidden"; - } - } - - return null; - } - + var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); var specialPropKeyWarningShown; var specialPropRefWarningShown; var didWarnAboutStringRefs; var didWarnAboutElementRef; - var didWarnAboutOldJSXRuntime; { didWarnAboutStringRefs = {}; @@ -1331,12 +1219,12 @@ if (__DEV__) { { if ( typeof config.ref === "string" && - ReactSharedInternals.owner && + ReactCurrentOwner.current && self && - ReactSharedInternals.owner.stateNode !== self + ReactCurrentOwner.current.stateNode !== self ) { var componentName = getComponentNameFromType( - ReactSharedInternals.owner.type + ReactCurrentOwner.current.type ); if (!didWarnAboutStringRefs[componentName]) { @@ -1347,7 +1235,7 @@ if (__DEV__) { "We ask you to manually fix this case by using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + "https://react.dev/link/strict-mode-string-ref", - getComponentNameFromType(ReactSharedInternals.owner.type), + getComponentNameFromType(ReactCurrentOwner.current.type), config.ref ); @@ -1707,6 +1595,9 @@ if (__DEV__) { } } + var propName; // Reserved names are extracted + + var props = {}; var key = null; var ref = null; // Currently, key can be spread in as a prop. This causes a potential // issue if key is also explicitly declared (ie.
@@ -1734,49 +1625,20 @@ if (__DEV__) { if (hasValidRef(config)) { if (!enableRefAsProp) { ref = config.ref; - - { - ref = coerceStringRef(ref, ReactSharedInternals.owner, type); - } } { warnIfStringRefCannotBeAutoConverted(config, self); } - } + } // Remaining properties are added to a new props object - var props; - - if (enableRefAsProp && disableStringRefs && !("key" in config)) { - // If key was not spread in, we can reuse the original props object. This - // only works for `jsx`, not `createElement`, because `jsx` is a compiler - // target and the compiler always passes a new object. For `createElement`, - // we can't assume a new object is passed every time because it can be - // called manually. - // - // Spreading key is a warning in dev. In a future release, we will not - // remove a spread key from the props object. (But we'll still warn.) We'll - // always pass the object straight through. - props = config; - } else { - // We need to remove reserved props (key, prop, ref). Create a fresh props - // object and copy over all the non-reserved props. We don't use `delete` - // because in V8 it will deopt the object to dictionary mode. - props = {}; - - for (var propName in config) { - // Skip over reserved prop names - if (propName !== "key" && (enableRefAsProp || propName !== "ref")) { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - ); - } else { - props[propName] = config[propName]; - } - } + for (propName in config) { + if ( + hasOwnProperty.call(config, propName) && // Skip over reserved prop names + propName !== "key" && + (enableRefAsProp || propName !== "ref") + ) { + props[propName] = config[propName]; } } @@ -1785,9 +1647,9 @@ if (__DEV__) { if (type && type.defaultProps) { var defaultProps = type.defaultProps; - for (var _propName2 in defaultProps) { - if (props[_propName2] === undefined) { - props[_propName2] = defaultProps[_propName2]; + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; } } } @@ -1814,7 +1676,7 @@ if (__DEV__) { ref, self, source, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); @@ -1895,34 +1757,9 @@ if (__DEV__) { var ref = null; if (config != null) { - { - if ( - !didWarnAboutOldJSXRuntime && - "__self" in config && // Do not assume this is the result of an oudated JSX transform if key - // is present, because the modern JSX transform sometimes outputs - // createElement to preserve precedence between a static key and a - // spread key. To avoid false positive warnings, we never warn if - // there's a key. - !("key" in config) - ) { - didWarnAboutOldJSXRuntime = true; - - warn( - "Your app (or one of its dependencies) is using an outdated JSX " + - "transform. Update to the modern JSX transform for " + - "faster performance: " + // TODO: Create a short link for this - "https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html" - ); - } - } - if (hasValidRef(config)) { if (!enableRefAsProp) { ref = config.ref; - - { - ref = coerceStringRef(ref, ReactSharedInternals.owner, type); - } } { @@ -1949,15 +1786,7 @@ if (__DEV__) { propName !== "__self" && propName !== "__source" ) { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - ); - } else { - props[propName] = config[propName]; - } + props[propName] = config[propName]; } } } // Children can be more than one argument, and those are transferred onto @@ -2016,7 +1845,7 @@ if (__DEV__) { ref, undefined, undefined, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); @@ -2063,16 +1892,12 @@ if (__DEV__) { if (config != null) { if (hasValidRef(config)) { - owner = ReactSharedInternals.owner; - if (!enableRefAsProp) { // Silently steal the ref from the parent. ref = config.ref; - - { - ref = coerceStringRef(ref, owner, element.type); - } } + + owner = ReactCurrentOwner.current; } if (hasValidKey(config)) { @@ -2117,15 +1942,7 @@ if (__DEV__) { // Resolve default props props[propName] = defaultProps[propName]; } else { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - owner, - element.type - ); - } else { - props[propName] = config[propName]; - } + props[propName] = config[propName]; } } } @@ -2165,8 +1982,8 @@ if (__DEV__) { function getDeclarationErrorAddendum() { { - if (ReactSharedInternals.owner) { - var name = getComponentNameFromType(ReactSharedInternals.owner.type); + if (ReactCurrentOwner.current) { + var name = getComponentNameFromType(ReactCurrentOwner.current.type); if (name) { return "\n\nCheck the render method of `" + name + "`."; @@ -2280,18 +2097,14 @@ if (__DEV__) { if ( element && - element._owner != null && - element._owner !== ReactSharedInternals.owner + element._owner && + element._owner !== ReactCurrentOwner.current ) { - var ownerName = null; - - if (typeof element._owner.tag === "number") { - ownerName = getComponentNameFromType(element._owner.type); - } else if (typeof element._owner.name === "string") { - ownerName = element._owner.name; - } // Give the component that originally created this child. - - childOwner = " It was passed a child from " + ownerName + "."; + // Give the component that originally created this child. + childOwner = + " It was passed a child from " + + getComponentNameFromType(element._owner.type) + + "."; } setCurrentlyValidatingElement(element); @@ -2310,10 +2123,14 @@ if (__DEV__) { function setCurrentlyValidatingElement(element) { { if (element) { - var stack = describeUnknownElementTypeFrameInDEV(element.type); - ReactSharedInternals.setExtraStackFrame(stack); + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV( + element.type, + owner ? owner.type : null + ); + ReactDebugCurrentFrame.setExtraStackFrame(stack); } else { - ReactSharedInternals.setExtraStackFrame(null); + ReactDebugCurrentFrame.setExtraStackFrame(null); } } } @@ -2371,96 +2188,6 @@ if (__DEV__) { } } - function coerceStringRef(mixedRef, owner, type) { - var stringRef; - - if (typeof mixedRef === "string") { - stringRef = mixedRef; - } else { - if (typeof mixedRef === "number" || typeof mixedRef === "boolean") { - { - checkPropStringCoercion(mixedRef, "ref"); - } - - stringRef = "" + mixedRef; - } else { - return mixedRef; - } - } - - return stringRefAsCallbackRef.bind(null, stringRef, type, owner); - } - - function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) { - throw new Error( - "Element ref was specified as a string (" + - stringRef + - ") but no owner was set. This could happen for one of" + - " the following reasons:\n" + - "1. You may be adding a ref to a function component\n" + - "2. You may be adding a ref to a component that was not created inside a component's render method\n" + - "3. You have multiple copies of React loaded\n" + - "See https://react.dev/link/refs-must-have-owner for more information." - ); - } - - if (owner.tag !== ClassComponent) { - throw new Error( - "Function components cannot have string refs. " + - "We recommend using useRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref" - ); - } - - { - if ( - // Will already warn with "Function components cannot be given refs" - !(typeof type === "function" && !isReactClass(type)) - ) { - var componentName = getComponentNameFromFiber(owner) || "Component"; - - if (!didWarnAboutStringRefs[componentName]) { - error( - 'Component "%s" contains the string ref "%s". Support for string refs ' + - "will be removed in a future major release. We recommend using " + - "useRef() or createRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref", - componentName, - stringRef - ); - - didWarnAboutStringRefs[componentName] = true; - } - } - } - - var inst = owner.stateNode; - - if (!inst) { - throw new Error( - "Missing owner for string ref " + - stringRef + - ". This error is likely caused by a " + - "bug in React. Please file an issue." - ); - } - - var refs = inst.refs; - - if (value === null) { - delete refs[stringRef]; - } else { - refs[stringRef] = value; - } - } - - function isReactClass(type) { - return type.prototype && type.prototype.isReactComponent; - } - var SEPARATOR = "."; var SUBSEPARATOR = ":"; /** @@ -3215,7 +2942,7 @@ if (__DEV__) { var cache = noopCache; function resolveDispatcher() { - var dispatcher = ReactSharedInternals.H; + var dispatcher = ReactCurrentDispatcher$1.current; { if (dispatcher === null) { @@ -3236,7 +2963,7 @@ if (__DEV__) { } function getCacheForType(resourceType) { - var dispatcher = ReactSharedInternals.C; + var dispatcher = ReactCurrentCache.current; if (!dispatcher) { // If there is no dispatcher, then we treat this as not being cached. @@ -3393,26 +3120,26 @@ if (__DEV__) { }; function startTransition(scope, options) { - var prevTransition = ReactSharedInternals.T; // Each renderer registers a callback to receive the return value of + var prevTransition = ReactCurrentBatchConfig.transition; // Each renderer registers a callback to receive the return value of // the scope function. This is used to implement async actions. var callbacks = new Set(); var transition = { _callbacks: callbacks }; - ReactSharedInternals.T = transition; - var currentTransition = ReactSharedInternals.T; + ReactCurrentBatchConfig.transition = transition; + var currentTransition = ReactCurrentBatchConfig.transition; { - ReactSharedInternals.T._updatedFibers = new Set(); + ReactCurrentBatchConfig.transition._updatedFibers = new Set(); } if (enableTransitionTracing) { if (options !== undefined && options.name !== undefined) { // $FlowFixMe[incompatible-use] found when upgrading Flow - ReactSharedInternals.T.name = options.name; // $FlowFixMe[incompatible-use] found when upgrading Flow + ReactCurrentBatchConfig.transition.name = options.name; // $FlowFixMe[incompatible-use] found when upgrading Flow - ReactSharedInternals.T.startTime = -1; + ReactCurrentBatchConfig.transition.startTime = -1; } } @@ -3434,7 +3161,7 @@ if (__DEV__) { reportGlobalError(error); } finally { warnAboutTransitionSubscriptions(prevTransition, currentTransition); - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; } } } @@ -3521,7 +3248,7 @@ if (__DEV__) { function act(callback) { { - // When ReactSharedInternals.actQueue is not null, it signals to React that + // When ReactCurrentActQueue.current is not null, it signals to React that // we're currently inside an `act` scope. React will push all its tasks to // this queue instead of scheduling them with platform APIs. // @@ -3530,18 +3257,18 @@ if (__DEV__) { // `act` calls can be nested. // // If we're already inside an `act` scope, reuse the existing queue. - var prevIsBatchingLegacy = ReactSharedInternals.isBatchingLegacy; - var prevActQueue = ReactSharedInternals.actQueue; + var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy; + var prevActQueue = ReactCurrentActQueue.current; var prevActScopeDepth = actScopeDepth; actScopeDepth++; - var queue = (ReactSharedInternals.actQueue = + var queue = (ReactCurrentActQueue.current = prevActQueue !== null ? prevActQueue : []); // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only // set to `true` while the given callback is executed, not for updates // triggered during an async event, because this is how the legacy // implementation of `act` behaved. { - ReactSharedInternals.isBatchingLegacy = true; + ReactCurrentActQueue.isBatchingLegacy = true; } var result; // This tracks whether the `act` call is awaited. In certain cases, not @@ -3554,12 +3281,12 @@ if (__DEV__) { // only place we ever read this fields is just below, right after running // the callback. So we don't need to reset after the callback runs. if (!disableLegacyMode) { - ReactSharedInternals.didScheduleLegacyUpdate = false; + ReactCurrentActQueue.didScheduleLegacyUpdate = false; } result = callback(); var didScheduleLegacyUpdate = !disableLegacyMode - ? ReactSharedInternals.didScheduleLegacyUpdate + ? ReactCurrentActQueue.didScheduleLegacyUpdate : false; // Replicate behavior of original `act` implementation in legacy mode, // which flushed updates immediately after the scope function exits, even // if it's an async function. @@ -3572,24 +3299,24 @@ if (__DEV__) { // delete legacy mode!! if (!disableLegacyMode) { - ReactSharedInternals.isBatchingLegacy = prevIsBatchingLegacy; + ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy; } } catch (error) { // `isBatchingLegacy` gets reset using the regular stack, not the async // one used to track `act` scopes. Why, you may be wondering? Because // that's how it worked before version 18. Yes, it's confusing! We should // delete legacy mode!! - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue.thrownErrors.push(error); } - if (ReactSharedInternals.thrownErrors.length > 0) { + if (ReactCurrentActQueue.thrownErrors.length > 0) { { - ReactSharedInternals.isBatchingLegacy = prevIsBatchingLegacy; + ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy; } popActScope(prevActQueue, prevActScopeDepth); - var thrownError = aggregateErrors(ReactSharedInternals.thrownErrors); - ReactSharedInternals.thrownErrors.length = 0; + var thrownError = aggregateErrors(ReactCurrentActQueue.thrownErrors); + ReactCurrentActQueue.thrownErrors.length = 0; throw thrownError; } @@ -3645,15 +3372,15 @@ if (__DEV__) { // `thenable` might not be a real promise, and `flushActQueue` // might throw, so we need to wrap `flushActQueue` in a // try/catch. - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue.thrownErrors.push(error); } - if (ReactSharedInternals.thrownErrors.length > 0) { + if (ReactCurrentActQueue.thrownErrors.length > 0) { var _thrownError = aggregateErrors( - ReactSharedInternals.thrownErrors + ReactCurrentActQueue.thrownErrors ); - ReactSharedInternals.thrownErrors.length = 0; + ReactCurrentActQueue.thrownErrors.length = 0; reject(_thrownError); } } else { @@ -3663,12 +3390,12 @@ if (__DEV__) { function (error) { popActScope(prevActQueue, prevActScopeDepth); - if (ReactSharedInternals.thrownErrors.length > 0) { + if (ReactCurrentActQueue.thrownErrors.length > 0) { var _thrownError2 = aggregateErrors( - ReactSharedInternals.thrownErrors + ReactCurrentActQueue.thrownErrors ); - ReactSharedInternals.thrownErrors.length = 0; + ReactCurrentActQueue.thrownErrors.length = 0; reject(_thrownError2); } else { reject(error); @@ -3722,15 +3449,15 @@ if (__DEV__) { // TODO: In a future version, consider always requiring all `act` calls // to be awaited, regardless of whether the callback is sync or async. - ReactSharedInternals.actQueue = null; + ReactCurrentActQueue.current = null; } - if (ReactSharedInternals.thrownErrors.length > 0) { + if (ReactCurrentActQueue.thrownErrors.length > 0) { var _thrownError3 = aggregateErrors( - ReactSharedInternals.thrownErrors + ReactCurrentActQueue.thrownErrors ); - ReactSharedInternals.thrownErrors.length = 0; + ReactCurrentActQueue.thrownErrors.length = 0; throw _thrownError3; } @@ -3741,7 +3468,7 @@ if (__DEV__) { if (prevActScopeDepth === 0) { // If the `act` call is awaited, restore the queue we were // using before (see long comment above) so we can flush it. - ReactSharedInternals.actQueue = queue; + ReactCurrentActQueue.current = queue; enqueueTask(function () { return ( // Recursively flush tasks scheduled by a microtask. @@ -3773,7 +3500,7 @@ if (__DEV__) { function recursivelyFlushAsyncActWork(returnValue, resolve, reject) { { // Check if any tasks were scheduled asynchronously. - var queue = ReactSharedInternals.actQueue; + var queue = ReactCurrentActQueue.current; if (queue !== null) { if (queue.length !== 0) { @@ -3793,17 +3520,17 @@ if (__DEV__) { return; } catch (error) { // Leave remaining tasks on the queue if something throws. - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue.thrownErrors.push(error); } } else { // The queue is empty. We can finish. - ReactSharedInternals.actQueue = null; + ReactCurrentActQueue.current = null; } } - if (ReactSharedInternals.thrownErrors.length > 0) { - var thrownError = aggregateErrors(ReactSharedInternals.thrownErrors); - ReactSharedInternals.thrownErrors.length = 0; + if (ReactCurrentActQueue.thrownErrors.length > 0) { + var thrownError = aggregateErrors(ReactCurrentActQueue.thrownErrors); + ReactCurrentActQueue.thrownErrors.length = 0; reject(thrownError); } else { resolve(returnValue); @@ -3825,11 +3552,11 @@ if (__DEV__) { var callback = queue[i]; do { - ReactSharedInternals.didUsePromise = false; + ReactCurrentActQueue.didUsePromise = false; var continuation = callback(false); if (continuation !== null) { - if (ReactSharedInternals.didUsePromise) { + if (ReactCurrentActQueue.didUsePromise) { // The component just suspended. Yield to the main thread in // case the promise is already resolved. If so, it will ping in // a microtask and we can resume without unwinding the stack. @@ -3849,7 +3576,7 @@ if (__DEV__) { } catch (error) { // If something throws, leave the remaining callbacks on the queue. queue.splice(0, i + 1); - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue.thrownErrors.push(error); } finally { isFlushing = false; } @@ -3896,7 +3623,7 @@ if (__DEV__) { exports.PureComponent = PureComponent; exports.StrictMode = REACT_STRICT_MODE_TYPE; exports.Suspense = REACT_SUSPENSE_TYPE; - exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = + exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; exports.act = act; exports.cache = cache; diff --git a/compiled/facebook-www/React-dev.modern.js b/compiled/facebook-www/React-dev.modern.js index d19ef6b0a0..e81bca2033 100644 --- a/compiled/facebook-www/React-dev.modern.js +++ b/compiled/facebook-www/React-dev.modern.js @@ -24,7 +24,7 @@ if (__DEV__) { ) { __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); } - var ReactVersion = "19.0.0-www-modern-cd353aaf"; + var ReactVersion = "19.0.0-www-modern-3a8173ed"; // ATTENTION // When adding new symbols to this file, @@ -109,10 +109,12 @@ if (__DEV__) { var React = require("react"); var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; // Defensive in case this is fired before React is initialized. + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Defensive in case this is fired before React is initialized. if (ReactSharedInternals != null) { - var stack = ReactSharedInternals.getStackAddendum(); + var ReactDebugCurrentFrame = + ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { format += "%s"; @@ -466,20 +468,6 @@ if (__DEV__) { } } } - function checkPropStringCoercion(value, propName) { - { - if (willCoercionThrow(value)) { - error( - "The provided `%s` prop is an unsupported type %s." + - " This value must be coerced to a string before using it here.", - propName, - typeName(value) - ); - - return testStringCoercion(value); // throw (to help callers find troubleshooting comments) - } - } - } // Re-export dynamic flags from the www version. var dynamicFeatureFlags = require("ReactFeatureFlags"); @@ -490,12 +478,9 @@ if (__DEV__) { enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses; // On WWW, true is used for a new modern build. - // because JSX is an extremely hot path. - - var disableStringRefs = false; var disableLegacyMode = true; - function getWrappedName$1(outerType, innerType, wrapperName) { + function getWrappedName(outerType, innerType, wrapperName) { var displayName = outerType.displayName; if (displayName) { @@ -508,7 +493,7 @@ if (__DEV__) { : wrapperName; } // Keep in sync with react-reconciler/getComponentNameFromFiber - function getContextName$1(type) { + function getContextName(type) { return type.displayName || "Context"; } @@ -575,28 +560,28 @@ if (__DEV__) { return null; } else { var provider = type; - return getContextName$1(provider._context) + ".Provider"; + return getContextName(provider._context) + ".Provider"; } case REACT_CONTEXT_TYPE: var context = type; if (enableRenderableContext) { - return getContextName$1(context) + ".Provider"; + return getContextName(context) + ".Provider"; } else { - return getContextName$1(context) + ".Consumer"; + return getContextName(context) + ".Consumer"; } case REACT_CONSUMER_TYPE: if (enableRenderableContext) { var consumer = type; - return getContextName$1(consumer._context) + ".Consumer"; + return getContextName(consumer._context) + ".Consumer"; } else { return null; } case REACT_FORWARD_REF_TYPE: - return getWrappedName$1(type, type.render, "ForwardRef"); + return getWrappedName(type, type.render, "ForwardRef"); case REACT_MEMO_TYPE: var outerName = type.displayName || null; @@ -624,38 +609,75 @@ if (__DEV__) { return null; } - var ReactSharedInternals = { - H: null, - C: null, - T: null + /** + * Keeps track of the current dispatcher. + */ + var ReactCurrentDispatcher$1 = { + current: null }; - { - ReactSharedInternals.owner = null; - } + /** + * Keeps track of the current Cache dispatcher. + */ + var ReactCurrentCache = { + current: null + }; + + /** + * Keeps track of the current batch's configuration such as how long an update + * should suspend for if it needs to. + */ + var ReactCurrentBatchConfig = { + transition: null + }; + + var ReactCurrentActQueue = { + current: null, + // Used to reproduce behavior of `batchedUpdates` in legacy mode. + isBatchingLegacy: false, + didScheduleLegacyUpdate: false, + // Tracks whether something called `use` during the current batch of work. + // Determines whether we should yield to microtasks to unwrap already resolved + // promises without suspending. + didUsePromise: false, + // Track first uncaught error within this act + thrownErrors: [] + }; + + /** + * Keeps track of the current owner. + * + * The current owner is the component who should own any components that are + * currently being constructed. + */ + var ReactCurrentOwner$1 = { + /** + * @internal + * @type {ReactComponent} + */ + current: null + }; + + var ReactDebugCurrentFrame$1 = {}; + var currentExtraStackFrame = null; { - ReactSharedInternals.actQueue = null; - ReactSharedInternals.isBatchingLegacy = false; - ReactSharedInternals.didScheduleLegacyUpdate = false; - ReactSharedInternals.didUsePromise = false; - ReactSharedInternals.thrownErrors = []; - var currentExtraStackFrame = null; - - ReactSharedInternals.setExtraStackFrame = function (stack) { - currentExtraStackFrame = stack; + ReactDebugCurrentFrame$1.setExtraStackFrame = function (stack) { + { + currentExtraStackFrame = stack; + } }; // Stack implementation injected by the current renderer. - ReactSharedInternals.getCurrentStack = null; + ReactDebugCurrentFrame$1.getCurrentStack = null; - ReactSharedInternals.getStackAddendum = function () { + ReactDebugCurrentFrame$1.getStackAddendum = function () { var stack = ""; // Add an extra top frame while an element is being validated if (currentExtraStackFrame) { stack += currentExtraStackFrame; } // Delegate to the injected renderer-specific implementation - var impl = ReactSharedInternals.getCurrentStack; + var impl = ReactDebugCurrentFrame$1.getCurrentStack; if (impl) { stack += impl() || ""; @@ -665,6 +687,18 @@ if (__DEV__) { }; } + var ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher$1, + ReactCurrentCache: ReactCurrentCache, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: ReactCurrentOwner$1 + }; + + { + ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame$1; + ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue; + } + // $FlowFixMe[method-unbinding] var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -807,8 +841,9 @@ if (__DEV__) { } } + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; var prefix; - function describeBuiltInComponentFrame(name) { + function describeBuiltInComponentFrame(name, ownerFn) { { if (prefix === undefined) { // Extract the VM specific prefix used by each line. @@ -860,13 +895,13 @@ if (__DEV__) { var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. Error.prepareStackTrace = undefined; - var previousDispatcher = null; + var previousDispatcher; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function // for warnings. - ReactSharedInternals.H = null; + ReactCurrentDispatcher.current = null; disableLogs(); } /** @@ -1059,7 +1094,7 @@ if (__DEV__) { reentry = false; { - ReactSharedInternals.H = previousDispatcher; + ReactCurrentDispatcher.current = previousDispatcher; reenableLogs(); } @@ -1077,7 +1112,7 @@ if (__DEV__) { return syntheticFrame; } - function describeFunctionComponentFrame(fn) { + function describeFunctionComponentFrame(fn, ownerFn) { { return describeNativeComponentFrame(fn, false); } @@ -1088,7 +1123,7 @@ if (__DEV__) { return !!(prototype && prototype.isReactComponent); } - function describeUnknownElementTypeFrameInDEV(type) { + function describeUnknownElementTypeFrameInDEV(type, ownerFn) { if (type == null) { return ""; } @@ -1118,7 +1153,7 @@ if (__DEV__) { case REACT_MEMO_TYPE: // Memo may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(type.type); + return describeUnknownElementTypeFrameInDEV(type.type, ownerFn); case REACT_LAZY_TYPE: { var lazyComponent = type; @@ -1127,7 +1162,10 @@ if (__DEV__) { try { // Lazy may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(init(payload)); + return describeUnknownElementTypeFrameInDEV( + init(payload), + ownerFn + ); } catch (x) {} } } @@ -1136,165 +1174,13 @@ if (__DEV__) { return ""; } - var FunctionComponent = 0; - var ClassComponent = 1; - var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - - var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - - var HostComponent = 5; - var HostText = 6; - var Fragment = 7; - var Mode = 8; - var ContextConsumer = 9; - var ContextProvider = 10; - var ForwardRef = 11; - var Profiler = 12; - var SuspenseComponent = 13; - var MemoComponent = 14; - var SimpleMemoComponent = 15; - var LazyComponent = 16; - var IncompleteClassComponent = 17; - var DehydratedFragment = 18; - var SuspenseListComponent = 19; - var ScopeComponent = 21; - var OffscreenComponent = 22; - var LegacyHiddenComponent = 23; - var CacheComponent = 24; - var TracingMarkerComponent = 25; - var HostHoistable = 26; - var HostSingleton = 27; - var IncompleteFunctionComponent = 28; - - function getWrappedName(outerType, innerType, wrapperName) { - var functionName = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - (functionName !== "" - ? wrapperName + "(" + functionName + ")" - : wrapperName) - ); - } // Keep in sync with shared/getComponentNameFromType - - function getContextName(type) { - return type.displayName || "Context"; - } - function getComponentNameFromFiber(fiber) { - var tag = fiber.tag, - type = fiber.type; - - switch (tag) { - case CacheComponent: - return "Cache"; - - case ContextConsumer: - if (enableRenderableContext) { - var consumer = type; - return getContextName(consumer._context) + ".Consumer"; - } else { - var context = type; - return getContextName(context) + ".Consumer"; - } - - case ContextProvider: - if (enableRenderableContext) { - var _context = type; - return getContextName(_context) + ".Provider"; - } else { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } - - case DehydratedFragment: - return "DehydratedFragment"; - - case ForwardRef: - return getWrappedName(type, type.render, "ForwardRef"); - - case Fragment: - return "Fragment"; - - case HostHoistable: - case HostSingleton: - case HostComponent: - // Host component type is the display name (e.g. "div", "View") - return type; - - case HostPortal: - return "Portal"; - - case HostRoot: - return "Root"; - - case HostText: - return "Text"; - - case LazyComponent: - // Name comes from the type in this case; we don't have a tag. - return getComponentNameFromType(type); - - case Mode: - if (type === REACT_STRICT_MODE_TYPE) { - // Don't be less specific than shared/getComponentNameFromType - return "StrictMode"; - } - - return "Mode"; - - case OffscreenComponent: - return "Offscreen"; - - case Profiler: - return "Profiler"; - - case ScopeComponent: - return "Scope"; - - case SuspenseComponent: - return "Suspense"; - - case SuspenseListComponent: - return "SuspenseList"; - - case TracingMarkerComponent: - return "TracingMarker"; - // The display name for these tags come from the user-provided type: - - case IncompleteClassComponent: - case IncompleteFunctionComponent: { - break; - } - - // Fallthrough - - case ClassComponent: - case FunctionComponent: - case MemoComponent: - case SimpleMemoComponent: - if (typeof type === "function") { - return type.displayName || type.name || null; - } - - if (typeof type === "string") { - return type; - } - - break; - - case LegacyHiddenComponent: { - return "LegacyHidden"; - } - } - - return null; - } - + var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); var specialPropKeyWarningShown; var specialPropRefWarningShown; var didWarnAboutStringRefs; var didWarnAboutElementRef; - var didWarnAboutOldJSXRuntime; { didWarnAboutStringRefs = {}; @@ -1333,12 +1219,12 @@ if (__DEV__) { { if ( typeof config.ref === "string" && - ReactSharedInternals.owner && + ReactCurrentOwner.current && self && - ReactSharedInternals.owner.stateNode !== self + ReactCurrentOwner.current.stateNode !== self ) { var componentName = getComponentNameFromType( - ReactSharedInternals.owner.type + ReactCurrentOwner.current.type ); if (!didWarnAboutStringRefs[componentName]) { @@ -1349,7 +1235,7 @@ if (__DEV__) { "We ask you to manually fix this case by using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + "https://react.dev/link/strict-mode-string-ref", - getComponentNameFromType(ReactSharedInternals.owner.type), + getComponentNameFromType(ReactCurrentOwner.current.type), config.ref ); @@ -1709,6 +1595,9 @@ if (__DEV__) { } } + var propName; // Reserved names are extracted + + var props = {}; var key = null; var ref = null; // Currently, key can be spread in as a prop. This causes a potential // issue if key is also explicitly declared (ie.
@@ -1736,49 +1625,20 @@ if (__DEV__) { if (hasValidRef(config)) { if (!enableRefAsProp) { ref = config.ref; - - { - ref = coerceStringRef(ref, ReactSharedInternals.owner, type); - } } { warnIfStringRefCannotBeAutoConverted(config, self); } - } + } // Remaining properties are added to a new props object - var props; - - if (enableRefAsProp && disableStringRefs && !("key" in config)) { - // If key was not spread in, we can reuse the original props object. This - // only works for `jsx`, not `createElement`, because `jsx` is a compiler - // target and the compiler always passes a new object. For `createElement`, - // we can't assume a new object is passed every time because it can be - // called manually. - // - // Spreading key is a warning in dev. In a future release, we will not - // remove a spread key from the props object. (But we'll still warn.) We'll - // always pass the object straight through. - props = config; - } else { - // We need to remove reserved props (key, prop, ref). Create a fresh props - // object and copy over all the non-reserved props. We don't use `delete` - // because in V8 it will deopt the object to dictionary mode. - props = {}; - - for (var propName in config) { - // Skip over reserved prop names - if (propName !== "key" && (enableRefAsProp || propName !== "ref")) { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - ); - } else { - props[propName] = config[propName]; - } - } + for (propName in config) { + if ( + hasOwnProperty.call(config, propName) && // Skip over reserved prop names + propName !== "key" && + (enableRefAsProp || propName !== "ref") + ) { + props[propName] = config[propName]; } } @@ -1787,9 +1647,9 @@ if (__DEV__) { if (type && type.defaultProps) { var defaultProps = type.defaultProps; - for (var _propName2 in defaultProps) { - if (props[_propName2] === undefined) { - props[_propName2] = defaultProps[_propName2]; + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; } } } @@ -1816,7 +1676,7 @@ if (__DEV__) { ref, self, source, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); @@ -1897,34 +1757,9 @@ if (__DEV__) { var ref = null; if (config != null) { - { - if ( - !didWarnAboutOldJSXRuntime && - "__self" in config && // Do not assume this is the result of an oudated JSX transform if key - // is present, because the modern JSX transform sometimes outputs - // createElement to preserve precedence between a static key and a - // spread key. To avoid false positive warnings, we never warn if - // there's a key. - !("key" in config) - ) { - didWarnAboutOldJSXRuntime = true; - - warn( - "Your app (or one of its dependencies) is using an outdated JSX " + - "transform. Update to the modern JSX transform for " + - "faster performance: " + // TODO: Create a short link for this - "https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html" - ); - } - } - if (hasValidRef(config)) { if (!enableRefAsProp) { ref = config.ref; - - { - ref = coerceStringRef(ref, ReactSharedInternals.owner, type); - } } { @@ -1951,15 +1786,7 @@ if (__DEV__) { propName !== "__self" && propName !== "__source" ) { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - ); - } else { - props[propName] = config[propName]; - } + props[propName] = config[propName]; } } } // Children can be more than one argument, and those are transferred onto @@ -2018,7 +1845,7 @@ if (__DEV__) { ref, undefined, undefined, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); @@ -2065,16 +1892,12 @@ if (__DEV__) { if (config != null) { if (hasValidRef(config)) { - owner = ReactSharedInternals.owner; - if (!enableRefAsProp) { // Silently steal the ref from the parent. ref = config.ref; - - { - ref = coerceStringRef(ref, owner, element.type); - } } + + owner = ReactCurrentOwner.current; } if (hasValidKey(config)) { @@ -2119,15 +1942,7 @@ if (__DEV__) { // Resolve default props props[propName] = defaultProps[propName]; } else { - if (enableRefAsProp && !disableStringRefs && propName === "ref") { - props.ref = coerceStringRef( - config[propName], - owner, - element.type - ); - } else { - props[propName] = config[propName]; - } + props[propName] = config[propName]; } } } @@ -2167,8 +1982,8 @@ if (__DEV__) { function getDeclarationErrorAddendum() { { - if (ReactSharedInternals.owner) { - var name = getComponentNameFromType(ReactSharedInternals.owner.type); + if (ReactCurrentOwner.current) { + var name = getComponentNameFromType(ReactCurrentOwner.current.type); if (name) { return "\n\nCheck the render method of `" + name + "`."; @@ -2282,18 +2097,14 @@ if (__DEV__) { if ( element && - element._owner != null && - element._owner !== ReactSharedInternals.owner + element._owner && + element._owner !== ReactCurrentOwner.current ) { - var ownerName = null; - - if (typeof element._owner.tag === "number") { - ownerName = getComponentNameFromType(element._owner.type); - } else if (typeof element._owner.name === "string") { - ownerName = element._owner.name; - } // Give the component that originally created this child. - - childOwner = " It was passed a child from " + ownerName + "."; + // Give the component that originally created this child. + childOwner = + " It was passed a child from " + + getComponentNameFromType(element._owner.type) + + "."; } setCurrentlyValidatingElement(element); @@ -2312,10 +2123,14 @@ if (__DEV__) { function setCurrentlyValidatingElement(element) { { if (element) { - var stack = describeUnknownElementTypeFrameInDEV(element.type); - ReactSharedInternals.setExtraStackFrame(stack); + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV( + element.type, + owner ? owner.type : null + ); + ReactDebugCurrentFrame.setExtraStackFrame(stack); } else { - ReactSharedInternals.setExtraStackFrame(null); + ReactDebugCurrentFrame.setExtraStackFrame(null); } } } @@ -2373,96 +2188,6 @@ if (__DEV__) { } } - function coerceStringRef(mixedRef, owner, type) { - var stringRef; - - if (typeof mixedRef === "string") { - stringRef = mixedRef; - } else { - if (typeof mixedRef === "number" || typeof mixedRef === "boolean") { - { - checkPropStringCoercion(mixedRef, "ref"); - } - - stringRef = "" + mixedRef; - } else { - return mixedRef; - } - } - - return stringRefAsCallbackRef.bind(null, stringRef, type, owner); - } - - function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) { - throw new Error( - "Element ref was specified as a string (" + - stringRef + - ") but no owner was set. This could happen for one of" + - " the following reasons:\n" + - "1. You may be adding a ref to a function component\n" + - "2. You may be adding a ref to a component that was not created inside a component's render method\n" + - "3. You have multiple copies of React loaded\n" + - "See https://react.dev/link/refs-must-have-owner for more information." - ); - } - - if (owner.tag !== ClassComponent) { - throw new Error( - "Function components cannot have string refs. " + - "We recommend using useRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref" - ); - } - - { - if ( - // Will already warn with "Function components cannot be given refs" - !(typeof type === "function" && !isReactClass(type)) - ) { - var componentName = getComponentNameFromFiber(owner) || "Component"; - - if (!didWarnAboutStringRefs[componentName]) { - error( - 'Component "%s" contains the string ref "%s". Support for string refs ' + - "will be removed in a future major release. We recommend using " + - "useRef() or createRef() instead. " + - "Learn more about using refs safely here: " + - "https://react.dev/link/strict-mode-string-ref", - componentName, - stringRef - ); - - didWarnAboutStringRefs[componentName] = true; - } - } - } - - var inst = owner.stateNode; - - if (!inst) { - throw new Error( - "Missing owner for string ref " + - stringRef + - ". This error is likely caused by a " + - "bug in React. Please file an issue." - ); - } - - var refs = inst.refs; - - if (value === null) { - delete refs[stringRef]; - } else { - refs[stringRef] = value; - } - } - - function isReactClass(type) { - return type.prototype && type.prototype.isReactComponent; - } - var SEPARATOR = "."; var SUBSEPARATOR = ":"; /** @@ -3217,7 +2942,7 @@ if (__DEV__) { var cache = noopCache; function resolveDispatcher() { - var dispatcher = ReactSharedInternals.H; + var dispatcher = ReactCurrentDispatcher$1.current; { if (dispatcher === null) { @@ -3238,7 +2963,7 @@ if (__DEV__) { } function getCacheForType(resourceType) { - var dispatcher = ReactSharedInternals.C; + var dispatcher = ReactCurrentCache.current; if (!dispatcher) { // If there is no dispatcher, then we treat this as not being cached. @@ -3395,26 +3120,26 @@ if (__DEV__) { }; function startTransition(scope, options) { - var prevTransition = ReactSharedInternals.T; // Each renderer registers a callback to receive the return value of + var prevTransition = ReactCurrentBatchConfig.transition; // Each renderer registers a callback to receive the return value of // the scope function. This is used to implement async actions. var callbacks = new Set(); var transition = { _callbacks: callbacks }; - ReactSharedInternals.T = transition; - var currentTransition = ReactSharedInternals.T; + ReactCurrentBatchConfig.transition = transition; + var currentTransition = ReactCurrentBatchConfig.transition; { - ReactSharedInternals.T._updatedFibers = new Set(); + ReactCurrentBatchConfig.transition._updatedFibers = new Set(); } if (enableTransitionTracing) { if (options !== undefined && options.name !== undefined) { // $FlowFixMe[incompatible-use] found when upgrading Flow - ReactSharedInternals.T.name = options.name; // $FlowFixMe[incompatible-use] found when upgrading Flow + ReactCurrentBatchConfig.transition.name = options.name; // $FlowFixMe[incompatible-use] found when upgrading Flow - ReactSharedInternals.T.startTime = -1; + ReactCurrentBatchConfig.transition.startTime = -1; } } @@ -3436,7 +3161,7 @@ if (__DEV__) { reportGlobalError(error); } finally { warnAboutTransitionSubscriptions(prevTransition, currentTransition); - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; } } } @@ -3523,7 +3248,7 @@ if (__DEV__) { function act(callback) { { - // When ReactSharedInternals.actQueue is not null, it signals to React that + // When ReactCurrentActQueue.current is not null, it signals to React that // we're currently inside an `act` scope. React will push all its tasks to // this queue instead of scheduling them with platform APIs. // @@ -3533,10 +3258,10 @@ if (__DEV__) { // // If we're already inside an `act` scope, reuse the existing queue. var prevIsBatchingLegacy = false; - var prevActQueue = ReactSharedInternals.actQueue; + var prevActQueue = ReactCurrentActQueue.current; var prevActScopeDepth = actScopeDepth; actScopeDepth++; - var queue = (ReactSharedInternals.actQueue = + var queue = (ReactCurrentActQueue.current = prevActQueue !== null ? prevActQueue : []); // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only var result; // This tracks whether the `act` call is awaited. In certain cases, not @@ -3552,7 +3277,7 @@ if (__DEV__) { result = callback(); var didScheduleLegacyUpdate = !disableLegacyMode - ? ReactSharedInternals.didScheduleLegacyUpdate + ? ReactCurrentActQueue.didScheduleLegacyUpdate : false; // Replicate behavior of original `act` implementation in legacy mode, // which flushed updates immediately after the scope function exits, even // if it's an async function. @@ -3570,13 +3295,13 @@ if (__DEV__) { // one used to track `act` scopes. Why, you may be wondering? Because // that's how it worked before version 18. Yes, it's confusing! We should // delete legacy mode!! - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue.thrownErrors.push(error); } - if (ReactSharedInternals.thrownErrors.length > 0) { + if (ReactCurrentActQueue.thrownErrors.length > 0) { popActScope(prevActQueue, prevActScopeDepth); - var thrownError = aggregateErrors(ReactSharedInternals.thrownErrors); - ReactSharedInternals.thrownErrors.length = 0; + var thrownError = aggregateErrors(ReactCurrentActQueue.thrownErrors); + ReactCurrentActQueue.thrownErrors.length = 0; throw thrownError; } @@ -3632,15 +3357,15 @@ if (__DEV__) { // `thenable` might not be a real promise, and `flushActQueue` // might throw, so we need to wrap `flushActQueue` in a // try/catch. - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue.thrownErrors.push(error); } - if (ReactSharedInternals.thrownErrors.length > 0) { + if (ReactCurrentActQueue.thrownErrors.length > 0) { var _thrownError = aggregateErrors( - ReactSharedInternals.thrownErrors + ReactCurrentActQueue.thrownErrors ); - ReactSharedInternals.thrownErrors.length = 0; + ReactCurrentActQueue.thrownErrors.length = 0; reject(_thrownError); } } else { @@ -3650,12 +3375,12 @@ if (__DEV__) { function (error) { popActScope(prevActQueue, prevActScopeDepth); - if (ReactSharedInternals.thrownErrors.length > 0) { + if (ReactCurrentActQueue.thrownErrors.length > 0) { var _thrownError2 = aggregateErrors( - ReactSharedInternals.thrownErrors + ReactCurrentActQueue.thrownErrors ); - ReactSharedInternals.thrownErrors.length = 0; + ReactCurrentActQueue.thrownErrors.length = 0; reject(_thrownError2); } else { reject(error); @@ -3709,15 +3434,15 @@ if (__DEV__) { // TODO: In a future version, consider always requiring all `act` calls // to be awaited, regardless of whether the callback is sync or async. - ReactSharedInternals.actQueue = null; + ReactCurrentActQueue.current = null; } - if (ReactSharedInternals.thrownErrors.length > 0) { + if (ReactCurrentActQueue.thrownErrors.length > 0) { var _thrownError3 = aggregateErrors( - ReactSharedInternals.thrownErrors + ReactCurrentActQueue.thrownErrors ); - ReactSharedInternals.thrownErrors.length = 0; + ReactCurrentActQueue.thrownErrors.length = 0; throw _thrownError3; } @@ -3728,7 +3453,7 @@ if (__DEV__) { if (prevActScopeDepth === 0) { // If the `act` call is awaited, restore the queue we were // using before (see long comment above) so we can flush it. - ReactSharedInternals.actQueue = queue; + ReactCurrentActQueue.current = queue; enqueueTask(function () { return ( // Recursively flush tasks scheduled by a microtask. @@ -3760,7 +3485,7 @@ if (__DEV__) { function recursivelyFlushAsyncActWork(returnValue, resolve, reject) { { // Check if any tasks were scheduled asynchronously. - var queue = ReactSharedInternals.actQueue; + var queue = ReactCurrentActQueue.current; if (queue !== null) { if (queue.length !== 0) { @@ -3780,17 +3505,17 @@ if (__DEV__) { return; } catch (error) { // Leave remaining tasks on the queue if something throws. - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue.thrownErrors.push(error); } } else { // The queue is empty. We can finish. - ReactSharedInternals.actQueue = null; + ReactCurrentActQueue.current = null; } } - if (ReactSharedInternals.thrownErrors.length > 0) { - var thrownError = aggregateErrors(ReactSharedInternals.thrownErrors); - ReactSharedInternals.thrownErrors.length = 0; + if (ReactCurrentActQueue.thrownErrors.length > 0) { + var thrownError = aggregateErrors(ReactCurrentActQueue.thrownErrors); + ReactCurrentActQueue.thrownErrors.length = 0; reject(thrownError); } else { resolve(returnValue); @@ -3812,11 +3537,11 @@ if (__DEV__) { var callback = queue[i]; do { - ReactSharedInternals.didUsePromise = false; + ReactCurrentActQueue.didUsePromise = false; var continuation = callback(false); if (continuation !== null) { - if (ReactSharedInternals.didUsePromise) { + if (ReactCurrentActQueue.didUsePromise) { // The component just suspended. Yield to the main thread in // case the promise is already resolved. If so, it will ping in // a microtask and we can resume without unwinding the stack. @@ -3836,7 +3561,7 @@ if (__DEV__) { } catch (error) { // If something throws, leave the remaining callbacks on the queue. queue.splice(0, i + 1); - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue.thrownErrors.push(error); } finally { isFlushing = false; } @@ -3883,7 +3608,7 @@ if (__DEV__) { exports.PureComponent = PureComponent; exports.StrictMode = REACT_STRICT_MODE_TYPE; exports.Suspense = REACT_SUSPENSE_TYPE; - exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = + exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; exports.act = act; exports.cache = cache; diff --git a/compiled/facebook-www/React-prod.classic.js b/compiled/facebook-www/React-prod.classic.js index 23523c5e94..1321fa9560 100644 --- a/compiled/facebook-www/React-prod.classic.js +++ b/compiled/facebook-www/React-prod.classic.js @@ -87,8 +87,17 @@ var isArrayImpl = Array.isArray, enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses, - ReactSharedInternals = { H: null, C: null, T: null, owner: null }, - hasOwnProperty = Object.prototype.hasOwnProperty; + ReactCurrentDispatcher = { current: null }, + ReactCurrentCache = { current: null }, + ReactCurrentBatchConfig = { transition: null }, + ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentCache: ReactCurrentCache, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: { current: null } + }, + hasOwnProperty = Object.prototype.hasOwnProperty, + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function ReactElement(type, key, _ref, self, source, owner, props) { enableRefAsProp && ((_ref = props.ref), (_ref = void 0 !== _ref ? _ref : null)); @@ -102,39 +111,29 @@ function ReactElement(type, key, _ref, self, source, owner, props) { }; } function jsxProd(type, config, maybeKey) { - var key = null, + var propName, + props = {}, + key = null, ref = null; void 0 !== maybeKey && (key = "" + maybeKey); void 0 !== config.key && (key = "" + config.key); - void 0 === config.ref || - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))); - maybeKey = {}; - for (var propName in config) - "key" === propName || - (!enableRefAsProp && "ref" === propName) || - (enableRefAsProp && "ref" === propName - ? (maybeKey.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (maybeKey[propName] = config[propName])); - if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) { - config = type.defaultProps; - for (var propName$0 in config) - void 0 === maybeKey[propName$0] && - (maybeKey[propName$0] = config[propName$0]); - } + void 0 === config.ref || enableRefAsProp || (ref = config.ref); + for (propName in config) + hasOwnProperty.call(config, propName) && + "key" !== propName && + (enableRefAsProp || "ref" !== propName) && + (props[propName] = config[propName]); + if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) + for (propName in ((config = type.defaultProps), config)) + void 0 === props[propName] && (props[propName] = config[propName]); return ReactElement( type, key, ref, void 0, void 0, - ReactSharedInternals.owner, - maybeKey + ReactCurrentOwner.current, + props ); } function cloneAndReplaceKey(oldElement, newKey) { @@ -155,34 +154,6 @@ function isValidElement(object) { object.$$typeof === REACT_ELEMENT_TYPE ); } -function coerceStringRef(mixedRef, owner, type) { - if ("string" !== typeof mixedRef) - if ("number" === typeof mixedRef || "boolean" === typeof mixedRef) - mixedRef = "" + mixedRef; - else return mixedRef; - return stringRefAsCallbackRef.bind(null, mixedRef, type, owner); -} -function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) - throw Error( - "Element ref was specified as a string (" + - stringRef + - ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://react.dev/link/refs-must-have-owner for more information." - ); - if (1 !== owner.tag) - throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref" - ); - type = owner.stateNode; - if (!type) - throw Error( - "Missing owner for string ref " + - stringRef + - ". This error is likely caused by a bug in React. Please file an issue." - ); - type = type.refs; - null === value ? delete type[stringRef] : (type[stringRef] = value); -} function escape(key) { var escaperLookup = { "=": "=0", ":": "=2" }; return ( @@ -436,7 +407,7 @@ exports.Profiler = REACT_PROFILER_TYPE; exports.PureComponent = PureComponent; exports.StrictMode = REACT_STRICT_MODE_TYPE; exports.Suspense = REACT_SUSPENSE_TYPE; -exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = +exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; exports.act = function () { throw Error("act(...) is not supported in production builds of React."); @@ -457,10 +428,8 @@ exports.cloneElement = function (element, config, children) { owner = element._owner; if (null != config) { void 0 !== config.ref && - ((owner = ReactSharedInternals.owner), - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, owner, element.type)))); + (enableRefAsProp || (ref = config.ref), + (owner = ReactCurrentOwner.current)); void 0 !== config.key && (key = "" + config.key); if ( !disableDefaultPropsExceptForClasses && @@ -475,17 +444,12 @@ exports.cloneElement = function (element, config, children) { "__self" === propName || "__source" === propName || (enableRefAsProp && "ref" === propName && void 0 === config.ref) || - (disableDefaultPropsExceptForClasses || - void 0 !== config[propName] || - void 0 === defaultProps - ? enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - owner, - element.type - )) - : (props[propName] = config[propName]) - : (props[propName] = defaultProps[propName])); + (props[propName] = + disableDefaultPropsExceptForClasses || + void 0 !== config[propName] || + void 0 === defaultProps + ? config[propName] + : defaultProps[propName]); } var propName = arguments.length - 2; if (1 === propName) props.children = children; @@ -526,8 +490,7 @@ exports.createElement = function (type, config, children) { if (null != config) for (propName in (void 0 === config.ref || enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))), + (ref = config.ref), void 0 !== config.key && (key = "" + config.key), config)) hasOwnProperty.call(config, propName) && @@ -535,13 +498,7 @@ exports.createElement = function (type, config, children) { (enableRefAsProp || "ref" !== propName) && "__self" !== propName && "__source" !== propName && - (enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (props[propName] = config[propName])); + (props[propName] = config[propName]); var childrenLength = arguments.length - 2; if (1 === childrenLength) props.children = children; else if (1 < childrenLength) { @@ -559,7 +516,7 @@ exports.createElement = function (type, config, children) { ref, void 0, void 0, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); }; @@ -567,7 +524,7 @@ exports.createRef = function () { return { current: null }; }; exports.experimental_useEffectEvent = function (callback) { - return ReactSharedInternals.H.useEffectEvent(callback); + return ReactCurrentDispatcher.current.useEffectEvent(callback); }; exports.forwardRef = function (render) { return { $$typeof: REACT_FORWARD_REF_TYPE, render: render }; @@ -591,15 +548,15 @@ exports.memo = function (type, compare) { }; }; exports.startTransition = function (scope, options) { - var prevTransition = ReactSharedInternals.T, + var prevTransition = ReactCurrentBatchConfig.transition, callbacks = new Set(); - ReactSharedInternals.T = { _callbacks: callbacks }; - var currentTransition = ReactSharedInternals.T; + ReactCurrentBatchConfig.transition = { _callbacks: callbacks }; + var currentTransition = ReactCurrentBatchConfig.transition; enableTransitionTracing && void 0 !== options && void 0 !== options.name && - ((ReactSharedInternals.T.name = options.name), - (ReactSharedInternals.T.startTime = -1)); + ((ReactCurrentBatchConfig.transition.name = options.name), + (ReactCurrentBatchConfig.transition.startTime = -1)); try { var returnValue = scope(); "object" === typeof returnValue && @@ -612,7 +569,7 @@ exports.startTransition = function (scope, options) { } catch (error) { reportGlobalError(error); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; } }; exports.unstable_Activity = REACT_OFFSCREEN_TYPE; @@ -622,73 +579,77 @@ exports.unstable_Scope = REACT_SCOPE_TYPE; exports.unstable_SuspenseList = REACT_SUSPENSE_LIST_TYPE; exports.unstable_TracingMarker = REACT_TRACING_MARKER_TYPE; exports.unstable_getCacheForType = function (resourceType) { - var dispatcher = ReactSharedInternals.C; + var dispatcher = ReactCurrentCache.current; return dispatcher ? dispatcher.getCacheForType(resourceType) : resourceType(); }; exports.unstable_useCacheRefresh = function () { - return ReactSharedInternals.H.useCacheRefresh(); + return ReactCurrentDispatcher.current.useCacheRefresh(); }; exports.unstable_useMemoCache = function (size) { - return ReactSharedInternals.H.useMemoCache(size); + return ReactCurrentDispatcher.current.useMemoCache(size); }; exports.use = function (usable) { - return ReactSharedInternals.H.use(usable); + return ReactCurrentDispatcher.current.use(usable); }; exports.useActionState = function (action, initialState, permalink) { - return ReactSharedInternals.H.useActionState(action, initialState, permalink); + return ReactCurrentDispatcher.current.useActionState( + action, + initialState, + permalink + ); }; exports.useCallback = function (callback, deps) { - return ReactSharedInternals.H.useCallback(callback, deps); + return ReactCurrentDispatcher.current.useCallback(callback, deps); }; exports.useContext = function (Context) { - return ReactSharedInternals.H.useContext(Context); + return ReactCurrentDispatcher.current.useContext(Context); }; exports.useDebugValue = function () {}; exports.useDeferredValue = function (value, initialValue) { - return ReactSharedInternals.H.useDeferredValue(value, initialValue); + return ReactCurrentDispatcher.current.useDeferredValue(value, initialValue); }; exports.useEffect = function (create, deps) { - return ReactSharedInternals.H.useEffect(create, deps); + return ReactCurrentDispatcher.current.useEffect(create, deps); }; exports.useId = function () { - return ReactSharedInternals.H.useId(); + return ReactCurrentDispatcher.current.useId(); }; exports.useImperativeHandle = function (ref, create, deps) { - return ReactSharedInternals.H.useImperativeHandle(ref, create, deps); + return ReactCurrentDispatcher.current.useImperativeHandle(ref, create, deps); }; exports.useInsertionEffect = function (create, deps) { - return ReactSharedInternals.H.useInsertionEffect(create, deps); + return ReactCurrentDispatcher.current.useInsertionEffect(create, deps); }; exports.useLayoutEffect = function (create, deps) { - return ReactSharedInternals.H.useLayoutEffect(create, deps); + return ReactCurrentDispatcher.current.useLayoutEffect(create, deps); }; exports.useMemo = function (create, deps) { - return ReactSharedInternals.H.useMemo(create, deps); + return ReactCurrentDispatcher.current.useMemo(create, deps); }; exports.useOptimistic = function (passthrough, reducer) { - return ReactSharedInternals.H.useOptimistic(passthrough, reducer); + return ReactCurrentDispatcher.current.useOptimistic(passthrough, reducer); }; exports.useReducer = function (reducer, initialArg, init) { - return ReactSharedInternals.H.useReducer(reducer, initialArg, init); + return ReactCurrentDispatcher.current.useReducer(reducer, initialArg, init); }; exports.useRef = function (initialValue) { - return ReactSharedInternals.H.useRef(initialValue); + return ReactCurrentDispatcher.current.useRef(initialValue); }; exports.useState = function (initialState) { - return ReactSharedInternals.H.useState(initialState); + return ReactCurrentDispatcher.current.useState(initialState); }; exports.useSyncExternalStore = function ( subscribe, getSnapshot, getServerSnapshot ) { - return ReactSharedInternals.H.useSyncExternalStore( + return ReactCurrentDispatcher.current.useSyncExternalStore( subscribe, getSnapshot, getServerSnapshot ); }; exports.useTransition = function () { - return ReactSharedInternals.H.useTransition(); + return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "19.0.0-www-classic-0eabe82a"; +exports.version = "19.0.0-www-classic-6f7d270a"; diff --git a/compiled/facebook-www/React-prod.modern.js b/compiled/facebook-www/React-prod.modern.js index 7f794b1382..992e6e6900 100644 --- a/compiled/facebook-www/React-prod.modern.js +++ b/compiled/facebook-www/React-prod.modern.js @@ -87,8 +87,17 @@ var isArrayImpl = Array.isArray, enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses, - ReactSharedInternals = { H: null, C: null, T: null, owner: null }, - hasOwnProperty = Object.prototype.hasOwnProperty; + ReactCurrentDispatcher = { current: null }, + ReactCurrentCache = { current: null }, + ReactCurrentBatchConfig = { transition: null }, + ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentCache: ReactCurrentCache, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: { current: null } + }, + hasOwnProperty = Object.prototype.hasOwnProperty, + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function ReactElement(type, key, _ref, self, source, owner, props) { enableRefAsProp && ((_ref = props.ref), (_ref = void 0 !== _ref ? _ref : null)); @@ -102,39 +111,29 @@ function ReactElement(type, key, _ref, self, source, owner, props) { }; } function jsxProd(type, config, maybeKey) { - var key = null, + var propName, + props = {}, + key = null, ref = null; void 0 !== maybeKey && (key = "" + maybeKey); void 0 !== config.key && (key = "" + config.key); - void 0 === config.ref || - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))); - maybeKey = {}; - for (var propName in config) - "key" === propName || - (!enableRefAsProp && "ref" === propName) || - (enableRefAsProp && "ref" === propName - ? (maybeKey.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (maybeKey[propName] = config[propName])); - if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) { - config = type.defaultProps; - for (var propName$0 in config) - void 0 === maybeKey[propName$0] && - (maybeKey[propName$0] = config[propName$0]); - } + void 0 === config.ref || enableRefAsProp || (ref = config.ref); + for (propName in config) + hasOwnProperty.call(config, propName) && + "key" !== propName && + (enableRefAsProp || "ref" !== propName) && + (props[propName] = config[propName]); + if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) + for (propName in ((config = type.defaultProps), config)) + void 0 === props[propName] && (props[propName] = config[propName]); return ReactElement( type, key, ref, void 0, void 0, - ReactSharedInternals.owner, - maybeKey + ReactCurrentOwner.current, + props ); } function cloneAndReplaceKey(oldElement, newKey) { @@ -155,34 +154,6 @@ function isValidElement(object) { object.$$typeof === REACT_ELEMENT_TYPE ); } -function coerceStringRef(mixedRef, owner, type) { - if ("string" !== typeof mixedRef) - if ("number" === typeof mixedRef || "boolean" === typeof mixedRef) - mixedRef = "" + mixedRef; - else return mixedRef; - return stringRefAsCallbackRef.bind(null, mixedRef, type, owner); -} -function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) - throw Error( - "Element ref was specified as a string (" + - stringRef + - ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://react.dev/link/refs-must-have-owner for more information." - ); - if (1 !== owner.tag) - throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref" - ); - type = owner.stateNode; - if (!type) - throw Error( - "Missing owner for string ref " + - stringRef + - ". This error is likely caused by a bug in React. Please file an issue." - ); - type = type.refs; - null === value ? delete type[stringRef] : (type[stringRef] = value); -} function escape(key) { var escaperLookup = { "=": "=0", ":": "=2" }; return ( @@ -436,7 +407,7 @@ exports.Profiler = REACT_PROFILER_TYPE; exports.PureComponent = PureComponent; exports.StrictMode = REACT_STRICT_MODE_TYPE; exports.Suspense = REACT_SUSPENSE_TYPE; -exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = +exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; exports.act = function () { throw Error("act(...) is not supported in production builds of React."); @@ -457,10 +428,8 @@ exports.cloneElement = function (element, config, children) { owner = element._owner; if (null != config) { void 0 !== config.ref && - ((owner = ReactSharedInternals.owner), - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, owner, element.type)))); + (enableRefAsProp || (ref = config.ref), + (owner = ReactCurrentOwner.current)); void 0 !== config.key && (key = "" + config.key); if ( !disableDefaultPropsExceptForClasses && @@ -475,17 +444,12 @@ exports.cloneElement = function (element, config, children) { "__self" === propName || "__source" === propName || (enableRefAsProp && "ref" === propName && void 0 === config.ref) || - (disableDefaultPropsExceptForClasses || - void 0 !== config[propName] || - void 0 === defaultProps - ? enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - owner, - element.type - )) - : (props[propName] = config[propName]) - : (props[propName] = defaultProps[propName])); + (props[propName] = + disableDefaultPropsExceptForClasses || + void 0 !== config[propName] || + void 0 === defaultProps + ? config[propName] + : defaultProps[propName]); } var propName = arguments.length - 2; if (1 === propName) props.children = children; @@ -526,8 +490,7 @@ exports.createElement = function (type, config, children) { if (null != config) for (propName in (void 0 === config.ref || enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))), + (ref = config.ref), void 0 !== config.key && (key = "" + config.key), config)) hasOwnProperty.call(config, propName) && @@ -535,13 +498,7 @@ exports.createElement = function (type, config, children) { (enableRefAsProp || "ref" !== propName) && "__self" !== propName && "__source" !== propName && - (enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (props[propName] = config[propName])); + (props[propName] = config[propName]); var childrenLength = arguments.length - 2; if (1 === childrenLength) props.children = children; else if (1 < childrenLength) { @@ -559,7 +516,7 @@ exports.createElement = function (type, config, children) { ref, void 0, void 0, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); }; @@ -567,7 +524,7 @@ exports.createRef = function () { return { current: null }; }; exports.experimental_useEffectEvent = function (callback) { - return ReactSharedInternals.H.useEffectEvent(callback); + return ReactCurrentDispatcher.current.useEffectEvent(callback); }; exports.forwardRef = function (render) { return { $$typeof: REACT_FORWARD_REF_TYPE, render: render }; @@ -591,15 +548,15 @@ exports.memo = function (type, compare) { }; }; exports.startTransition = function (scope, options) { - var prevTransition = ReactSharedInternals.T, + var prevTransition = ReactCurrentBatchConfig.transition, callbacks = new Set(); - ReactSharedInternals.T = { _callbacks: callbacks }; - var currentTransition = ReactSharedInternals.T; + ReactCurrentBatchConfig.transition = { _callbacks: callbacks }; + var currentTransition = ReactCurrentBatchConfig.transition; enableTransitionTracing && void 0 !== options && void 0 !== options.name && - ((ReactSharedInternals.T.name = options.name), - (ReactSharedInternals.T.startTime = -1)); + ((ReactCurrentBatchConfig.transition.name = options.name), + (ReactCurrentBatchConfig.transition.startTime = -1)); try { var returnValue = scope(); "object" === typeof returnValue && @@ -612,7 +569,7 @@ exports.startTransition = function (scope, options) { } catch (error) { reportGlobalError(error); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; } }; exports.unstable_Activity = REACT_OFFSCREEN_TYPE; @@ -622,73 +579,77 @@ exports.unstable_Scope = REACT_SCOPE_TYPE; exports.unstable_SuspenseList = REACT_SUSPENSE_LIST_TYPE; exports.unstable_TracingMarker = REACT_TRACING_MARKER_TYPE; exports.unstable_getCacheForType = function (resourceType) { - var dispatcher = ReactSharedInternals.C; + var dispatcher = ReactCurrentCache.current; return dispatcher ? dispatcher.getCacheForType(resourceType) : resourceType(); }; exports.unstable_useCacheRefresh = function () { - return ReactSharedInternals.H.useCacheRefresh(); + return ReactCurrentDispatcher.current.useCacheRefresh(); }; exports.unstable_useMemoCache = function (size) { - return ReactSharedInternals.H.useMemoCache(size); + return ReactCurrentDispatcher.current.useMemoCache(size); }; exports.use = function (usable) { - return ReactSharedInternals.H.use(usable); + return ReactCurrentDispatcher.current.use(usable); }; exports.useActionState = function (action, initialState, permalink) { - return ReactSharedInternals.H.useActionState(action, initialState, permalink); + return ReactCurrentDispatcher.current.useActionState( + action, + initialState, + permalink + ); }; exports.useCallback = function (callback, deps) { - return ReactSharedInternals.H.useCallback(callback, deps); + return ReactCurrentDispatcher.current.useCallback(callback, deps); }; exports.useContext = function (Context) { - return ReactSharedInternals.H.useContext(Context); + return ReactCurrentDispatcher.current.useContext(Context); }; exports.useDebugValue = function () {}; exports.useDeferredValue = function (value, initialValue) { - return ReactSharedInternals.H.useDeferredValue(value, initialValue); + return ReactCurrentDispatcher.current.useDeferredValue(value, initialValue); }; exports.useEffect = function (create, deps) { - return ReactSharedInternals.H.useEffect(create, deps); + return ReactCurrentDispatcher.current.useEffect(create, deps); }; exports.useId = function () { - return ReactSharedInternals.H.useId(); + return ReactCurrentDispatcher.current.useId(); }; exports.useImperativeHandle = function (ref, create, deps) { - return ReactSharedInternals.H.useImperativeHandle(ref, create, deps); + return ReactCurrentDispatcher.current.useImperativeHandle(ref, create, deps); }; exports.useInsertionEffect = function (create, deps) { - return ReactSharedInternals.H.useInsertionEffect(create, deps); + return ReactCurrentDispatcher.current.useInsertionEffect(create, deps); }; exports.useLayoutEffect = function (create, deps) { - return ReactSharedInternals.H.useLayoutEffect(create, deps); + return ReactCurrentDispatcher.current.useLayoutEffect(create, deps); }; exports.useMemo = function (create, deps) { - return ReactSharedInternals.H.useMemo(create, deps); + return ReactCurrentDispatcher.current.useMemo(create, deps); }; exports.useOptimistic = function (passthrough, reducer) { - return ReactSharedInternals.H.useOptimistic(passthrough, reducer); + return ReactCurrentDispatcher.current.useOptimistic(passthrough, reducer); }; exports.useReducer = function (reducer, initialArg, init) { - return ReactSharedInternals.H.useReducer(reducer, initialArg, init); + return ReactCurrentDispatcher.current.useReducer(reducer, initialArg, init); }; exports.useRef = function (initialValue) { - return ReactSharedInternals.H.useRef(initialValue); + return ReactCurrentDispatcher.current.useRef(initialValue); }; exports.useState = function (initialState) { - return ReactSharedInternals.H.useState(initialState); + return ReactCurrentDispatcher.current.useState(initialState); }; exports.useSyncExternalStore = function ( subscribe, getSnapshot, getServerSnapshot ) { - return ReactSharedInternals.H.useSyncExternalStore( + return ReactCurrentDispatcher.current.useSyncExternalStore( subscribe, getSnapshot, getServerSnapshot ); }; exports.useTransition = function () { - return ReactSharedInternals.H.useTransition(); + return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "19.0.0-www-modern-0eabe82a"; +exports.version = "19.0.0-www-modern-6f7d270a"; diff --git a/compiled/facebook-www/React-profiling.classic.js b/compiled/facebook-www/React-profiling.classic.js index 9b5e9119ce..45d8fb65fe 100644 --- a/compiled/facebook-www/React-profiling.classic.js +++ b/compiled/facebook-www/React-profiling.classic.js @@ -91,8 +91,17 @@ var isArrayImpl = Array.isArray, enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses, - ReactSharedInternals = { H: null, C: null, T: null, owner: null }, - hasOwnProperty = Object.prototype.hasOwnProperty; + ReactCurrentDispatcher = { current: null }, + ReactCurrentCache = { current: null }, + ReactCurrentBatchConfig = { transition: null }, + ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentCache: ReactCurrentCache, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: { current: null } + }, + hasOwnProperty = Object.prototype.hasOwnProperty, + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function ReactElement(type, key, _ref, self, source, owner, props) { enableRefAsProp && ((_ref = props.ref), (_ref = void 0 !== _ref ? _ref : null)); @@ -106,39 +115,29 @@ function ReactElement(type, key, _ref, self, source, owner, props) { }; } function jsxProd(type, config, maybeKey) { - var key = null, + var propName, + props = {}, + key = null, ref = null; void 0 !== maybeKey && (key = "" + maybeKey); void 0 !== config.key && (key = "" + config.key); - void 0 === config.ref || - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))); - maybeKey = {}; - for (var propName in config) - "key" === propName || - (!enableRefAsProp && "ref" === propName) || - (enableRefAsProp && "ref" === propName - ? (maybeKey.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (maybeKey[propName] = config[propName])); - if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) { - config = type.defaultProps; - for (var propName$0 in config) - void 0 === maybeKey[propName$0] && - (maybeKey[propName$0] = config[propName$0]); - } + void 0 === config.ref || enableRefAsProp || (ref = config.ref); + for (propName in config) + hasOwnProperty.call(config, propName) && + "key" !== propName && + (enableRefAsProp || "ref" !== propName) && + (props[propName] = config[propName]); + if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) + for (propName in ((config = type.defaultProps), config)) + void 0 === props[propName] && (props[propName] = config[propName]); return ReactElement( type, key, ref, void 0, void 0, - ReactSharedInternals.owner, - maybeKey + ReactCurrentOwner.current, + props ); } function cloneAndReplaceKey(oldElement, newKey) { @@ -159,34 +158,6 @@ function isValidElement(object) { object.$$typeof === REACT_ELEMENT_TYPE ); } -function coerceStringRef(mixedRef, owner, type) { - if ("string" !== typeof mixedRef) - if ("number" === typeof mixedRef || "boolean" === typeof mixedRef) - mixedRef = "" + mixedRef; - else return mixedRef; - return stringRefAsCallbackRef.bind(null, mixedRef, type, owner); -} -function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) - throw Error( - "Element ref was specified as a string (" + - stringRef + - ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://react.dev/link/refs-must-have-owner for more information." - ); - if (1 !== owner.tag) - throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref" - ); - type = owner.stateNode; - if (!type) - throw Error( - "Missing owner for string ref " + - stringRef + - ". This error is likely caused by a bug in React. Please file an issue." - ); - type = type.refs; - null === value ? delete type[stringRef] : (type[stringRef] = value); -} function escape(key) { var escaperLookup = { "=": "=0", ":": "=2" }; return ( @@ -440,7 +411,7 @@ exports.Profiler = REACT_PROFILER_TYPE; exports.PureComponent = PureComponent; exports.StrictMode = REACT_STRICT_MODE_TYPE; exports.Suspense = REACT_SUSPENSE_TYPE; -exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = +exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; exports.act = function () { throw Error("act(...) is not supported in production builds of React."); @@ -461,10 +432,8 @@ exports.cloneElement = function (element, config, children) { owner = element._owner; if (null != config) { void 0 !== config.ref && - ((owner = ReactSharedInternals.owner), - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, owner, element.type)))); + (enableRefAsProp || (ref = config.ref), + (owner = ReactCurrentOwner.current)); void 0 !== config.key && (key = "" + config.key); if ( !disableDefaultPropsExceptForClasses && @@ -479,17 +448,12 @@ exports.cloneElement = function (element, config, children) { "__self" === propName || "__source" === propName || (enableRefAsProp && "ref" === propName && void 0 === config.ref) || - (disableDefaultPropsExceptForClasses || - void 0 !== config[propName] || - void 0 === defaultProps - ? enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - owner, - element.type - )) - : (props[propName] = config[propName]) - : (props[propName] = defaultProps[propName])); + (props[propName] = + disableDefaultPropsExceptForClasses || + void 0 !== config[propName] || + void 0 === defaultProps + ? config[propName] + : defaultProps[propName]); } var propName = arguments.length - 2; if (1 === propName) props.children = children; @@ -530,8 +494,7 @@ exports.createElement = function (type, config, children) { if (null != config) for (propName in (void 0 === config.ref || enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))), + (ref = config.ref), void 0 !== config.key && (key = "" + config.key), config)) hasOwnProperty.call(config, propName) && @@ -539,13 +502,7 @@ exports.createElement = function (type, config, children) { (enableRefAsProp || "ref" !== propName) && "__self" !== propName && "__source" !== propName && - (enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (props[propName] = config[propName])); + (props[propName] = config[propName]); var childrenLength = arguments.length - 2; if (1 === childrenLength) props.children = children; else if (1 < childrenLength) { @@ -563,7 +520,7 @@ exports.createElement = function (type, config, children) { ref, void 0, void 0, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); }; @@ -571,7 +528,7 @@ exports.createRef = function () { return { current: null }; }; exports.experimental_useEffectEvent = function (callback) { - return ReactSharedInternals.H.useEffectEvent(callback); + return ReactCurrentDispatcher.current.useEffectEvent(callback); }; exports.forwardRef = function (render) { return { $$typeof: REACT_FORWARD_REF_TYPE, render: render }; @@ -595,15 +552,15 @@ exports.memo = function (type, compare) { }; }; exports.startTransition = function (scope, options) { - var prevTransition = ReactSharedInternals.T, + var prevTransition = ReactCurrentBatchConfig.transition, callbacks = new Set(); - ReactSharedInternals.T = { _callbacks: callbacks }; - var currentTransition = ReactSharedInternals.T; + ReactCurrentBatchConfig.transition = { _callbacks: callbacks }; + var currentTransition = ReactCurrentBatchConfig.transition; enableTransitionTracing && void 0 !== options && void 0 !== options.name && - ((ReactSharedInternals.T.name = options.name), - (ReactSharedInternals.T.startTime = -1)); + ((ReactCurrentBatchConfig.transition.name = options.name), + (ReactCurrentBatchConfig.transition.startTime = -1)); try { var returnValue = scope(); "object" === typeof returnValue && @@ -616,7 +573,7 @@ exports.startTransition = function (scope, options) { } catch (error) { reportGlobalError(error); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; } }; exports.unstable_Activity = REACT_OFFSCREEN_TYPE; @@ -626,76 +583,80 @@ exports.unstable_Scope = REACT_SCOPE_TYPE; exports.unstable_SuspenseList = REACT_SUSPENSE_LIST_TYPE; exports.unstable_TracingMarker = REACT_TRACING_MARKER_TYPE; exports.unstable_getCacheForType = function (resourceType) { - var dispatcher = ReactSharedInternals.C; + var dispatcher = ReactCurrentCache.current; return dispatcher ? dispatcher.getCacheForType(resourceType) : resourceType(); }; exports.unstable_useCacheRefresh = function () { - return ReactSharedInternals.H.useCacheRefresh(); + return ReactCurrentDispatcher.current.useCacheRefresh(); }; exports.unstable_useMemoCache = function (size) { - return ReactSharedInternals.H.useMemoCache(size); + return ReactCurrentDispatcher.current.useMemoCache(size); }; exports.use = function (usable) { - return ReactSharedInternals.H.use(usable); + return ReactCurrentDispatcher.current.use(usable); }; exports.useActionState = function (action, initialState, permalink) { - return ReactSharedInternals.H.useActionState(action, initialState, permalink); + return ReactCurrentDispatcher.current.useActionState( + action, + initialState, + permalink + ); }; exports.useCallback = function (callback, deps) { - return ReactSharedInternals.H.useCallback(callback, deps); + return ReactCurrentDispatcher.current.useCallback(callback, deps); }; exports.useContext = function (Context) { - return ReactSharedInternals.H.useContext(Context); + return ReactCurrentDispatcher.current.useContext(Context); }; exports.useDebugValue = function () {}; exports.useDeferredValue = function (value, initialValue) { - return ReactSharedInternals.H.useDeferredValue(value, initialValue); + return ReactCurrentDispatcher.current.useDeferredValue(value, initialValue); }; exports.useEffect = function (create, deps) { - return ReactSharedInternals.H.useEffect(create, deps); + return ReactCurrentDispatcher.current.useEffect(create, deps); }; exports.useId = function () { - return ReactSharedInternals.H.useId(); + return ReactCurrentDispatcher.current.useId(); }; exports.useImperativeHandle = function (ref, create, deps) { - return ReactSharedInternals.H.useImperativeHandle(ref, create, deps); + return ReactCurrentDispatcher.current.useImperativeHandle(ref, create, deps); }; exports.useInsertionEffect = function (create, deps) { - return ReactSharedInternals.H.useInsertionEffect(create, deps); + return ReactCurrentDispatcher.current.useInsertionEffect(create, deps); }; exports.useLayoutEffect = function (create, deps) { - return ReactSharedInternals.H.useLayoutEffect(create, deps); + return ReactCurrentDispatcher.current.useLayoutEffect(create, deps); }; exports.useMemo = function (create, deps) { - return ReactSharedInternals.H.useMemo(create, deps); + return ReactCurrentDispatcher.current.useMemo(create, deps); }; exports.useOptimistic = function (passthrough, reducer) { - return ReactSharedInternals.H.useOptimistic(passthrough, reducer); + return ReactCurrentDispatcher.current.useOptimistic(passthrough, reducer); }; exports.useReducer = function (reducer, initialArg, init) { - return ReactSharedInternals.H.useReducer(reducer, initialArg, init); + return ReactCurrentDispatcher.current.useReducer(reducer, initialArg, init); }; exports.useRef = function (initialValue) { - return ReactSharedInternals.H.useRef(initialValue); + return ReactCurrentDispatcher.current.useRef(initialValue); }; exports.useState = function (initialState) { - return ReactSharedInternals.H.useState(initialState); + return ReactCurrentDispatcher.current.useState(initialState); }; exports.useSyncExternalStore = function ( subscribe, getSnapshot, getServerSnapshot ) { - return ReactSharedInternals.H.useSyncExternalStore( + return ReactCurrentDispatcher.current.useSyncExternalStore( subscribe, getSnapshot, getServerSnapshot ); }; exports.useTransition = function () { - return ReactSharedInternals.H.useTransition(); + return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "19.0.0-www-classic-aab80d0a"; +exports.version = "19.0.0-www-classic-26c19df2"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled/facebook-www/React-profiling.modern.js b/compiled/facebook-www/React-profiling.modern.js index 4954072ad8..4ef4a951e7 100644 --- a/compiled/facebook-www/React-profiling.modern.js +++ b/compiled/facebook-www/React-profiling.modern.js @@ -91,8 +91,17 @@ var isArrayImpl = Array.isArray, enableRefAsProp = dynamicFeatureFlags.enableRefAsProp, disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses, - ReactSharedInternals = { H: null, C: null, T: null, owner: null }, - hasOwnProperty = Object.prototype.hasOwnProperty; + ReactCurrentDispatcher = { current: null }, + ReactCurrentCache = { current: null }, + ReactCurrentBatchConfig = { transition: null }, + ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentCache: ReactCurrentCache, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: { current: null } + }, + hasOwnProperty = Object.prototype.hasOwnProperty, + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function ReactElement(type, key, _ref, self, source, owner, props) { enableRefAsProp && ((_ref = props.ref), (_ref = void 0 !== _ref ? _ref : null)); @@ -106,39 +115,29 @@ function ReactElement(type, key, _ref, self, source, owner, props) { }; } function jsxProd(type, config, maybeKey) { - var key = null, + var propName, + props = {}, + key = null, ref = null; void 0 !== maybeKey && (key = "" + maybeKey); void 0 !== config.key && (key = "" + config.key); - void 0 === config.ref || - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))); - maybeKey = {}; - for (var propName in config) - "key" === propName || - (!enableRefAsProp && "ref" === propName) || - (enableRefAsProp && "ref" === propName - ? (maybeKey.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (maybeKey[propName] = config[propName])); - if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) { - config = type.defaultProps; - for (var propName$0 in config) - void 0 === maybeKey[propName$0] && - (maybeKey[propName$0] = config[propName$0]); - } + void 0 === config.ref || enableRefAsProp || (ref = config.ref); + for (propName in config) + hasOwnProperty.call(config, propName) && + "key" !== propName && + (enableRefAsProp || "ref" !== propName) && + (props[propName] = config[propName]); + if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) + for (propName in ((config = type.defaultProps), config)) + void 0 === props[propName] && (props[propName] = config[propName]); return ReactElement( type, key, ref, void 0, void 0, - ReactSharedInternals.owner, - maybeKey + ReactCurrentOwner.current, + props ); } function cloneAndReplaceKey(oldElement, newKey) { @@ -159,34 +158,6 @@ function isValidElement(object) { object.$$typeof === REACT_ELEMENT_TYPE ); } -function coerceStringRef(mixedRef, owner, type) { - if ("string" !== typeof mixedRef) - if ("number" === typeof mixedRef || "boolean" === typeof mixedRef) - mixedRef = "" + mixedRef; - else return mixedRef; - return stringRefAsCallbackRef.bind(null, mixedRef, type, owner); -} -function stringRefAsCallbackRef(stringRef, type, owner, value) { - if (!owner) - throw Error( - "Element ref was specified as a string (" + - stringRef + - ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://react.dev/link/refs-must-have-owner for more information." - ); - if (1 !== owner.tag) - throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref" - ); - type = owner.stateNode; - if (!type) - throw Error( - "Missing owner for string ref " + - stringRef + - ". This error is likely caused by a bug in React. Please file an issue." - ); - type = type.refs; - null === value ? delete type[stringRef] : (type[stringRef] = value); -} function escape(key) { var escaperLookup = { "=": "=0", ":": "=2" }; return ( @@ -440,7 +411,7 @@ exports.Profiler = REACT_PROFILER_TYPE; exports.PureComponent = PureComponent; exports.StrictMode = REACT_STRICT_MODE_TYPE; exports.Suspense = REACT_SUSPENSE_TYPE; -exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = +exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; exports.act = function () { throw Error("act(...) is not supported in production builds of React."); @@ -461,10 +432,8 @@ exports.cloneElement = function (element, config, children) { owner = element._owner; if (null != config) { void 0 !== config.ref && - ((owner = ReactSharedInternals.owner), - enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, owner, element.type)))); + (enableRefAsProp || (ref = config.ref), + (owner = ReactCurrentOwner.current)); void 0 !== config.key && (key = "" + config.key); if ( !disableDefaultPropsExceptForClasses && @@ -479,17 +448,12 @@ exports.cloneElement = function (element, config, children) { "__self" === propName || "__source" === propName || (enableRefAsProp && "ref" === propName && void 0 === config.ref) || - (disableDefaultPropsExceptForClasses || - void 0 !== config[propName] || - void 0 === defaultProps - ? enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - owner, - element.type - )) - : (props[propName] = config[propName]) - : (props[propName] = defaultProps[propName])); + (props[propName] = + disableDefaultPropsExceptForClasses || + void 0 !== config[propName] || + void 0 === defaultProps + ? config[propName] + : defaultProps[propName]); } var propName = arguments.length - 2; if (1 === propName) props.children = children; @@ -530,8 +494,7 @@ exports.createElement = function (type, config, children) { if (null != config) for (propName in (void 0 === config.ref || enableRefAsProp || - ((ref = config.ref), - (ref = coerceStringRef(ref, ReactSharedInternals.owner, type))), + (ref = config.ref), void 0 !== config.key && (key = "" + config.key), config)) hasOwnProperty.call(config, propName) && @@ -539,13 +502,7 @@ exports.createElement = function (type, config, children) { (enableRefAsProp || "ref" !== propName) && "__self" !== propName && "__source" !== propName && - (enableRefAsProp && "ref" === propName - ? (props.ref = coerceStringRef( - config[propName], - ReactSharedInternals.owner, - type - )) - : (props[propName] = config[propName])); + (props[propName] = config[propName]); var childrenLength = arguments.length - 2; if (1 === childrenLength) props.children = children; else if (1 < childrenLength) { @@ -563,7 +520,7 @@ exports.createElement = function (type, config, children) { ref, void 0, void 0, - ReactSharedInternals.owner, + ReactCurrentOwner.current, props ); }; @@ -571,7 +528,7 @@ exports.createRef = function () { return { current: null }; }; exports.experimental_useEffectEvent = function (callback) { - return ReactSharedInternals.H.useEffectEvent(callback); + return ReactCurrentDispatcher.current.useEffectEvent(callback); }; exports.forwardRef = function (render) { return { $$typeof: REACT_FORWARD_REF_TYPE, render: render }; @@ -595,15 +552,15 @@ exports.memo = function (type, compare) { }; }; exports.startTransition = function (scope, options) { - var prevTransition = ReactSharedInternals.T, + var prevTransition = ReactCurrentBatchConfig.transition, callbacks = new Set(); - ReactSharedInternals.T = { _callbacks: callbacks }; - var currentTransition = ReactSharedInternals.T; + ReactCurrentBatchConfig.transition = { _callbacks: callbacks }; + var currentTransition = ReactCurrentBatchConfig.transition; enableTransitionTracing && void 0 !== options && void 0 !== options.name && - ((ReactSharedInternals.T.name = options.name), - (ReactSharedInternals.T.startTime = -1)); + ((ReactCurrentBatchConfig.transition.name = options.name), + (ReactCurrentBatchConfig.transition.startTime = -1)); try { var returnValue = scope(); "object" === typeof returnValue && @@ -616,7 +573,7 @@ exports.startTransition = function (scope, options) { } catch (error) { reportGlobalError(error); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; } }; exports.unstable_Activity = REACT_OFFSCREEN_TYPE; @@ -626,76 +583,80 @@ exports.unstable_Scope = REACT_SCOPE_TYPE; exports.unstable_SuspenseList = REACT_SUSPENSE_LIST_TYPE; exports.unstable_TracingMarker = REACT_TRACING_MARKER_TYPE; exports.unstable_getCacheForType = function (resourceType) { - var dispatcher = ReactSharedInternals.C; + var dispatcher = ReactCurrentCache.current; return dispatcher ? dispatcher.getCacheForType(resourceType) : resourceType(); }; exports.unstable_useCacheRefresh = function () { - return ReactSharedInternals.H.useCacheRefresh(); + return ReactCurrentDispatcher.current.useCacheRefresh(); }; exports.unstable_useMemoCache = function (size) { - return ReactSharedInternals.H.useMemoCache(size); + return ReactCurrentDispatcher.current.useMemoCache(size); }; exports.use = function (usable) { - return ReactSharedInternals.H.use(usable); + return ReactCurrentDispatcher.current.use(usable); }; exports.useActionState = function (action, initialState, permalink) { - return ReactSharedInternals.H.useActionState(action, initialState, permalink); + return ReactCurrentDispatcher.current.useActionState( + action, + initialState, + permalink + ); }; exports.useCallback = function (callback, deps) { - return ReactSharedInternals.H.useCallback(callback, deps); + return ReactCurrentDispatcher.current.useCallback(callback, deps); }; exports.useContext = function (Context) { - return ReactSharedInternals.H.useContext(Context); + return ReactCurrentDispatcher.current.useContext(Context); }; exports.useDebugValue = function () {}; exports.useDeferredValue = function (value, initialValue) { - return ReactSharedInternals.H.useDeferredValue(value, initialValue); + return ReactCurrentDispatcher.current.useDeferredValue(value, initialValue); }; exports.useEffect = function (create, deps) { - return ReactSharedInternals.H.useEffect(create, deps); + return ReactCurrentDispatcher.current.useEffect(create, deps); }; exports.useId = function () { - return ReactSharedInternals.H.useId(); + return ReactCurrentDispatcher.current.useId(); }; exports.useImperativeHandle = function (ref, create, deps) { - return ReactSharedInternals.H.useImperativeHandle(ref, create, deps); + return ReactCurrentDispatcher.current.useImperativeHandle(ref, create, deps); }; exports.useInsertionEffect = function (create, deps) { - return ReactSharedInternals.H.useInsertionEffect(create, deps); + return ReactCurrentDispatcher.current.useInsertionEffect(create, deps); }; exports.useLayoutEffect = function (create, deps) { - return ReactSharedInternals.H.useLayoutEffect(create, deps); + return ReactCurrentDispatcher.current.useLayoutEffect(create, deps); }; exports.useMemo = function (create, deps) { - return ReactSharedInternals.H.useMemo(create, deps); + return ReactCurrentDispatcher.current.useMemo(create, deps); }; exports.useOptimistic = function (passthrough, reducer) { - return ReactSharedInternals.H.useOptimistic(passthrough, reducer); + return ReactCurrentDispatcher.current.useOptimistic(passthrough, reducer); }; exports.useReducer = function (reducer, initialArg, init) { - return ReactSharedInternals.H.useReducer(reducer, initialArg, init); + return ReactCurrentDispatcher.current.useReducer(reducer, initialArg, init); }; exports.useRef = function (initialValue) { - return ReactSharedInternals.H.useRef(initialValue); + return ReactCurrentDispatcher.current.useRef(initialValue); }; exports.useState = function (initialState) { - return ReactSharedInternals.H.useState(initialState); + return ReactCurrentDispatcher.current.useState(initialState); }; exports.useSyncExternalStore = function ( subscribe, getSnapshot, getServerSnapshot ) { - return ReactSharedInternals.H.useSyncExternalStore( + return ReactCurrentDispatcher.current.useSyncExternalStore( subscribe, getSnapshot, getServerSnapshot ); }; exports.useTransition = function () { - return ReactSharedInternals.H.useTransition(); + return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "19.0.0-www-modern-aab80d0a"; +exports.version = "19.0.0-www-modern-26c19df2"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled/facebook-www/ReactART-dev.classic.js b/compiled/facebook-www/ReactART-dev.classic.js index 753f418191..e2a97177ee 100644 --- a/compiled/facebook-www/ReactART-dev.classic.js +++ b/compiled/facebook-www/ReactART-dev.classic.js @@ -66,7 +66,7 @@ if (__DEV__) { return self; } - var ReactVersion = "19.0.0-www-classic-5df29fbc"; + var ReactVersion = "19.0.0-www-classic-e11823db"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -120,10 +120,12 @@ if (__DEV__) { var React = require("react"); var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; // Defensive in case this is fired before React is initialized. + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Defensive in case this is fired before React is initialized. if (ReactSharedInternals != null) { - var stack = ReactSharedInternals.getStackAddendum(); + var ReactDebugCurrentFrame = + ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { format += "%s"; @@ -156,7 +158,7 @@ if (__DEV__) { } var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Re-export dynamic flags from the www version. var dynamicFeatureFlags = require("ReactFeatureFlags"); @@ -409,17 +411,6 @@ if (__DEV__) { return type.displayName || "Context"; } - function getComponentNameFromOwner(owner) { - if (typeof owner.tag === "number") { - return getComponentNameFromFiber(owner); - } - - if (typeof owner.name === "string") { - return owner.name; - } - - return null; - } function getComponentNameFromFiber(fiber) { var tag = fiber.tag, type = fiber.type; @@ -586,7 +577,6 @@ if (__DEV__) { var ScheduleRetry = StoreConsistency; var ShouldSuspendCommit = Visibility; var DidDefer = ContentReset; - var FormReset = Snapshot; var LifecycleEffectMask = Passive$1 | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit) @@ -656,8 +646,7 @@ if (__DEV__) { ContentReset | Ref | Hydrating | - Visibility | - FormReset; + Visibility; var LayoutMask = Update | Callback | Ref | Visibility; // TODO: Split into PassiveMountMask and PassiveUnmountMask var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that don't get reset on clones. @@ -667,6 +656,7 @@ if (__DEV__) { var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; + var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { var node = fiber; var nearestMounted = fiber; @@ -708,7 +698,7 @@ if (__DEV__) { } function isMounted(component) { { - var owner = ReactSharedInternals.owner; + var owner = ReactCurrentOwner$2.current; if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; @@ -2575,11 +2565,17 @@ if (__DEV__) { } } - var NoEventPriority = NoLane; var DiscreteEventPriority = SyncLane; var ContinuousEventPriority = InputContinuousLane; var DefaultEventPriority = DefaultLane; var IdleEventPriority = IdleLane; + var currentUpdatePriority = NoLane; + function getCurrentUpdatePriority() { + return currentUpdatePriority; + } + function setCurrentUpdatePriority(newPriority) { + currentUpdatePriority = newPriority; + } function higherEventPriority(a, b) { return a !== 0 && a < b ? a : b; } @@ -2589,9 +2585,6 @@ if (__DEV__) { function isHigherEventPriority(a, b) { return a !== 0 && a < b; } - function eventPriorityToLane(updatePriority) { - return updatePriority; - } function lanesToEventPriority(lanes) { var lane = getHighestPriorityLane(lanes); @@ -2957,15 +2950,8 @@ if (__DEV__) { typeof props.children === "string" || typeof props.children === "number" ); } - var currentUpdatePriority = NoEventPriority; - function setCurrentUpdatePriority(newPriority) { - currentUpdatePriority = newPriority; - } - function getCurrentUpdatePriority() { - return currentUpdatePriority; - } - function resolveUpdatePriority() { - return currentUpdatePriority || DefaultEventPriority; + function getCurrentEventPriority() { + return DefaultEventPriority; } function shouldAttemptEagerTransition() { return false; @@ -3603,8 +3589,9 @@ if (__DEV__) { } } + var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher; var prefix; - function describeBuiltInComponentFrame(name) { + function describeBuiltInComponentFrame(name, ownerFn) { { if (prefix === undefined) { // Extract the VM specific prefix used by each line. @@ -3661,13 +3648,13 @@ if (__DEV__) { var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. Error.prepareStackTrace = undefined; - var previousDispatcher = null; + var previousDispatcher; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + previousDispatcher = ReactCurrentDispatcher$2.current; // Set the dispatcher in DEV because this might be call in the render function // for warnings. - ReactSharedInternals.H = null; + ReactCurrentDispatcher$2.current = null; disableLogs(); } /** @@ -3860,7 +3847,7 @@ if (__DEV__) { reentry = false; { - ReactSharedInternals.H = previousDispatcher; + ReactCurrentDispatcher$2.current = previousDispatcher; reenableLogs(); } @@ -3879,12 +3866,12 @@ if (__DEV__) { return syntheticFrame; } - function describeClassComponentFrame(ctor) { + function describeClassComponentFrame(ctor, ownerFn) { { return describeNativeComponentFrame(ctor, true); } } - function describeFunctionComponentFrame(fn) { + function describeFunctionComponentFrame(fn, ownerFn) { { return describeNativeComponentFrame(fn, false); } @@ -5081,6 +5068,7 @@ if (__DEV__) { } } + var ReactCurrentActQueue$4 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, // there's only a single root, but we do support multi root apps, hence this // extra complexity. But this module is optimized for the single root case. @@ -5119,7 +5107,7 @@ if (__DEV__) { mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure // there's a task scheduled for each one at the correct priority. - if (ReactSharedInternals.actQueue !== null) { + if (ReactCurrentActQueue$4.current !== null) { // We're inside an `act` scope. if (!didScheduleMicrotask_act) { didScheduleMicrotask_act = true; @@ -5140,9 +5128,9 @@ if (__DEV__) { scheduleTaskForRootDuringMicrotask(root, now$1()); } - if (ReactSharedInternals.isBatchingLegacy && root.tag === LegacyRoot) { + if (ReactCurrentActQueue$4.isBatchingLegacy && root.tag === LegacyRoot) { // Special `act` case: Record whenever a legacy update is scheduled. - ReactSharedInternals.didScheduleLegacyUpdate = true; + ReactCurrentActQueue$4.didScheduleLegacyUpdate = true; } } function flushSyncWorkOnAllRoots() { @@ -5333,7 +5321,7 @@ if (__DEV__) { // Scheduler task, rather than an `act` task, cancel it and re-schedule // on the `act` queue. !( - ReactSharedInternals.actQueue !== null && + ReactCurrentActQueue$4.current !== null && existingCallbackNode !== fakeActCallbackNode$1 ) ) { @@ -5400,11 +5388,11 @@ if (__DEV__) { var fakeActCallbackNode$1 = {}; function scheduleCallback$2(priorityLevel, callback) { - if (ReactSharedInternals.actQueue !== null) { + if (ReactCurrentActQueue$4.current !== null) { // Special case: We're inside an `act` scope (a testing utility). // Instead of scheduling work in the host environment, add it to a // fake internal queue that's managed by the `act` implementation. - ReactSharedInternals.actQueue.push(callback); + ReactCurrentActQueue$4.current.push(callback); return fakeActCallbackNode$1; } else { return scheduleCallback$3(priorityLevel, callback); @@ -5419,13 +5407,13 @@ if (__DEV__) { } function scheduleImmediateTask(cb) { - if (ReactSharedInternals.actQueue !== null) { + if (ReactCurrentActQueue$4.current !== null) { // Special case: Inside an `act` scope, we push microtasks to the fake `act` // callback queue. This is because we currently support calling `act` // without awaiting the result. The plan is to deprecate that, and require // that you always await the result so that the microtasks have a chance to // run. But it hasn't happened yet. - ReactSharedInternals.actQueue.push(function () { + ReactCurrentActQueue$4.current.push(function () { cb(); return null; }); @@ -6217,6 +6205,7 @@ if (__DEV__) { return true; } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var current = null; var isRendering = false; function getCurrentFiberOwnerNameInDevOrNull() { @@ -6227,8 +6216,8 @@ if (__DEV__) { var owner = current._debugOwner; - if (owner != null) { - return getComponentNameFromOwner(owner); + if (owner !== null && typeof owner !== "undefined") { + return getComponentNameFromFiber(owner); } } @@ -6248,14 +6237,14 @@ if (__DEV__) { function resetCurrentFiber() { { - ReactSharedInternals.getCurrentStack = null; + ReactDebugCurrentFrame.getCurrentStack = null; current = null; isRendering = false; } } function setCurrentFiber(fiber) { { - ReactSharedInternals.getCurrentStack = + ReactDebugCurrentFrame.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev; current = fiber; isRendering = false; @@ -6630,6 +6619,83 @@ if (__DEV__) { }; } + /* + * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol + * and Temporal.* types. See https://github.com/facebook/react/pull/22064. + * + * The functions in this module will throw an easier-to-understand, + * easier-to-debug exception with a clear errors message message explaining the + * problem. (Instead of a confusing exception thrown inside the implementation + * of the `value` object). + */ + // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible. + function typeName(value) { + { + // toStringTag is needed for namespaced types like Temporal.Instant + var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag; + var type = + (hasToStringTag && value[Symbol.toStringTag]) || + value.constructor.name || + "Object"; // $FlowFixMe[incompatible-return] + + return type; + } + } // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible. + + function willCoercionThrow(value) { + { + try { + testStringCoercion(value); + return false; + } catch (e) { + return true; + } + } + } + + function testStringCoercion(value) { + // If you ended up here by following an exception call stack, here's what's + // happened: you supplied an object or symbol value to React (as a prop, key, + // DOM attribute, CSS property, string ref, etc.) and when React tried to + // coerce it to a string using `'' + value`, an exception was thrown. + // + // The most common types that will cause this exception are `Symbol` instances + // and Temporal objects like `Temporal.Instant`. But any object that has a + // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this + // exception. (Library authors do this to prevent users from using built-in + // numeric operators like `+` or comparison operators like `>=` because custom + // methods are needed to perform accurate arithmetic or comparison.) + // + // To fix the problem, coerce this object or symbol value to a string before + // passing it to React. The most reliable way is usually `String(value)`. + // + // To find which value is throwing, check the browser or debugger console. + // Before this exception was thrown, there should be `console.error` output + // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the + // problem and how that type was used: key, atrribute, input value prop, etc. + // In most cases, this console output also shows the component and its + // ancestor components where the exception happened. + // + // eslint-disable-next-line react-internal/safe-string-coercion + return "" + value; + } + function checkPropStringCoercion(value, propName) { + { + if (willCoercionThrow(value)) { + error( + "The provided `%s` prop is an unsupported type %s." + + " This value must be coerced to a string before using it here.", + propName, + typeName(value) + ); + + return testStringCoercion(value); // throw (to help callers find troubleshooting comments) + } + } + } + + var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; + function getThenablesFromState(state) { { var devState = state; @@ -6683,8 +6749,8 @@ if (__DEV__) { function noop() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactSharedInternals.actQueue !== null) { - ReactSharedInternals.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var trackedThenables = getThenablesFromState(thenableState); @@ -6907,6 +6973,7 @@ if (__DEV__) { var didWarnAboutMaps; var didWarnAboutGenerators; + var didWarnAboutStringRefs; var ownerHasKeyUseWarning; var ownerHasFunctionTypeWarning; var ownerHasSymbolTypeWarning; @@ -6916,6 +6983,7 @@ if (__DEV__) { { didWarnAboutMaps = false; didWarnAboutGenerators = false; + didWarnAboutStringRefs = {}; /** * Warn if there's no key explicitly set on dynamic arrays of children or * object keys are not valid. This allows us to keep track of children between @@ -6960,6 +7028,10 @@ if (__DEV__) { }; } + function isReactClass(type) { + return type.prototype && type.prototype.isReactComponent; + } + function unwrapThenable(thenable) { var index = thenableIndexCounter$1; thenableIndexCounter$1 += 1; @@ -6971,22 +7043,159 @@ if (__DEV__) { return trackUsedThenable(thenableState$1, thenable, index); } + function convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef + ) { + { + checkPropStringCoercion(mixedRef, "ref"); + } + + var stringRef = "" + mixedRef; + var owner = element._owner; + + if (!owner) { + throw new Error( + "Element ref was specified as a string (" + + stringRef + + ") but no owner was set. This could happen for one of" + + " the following reasons:\n" + + "1. You may be adding a ref to a function component\n" + + "2. You may be adding a ref to a component that was not created inside a component's render method\n" + + "3. You have multiple copies of React loaded\n" + + "See https://react.dev/link/refs-must-have-owner for more information." + ); + } + + if (owner.tag !== ClassComponent) { + throw new Error( + "Function components cannot have string refs. " + + "We recommend using useRef() instead. " + + "Learn more about using refs safely here: " + + "https://react.dev/link/strict-mode-string-ref" + ); + } + + { + if ( + // Will already warn with "Function components cannot be given refs" + !(typeof element.type === "function" && !isReactClass(element.type)) + ) { + var componentName = + getComponentNameFromFiber(returnFiber) || "Component"; + + if (!didWarnAboutStringRefs[componentName]) { + error( + 'Component "%s" contains the string ref "%s". Support for string refs ' + + "will be removed in a future major release. We recommend using " + + "useRef() or createRef() instead. " + + "Learn more about using refs safely here: " + + "https://react.dev/link/strict-mode-string-ref", + componentName, + stringRef + ); + + didWarnAboutStringRefs[componentName] = true; + } + } + } + + var inst = owner.stateNode; + + if (!inst) { + throw new Error( + "Missing owner for string ref " + + stringRef + + ". This error is likely caused by a " + + "bug in React. Please file an issue." + ); + } // Check if previous string ref matches new string ref + + if ( + current !== null && + current.ref !== null && + typeof current.ref === "function" && + current.ref._stringRef === stringRef + ) { + // Reuse the existing string ref + var currentRef = current.ref; + return currentRef; + } // Create a new string ref + + var ref = function (value) { + var refs = inst.refs; + + if (value === null) { + delete refs[stringRef]; + } else { + refs[stringRef] = value; + } + }; + + ref._stringRef = stringRef; + return ref; + } + function coerceRef(returnFiber, current, workInProgress, element) { - var ref; + var mixedRef; if (enableRefAsProp) { // TODO: This is a temporary, intermediate step. When enableRefAsProp is on, // we should resolve the `ref` prop during the begin phase of the component // it's attached to (HostComponent, ClassComponent, etc). var refProp = element.props.ref; - ref = refProp !== undefined ? refProp : null; + mixedRef = refProp !== undefined ? refProp : null; } else { // Old behavior. - ref = element.ref; + mixedRef = element.ref; + } + + var coercedRef; + + if ( + typeof mixedRef === "string" || + typeof mixedRef === "number" || + typeof mixedRef === "boolean" + ) { + coercedRef = convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef + ); + + if (enableRefAsProp) { + // When enableRefAsProp is on, we should always use the props as the + // source of truth for refs. Not a field on the fiber. + // + // In the case of string refs, this presents a problem, because string + // refs are not passed around internally as strings; they are converted to + // callback refs. The ref used by the reconciler is not the same as the + // one the user provided. + // + // But since this is a deprecated feature anyway, what we can do is clone + // the props object and replace it with the internal callback ref. Then we + // can continue to use the props object as the source of truth. + // + // This means the internal callback ref will leak into userspace. The + // receiving component will receive a callback ref even though the parent + // passed a string. Which is weird, but again, this is a deprecated + // feature, and we're only leaving it around behind a flag so that Meta + // can keep using string refs temporarily while they finish migrating + // their codebase. + var userProvidedProps = workInProgress.pendingProps; + var propsWithInternalCallbackRef = assign({}, userProvidedProps); + propsWithInternalCallbackRef.ref = coercedRef; + workInProgress.pendingProps = propsWithInternalCallbackRef; + } + } else { + coercedRef = mixedRef; } // TODO: If enableRefAsProp is on, we shouldn't use the `ref` field. We // should always read the ref from the prop. - workInProgress.ref = ref; + workInProgress.ref = coercedRef; } function throwOnInvalidObjectType(returnFiber, newChild) { @@ -8805,6 +9014,8 @@ if (__DEV__) { /* */ 8; + var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; var didWarnUncachedGetSnapshot; var didWarnAboutUseWrappedInTryCatch; @@ -8968,8 +9179,8 @@ if (__DEV__) { didWarnAboutUseFormState.add(componentName); error( - "ReactDOM.useFormState has been renamed to React.useActionState. " + - "Please update %s to use React.useActionState.", + "ReactDOM.useFormState has been deprecated and replaced by " + + "React.useActionState. Please update %s to use React.useActionState.", componentName ); } @@ -9105,16 +9316,17 @@ if (__DEV__) { { if (current !== null && current.memoizedState !== null) { - ReactSharedInternals.H = HooksDispatcherOnUpdateInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, // but no stateful hooks have been used. // We want to match the production code behavior (which will use HooksDispatcherOnMount), // but with the extra DEV validation to ensure hooks ordering hasn't changed. // This dispatcher does that. - ReactSharedInternals.H = HooksDispatcherOnMountWithHookTypesInDEV; + ReactCurrentDispatcher$1.current = + HooksDispatcherOnMountWithHookTypesInDEV; } else { - ReactSharedInternals.H = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; } } // In Strict Mode, during development, user functions are double invoked to // help detect side effects. The logic for how this is implemented for in @@ -9186,7 +9398,7 @@ if (__DEV__) { } // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrance. - ReactSharedInternals.H = ContextOnlyDispatcher; // This check uses currentHook so that it works the same in DEV and prod bundles. + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; // This check uses currentHook so that it works the same in DEV and prod bundles. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = @@ -9359,7 +9571,7 @@ if (__DEV__) { hookTypesUpdateIndexDev = -1; } - ReactSharedInternals.H = HooksDispatcherOnRerenderInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV; children = Component(props, secondArg); } while (didScheduleRenderPhaseUpdateDuringThisPass); @@ -9381,34 +9593,18 @@ if (__DEV__) { ); } function TransitionAwareHostComponent() { - var dispatcher = ReactSharedInternals.H; + var dispatcher = ReactCurrentDispatcher$1.current; var _dispatcher$useState = dispatcher.useState(), maybeThenable = _dispatcher$useState[0]; - var nextState; - if (typeof maybeThenable.then === "function") { var thenable = maybeThenable; - nextState = useThenable(thenable); + return useThenable(thenable); } else { var status = maybeThenable; - nextState = status; - } // The "reset state" is an object. If it changes, that means something - // requested that we reset the form. - - var _dispatcher$useState2 = dispatcher.useState(), - nextResetState = _dispatcher$useState2[0]; - - var prevResetState = - currentHook !== null ? currentHook.memoizedState : null; - - if (prevResetState !== nextResetState) { - // Schedule a form reset - currentlyRenderingFiber$1.flags |= FormReset; + return status; } - - return nextState; } function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; // TODO: Don't need to reset the flags here, because they're reset in the @@ -9437,7 +9633,7 @@ if (__DEV__) { currentlyRenderingFiber$1 = null; // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrance. - ReactSharedInternals.H = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; } function resetHooksOnUnwind(workInProgress) { if (didScheduleRenderPhaseUpdate) { @@ -9610,7 +9806,7 @@ if (__DEV__) { // time (perhaps because it threw). Subsequent Hook calls should use the // mount dispatcher. { - ReactSharedInternals.H = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; } } @@ -10419,14 +10615,14 @@ if (__DEV__) { var action = actionQueue.action; var prevState = actionQueue.state; // This is a fork of startTransition - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig$2.transition; var currentTransition = { _callbacks: new Set() }; - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$2.transition = currentTransition; { - ReactSharedInternals.T._updatedFibers = new Set(); + ReactCurrentBatchConfig$2.transition._updatedFibers = new Set(); } // Optimistically update the pending state, similar to useTransition. // This will be reverted automatically when all actions are finished. @@ -10484,7 +10680,7 @@ if (__DEV__) { setState(rejectedThenable); finishRunningActionStateAction(actionQueue, setPendingState, setState); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$2.transition = prevTransition; { if (prevTransition === null && currentTransition._updatedFibers) { @@ -11126,7 +11322,7 @@ if (__DEV__) { setCurrentUpdatePriority( higherEventPriority(previousPriority, ContinuousEventPriority) ); - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig$2.transition; var currentTransition = { _callbacks: new Set() }; @@ -11138,19 +11334,19 @@ if (__DEV__) { // optimistic update anyway to make it less likely the behavior accidentally // diverges; for example, both an optimistic update and this one should // share the same lane. - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$2.transition = currentTransition; dispatchOptimisticSetState(fiber, false, queue, pendingState); } if (enableTransitionTracing) { if (options !== undefined && options.name !== undefined) { - currentTransition.name = options.name; - currentTransition.startTime = now$1(); + ReactCurrentBatchConfig$2.transition.name = options.name; + ReactCurrentBatchConfig$2.transition.startTime = now$1(); } } { - currentTransition._updatedFibers = new Set(); + ReactCurrentBatchConfig$2.transition._updatedFibers = new Set(); } try { @@ -11196,7 +11392,7 @@ if (__DEV__) { } } finally { setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$2.transition = prevTransition; { if (prevTransition === null && currentTransition._updatedFibers) { @@ -11418,11 +11614,11 @@ if (__DEV__) { var lastRenderedReducer = queue.lastRenderedReducer; if (lastRenderedReducer !== null) { - var prevDispatcher = null; + var prevDispatcher; { - prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = + prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } @@ -11453,7 +11649,7 @@ if (__DEV__) { // Suppress the error. It will throw again in the render phase. } finally { { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } } } @@ -11727,25 +11923,27 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; mountHookTypesDev(); checkDepsAreArrayDev(deps); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -11756,13 +11954,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -11893,25 +12092,27 @@ if (__DEV__) { useMemo: function (create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -11922,13 +12123,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -12051,25 +12253,27 @@ if (__DEV__) { useMemo: function (create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -12080,13 +12284,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -12218,25 +12423,27 @@ if (__DEV__) { useMemo: function (create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnRerenderInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -12247,13 +12454,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -12396,26 +12604,28 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -12428,13 +12638,14 @@ if (__DEV__) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -12581,26 +12792,28 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -12613,13 +12826,14 @@ if (__DEV__) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -12766,26 +12980,28 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -12798,13 +13014,14 @@ if (__DEV__) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -14277,20 +14494,7 @@ if (__DEV__) { // remove this extra check. alreadyResolvedDefaultProps ) { - var newProps = baseProps; - - if (enableRefAsProp) { - // Remove ref from the props object, if it exists. - if ("ref" in baseProps) { - newProps = {}; - - for (var propName in baseProps) { - if (propName !== "ref") { - newProps[propName] = baseProps[propName]; - } - } - } - } // Resolve default props. + var newProps = baseProps; // Resolve default props. Taken from old JSX runtime, where this used to live. var defaultProps = Component.defaultProps; @@ -14299,19 +14503,26 @@ if (__DEV__) { // default props here in the reconciler, rather than in the JSX runtime. (disableDefaultPropsExceptForClasses || !alreadyResolvedDefaultProps) ) { - // We may have already copied the props object above to remove ref. If so, - // we can modify that. Otherwise, copy the props object with Object.assign. - if (newProps === baseProps) { - newProps = assign({}, newProps, baseProps); - } // Taken from old JSX runtime, where this used to live. + newProps = assign({}, newProps, baseProps); - for (var _propName in defaultProps) { - if (newProps[_propName] === undefined) { - newProps[_propName] = defaultProps[_propName]; + for (var propName in defaultProps) { + if (newProps[propName] === undefined) { + newProps[propName] = defaultProps[propName]; } } } + if (enableRefAsProp) { + // Remove ref from the props object, if it exists. + if ("ref" in newProps) { + if (newProps === baseProps) { + newProps = assign({}, newProps); + } + + delete newProps.ref; + } + } + return newProps; } @@ -14377,6 +14588,8 @@ if (__DEV__) { console["error"](error); }; + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API + var componentName = null; var errorBoundaryName = null; function logUncaughtError(root, errorInfo) { @@ -14390,10 +14603,10 @@ if (__DEV__) { var error = errorInfo.value; - if (true && ReactSharedInternals.actQueue !== null) { + if (true && ReactCurrentActQueue$2.current !== null) { // For uncaught errors inside act, we track them on the act and then // rethrow them into the test. - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue$2.thrownErrors.push(error); return; } @@ -15168,6 +15381,7 @@ if (__DEV__) { return null; } + var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; // A special exception that's used to unwind the stack when an update flows // into a dehydrated boundary. var SelectiveHydrationException = new Error( @@ -15300,7 +15514,7 @@ if (__DEV__) { } { - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); nextChildren = renderWithHooks( current, @@ -15979,7 +16193,7 @@ if (__DEV__) { } { - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); nextChildren = renderWithHooks( current, @@ -16202,10 +16416,7 @@ if (__DEV__) { var instance = workInProgress.stateNode; // Rerender - { - ReactSharedInternals.owner = workInProgress; - } - + ReactCurrentOwner$1.current = workInProgress; var nextChildren; if ( @@ -18029,7 +18240,7 @@ if (__DEV__) { var newChildren; { - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); newChildren = render(newValue); setIsRendering(false); @@ -19529,8 +19740,10 @@ if (__DEV__) { popProvider(CacheContext, workInProgress); } + var ReactCurrentBatchConfig$1 = + ReactSharedInternals.ReactCurrentBatchConfig; function requestCurrentTransition() { - var transition = ReactSharedInternals.T; + var transition = ReactCurrentBatchConfig$1.transition; if (transition !== null) { // Whenever a transition update is scheduled, register a callback on the @@ -21277,7 +21490,7 @@ if (__DEV__) { // Allows us to avoid traversing the return path to find the nearest Offscreen ancestor. var offscreenSubtreeIsHidden = false; - var offscreenSubtreeWasHidden = false; // Used to track if a form needs to be reset at the end of the mutation phase. + var offscreenSubtreeWasHidden = false; var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; var nextEffect = null; // Used for Profiling builds to track updaters. @@ -23609,19 +23822,6 @@ if (__DEV__) { } } } - - if (flags & FormReset) { - { - if (finishedWork.type !== "form") { - // Paranoid coding. In case we accidentally start using the - // FormReset bit for something else. - error( - "Unexpected host component type. Expected a form. This is a " + - "bug in React." - ); - } - } - } } return; @@ -25523,6 +25723,7 @@ if (__DEV__) { symbolFor("selector.text"); } + var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -25545,7 +25746,7 @@ if (__DEV__) { if ( !isReactActEnvironmentGlobal && - ReactSharedInternals.actQueue !== null + ReactCurrentActQueue$1.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -25559,9 +25760,17 @@ if (__DEV__) { } var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentCache = ReactSharedInternals.ReactCurrentCache, + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner, + ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, + ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue; var NoContext = /* */ 0; + var BatchedContext = + /* */ + 1; var RenderContext = /* */ 2; @@ -25857,11 +26066,13 @@ if (__DEV__) { if (transition !== null) { { - if (!transition._updatedFibers) { - transition._updatedFibers = new Set(); + var batchConfigTransition = ReactCurrentBatchConfig.transition; + + if (!batchConfigTransition._updatedFibers) { + batchConfigTransition._updatedFibers = new Set(); } - transition._updatedFibers.add(fiber); + batchConfigTransition._updatedFibers.add(fiber); } var actionScopeLane = peekEntangledActionLane(); @@ -25870,9 +26081,26 @@ if (__DEV__) { : // is the first update in that scope. Either way, we need to get a // fresh transition lane. requestTransitionLane(); - } + } // Updates originating inside certain React methods, like flushSync, have + // their priority set by tracking it with a context variable. + // + // The opaque type returned by the host config is internally a lane, so we can + // use that directly. + // TODO: Move this type conversion to the event priority module. - return eventPriorityToLane(resolveUpdatePriority()); + var updateLane = getCurrentUpdatePriority(); + + if (updateLane !== NoLane) { + return updateLane; + } // This update originated outside React. Ask the host environment for an + // appropriate priority, based on the type of event. + // + // The opaque type returned by the host config is internally a lane, so we can + // use that directly. + // TODO: Move this type conversion to the event priority module. + + var eventLane = getCurrentEventPriority(); + return eventLane; } function requestRetryLane(fiber) { @@ -25983,13 +26211,12 @@ if (__DEV__) { warnIfUpdatesNotWrappedWithActDEV(fiber); if (enableTransitionTracing) { - var transition = ReactSharedInternals.T; + var transition = ReactCurrentBatchConfig.transition; if (transition !== null && transition.name != null) { if (transition.startTime === -1) { transition.startTime = now$1(); - } // $FlowFixMe[prop-missing]: The BatchConfigTransition and Transition types are incompatible but was previously untyped and thus uncaught - // $FlowFixMe[incompatible-call]: " + } addTransitionToLanesMap(root, transition, lane); } @@ -26028,7 +26255,7 @@ if (__DEV__) { !disableLegacyMode && (fiber.mode & ConcurrentMode) === NoMode ) { - if (ReactSharedInternals.isBatchingLegacy); + if (ReactCurrentActQueue.isBatchingLegacy); else { // Flush the synchronous work now, unless we're already working or inside // a batch. This is intentionally inside scheduleUpdateOnFiber instead of @@ -26130,31 +26357,20 @@ if (__DEV__) { } // Check if something threw if (exitStatus === RootErrored) { - var lanesThatJustErrored = lanes; + var originallyAttemptedLanes = lanes; var errorRetryLanes = getLanesToRetrySynchronouslyOnError( root, - lanesThatJustErrored + originallyAttemptedLanes ); if (errorRetryLanes !== NoLanes) { lanes = errorRetryLanes; exitStatus = recoverFromConcurrentError( root, - lanesThatJustErrored, + originallyAttemptedLanes, errorRetryLanes ); - renderWasConcurrent = false; // Need to check the exit status again. - - if (exitStatus !== RootErrored) { - // The root did not error this time. Restart the exit algorithm - // from the beginning. - // TODO: Refactor the exit algorithm to be less confusing. Maybe - // more branches + recursion instead of a loop. I think the only - // thing that causes it to be a loop is the RootDidNotComplete - // check. If that's true, then we don't need a loop/recursion - // at all. - continue; - } + renderWasConcurrent = false; } } @@ -26595,15 +26811,51 @@ if (__DEV__) { function getExecutionContext() { return executionContext; } - // Returns whether the the call was during a render or not + // Warning, this opts-out of checking the function body. + // eslint-disable-next-line no-unused-vars + // eslint-disable-next-line no-redeclare + // eslint-disable-next-line no-redeclare - function flushSyncWork() { - if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncWorkOnAllRoots(); - return false; + function flushSync(fn) { + // In legacy mode, we flush pending passive effects at the beginning of the + // next event, not at the end of the previous one. + if ( + rootWithPendingPassiveEffects !== null && + !disableLegacyMode && + rootWithPendingPassiveEffects.tag === LegacyRoot && + (executionContext & (RenderContext | CommitContext)) === NoContext + ) { + flushPassiveEffects(); } - return true; + var prevExecutionContext = executionContext; + executionContext |= BatchedContext; + var prevTransition = ReactCurrentBatchConfig.transition; + var previousPriority = getCurrentUpdatePriority(); + + try { + ReactCurrentBatchConfig.transition = null; + setCurrentUpdatePriority(DiscreteEventPriority); + + if (fn) { + return fn(); + } else { + return undefined; + } + } finally { + setCurrentUpdatePriority(previousPriority); + ReactCurrentBatchConfig.transition = prevTransition; + executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. + // Note that this will happen even if batchedUpdates is higher up + // the stack. + + if ( + (executionContext & (RenderContext | CommitContext)) === + NoContext + ) { + flushSyncWorkOnAllRoots(); + } + } } function isInvalidExecutionContextForEventFunction() { // Used to throw if certain APIs are called from the wrong context. @@ -26721,10 +26973,7 @@ if (__DEV__) { // when React is executing user code. resetHooksAfterThrow(); resetCurrentFiber(); - - { - ReactSharedInternals.owner = null; - } + ReactCurrentOwner.current = null; if (thrownValue === SuspenseException) { // This is a special type of exception used for Suspense. For historical @@ -26876,8 +27125,8 @@ if (__DEV__) { } function pushDispatcher(container) { - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; if (prevDispatcher === null) { // The React isomorphic package does not include a default dispatcher. @@ -26890,20 +27139,20 @@ if (__DEV__) { } function popDispatcher(prevDispatcher) { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } function pushCacheDispatcher() { { - var prevCacheDispatcher = ReactSharedInternals.C; - ReactSharedInternals.C = DefaultCacheDispatcher; + var prevCacheDispatcher = ReactCurrentCache.current; + ReactCurrentCache.current = DefaultCacheDispatcher; return prevCacheDispatcher; } } function popCacheDispatcher(prevCacheDispatcher) { { - ReactSharedInternals.C = prevCacheDispatcher; + ReactCurrentCache.current = prevCacheDispatcher; } } @@ -27330,7 +27579,7 @@ if (__DEV__) { } } - if (true && ReactSharedInternals.actQueue !== null) { + if (true && ReactCurrentActQueue.current !== null) { // `act` special case: If we're inside an `act` scope, don't consult // `shouldYield`. Always keep working until the render is complete. // This is not just an optimization: in a unit test environment, we @@ -27415,9 +27664,7 @@ if (__DEV__) { workInProgress = next; } - { - ReactSharedInternals.owner = null; - } + ReactCurrentOwner.current = null; } function replaySuspendedUnitOfWork(unitOfWork) { @@ -27545,9 +27792,7 @@ if (__DEV__) { workInProgress = next; } - { - ReactSharedInternals.owner = null; - } + ReactCurrentOwner.current = null; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -27757,12 +28002,12 @@ if (__DEV__) { ) { // TODO: This no longer makes any sense. We already wrap the mutation and // layout phases. Should be able to remove. - var prevTransition = ReactSharedInternals.T; var previousUpdateLanePriority = getCurrentUpdatePriority(); + var prevTransition = ReactCurrentBatchConfig.transition; try { + ReactCurrentBatchConfig.transition = null; setCurrentUpdatePriority(DiscreteEventPriority); - ReactSharedInternals.T = null; commitRootImpl( root, recoverableErrors, @@ -27772,7 +28017,7 @@ if (__DEV__) { spawnedLane ); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; setCurrentUpdatePriority(previousUpdateLanePriority); } @@ -27916,16 +28161,14 @@ if (__DEV__) { NoFlags$1; if (subtreeHasEffects || rootHasEffect) { - var prevTransition = ReactSharedInternals.T; - ReactSharedInternals.T = null; + var prevTransition = ReactCurrentBatchConfig.transition; + ReactCurrentBatchConfig.transition = null; var previousPriority = getCurrentUpdatePriority(); setCurrentUpdatePriority(DiscreteEventPriority); var prevExecutionContext = executionContext; executionContext |= CommitContext; // Reset this to null before calling lifecycles - { - ReactSharedInternals.owner = null; - } // The commit phase is broken into several sub-phases. We do a separate pass + ReactCurrentOwner.current = null; // The commit phase is broken into several sub-phases. We do a separate pass // of the effect list for each phase: all mutation effects come before all // layout effects, and so on. // The first phase a "before mutation" phase. We use this phase to read the @@ -27976,7 +28219,7 @@ if (__DEV__) { executionContext = prevExecutionContext; // Reset the priority to the previous non-sync value. setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; } else { // No effects. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were @@ -28166,16 +28409,16 @@ if (__DEV__) { pendingPassiveEffectsRemainingLanes = NoLanes; var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes); var priority = lowerEventPriority(DefaultEventPriority, renderPriority); - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig.transition; var previousPriority = getCurrentUpdatePriority(); try { + ReactCurrentBatchConfig.transition = null; setCurrentUpdatePriority(priority); - ReactSharedInternals.T = null; return flushPassiveEffectsImpl(); } finally { setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; // Once passive effects have run for the tree - giving components a + ReactCurrentBatchConfig.transition = prevTransition; // Once passive effects have run for the tree - giving components a // chance to retain cache instances they use - release the pooled // cache at the root (if there is one) @@ -28930,7 +29173,7 @@ if (__DEV__) { { // If we're currently inside an `act` scope, bypass Scheduler and push to // the `act` queue instead. - var actQueue = ReactSharedInternals.actQueue; + var actQueue = ReactCurrentActQueue.current; if (actQueue !== null) { actQueue.push(callback); @@ -28943,7 +29186,7 @@ if (__DEV__) { function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. - return ReactSharedInternals.actQueue !== null; + return ReactCurrentActQueue.current !== null; } function warnIfUpdatesNotWrappedWithActDEV(fiber) { @@ -28977,7 +29220,7 @@ if (__DEV__) { } } - if (ReactSharedInternals.actQueue === null) { + if (ReactCurrentActQueue.current === null) { var previousFiber = current; try { @@ -29012,7 +29255,7 @@ if (__DEV__) { if ( root.tag !== LegacyRoot && isConcurrentActEnvironment() && - ReactSharedInternals.actQueue === null + ReactCurrentActQueue.current === null ) { error( "A suspended resource finished loading inside a test, but the event " + @@ -29221,12 +29464,13 @@ if (__DEV__) { var staleFamilies = update.staleFamilies, updatedFamilies = update.updatedFamilies; flushPassiveEffects(); - scheduleFibersWithFamiliesRecursively( - root.current, - updatedFamilies, - staleFamilies - ); - flushSyncWork(); + flushSync(function () { + scheduleFibersWithFamiliesRecursively( + root.current, + updatedFamilies, + staleFamilies + ); + }); } }; var scheduleRoot = function (root, element) { @@ -29238,8 +29482,10 @@ if (__DEV__) { return; } - updateContainerSync(element, root, null, null); - flushSyncWork(); + flushPassiveEffects(); + flushSync(function () { + updateContainer(element, root, null, null); + }); } }; @@ -29970,7 +30216,7 @@ if (__DEV__) { "named imports."; } - var ownerName = owner ? getComponentNameFromOwner(owner) : null; + var ownerName = owner ? getComponentNameFromFiber(owner) : null; if (ownerName) { info += "\n\nCheck the render method of `" + ownerName + "`."; @@ -30365,40 +30611,14 @@ if (__DEV__) { null ); } - function updateContainerSync( - element, - container, - parentComponent, - callback - ) { - if (container.tag === LegacyRoot) { - flushPassiveEffects(); - } - - var current = container.current; - updateContainerImpl( - current, - SyncLane, - element, - container, - parentComponent, - callback - ); - return SyncLane; - } - - function updateContainerImpl( - rootFiber, - lane, - element, - container, - parentComponent, - callback - ) { + function updateContainer(element, container, parentComponent, callback) { { onScheduleRoot(container, element); } + var current$1 = container.current; + var lane = requestUpdateLane(current$1); + if (enableSchedulingProfiler) { markRenderScheduled(lane); } @@ -30447,12 +30667,14 @@ if (__DEV__) { update.callback = callback; } - var root = enqueueUpdate(rootFiber, update, lane); + var root = enqueueUpdate(current$1, update, lane); if (root !== null) { - scheduleUpdateOnFiber(root, rootFiber, lane); - entangleTransitions(root, rootFiber, lane); + scheduleUpdateOnFiber(root, current$1, lane); + entangleTransitions(root, current$1, lane); } + + return lane; } var shouldErrorImpl = function (fiber) { @@ -30726,6 +30948,7 @@ if (__DEV__) { function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; return injectInternals({ bundleType: devToolsConfig.bundleType, version: devToolsConfig.version, @@ -30740,7 +30963,7 @@ if (__DEV__) { setErrorHandler: setErrorHandler, setSuspenseHandler: setSuspenseHandler, scheduleUpdate: scheduleUpdate, - currentDispatcherRef: ReactSharedInternals, + currentDispatcherRef: ReactCurrentDispatcher, findHostInstanceByFiber: findHostInstanceByFiber, findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance, @@ -30818,6 +31041,8 @@ if (__DEV__) { var _proto4 = Surface.prototype; _proto4.componentDidMount = function componentDidMount() { + var _this = this; + var _this$props = this.props, height = _this$props.height, width = _this$props.width; @@ -30832,14 +31057,17 @@ if (__DEV__) { ); // We synchronously flush updates coming from above so that they commit together // and so that refs resolve before the parent life cycles. - updateContainerSync(this.props.children, this._mountNode, this); - flushSyncWork(); + flushSync(function () { + updateContainer(_this.props.children, _this._mountNode, _this); + }); }; _proto4.componentDidUpdate = function componentDidUpdate( prevProps, prevState ) { + var _this2 = this; + var props = this.props; if ( @@ -30850,8 +31078,9 @@ if (__DEV__) { } // We synchronously flush updates coming from above so that they commit together // and so that refs resolve before the parent life cycles. - updateContainerSync(this.props.children, this._mountNode, this); - flushSyncWork(); + flushSync(function () { + updateContainer(_this2.props.children, _this2._mountNode, _this2); + }); if (this._surface.render) { this._surface.render(); @@ -30859,14 +31088,17 @@ if (__DEV__) { }; _proto4.componentWillUnmount = function componentWillUnmount() { + var _this3 = this; + // We synchronously flush updates coming from above so that they commit together // and so that refs resolve before the parent life cycles. - updateContainerSync(null, this._mountNode, this); - flushSyncWork(); + flushSync(function () { + updateContainer(null, _this3._mountNode, _this3); + }); }; _proto4.render = function render() { - var _this = this; + var _this4 = this; // This is going to be a placeholder because we don't know what it will // actually resolve to because ART may render canvas, vml or svg tags here. @@ -30877,7 +31109,7 @@ if (__DEV__) { var Tag = Mode$1.Surface.tagName; return /*#__PURE__*/ React.createElement(Tag, { ref: function (ref) { - return (_this._tagRef = ref); + return (_this4._tagRef = ref); }, accessKey: props.accessKey, className: props.className, @@ -30896,25 +31128,25 @@ if (__DEV__) { _inheritsLoose(Text, _React$Component2); function Text(props) { - var _this2; + var _this5; - _this2 = _React$Component2.call(this, props) || this; // We allow reading these props. Ideally we could expose the Text node as + _this5 = _React$Component2.call(this, props) || this; // We allow reading these props. Ideally we could expose the Text node as // ref directly. ["height", "width", "x", "y"].forEach(function (key) { - Object.defineProperty(_assertThisInitialized(_this2), key, { + Object.defineProperty(_assertThisInitialized(_this5), key, { get: function () { return this._text ? this._text[key] : undefined; } }); }); - return _this2; + return _this5; } var _proto5 = Text.prototype; _proto5.render = function render() { - var _this3 = this; + var _this6 = this; // This means you can't have children that render into strings... var T = TYPES.TEXT; @@ -30922,7 +31154,7 @@ if (__DEV__) { T, _extends({}, this.props, { ref: function (t) { - return (_this3._text = t); + return (_this6._text = t); } }), childrenAsString(this.props.children) diff --git a/compiled/facebook-www/ReactART-dev.modern.js b/compiled/facebook-www/ReactART-dev.modern.js index 2e604c3730..231de1c158 100644 --- a/compiled/facebook-www/ReactART-dev.modern.js +++ b/compiled/facebook-www/ReactART-dev.modern.js @@ -66,7 +66,7 @@ if (__DEV__) { return self; } - var ReactVersion = "19.0.0-www-modern-2b9608d3"; + var ReactVersion = "19.0.0-www-modern-ab20b5da"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -120,10 +120,12 @@ if (__DEV__) { var React = require("react"); var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; // Defensive in case this is fired before React is initialized. + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Defensive in case this is fired before React is initialized. if (ReactSharedInternals != null) { - var stack = ReactSharedInternals.getStackAddendum(); + var ReactDebugCurrentFrame = + ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { format += "%s"; @@ -156,7 +158,7 @@ if (__DEV__) { } var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Re-export dynamic flags from the www version. var dynamicFeatureFlags = require("ReactFeatureFlags"); @@ -409,17 +411,6 @@ if (__DEV__) { return type.displayName || "Context"; } - function getComponentNameFromOwner(owner) { - if (typeof owner.tag === "number") { - return getComponentNameFromFiber(owner); - } - - if (typeof owner.name === "string") { - return owner.name; - } - - return null; - } function getComponentNameFromFiber(fiber) { var tag = fiber.tag, type = fiber.type; @@ -588,7 +579,6 @@ if (__DEV__) { var ScheduleRetry = StoreConsistency; var ShouldSuspendCommit = Visibility; var DidDefer = ContentReset; - var FormReset = Snapshot; var HostEffectMask = /* */ @@ -656,8 +646,7 @@ if (__DEV__) { ContentReset | Ref | Hydrating | - Visibility | - FormReset; + Visibility; var LayoutMask = Update | Callback | Ref | Visibility; // TODO: Split into PassiveMountMask and PassiveUnmountMask var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that don't get reset on clones. @@ -667,6 +656,7 @@ if (__DEV__) { var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; + var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { var node = fiber; var nearestMounted = fiber; @@ -705,7 +695,7 @@ if (__DEV__) { } function isMounted(component) { { - var owner = ReactSharedInternals.owner; + var owner = ReactCurrentOwner$2.current; if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; @@ -2572,11 +2562,17 @@ if (__DEV__) { } } - var NoEventPriority = NoLane; var DiscreteEventPriority = SyncLane; var ContinuousEventPriority = InputContinuousLane; var DefaultEventPriority = DefaultLane; var IdleEventPriority = IdleLane; + var currentUpdatePriority = NoLane; + function getCurrentUpdatePriority() { + return currentUpdatePriority; + } + function setCurrentUpdatePriority(newPriority) { + currentUpdatePriority = newPriority; + } function higherEventPriority(a, b) { return a !== 0 && a < b ? a : b; } @@ -2586,9 +2582,6 @@ if (__DEV__) { function isHigherEventPriority(a, b) { return a !== 0 && a < b; } - function eventPriorityToLane(updatePriority) { - return updatePriority; - } function lanesToEventPriority(lanes) { var lane = getHighestPriorityLane(lanes); @@ -2954,15 +2947,8 @@ if (__DEV__) { typeof props.children === "string" || typeof props.children === "number" ); } - var currentUpdatePriority = NoEventPriority; - function setCurrentUpdatePriority(newPriority) { - currentUpdatePriority = newPriority; - } - function getCurrentUpdatePriority() { - return currentUpdatePriority; - } - function resolveUpdatePriority() { - return currentUpdatePriority || DefaultEventPriority; + function getCurrentEventPriority() { + return DefaultEventPriority; } function shouldAttemptEagerTransition() { return false; @@ -3366,8 +3352,9 @@ if (__DEV__) { } } + var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher; var prefix; - function describeBuiltInComponentFrame(name) { + function describeBuiltInComponentFrame(name, ownerFn) { { if (prefix === undefined) { // Extract the VM specific prefix used by each line. @@ -3424,13 +3411,13 @@ if (__DEV__) { var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. Error.prepareStackTrace = undefined; - var previousDispatcher = null; + var previousDispatcher; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + previousDispatcher = ReactCurrentDispatcher$2.current; // Set the dispatcher in DEV because this might be call in the render function // for warnings. - ReactSharedInternals.H = null; + ReactCurrentDispatcher$2.current = null; disableLogs(); } /** @@ -3623,7 +3610,7 @@ if (__DEV__) { reentry = false; { - ReactSharedInternals.H = previousDispatcher; + ReactCurrentDispatcher$2.current = previousDispatcher; reenableLogs(); } @@ -3642,12 +3629,12 @@ if (__DEV__) { return syntheticFrame; } - function describeClassComponentFrame(ctor) { + function describeClassComponentFrame(ctor, ownerFn) { { return describeNativeComponentFrame(ctor, true); } } - function describeFunctionComponentFrame(fn) { + function describeFunctionComponentFrame(fn, ownerFn) { { return describeNativeComponentFrame(fn, false); } @@ -4844,6 +4831,7 @@ if (__DEV__) { } } + var ReactCurrentActQueue$4 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, // there's only a single root, but we do support multi root apps, hence this // extra complexity. But this module is optimized for the single root case. @@ -4882,7 +4870,7 @@ if (__DEV__) { mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure // there's a task scheduled for each one at the correct priority. - if (ReactSharedInternals.actQueue !== null) { + if (ReactCurrentActQueue$4.current !== null) { // We're inside an `act` scope. if (!didScheduleMicrotask_act) { didScheduleMicrotask_act = true; @@ -5084,7 +5072,7 @@ if (__DEV__) { // Scheduler task, rather than an `act` task, cancel it and re-schedule // on the `act` queue. !( - ReactSharedInternals.actQueue !== null && + ReactCurrentActQueue$4.current !== null && existingCallbackNode !== fakeActCallbackNode$1 ) ) { @@ -5151,11 +5139,11 @@ if (__DEV__) { var fakeActCallbackNode$1 = {}; function scheduleCallback$2(priorityLevel, callback) { - if (ReactSharedInternals.actQueue !== null) { + if (ReactCurrentActQueue$4.current !== null) { // Special case: We're inside an `act` scope (a testing utility). // Instead of scheduling work in the host environment, add it to a // fake internal queue that's managed by the `act` implementation. - ReactSharedInternals.actQueue.push(callback); + ReactCurrentActQueue$4.current.push(callback); return fakeActCallbackNode$1; } else { return scheduleCallback$3(priorityLevel, callback); @@ -5170,13 +5158,13 @@ if (__DEV__) { } function scheduleImmediateTask(cb) { - if (ReactSharedInternals.actQueue !== null) { + if (ReactCurrentActQueue$4.current !== null) { // Special case: Inside an `act` scope, we push microtasks to the fake `act` // callback queue. This is because we currently support calling `act` // without awaiting the result. The plan is to deprecate that, and require // that you always await the result so that the microtasks have a chance to // run. But it hasn't happened yet. - ReactSharedInternals.actQueue.push(function () { + ReactCurrentActQueue$4.current.push(function () { cb(); return null; }); @@ -5968,6 +5956,7 @@ if (__DEV__) { return true; } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var current = null; var isRendering = false; function getCurrentFiberOwnerNameInDevOrNull() { @@ -5978,8 +5967,8 @@ if (__DEV__) { var owner = current._debugOwner; - if (owner != null) { - return getComponentNameFromOwner(owner); + if (owner !== null && typeof owner !== "undefined") { + return getComponentNameFromFiber(owner); } } @@ -5999,14 +5988,14 @@ if (__DEV__) { function resetCurrentFiber() { { - ReactSharedInternals.getCurrentStack = null; + ReactDebugCurrentFrame.getCurrentStack = null; current = null; isRendering = false; } } function setCurrentFiber(fiber) { { - ReactSharedInternals.getCurrentStack = + ReactDebugCurrentFrame.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev; current = fiber; isRendering = false; @@ -6381,6 +6370,83 @@ if (__DEV__) { }; } + /* + * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol + * and Temporal.* types. See https://github.com/facebook/react/pull/22064. + * + * The functions in this module will throw an easier-to-understand, + * easier-to-debug exception with a clear errors message message explaining the + * problem. (Instead of a confusing exception thrown inside the implementation + * of the `value` object). + */ + // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible. + function typeName(value) { + { + // toStringTag is needed for namespaced types like Temporal.Instant + var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag; + var type = + (hasToStringTag && value[Symbol.toStringTag]) || + value.constructor.name || + "Object"; // $FlowFixMe[incompatible-return] + + return type; + } + } // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible. + + function willCoercionThrow(value) { + { + try { + testStringCoercion(value); + return false; + } catch (e) { + return true; + } + } + } + + function testStringCoercion(value) { + // If you ended up here by following an exception call stack, here's what's + // happened: you supplied an object or symbol value to React (as a prop, key, + // DOM attribute, CSS property, string ref, etc.) and when React tried to + // coerce it to a string using `'' + value`, an exception was thrown. + // + // The most common types that will cause this exception are `Symbol` instances + // and Temporal objects like `Temporal.Instant`. But any object that has a + // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this + // exception. (Library authors do this to prevent users from using built-in + // numeric operators like `+` or comparison operators like `>=` because custom + // methods are needed to perform accurate arithmetic or comparison.) + // + // To fix the problem, coerce this object or symbol value to a string before + // passing it to React. The most reliable way is usually `String(value)`. + // + // To find which value is throwing, check the browser or debugger console. + // Before this exception was thrown, there should be `console.error` output + // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the + // problem and how that type was used: key, atrribute, input value prop, etc. + // In most cases, this console output also shows the component and its + // ancestor components where the exception happened. + // + // eslint-disable-next-line react-internal/safe-string-coercion + return "" + value; + } + function checkPropStringCoercion(value, propName) { + { + if (willCoercionThrow(value)) { + error( + "The provided `%s` prop is an unsupported type %s." + + " This value must be coerced to a string before using it here.", + propName, + typeName(value) + ); + + return testStringCoercion(value); // throw (to help callers find troubleshooting comments) + } + } + } + + var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; + function getThenablesFromState(state) { { var devState = state; @@ -6434,8 +6500,8 @@ if (__DEV__) { function noop() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactSharedInternals.actQueue !== null) { - ReactSharedInternals.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var trackedThenables = getThenablesFromState(thenableState); @@ -6658,6 +6724,7 @@ if (__DEV__) { var didWarnAboutMaps; var didWarnAboutGenerators; + var didWarnAboutStringRefs; var ownerHasKeyUseWarning; var ownerHasFunctionTypeWarning; var ownerHasSymbolTypeWarning; @@ -6667,6 +6734,7 @@ if (__DEV__) { { didWarnAboutMaps = false; didWarnAboutGenerators = false; + didWarnAboutStringRefs = {}; /** * Warn if there's no key explicitly set on dynamic arrays of children or * object keys are not valid. This allows us to keep track of children between @@ -6711,6 +6779,10 @@ if (__DEV__) { }; } + function isReactClass(type) { + return type.prototype && type.prototype.isReactComponent; + } + function unwrapThenable(thenable) { var index = thenableIndexCounter$1; thenableIndexCounter$1 += 1; @@ -6722,22 +6794,159 @@ if (__DEV__) { return trackUsedThenable(thenableState$1, thenable, index); } + function convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef + ) { + { + checkPropStringCoercion(mixedRef, "ref"); + } + + var stringRef = "" + mixedRef; + var owner = element._owner; + + if (!owner) { + throw new Error( + "Element ref was specified as a string (" + + stringRef + + ") but no owner was set. This could happen for one of" + + " the following reasons:\n" + + "1. You may be adding a ref to a function component\n" + + "2. You may be adding a ref to a component that was not created inside a component's render method\n" + + "3. You have multiple copies of React loaded\n" + + "See https://react.dev/link/refs-must-have-owner for more information." + ); + } + + if (owner.tag !== ClassComponent) { + throw new Error( + "Function components cannot have string refs. " + + "We recommend using useRef() instead. " + + "Learn more about using refs safely here: " + + "https://react.dev/link/strict-mode-string-ref" + ); + } + + { + if ( + // Will already warn with "Function components cannot be given refs" + !(typeof element.type === "function" && !isReactClass(element.type)) + ) { + var componentName = + getComponentNameFromFiber(returnFiber) || "Component"; + + if (!didWarnAboutStringRefs[componentName]) { + error( + 'Component "%s" contains the string ref "%s". Support for string refs ' + + "will be removed in a future major release. We recommend using " + + "useRef() or createRef() instead. " + + "Learn more about using refs safely here: " + + "https://react.dev/link/strict-mode-string-ref", + componentName, + stringRef + ); + + didWarnAboutStringRefs[componentName] = true; + } + } + } + + var inst = owner.stateNode; + + if (!inst) { + throw new Error( + "Missing owner for string ref " + + stringRef + + ". This error is likely caused by a " + + "bug in React. Please file an issue." + ); + } // Check if previous string ref matches new string ref + + if ( + current !== null && + current.ref !== null && + typeof current.ref === "function" && + current.ref._stringRef === stringRef + ) { + // Reuse the existing string ref + var currentRef = current.ref; + return currentRef; + } // Create a new string ref + + var ref = function (value) { + var refs = inst.refs; + + if (value === null) { + delete refs[stringRef]; + } else { + refs[stringRef] = value; + } + }; + + ref._stringRef = stringRef; + return ref; + } + function coerceRef(returnFiber, current, workInProgress, element) { - var ref; + var mixedRef; if (enableRefAsProp) { // TODO: This is a temporary, intermediate step. When enableRefAsProp is on, // we should resolve the `ref` prop during the begin phase of the component // it's attached to (HostComponent, ClassComponent, etc). var refProp = element.props.ref; - ref = refProp !== undefined ? refProp : null; + mixedRef = refProp !== undefined ? refProp : null; } else { // Old behavior. - ref = element.ref; + mixedRef = element.ref; + } + + var coercedRef; + + if ( + typeof mixedRef === "string" || + typeof mixedRef === "number" || + typeof mixedRef === "boolean" + ) { + coercedRef = convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef + ); + + if (enableRefAsProp) { + // When enableRefAsProp is on, we should always use the props as the + // source of truth for refs. Not a field on the fiber. + // + // In the case of string refs, this presents a problem, because string + // refs are not passed around internally as strings; they are converted to + // callback refs. The ref used by the reconciler is not the same as the + // one the user provided. + // + // But since this is a deprecated feature anyway, what we can do is clone + // the props object and replace it with the internal callback ref. Then we + // can continue to use the props object as the source of truth. + // + // This means the internal callback ref will leak into userspace. The + // receiving component will receive a callback ref even though the parent + // passed a string. Which is weird, but again, this is a deprecated + // feature, and we're only leaving it around behind a flag so that Meta + // can keep using string refs temporarily while they finish migrating + // their codebase. + var userProvidedProps = workInProgress.pendingProps; + var propsWithInternalCallbackRef = assign({}, userProvidedProps); + propsWithInternalCallbackRef.ref = coercedRef; + workInProgress.pendingProps = propsWithInternalCallbackRef; + } + } else { + coercedRef = mixedRef; } // TODO: If enableRefAsProp is on, we shouldn't use the `ref` field. We // should always read the ref from the prop. - workInProgress.ref = ref; + workInProgress.ref = coercedRef; } function throwOnInvalidObjectType(returnFiber, newChild) { @@ -8556,6 +8765,8 @@ if (__DEV__) { /* */ 8; + var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; var didWarnUncachedGetSnapshot; var didWarnAboutUseWrappedInTryCatch; @@ -8719,8 +8930,8 @@ if (__DEV__) { didWarnAboutUseFormState.add(componentName); error( - "ReactDOM.useFormState has been renamed to React.useActionState. " + - "Please update %s to use React.useActionState.", + "ReactDOM.useFormState has been deprecated and replaced by " + + "React.useActionState. Please update %s to use React.useActionState.", componentName ); } @@ -8856,16 +9067,17 @@ if (__DEV__) { { if (current !== null && current.memoizedState !== null) { - ReactSharedInternals.H = HooksDispatcherOnUpdateInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, // but no stateful hooks have been used. // We want to match the production code behavior (which will use HooksDispatcherOnMount), // but with the extra DEV validation to ensure hooks ordering hasn't changed. // This dispatcher does that. - ReactSharedInternals.H = HooksDispatcherOnMountWithHookTypesInDEV; + ReactCurrentDispatcher$1.current = + HooksDispatcherOnMountWithHookTypesInDEV; } else { - ReactSharedInternals.H = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; } } // In Strict Mode, during development, user functions are double invoked to // help detect side effects. The logic for how this is implemented for in @@ -8937,7 +9149,7 @@ if (__DEV__) { } // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrance. - ReactSharedInternals.H = ContextOnlyDispatcher; // This check uses currentHook so that it works the same in DEV and prod bundles. + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; // This check uses currentHook so that it works the same in DEV and prod bundles. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = @@ -9110,7 +9322,7 @@ if (__DEV__) { hookTypesUpdateIndexDev = -1; } - ReactSharedInternals.H = HooksDispatcherOnRerenderInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV; children = Component(props, secondArg); } while (didScheduleRenderPhaseUpdateDuringThisPass); @@ -9132,34 +9344,18 @@ if (__DEV__) { ); } function TransitionAwareHostComponent() { - var dispatcher = ReactSharedInternals.H; + var dispatcher = ReactCurrentDispatcher$1.current; var _dispatcher$useState = dispatcher.useState(), maybeThenable = _dispatcher$useState[0]; - var nextState; - if (typeof maybeThenable.then === "function") { var thenable = maybeThenable; - nextState = useThenable(thenable); + return useThenable(thenable); } else { var status = maybeThenable; - nextState = status; - } // The "reset state" is an object. If it changes, that means something - // requested that we reset the form. - - var _dispatcher$useState2 = dispatcher.useState(), - nextResetState = _dispatcher$useState2[0]; - - var prevResetState = - currentHook !== null ? currentHook.memoizedState : null; - - if (prevResetState !== nextResetState) { - // Schedule a form reset - currentlyRenderingFiber$1.flags |= FormReset; + return status; } - - return nextState; } function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; // TODO: Don't need to reset the flags here, because they're reset in the @@ -9188,7 +9384,7 @@ if (__DEV__) { currentlyRenderingFiber$1 = null; // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrance. - ReactSharedInternals.H = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; } function resetHooksOnUnwind(workInProgress) { if (didScheduleRenderPhaseUpdate) { @@ -9361,7 +9557,7 @@ if (__DEV__) { // time (perhaps because it threw). Subsequent Hook calls should use the // mount dispatcher. { - ReactSharedInternals.H = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; } } @@ -10170,14 +10366,14 @@ if (__DEV__) { var action = actionQueue.action; var prevState = actionQueue.state; // This is a fork of startTransition - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig$2.transition; var currentTransition = { _callbacks: new Set() }; - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$2.transition = currentTransition; { - ReactSharedInternals.T._updatedFibers = new Set(); + ReactCurrentBatchConfig$2.transition._updatedFibers = new Set(); } // Optimistically update the pending state, similar to useTransition. // This will be reverted automatically when all actions are finished. @@ -10235,7 +10431,7 @@ if (__DEV__) { setState(rejectedThenable); finishRunningActionStateAction(actionQueue, setPendingState, setState); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$2.transition = prevTransition; { if (prevTransition === null && currentTransition._updatedFibers) { @@ -10877,7 +11073,7 @@ if (__DEV__) { setCurrentUpdatePriority( higherEventPriority(previousPriority, ContinuousEventPriority) ); - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig$2.transition; var currentTransition = { _callbacks: new Set() }; @@ -10889,19 +11085,19 @@ if (__DEV__) { // optimistic update anyway to make it less likely the behavior accidentally // diverges; for example, both an optimistic update and this one should // share the same lane. - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$2.transition = currentTransition; dispatchOptimisticSetState(fiber, false, queue, pendingState); } if (enableTransitionTracing) { if (options !== undefined && options.name !== undefined) { - currentTransition.name = options.name; - currentTransition.startTime = now$1(); + ReactCurrentBatchConfig$2.transition.name = options.name; + ReactCurrentBatchConfig$2.transition.startTime = now$1(); } } { - currentTransition._updatedFibers = new Set(); + ReactCurrentBatchConfig$2.transition._updatedFibers = new Set(); } try { @@ -10947,7 +11143,7 @@ if (__DEV__) { } } finally { setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$2.transition = prevTransition; { if (prevTransition === null && currentTransition._updatedFibers) { @@ -11169,11 +11365,11 @@ if (__DEV__) { var lastRenderedReducer = queue.lastRenderedReducer; if (lastRenderedReducer !== null) { - var prevDispatcher = null; + var prevDispatcher; { - prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = + prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } @@ -11204,7 +11400,7 @@ if (__DEV__) { // Suppress the error. It will throw again in the render phase. } finally { { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } } } @@ -11478,25 +11674,27 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; mountHookTypesDev(); checkDepsAreArrayDev(deps); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -11507,13 +11705,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -11644,25 +11843,27 @@ if (__DEV__) { useMemo: function (create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -11673,13 +11874,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -11802,25 +12004,27 @@ if (__DEV__) { useMemo: function (create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -11831,13 +12035,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -11969,25 +12174,27 @@ if (__DEV__) { useMemo: function (create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnRerenderInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -11998,13 +12205,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -12147,26 +12355,28 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -12179,13 +12389,14 @@ if (__DEV__) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -12332,26 +12543,28 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -12364,13 +12577,14 @@ if (__DEV__) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -12517,26 +12731,28 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -12549,13 +12765,14 @@ if (__DEV__) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -13987,20 +14204,7 @@ if (__DEV__) { // remove this extra check. alreadyResolvedDefaultProps ) { - var newProps = baseProps; - - if (enableRefAsProp) { - // Remove ref from the props object, if it exists. - if ("ref" in baseProps) { - newProps = {}; - - for (var propName in baseProps) { - if (propName !== "ref") { - newProps[propName] = baseProps[propName]; - } - } - } - } // Resolve default props. + var newProps = baseProps; // Resolve default props. Taken from old JSX runtime, where this used to live. var defaultProps = Component.defaultProps; @@ -14009,19 +14213,26 @@ if (__DEV__) { // default props here in the reconciler, rather than in the JSX runtime. (disableDefaultPropsExceptForClasses || !alreadyResolvedDefaultProps) ) { - // We may have already copied the props object above to remove ref. If so, - // we can modify that. Otherwise, copy the props object with Object.assign. - if (newProps === baseProps) { - newProps = assign({}, newProps, baseProps); - } // Taken from old JSX runtime, where this used to live. + newProps = assign({}, newProps, baseProps); - for (var _propName in defaultProps) { - if (newProps[_propName] === undefined) { - newProps[_propName] = defaultProps[_propName]; + for (var propName in defaultProps) { + if (newProps[propName] === undefined) { + newProps[propName] = defaultProps[propName]; } } } + if (enableRefAsProp) { + // Remove ref from the props object, if it exists. + if ("ref" in newProps) { + if (newProps === baseProps) { + newProps = assign({}, newProps); + } + + delete newProps.ref; + } + } + return newProps; } @@ -14087,6 +14298,8 @@ if (__DEV__) { console["error"](error); }; + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API + var componentName = null; var errorBoundaryName = null; function logUncaughtError(root, errorInfo) { @@ -14100,10 +14313,10 @@ if (__DEV__) { var error = errorInfo.value; - if (true && ReactSharedInternals.actQueue !== null) { + if (true && ReactCurrentActQueue$2.current !== null) { // For uncaught errors inside act, we track them on the act and then // rethrow them into the test. - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue$2.thrownErrors.push(error); return; } @@ -14782,6 +14995,7 @@ if (__DEV__) { return null; } + var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; // A special exception that's used to unwind the stack when an update flows // into a dehydrated boundary. var SelectiveHydrationException = new Error( @@ -14914,7 +15128,7 @@ if (__DEV__) { } { - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); nextChildren = renderWithHooks( current, @@ -15555,7 +15769,7 @@ if (__DEV__) { } { - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); nextChildren = renderWithHooks( current, @@ -15770,10 +15984,7 @@ if (__DEV__) { var instance = workInProgress.stateNode; // Rerender - { - ReactSharedInternals.owner = workInProgress; - } - + ReactCurrentOwner$1.current = workInProgress; var nextChildren; if ( @@ -17476,7 +17687,7 @@ if (__DEV__) { var newChildren; { - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); newChildren = render(newValue); setIsRendering(false); @@ -18929,8 +19140,10 @@ if (__DEV__) { popProvider(CacheContext, workInProgress); } + var ReactCurrentBatchConfig$1 = + ReactSharedInternals.ReactCurrentBatchConfig; function requestCurrentTransition() { - var transition = ReactSharedInternals.T; + var transition = ReactCurrentBatchConfig$1.transition; if (transition !== null) { // Whenever a transition update is scheduled, register a callback on the @@ -20650,7 +20863,7 @@ if (__DEV__) { // Allows us to avoid traversing the return path to find the nearest Offscreen ancestor. var offscreenSubtreeIsHidden = false; - var offscreenSubtreeWasHidden = false; // Used to track if a form needs to be reset at the end of the mutation phase. + var offscreenSubtreeWasHidden = false; var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; var nextEffect = null; // Used for Profiling builds to track updaters. @@ -22976,19 +23189,6 @@ if (__DEV__) { } } } - - if (flags & FormReset) { - { - if (finishedWork.type !== "form") { - // Paranoid coding. In case we accidentally start using the - // FormReset bit for something else. - error( - "Unexpected host component type. Expected a form. This is a " + - "bug in React." - ); - } - } - } } return; @@ -24759,6 +24959,7 @@ if (__DEV__) { symbolFor("selector.text"); } + var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; function isConcurrentActEnvironment() { { var isReactActEnvironmentGlobal = // $FlowFixMe[cannot-resolve-name] Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global @@ -24768,7 +24969,7 @@ if (__DEV__) { if ( !isReactActEnvironmentGlobal && - ReactSharedInternals.actQueue !== null + ReactCurrentActQueue$1.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -24782,9 +24983,17 @@ if (__DEV__) { } var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentCache = ReactSharedInternals.ReactCurrentCache, + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner, + ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, + ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue; var NoContext = /* */ 0; + var BatchedContext = + /* */ + 1; var RenderContext = /* */ 2; @@ -25075,11 +25284,13 @@ if (__DEV__) { if (transition !== null) { { - if (!transition._updatedFibers) { - transition._updatedFibers = new Set(); + var batchConfigTransition = ReactCurrentBatchConfig.transition; + + if (!batchConfigTransition._updatedFibers) { + batchConfigTransition._updatedFibers = new Set(); } - transition._updatedFibers.add(fiber); + batchConfigTransition._updatedFibers.add(fiber); } var actionScopeLane = peekEntangledActionLane(); @@ -25088,9 +25299,26 @@ if (__DEV__) { : // is the first update in that scope. Either way, we need to get a // fresh transition lane. requestTransitionLane(); - } + } // Updates originating inside certain React methods, like flushSync, have + // their priority set by tracking it with a context variable. + // + // The opaque type returned by the host config is internally a lane, so we can + // use that directly. + // TODO: Move this type conversion to the event priority module. - return eventPriorityToLane(resolveUpdatePriority()); + var updateLane = getCurrentUpdatePriority(); + + if (updateLane !== NoLane) { + return updateLane; + } // This update originated outside React. Ask the host environment for an + // appropriate priority, based on the type of event. + // + // The opaque type returned by the host config is internally a lane, so we can + // use that directly. + // TODO: Move this type conversion to the event priority module. + + var eventLane = getCurrentEventPriority(); + return eventLane; } function requestRetryLane(fiber) { @@ -25191,13 +25419,12 @@ if (__DEV__) { warnIfUpdatesNotWrappedWithActDEV(fiber); if (enableTransitionTracing) { - var transition = ReactSharedInternals.T; + var transition = ReactCurrentBatchConfig.transition; if (transition !== null && transition.name != null) { if (transition.startTime === -1) { transition.startTime = now$1(); - } // $FlowFixMe[prop-missing]: The BatchConfigTransition and Transition types are incompatible but was previously untyped and thus uncaught - // $FlowFixMe[incompatible-call]: " + } addTransitionToLanesMap(root, transition, lane); } @@ -25236,7 +25463,7 @@ if (__DEV__) { !disableLegacyMode && (fiber.mode & ConcurrentMode) === NoMode ) { - if (ReactSharedInternals.isBatchingLegacy); + if (ReactCurrentActQueue.isBatchingLegacy); else { // Flush the synchronous work now, unless we're already working or inside // a batch. This is intentionally inside scheduleUpdateOnFiber instead of @@ -25337,31 +25564,20 @@ if (__DEV__) { } // Check if something threw if (exitStatus === RootErrored) { - var lanesThatJustErrored = lanes; + var originallyAttemptedLanes = lanes; var errorRetryLanes = getLanesToRetrySynchronouslyOnError( root, - lanesThatJustErrored + originallyAttemptedLanes ); if (errorRetryLanes !== NoLanes) { lanes = errorRetryLanes; exitStatus = recoverFromConcurrentError( root, - lanesThatJustErrored, + originallyAttemptedLanes, errorRetryLanes ); - renderWasConcurrent = false; // Need to check the exit status again. - - if (exitStatus !== RootErrored) { - // The root did not error this time. Restart the exit algorithm - // from the beginning. - // TODO: Refactor the exit algorithm to be less confusing. Maybe - // more branches + recursion instead of a loop. I think the only - // thing that causes it to be a loop is the RootDidNotComplete - // check. If that's true, then we don't need a loop/recursion - // at all. - continue; - } + renderWasConcurrent = false; } } @@ -25802,15 +26018,51 @@ if (__DEV__) { function getExecutionContext() { return executionContext; } - // Returns whether the the call was during a render or not + // Warning, this opts-out of checking the function body. + // eslint-disable-next-line no-unused-vars + // eslint-disable-next-line no-redeclare + // eslint-disable-next-line no-redeclare - function flushSyncWork() { - if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncWorkOnAllRoots(); - return false; + function flushSync(fn) { + // In legacy mode, we flush pending passive effects at the beginning of the + // next event, not at the end of the previous one. + if ( + rootWithPendingPassiveEffects !== null && + !disableLegacyMode && + rootWithPendingPassiveEffects.tag === LegacyRoot && + (executionContext & (RenderContext | CommitContext)) === NoContext + ) { + flushPassiveEffects(); } - return true; + var prevExecutionContext = executionContext; + executionContext |= BatchedContext; + var prevTransition = ReactCurrentBatchConfig.transition; + var previousPriority = getCurrentUpdatePriority(); + + try { + ReactCurrentBatchConfig.transition = null; + setCurrentUpdatePriority(DiscreteEventPriority); + + if (fn) { + return fn(); + } else { + return undefined; + } + } finally { + setCurrentUpdatePriority(previousPriority); + ReactCurrentBatchConfig.transition = prevTransition; + executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. + // Note that this will happen even if batchedUpdates is higher up + // the stack. + + if ( + (executionContext & (RenderContext | CommitContext)) === + NoContext + ) { + flushSyncWorkOnAllRoots(); + } + } } function isInvalidExecutionContextForEventFunction() { // Used to throw if certain APIs are called from the wrong context. @@ -25928,10 +26180,7 @@ if (__DEV__) { // when React is executing user code. resetHooksAfterThrow(); resetCurrentFiber(); - - { - ReactSharedInternals.owner = null; - } + ReactCurrentOwner.current = null; if (thrownValue === SuspenseException) { // This is a special type of exception used for Suspense. For historical @@ -26083,8 +26332,8 @@ if (__DEV__) { } function pushDispatcher(container) { - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; if (prevDispatcher === null) { // The React isomorphic package does not include a default dispatcher. @@ -26097,20 +26346,20 @@ if (__DEV__) { } function popDispatcher(prevDispatcher) { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } function pushCacheDispatcher() { { - var prevCacheDispatcher = ReactSharedInternals.C; - ReactSharedInternals.C = DefaultCacheDispatcher; + var prevCacheDispatcher = ReactCurrentCache.current; + ReactCurrentCache.current = DefaultCacheDispatcher; return prevCacheDispatcher; } } function popCacheDispatcher(prevCacheDispatcher) { { - ReactSharedInternals.C = prevCacheDispatcher; + ReactCurrentCache.current = prevCacheDispatcher; } } @@ -26537,7 +26786,7 @@ if (__DEV__) { } } - if (true && ReactSharedInternals.actQueue !== null) { + if (true && ReactCurrentActQueue.current !== null) { // `act` special case: If we're inside an `act` scope, don't consult // `shouldYield`. Always keep working until the render is complete. // This is not just an optimization: in a unit test environment, we @@ -26622,9 +26871,7 @@ if (__DEV__) { workInProgress = next; } - { - ReactSharedInternals.owner = null; - } + ReactCurrentOwner.current = null; } function replaySuspendedUnitOfWork(unitOfWork) { @@ -26743,9 +26990,7 @@ if (__DEV__) { workInProgress = next; } - { - ReactSharedInternals.owner = null; - } + ReactCurrentOwner.current = null; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -26955,12 +27200,12 @@ if (__DEV__) { ) { // TODO: This no longer makes any sense. We already wrap the mutation and // layout phases. Should be able to remove. - var prevTransition = ReactSharedInternals.T; var previousUpdateLanePriority = getCurrentUpdatePriority(); + var prevTransition = ReactCurrentBatchConfig.transition; try { + ReactCurrentBatchConfig.transition = null; setCurrentUpdatePriority(DiscreteEventPriority); - ReactSharedInternals.T = null; commitRootImpl( root, recoverableErrors, @@ -26970,7 +27215,7 @@ if (__DEV__) { spawnedLane ); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; setCurrentUpdatePriority(previousUpdateLanePriority); } @@ -27114,16 +27359,14 @@ if (__DEV__) { NoFlags$1; if (subtreeHasEffects || rootHasEffect) { - var prevTransition = ReactSharedInternals.T; - ReactSharedInternals.T = null; + var prevTransition = ReactCurrentBatchConfig.transition; + ReactCurrentBatchConfig.transition = null; var previousPriority = getCurrentUpdatePriority(); setCurrentUpdatePriority(DiscreteEventPriority); var prevExecutionContext = executionContext; executionContext |= CommitContext; // Reset this to null before calling lifecycles - { - ReactSharedInternals.owner = null; - } // The commit phase is broken into several sub-phases. We do a separate pass + ReactCurrentOwner.current = null; // The commit phase is broken into several sub-phases. We do a separate pass // of the effect list for each phase: all mutation effects come before all // layout effects, and so on. // The first phase a "before mutation" phase. We use this phase to read the @@ -27174,7 +27417,7 @@ if (__DEV__) { executionContext = prevExecutionContext; // Reset the priority to the previous non-sync value. setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig.transition = prevTransition; } else { // No effects. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were @@ -27361,16 +27604,16 @@ if (__DEV__) { pendingPassiveEffectsRemainingLanes = NoLanes; var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes); var priority = lowerEventPriority(DefaultEventPriority, renderPriority); - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig.transition; var previousPriority = getCurrentUpdatePriority(); try { + ReactCurrentBatchConfig.transition = null; setCurrentUpdatePriority(priority); - ReactSharedInternals.T = null; return flushPassiveEffectsImpl(); } finally { setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; // Once passive effects have run for the tree - giving components a + ReactCurrentBatchConfig.transition = prevTransition; // Once passive effects have run for the tree - giving components a // chance to retain cache instances they use - release the pooled // cache at the root (if there is one) @@ -28061,7 +28304,7 @@ if (__DEV__) { { // If we're currently inside an `act` scope, bypass Scheduler and push to // the `act` queue instead. - var actQueue = ReactSharedInternals.actQueue; + var actQueue = ReactCurrentActQueue.current; if (actQueue !== null) { actQueue.push(callback); @@ -28074,7 +28317,7 @@ if (__DEV__) { function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. - return ReactSharedInternals.actQueue !== null; + return ReactCurrentActQueue.current !== null; } function warnIfUpdatesNotWrappedWithActDEV(fiber) { @@ -28086,7 +28329,7 @@ if (__DEV__) { } } - if (ReactSharedInternals.actQueue === null) { + if (ReactCurrentActQueue.current === null) { var previousFiber = current; try { @@ -28120,7 +28363,7 @@ if (__DEV__) { { if ( isConcurrentActEnvironment() && - ReactSharedInternals.actQueue === null + ReactCurrentActQueue.current === null ) { error( "A suspended resource finished loading inside a test, but the event " + @@ -28329,12 +28572,13 @@ if (__DEV__) { var staleFamilies = update.staleFamilies, updatedFamilies = update.updatedFamilies; flushPassiveEffects(); - scheduleFibersWithFamiliesRecursively( - root.current, - updatedFamilies, - staleFamilies - ); - flushSyncWork(); + flushSync(function () { + scheduleFibersWithFamiliesRecursively( + root.current, + updatedFamilies, + staleFamilies + ); + }); } }; var scheduleRoot = function (root, element) { @@ -28346,8 +28590,10 @@ if (__DEV__) { return; } - updateContainerSync(element, root, null, null); - flushSyncWork(); + flushPassiveEffects(); + flushSync(function () { + updateContainer(element, root, null, null); + }); } }; @@ -29076,7 +29322,7 @@ if (__DEV__) { "named imports."; } - var ownerName = owner ? getComponentNameFromOwner(owner) : null; + var ownerName = owner ? getComponentNameFromFiber(owner) : null; if (ownerName) { info += "\n\nCheck the render method of `" + ownerName + "`."; @@ -29464,40 +29710,14 @@ if (__DEV__) { null ); } - function updateContainerSync( - element, - container, - parentComponent, - callback - ) { - if (container.tag === LegacyRoot) { - flushPassiveEffects(); - } - - var current = container.current; - updateContainerImpl( - current, - SyncLane, - element, - container, - parentComponent, - callback - ); - return SyncLane; - } - - function updateContainerImpl( - rootFiber, - lane, - element, - container, - parentComponent, - callback - ) { + function updateContainer(element, container, parentComponent, callback) { { onScheduleRoot(container, element); } + var current$1 = container.current; + var lane = requestUpdateLane(current$1); + if (enableSchedulingProfiler) { markRenderScheduled(lane); } @@ -29546,12 +29766,14 @@ if (__DEV__) { update.callback = callback; } - var root = enqueueUpdate(rootFiber, update, lane); + var root = enqueueUpdate(current$1, update, lane); if (root !== null) { - scheduleUpdateOnFiber(root, rootFiber, lane); - entangleTransitions(root, rootFiber, lane); + scheduleUpdateOnFiber(root, current$1, lane); + entangleTransitions(root, current$1, lane); } + + return lane; } var shouldErrorImpl = function (fiber) { @@ -29825,6 +30047,7 @@ if (__DEV__) { function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; return injectInternals({ bundleType: devToolsConfig.bundleType, version: devToolsConfig.version, @@ -29839,7 +30062,7 @@ if (__DEV__) { setErrorHandler: setErrorHandler, setSuspenseHandler: setSuspenseHandler, scheduleUpdate: scheduleUpdate, - currentDispatcherRef: ReactSharedInternals, + currentDispatcherRef: ReactCurrentDispatcher, findHostInstanceByFiber: findHostInstanceByFiber, findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance, @@ -29917,6 +30140,8 @@ if (__DEV__) { var _proto4 = Surface.prototype; _proto4.componentDidMount = function componentDidMount() { + var _this = this; + var _this$props = this.props, height = _this$props.height, width = _this$props.width; @@ -29931,14 +30156,17 @@ if (__DEV__) { ); // We synchronously flush updates coming from above so that they commit together // and so that refs resolve before the parent life cycles. - updateContainerSync(this.props.children, this._mountNode, this); - flushSyncWork(); + flushSync(function () { + updateContainer(_this.props.children, _this._mountNode, _this); + }); }; _proto4.componentDidUpdate = function componentDidUpdate( prevProps, prevState ) { + var _this2 = this; + var props = this.props; if ( @@ -29949,8 +30177,9 @@ if (__DEV__) { } // We synchronously flush updates coming from above so that they commit together // and so that refs resolve before the parent life cycles. - updateContainerSync(this.props.children, this._mountNode, this); - flushSyncWork(); + flushSync(function () { + updateContainer(_this2.props.children, _this2._mountNode, _this2); + }); if (this._surface.render) { this._surface.render(); @@ -29958,14 +30187,17 @@ if (__DEV__) { }; _proto4.componentWillUnmount = function componentWillUnmount() { + var _this3 = this; + // We synchronously flush updates coming from above so that they commit together // and so that refs resolve before the parent life cycles. - updateContainerSync(null, this._mountNode, this); - flushSyncWork(); + flushSync(function () { + updateContainer(null, _this3._mountNode, _this3); + }); }; _proto4.render = function render() { - var _this = this; + var _this4 = this; // This is going to be a placeholder because we don't know what it will // actually resolve to because ART may render canvas, vml or svg tags here. @@ -29976,7 +30208,7 @@ if (__DEV__) { var Tag = Mode$1.Surface.tagName; return /*#__PURE__*/ React.createElement(Tag, { ref: function (ref) { - return (_this._tagRef = ref); + return (_this4._tagRef = ref); }, accessKey: props.accessKey, className: props.className, @@ -29995,25 +30227,25 @@ if (__DEV__) { _inheritsLoose(Text, _React$Component2); function Text(props) { - var _this2; + var _this5; - _this2 = _React$Component2.call(this, props) || this; // We allow reading these props. Ideally we could expose the Text node as + _this5 = _React$Component2.call(this, props) || this; // We allow reading these props. Ideally we could expose the Text node as // ref directly. ["height", "width", "x", "y"].forEach(function (key) { - Object.defineProperty(_assertThisInitialized(_this2), key, { + Object.defineProperty(_assertThisInitialized(_this5), key, { get: function () { return this._text ? this._text[key] : undefined; } }); }); - return _this2; + return _this5; } var _proto5 = Text.prototype; _proto5.render = function render() { - var _this3 = this; + var _this6 = this; // This means you can't have children that render into strings... var T = TYPES.TEXT; @@ -30021,7 +30253,7 @@ if (__DEV__) { T, _extends({}, this.props, { ref: function (t) { - return (_this3._text = t); + return (_this6._text = t); } }), childrenAsString(this.props.children) diff --git a/compiled/facebook-www/ReactART-prod.classic.js b/compiled/facebook-www/ReactART-prod.classic.js index 8c16970dbd..13dbf26912 100644 --- a/compiled/facebook-www/ReactART-prod.classic.js +++ b/compiled/facebook-www/ReactART-prod.classic.js @@ -60,7 +60,7 @@ function formatProdErrorMessage(code) { ); } var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, dynamicFeatureFlags = require("ReactFeatureFlags"), enableDebugTracing = dynamicFeatureFlags.enableDebugTracing, enableLazyContextPropagation = @@ -648,6 +648,7 @@ function clearTransitionsForLanes(root, lanes) { lanes &= ~lane; } } +var currentUpdatePriority = 0; function lanesToEventPriority(lanes) { lanes &= -lanes; return 2 < lanes @@ -825,8 +826,7 @@ function shouldSetTextContent(type, props) { "string" === typeof props.children || "number" === typeof props.children ); } -var currentUpdatePriority = 0, - valueStack = [], +var valueStack = [], index = -1; function createCursor(defaultValue) { return { current: defaultValue }; @@ -1770,11 +1770,51 @@ function unwrapThenable(thenable) { null === thenableState$1 && (thenableState$1 = []); return trackUsedThenable(thenableState$1, thenable, index); } +function convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef +) { + function ref(value) { + var refs = inst.refs; + null === value ? delete refs[stringRef] : (refs[stringRef] = value); + } + var stringRef = "" + mixedRef; + returnFiber = element._owner; + if (!returnFiber) throw Error(formatProdErrorMessage(290, stringRef)); + if (1 !== returnFiber.tag) throw Error(formatProdErrorMessage(309)); + var inst = returnFiber.stateNode; + if (!inst) throw Error(formatProdErrorMessage(147, stringRef)); + if ( + null !== current && + null !== current.ref && + "function" === typeof current.ref && + current.ref._stringRef === stringRef + ) + return current.ref; + ref._stringRef = stringRef; + return ref; +} function coerceRef(returnFiber, current, workInProgress, element) { - enableRefAsProp - ? ((returnFiber = element.props.ref), - (returnFiber = void 0 !== returnFiber ? returnFiber : null)) - : (returnFiber = element.ref); + if (enableRefAsProp) { + var mixedRef = element.props.ref; + mixedRef = void 0 !== mixedRef ? mixedRef : null; + } else mixedRef = element.ref; + "string" === typeof mixedRef || + "number" === typeof mixedRef || + "boolean" === typeof mixedRef + ? ((returnFiber = convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef + )), + enableRefAsProp && + ((current = assign({}, workInProgress.pendingProps)), + (current.ref = returnFiber), + (workInProgress.pendingProps = current))) + : (returnFiber = mixedRef); workInProgress.ref = returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { @@ -2539,7 +2579,9 @@ function findFirstSuspended(row) { } return null; } -var renderLanes = 0, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig, + renderLanes = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, @@ -2571,7 +2613,7 @@ function renderWithHooks( workInProgress.memoizedState = null; workInProgress.updateQueue = null; workInProgress.lanes = 0; - ReactSharedInternals.H = + ReactCurrentDispatcher$1.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; @@ -2589,7 +2631,7 @@ function renderWithHooks( return nextRenderLanes; } function finishRenderingHooks(current) { - ReactSharedInternals.H = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; var didRenderTooFewHooks = null !== currentHook && null !== currentHook.next; renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; @@ -2616,22 +2658,16 @@ function renderWithHooksAgain(workInProgress, Component, props, secondArg) { numberOfReRenders += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactSharedInternals.H = HooksDispatcherOnRerender; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; var children = Component(props, secondArg); } while (didScheduleRenderPhaseUpdateDuringThisPass); return children; } function TransitionAwareHostComponent() { - var dispatcher = ReactSharedInternals.H, - maybeThenable = dispatcher.useState()[0]; - maybeThenable = - "function" === typeof maybeThenable.then - ? useThenable(maybeThenable) - : maybeThenable; - dispatcher = dispatcher.useState()[0]; - (null !== currentHook ? currentHook.memoizedState : null) !== dispatcher && - (currentlyRenderingFiber$1.flags |= 1024); - return maybeThenable; + var maybeThenable = ReactCurrentDispatcher$1.current.useState()[0]; + return "function" === typeof maybeThenable.then + ? useThenable(maybeThenable) + : maybeThenable; } function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; @@ -2717,7 +2753,7 @@ function useThenable(thenable) { (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState : null === workInProgressHook.next) && - (ReactSharedInternals.H = HooksDispatcherOnMount); + (ReactCurrentDispatcher$1.current = HooksDispatcherOnMount); return thenable; } function use(usable) { @@ -3010,9 +3046,9 @@ function dispatchActionState( function runActionStateAction(actionQueue, setPendingState, setState, payload) { var action = actionQueue.action, prevState = actionQueue.state, - prevTransition = ReactSharedInternals.T, + prevTransition = ReactCurrentBatchConfig$2.transition, currentTransition = { _callbacks: new Set() }; - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$2.transition = currentTransition; setPendingState(!0); try { var returnValue = action(prevState, payload); @@ -3045,7 +3081,7 @@ function runActionStateAction(actionQueue, setPendingState, setState, payload) { setState({ then: function () {}, status: "rejected", reason: error }), finishRunningActionStateAction(actionQueue, setPendingState, setState); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$2.transition = prevTransition; } } function finishRunningActionStateAction( @@ -3316,15 +3352,15 @@ function startTransition( var previousPriority = currentUpdatePriority; currentUpdatePriority = 0 !== previousPriority && 8 > previousPriority ? previousPriority : 8; - var prevTransition = ReactSharedInternals.T, + var prevTransition = ReactCurrentBatchConfig$2.transition, currentTransition = { _callbacks: new Set() }; - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$2.transition = currentTransition; dispatchOptimisticSetState(fiber, !1, queue, pendingState); enableTransitionTracing && void 0 !== options && void 0 !== options.name && - ((currentTransition.name = options.name), - (currentTransition.startTime = now())); + ((ReactCurrentBatchConfig$2.transition.name = options.name), + (ReactCurrentBatchConfig$2.transition.startTime = now())); try { var returnValue = callback(); if ( @@ -3347,7 +3383,7 @@ function startTransition( }); } finally { (currentUpdatePriority = previousPriority), - (ReactSharedInternals.T = prevTransition); + (ReactCurrentBatchConfig$2.transition = prevTransition); } } function useHostTransitionStatus() { @@ -3928,20 +3964,19 @@ function resolveClassComponentProps( alreadyResolvedDefaultProps ) { var newProps = baseProps; - if (enableRefAsProp && "ref" in baseProps) { - newProps = {}; - for (var propName in baseProps) - "ref" !== propName && (newProps[propName] = baseProps[propName]); - } if ( (Component = Component.defaultProps) && (disableDefaultPropsExceptForClasses || !alreadyResolvedDefaultProps) ) { - newProps === baseProps && (newProps = assign({}, newProps, baseProps)); - for (var propName$36 in Component) - void 0 === newProps[propName$36] && - (newProps[propName$36] = Component[propName$36]); + newProps = assign({}, newProps, baseProps); + for (var propName in Component) + void 0 === newProps[propName] && + (newProps[propName] = Component[propName]); } + enableRefAsProp && + "ref" in newProps && + (newProps === baseProps && (newProps = assign({}, newProps)), + delete newProps.ref); return newProps; } function resolveDefaultPropsOnNonClassComponent(Component, baseProps) { @@ -4344,7 +4379,8 @@ function pushMarkerInstance(workInProgress, markerInstance) { markerInstanceStack.current.concat(markerInstance) )); } -var SelectiveHydrationException = Error(formatProdErrorMessage(461)), +var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, + SelectiveHydrationException = Error(formatProdErrorMessage(461)), didReceiveUpdate = !1; function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress.child = @@ -4871,7 +4907,7 @@ function finishClassComponent( bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); shouldUpdate = workInProgress.stateNode; - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$1.current = workInProgress; var nextChildren = didCaptureError && "function" !== typeof Component.getDerivedStateFromError ? null @@ -6333,8 +6369,9 @@ function releaseCache(cache) { cache.controller.abort(); }); } +var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; function requestCurrentTransition() { - var transition = ReactSharedInternals.T; + var transition = ReactCurrentBatchConfig$1.transition; null !== transition && transition._callbacks.add(handleAsyncAction); return transition; } @@ -6502,14 +6539,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$82 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$82 = lastTailNode), + for (var lastTailNode$81 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$81 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$82 + null === lastTailNode$81 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$82.sibling = null); + : (lastTailNode$81.sibling = null); } } function bubbleProperties(completedWork) { @@ -6519,19 +6556,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$83 = completedWork.child; null !== child$83; ) - (newChildLanes |= child$83.lanes | child$83.childLanes), - (subtreeFlags |= child$83.subtreeFlags & 31457280), - (subtreeFlags |= child$83.flags & 31457280), - (child$83.return = completedWork), - (child$83 = child$83.sibling); + for (var child$82 = completedWork.child; null !== child$82; ) + (newChildLanes |= child$82.lanes | child$82.childLanes), + (subtreeFlags |= child$82.subtreeFlags & 31457280), + (subtreeFlags |= child$82.flags & 31457280), + (child$82.return = completedWork), + (child$82 = child$82.sibling); else - for (child$83 = completedWork.child; null !== child$83; ) - (newChildLanes |= child$83.lanes | child$83.childLanes), - (subtreeFlags |= child$83.subtreeFlags), - (subtreeFlags |= child$83.flags), - (child$83.return = completedWork), - (child$83 = child$83.sibling); + for (child$82 = completedWork.child; null !== child$82; ) + (newChildLanes |= child$82.lanes | child$82.childLanes), + (subtreeFlags |= child$82.subtreeFlags), + (subtreeFlags |= child$82.flags), + (child$82.return = completedWork), + (child$82 = child$82.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6709,11 +6746,11 @@ function completeWork(current, workInProgress, renderLanes) { null !== newProps.alternate.memoizedState && null !== newProps.alternate.memoizedState.cachePool && (instance = newProps.alternate.memoizedState.cachePool.pool); - var cache$87 = null; + var cache$86 = null; null !== newProps.memoizedState && null !== newProps.memoizedState.cachePool && - (cache$87 = newProps.memoizedState.cachePool.pool); - cache$87 !== instance && (newProps.flags |= 2048); + (cache$86 = newProps.memoizedState.cachePool.pool); + cache$86 !== instance && (newProps.flags |= 2048); } renderLanes !== current && (enableTransitionTracing && (workInProgress.child.flags |= 2048), @@ -6747,8 +6784,8 @@ function completeWork(current, workInProgress, renderLanes) { instance = workInProgress.memoizedState; if (null === instance) return bubbleProperties(workInProgress), null; newProps = 0 !== (workInProgress.flags & 128); - cache$87 = instance.rendering; - if (null === cache$87) + cache$86 = instance.rendering; + if (null === cache$86) if (newProps) cutOffTailIfNeeded(instance, !1); else { if ( @@ -6756,11 +6793,11 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current && 0 !== (current.flags & 128)) ) for (current = workInProgress.child; null !== current; ) { - cache$87 = findFirstSuspended(current); - if (null !== cache$87) { + cache$86 = findFirstSuspended(current); + if (null !== cache$86) { workInProgress.flags |= 128; cutOffTailIfNeeded(instance, !1); - current = cache$87.updateQueue; + current = cache$86.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); workInProgress.subtreeFlags = 0; @@ -6785,7 +6822,7 @@ function completeWork(current, workInProgress, renderLanes) { } else { if (!newProps) - if (((current = findFirstSuspended(cache$87)), null !== current)) { + if (((current = findFirstSuspended(cache$86)), null !== current)) { if ( ((workInProgress.flags |= 128), (newProps = !0), @@ -6795,7 +6832,7 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(instance, !0), null === instance.tail && "hidden" === instance.tailMode && - !cache$87.alternate) + !cache$86.alternate) ) return bubbleProperties(workInProgress), null; } else @@ -6807,13 +6844,13 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(instance, !1), (workInProgress.lanes = 4194304)); instance.isBackwards - ? ((cache$87.sibling = workInProgress.child), - (workInProgress.child = cache$87)) + ? ((cache$86.sibling = workInProgress.child), + (workInProgress.child = cache$86)) : ((current = instance.last), null !== current - ? (current.sibling = cache$87) - : (workInProgress.child = cache$87), - (instance.last = cache$87)); + ? (current.sibling = cache$86) + : (workInProgress.child = cache$86), + (instance.last = cache$86)); } if (null !== instance.tail) return ( @@ -7085,8 +7122,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$105) { - captureCommitPhaseError(current, nearestMountedAncestor, error$105); + } catch (error$104) { + captureCommitPhaseError(current, nearestMountedAncestor, error$104); } else ref.current = null; } @@ -7290,11 +7327,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$106) { + } catch (error$105) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$106 + error$105 ); } } @@ -7861,7 +7898,7 @@ function recursivelyTraverseMutationEffects(root$jscomp$0, parentFiber) { captureCommitPhaseError(childToDelete, parentFiber, error); } } - if (parentFiber.subtreeFlags & 13878) + if (parentFiber.subtreeFlags & 12854) for (parentFiber = parentFiber.child; null !== parentFiber; ) commitMutationEffectsOnFiber(parentFiber, root$jscomp$0), (parentFiber = parentFiber.sibling); @@ -7885,8 +7922,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$114) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$114); + } catch (error$113) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$113); } } break; @@ -7920,8 +7957,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { finishedWork.updateQueue = null; try { flags._applyProps(flags, newProps, current); - } catch (error$117) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$117); + } catch (error$116) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$116); } } break; @@ -7957,8 +7994,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$119) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$119); + } catch (error$118) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$118); } flags = finishedWork.updateQueue; null !== flags && @@ -8098,12 +8135,12 @@ function commitReconciliationEffects(finishedWork) { break; case 3: case 4: - var parent$109 = JSCompiler_inline_result.stateNode.containerInfo, - before$110 = getHostSibling(finishedWork); + var parent$108 = JSCompiler_inline_result.stateNode.containerInfo, + before$109 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$110, - parent$109 + before$109, + parent$108 ); break; default: @@ -8561,9 +8598,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$125 = finishedWork.stateNode; + var instance$124 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$125._visibility & 4 + ? instance$124._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8576,7 +8613,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$125._visibility |= 4), + : ((instance$124._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8584,7 +8621,7 @@ function recursivelyTraverseReconnectPassiveEffects( committedTransitions, includeWorkInProgressEffects )) - : ((instance$125._visibility |= 4), + : ((instance$124._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8597,7 +8634,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$125 + instance$124 ); break; case 24: @@ -8904,6 +8941,10 @@ var DefaultCacheDispatcher = { } }, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentCache = ReactSharedInternals.ReactCurrentCache, + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner, + ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, executionContext = 0, workInProgressRoot = null, workInProgress = null, @@ -8996,14 +9037,16 @@ var legacyErrorBoundariesThatAlreadyFailed = null, nestedUpdateCount = 0, rootWithNestedUpdates = null; function requestUpdateLane(fiber) { - return 0 === (fiber.mode & 1) - ? 2 - : 0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes - ? workInProgressRootRenderLanes & -workInProgressRootRenderLanes - : null !== requestCurrentTransition() - ? ((fiber = currentEntangledLane), - 0 !== fiber ? fiber : requestTransitionLane()) - : currentUpdatePriority || 32; + if (0 === (fiber.mode & 1)) return 2; + if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) + return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; + if (null !== requestCurrentTransition()) + return ( + (fiber = currentEntangledLane), + 0 !== fiber ? fiber : requestTransitionLane() + ); + fiber = currentUpdatePriority; + return 0 !== fiber ? fiber : 32; } function requestDeferredLane() { 0 === workInProgressDeferredLane && @@ -9029,7 +9072,7 @@ function scheduleUpdateOnFiber(root, fiber, lane) { markRootUpdated(root, lane); if (0 === (executionContext & 2) || root !== workInProgressRoot) { if (enableTransitionTracing) { - var transition = ReactSharedInternals.T; + var transition = ReactCurrentBatchConfig.transition; if ( null !== transition && null != transition.name && @@ -9097,18 +9140,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { root, renderWasConcurrent ); - if ( - 0 !== errorRetryLanes && + 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = recoverFromConcurrentError( root, renderWasConcurrent, errorRetryLanes - )), - (renderWasConcurrent = !1), - 2 !== exitStatus) - ) - continue; + ))); } if (1 === exitStatus) { prepareFreshStack(root, 0); @@ -9342,10 +9380,28 @@ function performSyncWorkOnRoot(root, lanes) { ensureRootIsScheduled(root); return null; } -function flushSyncWork() { - return 0 === (executionContext & 6) - ? (flushSyncWorkAcrossRoots_impl(!1), !1) - : !0; +function flushSync(fn) { + null !== rootWithPendingPassiveEffects && + 0 === rootWithPendingPassiveEffects.tag && + 0 === (executionContext & 6) && + flushPassiveEffects(); + var prevExecutionContext = executionContext; + executionContext |= 1; + var prevTransition = ReactCurrentBatchConfig.transition, + previousPriority = currentUpdatePriority; + try { + if ( + ((ReactCurrentBatchConfig.transition = null), + (currentUpdatePriority = 2), + fn) + ) + return fn(); + } finally { + (currentUpdatePriority = previousPriority), + (ReactCurrentBatchConfig.transition = prevTransition), + (executionContext = prevExecutionContext), + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); + } } function resetWorkInProgressStack() { if (null !== workInProgress) { @@ -9408,8 +9464,8 @@ function prepareFreshStack(root, lanes) { } function handleThrow(root, thrownValue) { currentlyRenderingFiber$1 = null; - ReactSharedInternals.H = ContextOnlyDispatcher; - ReactSharedInternals.owner = null; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentOwner.current = null; if (thrownValue === SuspenseException) { thrownValue = getSuspendedThenable(); var handler = suspenseHandlerStackCursor.current; @@ -9447,13 +9503,13 @@ function handleThrow(root, thrownValue) { )); } function pushDispatcher() { - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } function pushCacheDispatcher() { - var prevCacheDispatcher = ReactSharedInternals.C; - ReactSharedInternals.C = DefaultCacheDispatcher; + var prevCacheDispatcher = ReactCurrentCache.current; + ReactCurrentCache.current = DefaultCacheDispatcher; return prevCacheDispatcher; } function renderDidSuspendDelayIfPossible() { @@ -9499,15 +9555,15 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$133) { - handleThrow(root, thrownValue$133); + } catch (thrownValue$132) { + handleThrow(root, thrownValue$132); } while (1); lanes && root.shellSuspendCounter++; resetContextDependencies(); executionContext = prevExecutionContext; - ReactSharedInternals.H = prevDispatcher; - ReactSharedInternals.C = prevCacheDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentCache.current = prevCacheDispatcher; if (null !== workInProgress) throw Error(formatProdErrorMessage(261)); workInProgressRoot = null; workInProgressRootRenderLanes = 0; @@ -9605,13 +9661,13 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$135) { - handleThrow(root, thrownValue$135); + } catch (thrownValue$134) { + handleThrow(root, thrownValue$134); } while (1); resetContextDependencies(); - ReactSharedInternals.H = prevDispatcher; - ReactSharedInternals.C = prevCacheDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentCache.current = prevCacheDispatcher; executionContext = prevExecutionContext; if (null !== workInProgress) return 0; workInProgressRoot = null; @@ -9627,7 +9683,7 @@ function performUnitOfWork(unitOfWork) { var next = beginWork(unitOfWork.alternate, unitOfWork, entangledRenderLanes); unitOfWork.memoizedProps = unitOfWork.pendingProps; null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); - ReactSharedInternals.owner = null; + ReactCurrentOwner.current = null; } function replaySuspendedUnitOfWork(unitOfWork) { var current = unitOfWork.alternate; @@ -9683,7 +9739,7 @@ function replaySuspendedUnitOfWork(unitOfWork) { null === current ? completeUnitOfWork(unitOfWork) : (workInProgress = current); - ReactSharedInternals.owner = null; + ReactCurrentOwner.current = null; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -9770,11 +9826,11 @@ function commitRoot( didIncludeRenderPhaseUpdate, spawnedLane ) { - var prevTransition = ReactSharedInternals.T, - previousUpdateLanePriority = currentUpdatePriority; + var previousUpdateLanePriority = currentUpdatePriority, + prevTransition = ReactCurrentBatchConfig.transition; try { - (currentUpdatePriority = 2), - (ReactSharedInternals.T = null), + (ReactCurrentBatchConfig.transition = null), + (currentUpdatePriority = 2), commitRootImpl( root, recoverableErrors, @@ -9784,7 +9840,7 @@ function commitRoot( spawnedLane ); } finally { - (ReactSharedInternals.T = prevTransition), + (ReactCurrentBatchConfig.transition = prevTransition), (currentUpdatePriority = previousUpdateLanePriority); } return null; @@ -9828,13 +9884,13 @@ function commitRootImpl( })); transitions = 0 !== (finishedWork.flags & 15990); if (0 !== (finishedWork.subtreeFlags & 15990) || transitions) { - transitions = ReactSharedInternals.T; - ReactSharedInternals.T = null; + transitions = ReactCurrentBatchConfig.transition; + ReactCurrentBatchConfig.transition = null; spawnedLane = currentUpdatePriority; currentUpdatePriority = 2; var prevExecutionContext = executionContext; executionContext |= 4; - ReactSharedInternals.owner = null; + ReactCurrentOwner.current = null; commitBeforeMutationEffects(root, finishedWork); commitMutationEffectsOnFiber(finishedWork, root); root.current = finishedWork; @@ -9842,7 +9898,7 @@ function commitRootImpl( requestPaint(); executionContext = prevExecutionContext; currentUpdatePriority = spawnedLane; - ReactSharedInternals.T = transitions; + ReactCurrentBatchConfig.transition = transitions; } else root.current = finishedWork; rootDoesHavePassiveEffects ? ((rootDoesHavePassiveEffects = !1), @@ -9888,18 +9944,19 @@ function flushPassiveEffects() { var root = rootWithPendingPassiveEffects, remainingLanes = pendingPassiveEffectsRemainingLanes; pendingPassiveEffectsRemainingLanes = 0; - var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes), - prevTransition = ReactSharedInternals.T, + var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes); + renderPriority = 32 > renderPriority ? 32 : renderPriority; + var prevTransition = ReactCurrentBatchConfig.transition, previousPriority = currentUpdatePriority; try { return ( - (currentUpdatePriority = 32 > renderPriority ? 32 : renderPriority), - (ReactSharedInternals.T = null), + (ReactCurrentBatchConfig.transition = null), + (currentUpdatePriority = renderPriority), flushPassiveEffectsImpl() ); } finally { (currentUpdatePriority = previousPriority), - (ReactSharedInternals.T = prevTransition), + (ReactCurrentBatchConfig.transition = prevTransition), releaseRootPooledCache(root, remainingLanes); } } @@ -10413,9 +10470,54 @@ function FiberRootNode( ) containerInfo.push(null); } -function updateContainerSync(element, container, parentComponent, callback) { - 0 === container.tag && flushPassiveEffects(); - var current = container.current; +function createContainer( + containerInfo, + tag, + hydrationCallbacks, + isStrictMode, + concurrentUpdatesByDefaultOverride, + identifierPrefix, + onUncaughtError, + onCaughtError, + onRecoverableError, + transitionCallbacks +) { + containerInfo = new FiberRootNode( + containerInfo, + tag, + !1, + identifierPrefix, + onUncaughtError, + onCaughtError, + onRecoverableError, + null + ); + containerInfo.hydrationCallbacks = hydrationCallbacks; + enableTransitionTracing && + (containerInfo.transitionCallbacks = transitionCallbacks); + 1 === tag + ? ((tag = 1), + !0 === isStrictMode && (tag |= 24), + concurrentUpdatesByDefaultOverride && (tag |= 32)) + : (tag = 0); + isStrictMode = createFiber(3, null, null, tag); + containerInfo.current = isStrictMode; + isStrictMode.stateNode = containerInfo; + concurrentUpdatesByDefaultOverride = createCache(); + concurrentUpdatesByDefaultOverride.refCount++; + containerInfo.pooledCache = concurrentUpdatesByDefaultOverride; + concurrentUpdatesByDefaultOverride.refCount++; + isStrictMode.memoizedState = { + element: null, + isDehydrated: !1, + cache: concurrentUpdatesByDefaultOverride + }; + initializeUpdateQueue(isStrictMode); + return containerInfo; +} +function updateContainer(element, container, parentComponent, callback) { + var current = container.current, + lane = requestUpdateLane(current); a: if (parentComponent) { parentComponent = parentComponent._reactInternals; b: { @@ -10459,15 +10561,15 @@ function updateContainerSync(element, container, parentComponent, callback) { null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(2); + container = createUpdate(lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); - element = enqueueUpdate(current, container, 2); + element = enqueueUpdate(current, container, lane); null !== element && - (scheduleUpdateOnFiber(element, current, 2), - entangleTransitions(element, current, 2)); - return 2; + (scheduleUpdateOnFiber(element, current, lane), + entangleTransitions(element, current, lane)); + return lane; } function emptyFindFiberByHostInstance() { return null; @@ -10508,52 +10610,41 @@ var slice = Array.prototype.slice, _inheritsLoose(Surface, _React$Component); var _proto4 = Surface.prototype; _proto4.componentDidMount = function () { - var _this$props = this.props; + var $jscomp$this = this, + _this$props = this.props; this._surface = Mode$1.Surface( +_this$props.width, +_this$props.height, this._tagRef ); - _this$props = new FiberRootNode( - this._surface, - 0, - !1, - "", - void 0, - void 0, - void 0, - null - ); - _this$props.hydrationCallbacks = null; - enableTransitionTracing && (_this$props.transitionCallbacks = void 0); - var JSCompiler_inline_result = createFiber(3, null, null, 0); - _this$props.current = JSCompiler_inline_result; - JSCompiler_inline_result.stateNode = _this$props; - var initialCache = createCache(); - initialCache.refCount++; - _this$props.pooledCache = initialCache; - initialCache.refCount++; - JSCompiler_inline_result.memoizedState = { - element: null, - isDehydrated: !1, - cache: initialCache - }; - initializeUpdateQueue(JSCompiler_inline_result); - this._mountNode = _this$props; - updateContainerSync(this.props.children, this._mountNode, this); - flushSyncWork(); + this._mountNode = createContainer(this._surface, 0, null, !1, !1, ""); + flushSync(function () { + updateContainer( + $jscomp$this.props.children, + $jscomp$this._mountNode, + $jscomp$this + ); + }); }; _proto4.componentDidUpdate = function (prevProps) { - var props = this.props; + var $jscomp$this = this, + props = this.props; (props.height === prevProps.height && props.width === prevProps.width) || this._surface.resize(+props.width, +props.height); - updateContainerSync(this.props.children, this._mountNode, this); - flushSyncWork(); + flushSync(function () { + updateContainer( + $jscomp$this.props.children, + $jscomp$this._mountNode, + $jscomp$this + ); + }); this._surface.render && this._surface.render(); }; _proto4.componentWillUnmount = function () { - updateContainerSync(null, this._mountNode, this); - flushSyncWork(); + var $jscomp$this = this; + flushSync(function () { + updateContainer(null, $jscomp$this._mountNode, $jscomp$this); + }); }; _proto4.render = function () { var $jscomp$this = this, @@ -10600,19 +10691,19 @@ var slice = Array.prototype.slice, }; return Text; })(React.Component), - devToolsConfig$jscomp$inline_1114 = { + devToolsConfig$jscomp$inline_1121 = { findFiberByHostInstance: function () { return null; }, bundleType: 0, - version: "19.0.0-www-classic-52a8955f", + version: "19.0.0-www-classic-442df77a", rendererPackageName: "react-art" }; -var internals$jscomp$inline_1322 = { - bundleType: devToolsConfig$jscomp$inline_1114.bundleType, - version: devToolsConfig$jscomp$inline_1114.version, - rendererPackageName: devToolsConfig$jscomp$inline_1114.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1114.rendererConfig, +var internals$jscomp$inline_1317 = { + bundleType: devToolsConfig$jscomp$inline_1121.bundleType, + version: devToolsConfig$jscomp$inline_1121.version, + rendererPackageName: devToolsConfig$jscomp$inline_1121.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1121.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10622,33 +10713,33 @@ var internals$jscomp$inline_1322 = { setErrorHandler: null, setSuspenseHandler: null, scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function (fiber) { fiber = findCurrentFiberUsingSlowPath(fiber); fiber = null !== fiber ? findCurrentHostFiberImpl(fiber) : null; return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1114.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1121.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-52a8955f" + reconcilerVersion: "19.0.0-www-classic-442df77a" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1323 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1318 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1323.isDisabled && - hook$jscomp$inline_1323.supportsFiber + !hook$jscomp$inline_1318.isDisabled && + hook$jscomp$inline_1318.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1323.inject( - internals$jscomp$inline_1322 + (rendererID = hook$jscomp$inline_1318.inject( + internals$jscomp$inline_1317 )), - (injectedHook = hook$jscomp$inline_1323); + (injectedHook = hook$jscomp$inline_1318); } catch (err) {} } var Path = Mode$1.Path; diff --git a/compiled/facebook-www/ReactART-prod.modern.js b/compiled/facebook-www/ReactART-prod.modern.js index 36abae3d2a..ffe1fd3530 100644 --- a/compiled/facebook-www/ReactART-prod.modern.js +++ b/compiled/facebook-www/ReactART-prod.modern.js @@ -60,7 +60,7 @@ function formatProdErrorMessage(code) { ); } var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, dynamicFeatureFlags = require("ReactFeatureFlags"), enableDebugTracing = dynamicFeatureFlags.enableDebugTracing, enableLazyContextPropagation = @@ -524,6 +524,7 @@ function clearTransitionsForLanes(root, lanes) { lanes &= ~lane; } } +var currentUpdatePriority = 0; function lanesToEventPriority(lanes) { lanes &= -lanes; return 2 < lanes @@ -701,8 +702,7 @@ function shouldSetTextContent(type, props) { "string" === typeof props.children || "number" === typeof props.children ); } -var currentUpdatePriority = 0, - valueStack = [], +var valueStack = [], index = -1; function createCursor(defaultValue) { return { current: defaultValue }; @@ -1568,11 +1568,51 @@ function unwrapThenable(thenable) { null === thenableState$1 && (thenableState$1 = []); return trackUsedThenable(thenableState$1, thenable, index); } +function convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef +) { + function ref(value) { + var refs = inst.refs; + null === value ? delete refs[stringRef] : (refs[stringRef] = value); + } + var stringRef = "" + mixedRef; + returnFiber = element._owner; + if (!returnFiber) throw Error(formatProdErrorMessage(290, stringRef)); + if (1 !== returnFiber.tag) throw Error(formatProdErrorMessage(309)); + var inst = returnFiber.stateNode; + if (!inst) throw Error(formatProdErrorMessage(147, stringRef)); + if ( + null !== current && + null !== current.ref && + "function" === typeof current.ref && + current.ref._stringRef === stringRef + ) + return current.ref; + ref._stringRef = stringRef; + return ref; +} function coerceRef(returnFiber, current, workInProgress, element) { - enableRefAsProp - ? ((returnFiber = element.props.ref), - (returnFiber = void 0 !== returnFiber ? returnFiber : null)) - : (returnFiber = element.ref); + if (enableRefAsProp) { + var mixedRef = element.props.ref; + mixedRef = void 0 !== mixedRef ? mixedRef : null; + } else mixedRef = element.ref; + "string" === typeof mixedRef || + "number" === typeof mixedRef || + "boolean" === typeof mixedRef + ? ((returnFiber = convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef + )), + enableRefAsProp && + ((current = assign({}, workInProgress.pendingProps)), + (current.ref = returnFiber), + (workInProgress.pendingProps = current))) + : (returnFiber = mixedRef); workInProgress.ref = returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { @@ -2337,7 +2377,9 @@ function findFirstSuspended(row) { } return null; } -var renderLanes = 0, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig, + renderLanes = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, @@ -2369,7 +2411,7 @@ function renderWithHooks( workInProgress.memoizedState = null; workInProgress.updateQueue = null; workInProgress.lanes = 0; - ReactSharedInternals.H = + ReactCurrentDispatcher$1.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; @@ -2387,7 +2429,7 @@ function renderWithHooks( return nextRenderLanes; } function finishRenderingHooks(current) { - ReactSharedInternals.H = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; var didRenderTooFewHooks = null !== currentHook && null !== currentHook.next; renderLanes = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; @@ -2414,22 +2456,16 @@ function renderWithHooksAgain(workInProgress, Component, props, secondArg) { numberOfReRenders += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactSharedInternals.H = HooksDispatcherOnRerender; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; var children = Component(props, secondArg); } while (didScheduleRenderPhaseUpdateDuringThisPass); return children; } function TransitionAwareHostComponent() { - var dispatcher = ReactSharedInternals.H, - maybeThenable = dispatcher.useState()[0]; - maybeThenable = - "function" === typeof maybeThenable.then - ? useThenable(maybeThenable) - : maybeThenable; - dispatcher = dispatcher.useState()[0]; - (null !== currentHook ? currentHook.memoizedState : null) !== dispatcher && - (currentlyRenderingFiber$1.flags |= 1024); - return maybeThenable; + var maybeThenable = ReactCurrentDispatcher$1.current.useState()[0]; + return "function" === typeof maybeThenable.then + ? useThenable(maybeThenable) + : maybeThenable; } function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; @@ -2515,7 +2551,7 @@ function useThenable(thenable) { (null === workInProgressHook ? null === currentlyRenderingFiber$1.memoizedState : null === workInProgressHook.next) && - (ReactSharedInternals.H = HooksDispatcherOnMount); + (ReactCurrentDispatcher$1.current = HooksDispatcherOnMount); return thenable; } function use(usable) { @@ -2808,9 +2844,9 @@ function dispatchActionState( function runActionStateAction(actionQueue, setPendingState, setState, payload) { var action = actionQueue.action, prevState = actionQueue.state, - prevTransition = ReactSharedInternals.T, + prevTransition = ReactCurrentBatchConfig$2.transition, currentTransition = { _callbacks: new Set() }; - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$2.transition = currentTransition; setPendingState(!0); try { var returnValue = action(prevState, payload); @@ -2843,7 +2879,7 @@ function runActionStateAction(actionQueue, setPendingState, setState, payload) { setState({ then: function () {}, status: "rejected", reason: error }), finishRunningActionStateAction(actionQueue, setPendingState, setState); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$2.transition = prevTransition; } } function finishRunningActionStateAction( @@ -3114,15 +3150,15 @@ function startTransition( var previousPriority = currentUpdatePriority; currentUpdatePriority = 0 !== previousPriority && 8 > previousPriority ? previousPriority : 8; - var prevTransition = ReactSharedInternals.T, + var prevTransition = ReactCurrentBatchConfig$2.transition, currentTransition = { _callbacks: new Set() }; - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$2.transition = currentTransition; dispatchOptimisticSetState(fiber, !1, queue, pendingState); enableTransitionTracing && void 0 !== options && void 0 !== options.name && - ((currentTransition.name = options.name), - (currentTransition.startTime = now())); + ((ReactCurrentBatchConfig$2.transition.name = options.name), + (ReactCurrentBatchConfig$2.transition.startTime = now())); try { var returnValue = callback(); if ( @@ -3145,7 +3181,7 @@ function startTransition( }); } finally { (currentUpdatePriority = previousPriority), - (ReactSharedInternals.T = prevTransition); + (ReactCurrentBatchConfig$2.transition = prevTransition); } } function useHostTransitionStatus() { @@ -3664,20 +3700,19 @@ function resolveClassComponentProps( alreadyResolvedDefaultProps ) { var newProps = baseProps; - if (enableRefAsProp && "ref" in baseProps) { - newProps = {}; - for (var propName in baseProps) - "ref" !== propName && (newProps[propName] = baseProps[propName]); - } if ( (Component = Component.defaultProps) && (disableDefaultPropsExceptForClasses || !alreadyResolvedDefaultProps) ) { - newProps === baseProps && (newProps = assign({}, newProps, baseProps)); - for (var propName$36 in Component) - void 0 === newProps[propName$36] && - (newProps[propName$36] = Component[propName$36]); + newProps = assign({}, newProps, baseProps); + for (var propName in Component) + void 0 === newProps[propName] && + (newProps[propName] = Component[propName]); } + enableRefAsProp && + "ref" in newProps && + (newProps === baseProps && (newProps = assign({}, newProps)), + delete newProps.ref); return newProps; } function resolveDefaultPropsOnNonClassComponent(Component, baseProps) { @@ -4040,7 +4075,8 @@ function pushMarkerInstance(workInProgress, markerInstance) { markerInstanceStack.current.concat(markerInstance) )); } -var SelectiveHydrationException = Error(formatProdErrorMessage(461)), +var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, + SelectiveHydrationException = Error(formatProdErrorMessage(461)), didReceiveUpdate = !1; function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress.child = @@ -4570,7 +4606,7 @@ function updateClassComponent( nextProps = 0 !== (workInProgress.flags & 128); context || nextProps ? ((context = workInProgress.stateNode), - (ReactSharedInternals.owner = workInProgress), + (ReactCurrentOwner$1.current = workInProgress), (Component = nextProps && "function" !== typeof Component.getDerivedStateFromError ? null @@ -5921,8 +5957,9 @@ function releaseCache(cache) { cache.controller.abort(); }); } +var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; function requestCurrentTransition() { - var transition = ReactSharedInternals.T; + var transition = ReactCurrentBatchConfig$1.transition; null !== transition && transition._callbacks.add(handleAsyncAction); return transition; } @@ -6090,14 +6127,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$74 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$74 = lastTailNode), + for (var lastTailNode$73 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$73 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$74 + null === lastTailNode$73 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$74.sibling = null); + : (lastTailNode$73.sibling = null); } } function bubbleProperties(completedWork) { @@ -6107,19 +6144,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$75 = completedWork.child; null !== child$75; ) - (newChildLanes |= child$75.lanes | child$75.childLanes), - (subtreeFlags |= child$75.subtreeFlags & 31457280), - (subtreeFlags |= child$75.flags & 31457280), - (child$75.return = completedWork), - (child$75 = child$75.sibling); + for (var child$74 = completedWork.child; null !== child$74; ) + (newChildLanes |= child$74.lanes | child$74.childLanes), + (subtreeFlags |= child$74.subtreeFlags & 31457280), + (subtreeFlags |= child$74.flags & 31457280), + (child$74.return = completedWork), + (child$74 = child$74.sibling); else - for (child$75 = completedWork.child; null !== child$75; ) - (newChildLanes |= child$75.lanes | child$75.childLanes), - (subtreeFlags |= child$75.subtreeFlags), - (subtreeFlags |= child$75.flags), - (child$75.return = completedWork), - (child$75 = child$75.sibling); + for (child$74 = completedWork.child; null !== child$74; ) + (newChildLanes |= child$74.lanes | child$74.childLanes), + (subtreeFlags |= child$74.subtreeFlags), + (subtreeFlags |= child$74.flags), + (child$74.return = completedWork), + (child$74 = child$74.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6290,11 +6327,11 @@ function completeWork(current, workInProgress, renderLanes) { null !== newProps.alternate.memoizedState && null !== newProps.alternate.memoizedState.cachePool && (instance = newProps.alternate.memoizedState.cachePool.pool); - var cache$79 = null; + var cache$78 = null; null !== newProps.memoizedState && null !== newProps.memoizedState.cachePool && - (cache$79 = newProps.memoizedState.cachePool.pool); - cache$79 !== instance && (newProps.flags |= 2048); + (cache$78 = newProps.memoizedState.cachePool.pool); + cache$78 !== instance && (newProps.flags |= 2048); } renderLanes !== current && (enableTransitionTracing && (workInProgress.child.flags |= 2048), @@ -6322,8 +6359,8 @@ function completeWork(current, workInProgress, renderLanes) { instance = workInProgress.memoizedState; if (null === instance) return bubbleProperties(workInProgress), null; newProps = 0 !== (workInProgress.flags & 128); - cache$79 = instance.rendering; - if (null === cache$79) + cache$78 = instance.rendering; + if (null === cache$78) if (newProps) cutOffTailIfNeeded(instance, !1); else { if ( @@ -6331,11 +6368,11 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current && 0 !== (current.flags & 128)) ) for (current = workInProgress.child; null !== current; ) { - cache$79 = findFirstSuspended(current); - if (null !== cache$79) { + cache$78 = findFirstSuspended(current); + if (null !== cache$78) { workInProgress.flags |= 128; cutOffTailIfNeeded(instance, !1); - current = cache$79.updateQueue; + current = cache$78.updateQueue; workInProgress.updateQueue = current; scheduleRetryEffect(workInProgress, current); workInProgress.subtreeFlags = 0; @@ -6360,7 +6397,7 @@ function completeWork(current, workInProgress, renderLanes) { } else { if (!newProps) - if (((current = findFirstSuspended(cache$79)), null !== current)) { + if (((current = findFirstSuspended(cache$78)), null !== current)) { if ( ((workInProgress.flags |= 128), (newProps = !0), @@ -6370,7 +6407,7 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(instance, !0), null === instance.tail && "hidden" === instance.tailMode && - !cache$79.alternate) + !cache$78.alternate) ) return bubbleProperties(workInProgress), null; } else @@ -6382,13 +6419,13 @@ function completeWork(current, workInProgress, renderLanes) { cutOffTailIfNeeded(instance, !1), (workInProgress.lanes = 4194304)); instance.isBackwards - ? ((cache$79.sibling = workInProgress.child), - (workInProgress.child = cache$79)) + ? ((cache$78.sibling = workInProgress.child), + (workInProgress.child = cache$78)) : ((current = instance.last), null !== current - ? (current.sibling = cache$79) - : (workInProgress.child = cache$79), - (instance.last = cache$79)); + ? (current.sibling = cache$78) + : (workInProgress.child = cache$78), + (instance.last = cache$78)); } if (null !== instance.tail) return ( @@ -6651,8 +6688,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$96) { - captureCommitPhaseError(current, nearestMountedAncestor, error$96); + } catch (error$95) { + captureCommitPhaseError(current, nearestMountedAncestor, error$95); } else ref.current = null; } @@ -6856,11 +6893,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$97) { + } catch (error$96) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$97 + error$96 ); } } @@ -7416,7 +7453,7 @@ function recursivelyTraverseMutationEffects(root$jscomp$0, parentFiber) { captureCommitPhaseError(childToDelete, parentFiber, error); } } - if (parentFiber.subtreeFlags & 13878) + if (parentFiber.subtreeFlags & 12854) for (parentFiber = parentFiber.child; null !== parentFiber; ) commitMutationEffectsOnFiber(parentFiber, root$jscomp$0), (parentFiber = parentFiber.sibling); @@ -7440,8 +7477,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$105) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$105); + } catch (error$104) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$104); } } break; @@ -7475,8 +7512,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { finishedWork.updateQueue = null; try { flags._applyProps(flags, newProps, current); - } catch (error$108) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$108); + } catch (error$107) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$107); } } break; @@ -7512,8 +7549,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { null !== retryQueue && suspenseCallback(new Set(retryQueue)); } } - } catch (error$110) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$110); + } catch (error$109) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$109); } flags = finishedWork.updateQueue; null !== flags && @@ -7650,12 +7687,12 @@ function commitReconciliationEffects(finishedWork) { break; case 3: case 4: - var parent$100 = JSCompiler_inline_result.stateNode.containerInfo, - before$101 = getHostSibling(finishedWork); + var parent$99 = JSCompiler_inline_result.stateNode.containerInfo, + before$100 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$101, - parent$100 + before$100, + parent$99 ); break; default: @@ -8105,9 +8142,9 @@ function recursivelyTraverseReconnectPassiveEffects( ); break; case 22: - var instance$116 = finishedWork.stateNode; + var instance$115 = finishedWork.stateNode; null !== finishedWork.memoizedState - ? instance$116._visibility & 4 + ? instance$115._visibility & 4 ? recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8119,7 +8156,7 @@ function recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork ) - : ((instance$116._visibility |= 4), + : ((instance$115._visibility |= 4), recursivelyTraverseReconnectPassiveEffects( finishedRoot, finishedWork, @@ -8132,7 +8169,7 @@ function recursivelyTraverseReconnectPassiveEffects( commitOffscreenPassiveMountEffects( finishedWork.alternate, finishedWork, - instance$116 + instance$115 ); break; case 24: @@ -8439,6 +8476,10 @@ var DefaultCacheDispatcher = { } }, PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentCache = ReactSharedInternals.ReactCurrentCache, + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner, + ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig, executionContext = 0, workInProgressRoot = null, workInProgress = null, @@ -8537,7 +8578,8 @@ function requestUpdateLane() { var actionScopeLane = currentEntangledLane; return 0 !== actionScopeLane ? actionScopeLane : requestTransitionLane(); } - return currentUpdatePriority || 32; + actionScopeLane = currentUpdatePriority; + return 0 !== actionScopeLane ? actionScopeLane : 32; } function requestDeferredLane() { 0 === workInProgressDeferredLane && @@ -8564,7 +8606,7 @@ function scheduleUpdateOnFiber(root, fiber, lane) { if (0 === (executionContext & 2) || root !== workInProgressRoot) { if ( enableTransitionTracing && - ((fiber = ReactSharedInternals.T), + ((fiber = ReactCurrentBatchConfig.transition), null !== fiber && null != fiber.name && (-1 === fiber.startTime && (fiber.startTime = now()), @@ -8625,18 +8667,13 @@ function performConcurrentWorkOnRoot(root, didTimeout) { root, renderWasConcurrent ); - if ( - 0 !== errorRetryLanes && + 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = recoverFromConcurrentError( root, renderWasConcurrent, errorRetryLanes - )), - (renderWasConcurrent = !1), - 2 !== exitStatus) - ) - continue; + ))); } if (1 === exitStatus) { prepareFreshStack(root, 0); @@ -8870,10 +8907,24 @@ function performSyncWorkOnRoot(root, lanes) { ensureRootIsScheduled(root); return null; } -function flushSyncWork() { - return 0 === (executionContext & 6) - ? (flushSyncWorkAcrossRoots_impl(!1), !1) - : !0; +function flushSync(fn) { + var prevExecutionContext = executionContext; + executionContext |= 1; + var prevTransition = ReactCurrentBatchConfig.transition, + previousPriority = currentUpdatePriority; + try { + if ( + ((ReactCurrentBatchConfig.transition = null), + (currentUpdatePriority = 2), + fn) + ) + return fn(); + } finally { + (currentUpdatePriority = previousPriority), + (ReactCurrentBatchConfig.transition = prevTransition), + (executionContext = prevExecutionContext), + 0 === (executionContext & 6) && flushSyncWorkAcrossRoots_impl(!1); + } } function resetWorkInProgressStack() { if (null !== workInProgress) { @@ -8936,8 +8987,8 @@ function prepareFreshStack(root, lanes) { } function handleThrow(root, thrownValue) { currentlyRenderingFiber$1 = null; - ReactSharedInternals.H = ContextOnlyDispatcher; - ReactSharedInternals.owner = null; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentOwner.current = null; if (thrownValue === SuspenseException) { thrownValue = getSuspendedThenable(); var handler = suspenseHandlerStackCursor.current; @@ -8975,13 +9026,13 @@ function handleThrow(root, thrownValue) { )); } function pushDispatcher() { - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } function pushCacheDispatcher() { - var prevCacheDispatcher = ReactSharedInternals.C; - ReactSharedInternals.C = DefaultCacheDispatcher; + var prevCacheDispatcher = ReactCurrentCache.current; + ReactCurrentCache.current = DefaultCacheDispatcher; return prevCacheDispatcher; } function renderDidSuspendDelayIfPossible() { @@ -9027,15 +9078,15 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$124) { - handleThrow(root, thrownValue$124); + } catch (thrownValue$123) { + handleThrow(root, thrownValue$123); } while (1); lanes && root.shellSuspendCounter++; resetContextDependencies(); executionContext = prevExecutionContext; - ReactSharedInternals.H = prevDispatcher; - ReactSharedInternals.C = prevCacheDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentCache.current = prevCacheDispatcher; if (null !== workInProgress) throw Error(formatProdErrorMessage(261)); workInProgressRoot = null; workInProgressRootRenderLanes = 0; @@ -9133,13 +9184,13 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$126) { - handleThrow(root, thrownValue$126); + } catch (thrownValue$125) { + handleThrow(root, thrownValue$125); } while (1); resetContextDependencies(); - ReactSharedInternals.H = prevDispatcher; - ReactSharedInternals.C = prevCacheDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; + ReactCurrentCache.current = prevCacheDispatcher; executionContext = prevExecutionContext; if (null !== workInProgress) return 0; workInProgressRoot = null; @@ -9155,7 +9206,7 @@ function performUnitOfWork(unitOfWork) { var next = beginWork(unitOfWork.alternate, unitOfWork, entangledRenderLanes); unitOfWork.memoizedProps = unitOfWork.pendingProps; null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); - ReactSharedInternals.owner = null; + ReactCurrentOwner.current = null; } function replaySuspendedUnitOfWork(unitOfWork) { var current = unitOfWork.alternate; @@ -9207,7 +9258,7 @@ function replaySuspendedUnitOfWork(unitOfWork) { null === current ? completeUnitOfWork(unitOfWork) : (workInProgress = current); - ReactSharedInternals.owner = null; + ReactCurrentOwner.current = null; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { resetContextDependencies(); @@ -9294,11 +9345,11 @@ function commitRoot( didIncludeRenderPhaseUpdate, spawnedLane ) { - var prevTransition = ReactSharedInternals.T, - previousUpdateLanePriority = currentUpdatePriority; + var previousUpdateLanePriority = currentUpdatePriority, + prevTransition = ReactCurrentBatchConfig.transition; try { - (currentUpdatePriority = 2), - (ReactSharedInternals.T = null), + (ReactCurrentBatchConfig.transition = null), + (currentUpdatePriority = 2), commitRootImpl( root, recoverableErrors, @@ -9308,7 +9359,7 @@ function commitRoot( spawnedLane ); } finally { - (ReactSharedInternals.T = prevTransition), + (ReactCurrentBatchConfig.transition = prevTransition), (currentUpdatePriority = previousUpdateLanePriority); } return null; @@ -9352,13 +9403,13 @@ function commitRootImpl( })); transitions = 0 !== (finishedWork.flags & 15990); if (0 !== (finishedWork.subtreeFlags & 15990) || transitions) { - transitions = ReactSharedInternals.T; - ReactSharedInternals.T = null; + transitions = ReactCurrentBatchConfig.transition; + ReactCurrentBatchConfig.transition = null; spawnedLane = currentUpdatePriority; currentUpdatePriority = 2; var prevExecutionContext = executionContext; executionContext |= 4; - ReactSharedInternals.owner = null; + ReactCurrentOwner.current = null; commitBeforeMutationEffects(root, finishedWork); commitMutationEffectsOnFiber(finishedWork, root); root.current = finishedWork; @@ -9366,7 +9417,7 @@ function commitRootImpl( requestPaint(); executionContext = prevExecutionContext; currentUpdatePriority = spawnedLane; - ReactSharedInternals.T = transitions; + ReactCurrentBatchConfig.transition = transitions; } else root.current = finishedWork; rootDoesHavePassiveEffects ? ((rootDoesHavePassiveEffects = !1), @@ -9410,18 +9461,19 @@ function flushPassiveEffects() { var root = rootWithPendingPassiveEffects, remainingLanes = pendingPassiveEffectsRemainingLanes; pendingPassiveEffectsRemainingLanes = 0; - var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes), - prevTransition = ReactSharedInternals.T, + var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes); + renderPriority = 32 > renderPriority ? 32 : renderPriority; + var prevTransition = ReactCurrentBatchConfig.transition, previousPriority = currentUpdatePriority; try { return ( - (currentUpdatePriority = 32 > renderPriority ? 32 : renderPriority), - (ReactSharedInternals.T = null), + (ReactCurrentBatchConfig.transition = null), + (currentUpdatePriority = renderPriority), flushPassiveEffectsImpl() ); } finally { (currentUpdatePriority = previousPriority), - (ReactSharedInternals.T = prevTransition), + (ReactCurrentBatchConfig.transition = prevTransition), releaseRootPooledCache(root, remainingLanes); } } @@ -9932,21 +9984,64 @@ function FiberRootNode( ) containerInfo.push(null); } -function updateContainerSync(element, container, parentComponent, callback) { - 0 === container.tag && flushPassiveEffects(); +function createContainer( + containerInfo, + tag, + hydrationCallbacks, + isStrictMode, + concurrentUpdatesByDefaultOverride, + identifierPrefix, + onUncaughtError, + onCaughtError, + onRecoverableError, + transitionCallbacks +) { + containerInfo = new FiberRootNode( + containerInfo, + tag, + !1, + identifierPrefix, + onUncaughtError, + onCaughtError, + onRecoverableError, + null + ); + containerInfo.hydrationCallbacks = hydrationCallbacks; + enableTransitionTracing && + (containerInfo.transitionCallbacks = transitionCallbacks); + hydrationCallbacks = 1; + !0 === isStrictMode && (hydrationCallbacks |= 24); + concurrentUpdatesByDefaultOverride && (hydrationCallbacks |= 32); + isStrictMode = createFiber(3, null, null, hydrationCallbacks); + containerInfo.current = isStrictMode; + isStrictMode.stateNode = containerInfo; + concurrentUpdatesByDefaultOverride = createCache(); + concurrentUpdatesByDefaultOverride.refCount++; + containerInfo.pooledCache = concurrentUpdatesByDefaultOverride; + concurrentUpdatesByDefaultOverride.refCount++; + isStrictMode.memoizedState = { + element: null, + isDehydrated: !1, + cache: concurrentUpdatesByDefaultOverride + }; + initializeUpdateQueue(isStrictMode); + return containerInfo; +} +function updateContainer(element, container, parentComponent, callback) { parentComponent = container.current; + var lane = requestUpdateLane(); null === container.context ? (container.context = emptyContextObject) : (container.pendingContext = emptyContextObject); - container = createUpdate(2); + container = createUpdate(lane); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); - element = enqueueUpdate(parentComponent, container, 2); + element = enqueueUpdate(parentComponent, container, lane); null !== element && - (scheduleUpdateOnFiber(element, parentComponent, 2), - entangleTransitions(element, parentComponent, 2)); - return 2; + (scheduleUpdateOnFiber(element, parentComponent, lane), + entangleTransitions(element, parentComponent, lane)); + return lane; } function emptyFindFiberByHostInstance() { return null; @@ -9987,52 +10082,41 @@ var slice = Array.prototype.slice, _inheritsLoose(Surface, _React$Component); var _proto4 = Surface.prototype; _proto4.componentDidMount = function () { - var _this$props = this.props; + var $jscomp$this = this, + _this$props = this.props; this._surface = Mode$1.Surface( +_this$props.width, +_this$props.height, this._tagRef ); - _this$props = new FiberRootNode( - this._surface, - 1, - !1, - "", - void 0, - void 0, - void 0, - null - ); - _this$props.hydrationCallbacks = null; - enableTransitionTracing && (_this$props.transitionCallbacks = void 0); - var JSCompiler_inline_result = createFiber(3, null, null, 1); - _this$props.current = JSCompiler_inline_result; - JSCompiler_inline_result.stateNode = _this$props; - var initialCache = createCache(); - initialCache.refCount++; - _this$props.pooledCache = initialCache; - initialCache.refCount++; - JSCompiler_inline_result.memoizedState = { - element: null, - isDehydrated: !1, - cache: initialCache - }; - initializeUpdateQueue(JSCompiler_inline_result); - this._mountNode = _this$props; - updateContainerSync(this.props.children, this._mountNode, this); - flushSyncWork(); + this._mountNode = createContainer(this._surface, 1, null, !1, !1, ""); + flushSync(function () { + updateContainer( + $jscomp$this.props.children, + $jscomp$this._mountNode, + $jscomp$this + ); + }); }; _proto4.componentDidUpdate = function (prevProps) { - var props = this.props; + var $jscomp$this = this, + props = this.props; (props.height === prevProps.height && props.width === prevProps.width) || this._surface.resize(+props.width, +props.height); - updateContainerSync(this.props.children, this._mountNode, this); - flushSyncWork(); + flushSync(function () { + updateContainer( + $jscomp$this.props.children, + $jscomp$this._mountNode, + $jscomp$this + ); + }); this._surface.render && this._surface.render(); }; _proto4.componentWillUnmount = function () { - updateContainerSync(null, this._mountNode, this); - flushSyncWork(); + var $jscomp$this = this; + flushSync(function () { + updateContainer(null, $jscomp$this._mountNode, $jscomp$this); + }); }; _proto4.render = function () { var $jscomp$this = this, @@ -10079,19 +10163,19 @@ var slice = Array.prototype.slice, }; return Text; })(React.Component), - devToolsConfig$jscomp$inline_1079 = { + devToolsConfig$jscomp$inline_1086 = { findFiberByHostInstance: function () { return null; }, bundleType: 0, - version: "19.0.0-www-modern-e590ea90", + version: "19.0.0-www-modern-292e1686", rendererPackageName: "react-art" }; -var internals$jscomp$inline_1307 = { - bundleType: devToolsConfig$jscomp$inline_1079.bundleType, - version: devToolsConfig$jscomp$inline_1079.version, - rendererPackageName: devToolsConfig$jscomp$inline_1079.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1079.rendererConfig, +var internals$jscomp$inline_1298 = { + bundleType: devToolsConfig$jscomp$inline_1086.bundleType, + version: devToolsConfig$jscomp$inline_1086.version, + rendererPackageName: devToolsConfig$jscomp$inline_1086.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1086.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10101,33 +10185,33 @@ var internals$jscomp$inline_1307 = { setErrorHandler: null, setSuspenseHandler: null, scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function (fiber) { fiber = findCurrentFiberUsingSlowPath(fiber); fiber = null !== fiber ? findCurrentHostFiberImpl(fiber) : null; return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1079.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1086.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-e590ea90" + reconcilerVersion: "19.0.0-www-modern-292e1686" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1308 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1299 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1308.isDisabled && - hook$jscomp$inline_1308.supportsFiber + !hook$jscomp$inline_1299.isDisabled && + hook$jscomp$inline_1299.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1308.inject( - internals$jscomp$inline_1307 + (rendererID = hook$jscomp$inline_1299.inject( + internals$jscomp$inline_1298 )), - (injectedHook = hook$jscomp$inline_1308); + (injectedHook = hook$jscomp$inline_1299); } catch (err) {} } var Path = Mode$1.Path; diff --git a/compiled/facebook-www/ReactDOM-dev.classic.js b/compiled/facebook-www/ReactDOM-dev.classic.js index f875ee022c..2da877e887 100644 --- a/compiled/facebook-www/ReactDOM-dev.classic.js +++ b/compiled/facebook-www/ReactDOM-dev.classic.js @@ -78,10 +78,12 @@ if (__DEV__) { var React = require("react"); var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; // Defensive in case this is fired before React is initialized. + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Defensive in case this is fired before React is initialized. if (ReactSharedInternals != null) { - var stack = ReactSharedInternals.getStackAddendum(); + var ReactDebugCurrentFrame = + ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { format += "%s"; @@ -115,12 +117,13 @@ if (__DEV__) { } var ReactSharedInternals = - React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Re-export dynamic flags from the www version. var dynamicFeatureFlags = require("ReactFeatureFlags"); - var enableTrustedTypesIntegration = + var disableIEWorkarounds = dynamicFeatureFlags.disableIEWorkarounds, + enableTrustedTypesIntegration = dynamicFeatureFlags.enableTrustedTypesIntegration, enableDebugTracing = dynamicFeatureFlags.enableDebugTracing, enableLazyContextPropagation = @@ -152,7 +155,6 @@ if (__DEV__) { var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableProfilerNestedUpdatePhase = true; - var disableIEWorkarounds = true; var enableAsyncActions = true; var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler; @@ -374,17 +376,6 @@ if (__DEV__) { return type.displayName || "Context"; } - function getComponentNameFromOwner(owner) { - if (typeof owner.tag === "number") { - return getComponentNameFromFiber(owner); - } - - if (typeof owner.name === "string") { - return owner.name; - } - - return null; - } function getComponentNameFromFiber(fiber) { var tag = fiber.tag, type = fiber.type; @@ -551,7 +542,6 @@ if (__DEV__) { var ScheduleRetry = StoreConsistency; var ShouldSuspendCommit = Visibility; var DidDefer = ContentReset; - var FormReset = Snapshot; var LifecycleEffectMask = Passive$1 | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit) @@ -621,8 +611,7 @@ if (__DEV__) { ContentReset | Ref | Hydrating | - Visibility | - FormReset; + Visibility; var LayoutMask = Update | Callback | Ref | Visibility; // TODO: Split into PassiveMountMask and PassiveUnmountMask var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that don't get reset on clones. @@ -632,6 +621,7 @@ if (__DEV__) { var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; + var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { var node = fiber; var nearestMounted = fiber; @@ -695,7 +685,7 @@ if (__DEV__) { } function isMounted(component) { { - var owner = ReactSharedInternals.owner; + var owner = ReactCurrentOwner$3.current; if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; @@ -1015,6 +1005,235 @@ if (__DEV__) { return event === currentReplayingEvent; } + var ReactCurrentDispatcher$3 = ReactSharedInternals.ReactCurrentDispatcher; // Since the "not pending" value is always the same, we can reuse the + // same object across all transitions. + + var sharedNotPendingObject = { + pending: false, + data: null, + method: null, + action: null + }; + var NotPending = Object.freeze(sharedNotPendingObject); + + function resolveDispatcher() { + // Copied from react/src/ReactHooks.js. It's the same thing but in a + // different package. + var dispatcher = ReactCurrentDispatcher$3.current; + + { + if (dispatcher === null) { + error( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for" + + " one of the following reasons:\n" + + "1. You might have mismatching versions of React and the renderer (such as React DOM)\n" + + "2. You might be breaking the Rules of Hooks\n" + + "3. You might have more than one copy of React in the same app\n" + + "See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem." + ); + } + } // Will result in a null access error if accessed outside render phase. We + // intentionally don't throw our own error because this is in a hot path. + // Also helps ensure this is inlined. + + return dispatcher; + } + + function useFormStatus() { + { + var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] We know this exists because of the feature check above. + + return dispatcher.useHostTransitionStatus(); + } + } + function useFormState(action, initialState, permalink) { + { + var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional + + return dispatcher.useFormState(action, initialState, permalink); + } + } + + var valueStack = []; + var fiberStack; + + { + fiberStack = []; + } + + var index = -1; + + function createCursor(defaultValue) { + return { + current: defaultValue + }; + } + + function pop(cursor, fiber) { + if (index < 0) { + { + error("Unexpected pop."); + } + + return; + } + + { + if (fiber !== fiberStack[index]) { + error("Unexpected Fiber popped."); + } + } + + cursor.current = valueStack[index]; + valueStack[index] = null; + + { + fiberStack[index] = null; + } + + index--; + } + + function push(cursor, value, fiber) { + index++; + valueStack[index] = cursor.current; + + { + fiberStack[index] = fiber; + } + + cursor.current = value; + } + + var contextStackCursor$1 = createCursor(null); + var contextFiberStackCursor = createCursor(null); + var rootInstanceStackCursor = createCursor(null); // Represents the nearest host transition provider (in React DOM, a
) + // NOTE: Since forms cannot be nested, and this feature is only implemented by + // React DOM, we don't technically need this to be a stack. It could be a single + // module variable instead. + + var hostTransitionProviderCursor = createCursor(null); // TODO: This should initialize to NotPendingTransition, a constant + // imported from the fiber config. However, because of a cycle in the module + // graph, that value isn't defined during this module's initialization. I can't + // think of a way to work around this without moving that value out of the + // fiber config. For now, the "no provider" case is handled when reading, + // inside useHostTransitionStatus. + + var HostTransitionContext = { + $$typeof: REACT_CONTEXT_TYPE, + Provider: null, + Consumer: null, + _currentValue: null, + _currentValue2: null, + _threadCount: 0 + }; + + function requiredContext(c) { + { + if (c === null) { + error( + "Expected host context to exist. This error is likely caused by a bug " + + "in React. Please file an issue." + ); + } + } + + return c; + } + + function getCurrentRootHostContainer() { + return rootInstanceStackCursor.current; + } + + function getRootHostContainer() { + var rootInstance = requiredContext(rootInstanceStackCursor.current); + return rootInstance; + } + + function getHostTransitionProvider() { + return hostTransitionProviderCursor.current; + } + + function pushHostContainer(fiber, nextRootInstance) { + // Push current root instance onto the stack; + // This allows us to reset root when portals are popped. + push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + + push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. + // However, we can't just call getRootHostContext() and push it because + // we'd have a different number of entries on the stack depending on + // whether getRootHostContext() throws somewhere in renderer code or not. + // So we push an empty value first. This lets us safely unwind on errors. + + push(contextStackCursor$1, null, fiber); + var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it. + + pop(contextStackCursor$1, fiber); + push(contextStackCursor$1, nextRootContext, fiber); + } + + function popHostContainer(fiber) { + pop(contextStackCursor$1, fiber); + pop(contextFiberStackCursor, fiber); + pop(rootInstanceStackCursor, fiber); + } + + function getHostContext() { + var context = requiredContext(contextStackCursor$1.current); + return context; + } + + function pushHostContext(fiber) { + { + var stateHook = fiber.memoizedState; + + if (stateHook !== null) { + // Only provide context if this fiber has been upgraded by a host + // transition. We use the same optimization for regular host context below. + push(hostTransitionProviderCursor, fiber, fiber); + } + } + + var context = requiredContext(contextStackCursor$1.current); + var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. + + if (context !== nextContext) { + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); + } + } + + function popHostContext(fiber) { + if (contextFiberStackCursor.current === fiber) { + // Do not pop unless this Fiber provided the current context. + // pushHostContext() only pushes Fibers that provide unique contexts. + pop(contextStackCursor$1, fiber); + pop(contextFiberStackCursor, fiber); + } + + { + if (hostTransitionProviderCursor.current === fiber) { + // Do not pop unless this Fiber provided the current context. This is mostly + // a performance optimization, but conveniently it also prevents a potential + // data race where a host provider is upgraded (i.e. memoizedState becomes + // non-null) during a concurrent event. This is a bit of a flaw in the way + // we upgrade host components, but because we're accounting for it here, it + // should be fine. + pop(hostTransitionProviderCursor, fiber); // When popping the transition provider, we reset the context value back + // to `null`. We can do this because you're not allowd to nest forms. If + // we allowed for multiple nested host transition providers, then we'd + // need to reset this to the parent provider's status. + + { + HostTransitionContext._currentValue = null; + } + } + } + } + // This module only exists as an ESM wrapper around the external CommonJS var scheduleCallback$3 = Scheduler.unstable_scheduleCallback; var cancelCallback$1 = Scheduler.unstable_cancelCallback; @@ -2623,11 +2842,27 @@ if (__DEV__) { } } - var NoEventPriority = NoLane; var DiscreteEventPriority = SyncLane; var ContinuousEventPriority = InputContinuousLane; var DefaultEventPriority = DefaultLane; var IdleEventPriority = IdleLane; + var currentUpdatePriority = NoLane; + function getCurrentUpdatePriority() { + return currentUpdatePriority; + } + function setCurrentUpdatePriority(newPriority) { + currentUpdatePriority = newPriority; + } + function runWithPriority(priority, fn) { + var previousPriority = currentUpdatePriority; + + try { + currentUpdatePriority = priority; + return fn(); + } finally { + currentUpdatePriority = previousPriority; + } + } function higherEventPriority(a, b) { return a !== 0 && a < b ? a : b; } @@ -2637,9 +2872,6 @@ if (__DEV__) { function isHigherEventPriority(a, b) { return a !== 0 && a < b; } - function eventPriorityToLane(updatePriority) { - return updatePriority; - } function lanesToEventPriority(lanes) { var lane = getHighestPriorityLane(lanes); @@ -2658,284 +2890,6 @@ if (__DEV__) { return IdleEventPriority; } - function noop$3() {} - - var DefaultDispatcher = { - f: - /* flushSyncWork */ - noop$3, - r: - /* requestFormReset */ - noop$3, - D: - /* prefetchDNS */ - noop$3, - C: - /* preconnect */ - noop$3, - L: - /* preload */ - noop$3, - m: - /* preloadModule */ - noop$3, - X: - /* preinitScript */ - noop$3, - S: - /* preinitStyle */ - noop$3, - M: - /* preinitModuleScript */ - noop$3 - }; - var Internals = { - Events: null, - d: - /* ReactDOMCurrentDispatcher */ - DefaultDispatcher, - p: - /* currentUpdatePriority */ - NoEventPriority, - findDOMNode: null - }; - - // same object across all transitions. - - var sharedNotPendingObject = { - pending: false, - data: null, - method: null, - action: null - }; - var NotPending = Object.freeze(sharedNotPendingObject); - - function resolveDispatcher() { - // Copied from react/src/ReactHooks.js. It's the same thing but in a - // different package. - var dispatcher = ReactSharedInternals.H; - - { - if (dispatcher === null) { - error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for" + - " one of the following reasons:\n" + - "1. You might have mismatching versions of React and the renderer (such as React DOM)\n" + - "2. You might be breaking the Rules of Hooks\n" + - "3. You might have more than one copy of React in the same app\n" + - "See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem." - ); - } - } // Will result in a null access error if accessed outside render phase. We - // intentionally don't throw our own error because this is in a hot path. - // Also helps ensure this is inlined. - - return dispatcher; - } - - function useFormStatus() { - { - var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] We know this exists because of the feature check above. - - return dispatcher.useHostTransitionStatus(); - } - } - function useFormState(action, initialState, permalink) { - { - var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional - - return dispatcher.useFormState(action, initialState, permalink); - } - } - function requestFormReset$2(form) { - Internals.d - /* ReactDOMCurrentDispatcher */ - .r( - /* requestFormReset */ - form - ); - } - - var valueStack = []; - var fiberStack; - - { - fiberStack = []; - } - - var index = -1; - - function createCursor(defaultValue) { - return { - current: defaultValue - }; - } - - function pop(cursor, fiber) { - if (index < 0) { - { - error("Unexpected pop."); - } - - return; - } - - { - if (fiber !== fiberStack[index]) { - error("Unexpected Fiber popped."); - } - } - - cursor.current = valueStack[index]; - valueStack[index] = null; - - { - fiberStack[index] = null; - } - - index--; - } - - function push(cursor, value, fiber) { - index++; - valueStack[index] = cursor.current; - - { - fiberStack[index] = fiber; - } - - cursor.current = value; - } - - var contextStackCursor$1 = createCursor(null); - var contextFiberStackCursor = createCursor(null); - var rootInstanceStackCursor = createCursor(null); // Represents the nearest host transition provider (in React DOM, a ) - // NOTE: Since forms cannot be nested, and this feature is only implemented by - // React DOM, we don't technically need this to be a stack. It could be a single - // module variable instead. - - var hostTransitionProviderCursor = createCursor(null); // TODO: This should initialize to NotPendingTransition, a constant - // imported from the fiber config. However, because of a cycle in the module - // graph, that value isn't defined during this module's initialization. I can't - // think of a way to work around this without moving that value out of the - // fiber config. For now, the "no provider" case is handled when reading, - // inside useHostTransitionStatus. - - var HostTransitionContext = { - $$typeof: REACT_CONTEXT_TYPE, - Provider: null, - Consumer: null, - _currentValue: null, - _currentValue2: null, - _threadCount: 0 - }; - - function requiredContext(c) { - { - if (c === null) { - error( - "Expected host context to exist. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - } - } - - return c; - } - - function getCurrentRootHostContainer() { - return rootInstanceStackCursor.current; - } - - function getRootHostContainer() { - var rootInstance = requiredContext(rootInstanceStackCursor.current); - return rootInstance; - } - - function getHostTransitionProvider() { - return hostTransitionProviderCursor.current; - } - - function pushHostContainer(fiber, nextRootInstance) { - // Push current root instance onto the stack; - // This allows us to reset root when portals are popped. - push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. - // This enables us to pop only Fibers that provide unique contexts. - - push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. - // However, we can't just call getRootHostContext() and push it because - // we'd have a different number of entries on the stack depending on - // whether getRootHostContext() throws somewhere in renderer code or not. - // So we push an empty value first. This lets us safely unwind on errors. - - push(contextStackCursor$1, null, fiber); - var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it. - - pop(contextStackCursor$1, fiber); - push(contextStackCursor$1, nextRootContext, fiber); - } - - function popHostContainer(fiber) { - pop(contextStackCursor$1, fiber); - pop(contextFiberStackCursor, fiber); - pop(rootInstanceStackCursor, fiber); - } - - function getHostContext() { - var context = requiredContext(contextStackCursor$1.current); - return context; - } - - function pushHostContext(fiber) { - { - var stateHook = fiber.memoizedState; - - if (stateHook !== null) { - // Only provide context if this fiber has been upgraded by a host - // transition. We use the same optimization for regular host context below. - push(hostTransitionProviderCursor, fiber, fiber); - } - } - - var context = requiredContext(contextStackCursor$1.current); - var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. - - if (context !== nextContext) { - // Track the context and the Fiber that provided it. - // This enables us to pop only Fibers that provide unique contexts. - push(contextFiberStackCursor, fiber, fiber); - push(contextStackCursor$1, nextContext, fiber); - } - } - - function popHostContext(fiber) { - if (contextFiberStackCursor.current === fiber) { - // Do not pop unless this Fiber provided the current context. - // pushHostContext() only pushes Fibers that provide unique contexts. - pop(contextStackCursor$1, fiber); - pop(contextFiberStackCursor, fiber); - } - - { - if (hostTransitionProviderCursor.current === fiber) { - // Do not pop unless this Fiber provided the current context. This is mostly - // a performance optimization, but conveniently it also prevents a potential - // data race where a host provider is upgraded (i.e. memoizedState becomes - // non-null) during a concurrent event. This is a bit of a flaw in the way - // we upgrade host components, but because we're accounting for it here, it - // should be fine. - pop(hostTransitionProviderCursor, fiber); // When popping the transition provider, we reset the context value back - // to `null`. We can do this because you're not allowd to nest forms. If - // we allowed for multiple nested host transition providers, then we'd - // need to reset this to the parent provider's status. - - { - HostTransitionContext._currentValue = null; - } - } - } - } - // $FlowFixMe[method-unbinding] var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -3027,6 +2981,20 @@ if (__DEV__) { } } } + function checkPropStringCoercion(value, propName) { + { + if (willCoercionThrow(value)) { + error( + "The provided `%s` prop is an unsupported type %s." + + " This value must be coerced to a string before using it here.", + propName, + typeName(value) + ); + + return testStringCoercion(value); // throw (to help callers find troubleshooting comments) + } + } + } function checkCSSPropertyStringCoercion(value, propName) { { if (willCoercionThrow(value)) { @@ -3069,48 +3037,6 @@ if (__DEV__) { } } - function setCurrentUpdatePriority( - newPriority, // Closure will consistently not inline this function when it has arity 1 - // however when it has arity 2 even if the second arg is omitted at every - // callsite it seems to inline it even when the internal length of the function - // is much longer. I hope this is consistent enough to rely on across builds - IntentionallyUnusedArgument - ) { - Internals.p = - /* currentUpdatePriority */ - newPriority; - } - function getCurrentUpdatePriority() { - return Internals.p; - /* currentUpdatePriority */ - } - function resolveUpdatePriority() { - var updatePriority = Internals.p; - /* currentUpdatePriority */ - - if (updatePriority !== NoEventPriority) { - return updatePriority; - } - - var currentEvent = window.event; - - if (currentEvent === undefined) { - return DefaultEventPriority; - } - - return getEventPriority(currentEvent.type); - } - function runWithPriority(priority, fn) { - var previousPriority = getCurrentUpdatePriority(); - - try { - setCurrentUpdatePriority(priority); - return fn(); - } finally { - setCurrentUpdatePriority(previousPriority); - } - } - var allNativeEvents = new Set(); { @@ -3476,8 +3402,9 @@ if (__DEV__) { setValueForAttribute(node, name, value); } + var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher; var prefix; - function describeBuiltInComponentFrame(name) { + function describeBuiltInComponentFrame(name, ownerFn) { { if (prefix === undefined) { // Extract the VM specific prefix used by each line. @@ -3534,13 +3461,13 @@ if (__DEV__) { var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. Error.prepareStackTrace = undefined; - var previousDispatcher = null; + var previousDispatcher; { - previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + previousDispatcher = ReactCurrentDispatcher$2.current; // Set the dispatcher in DEV because this might be call in the render function // for warnings. - ReactSharedInternals.H = null; + ReactCurrentDispatcher$2.current = null; disableLogs(); } /** @@ -3733,7 +3660,7 @@ if (__DEV__) { reentry = false; { - ReactSharedInternals.H = previousDispatcher; + ReactCurrentDispatcher$2.current = previousDispatcher; reenableLogs(); } @@ -3752,12 +3679,12 @@ if (__DEV__) { return syntheticFrame; } - function describeClassComponentFrame(ctor) { + function describeClassComponentFrame(ctor, ownerFn) { { return describeNativeComponentFrame(ctor, true); } } - function describeFunctionComponentFrame(fn) { + function describeFunctionComponentFrame(fn, ownerFn) { { return describeNativeComponentFrame(fn, false); } @@ -3826,6 +3753,7 @@ if (__DEV__) { } } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var current = null; var isRendering = false; function getCurrentFiberOwnerNameInDevOrNull() { @@ -3836,8 +3764,8 @@ if (__DEV__) { var owner = current._debugOwner; - if (owner != null) { - return getComponentNameFromOwner(owner); + if (owner !== null && typeof owner !== "undefined") { + return getComponentNameFromFiber(owner); } } @@ -3857,14 +3785,14 @@ if (__DEV__) { function resetCurrentFiber() { { - ReactSharedInternals.getCurrentStack = null; + ReactDebugCurrentFrame.getCurrentStack = null; current = null; isRendering = false; } } function setCurrentFiber(fiber) { { - ReactSharedInternals.getCurrentStack = + ReactDebugCurrentFrame.getCurrentStack = fiber === null ? null : getCurrentFiberStackInDev; current = fiber; isRendering = false; @@ -5312,7 +5240,68 @@ if (__DEV__) { var MATH_NAMESPACE = "http://www.w3.org/1998/Math/MathML"; var SVG_NAMESPACE = "http://www.w3.org/2000/svg"; - if (typeof MSApp !== "undefined" && MSApp.execUnsafeLocalFunction); + var reusableSVGContainer; + + function setInnerHTMLImpl(node, html) { + if (node.namespaceURI === SVG_NAMESPACE) { + { + if (enableTrustedTypesIntegration) { + // TODO: reconsider the text of this warning and when it should show + // before enabling the feature flag. + if (typeof trustedTypes !== "undefined") { + error( + "Using 'dangerouslySetInnerHTML' in an svg element with " + + "Trusted Types enabled in an Internet Explorer will cause " + + "the trusted value to be converted to string. Assigning string " + + "to 'innerHTML' will throw an error if Trusted Types are enforced. " + + "You can try to wrap your svg element inside a div and use 'dangerouslySetInnerHTML' " + + "on the enclosing div instead." + ); + } + } + } + + if (!("innerHTML" in node)) { + // IE does not have innerHTML for SVG nodes, so instead we inject the + // new markup in a temp node and then move the child nodes across into + // the target node + reusableSVGContainer = + reusableSVGContainer || document.createElement("div"); + reusableSVGContainer.innerHTML = + "" + html.valueOf().toString() + ""; + var svgNode = reusableSVGContainer.firstChild; + + while (node.firstChild) { + node.removeChild(node.firstChild); + } // $FlowFixMe[incompatible-use] + // $FlowFixMe[incompatible-type] + + while (svgNode.firstChild) { + node.appendChild(svgNode.firstChild); + } + + return; + } + } + + node.innerHTML = html; + } + + var setInnerHTML = setInnerHTMLImpl; // $FlowFixMe[cannot-resolve-name] + + if (typeof MSApp !== "undefined" && MSApp.execUnsafeLocalFunction) { + /** + * Create a function which has 'unsafe' privileges (required by windows8 apps) + */ + setInnerHTML = function (node, html) { + // $FlowFixMe[cannot-resolve-name] + return MSApp.execUnsafeLocalFunction(function () { + return setInnerHTMLImpl(node, html); + }); + }; + } + + var setInnerHTML$1 = setInnerHTML; /** * HTML nodeType values that represent the type of the node @@ -7368,9 +7357,6 @@ if (__DEV__) { } } - var LegacyRoot = 0; - var ConcurrentRoot = 1; - var warnedAboutMissingGetChildContext; { @@ -7633,6 +7619,9 @@ if (__DEV__) { } } + var LegacyRoot = 0; + var ConcurrentRoot = 1; + // We use the existence of the state object as an indicator that the component // is hidden. var OffscreenVisible = @@ -9644,6 +9633,7 @@ if (__DEV__) { } } + var ReactCurrentActQueue$4 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app, // there's only a single root, but we do support multi root apps, hence this // extra complexity. But this module is optimized for the single root case. @@ -9682,7 +9672,7 @@ if (__DEV__) { mightHavePendingSyncWork = true; // At the end of the current event, go through each of the roots and ensure // there's a task scheduled for each one at the correct priority. - if (ReactSharedInternals.actQueue !== null) { + if (ReactCurrentActQueue$4.current !== null) { // We're inside an `act` scope. if (!didScheduleMicrotask_act) { didScheduleMicrotask_act = true; @@ -9703,9 +9693,9 @@ if (__DEV__) { scheduleTaskForRootDuringMicrotask(root, now$1()); } - if (ReactSharedInternals.isBatchingLegacy && root.tag === LegacyRoot) { + if (ReactCurrentActQueue$4.isBatchingLegacy && root.tag === LegacyRoot) { // Special `act` case: Record whenever a legacy update is scheduled. - ReactSharedInternals.didScheduleLegacyUpdate = true; + ReactCurrentActQueue$4.didScheduleLegacyUpdate = true; } } function flushSyncWorkOnAllRoots() { @@ -9896,7 +9886,7 @@ if (__DEV__) { // Scheduler task, rather than an `act` task, cancel it and re-schedule // on the `act` queue. !( - ReactSharedInternals.actQueue !== null && + ReactCurrentActQueue$4.current !== null && existingCallbackNode !== fakeActCallbackNode$1 ) ) { @@ -9963,11 +9953,11 @@ if (__DEV__) { var fakeActCallbackNode$1 = {}; function scheduleCallback$2(priorityLevel, callback) { - if (ReactSharedInternals.actQueue !== null) { + if (ReactCurrentActQueue$4.current !== null) { // Special case: We're inside an `act` scope (a testing utility). // Instead of scheduling work in the host environment, add it to a // fake internal queue that's managed by the `act` implementation. - ReactSharedInternals.actQueue.push(callback); + ReactCurrentActQueue$4.current.push(callback); return fakeActCallbackNode$1; } else { return scheduleCallback$3(priorityLevel, callback); @@ -9982,13 +9972,13 @@ if (__DEV__) { } function scheduleImmediateTask(cb) { - if (ReactSharedInternals.actQueue !== null) { + if (ReactCurrentActQueue$4.current !== null) { // Special case: Inside an `act` scope, we push microtasks to the fake `act` // callback queue. This is because we currently support calling `act` // without awaiting the result. The plan is to deprecate that, and require // that you always await the result so that the microtasks have a chance to // run. But it hasn't happened yet. - ReactSharedInternals.actQueue.push(function () { + ReactCurrentActQueue$4.current.push(function () { cb(); return null; }); @@ -11156,6 +11146,8 @@ if (__DEV__) { }; } + var ReactCurrentActQueue$3 = ReactSharedInternals.ReactCurrentActQueue; + function getThenablesFromState(state) { { var devState = state; @@ -11206,11 +11198,11 @@ if (__DEV__) { return status === "fulfilled" || status === "rejected"; } - function noop$2() {} + function noop$3() {} function trackUsedThenable(thenableState, thenable, index) { - if (ReactSharedInternals.actQueue !== null) { - ReactSharedInternals.didUsePromise = true; + if (ReactCurrentActQueue$3.current !== null) { + ReactCurrentActQueue$3.didUsePromise = true; } var trackedThenables = getThenablesFromState(thenableState); @@ -11252,7 +11244,7 @@ if (__DEV__) { } // Avoid an unhandled rejection errors for the Promises that we'll // intentionally ignore. - thenable.then(noop$2, noop$2); + thenable.then(noop$3, noop$3); thenable = previous; } } // We use an expando to track the status and result of a thenable so that we @@ -11281,7 +11273,7 @@ if (__DEV__) { // some custom userspace implementation. We treat it as "pending". // Attach a dummy listener, to ensure that any lazy initialization can // happen. Flight lazily parses JSON when the value is actually awaited. - thenable.then(noop$2, noop$2); + thenable.then(noop$3, noop$3); } else { // This is an uncached thenable that we haven't seen before. // Detect infinite ping loops caused by uncached promises. @@ -11440,6 +11432,7 @@ if (__DEV__) { var didWarnAboutMaps; var didWarnAboutGenerators; + var didWarnAboutStringRefs; var ownerHasKeyUseWarning; var ownerHasFunctionTypeWarning; var ownerHasSymbolTypeWarning; @@ -11449,6 +11442,7 @@ if (__DEV__) { { didWarnAboutMaps = false; didWarnAboutGenerators = false; + didWarnAboutStringRefs = {}; /** * Warn if there's no key explicitly set on dynamic arrays of children or * object keys are not valid. This allows us to keep track of children between @@ -11493,6 +11487,10 @@ if (__DEV__) { }; } + function isReactClass(type) { + return type.prototype && type.prototype.isReactComponent; + } + function unwrapThenable(thenable) { var index = thenableIndexCounter$1; thenableIndexCounter$1 += 1; @@ -11504,22 +11502,159 @@ if (__DEV__) { return trackUsedThenable(thenableState$1, thenable, index); } + function convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef + ) { + { + checkPropStringCoercion(mixedRef, "ref"); + } + + var stringRef = "" + mixedRef; + var owner = element._owner; + + if (!owner) { + throw new Error( + "Element ref was specified as a string (" + + stringRef + + ") but no owner was set. This could happen for one of" + + " the following reasons:\n" + + "1. You may be adding a ref to a function component\n" + + "2. You may be adding a ref to a component that was not created inside a component's render method\n" + + "3. You have multiple copies of React loaded\n" + + "See https://react.dev/link/refs-must-have-owner for more information." + ); + } + + if (owner.tag !== ClassComponent) { + throw new Error( + "Function components cannot have string refs. " + + "We recommend using useRef() instead. " + + "Learn more about using refs safely here: " + + "https://react.dev/link/strict-mode-string-ref" + ); + } + + { + if ( + // Will already warn with "Function components cannot be given refs" + !(typeof element.type === "function" && !isReactClass(element.type)) + ) { + var componentName = + getComponentNameFromFiber(returnFiber) || "Component"; + + if (!didWarnAboutStringRefs[componentName]) { + error( + 'Component "%s" contains the string ref "%s". Support for string refs ' + + "will be removed in a future major release. We recommend using " + + "useRef() or createRef() instead. " + + "Learn more about using refs safely here: " + + "https://react.dev/link/strict-mode-string-ref", + componentName, + stringRef + ); + + didWarnAboutStringRefs[componentName] = true; + } + } + } + + var inst = owner.stateNode; + + if (!inst) { + throw new Error( + "Missing owner for string ref " + + stringRef + + ". This error is likely caused by a " + + "bug in React. Please file an issue." + ); + } // Check if previous string ref matches new string ref + + if ( + current !== null && + current.ref !== null && + typeof current.ref === "function" && + current.ref._stringRef === stringRef + ) { + // Reuse the existing string ref + var currentRef = current.ref; + return currentRef; + } // Create a new string ref + + var ref = function (value) { + var refs = inst.refs; + + if (value === null) { + delete refs[stringRef]; + } else { + refs[stringRef] = value; + } + }; + + ref._stringRef = stringRef; + return ref; + } + function coerceRef(returnFiber, current, workInProgress, element) { - var ref; + var mixedRef; if (enableRefAsProp) { // TODO: This is a temporary, intermediate step. When enableRefAsProp is on, // we should resolve the `ref` prop during the begin phase of the component // it's attached to (HostComponent, ClassComponent, etc). var refProp = element.props.ref; - ref = refProp !== undefined ? refProp : null; + mixedRef = refProp !== undefined ? refProp : null; } else { // Old behavior. - ref = element.ref; + mixedRef = element.ref; + } + + var coercedRef; + + if ( + typeof mixedRef === "string" || + typeof mixedRef === "number" || + typeof mixedRef === "boolean" + ) { + coercedRef = convertStringRefToCallbackRef( + returnFiber, + current, + element, + mixedRef + ); + + if (enableRefAsProp) { + // When enableRefAsProp is on, we should always use the props as the + // source of truth for refs. Not a field on the fiber. + // + // In the case of string refs, this presents a problem, because string + // refs are not passed around internally as strings; they are converted to + // callback refs. The ref used by the reconciler is not the same as the + // one the user provided. + // + // But since this is a deprecated feature anyway, what we can do is clone + // the props object and replace it with the internal callback ref. Then we + // can continue to use the props object as the source of truth. + // + // This means the internal callback ref will leak into userspace. The + // receiving component will receive a callback ref even though the parent + // passed a string. Which is weird, but again, this is a deprecated + // feature, and we're only leaving it around behind a flag so that Meta + // can keep using string refs temporarily while they finish migrating + // their codebase. + var userProvidedProps = workInProgress.pendingProps; + var propsWithInternalCallbackRef = assign({}, userProvidedProps); + propsWithInternalCallbackRef.ref = coercedRef; + workInProgress.pendingProps = propsWithInternalCallbackRef; + } + } else { + coercedRef = mixedRef; } // TODO: If enableRefAsProp is on, we shouldn't use the `ref` field. We // should always read the ref from the prop. - workInProgress.ref = ref; + workInProgress.ref = coercedRef; } function throwOnInvalidObjectType(returnFiber, newChild) { @@ -13368,6 +13503,8 @@ if (__DEV__) { /* */ 8; + var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentBatchConfig$3 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; var didWarnUncachedGetSnapshot; var didWarnAboutUseWrappedInTryCatch; @@ -13533,8 +13670,8 @@ if (__DEV__) { didWarnAboutUseFormState.add(componentName); error( - "ReactDOM.useFormState has been renamed to React.useActionState. " + - "Please update %s to use React.useActionState.", + "ReactDOM.useFormState has been deprecated and replaced by " + + "React.useActionState. Please update %s to use React.useActionState.", componentName ); } @@ -13670,16 +13807,17 @@ if (__DEV__) { { if (current !== null && current.memoizedState !== null) { - ReactSharedInternals.H = HooksDispatcherOnUpdateInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, // but no stateful hooks have been used. // We want to match the production code behavior (which will use HooksDispatcherOnMount), // but with the extra DEV validation to ensure hooks ordering hasn't changed. // This dispatcher does that. - ReactSharedInternals.H = HooksDispatcherOnMountWithHookTypesInDEV; + ReactCurrentDispatcher$1.current = + HooksDispatcherOnMountWithHookTypesInDEV; } else { - ReactSharedInternals.H = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; } } // In Strict Mode, during development, user functions are double invoked to // help detect side effects. The logic for how this is implemented for in @@ -13751,7 +13889,7 @@ if (__DEV__) { } // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrance. - ReactSharedInternals.H = ContextOnlyDispatcher; // This check uses currentHook so that it works the same in DEV and prod bundles. + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; // This check uses currentHook so that it works the same in DEV and prod bundles. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = @@ -13924,7 +14062,7 @@ if (__DEV__) { hookTypesUpdateIndexDev = -1; } - ReactSharedInternals.H = HooksDispatcherOnRerenderInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV; children = Component(props, secondArg); } while (didScheduleRenderPhaseUpdateDuringThisPass); @@ -13946,34 +14084,18 @@ if (__DEV__) { ); } function TransitionAwareHostComponent() { - var dispatcher = ReactSharedInternals.H; + var dispatcher = ReactCurrentDispatcher$1.current; var _dispatcher$useState = dispatcher.useState(), maybeThenable = _dispatcher$useState[0]; - var nextState; - if (typeof maybeThenable.then === "function") { var thenable = maybeThenable; - nextState = useThenable(thenable); + return useThenable(thenable); } else { var status = maybeThenable; - nextState = status; - } // The "reset state" is an object. If it changes, that means something - // requested that we reset the form. - - var _dispatcher$useState2 = dispatcher.useState(), - nextResetState = _dispatcher$useState2[0]; - - var prevResetState = - currentHook !== null ? currentHook.memoizedState : null; - - if (prevResetState !== nextResetState) { - // Schedule a form reset - currentlyRenderingFiber$1.flags |= FormReset; + return status; } - - return nextState; } function checkDidRenderIdHook() { // This should be called immediately after every renderWithHooks call. @@ -14010,7 +14132,7 @@ if (__DEV__) { currentlyRenderingFiber$1 = null; // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrance. - ReactSharedInternals.H = ContextOnlyDispatcher; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; } function resetHooksOnUnwind(workInProgress) { if (didScheduleRenderPhaseUpdate) { @@ -14184,7 +14306,7 @@ if (__DEV__) { // time (perhaps because it threw). Subsequent Hook calls should use the // mount dispatcher. { - ReactSharedInternals.H = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; } } @@ -15026,14 +15148,14 @@ if (__DEV__) { var action = actionQueue.action; var prevState = actionQueue.state; // This is a fork of startTransition - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig$3.transition; var currentTransition = { _callbacks: new Set() }; - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$3.transition = currentTransition; { - ReactSharedInternals.T._updatedFibers = new Set(); + ReactCurrentBatchConfig$3.transition._updatedFibers = new Set(); } // Optimistically update the pending state, similar to useTransition. // This will be reverted automatically when all actions are finished. @@ -15091,7 +15213,7 @@ if (__DEV__) { setState(rejectedThenable); finishRunningActionStateAction(actionQueue, setPendingState, setState); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$3.transition = prevTransition; { if (prevTransition === null && currentTransition._updatedFibers) { @@ -15750,7 +15872,7 @@ if (__DEV__) { setCurrentUpdatePriority( higherEventPriority(previousPriority, ContinuousEventPriority) ); - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig$3.transition; var currentTransition = { _callbacks: new Set() }; @@ -15762,19 +15884,19 @@ if (__DEV__) { // optimistic update anyway to make it less likely the behavior accidentally // diverges; for example, both an optimistic update and this one should // share the same lane. - ReactSharedInternals.T = currentTransition; + ReactCurrentBatchConfig$3.transition = currentTransition; dispatchOptimisticSetState(fiber, false, queue, pendingState); } if (enableTransitionTracing) { if (options !== undefined && options.name !== undefined) { - currentTransition.name = options.name; - currentTransition.startTime = now$1(); + ReactCurrentBatchConfig$3.transition.name = options.name; + ReactCurrentBatchConfig$3.transition.startTime = now$1(); } } { - currentTransition._updatedFibers = new Set(); + ReactCurrentBatchConfig$3.transition._updatedFibers = new Set(); } try { @@ -15820,7 +15942,7 @@ if (__DEV__) { } } finally { setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$3.transition = prevTransition; { if (prevTransition === null && currentTransition._updatedFibers) { @@ -15848,8 +15970,46 @@ if (__DEV__) { ); } - var stateHook = ensureFormComponentIsStateful(formFiber); - var queue = stateHook.queue; + var queue; + + if (formFiber.memoizedState === null) { + // Upgrade this host component fiber to be stateful. We're going to pretend + // it was stateful all along so we can reuse most of the implementation + // for function components and useTransition. + // + // Create the state hook used by TransitionAwareHostComponent. This is + // essentially an inlined version of mountState. + var newQueue = { + pending: null, + lanes: NoLanes, + // We're going to cheat and intentionally not create a bound dispatch + // method, because we can call it directly in startTransition. + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: NotPendingTransition + }; + queue = newQueue; + var stateHook = { + memoizedState: NotPendingTransition, + baseState: NotPendingTransition, + baseQueue: null, + queue: newQueue, + next: null + }; // Add the state hook to both fiber alternates. The idea is that the fiber + // had this hook all along. + + formFiber.memoizedState = stateHook; + var alternate = formFiber.alternate; + + if (alternate !== null) { + alternate.memoizedState = stateHook; + } + } else { + // This fiber was already upgraded to be stateful. + var _stateHook = formFiber.memoizedState; + queue = _stateHook.queue; + } + startTransition( formFiber, queue, @@ -15857,104 +16017,11 @@ if (__DEV__) { NotPendingTransition, // TODO: We can avoid this extra wrapper, somehow. Figure out layering // once more of this function is implemented. function () { - // Automatically reset the form when the action completes. - requestFormReset$1(formFiber); return callback(formData); } ); } - function ensureFormComponentIsStateful(formFiber) { - var existingStateHook = formFiber.memoizedState; - - if (existingStateHook !== null) { - // This fiber was already upgraded to be stateful. - return existingStateHook; - } // Upgrade this host component fiber to be stateful. We're going to pretend - // it was stateful all along so we can reuse most of the implementation - // for function components and useTransition. - // - // Create the state hook used by TransitionAwareHostComponent. This is - // essentially an inlined version of mountState. - - var newQueue = { - pending: null, - lanes: NoLanes, - // We're going to cheat and intentionally not create a bound dispatch - // method, because we can call it directly in startTransition. - dispatch: null, - lastRenderedReducer: basicStateReducer, - lastRenderedState: NotPendingTransition - }; - var stateHook = { - memoizedState: NotPendingTransition, - baseState: NotPendingTransition, - baseQueue: null, - queue: newQueue, - next: null - }; // We use another state hook to track whether the form needs to be reset. - // The state is an empty object. To trigger a reset, we update the state - // to a new object. Then during rendering, we detect that the state has - // changed and schedule a commit effect. - - var initialResetState = {}; - var newResetStateQueue = { - pending: null, - lanes: NoLanes, - // We're going to cheat and intentionally not create a bound dispatch - // method, because we can call it directly in startTransition. - dispatch: null, - lastRenderedReducer: basicStateReducer, - lastRenderedState: initialResetState - }; - var resetStateHook = { - memoizedState: initialResetState, - baseState: initialResetState, - baseQueue: null, - queue: newResetStateQueue, - next: null - }; - stateHook.next = resetStateHook; // Add the hook list to both fiber alternates. The idea is that the fiber - // had this hook all along. - - formFiber.memoizedState = stateHook; - var alternate = formFiber.alternate; - - if (alternate !== null) { - alternate.memoizedState = stateHook; - } - - return stateHook; - } - - function requestFormReset$1(formFiber) { - var transition = requestCurrentTransition(); - - { - if (transition === null) { - // An optimistic update occurred, but startTransition is not on the stack. - // The form reset will be scheduled at default (sync) priority, which - // is probably not what the user intended. Most likely because the - // requestFormReset call happened after an `await`. - // TODO: Theoretically, requestFormReset is still useful even for - // non-transition updates because it allows you to update defaultValue - // synchronously and then wait to reset until after the update commits. - // I've chosen to warn anyway because it's more likely the `await` mistake - // described above. But arguably we shouldn't. - error( - "requestFormReset was called outside a transition or action. To " + - "fix, move to an action, or wrap with startTransition." - ); - } - } - - var stateHook = ensureFormComponentIsStateful(formFiber); - var newResetState = {}; - var resetStateHook = stateHook.next; - var resetStateQueue = resetStateHook.queue; - dispatchSetState(formFiber, resetStateQueue, newResetState); - } - function mountTransition() { var stateHook = mountStateImpl(false); // The `start` method never changes. @@ -16171,11 +16238,11 @@ if (__DEV__) { var lastRenderedReducer = queue.lastRenderedReducer; if (lastRenderedReducer !== null) { - var prevDispatcher = null; + var prevDispatcher; { - prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = + prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } @@ -16206,7 +16273,7 @@ if (__DEV__) { // Suppress the error. It will throw again in the render phase. } finally { { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } } } @@ -16480,25 +16547,27 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; mountHookTypesDev(); checkDepsAreArrayDev(deps); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -16509,13 +16578,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -16650,25 +16720,27 @@ if (__DEV__) { useMemo: function (create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -16679,13 +16751,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -16812,25 +16885,27 @@ if (__DEV__) { useMemo: function (create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -16841,13 +16916,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -16983,25 +17059,27 @@ if (__DEV__) { useMemo: function (create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnRerenderInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -17012,13 +17090,14 @@ if (__DEV__) { useState: function (initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -17165,26 +17244,28 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -17197,13 +17278,14 @@ if (__DEV__) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -17354,26 +17436,28 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -17386,13 +17470,14 @@ if (__DEV__) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -17543,26 +17628,28 @@ if (__DEV__) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useReducer: function (reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useRef: function (initialValue) { @@ -17575,13 +17662,14 @@ if (__DEV__) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = + InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderState(initialState); } finally { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } }, useDebugValue: function (value, formatterFn) { @@ -19058,20 +19146,7 @@ if (__DEV__) { // remove this extra check. alreadyResolvedDefaultProps ) { - var newProps = baseProps; - - if (enableRefAsProp) { - // Remove ref from the props object, if it exists. - if ("ref" in baseProps) { - newProps = {}; - - for (var propName in baseProps) { - if (propName !== "ref") { - newProps[propName] = baseProps[propName]; - } - } - } - } // Resolve default props. + var newProps = baseProps; // Resolve default props. Taken from old JSX runtime, where this used to live. var defaultProps = Component.defaultProps; @@ -19080,19 +19155,26 @@ if (__DEV__) { // default props here in the reconciler, rather than in the JSX runtime. (disableDefaultPropsExceptForClasses || !alreadyResolvedDefaultProps) ) { - // We may have already copied the props object above to remove ref. If so, - // we can modify that. Otherwise, copy the props object with Object.assign. - if (newProps === baseProps) { - newProps = assign({}, newProps, baseProps); - } // Taken from old JSX runtime, where this used to live. + newProps = assign({}, newProps, baseProps); - for (var _propName in defaultProps) { - if (newProps[_propName] === undefined) { - newProps[_propName] = defaultProps[_propName]; + for (var propName in defaultProps) { + if (newProps[propName] === undefined) { + newProps[propName] = defaultProps[propName]; } } } + if (enableRefAsProp) { + // Remove ref from the props object, if it exists. + if ("ref" in newProps) { + if (newProps === baseProps) { + newProps = assign({}, newProps); + } + + delete newProps.ref; + } + } + return newProps; } @@ -19159,6 +19241,8 @@ if (__DEV__) { console["error"](error); }; + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API + var componentName = null; var errorBoundaryName = null; function defaultOnUncaughtError(error, errorInfo) { @@ -19223,10 +19307,10 @@ if (__DEV__) { var error = errorInfo.value; - if (true && ReactSharedInternals.actQueue !== null) { + if (true && ReactCurrentActQueue$2.current !== null) { // For uncaught errors inside act, we track them on the act and then // rethrow them into the test. - ReactSharedInternals.thrownErrors.push(error); + ReactCurrentActQueue$2.thrownErrors.push(error); return; } @@ -20079,6 +20163,7 @@ if (__DEV__) { return null; } + var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; // A special exception that's used to unwind the stack when an update flows // into a dehydrated boundary. var SelectiveHydrationException = new Error( @@ -20212,7 +20297,7 @@ if (__DEV__) { } { - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$2.current = workInProgress; setIsRendering(true); nextChildren = renderWithHooks( current, @@ -20897,7 +20982,7 @@ if (__DEV__) { } { - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$2.current = workInProgress; setIsRendering(true); nextChildren = renderWithHooks( current, @@ -21130,10 +21215,7 @@ if (__DEV__) { var instance = workInProgress.stateNode; // Rerender - { - ReactSharedInternals.owner = workInProgress; - } - + ReactCurrentOwner$2.current = workInProgress; var nextChildren; if ( @@ -23171,7 +23253,7 @@ if (__DEV__) { var newChildren; { - ReactSharedInternals.owner = workInProgress; + ReactCurrentOwner$2.current = workInProgress; setIsRendering(true); newChildren = render(newValue); setIsRendering(false); @@ -24691,8 +24773,10 @@ if (__DEV__) { popProvider(CacheContext, workInProgress); } + var ReactCurrentBatchConfig$2 = + ReactSharedInternals.ReactCurrentBatchConfig; function requestCurrentTransition() { - var transition = ReactSharedInternals.T; + var transition = ReactCurrentBatchConfig$2.transition; if (transition !== null) { // Whenever a transition update is scheduled, register a callback on the @@ -26641,9 +26725,7 @@ if (__DEV__) { // Allows us to avoid traversing the return path to find the nearest Offscreen ancestor. var offscreenSubtreeIsHidden = false; - var offscreenSubtreeWasHidden = false; // Used to track if a form needs to be reset at the end of the mutation phase. - - var needsFormReset = false; + var offscreenSubtreeWasHidden = false; var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; var nextEffect = null; // Used for Profiling builds to track updaters. @@ -29239,21 +29321,6 @@ if (__DEV__) { } } } - - if (flags & FormReset) { - needsFormReset = true; - - { - if (finishedWork.type !== "form") { - // Paranoid coding. In case we accidentally start using the - // FormReset bit for something else. - error( - "Unexpected host component type. Expected a form. This is a " + - "bug in React." - ); - } - } - } } return; @@ -29324,20 +29391,6 @@ if (__DEV__) { } } - if (needsFormReset) { - // A form component requested to be reset during this commit. We do this - // after all mutations in the rest of the tree so that `defaultValue` - // will already be updated. This way you can update `defaultValue` using - // data sent by the server as a result of the form submission. - // - // Theoretically we could check finishedWork.subtreeFlags & FormReset, - // but the FormReset bit is overloaded with other flags used by other - // fiber types. So this extra variable lets us skip traversing the tree - // except when a form was actually submitted. - needsFormReset = false; - recursivelyResetForms(finishedWork); - } - return; } @@ -29565,26 +29618,6 @@ if (__DEV__) { } } - function recursivelyResetForms(parentFiber) { - if (parentFiber.subtreeFlags & FormReset) { - var child = parentFiber.child; - - while (child !== null) { - resetFormOnFiber(child); - child = child.sibling; - } - } - } - - function resetFormOnFiber(fiber) { - recursivelyResetForms(fiber); - - if (fiber.tag === HostComponent && fiber.flags & FormReset) { - var formInstance = fiber.stateNode; - resetFormInstance(formInstance); - } - } - function commitLayoutEffects(finishedWork, root, committedLanes) { inProgressLanes = committedLanes; inProgressRoot = root; @@ -31241,6 +31274,7 @@ if (__DEV__) { } } + var ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; function isLegacyActEnvironment(fiber) { { // Legacy mode. We preserve the behavior of React 17's act. It assumes an @@ -31265,7 +31299,7 @@ if (__DEV__) { if ( !isReactActEnvironmentGlobal && - ReactSharedInternals.actQueue !== null + ReactCurrentActQueue$1.current !== null ) { // TODO: Include link to relevant documentation page. error( @@ -31297,6 +31331,11 @@ if (__DEV__) { } var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentCache = ReactSharedInternals.ReactCurrentCache, + ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, + ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig, + ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue; var NoContext = /* */ 0; @@ -31598,11 +31637,13 @@ if (__DEV__) { if (transition !== null) { { - if (!transition._updatedFibers) { - transition._updatedFibers = new Set(); + var batchConfigTransition = ReactCurrentBatchConfig$1.transition; + + if (!batchConfigTransition._updatedFibers) { + batchConfigTransition._updatedFibers = new Set(); } - transition._updatedFibers.add(fiber); + batchConfigTransition._updatedFibers.add(fiber); } var actionScopeLane = peekEntangledActionLane(); @@ -31611,9 +31652,26 @@ if (__DEV__) { : // is the first update in that scope. Either way, we need to get a // fresh transition lane. requestTransitionLane(); - } + } // Updates originating inside certain React methods, like flushSync, have + // their priority set by tracking it with a context variable. + // + // The opaque type returned by the host config is internally a lane, so we can + // use that directly. + // TODO: Move this type conversion to the event priority module. - return eventPriorityToLane(resolveUpdatePriority()); + var updateLane = getCurrentUpdatePriority(); + + if (updateLane !== NoLane) { + return updateLane; + } // This update originated outside React. Ask the host environment for an + // appropriate priority, based on the type of event. + // + // The opaque type returned by the host config is internally a lane, so we can + // use that directly. + // TODO: Move this type conversion to the event priority module. + + var eventLane = getCurrentEventPriority(); + return eventLane; } function requestRetryLane(fiber) { @@ -31724,13 +31782,12 @@ if (__DEV__) { warnIfUpdatesNotWrappedWithActDEV(fiber); if (enableTransitionTracing) { - var transition = ReactSharedInternals.T; + var transition = ReactCurrentBatchConfig$1.transition; if (transition !== null && transition.name != null) { if (transition.startTime === -1) { transition.startTime = now$1(); - } // $FlowFixMe[prop-missing]: The BatchConfigTransition and Transition types are incompatible but was previously untyped and thus uncaught - // $FlowFixMe[incompatible-call]: " + } addTransitionToLanesMap(root, transition, lane); } @@ -31769,7 +31826,7 @@ if (__DEV__) { !disableLegacyMode && (fiber.mode & ConcurrentMode) === NoMode ) { - if (ReactSharedInternals.isBatchingLegacy); + if (ReactCurrentActQueue.isBatchingLegacy); else { // Flush the synchronous work now, unless we're already working or inside // a batch. This is intentionally inside scheduleUpdateOnFiber instead of @@ -31886,31 +31943,20 @@ if (__DEV__) { } // Check if something threw if (exitStatus === RootErrored) { - var lanesThatJustErrored = lanes; + var originallyAttemptedLanes = lanes; var errorRetryLanes = getLanesToRetrySynchronouslyOnError( root, - lanesThatJustErrored + originallyAttemptedLanes ); if (errorRetryLanes !== NoLanes) { lanes = errorRetryLanes; exitStatus = recoverFromConcurrentError( root, - lanesThatJustErrored, + originallyAttemptedLanes, errorRetryLanes ); - renderWasConcurrent = false; // Need to check the exit status again. - - if (exitStatus !== RootErrored) { - // The root did not error this time. Restart the exit algorithm - // from the beginning. - // TODO: Refactor the exit algorithm to be less confusing. Maybe - // more branches + recursion instead of a loop. I think the only - // thing that causes it to be a loop is the RootDidNotComplete - // check. If that's true, then we don't need a loop/recursion - // at all. - continue; - } + renderWasConcurrent = false; } } @@ -32400,7 +32446,7 @@ if (__DEV__) { if ( executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactSharedInternals.isBatchingLegacy + !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); flushSyncWorkOnLegacyRootsOnly(); @@ -32413,7 +32459,7 @@ if (__DEV__) { // eslint-disable-next-line no-redeclare // eslint-disable-next-line no-redeclare - function flushSyncFromReconciler$1(fn) { + function flushSync$1(fn) { // In legacy mode, we flush pending passive effects at the beginning of the // next event, not at the end of the previous one. if ( @@ -32427,12 +32473,12 @@ if (__DEV__) { var prevExecutionContext = executionContext; executionContext |= BatchedContext; - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig$1.transition; var previousPriority = getCurrentUpdatePriority(); try { + ReactCurrentBatchConfig$1.transition = null; setCurrentUpdatePriority(DiscreteEventPriority); - ReactSharedInternals.T = null; if (fn) { return fn(); @@ -32441,7 +32487,7 @@ if (__DEV__) { } } finally { setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$1.transition = prevTransition; executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. // Note that this will happen even if batchedUpdates is higher up // the stack. @@ -32453,16 +32499,6 @@ if (__DEV__) { flushSyncWorkOnAllRoots(); } } - } // If called outside of a render or commit will flush all sync work on all roots - // Returns whether the the call was during a render or not - - function flushSyncWork() { - if ((executionContext & (RenderContext | CommitContext)) === NoContext) { - flushSyncWorkOnAllRoots(); - return false; - } - - return true; } function isAlreadyRendering() { // Used by the renderer to print a warning if certain APIs are called from @@ -32585,10 +32621,7 @@ if (__DEV__) { // when React is executing user code. resetHooksAfterThrow(); resetCurrentFiber(); - - { - ReactSharedInternals.owner = null; - } + ReactCurrentOwner$1.current = null; if (thrownValue === SuspenseException) { // This is a special type of exception used for Suspense. For historical @@ -32740,8 +32773,8 @@ if (__DEV__) { } function pushDispatcher(container) { - var prevDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; if (prevDispatcher === null) { // The React isomorphic package does not include a default dispatcher. @@ -32754,20 +32787,20 @@ if (__DEV__) { } function popDispatcher(prevDispatcher) { - ReactSharedInternals.H = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } function pushCacheDispatcher() { { - var prevCacheDispatcher = ReactSharedInternals.C; - ReactSharedInternals.C = DefaultCacheDispatcher; + var prevCacheDispatcher = ReactCurrentCache.current; + ReactCurrentCache.current = DefaultCacheDispatcher; return prevCacheDispatcher; } } function popCacheDispatcher(prevCacheDispatcher) { { - ReactSharedInternals.C = prevCacheDispatcher; + ReactCurrentCache.current = prevCacheDispatcher; } } @@ -33194,7 +33227,7 @@ if (__DEV__) { } } - if (true && ReactSharedInternals.actQueue !== null) { + if (true && ReactCurrentActQueue.current !== null) { // `act` special case: If we're inside an `act` scope, don't consult // `shouldYield`. Always keep working until the render is complete. // This is not just an optimization: in a unit test environment, we @@ -33279,9 +33312,7 @@ if (__DEV__) { workInProgress = next; } - { - ReactSharedInternals.owner = null; - } + ReactCurrentOwner$1.current = null; } function replaySuspendedUnitOfWork(unitOfWork) { @@ -33409,9 +33440,7 @@ if (__DEV__) { workInProgress = next; } - { - ReactSharedInternals.owner = null; - } + ReactCurrentOwner$1.current = null; } function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { @@ -33621,12 +33650,12 @@ if (__DEV__) { ) { // TODO: This no longer makes any sense. We already wrap the mutation and // layout phases. Should be able to remove. - var prevTransition = ReactSharedInternals.T; var previousUpdateLanePriority = getCurrentUpdatePriority(); + var prevTransition = ReactCurrentBatchConfig$1.transition; try { + ReactCurrentBatchConfig$1.transition = null; setCurrentUpdatePriority(DiscreteEventPriority); - ReactSharedInternals.T = null; commitRootImpl( root, recoverableErrors, @@ -33636,7 +33665,7 @@ if (__DEV__) { spawnedLane ); } finally { - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$1.transition = prevTransition; setCurrentUpdatePriority(previousUpdateLanePriority); } @@ -33780,16 +33809,14 @@ if (__DEV__) { NoFlags$1; if (subtreeHasEffects || rootHasEffect) { - var prevTransition = ReactSharedInternals.T; - ReactSharedInternals.T = null; + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = null; var previousPriority = getCurrentUpdatePriority(); setCurrentUpdatePriority(DiscreteEventPriority); var prevExecutionContext = executionContext; executionContext |= CommitContext; // Reset this to null before calling lifecycles - { - ReactSharedInternals.owner = null; - } // The commit phase is broken into several sub-phases. We do a separate pass + ReactCurrentOwner$1.current = null; // The commit phase is broken into several sub-phases. We do a separate pass // of the effect list for each phase: all mutation effects come before all // layout effects, and so on. // The first phase a "before mutation" phase. We use this phase to read the @@ -33851,7 +33878,7 @@ if (__DEV__) { executionContext = prevExecutionContext; // Reset the priority to the previous non-sync value. setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; + ReactCurrentBatchConfig$1.transition = prevTransition; } else { // No effects. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were @@ -34078,16 +34105,16 @@ if (__DEV__) { pendingPassiveEffectsRemainingLanes = NoLanes; var renderPriority = lanesToEventPriority(pendingPassiveEffectsLanes); var priority = lowerEventPriority(DefaultEventPriority, renderPriority); - var prevTransition = ReactSharedInternals.T; + var prevTransition = ReactCurrentBatchConfig$1.transition; var previousPriority = getCurrentUpdatePriority(); try { + ReactCurrentBatchConfig$1.transition = null; setCurrentUpdatePriority(priority); - ReactSharedInternals.T = null; return flushPassiveEffectsImpl(); } finally { setCurrentUpdatePriority(previousPriority); - ReactSharedInternals.T = prevTransition; // Once passive effects have run for the tree - giving components a + ReactCurrentBatchConfig$1.transition = prevTransition; // Once passive effects have run for the tree - giving components a // chance to retain cache instances they use - release the pooled // cache at the root (if there is one) @@ -34842,7 +34869,7 @@ if (__DEV__) { { // If we're currently inside an `act` scope, bypass Scheduler and push to // the `act` queue instead. - var actQueue = ReactSharedInternals.actQueue; + var actQueue = ReactCurrentActQueue.current; if (actQueue !== null) { actQueue.push(callback); @@ -34855,7 +34882,7 @@ if (__DEV__) { function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. - return ReactSharedInternals.actQueue !== null; + return ReactCurrentActQueue.current !== null; } function warnIfUpdatesNotWrappedWithActDEV(fiber) { @@ -34889,7 +34916,7 @@ if (__DEV__) { } } - if (ReactSharedInternals.actQueue === null) { + if (ReactCurrentActQueue.current === null) { var previousFiber = current; try { @@ -34924,7 +34951,7 @@ if (__DEV__) { if ( root.tag !== LegacyRoot && isConcurrentActEnvironment() && - ReactSharedInternals.actQueue === null + ReactCurrentActQueue.current === null ) { error( "A suspended resource finished loading inside a test, but the event " + @@ -35133,12 +35160,13 @@ if (__DEV__) { var staleFamilies = update.staleFamilies, updatedFamilies = update.updatedFamilies; flushPassiveEffects(); - scheduleFibersWithFamiliesRecursively( - root.current, - updatedFamilies, - staleFamilies - ); - flushSyncWork(); + flushSync$1(function () { + scheduleFibersWithFamiliesRecursively( + root.current, + updatedFamilies, + staleFamilies + ); + }); } }; var scheduleRoot = function (root, element) { @@ -35150,8 +35178,10 @@ if (__DEV__) { return; } - updateContainerSync(element, root, null, null); - flushSyncWork(); + flushPassiveEffects(); + flushSync$1(function () { + updateContainer(element, root, null, null); + }); } }; @@ -35887,7 +35917,7 @@ if (__DEV__) { "named imports."; } - var ownerName = owner ? getComponentNameFromOwner(owner) : null; + var ownerName = owner ? getComponentNameFromFiber(owner) : null; if (ownerName) { info += "\n\nCheck the render method of `" + ownerName + "`."; @@ -36230,7 +36260,7 @@ if (__DEV__) { return root; } - var ReactVersion = "19.0.0-www-classic-3b25da96"; + var ReactVersion = "19.0.0-www-classic-82184e0e"; function createPortal$1( children, @@ -36457,52 +36487,13 @@ if (__DEV__) { return root; } function updateContainer(element, container, parentComponent, callback) { - var current = container.current; - var lane = requestUpdateLane(current); - updateContainerImpl( - current, - lane, - element, - container, - parentComponent, - callback - ); - return lane; - } - function updateContainerSync( - element, - container, - parentComponent, - callback - ) { - if (container.tag === LegacyRoot) { - flushPassiveEffects(); - } - - var current = container.current; - updateContainerImpl( - current, - SyncLane, - element, - container, - parentComponent, - callback - ); - return SyncLane; - } - - function updateContainerImpl( - rootFiber, - lane, - element, - container, - parentComponent, - callback - ) { { onScheduleRoot(container, element); } + var current$1 = container.current; + var lane = requestUpdateLane(current$1); + if (enableSchedulingProfiler) { markRenderScheduled(lane); } @@ -36551,12 +36542,14 @@ if (__DEV__) { update.callback = callback; } - var root = enqueueUpdate(rootFiber, update, lane); + var root = enqueueUpdate(current$1, update, lane); if (root !== null) { - scheduleUpdateOnFiber(root, rootFiber, lane); - entangleTransitions(root, rootFiber, lane); + scheduleUpdateOnFiber(root, current$1, lane); + entangleTransitions(root, current$1, lane); } + + return lane; } function getPublicRootInstance(container) { var containerFiber = container.current; @@ -36589,13 +36582,13 @@ if (__DEV__) { } case SuspenseComponent: { - var _root = enqueueConcurrentRenderForLane(fiber, SyncLane); + flushSync$1(function () { + var root = enqueueConcurrentRenderForLane(fiber, SyncLane); - if (_root !== null) { - scheduleUpdateOnFiber(_root, fiber, SyncLane); - } - - flushSyncWork(); // If we're still blocked after this, we need to increase + if (root !== null) { + scheduleUpdateOnFiber(root, fiber, SyncLane); + } + }); // If we're still blocked after this, we need to increase // the priority of any promises resolving within this // boundary so that they next attempt also has higher pri. @@ -36941,6 +36934,7 @@ if (__DEV__) { function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; return injectInternals({ bundleType: devToolsConfig.bundleType, version: devToolsConfig.version, @@ -36955,7 +36949,7 @@ if (__DEV__) { setErrorHandler: setErrorHandler, setSuspenseHandler: setSuspenseHandler, scheduleUpdate: scheduleUpdate, - currentDispatcherRef: ReactSharedInternals, + currentDispatcherRef: ReactCurrentDispatcher, findHostInstanceByFiber: findHostInstanceByFiber, findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance, @@ -36992,9 +36986,7 @@ if (__DEV__) { // bails out of the update without touching the DOM. // TODO: Restore state in the microtask, after the discrete updates flush, // instead of early flushing them here. - // @TODO Should move to flushSyncWork once legacy mode is removed but since this flushSync - // flushes passive effects we can't do this yet. - flushSyncWork(); + flushSync$1(); restoreStateIfNeeded(); } } @@ -39415,9 +39407,6 @@ if (__DEV__) { animationend: makePrefixMap("Animation", "AnimationEnd"), animationiteration: makePrefixMap("Animation", "AnimationIteration"), animationstart: makePrefixMap("Animation", "AnimationStart"), - transitionrun: makePrefixMap("Transition", "TransitionRun"), - transitionstart: makePrefixMap("Transition", "TransitionStart"), - transitioncancel: makePrefixMap("Transition", "TransitionCancel"), transitionend: makePrefixMap("Transition", "TransitionEnd") }; /** @@ -39478,9 +39467,6 @@ if (__DEV__) { var ANIMATION_END = getVendorPrefixedEventName("animationend"); var ANIMATION_ITERATION = getVendorPrefixedEventName("animationiteration"); var ANIMATION_START = getVendorPrefixedEventName("animationstart"); - var TRANSITION_RUN = getVendorPrefixedEventName("transitionrun"); - var TRANSITION_START = getVendorPrefixedEventName("transitionstart"); - var TRANSITION_CANCEL = getVendorPrefixedEventName("transitioncancel"); var TRANSITION_END = getVendorPrefixedEventName("transitionend"); var topLevelEventsToReactNames = new Map(); // NOTE: Capitalization is important in this list! @@ -39521,9 +39507,6 @@ if (__DEV__) { registerSimpleEvent("dblclick", "onDoubleClick"); registerSimpleEvent("focusin", "onFocus"); registerSimpleEvent("focusout", "onBlur"); - registerSimpleEvent(TRANSITION_RUN, "onTransitionRun"); - registerSimpleEvent(TRANSITION_START, "onTransitionStart"); - registerSimpleEvent(TRANSITION_CANCEL, "onTransitionCancel"); registerSimpleEvent(TRANSITION_END, "onTransitionEnd"); } @@ -40811,7 +40794,8 @@ if (__DEV__) { // in that browser completely in favor of doing all that work. // See https://github.com/facebook/react/issues/11807 - canDiffStyleForHydrationWarning = disableIEWorkarounds; + canDiffStyleForHydrationWarning = + disableIEWorkarounds || (canUseDOM && !document.documentMode); } function validatePropertiesInDevelopment(type, props) { @@ -41052,7 +41036,7 @@ if (__DEV__) { return false; } - function noop$1() {} + function noop$2() {} function trapClickOnNonInteractiveElement(node) { // Mobile Safari does not fire properly bubble click events on @@ -41064,7 +41048,7 @@ if (__DEV__) { // bookkeeping for it. Not sure if we need to clear it when the listener is // removed. // TODO: Only do this for the relevant Safaris maybe? - node.onclick = noop$1; + node.onclick = noop$2; } var xlinkNamespace = "http://www.w3.org/1999/xlink"; var xmlNamespace = "http://www.w3.org/XML/1998/namespace"; @@ -41331,8 +41315,10 @@ if (__DEV__) { ); } - { + if (disableIEWorkarounds) { domElement.innerHTML = nextHtml; + } else { + setInnerHTML$1(domElement, nextHtml); } } } @@ -41718,8 +41704,10 @@ if (__DEV__) { ); } - { + if (disableIEWorkarounds) { domElement.innerHTML = nextHtml; + } else { + setInnerHTML$1(domElement, nextHtml); } } } @@ -44253,6 +44241,28 @@ if (__DEV__) { } } + function noop$1() {} + + var DefaultDispatcher = { + prefetchDNS: noop$1, + preconnect: noop$1, + preload: noop$1, + preloadModule: noop$1, + preinitScript: noop$1, + preinitStyle: noop$1, + preinitModuleScript: noop$1 + }; + var Internals = { + usingClientEntryPoint: false, + Events: null, + ReactDOMCurrentDispatcher: { + current: DefaultDispatcher + }, + findDOMNode: null + }; + + var ReactDOMCurrentDispatcher$1 = Internals.ReactDOMCurrentDispatcher; // Unused + var SUPPRESS_HYDRATION_WARNING = "suppressHydrationWarning"; var SUSPENSE_START_DATA = "$"; var SUSPENSE_END_DATA = "/$"; @@ -44658,6 +44668,15 @@ if (__DEV__) { precacheFiberNode(internalInstanceHandle, textNode); return textNode; } + function getCurrentEventPriority() { + var currentEvent = window.event; + + if (currentEvent === undefined) { + return DefaultEventPriority; + } + + return getEventPriority(currentEvent.type); + } var currentPopstateTransitionEvent = null; function shouldAttemptEagerTransition() { var event = window.event; @@ -45671,60 +45690,16 @@ if (__DEV__) { return root.ownerDocument || root; } - var previousDispatcher = Internals.d; - /* ReactDOMCurrentDispatcher */ - - Internals.d = - /* ReactDOMCurrentDispatcher */ - { - f: - /* flushSyncWork */ - previousDispatcher.f, - /* flushSyncWork */ - r: requestFormReset, - D: - /* prefetchDNS */ - prefetchDNS$1, - C: - /* preconnect */ - preconnect$1, - L: - /* preload */ - preload$1, - m: - /* preloadModule */ - preloadModule$1, - X: - /* preinitScript */ - preinitScript, - S: - /* preinitStyle */ - preinitStyle, - M: - /* preinitModuleScript */ - preinitModuleScript - }; - - function requestFormReset(form) { - var formInst = getInstanceFromNode(form); - - if ( - formInst !== null && - formInst.tag === HostComponent && - formInst.type === "form" - ) { - requestFormReset$1(formInst); - } else { - // This form was either not rendered by this React renderer (or it's an - // invalid type). Try the next one. - // - // The last implementation in the sequence will throw an error. - previousDispatcher.r( - /* requestFormReset */ - form - ); - } - } // We expect this to get inlined. It is a function mostly to communicate the special nature of + var previousDispatcher = ReactDOMCurrentDispatcher$1.current; + ReactDOMCurrentDispatcher$1.current = { + prefetchDNS: prefetchDNS$1, + preconnect: preconnect$1, + preload: preload$1, + preloadModule: preloadModule$1, + preinitStyle: preinitStyle, + preinitScript: preinitScript, + preinitModuleScript: preinitModuleScript + }; // We expect this to get inlined. It is a function mostly to communicate the special nature of // how we resolve the HoistableRoot for ReactDOM.pre*() methods. Because we support calling // these methods outside of render there is no way to know which Document or ShadowRoot is 'scoped' // and so we have to fall back to something universal. Currently we just refer to the global document. @@ -45768,29 +45743,17 @@ if (__DEV__) { } function prefetchDNS$1(href) { - previousDispatcher.D( - /* prefetchDNS */ - href - ); + previousDispatcher.prefetchDNS(href); preconnectAs("dns-prefetch", href, null); } function preconnect$1(href, crossOrigin) { - previousDispatcher.C( - /* preconnect */ - href, - crossOrigin - ); + previousDispatcher.preconnect(href, crossOrigin); preconnectAs("preconnect", href, crossOrigin); } function preload$1(href, as, options) { - previousDispatcher.L( - /* preload */ - href, - as, - options - ); + previousDispatcher.preload(href, as, options); var ownerDocument = getGlobalDocument(); if (ownerDocument && href && as) { @@ -45887,11 +45850,7 @@ if (__DEV__) { } function preloadModule$1(href, options) { - previousDispatcher.m( - /* preloadModule */ - href, - options - ); + previousDispatcher.preloadModule(href, options); var ownerDocument = getGlobalDocument(); if (ownerDocument && href) { @@ -45957,12 +45916,7 @@ if (__DEV__) { } function preinitStyle(href, precedence, options) { - previousDispatcher.S( - /* preinitStyle */ - href, - precedence, - options - ); + previousDispatcher.preinitStyle(href, precedence, options); var ownerDocument = getGlobalDocument(); if (ownerDocument && href) { @@ -46035,11 +45989,7 @@ if (__DEV__) { } function preinitScript(src, options) { - previousDispatcher.X( - /* preinitScript */ - src, - options - ); + previousDispatcher.preinitScript(src, options); var ownerDocument = getGlobalDocument(); if (ownerDocument && src) { @@ -46092,11 +46042,7 @@ if (__DEV__) { } function preinitModuleScript(src, options) { - previousDispatcher.M( - /* preinitModuleScript */ - src, - options - ); + previousDispatcher.preinitModuleScript(src, options); var ownerDocument = getGlobalDocument(); if (ownerDocument && src) { @@ -46240,16 +46186,13 @@ if (__DEV__) { } case "script": { - var async = pendingProps.async; - var src = pendingProps.src; - if ( - typeof src === "string" && - async && - typeof async !== "function" && - typeof async !== "symbol" + typeof pendingProps.src === "string" && + pendingProps.async === true ) { - var _key2 = getScriptKey(src); + var scriptProps = pendingProps; + + var _key2 = getScriptKey(scriptProps.src); var scripts = getResourcesFromRoot(resourceRoot).hoistableScripts; @@ -46925,21 +46868,16 @@ if (__DEV__) { } case "script": { - var isAsync = - props.async && - typeof props.async !== "function" && - typeof props.async !== "symbol"; - if ( - !isAsync || + props.async !== true || props.onLoad || props.onError || - !props.src || - typeof props.src !== "string" + typeof props.src !== "string" || + !props.src ) { { if (outsideHostContainerContext) { - if (!isAsync) { + if (props.async !== true) { error( "Cannot render a sync or defer