diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js index 32d3ce4cb7fdc..4add0975e7f1c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -25686,7 +25686,7 @@ if (__DEV__) { return root; } - var ReactVersion = "18.3.0-canary-ec160f32c-20240219"; + var ReactVersion = "18.3.0-canary-5fb2c93f3-20240219"; // Might add PROFILE later. diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js index 7426b665293cb..385ca7e83513d 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -9176,7 +9176,7 @@ var devToolsConfig$jscomp$inline_1014 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-canary-ec160f32c-20240219", + version: "18.3.0-canary-5fb2c93f3-20240219", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1195 = { @@ -9207,7 +9207,7 @@ var internals$jscomp$inline_1195 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-ec160f32c-20240219" + reconcilerVersion: "18.3.0-canary-5fb2c93f3-20240219" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1196 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js index 0a43c544c6ac6..ea5b64dce9f9d 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -9604,7 +9604,7 @@ var devToolsConfig$jscomp$inline_1056 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-canary-ec160f32c-20240219", + version: "18.3.0-canary-5fb2c93f3-20240219", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1236 = { @@ -9635,7 +9635,7 @@ var internals$jscomp$inline_1236 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-ec160f32c-20240219" + reconcilerVersion: "18.3.0-canary-5fb2c93f3-20240219" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1237 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js index 9cbdb84e548a4..dd6d08a878978 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<9d1803d74418a7ac44bc89ae8cd0f170>> */ "use strict"; @@ -1025,13 +1025,11 @@ if (__DEV__) { */ function isValidElement(object) { - { - return ( - typeof object === "object" && - object !== null && - object.$$typeof === REACT_ELEMENT_TYPE - ); - } + return ( + typeof object === "object" && + object !== null && + object.$$typeof === REACT_ELEMENT_TYPE + ); } var ownerHasKeyUseWarning = {}; /** diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js index d309451c88ea6..98dfd4c08b189 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<040e6a4059e2c6d1c22e6d708cbf3b39>> + * @generated SignedSource<<8af9696c59d9d4cfa4cc835b5a54e94e>> */ "use strict"; @@ -1061,13 +1061,11 @@ if (__DEV__) { */ function isValidElement(object) { - { - return ( - typeof object === "object" && - object !== null && - object.$$typeof === REACT_ELEMENT_TYPE - ); - } + return ( + typeof object === "object" && + object !== null && + object.$$typeof === REACT_ELEMENT_TYPE + ); } var ownerHasKeyUseWarning = {}; /** diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js index f579f6fb91c40..1adc29f217f3c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<771f900d99c19be9a9ca908e40980fa4>> */ "use strict"; @@ -24,7 +24,7 @@ if (__DEV__) { ) { __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); } - var ReactVersion = "18.3.0-canary-ec160f32c-20240219"; + var ReactVersion = "18.3.0-canary-5fb2c93f3-20240219"; // ATTENTION // When adding new symbols to this file, @@ -117,11 +117,6 @@ if (__DEV__) { var ReactDebugCurrentFrame$2 = {}; var currentExtraStackFrame = null; - function setExtraStackFrame(stack) { - { - currentExtraStackFrame = stack; - } - } { ReactDebugCurrentFrame$2.setExtraStackFrame = function (stack) { @@ -591,7 +586,7 @@ if (__DEV__) { return type.displayName || "Context"; } - var REACT_CLIENT_REFERENCE$3 = Symbol.for("react.client.reference"); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead. + var REACT_CLIENT_REFERENCE$2 = Symbol.for("react.client.reference"); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead. function getComponentNameFromType(type) { if (type == null) { @@ -600,7 +595,7 @@ if (__DEV__) { } if (typeof type === "function") { - if (type.$$typeof === REACT_CLIENT_REFERENCE$3) { + if (type.$$typeof === REACT_CLIENT_REFERENCE$2) { // TODO: Create a convention for naming client references with debug info. return null; } @@ -691,992 +686,868 @@ if (__DEV__) { // $FlowFixMe[method-unbinding] var hasOwnProperty = Object.prototype.hasOwnProperty; - var specialPropKeyWarningShown$1, - specialPropRefWarningShown$1, - didWarnAboutStringRefs$1; - - { - didWarnAboutStringRefs$1 = {}; - } + var REACT_CLIENT_REFERENCE$1 = Symbol.for("react.client.reference"); + function isValidElementType(type) { + if (typeof type === "string" || typeof type === "function") { + return true; + } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). - function hasValidRef$1(config) { - { - if (hasOwnProperty.call(config, "ref")) { - var getter = Object.getOwnPropertyDescriptor(config, "ref").get; + if ( + type === REACT_FRAGMENT_TYPE || + type === REACT_PROFILER_TYPE || + enableDebugTracing || + type === REACT_STRICT_MODE_TYPE || + type === REACT_SUSPENSE_TYPE || + type === REACT_SUSPENSE_LIST_TYPE || + enableLegacyHidden || + type === REACT_OFFSCREEN_TYPE || + enableScopeAPI || + type === REACT_CACHE_TYPE || + enableTransitionTracing + ) { + return true; + } - if (getter && getter.isReactWarning) { - return false; - } + if (typeof type === "object" && type !== null) { + if ( + type.$$typeof === REACT_LAZY_TYPE || + type.$$typeof === REACT_MEMO_TYPE || + type.$$typeof === REACT_CONTEXT_TYPE || + type.$$typeof === REACT_PROVIDER_TYPE || + enableRenderableContext || + type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object + // types supported by any Flight configuration anywhere since + // we don't know which Flight build this will end up being used + // with. + type.$$typeof === REACT_CLIENT_REFERENCE$1 || + type.getModuleId !== undefined + ) { + return true; } } - return config.ref !== undefined; + return false; } - function hasValidKey$1(config) { + function describeBuiltInComponentFrame(name, ownerFn) { { - if (hasOwnProperty.call(config, "key")) { - var getter = Object.getOwnPropertyDescriptor(config, "key").get; + var ownerName = null; - if (getter && getter.isReactWarning) { - return false; - } + if (ownerFn) { + ownerName = ownerFn.displayName || ownerFn.name || null; } - } - return config.key !== undefined; + return describeComponentFrame(name, ownerName); + } } - function defineKeyPropWarningGetter$1(props, displayName) { - var warnAboutAccessingKey = function () { - { - if (!specialPropKeyWarningShown$1) { - specialPropKeyWarningShown$1 = true; - - error( - "%s: `key` is not a prop. Trying to access it will result " + - "in `undefined` being returned. If you need to access the same " + - "value within the child component, you should pass it as a different " + - "prop. (https://reactjs.org/link/special-props)", - displayName - ); - } - } - }; - - warnAboutAccessingKey.isReactWarning = true; - Object.defineProperty(props, "key", { - get: warnAboutAccessingKey, - configurable: true - }); + { + var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; + new PossiblyWeakMap(); } - function defineRefPropWarningGetter$1(props, displayName) { - var warnAboutAccessingRef = function () { - { - if (!specialPropRefWarningShown$1) { - specialPropRefWarningShown$1 = true; + function describeComponentFrame(name, ownerName) { + var sourceInfo = ""; - error( - "%s: `ref` is not a prop. Trying to access it will result " + - "in `undefined` being returned. If you need to access the same " + - "value within the child component, you should pass it as a different " + - "prop. (https://reactjs.org/link/special-props)", - displayName - ); - } - } - }; + if (ownerName) { + sourceInfo = " (created by " + ownerName + ")"; + } - warnAboutAccessingRef.isReactWarning = true; - Object.defineProperty(props, "ref", { - get: warnAboutAccessingRef, - configurable: true - }); + return "\n in " + (name || "Unknown") + sourceInfo; } - - function warnIfStringRefCannotBeAutoConverted$1(config) { + function describeFunctionComponentFrame(fn, ownerFn) { { - if ( - typeof config.ref === "string" && - ReactCurrentOwner$1.current && - config.__self && - ReactCurrentOwner$1.current.stateNode !== config.__self - ) { - var componentName = getComponentNameFromType( - ReactCurrentOwner$1.current.type - ); + if (!fn) { + return ""; + } - if (!didWarnAboutStringRefs$1[componentName]) { - error( - 'Component "%s" contains the string ref "%s". ' + - "Support for string refs will be removed in a future major release. " + - "This case cannot be automatically converted to an arrow function. " + - "We ask you to manually fix this case by using useRef() or createRef() instead. " + - "Learn more about using refs safely here: " + - "https://reactjs.org/link/strict-mode-string-ref", - componentName, - config.ref - ); + var name = fn.displayName || fn.name || null; + var ownerName = null; - didWarnAboutStringRefs$1[componentName] = true; - } + if (ownerFn) { + ownerName = ownerFn.displayName || ownerFn.name || null; } + + return describeComponentFrame(name, ownerName); } } - /** - * Factory method to create a new React element. This no longer adheres to - * the class pattern, so do not use new to call it. Also, instanceof check - * will not work. Instead test $$typeof field against Symbol.for('react.element') to check - * if something is a React Element. - * - * @param {*} type - * @param {*} props - * @param {*} key - * @param {string|object} ref - * @param {*} owner - * @param {*} self A *temporary* helper to detect places where `this` is - * different from the `owner` when React.createElement is called, so that we - * can warn. We want to get rid of owner and replace string `ref`s with arrow - * functions, and as long as `this` and owner are the same, there will be no - * change in behavior. - * @param {*} source An annotation object (added by a transpiler or otherwise) - * indicating filename, line number, and/or other information. - * @internal - */ - - function ReactElement$1(type, key, ref, owner, props) { - var element = { - // This tag allows us to uniquely identify this as a React Element - $$typeof: REACT_ELEMENT_TYPE, - // Built-in properties that belong on the element - type: type, - key: key, - ref: ref, - props: props, - // Record the component responsible for creating this element. - _owner: owner - }; - - { - // The validation flag is currently mutative. We put it on - // an external backing store so that we can freeze the whole object. - // This can be replaced with a WeakMap once they are implemented in - // commonly used development environments. - element._store = {}; // To make comparing ReactElements easier for testing purposes, we make - // the validation flag non-enumerable (where possible, which should - // include every environment we run tests in), so the test framework - // ignores it. - - Object.defineProperty(element._store, "validated", { - configurable: false, - enumerable: false, - writable: true, - value: false - }); // debugInfo contains Server Component debug information. - Object.defineProperty(element, "_debugInfo", { - configurable: false, - enumerable: false, - writable: true, - value: null - }); + function describeUnknownElementTypeFrameInDEV(type, ownerFn) { + if (type == null) { + return ""; + } - if (Object.freeze) { - Object.freeze(element.props); - Object.freeze(element); + if (typeof type === "function") { + { + return describeFunctionComponentFrame(type, ownerFn); } } - return element; - } - /** - * Create and return a new ReactElement of the given type. - * See https://reactjs.org/docs/react-api.html#createelement - */ - - function createElement$1(type, config, children) { - var propName; // Reserved names are extracted + if (typeof type === "string") { + return describeBuiltInComponentFrame(type, ownerFn); + } - var props = {}; - var key = null; - var ref = null; + switch (type) { + case REACT_SUSPENSE_TYPE: + return describeBuiltInComponentFrame("Suspense", ownerFn); - if (config != null) { - if (hasValidRef$1(config)) { - ref = config.ref; + case REACT_SUSPENSE_LIST_TYPE: + return describeBuiltInComponentFrame("SuspenseList", ownerFn); + } - { - warnIfStringRefCannotBeAutoConverted$1(config); - } - } + if (typeof type === "object") { + switch (type.$$typeof) { + case REACT_FORWARD_REF_TYPE: + return describeFunctionComponentFrame(type.render, ownerFn); - if (hasValidKey$1(config)) { - { - checkKeyStringCoercion(config.key); - } + case REACT_MEMO_TYPE: + // Memo may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV(type.type, ownerFn); - key = "" + config.key; - } // Remaining properties are added to a new props object + case REACT_LAZY_TYPE: { + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; - for (propName in config) { - if ( - hasOwnProperty.call(config, propName) && // Skip over reserved prop names - propName !== "key" && // TODO: `ref` will no longer be reserved in the next major - propName !== "ref" && // ...and maybe these, too, though we currently rely on them for - // warnings and debug information in dev. Need to decide if we're OK - // with dropping them. In the jsx() runtime it's not an issue because - // the data gets passed as separate arguments instead of props, but - // it would be nice to stop relying on them entirely so we can drop - // them from the internal Fiber field. - propName !== "__self" && - propName !== "__source" - ) { - props[propName] = config[propName]; + try { + // Lazy may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV( + init(payload), + ownerFn + ); + } catch (x) {} } } - } // Children can be more than one argument, and those are transferred onto - // the newly allocated props object. + } - var childrenLength = arguments.length - 2; + return ""; + } - if (childrenLength === 1) { - props.children = children; - } else if (childrenLength > 1) { - var childArray = Array(childrenLength); - - for (var i = 0; i < childrenLength; i++) { - childArray[i] = arguments[i + 2]; - } - - { - if (Object.freeze) { - Object.freeze(childArray); - } - } - - props.children = childArray; - } // Resolve default props - - if (type && type.defaultProps) { - var defaultProps = type.defaultProps; + var loggedTypeFailures = {}; + var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; - for (propName in defaultProps) { - if (props[propName] === undefined) { - props[propName] = defaultProps[propName]; - } + function setCurrentlyValidatingElement$1(element) { + { + if (element) { + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV( + element.type, + owner ? owner.type : null + ); + ReactDebugCurrentFrame$1.setExtraStackFrame(stack); + } else { + ReactDebugCurrentFrame$1.setExtraStackFrame(null); } } + } + function checkPropTypes( + typeSpecs, + values, + location, + componentName, + element + ) { { - if (key || ref) { - var displayName = - typeof type === "function" - ? type.displayName || type.name || "Unknown" - : type; - - if (key) { - defineKeyPropWarningGetter$1(props, displayName); - } + // $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it. + var has = Function.call.bind(hasOwnProperty); - if (ref) { - defineRefPropWarningGetter$1(props, displayName); - } - } - } + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. - return ReactElement$1(type, key, ref, ReactCurrentOwner$1.current, props); - } - function cloneAndReplaceKey(oldElement, newKey) { - var newElement = ReactElement$1( - oldElement.type, - newKey, - oldElement.ref, - oldElement._owner, - oldElement.props - ); - return newElement; - } - /** - * Clone and return a new ReactElement using element as the starting point. - * See https://reactjs.org/docs/react-api.html#cloneelement - */ + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== "function") { + // eslint-disable-next-line react-internal/prod-error-codes + var err = Error( + (componentName || "React class") + + ": " + + location + + " type `" + + typeSpecName + + "` is invalid; " + + "it must be a function, usually from the `prop-types` package, but received `" + + typeof typeSpecs[typeSpecName] + + "`." + + "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`." + ); + err.name = "Invariant Violation"; + throw err; + } - function cloneElement$1(element, config, children) { - if (element === null || element === undefined) { - throw new Error( - "React.cloneElement(...): The argument must be a React element, but you passed " + - element + - "." - ); - } + error$1 = typeSpecs[typeSpecName]( + values, + typeSpecName, + componentName, + location, + null, + "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" + ); + } catch (ex) { + error$1 = ex; + } - var propName; // Original props are copied + if (error$1 && !(error$1 instanceof Error)) { + setCurrentlyValidatingElement$1(element); - var props = assign({}, element.props); // Reserved names are extracted + error( + "%s: type specification of %s" + + " `%s` is invalid; the type checker " + + "function must return `null` or an `Error` but returned a %s. " + + "You may have forgotten to pass an argument to the type checker " + + "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " + + "shape all require an argument).", + componentName || "React class", + location, + typeSpecName, + typeof error$1 + ); - var key = element.key; - var ref = element.ref; // Owner will be preserved, unless ref is overridden + setCurrentlyValidatingElement$1(null); + } - var owner = element._owner; + if ( + error$1 instanceof Error && + !(error$1.message in loggedTypeFailures) + ) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error$1.message] = true; + setCurrentlyValidatingElement$1(element); - if (config != null) { - if (hasValidRef$1(config)) { - // Silently steal the ref from the parent. - ref = config.ref; - owner = ReactCurrentOwner$1.current; - } + error("Failed %s type: %s", location, error$1.message); - if (hasValidKey$1(config)) { - { - checkKeyStringCoercion(config.key); + setCurrentlyValidatingElement$1(null); + } } + } + } + } - key = "" + config.key; - } // Remaining properties override existing props + var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); + var specialPropKeyWarningShown; + var specialPropRefWarningShown; + var didWarnAboutStringRefs; - var defaultProps; + { + didWarnAboutStringRefs = {}; + } - if (element.type && element.type.defaultProps) { - defaultProps = element.type.defaultProps; - } + function hasValidRef(config) { + { + if (hasOwnProperty.call(config, "ref")) { + var getter = Object.getOwnPropertyDescriptor(config, "ref").get; - for (propName in config) { - if ( - hasOwnProperty.call(config, propName) && // Skip over reserved prop names - propName !== "key" && // TODO: `ref` will no longer be reserved in the next major - propName !== "ref" && // ...and maybe these, too, though we currently rely on them for - // warnings and debug information in dev. Need to decide if we're OK - // with dropping them. In the jsx() runtime it's not an issue because - // the data gets passed as separate arguments instead of props, but - // it would be nice to stop relying on them entirely so we can drop - // them from the internal Fiber field. - propName !== "__self" && - propName !== "__source" - ) { - if (config[propName] === undefined && defaultProps !== undefined) { - // Resolve default props - props[propName] = defaultProps[propName]; - } else { - props[propName] = config[propName]; - } + if (getter && getter.isReactWarning) { + return false; } } - } // Children can be more than one argument, and those are transferred onto - // the newly allocated props object. + } - var childrenLength = arguments.length - 2; + return config.ref !== undefined; + } - if (childrenLength === 1) { - props.children = children; - } else if (childrenLength > 1) { - var childArray = Array(childrenLength); + function hasValidKey(config) { + { + if (hasOwnProperty.call(config, "key")) { + var getter = Object.getOwnPropertyDescriptor(config, "key").get; - for (var i = 0; i < childrenLength; i++) { - childArray[i] = arguments[i + 2]; + if (getter && getter.isReactWarning) { + return false; + } } - - props.children = childArray; } - return ReactElement$1(element.type, key, ref, owner, props); + return config.key !== undefined; } - /** - * Verifies the object is a ReactElement. - * See https://reactjs.org/docs/react-api.html#isvalidelement - * @param {?object} object - * @return {boolean} True if `object` is a ReactElement. - * @final - */ - function isValidElement$1(object) { - return ( - typeof object === "object" && - object !== null && - object.$$typeof === REACT_ELEMENT_TYPE - ); - } + function warnIfStringRefCannotBeAutoConverted(config, self) { + { + if ( + typeof config.ref === "string" && + ReactCurrentOwner.current && + self && + ReactCurrentOwner.current.stateNode !== self + ) { + var componentName = getComponentNameFromType( + ReactCurrentOwner.current.type + ); - var REACT_CLIENT_REFERENCE$2 = Symbol.for("react.client.reference"); - function isValidElementType(type) { - if (typeof type === "string" || typeof type === "function") { - return true; - } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). + if (!didWarnAboutStringRefs[componentName]) { + error( + 'Component "%s" contains the string ref "%s". ' + + "Support for string refs will be removed in a future major release. " + + "This case cannot be automatically converted to an arrow function. " + + "We ask you to manually fix this case by using useRef() or createRef() instead. " + + "Learn more about using refs safely here: " + + "https://reactjs.org/link/strict-mode-string-ref", + getComponentNameFromType(ReactCurrentOwner.current.type), + config.ref + ); - if ( - type === REACT_FRAGMENT_TYPE || - type === REACT_PROFILER_TYPE || - enableDebugTracing || - type === REACT_STRICT_MODE_TYPE || - type === REACT_SUSPENSE_TYPE || - type === REACT_SUSPENSE_LIST_TYPE || - enableLegacyHidden || - type === REACT_OFFSCREEN_TYPE || - enableScopeAPI || - type === REACT_CACHE_TYPE || - enableTransitionTracing - ) { - return true; - } - - if (typeof type === "object" && type !== null) { - if ( - type.$$typeof === REACT_LAZY_TYPE || - type.$$typeof === REACT_MEMO_TYPE || - type.$$typeof === REACT_CONTEXT_TYPE || - type.$$typeof === REACT_PROVIDER_TYPE || - enableRenderableContext || - type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object - // types supported by any Flight configuration anywhere since - // we don't know which Flight build this will end up being used - // with. - type.$$typeof === REACT_CLIENT_REFERENCE$2 || - type.getModuleId !== undefined - ) { - return true; + didWarnAboutStringRefs[componentName] = true; + } } } - - return false; } - function describeBuiltInComponentFrame(name, ownerFn) { + function defineKeyPropWarningGetter(props, displayName) { { - var ownerName = null; + var warnAboutAccessingKey = function () { + if (!specialPropKeyWarningShown) { + specialPropKeyWarningShown = true; - if (ownerFn) { - ownerName = ownerFn.displayName || ownerFn.name || null; - } + error( + "%s: `key` is not a prop. Trying to access it will result " + + "in `undefined` being returned. If you need to access the same " + + "value within the child component, you should pass it as a different " + + "prop. (https://reactjs.org/link/special-props)", + displayName + ); + } + }; - return describeComponentFrame(name, ownerName); + warnAboutAccessingKey.isReactWarning = true; + Object.defineProperty(props, "key", { + get: warnAboutAccessingKey, + configurable: true + }); } } - { - var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; - new PossiblyWeakMap(); - } - - function describeComponentFrame(name, ownerName) { - var sourceInfo = ""; - - if (ownerName) { - sourceInfo = " (created by " + ownerName + ")"; - } - - return "\n in " + (name || "Unknown") + sourceInfo; - } - function describeFunctionComponentFrame(fn, ownerFn) { + function defineRefPropWarningGetter(props, displayName) { { - if (!fn) { - return ""; - } - - var name = fn.displayName || fn.name || null; - var ownerName = null; + var warnAboutAccessingRef = function () { + if (!specialPropRefWarningShown) { + specialPropRefWarningShown = true; - if (ownerFn) { - ownerName = ownerFn.displayName || ownerFn.name || null; - } + error( + "%s: `ref` is not a prop. Trying to access it will result " + + "in `undefined` being returned. If you need to access the same " + + "value within the child component, you should pass it as a different " + + "prop. (https://reactjs.org/link/special-props)", + displayName + ); + } + }; - return describeComponentFrame(name, ownerName); + warnAboutAccessingRef.isReactWarning = true; + Object.defineProperty(props, "ref", { + get: warnAboutAccessingRef, + configurable: true + }); } } + /** + * Factory method to create a new React element. This no longer adheres to + * the class pattern, so do not use new to call it. Also, instanceof check + * will not work. Instead test $$typeof field against Symbol.for('react.element') to check + * if something is a React Element. + * + * @param {*} type + * @param {*} props + * @param {*} key + * @param {string|object} ref + * @param {*} owner + * @param {*} self A *temporary* helper to detect places where `this` is + * different from the `owner` when React.createElement is called, so that we + * can warn. We want to get rid of owner and replace string `ref`s with arrow + * functions, and as long as `this` and owner are the same, there will be no + * change in behavior. + * @param {*} source An annotation object (added by a transpiler or otherwise) + * indicating filename, line number, and/or other information. + * @internal + */ - function describeUnknownElementTypeFrameInDEV(type, ownerFn) { - if (type == null) { - return ""; - } - - if (typeof type === "function") { - { - return describeFunctionComponentFrame(type, ownerFn); - } - } - - if (typeof type === "string") { - return describeBuiltInComponentFrame(type, ownerFn); - } - - switch (type) { - case REACT_SUSPENSE_TYPE: - return describeBuiltInComponentFrame("Suspense", ownerFn); - - case REACT_SUSPENSE_LIST_TYPE: - return describeBuiltInComponentFrame("SuspenseList", ownerFn); - } + function ReactElement(type, key, ref, self, source, owner, props) { + var element = { + // This tag allows us to uniquely identify this as a React Element + $$typeof: REACT_ELEMENT_TYPE, + // Built-in properties that belong on the element + type: type, + key: key, + ref: ref, + props: props, + // Record the component responsible for creating this element. + _owner: owner + }; - if (typeof type === "object") { - switch (type.$$typeof) { - case REACT_FORWARD_REF_TYPE: - return describeFunctionComponentFrame(type.render, ownerFn); + { + // The validation flag is currently mutative. We put it on + // an external backing store so that we can freeze the whole object. + // This can be replaced with a WeakMap once they are implemented in + // commonly used development environments. + element._store = {}; // To make comparing ReactElements easier for testing purposes, we make + // the validation flag non-enumerable (where possible, which should + // include every environment we run tests in), so the test framework + // ignores it. - case REACT_MEMO_TYPE: - // Memo may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(type.type, ownerFn); + Object.defineProperty(element._store, "validated", { + configurable: false, + enumerable: false, + writable: true, + value: false + }); // debugInfo contains Server Component debug information. - case REACT_LAZY_TYPE: { - var lazyComponent = type; - var payload = lazyComponent._payload; - var init = lazyComponent._init; + Object.defineProperty(element, "_debugInfo", { + configurable: false, + enumerable: false, + writable: true, + value: null + }); - try { - // Lazy may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV( - init(payload), - ownerFn - ); - } catch (x) {} - } + if (Object.freeze) { + Object.freeze(element.props); + Object.freeze(element); } } - return ""; + return element; } + // support `jsx` and `jsxs` when running in development. This supports the case + // where a third-party dependency ships code that was compiled for production; + // we want to still provide warnings in development. + // + // So these functions are the _dev_ implementations of the _production_ + // API signatures. + // + // Since these functions are dev-only, it's ok to add an indirection here. They + // only exist to provide different versions of `isStaticChildren`. (We shouldn't + // use this pattern for the prod versions, though, because it will add an call + // frame.) - var loggedTypeFailures = {}; - var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; - - function setCurrentlyValidatingElement$2(element) { + function jsxProdSignatureRunningInDevWithDynamicChildren( + type, + config, + maybeKey, + source, + self + ) { { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - owner ? owner.type : null - ); - ReactDebugCurrentFrame$1.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame$1.setExtraStackFrame(null); - } + var isStaticChildren = false; + return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); } } - - function checkPropTypes( - typeSpecs, - values, - location, - componentName, - element + function jsxProdSignatureRunningInDevWithStaticChildren( + type, + config, + maybeKey, + source, + self ) { { - // $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it. - var has = Function.call.bind(hasOwnProperty); + var isStaticChildren = true; + return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); + } + } + var didWarnAboutKeySpread = {}; + /** + * https://github.com/reactjs/rfcs/pull/107 + * @param {*} type + * @param {object} props + * @param {string} key + */ - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. + function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) { + { + if (!isValidElementType(type)) { + // This is an invalid element type. + // + // We warn in this case but don't throw. We expect the element creation to + // succeed and there will likely be errors in render. + var info = ""; - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== "function") { - // eslint-disable-next-line react-internal/prod-error-codes - var err = Error( - (componentName || "React class") + - ": " + - location + - " type `" + - typeSpecName + - "` is invalid; " + - "it must be a function, usually from the `prop-types` package, but received `" + - typeof typeSpecs[typeSpecName] + - "`." + - "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`." - ); - err.name = "Invariant Violation"; - throw err; - } + if ( + type === undefined || + (typeof type === "object" && + type !== null && + Object.keys(type).length === 0) + ) { + info += + " You likely forgot to export your component from the file " + + "it's defined in, or you might have mixed up default and named imports."; + } - error$1 = typeSpecs[typeSpecName]( - values, - typeSpecName, - componentName, - location, - null, - "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" - ); - } catch (ex) { - error$1 = ex; - } + var sourceInfo = getSourceInfoErrorAddendum(source); - if (error$1 && !(error$1 instanceof Error)) { - setCurrentlyValidatingElement$2(element); + if (sourceInfo) { + info += sourceInfo; + } else { + info += getDeclarationErrorAddendum(); + } - error( - "%s: type specification of %s" + - " `%s` is invalid; the type checker " + - "function must return `null` or an `Error` but returned a %s. " + - "You may have forgotten to pass an argument to the type checker " + - "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " + - "shape all require an argument).", - componentName || "React class", - location, - typeSpecName, - typeof error$1 - ); + var typeString; - setCurrentlyValidatingElement$2(null); - } + if (type === null) { + typeString = "null"; + } else if (isArray(type)) { + typeString = "array"; + } else if ( + type !== undefined && + type.$$typeof === REACT_ELEMENT_TYPE + ) { + typeString = + "<" + (getComponentNameFromType(type.type) || "Unknown") + " />"; + info = + " Did you accidentally export a JSX literal instead of a component?"; + } else { + typeString = typeof type; + } - if ( - error$1 instanceof Error && - !(error$1.message in loggedTypeFailures) - ) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error$1.message] = true; - setCurrentlyValidatingElement$2(element); + error( + "React.jsx: type is invalid -- expected a string (for " + + "built-in components) or a class/function (for composite " + + "components) but got: %s.%s", + typeString, + info + ); + } else { + // This is a valid element type. + // Skip key warning if the type isn't valid since our key validation logic + // doesn't expect a non-string/function type and can throw confusing + // errors. We don't want exception behavior to differ between dev and + // prod. (Rendering will throw with a helpful message and as soon as the + // type is fixed, the key warnings will appear.) + var children = config.children; - error("Failed %s type: %s", location, error$1.message); + if (children !== undefined) { + if (isStaticChildren) { + if (isArray(children)) { + for (var i = 0; i < children.length; i++) { + validateChildKeys(children[i], type); + } - setCurrentlyValidatingElement$2(null); + if (Object.freeze) { + Object.freeze(children); + } + } else { + error( + "React.jsx: Static children should always be an array. " + + "You are likely explicitly calling React.jsxs or React.jsxDEV. " + + "Use the Babel transform instead." + ); + } + } else { + validateChildKeys(children, type); } } - } - } - } + } // Warn about key spread regardless of whether the type is valid. - var REACT_CLIENT_REFERENCE$1 = Symbol.for("react.client.reference"); + if (hasOwnProperty.call(config, "key")) { + var componentName = getComponentNameFromType(type); + var keys = Object.keys(config).filter(function (k) { + return k !== "key"; + }); + var beforeExample = + keys.length > 0 + ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" + : "{key: someKey}"; - function setCurrentlyValidatingElement$1(element) { - { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - owner ? owner.type : null - ); - setExtraStackFrame(stack); - } else { - setExtraStackFrame(null); + if (!didWarnAboutKeySpread[componentName + beforeExample]) { + var afterExample = + keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}"; + + error( + 'A props object containing a "key" prop is being spread into JSX:\n' + + " let props = %s;\n" + + " <%s {...props} />\n" + + "React keys must be passed directly to JSX without using spread:\n" + + " let props = %s;\n" + + " <%s key={someKey} {...props} />", + beforeExample, + componentName, + afterExample, + componentName + ); + + didWarnAboutKeySpread[componentName + beforeExample] = true; + } } - } - } - var propTypesMisspellWarningShown$1; + var propName; // Reserved names are extracted - { - propTypesMisspellWarningShown$1 = false; - } + 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.
+ // or
). We want to deprecate key spread, + // but as an intermediary step, we will use jsxDEV for everything except + //
, because we aren't currently able to tell if + // key is explicitly declared to be undefined or not. - function getDeclarationErrorAddendum$1() { - if (ReactCurrentOwner$1.current) { - var name = getComponentNameFromType(ReactCurrentOwner$1.current.type); + if (maybeKey !== undefined) { + { + checkKeyStringCoercion(maybeKey); + } - if (name) { - return "\n\nCheck the render method of `" + name + "`."; + key = "" + maybeKey; } - } - return ""; - } + if (hasValidKey(config)) { + { + checkKeyStringCoercion(config.key); + } - function getSourceInfoErrorAddendum$1(source) { - if (source !== undefined) { - var fileName = source.fileName.replace(/^.*[\\\/]/, ""); - var lineNumber = source.lineNumber; - return "\n\nCheck your code at " + fileName + ":" + lineNumber + "."; - } + key = "" + config.key; + } - return ""; - } + if (hasValidRef(config)) { + ref = config.ref; + warnIfStringRefCannotBeAutoConverted(config, self); + } // Remaining properties are added to a new props object - function getSourceInfoErrorAddendumForProps(elementProps) { - if (elementProps !== null && elementProps !== undefined) { - return getSourceInfoErrorAddendum$1(elementProps.__source); - } + for (propName in config) { + if ( + hasOwnProperty.call(config, propName) && // Skip over reserved prop names + propName !== "key" && // TODO: `ref` will no longer be reserved in the next major + propName !== "ref" + ) { + props[propName] = config[propName]; + } + } // Resolve default props - return ""; - } - /** - * 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 - * updates. - */ + if (type && type.defaultProps) { + var defaultProps = type.defaultProps; - var ownerHasKeyUseWarning$1 = {}; + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } + } + } - function getCurrentComponentErrorInfo$1(parentType) { - var info = getDeclarationErrorAddendum$1(); + if (key || ref) { + var displayName = + typeof type === "function" + ? type.displayName || type.name || "Unknown" + : type; - if (!info) { - var parentName = getComponentNameFromType(parentType); + if (key) { + defineKeyPropWarningGetter(props, displayName); + } - if (parentName) { - info = - "\n\nCheck the top-level render call using <" + parentName + ">."; + if (ref) { + defineRefPropWarningGetter(props, displayName); + } } - } - - return info; - } - /** - * Warn if the element doesn't have an explicit key assigned to it. - * This element is in an array. The array could grow and shrink or be - * reordered. All children that haven't already been validated are required to - * have a "key" property assigned to it. Error statuses are cached so a warning - * will only be shown once. - * - * @internal - * @param {ReactElement} element Element that requires a key. - * @param {*} parentType element's parent's type. - */ - function validateExplicitKey$1(element, parentType) { - if (!element._store || element._store.validated || element.key != null) { - return; - } - - element._store.validated = true; - var currentComponentErrorInfo = - getCurrentComponentErrorInfo$1(parentType); - - if (ownerHasKeyUseWarning$1[currentComponentErrorInfo]) { - return; - } - - ownerHasKeyUseWarning$1[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a - // property, it may be the creator of the child that's responsible for - // assigning it a key. - - var childOwner = ""; - - if ( - element && - element._owner && - element._owner !== ReactCurrentOwner$1.current - ) { - // Give the component that originally created this child. - childOwner = - " It was passed a child from " + - getComponentNameFromType(element._owner.type) + - "."; - } - - { - setCurrentlyValidatingElement$1(element); - - error( - 'Each child in a list should have a unique "key" prop.' + - "%s%s See https://reactjs.org/link/warning-keys for more information.", - currentComponentErrorInfo, - childOwner + var element = ReactElement( + type, + key, + ref, + self, + source, + ReactCurrentOwner.current, + props ); - setCurrentlyValidatingElement$1(null); - } - } - /** - * Ensure that every element either is passed in a static location, in an - * array with an explicit keys property defined, or in an object literal - * with valid key property. - * - * @internal - * @param {ReactNode} node Statically passed child of any type. - * @param {*} parentType node's parent's type. - */ - - function validateChildKeys$1(node, parentType) { - if (typeof node !== "object" || !node) { - return; - } - - if (node.$$typeof === REACT_CLIENT_REFERENCE$1); - else if (isArray(node)) { - for (var i = 0; i < node.length; i++) { - var child = node[i]; - - if (isValidElement$1(child)) { - validateExplicitKey$1(child, parentType); - } - } - } else if (isValidElement$1(node)) { - // This element was passed in a valid location. - if (node._store) { - node._store.validated = true; + if (type === REACT_FRAGMENT_TYPE) { + validateFragmentProps(element); + } else { + validatePropTypes(element); } - } else { - var iteratorFn = getIteratorFn(node); - if (typeof iteratorFn === "function") { - // Entry iterators used to provide implicit keys, - // but now we print a separate warning for them later. - if (iteratorFn !== node.entries) { - var iterator = iteratorFn.call(node); - var step; - - while (!(step = iterator.next()).done) { - if (isValidElement$1(step.value)) { - validateExplicitKey$1(step.value, parentType); - } - } - } - } + return element; } } /** - * Given an element, validate that its props follow the propTypes definition, - * provided by the type. - * - * @param {ReactElement} element + * Create and return a new ReactElement of the given type. + * See https://reactjs.org/docs/react-api.html#createelement */ - function validatePropTypes$1(element) { + function createElement(type, config, children) { { - var type = element.type; - - if (type === null || type === undefined || typeof type === "string") { - return; - } - - if (type.$$typeof === REACT_CLIENT_REFERENCE$1) { - return; - } + if (!isValidElementType(type)) { + // This is an invalid element type. + // + // We warn in this case but don't throw. We expect the element creation to + // succeed and there will likely be errors in render. + var info = ""; - var propTypes; + if ( + type === undefined || + (typeof type === "object" && + type !== null && + Object.keys(type).length === 0) + ) { + info += + " You likely forgot to export your component from the file " + + "it's defined in, or you might have mixed up default and named imports."; + } - if (typeof type === "function") { - propTypes = type.propTypes; - } else if ( - typeof type === "object" && - (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - type.$$typeof === REACT_MEMO_TYPE) - ) { - propTypes = type.propTypes; - } else { - return; - } + var sourceInfo = getSourceInfoErrorAddendumForProps(config); - if (propTypes) { - // Intentionally inside to avoid triggering lazy initializers: - var name = getComponentNameFromType(type); - checkPropTypes(propTypes, element.props, "prop", name, element); - } else if ( - type.PropTypes !== undefined && - !propTypesMisspellWarningShown$1 - ) { - propTypesMisspellWarningShown$1 = true; // Intentionally inside to avoid triggering lazy initializers: + if (sourceInfo) { + info += sourceInfo; + } else { + info += getDeclarationErrorAddendum(); + } - var _name = getComponentNameFromType(type); + var typeString; - error( - "Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", - _name || "Unknown" - ); - } + if (type === null) { + typeString = "null"; + } else if (isArray(type)) { + typeString = "array"; + } else if ( + type !== undefined && + type.$$typeof === REACT_ELEMENT_TYPE + ) { + typeString = + "<" + (getComponentNameFromType(type.type) || "Unknown") + " />"; + info = + " Did you accidentally export a JSX literal instead of a component?"; + } else { + typeString = typeof type; + } - if ( - typeof type.getDefaultProps === "function" && - !type.getDefaultProps.isReactClassApproved - ) { error( - "getDefaultProps is only used on classic React.createClass " + - "definitions. Use a static property named `defaultProps` instead." + "React.createElement: type is invalid -- expected a string (for " + + "built-in components) or a class/function (for composite " + + "components) but got: %s.%s", + typeString, + info ); - } + } else { + // This is a valid element type. + // Skip key warning if the type isn't valid since our key validation logic + // doesn't expect a non-string/function type and can throw confusing + // errors. We don't want exception behavior to differ between dev and + // prod. (Rendering will throw with a helpful message and as soon as the + // type is fixed, the key warnings will appear.) + for (var i = 2; i < arguments.length; i++) { + validateChildKeys(arguments[i], type); + } + } // Unlike the jsx() runtime, createElement() doesn't warn about key spread. } - } - /** - * Given a fragment, validate that it can only be provided with fragment props - * @param {ReactElement} fragment - */ - function validateFragmentProps$1(fragment) { - { - var keys = Object.keys(fragment.props); - - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; + var propName; // Reserved names are extracted - if (key !== "children" && key !== "key") { - setCurrentlyValidatingElement$1(fragment); + var props = {}; + var key = null; + var ref = null; - error( - "Invalid prop `%s` supplied to `React.Fragment`. " + - "React.Fragment can only have `key` and `children` props.", - key - ); + if (config != null) { + if (hasValidRef(config)) { + ref = config.ref; - setCurrentlyValidatingElement$1(null); - break; + { + warnIfStringRefCannotBeAutoConverted(config, config.__self); } } - if (fragment.ref !== null) { - setCurrentlyValidatingElement$1(fragment); + if (hasValidKey(config)) { + { + checkKeyStringCoercion(config.key); + } - error("Invalid attribute `ref` supplied to `React.Fragment`."); + key = "" + config.key; + } // Remaining properties are added to a new props object - setCurrentlyValidatingElement$1(null); + for (propName in config) { + if ( + hasOwnProperty.call(config, propName) && // Skip over reserved prop names + propName !== "key" && // TODO: `ref` will no longer be reserved in the next major + propName !== "ref" && // ...and maybe these, too, though we currently rely on them for + // warnings and debug information in dev. Need to decide if we're OK + // with dropping them. In the jsx() runtime it's not an issue because + // the data gets passed as separate arguments instead of props, but + // it would be nice to stop relying on them entirely so we can drop + // them from the internal Fiber field. + propName !== "__self" && + propName !== "__source" + ) { + props[propName] = config[propName]; + } } - } - } + } // Children can be more than one argument, and those are transferred onto + // the newly allocated props object. - function createElementWithValidation(type, props, children) { - var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to - // succeed and there will likely be errors in render. + var childrenLength = arguments.length - 2; - if (!validType) { - var info = ""; + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = Array(childrenLength); - if ( - type === undefined || - (typeof type === "object" && - type !== null && - Object.keys(type).length === 0) - ) { - info += - " You likely forgot to export your component from the file " + - "it's defined in, or you might have mixed up default and named imports."; + for (var _i = 0; _i < childrenLength; _i++) { + childArray[_i] = arguments[_i + 2]; } - var sourceInfo = getSourceInfoErrorAddendumForProps(props); - - if (sourceInfo) { - info += sourceInfo; - } else { - info += getDeclarationErrorAddendum$1(); + { + if (Object.freeze) { + Object.freeze(childArray); + } } - var typeString; + props.children = childArray; + } // Resolve default props - if (type === null) { - typeString = "null"; - } else if (isArray(type)) { - typeString = "array"; - } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { - typeString = - "<" + (getComponentNameFromType(type.type) || "Unknown") + " />"; - info = - " Did you accidentally export a JSX literal instead of a component?"; - } else { - typeString = typeof type; - } + if (type && type.defaultProps) { + var defaultProps = type.defaultProps; - { - error( - "React.createElement: type is invalid -- expected a string (for " + - "built-in components) or a class/function (for composite " + - "components) but got: %s.%s", - typeString, - info - ); + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } } } - var element = createElement$1.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. - // TODO: Drop this when these are no longer allowed as the type argument. + { + if (key || ref) { + var displayName = + typeof type === "function" + ? type.displayName || type.name || "Unknown" + : type; - if (element == null) { - return element; - } // Skip key warning if the type isn't valid since our key validation logic - // doesn't expect a non-string/function type and can throw confusing errors. - // We don't want exception behavior to differ between dev and prod. - // (Rendering will throw with a helpful message and as soon as the type is - // fixed, the key warnings will appear.) + if (key) { + defineKeyPropWarningGetter(props, displayName); + } - if (validType) { - for (var i = 2; i < arguments.length; i++) { - validateChildKeys$1(arguments[i], type); + if (ref) { + defineRefPropWarningGetter(props, displayName); + } } } + var element = ReactElement( + type, + key, + ref, + undefined, + undefined, + ReactCurrentOwner.current, + props + ); + if (type === REACT_FRAGMENT_TYPE) { - validateFragmentProps$1(element); + validateFragmentProps(element); } else { - validatePropTypes$1(element); + validatePropTypes(element); } return element; } var didWarnAboutDeprecatedCreateFactory = false; - function createFactoryWithValidation(type) { - var validatedFactory = createElementWithValidation.bind(null, type); - validatedFactory.type = type; + /** + * Return a function that produces ReactElements of a given type. + * See https://reactjs.org/docs/react-api.html#createfactory + */ + + function createFactory(type) { + var factory = createElement.bind(null, type); // Expose the type on the factory and the prototype so that it can be + // easily accessed on elements. E.g. `.type === Foo`. + // This should not be named `constructor` since this may not be the function + // that created the element, and it may not even be a constructor. + // Legacy hook: remove it + + factory.type = type; { if (!didWarnAboutDeprecatedCreateFactory) { @@ -1689,7 +1560,7 @@ if (__DEV__) { ); } // Legacy hook: remove it - Object.defineProperty(validatedFactory, "type", { + Object.defineProperty(factory, "type", { enumerable: false, get: function () { warn( @@ -1705,2073 +1576,1746 @@ if (__DEV__) { }); } - return validatedFactory; + return factory; } - function cloneElementWithValidation(element, props, children) { - var newElement = cloneElement$1.apply(this, arguments); - - for (var i = 2; i < arguments.length; i++) { - validateChildKeys$1(arguments[i], newElement.type); - } - - validatePropTypes$1(newElement); - return newElement; + function cloneAndReplaceKey(oldElement, newKey) { + return ReactElement( + oldElement.type, + newKey, + oldElement.ref, + undefined, + undefined, + oldElement._owner, + oldElement.props + ); } - - var createElement = createElementWithValidation; - var cloneElement = cloneElementWithValidation; - var createFactory = createFactoryWithValidation; - - var SEPARATOR = "."; - var SUBSEPARATOR = ":"; /** - * Escape and wrap key so it is safe to use as a reactid - * - * @param {string} key to be escaped. - * @return {string} the escaped key. + * Clone and return a new ReactElement using element as the starting point. + * See https://reactjs.org/docs/react-api.html#cloneelement */ - function escape(key) { - var escapeRegex = /[=:]/g; - var escaperLookup = { - "=": "=0", - ":": "=2" - }; - var escapedString = key.replace(escapeRegex, function (match) { - return escaperLookup[match]; - }); - return "$" + escapedString; - } - /** - * TODO: Test that a single child and an array with one item have the same key - * pattern. - */ + function cloneElement(element, config, children) { + if (element === null || element === undefined) { + throw new Error( + "React.cloneElement(...): The argument must be a React element, but you passed " + + element + + "." + ); + } - var didWarnAboutMaps = false; - var userProvidedKeyEscapeRegex = /\/+/g; + var propName; // Original props are copied - function escapeUserProvidedKey(text) { - return text.replace(userProvidedKeyEscapeRegex, "$&/"); - } - /** - * Generate a key string that identifies a element within a set. - * - * @param {*} element A element that could contain a manual key. - * @param {number} index Index that is used if a manual key is not provided. - * @return {string} - */ + var props = assign({}, element.props); // Reserved names are extracted - function getElementKey(element, index) { - // Do some typechecking here since we call this blindly. We want to ensure - // that we don't block potential future ES APIs. - if ( - typeof element === "object" && - element !== null && - element.key != null - ) { - // Explicit key - { - checkKeyStringCoercion(element.key); + var key = element.key; + var ref = element.ref; // Owner will be preserved, unless ref is overridden + + var owner = element._owner; + + if (config != null) { + if (hasValidRef(config)) { + // Silently steal the ref from the parent. + ref = config.ref; + owner = ReactCurrentOwner.current; } - return escape("" + element.key); - } // Implicit key determined by the index in the set + if (hasValidKey(config)) { + { + checkKeyStringCoercion(config.key); + } - return index.toString(36); - } + key = "" + config.key; + } // Remaining properties override existing props - function noop() {} + var defaultProps; - function resolveThenable(thenable) { - switch (thenable.status) { - case "fulfilled": { - var fulfilledValue = thenable.value; - return fulfilledValue; + if (element.type && element.type.defaultProps) { + defaultProps = element.type.defaultProps; } - case "rejected": { - var rejectedError = thenable.reason; - throw rejectedError; + for (propName in config) { + if ( + hasOwnProperty.call(config, propName) && // Skip over reserved prop names + propName !== "key" && // TODO: `ref` will no longer be reserved in the next major + propName !== "ref" && // ...and maybe these, too, though we currently rely on them for + // warnings and debug information in dev. Need to decide if we're OK + // with dropping them. In the jsx() runtime it's not an issue because + // the data gets passed as separate arguments instead of props, but + // it would be nice to stop relying on them entirely so we can drop + // them from the internal Fiber field. + propName !== "__self" && + propName !== "__source" + ) { + if (config[propName] === undefined && defaultProps !== undefined) { + // Resolve default props + props[propName] = defaultProps[propName]; + } else { + props[propName] = config[propName]; + } + } } + } // Children can be more than one argument, and those are transferred onto + // the newly allocated props object. - default: { - if (typeof thenable.status === "string") { - // Only instrument the thenable if the status if not defined. If - // it's defined, but an unknown value, assume it's been instrumented by - // 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, noop); - } else { - // This is an uncached thenable that we haven't seen before. - // TODO: Detect infinite ping loops caused by uncached promises. - var pendingThenable = thenable; - pendingThenable.status = "pending"; - pendingThenable.then( - function (fulfilledValue) { - if (thenable.status === "pending") { - var fulfilledThenable = thenable; - fulfilledThenable.status = "fulfilled"; - fulfilledThenable.value = fulfilledValue; - } - }, - function (error) { - if (thenable.status === "pending") { - var rejectedThenable = thenable; - rejectedThenable.status = "rejected"; - rejectedThenable.reason = error; - } - } - ); - } // Check one more time in case the thenable resolved synchronously. + var childrenLength = arguments.length - 2; - switch (thenable.status) { - case "fulfilled": { - var fulfilledThenable = thenable; - return fulfilledThenable.value; - } + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = Array(childrenLength); - case "rejected": { - var rejectedThenable = thenable; - var _rejectedError = rejectedThenable.reason; - throw _rejectedError; - } - } + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 2]; } - } - throw thenable; - } + props.children = childArray; + } - function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { - var type = typeof children; + var clonedElement = ReactElement( + element.type, + key, + ref, + undefined, + undefined, + owner, + props + ); - if (type === "undefined" || type === "boolean") { - // All of the above are perceived as null. - children = null; + for (var _i2 = 2; _i2 < arguments.length; _i2++) { + validateChildKeys(arguments[_i2], clonedElement.type); } - var invokeCallback = false; - - if (children === null) { - invokeCallback = true; - } else { - switch (type) { - case "string": - case "number": - invokeCallback = true; - break; + validatePropTypes(clonedElement); + return clonedElement; + } - case "object": - switch (children.$$typeof) { - case REACT_ELEMENT_TYPE: - case REACT_PORTAL_TYPE: - invokeCallback = true; - break; + function getDeclarationErrorAddendum() { + { + if (ReactCurrentOwner.current) { + var name = getComponentNameFromType(ReactCurrentOwner.current.type); - case REACT_LAZY_TYPE: - var payload = children._payload; - var init = children._init; - return mapIntoArray( - init(payload), - array, - escapedPrefix, - nameSoFar, - callback - ); - } + if (name) { + return "\n\nCheck the render method of `" + name + "`."; + } } + + return ""; } + } - if (invokeCallback) { - var _child = children; - var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array - // so that it's consistent if the number of children grows: + function getSourceInfoErrorAddendumForProps(elementProps) { + if (elementProps !== null && elementProps !== undefined) { + return getSourceInfoErrorAddendum(elementProps.__source); + } - var childKey = - nameSoFar === "" ? SEPARATOR + getElementKey(_child, 0) : nameSoFar; + return ""; + } - if (isArray(mappedChild)) { - var escapedChildKey = ""; + function getSourceInfoErrorAddendum(source) { + { + if (source !== undefined) { + var fileName = source.fileName.replace(/^.*[\\\/]/, ""); + var lineNumber = source.lineNumber; + return "\n\nCheck your code at " + fileName + ":" + lineNumber + "."; + } - if (childKey != null) { - escapedChildKey = escapeUserProvidedKey(childKey) + "/"; - } + return ""; + } + } + /** + * Ensure that every element either is passed in a static location, in an + * array with an explicit keys property defined, or in an object literal + * with valid key property. + * + * @internal + * @param {ReactNode} node Statically passed child of any type. + * @param {*} parentType node's parent's type. + */ - mapIntoArray(mappedChild, array, escapedChildKey, "", function (c) { - return c; - }); - } else if (mappedChild != null) { - if (isValidElement$1(mappedChild)) { - { - // The `if` statement here prevents auto-disabling of the safe - // coercion ESLint rule, so we must manually disable it below. - // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key - if ( - mappedChild.key && - (!_child || _child.key !== mappedChild.key) - ) { - checkKeyStringCoercion(mappedChild.key); - } - } + function validateChildKeys(node, parentType) { + { + if (typeof node !== "object" || !node) { + return; + } - mappedChild = cloneAndReplaceKey( - mappedChild, // Keep both the (mapped) and old keys if they differ, just as - // traverseAllChildren used to do for objects as children - escapedPrefix + // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key - (mappedChild.key && (!_child || _child.key !== mappedChild.key) - ? escapeUserProvidedKey( - // $FlowFixMe[unsafe-addition] - "" + mappedChild.key // eslint-disable-line react-internal/safe-string-coercion - ) + "/" - : "") + - childKey - ); + if (node.$$typeof === REACT_CLIENT_REFERENCE); + else if (isArray(node)) { + for (var i = 0; i < node.length; i++) { + var child = node[i]; + + if (isValidElement(child)) { + validateExplicitKey(child, parentType); + } + } + } else if (isValidElement(node)) { + // This element was passed in a valid location. + if (node._store) { + node._store.validated = true; } + } else { + var iteratorFn = getIteratorFn(node); - array.push(mappedChild); - } + if (typeof iteratorFn === "function") { + // Entry iterators used to provide implicit keys, + // but now we print a separate warning for them later. + if (iteratorFn !== node.entries) { + var iterator = iteratorFn.call(node); + var step; - return 1; + while (!(step = iterator.next()).done) { + if (isValidElement(step.value)) { + validateExplicitKey(step.value, parentType); + } + } + } + } + } } + } + /** + * Verifies the object is a ReactElement. + * See https://reactjs.org/docs/react-api.html#isvalidelement + * @param {?object} object + * @return {boolean} True if `object` is a ReactElement. + * @final + */ - var child; - var nextName; - var subtreeCount = 0; // Count of children found in the current subtree. + function isValidElement(object) { + return ( + typeof object === "object" && + object !== null && + object.$$typeof === REACT_ELEMENT_TYPE + ); + } + var ownerHasKeyUseWarning = {}; + /** + * Warn if the element doesn't have an explicit key assigned to it. + * This element is in an array. The array could grow and shrink or be + * reordered. All children that haven't already been validated are required to + * have a "key" property assigned to it. Error statuses are cached so a warning + * will only be shown once. + * + * @internal + * @param {ReactElement} element Element that requires a key. + * @param {*} parentType element's parent's type. + */ - var nextNamePrefix = - nameSoFar === "" ? SEPARATOR : nameSoFar + SUBSEPARATOR; + function validateExplicitKey(element, parentType) { + { + if ( + !element._store || + element._store.validated || + element.key != null + ) { + return; + } - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - child = children[i]; - nextName = nextNamePrefix + getElementKey(child, i); - subtreeCount += mapIntoArray( - child, - array, - escapedPrefix, - nextName, - callback - ); + element._store.validated = true; + var currentComponentErrorInfo = + getCurrentComponentErrorInfo(parentType); + + if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { + return; } - } else { - var iteratorFn = getIteratorFn(children); - if (typeof iteratorFn === "function") { - var iterableChildren = children; + ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a + // property, it may be the creator of the child that's responsible for + // assigning it a key. - { - // Warn about using Maps as children - if (iteratorFn === iterableChildren.entries) { - if (!didWarnAboutMaps) { - warn( - "Using Maps as children is not supported. " + - "Use an array of keyed ReactElements instead." - ); - } + var childOwner = ""; - didWarnAboutMaps = true; - } - } + if ( + element && + element._owner && + element._owner !== ReactCurrentOwner.current + ) { + // Give the component that originally created this child. + childOwner = + " It was passed a child from " + + getComponentNameFromType(element._owner.type) + + "."; + } - var iterator = iteratorFn.call(iterableChildren); - var step; - var ii = 0; // $FlowFixMe[incompatible-use] `iteratorFn` might return null according to typing. + setCurrentlyValidatingElement(element); - while (!(step = iterator.next()).done) { - child = step.value; - nextName = nextNamePrefix + getElementKey(child, ii++); - subtreeCount += mapIntoArray( - child, - array, - escapedPrefix, - nextName, - callback - ); - } - } else if (type === "object") { - if (typeof children.then === "function") { - return mapIntoArray( - resolveThenable(children), - array, - escapedPrefix, - nameSoFar, - callback - ); - } // eslint-disable-next-line react-internal/safe-string-coercion + error( + 'Each child in a list should have a unique "key" prop.' + + "%s%s See https://reactjs.org/link/warning-keys for more information.", + currentComponentErrorInfo, + childOwner + ); - var childrenString = String(children); - throw new Error( - "Objects are not valid as a React child (found: " + - (childrenString === "[object Object]" - ? "object with keys {" + Object.keys(children).join(", ") + "}" - : childrenString) + - "). " + - "If you meant to render a collection of children, use an array " + - "instead." + setCurrentlyValidatingElement(null); + } + } + + function setCurrentlyValidatingElement(element) { + { + if (element) { + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV( + element.type, + owner ? owner.type : null ); + ReactDebugCurrentFrame.setExtraStackFrame(stack); + } else { + ReactDebugCurrentFrame.setExtraStackFrame(null); } } - - return subtreeCount; } - /** - * Maps children that are typically specified as `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenmap - * - * The provided mapFunction(child, index) will be called for each - * leaf child. - * - * @param {?*} children Children tree container. - * @param {function(*, int)} func The map function. - * @param {*} context Context for mapFunction. - * @return {object} Object containing the ordered map of results. - */ - function mapChildren(children, func, context) { - if (children == null) { - // $FlowFixMe limitation refining abstract types in Flow - return children; - } + function getCurrentComponentErrorInfo(parentType) { + { + var info = getDeclarationErrorAddendum(); - var result = []; - var count = 0; - mapIntoArray(children, result, "", "", function (child) { - return func.call(context, child, count++); - }); - return result; + if (!info) { + var parentName = getComponentNameFromType(parentType); + + if (parentName) { + info = + "\n\nCheck the top-level render call using <" + parentName + ">."; + } + } + + return info; + } } /** - * Count the number of children that are typically specified as - * `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrencount - * - * @param {?*} children Children tree container. - * @return {number} The number of children. + * Given a fragment, validate that it can only be provided with fragment props + * @param {ReactElement} fragment */ - function countChildren(children) { - var n = 0; - mapChildren(children, function () { - n++; // Don't return anything - }); - return n; - } + function validateFragmentProps(fragment) { + { + var keys = Object.keys(fragment.props); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + + if (key !== "children" && key !== "key") { + setCurrentlyValidatingElement(fragment); + + error( + "Invalid prop `%s` supplied to `React.Fragment`. " + + "React.Fragment can only have `key` and `children` props.", + key + ); + + setCurrentlyValidatingElement(null); + break; + } + } + + if (fragment.ref !== null) { + setCurrentlyValidatingElement(fragment); + + error("Invalid attribute `ref` supplied to `React.Fragment`."); + + setCurrentlyValidatingElement(null); + } + } + } + + var propTypesMisspellWarningShown = false; /** - * Iterates through children that are typically specified as `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenforeach - * - * The provided forEachFunc(child, index) will be called for each - * leaf child. + * Given an element, validate that its props follow the propTypes definition, + * provided by the type. * - * @param {?*} children Children tree container. - * @param {function(*, int)} forEachFunc - * @param {*} forEachContext Context for forEachContext. + * @param {ReactElement} element */ - function forEachChildren(children, forEachFunc, forEachContext) { - mapChildren( - children, // $FlowFixMe[missing-this-annot] - function () { - forEachFunc.apply(this, arguments); // Don't return anything. - }, - forEachContext - ); + function validatePropTypes(element) { + { + var type = element.type; + + if (type === null || type === undefined || typeof type === "string") { + return; + } + + if (type.$$typeof === REACT_CLIENT_REFERENCE) { + return; + } + + var propTypes; + + if (typeof type === "function") { + propTypes = type.propTypes; + } else if ( + typeof type === "object" && + (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. + // Inner props are checked in the reconciler. + type.$$typeof === REACT_MEMO_TYPE) + ) { + propTypes = type.propTypes; + } else { + return; + } + + if (propTypes) { + // Intentionally inside to avoid triggering lazy initializers: + var name = getComponentNameFromType(type); + checkPropTypes(propTypes, element.props, "prop", name, element); + } else if ( + type.PropTypes !== undefined && + !propTypesMisspellWarningShown + ) { + propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: + + var _name = getComponentNameFromType(type); + + error( + "Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", + _name || "Unknown" + ); + } + + if ( + typeof type.getDefaultProps === "function" && + !type.getDefaultProps.isReactClassApproved + ) { + error( + "getDefaultProps is only used on classic React.createClass " + + "definitions. Use a static property named `defaultProps` instead." + ); + } + } } + + var SEPARATOR = "."; + var SUBSEPARATOR = ":"; /** - * Flatten a children object (typically specified as `props.children`) and - * return an array with appropriately re-keyed children. + * Escape and wrap key so it is safe to use as a reactid * - * See https://reactjs.org/docs/react-api.html#reactchildrentoarray + * @param {string} key to be escaped. + * @return {string} the escaped key. */ - function toArray(children) { - return ( - mapChildren(children, function (child) { - return child; - }) || [] - ); + function escape(key) { + var escapeRegex = /[=:]/g; + var escaperLookup = { + "=": "=0", + ":": "=2" + }; + var escapedString = key.replace(escapeRegex, function (match) { + return escaperLookup[match]; + }); + return "$" + escapedString; } /** - * Returns the first child in a collection of children and verifies that there - * is only one child in the collection. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenonly - * - * The current implementation of this function assumes that a single child gets - * passed without a wrapper, but the purpose of this helper function is to - * abstract away the particular structure of children. + * TODO: Test that a single child and an array with one item have the same key + * pattern. + */ + + var didWarnAboutMaps = false; + var userProvidedKeyEscapeRegex = /\/+/g; + + function escapeUserProvidedKey(text) { + return text.replace(userProvidedKeyEscapeRegex, "$&/"); + } + /** + * Generate a key string that identifies a element within a set. * - * @param {?object} children Child collection structure. - * @return {ReactElement} The first and only `ReactElement` contained in the - * structure. + * @param {*} element A element that could contain a manual key. + * @param {number} index Index that is used if a manual key is not provided. + * @return {string} */ - function onlyChild(children) { - if (!isValidElement$1(children)) { - throw new Error( - "React.Children.only expected to receive a single React element child." - ); - } + function getElementKey(element, index) { + // Do some typechecking here since we call this blindly. We want to ensure + // that we don't block potential future ES APIs. + if ( + typeof element === "object" && + element !== null && + element.key != null + ) { + // Explicit key + { + checkKeyStringCoercion(element.key); + } - return children; + return escape("" + element.key); + } // Implicit key determined by the index in the set + + return index.toString(36); } - function createContext(defaultValue) { - // TODO: Second argument used to be an optional `calculateChangedBits` - // function. Warn to reserve for future use? - var context = { - $$typeof: REACT_CONTEXT_TYPE, - // As a workaround to support multiple concurrent renderers, we categorize - // some renderers as primary and others as secondary. We only expect - // there to be two concurrent renderers at most: React Native (primary) and - // Fabric (secondary); React DOM (primary) and React ART (secondary). - // Secondary renderers store their context values on separate fields. - _currentValue: defaultValue, - _currentValue2: defaultValue, - // Used to track how many concurrent renderers this context currently - // supports within in a single renderer. Such as parallel server rendering. - _threadCount: 0, - // These are circular - Provider: null, - Consumer: null - }; + function noop() {} - { - context.Provider = { - $$typeof: REACT_PROVIDER_TYPE, - _context: context - }; + function resolveThenable(thenable) { + switch (thenable.status) { + case "fulfilled": { + var fulfilledValue = thenable.value; + return fulfilledValue; + } - { - var Consumer = { - $$typeof: REACT_CONTEXT_TYPE, - _context: context - }; - Object.defineProperties(Consumer, { - Provider: { - get: function () { - return context.Provider; + case "rejected": { + var rejectedError = thenable.reason; + throw rejectedError; + } + + default: { + if (typeof thenable.status === "string") { + // Only instrument the thenable if the status if not defined. If + // it's defined, but an unknown value, assume it's been instrumented by + // 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, noop); + } else { + // This is an uncached thenable that we haven't seen before. + // TODO: Detect infinite ping loops caused by uncached promises. + var pendingThenable = thenable; + pendingThenable.status = "pending"; + pendingThenable.then( + function (fulfilledValue) { + if (thenable.status === "pending") { + var fulfilledThenable = thenable; + fulfilledThenable.status = "fulfilled"; + fulfilledThenable.value = fulfilledValue; + } }, - set: function (_Provider) { - context.Provider = _Provider; + function (error) { + if (thenable.status === "pending") { + var rejectedThenable = thenable; + rejectedThenable.status = "rejected"; + rejectedThenable.reason = error; + } } - }, - _currentValue: { - get: function () { - return context._currentValue; - }, - set: function (_currentValue) { - context._currentValue = _currentValue; - } - }, - _currentValue2: { - get: function () { - return context._currentValue2; - }, - set: function (_currentValue2) { - context._currentValue2 = _currentValue2; - } - }, - _threadCount: { - get: function () { - return context._threadCount; - }, - set: function (_threadCount) { - context._threadCount = _threadCount; - } - }, - Consumer: { - get: function () { - return context.Consumer; - } - }, - displayName: { - get: function () { - return context.displayName; - }, - set: function (displayName) {} + ); + } // Check one more time in case the thenable resolved synchronously. + + switch (thenable.status) { + case "fulfilled": { + var fulfilledThenable = thenable; + return fulfilledThenable.value; } - }); - context.Consumer = Consumer; + + case "rejected": { + var rejectedThenable = thenable; + var _rejectedError = rejectedThenable.reason; + throw _rejectedError; + } + } } } - { - context._currentRenderer = null; - context._currentRenderer2 = null; + throw thenable; + } + + function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { + var type = typeof children; + + if (type === "undefined" || type === "boolean") { + // All of the above are perceived as null. + children = null; } - return context; - } + var invokeCallback = false; - var Uninitialized = -1; - var Pending = 0; - var Resolved = 1; - var Rejected = 2; + if (children === null) { + invokeCallback = true; + } else { + switch (type) { + case "string": + case "number": + invokeCallback = true; + break; - function lazyInitializer(payload) { - if (payload._status === Uninitialized) { - var ctor = payload._result; - var thenable = ctor(); // Transition to the next state. - // This might throw either because it's missing or throws. If so, we treat it - // as still uninitialized and try again next time. Which is the same as what - // happens if the ctor or any wrappers processing the ctor throws. This might - // end up fixing it if the resolution was a concurrency bug. + case "object": + switch (children.$$typeof) { + case REACT_ELEMENT_TYPE: + case REACT_PORTAL_TYPE: + invokeCallback = true; + break; - thenable.then( - function (moduleObject) { - if ( - payload._status === Pending || - payload._status === Uninitialized - ) { - // Transition to the next state. - var resolved = payload; - resolved._status = Resolved; - resolved._result = moduleObject; - } - }, - function (error) { - if ( - payload._status === Pending || - payload._status === Uninitialized - ) { - // Transition to the next state. - var rejected = payload; - rejected._status = Rejected; - rejected._result = error; + case REACT_LAZY_TYPE: + var payload = children._payload; + var init = children._init; + return mapIntoArray( + init(payload), + array, + escapedPrefix, + nameSoFar, + callback + ); } - } - ); - - if (payload._status === Uninitialized) { - // In case, we're still uninitialized, then we're waiting for the thenable - // to resolve. Set it as pending in the meantime. - var pending = payload; - pending._status = Pending; - pending._result = thenable; } } - if (payload._status === Resolved) { - var moduleObject = payload._result; + if (invokeCallback) { + var _child = children; + var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array + // so that it's consistent if the number of children grows: - { - if (moduleObject === undefined) { - error( - "lazy: Expected the result of a dynamic imp" + - "ort() call. " + - "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. - "const MyComponent = lazy(() => imp" + - "ort('./MyComponent'))\n\n" + - "Did you accidentally put curly braces around the import?", - moduleObject - ); + var childKey = + nameSoFar === "" ? SEPARATOR + getElementKey(_child, 0) : nameSoFar; + + if (isArray(mappedChild)) { + var escapedChildKey = ""; + + if (childKey != null) { + escapedChildKey = escapeUserProvidedKey(childKey) + "/"; } - } - { - if (!("default" in moduleObject)) { - error( - "lazy: Expected the result of a dynamic imp" + - "ort() call. " + - "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. - "const MyComponent = lazy(() => imp" + - "ort('./MyComponent'))", - moduleObject + mapIntoArray(mappedChild, array, escapedChildKey, "", function (c) { + return c; + }); + } else if (mappedChild != null) { + if (isValidElement(mappedChild)) { + { + // The `if` statement here prevents auto-disabling of the safe + // coercion ESLint rule, so we must manually disable it below. + // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key + if ( + mappedChild.key && + (!_child || _child.key !== mappedChild.key) + ) { + checkKeyStringCoercion(mappedChild.key); + } + } + + mappedChild = cloneAndReplaceKey( + mappedChild, // Keep both the (mapped) and old keys if they differ, just as + // traverseAllChildren used to do for objects as children + escapedPrefix + // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key + (mappedChild.key && (!_child || _child.key !== mappedChild.key) + ? escapeUserProvidedKey( + // $FlowFixMe[unsafe-addition] + "" + mappedChild.key // eslint-disable-line react-internal/safe-string-coercion + ) + "/" + : "") + + childKey ); } + + array.push(mappedChild); } - return moduleObject.default; - } else { - throw payload._result; + return 1; } - } - function lazy(ctor) { - var payload = { - // We use these fields to store the result. - _status: Uninitialized, - _result: ctor - }; - var lazyType = { - $$typeof: REACT_LAZY_TYPE, - _payload: payload, - _init: lazyInitializer - }; + var child; + var nextName; + var subtreeCount = 0; // Count of children found in the current subtree. - { - // In production, this would just set it on the object. - var defaultProps; - var propTypes; // $FlowFixMe[prop-missing] + var nextNamePrefix = + nameSoFar === "" ? SEPARATOR : nameSoFar + SUBSEPARATOR; - Object.defineProperties(lazyType, { - defaultProps: { - configurable: true, - get: function () { - return defaultProps; - }, - // $FlowFixMe[missing-local-annot] - set: function (newDefaultProps) { - error( - "React.lazy(...): It is not supported to assign `defaultProps` to " + - "a lazy component import. Either specify them where the component " + - "is defined, or create a wrapping component around it." - ); + if (isArray(children)) { + for (var i = 0; i < children.length; i++) { + child = children[i]; + nextName = nextNamePrefix + getElementKey(child, i); + subtreeCount += mapIntoArray( + child, + array, + escapedPrefix, + nextName, + callback + ); + } + } else { + var iteratorFn = getIteratorFn(children); - defaultProps = newDefaultProps; // Match production behavior more closely: - // $FlowFixMe[prop-missing] + if (typeof iteratorFn === "function") { + var iterableChildren = children; - Object.defineProperty(lazyType, "defaultProps", { - enumerable: true - }); - } - }, - propTypes: { - configurable: true, - get: function () { - return propTypes; - }, - // $FlowFixMe[missing-local-annot] - set: function (newPropTypes) { - error( - "React.lazy(...): It is not supported to assign `propTypes` to " + - "a lazy component import. Either specify them where the component " + - "is defined, or create a wrapping component around it." - ); - - propTypes = newPropTypes; // Match production behavior more closely: - // $FlowFixMe[prop-missing] + { + // Warn about using Maps as children + if (iteratorFn === iterableChildren.entries) { + if (!didWarnAboutMaps) { + warn( + "Using Maps as children is not supported. " + + "Use an array of keyed ReactElements instead." + ); + } - Object.defineProperty(lazyType, "propTypes", { - enumerable: true - }); + didWarnAboutMaps = true; } } - }); - } - return lazyType; - } + var iterator = iteratorFn.call(iterableChildren); + var step; + var ii = 0; // $FlowFixMe[incompatible-use] `iteratorFn` might return null according to typing. - function forwardRef(render) { - { - if (render != null && render.$$typeof === REACT_MEMO_TYPE) { - error( - "forwardRef requires a render function but received a `memo` " + - "component. Instead of forwardRef(memo(...)), use " + - "memo(forwardRef(...))." - ); - } else if (typeof render !== "function") { - error( - "forwardRef requires a render function but was given %s.", - render === null ? "null" : typeof render - ); - } else { - if (render.length !== 0 && render.length !== 2) { - error( - "forwardRef render functions accept exactly two parameters: props and ref. %s", - render.length === 1 - ? "Did you forget to use the ref parameter?" - : "Any additional parameter will be undefined." + while (!(step = iterator.next()).done) { + child = step.value; + nextName = nextNamePrefix + getElementKey(child, ii++); + subtreeCount += mapIntoArray( + child, + array, + escapedPrefix, + nextName, + callback ); } - } - - if (render != null) { - if (render.defaultProps != null) { - error( - "forwardRef render functions do not support defaultProps. " + - "Did you accidentally pass a React component?" + } else if (type === "object") { + if (typeof children.then === "function") { + return mapIntoArray( + resolveThenable(children), + array, + escapedPrefix, + nameSoFar, + callback ); - } + } // eslint-disable-next-line react-internal/safe-string-coercion + + var childrenString = String(children); + throw new Error( + "Objects are not valid as a React child (found: " + + (childrenString === "[object Object]" + ? "object with keys {" + Object.keys(children).join(", ") + "}" + : childrenString) + + "). " + + "If you meant to render a collection of children, use an array " + + "instead." + ); } } - var elementType = { - $$typeof: REACT_FORWARD_REF_TYPE, - render: render - }; - - { - var ownName; - Object.defineProperty(elementType, "displayName", { - enumerable: false, - configurable: true, - get: function () { - return ownName; - }, - set: function (name) { - ownName = name; // The inner component shouldn't inherit this display name in most cases, - // because the component may be used elsewhere. - // But it's nice for anonymous functions to inherit the name, - // so that our component-stack generation logic will display their frames. - // An anonymous function generally suggests a pattern like: - // React.forwardRef((props, ref) => {...}); - // This kind of inner function is not used elsewhere so the side effect is okay. + return subtreeCount; + } + /** + * Maps children that are typically specified as `props.children`. + * + * See https://reactjs.org/docs/react-api.html#reactchildrenmap + * + * The provided mapFunction(child, index) will be called for each + * leaf child. + * + * @param {?*} children Children tree container. + * @param {function(*, int)} func The map function. + * @param {*} context Context for mapFunction. + * @return {object} Object containing the ordered map of results. + */ - if (!render.name && !render.displayName) { - render.displayName = name; - } - } - }); + function mapChildren(children, func, context) { + if (children == null) { + // $FlowFixMe limitation refining abstract types in Flow + return children; } - return elementType; + var result = []; + var count = 0; + mapIntoArray(children, result, "", "", function (child) { + return func.call(context, child, count++); + }); + return result; } + /** + * Count the number of children that are typically specified as + * `props.children`. + * + * See https://reactjs.org/docs/react-api.html#reactchildrencount + * + * @param {?*} children Children tree container. + * @return {number} The number of children. + */ - function memo(type, compare) { - { - if (!isValidElementType(type)) { - error( - "memo: The first argument must be a component. Instead " + - "received: %s", - type === null ? "null" : typeof type - ); - } - } + function countChildren(children) { + var n = 0; + mapChildren(children, function () { + n++; // Don't return anything + }); + return n; + } + /** + * Iterates through children that are typically specified as `props.children`. + * + * See https://reactjs.org/docs/react-api.html#reactchildrenforeach + * + * The provided forEachFunc(child, index) will be called for each + * leaf child. + * + * @param {?*} children Children tree container. + * @param {function(*, int)} forEachFunc + * @param {*} forEachContext Context for forEachContext. + */ - var elementType = { - $$typeof: REACT_MEMO_TYPE, - type: type, - compare: compare === undefined ? null : compare - }; + function forEachChildren(children, forEachFunc, forEachContext) { + mapChildren( + children, // $FlowFixMe[missing-this-annot] + function () { + forEachFunc.apply(this, arguments); // Don't return anything. + }, + forEachContext + ); + } + /** + * Flatten a children object (typically specified as `props.children`) and + * return an array with appropriately re-keyed children. + * + * See https://reactjs.org/docs/react-api.html#reactchildrentoarray + */ - { - var ownName; - Object.defineProperty(elementType, "displayName", { - enumerable: false, - configurable: true, - get: function () { - return ownName; - }, - set: function (name) { - ownName = name; // The inner component shouldn't inherit this display name in most cases, - // because the component may be used elsewhere. - // But it's nice for anonymous functions to inherit the name, - // so that our component-stack generation logic will display their frames. - // An anonymous function generally suggests a pattern like: - // React.memo((props) => {...}); - // This kind of inner function is not used elsewhere so the side effect is okay. + function toArray(children) { + return ( + mapChildren(children, function (child) { + return child; + }) || [] + ); + } + /** + * Returns the first child in a collection of children and verifies that there + * is only one child in the collection. + * + * See https://reactjs.org/docs/react-api.html#reactchildrenonly + * + * The current implementation of this function assumes that a single child gets + * passed without a wrapper, but the purpose of this helper function is to + * abstract away the particular structure of children. + * + * @param {?object} children Child collection structure. + * @return {ReactElement} The first and only `ReactElement` contained in the + * structure. + */ - if (!type.name && !type.displayName) { - type.displayName = name; - } - } - }); + function onlyChild(children) { + if (!isValidElement(children)) { + throw new Error( + "React.Children.only expected to receive a single React element child." + ); } - return elementType; + return children; } - function noopCache(fn) { - // On the client (i.e. not a Server Components environment) `cache` has - // no caching behavior. We just return the function as-is. - // - // We intend to implement client caching in a future major release. In the - // meantime, it's only exposed as an API so that Shared Components can use - // per-request caching on the server without breaking on the client. But it - // does mean they need to be aware of the behavioral difference. - // - // The rest of the behavior is the same as the server implementation — it - // returns a new reference, extra properties like `displayName` are not - // preserved, the length of the new function is 0, etc. That way apps can't - // accidentally depend on those details. - return function () { - // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code. - return fn.apply(null, arguments); - }; - } - var cache = noopCache; - - function resolveDispatcher() { - var dispatcher = ReactCurrentDispatcher.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://reactjs.org/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 getCacheSignal() { - var dispatcher = ReactCurrentCache.current; - - if (!dispatcher) { - // If we have no cache to associate with this call, then we don't know - // its lifetime. We abort early since that's safer than letting it live - // for ever. Unlike just caching which can be a functional noop outside - // of React, these should generally always be associated with some React - // render but we're not limiting quite as much as making it a Hook. - // It's safer than erroring early at runtime. - var controller = new AbortController(); - var reason = new Error( - "This CacheSignal was requested outside React which means that it is " + - "immediately aborted." - ); - controller.abort(reason); - return controller.signal; - } - - return dispatcher.getCacheSignal(); - } - function getCacheForType(resourceType) { - var dispatcher = ReactCurrentCache.current; - - if (!dispatcher) { - // If there is no dispatcher, then we treat this as not being cached. - return resourceType(); - } - - return dispatcher.getCacheForType(resourceType); - } - function useContext(Context) { - var dispatcher = resolveDispatcher(); - - { - if (Context.$$typeof === REACT_CONSUMER_TYPE) { - error( - "Calling useContext(Context.Consumer) is not supported and will cause bugs. " + - "Did you mean to call useContext(Context) instead?" - ); - } - } - - return dispatcher.useContext(Context); - } - function useState(initialState) { - var dispatcher = resolveDispatcher(); - return dispatcher.useState(initialState); - } - function useReducer(reducer, initialArg, init) { - var dispatcher = resolveDispatcher(); - return dispatcher.useReducer(reducer, initialArg, init); - } - function useRef(initialValue) { - var dispatcher = resolveDispatcher(); - return dispatcher.useRef(initialValue); - } - function useEffect(create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useEffect(create, deps); - } - function useInsertionEffect(create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useInsertionEffect(create, deps); - } - function useLayoutEffect(create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useLayoutEffect(create, deps); - } - function useCallback(callback, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useCallback(callback, deps); - } - function useMemo(create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useMemo(create, deps); - } - function useImperativeHandle(ref, create, deps) { - var dispatcher = resolveDispatcher(); - return dispatcher.useImperativeHandle(ref, create, deps); - } - function useDebugValue(value, formatterFn) { - { - var dispatcher = resolveDispatcher(); - return dispatcher.useDebugValue(value, formatterFn); - } - } - function useTransition() { - var dispatcher = resolveDispatcher(); - return dispatcher.useTransition(); - } - function useDeferredValue(value, initialValue) { - var dispatcher = resolveDispatcher(); - return dispatcher.useDeferredValue(value, initialValue); - } - function useId() { - var dispatcher = resolveDispatcher(); - return dispatcher.useId(); - } - function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { - var dispatcher = resolveDispatcher(); - return dispatcher.useSyncExternalStore( - subscribe, - getSnapshot, - getServerSnapshot - ); - } - function useCacheRefresh() { - var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional - - return dispatcher.useCacheRefresh(); - } - function use(usable) { - var dispatcher = resolveDispatcher(); - return dispatcher.use(usable); - } - function useMemoCache(size) { - var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional - - return dispatcher.useMemoCache(size); - } - function useEffectEvent(callback) { - var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional - - return dispatcher.useEffectEvent(callback); - } - function useOptimistic(passthrough, reducer) { - var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional - - return dispatcher.useOptimistic(passthrough, reducer); - } - - function startTransition(scope, options) { - 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 - }; - ReactCurrentBatchConfig.transition = transition; - var currentTransition = ReactCurrentBatchConfig.transition; - - { - ReactCurrentBatchConfig.transition._updatedFibers = new Set(); - } - - { - // When async actions are not enabled, startTransition does not - // capture errors. - try { - scope(); - } finally { - warnAboutTransitionSubscriptions(prevTransition, currentTransition); - ReactCurrentBatchConfig.transition = prevTransition; - } - } - } - - function warnAboutTransitionSubscriptions( - prevTransition, - currentTransition - ) { - { - if (prevTransition === null && currentTransition._updatedFibers) { - var updatedFibersCount = currentTransition._updatedFibers.size; - - currentTransition._updatedFibers.clear(); - - if (updatedFibersCount > 10) { - warn( - "Detected a large number of updates inside startTransition. " + - "If this is due to a subscription please re-write it to use React provided hooks. " + - "Otherwise concurrent mode guarantees are off the table." - ); - } - } - } - } - // the default for onRecoverableError. - - typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, - ? // emulating an uncaught JavaScript error. - reportError - : function (error) { - // In older browsers and test environments, fallback to console.error. - // eslint-disable-next-line react-internal/no-production-logging - console["error"](error); - }; - - var didWarnAboutMessageChannel = false; - var enqueueTaskImpl = null; - function enqueueTask(task) { - if (enqueueTaskImpl === null) { - try { - // read require off the module object to get around the bundlers. - // we don't want them to detect a require and bundle a Node polyfill. - var requireString = ("require" + Math.random()).slice(0, 7); - var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's - // version of setImmediate, bypassing fake timers if any. - - enqueueTaskImpl = nodeRequire.call(module, "timers").setImmediate; - } catch (_err) { - // we're in a browser - // we can't use regular timers because they may still be faked - // so we try MessageChannel+postMessage instead - enqueueTaskImpl = function (callback) { - { - if (didWarnAboutMessageChannel === false) { - didWarnAboutMessageChannel = true; - - if (typeof MessageChannel === "undefined") { - error( - "This browser does not have a MessageChannel implementation, " + - "so enqueuing tasks via await act(async () => ...) will fail. " + - "Please file an issue at https://github.com/facebook/react/issues " + - "if you encounter this warning." - ); - } - } - } - - var channel = new MessageChannel(); - channel.port1.onmessage = callback; - channel.port2.postMessage(undefined); - }; - } - } - - return enqueueTaskImpl(task); - } - - // number of `act` scopes on the stack. - - var actScopeDepth = 0; // We only warn the first time you neglect to await an async `act` scope. - - var didWarnNoAwaitAct = false; - function act(callback) { - { - // 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. - // - // We set this to an empty array when we first enter an `act` scope, and - // only unset it once we've left the outermost `act` scope — remember that - // `act` calls can be nested. - // - // If we're already inside an `act` scope, reuse the existing queue. - var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy; - var prevActQueue = ReactCurrentActQueue.current; - var prevActScopeDepth = actScopeDepth; - actScopeDepth++; - 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. - - ReactCurrentActQueue.isBatchingLegacy = true; - var result; // This tracks whether the `act` call is awaited. In certain cases, not - // awaiting it is a mistake, so we will detect that and warn. - - var didAwaitActCall = false; - - try { - // Reset this to `false` right before entering the React work loop. The - // 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. - ReactCurrentActQueue.didScheduleLegacyUpdate = false; - result = callback(); - var didScheduleLegacyUpdate = - ReactCurrentActQueue.didScheduleLegacyUpdate; // 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. - - if (!prevIsBatchingLegacy && didScheduleLegacyUpdate) { - flushActQueue(queue); - } // `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!! - - 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!! - ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy; - popActScope(prevActQueue, prevActScopeDepth); - throw error; - } - - if ( - result !== null && - typeof result === "object" && // $FlowFixMe[method-unbinding] - typeof result.then === "function" - ) { - // A promise/thenable was returned from the callback. Wait for it to - // resolve before flushing the queue. - // - // If `act` were implemented as an async function, this whole block could - // be a single `await` call. That's really the only difference between - // this branch and the next one. - var thenable = result; // Warn if the an `act` call with an async scope is not awaited. In a - // future release, consider making this an error. - - queueSeveralMicrotasks(function () { - if (!didAwaitActCall && !didWarnNoAwaitAct) { - didWarnNoAwaitAct = true; - - error( - "You called act(async () => ...) without await. " + - "This could lead to unexpected testing behaviour, " + - "interleaving multiple act calls and mixing their " + - "scopes. " + - "You should - await act(async () => ...);" - ); - } - }); - return { - then: function (resolve, reject) { - didAwaitActCall = true; - thenable.then( - function (returnValue) { - popActScope(prevActQueue, prevActScopeDepth); - - if (prevActScopeDepth === 0) { - // We're exiting the outermost `act` scope. Flush the queue. - try { - flushActQueue(queue); - enqueueTask(function () { - return ( - // Recursively flush tasks scheduled by a microtask. - recursivelyFlushAsyncActWork( - returnValue, - resolve, - reject - ) - ); - }); - } catch (error) { - // `thenable` might not be a real promise, and `flushActQueue` - // might throw, so we need to wrap `flushActQueue` in a - // try/catch. - reject(error); - } - } else { - resolve(returnValue); - } - }, - function (error) { - popActScope(prevActQueue, prevActScopeDepth); - reject(error); - } - ); - } - }; - } else { - var returnValue = result; // The callback is not an async function. Exit the current - // scope immediately. - - popActScope(prevActQueue, prevActScopeDepth); - - if (prevActScopeDepth === 0) { - // We're exiting the outermost `act` scope. Flush the queue. - flushActQueue(queue); // If the queue is not empty, it implies that we intentionally yielded - // to the main thread, because something suspended. We will continue - // in an asynchronous task. - // - // Warn if something suspends but the `act` call is not awaited. - // In a future release, consider making this an error. - - if (queue.length !== 0) { - queueSeveralMicrotasks(function () { - if (!didAwaitActCall && !didWarnNoAwaitAct) { - didWarnNoAwaitAct = true; - - error( - "A component suspended inside an `act` scope, but the " + - "`act` call was not awaited. When testing React " + - "components that depend on asynchronous data, you must " + - "await the result:\n\n" + - "await act(() => ...)" - ); - } - }); - } // Like many things in this module, this is next part is confusing. - // - // We do not currently require every `act` call that is passed a - // callback to be awaited, through arguably we should. Since this - // callback was synchronous, we need to exit the current scope before - // returning. - // - // However, if thenable we're about to return *is* awaited, we'll - // immediately restore the current scope. So it shouldn't observable. - // - // This doesn't affect the case where the scope callback is async, - // because we always require those calls to be awaited. - // - // TODO: In a future version, consider always requiring all `act` calls - // to be awaited, regardless of whether the callback is sync or async. - - ReactCurrentActQueue.current = null; - } - - return { - then: function (resolve, reject) { - didAwaitActCall = true; - - 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. - ReactCurrentActQueue.current = queue; - enqueueTask(function () { - return ( - // Recursively flush tasks scheduled by a microtask. - recursivelyFlushAsyncActWork(returnValue, resolve, reject) - ); - }); - } else { - resolve(returnValue); - } - } - }; - } - } - } - - function popActScope(prevActQueue, prevActScopeDepth) { - { - if (prevActScopeDepth !== actScopeDepth - 1) { - error( - "You seem to have overlapping act() calls, this is not supported. " + - "Be sure to await previous act() calls before making a new one. " - ); - } - - actScopeDepth = prevActScopeDepth; - } - } + function createContext(defaultValue) { + // TODO: Second argument used to be an optional `calculateChangedBits` + // function. Warn to reserve for future use? + var context = { + $$typeof: REACT_CONTEXT_TYPE, + // As a workaround to support multiple concurrent renderers, we categorize + // some renderers as primary and others as secondary. We only expect + // there to be two concurrent renderers at most: React Native (primary) and + // Fabric (secondary); React DOM (primary) and React ART (secondary). + // Secondary renderers store their context values on separate fields. + _currentValue: defaultValue, + _currentValue2: defaultValue, + // Used to track how many concurrent renderers this context currently + // supports within in a single renderer. Such as parallel server rendering. + _threadCount: 0, + // These are circular + Provider: null, + Consumer: null + }; - function recursivelyFlushAsyncActWork(returnValue, resolve, reject) { { - // Check if any tasks were scheduled asynchronously. - var queue = ReactCurrentActQueue.current; - - if (queue !== null) { - if (queue.length !== 0) { - // Async tasks were scheduled, mostly likely in a microtask. - // Keep flushing until there are no more. - try { - flushActQueue(queue); // The work we just performed may have schedule additional async - // tasks. Wait a macrotask and check again. + context.Provider = { + $$typeof: REACT_PROVIDER_TYPE, + _context: context + }; - enqueueTask(function () { - return recursivelyFlushAsyncActWork( - returnValue, - resolve, - reject - ); - }); - } catch (error) { - // Leave remaining tasks on the queue if something throws. - reject(error); + { + var Consumer = { + $$typeof: REACT_CONTEXT_TYPE, + _context: context + }; + Object.defineProperties(Consumer, { + Provider: { + get: function () { + return context.Provider; + }, + set: function (_Provider) { + context.Provider = _Provider; + } + }, + _currentValue: { + get: function () { + return context._currentValue; + }, + set: function (_currentValue) { + context._currentValue = _currentValue; + } + }, + _currentValue2: { + get: function () { + return context._currentValue2; + }, + set: function (_currentValue2) { + context._currentValue2 = _currentValue2; + } + }, + _threadCount: { + get: function () { + return context._threadCount; + }, + set: function (_threadCount) { + context._threadCount = _threadCount; + } + }, + Consumer: { + get: function () { + return context.Consumer; + } + }, + displayName: { + get: function () { + return context.displayName; + }, + set: function (displayName) {} } - } else { - // The queue is empty. We can finish. - ReactCurrentActQueue.current = null; - resolve(returnValue); - } - } else { - resolve(returnValue); - } - } - } - - var isFlushing = false; - - function flushActQueue(queue) { - { - if (!isFlushing) { - // Prevent re-entrance. - isFlushing = true; - var i = 0; - - try { - for (; i < queue.length; i++) { - var callback = queue[i]; - - do { - ReactCurrentActQueue.didUsePromise = false; - var continuation = callback(false); - - if (continuation !== null) { - 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. - queue[i] = callback; - queue.splice(0, i); - return; - } - - callback = continuation; - } else { - break; - } - } while (true); - } // We flushed the entire queue. - - queue.length = 0; - } catch (error) { - // If something throws, leave the remaining callbacks on the queue. - queue.splice(0, i + 1); - throw error; - } finally { - isFlushing = false; - } - } - } - } // Some of our warnings attempt to detect if the `act` call is awaited by - // checking in an asynchronous task. Wait a few microtasks before checking. The - // only reason one isn't sufficient is we want to accommodate the case where an - // `act` call is returned from an async function without first being awaited, - // since that's a somewhat common pattern. If you do this too many times in a - // nested sequence, you might get a warning, but you can always fix by awaiting - // the call. - // - // A macrotask would also work (and is the fallback) but depending on the test - // environment it may cause the warning to fire too late. - - var queueSeveralMicrotasks = - typeof queueMicrotask === "function" - ? function (callback) { - queueMicrotask(function () { - return queueMicrotask(callback); - }); - } - : enqueueTask; - - var Children = { - map: mapChildren, - forEach: forEachChildren, - count: countChildren, - toArray: toArray, - only: onlyChild - }; - - var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); - var specialPropKeyWarningShown; - var specialPropRefWarningShown; - var didWarnAboutStringRefs; - - { - didWarnAboutStringRefs = {}; - } - - function hasValidRef(config) { - { - if (hasOwnProperty.call(config, "ref")) { - var getter = Object.getOwnPropertyDescriptor(config, "ref").get; - - if (getter && getter.isReactWarning) { - return false; - } + }); + context.Consumer = Consumer; } } - return config.ref !== undefined; - } - - function hasValidKey(config) { { - if (hasOwnProperty.call(config, "key")) { - var getter = Object.getOwnPropertyDescriptor(config, "key").get; - - if (getter && getter.isReactWarning) { - return false; - } - } + context._currentRenderer = null; + context._currentRenderer2 = null; } - return config.key !== undefined; + return context; } - function warnIfStringRefCannotBeAutoConverted(config, self) { - { - if ( - typeof config.ref === "string" && - ReactCurrentOwner.current && - self && - ReactCurrentOwner.current.stateNode !== self - ) { - var componentName = getComponentNameFromType( - ReactCurrentOwner.current.type - ); + var Uninitialized = -1; + var Pending = 0; + var Resolved = 1; + var Rejected = 2; - if (!didWarnAboutStringRefs[componentName]) { - error( - 'Component "%s" contains the string ref "%s". ' + - "Support for string refs will be removed in a future major release. " + - "This case cannot be automatically converted to an arrow function. " + - "We ask you to manually fix this case by using useRef() or createRef() instead. " + - "Learn more about using refs safely here: " + - "https://reactjs.org/link/strict-mode-string-ref", - getComponentNameFromType(ReactCurrentOwner.current.type), - config.ref - ); + function lazyInitializer(payload) { + if (payload._status === Uninitialized) { + var ctor = payload._result; + var thenable = ctor(); // Transition to the next state. + // This might throw either because it's missing or throws. If so, we treat it + // as still uninitialized and try again next time. Which is the same as what + // happens if the ctor or any wrappers processing the ctor throws. This might + // end up fixing it if the resolution was a concurrency bug. - didWarnAboutStringRefs[componentName] = true; + thenable.then( + function (moduleObject) { + if ( + payload._status === Pending || + payload._status === Uninitialized + ) { + // Transition to the next state. + var resolved = payload; + resolved._status = Resolved; + resolved._result = moduleObject; + } + }, + function (error) { + if ( + payload._status === Pending || + payload._status === Uninitialized + ) { + // Transition to the next state. + var rejected = payload; + rejected._status = Rejected; + rejected._result = error; + } } + ); + + if (payload._status === Uninitialized) { + // In case, we're still uninitialized, then we're waiting for the thenable + // to resolve. Set it as pending in the meantime. + var pending = payload; + pending._status = Pending; + pending._result = thenable; } } - } - function defineKeyPropWarningGetter(props, displayName) { - { - var warnAboutAccessingKey = function () { - if (!specialPropKeyWarningShown) { - specialPropKeyWarningShown = true; + if (payload._status === Resolved) { + var moduleObject = payload._result; + { + if (moduleObject === undefined) { error( - "%s: `key` is not a prop. Trying to access it will result " + - "in `undefined` being returned. If you need to access the same " + - "value within the child component, you should pass it as a different " + - "prop. (https://reactjs.org/link/special-props)", - displayName + "lazy: Expected the result of a dynamic imp" + + "ort() call. " + + "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. + "const MyComponent = lazy(() => imp" + + "ort('./MyComponent'))\n\n" + + "Did you accidentally put curly braces around the import?", + moduleObject ); } - }; - - warnAboutAccessingKey.isReactWarning = true; - Object.defineProperty(props, "key", { - get: warnAboutAccessingKey, - configurable: true - }); - } - } - - function defineRefPropWarningGetter(props, displayName) { - { - var warnAboutAccessingRef = function () { - if (!specialPropRefWarningShown) { - specialPropRefWarningShown = true; + } + { + if (!("default" in moduleObject)) { error( - "%s: `ref` is not a prop. Trying to access it will result " + - "in `undefined` being returned. If you need to access the same " + - "value within the child component, you should pass it as a different " + - "prop. (https://reactjs.org/link/special-props)", - displayName + "lazy: Expected the result of a dynamic imp" + + "ort() call. " + + "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. + "const MyComponent = lazy(() => imp" + + "ort('./MyComponent'))", + moduleObject ); } - }; - - warnAboutAccessingRef.isReactWarning = true; - Object.defineProperty(props, "ref", { - get: warnAboutAccessingRef, - configurable: true - }); - } - } - /** - * Factory method to create a new React element. This no longer adheres to - * the class pattern, so do not use new to call it. Also, instanceof check - * will not work. Instead test $$typeof field against Symbol.for('react.element') to check - * if something is a React Element. - * - * @param {*} type - * @param {*} props - * @param {*} key - * @param {string|object} ref - * @param {*} owner - * @param {*} self A *temporary* helper to detect places where `this` is - * different from the `owner` when React.createElement is called, so that we - * can warn. We want to get rid of owner and replace string `ref`s with arrow - * functions, and as long as `this` and owner are the same, there will be no - * change in behavior. - * @param {*} source An annotation object (added by a transpiler or otherwise) - * indicating filename, line number, and/or other information. - * @internal - */ - - function ReactElement(type, key, ref, self, source, owner, props) { - var element = { - // This tag allows us to uniquely identify this as a React Element - $$typeof: REACT_ELEMENT_TYPE, - // Built-in properties that belong on the element - type: type, - key: key, - ref: ref, - props: props, - // Record the component responsible for creating this element. - _owner: owner - }; - - { - // The validation flag is currently mutative. We put it on - // an external backing store so that we can freeze the whole object. - // This can be replaced with a WeakMap once they are implemented in - // commonly used development environments. - element._store = {}; // To make comparing ReactElements easier for testing purposes, we make - // the validation flag non-enumerable (where possible, which should - // include every environment we run tests in), so the test framework - // ignores it. - - Object.defineProperty(element._store, "validated", { - configurable: false, - enumerable: false, - writable: true, - value: false - }); // debugInfo contains Server Component debug information. - - Object.defineProperty(element, "_debugInfo", { - configurable: false, - enumerable: false, - writable: true, - value: null - }); - - if (Object.freeze) { - Object.freeze(element.props); - Object.freeze(element); } - } - - return element; - } - // support `jsx` and `jsxs` when running in development. This supports the case - // where a third-party dependency ships code that was compiled for production; - // we want to still provide warnings in development. - // - // So these functions are the _dev_ implementations of the _production_ - // API signatures. - // - // Since these functions are dev-only, it's ok to add an indirection here. They - // only exist to provide different versions of `isStaticChildren`. (We shouldn't - // use this pattern for the prod versions, though, because it will add an call - // frame.) - function jsxProdSignatureRunningInDevWithDynamicChildren( - type, - config, - maybeKey, - source, - self - ) { - { - var isStaticChildren = false; - return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); - } - } - function jsxProdSignatureRunningInDevWithStaticChildren( - type, - config, - maybeKey, - source, - self - ) { - { - var isStaticChildren = true; - return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); + return moduleObject.default; + } else { + throw payload._result; } } - var didWarnAboutKeySpread = {}; - /** - * https://github.com/reactjs/rfcs/pull/107 - * @param {*} type - * @param {object} props - * @param {string} key - */ - function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) { - { - if (!isValidElementType(type)) { - // This is an invalid element type. - // - // We warn in this case but don't throw. We expect the element creation to - // succeed and there will likely be errors in render. - var info = ""; + function lazy(ctor) { + var payload = { + // We use these fields to store the result. + _status: Uninitialized, + _result: ctor + }; + var lazyType = { + $$typeof: REACT_LAZY_TYPE, + _payload: payload, + _init: lazyInitializer + }; - if ( - type === undefined || - (typeof type === "object" && - type !== null && - Object.keys(type).length === 0) - ) { - info += - " You likely forgot to export your component from the file " + - "it's defined in, or you might have mixed up default and named imports."; - } + { + // In production, this would just set it on the object. + var defaultProps; + var propTypes; // $FlowFixMe[prop-missing] - var sourceInfo = getSourceInfoErrorAddendum(source); + Object.defineProperties(lazyType, { + defaultProps: { + configurable: true, + get: function () { + return defaultProps; + }, + // $FlowFixMe[missing-local-annot] + set: function (newDefaultProps) { + error( + "React.lazy(...): It is not supported to assign `defaultProps` to " + + "a lazy component import. Either specify them where the component " + + "is defined, or create a wrapping component around it." + ); - if (sourceInfo) { - info += sourceInfo; - } else { - info += getDeclarationErrorAddendum(); - } + defaultProps = newDefaultProps; // Match production behavior more closely: + // $FlowFixMe[prop-missing] - var typeString; + Object.defineProperty(lazyType, "defaultProps", { + enumerable: true + }); + } + }, + propTypes: { + configurable: true, + get: function () { + return propTypes; + }, + // $FlowFixMe[missing-local-annot] + set: function (newPropTypes) { + error( + "React.lazy(...): It is not supported to assign `propTypes` to " + + "a lazy component import. Either specify them where the component " + + "is defined, or create a wrapping component around it." + ); - if (type === null) { - typeString = "null"; - } else if (isArray(type)) { - typeString = "array"; - } else if ( - type !== undefined && - type.$$typeof === REACT_ELEMENT_TYPE - ) { - typeString = - "<" + (getComponentNameFromType(type.type) || "Unknown") + " />"; - info = - " Did you accidentally export a JSX literal instead of a component?"; - } else { - typeString = typeof type; + propTypes = newPropTypes; // Match production behavior more closely: + // $FlowFixMe[prop-missing] + + Object.defineProperty(lazyType, "propTypes", { + enumerable: true + }); + } } + }); + } + return lazyType; + } + + function forwardRef(render) { + { + if (render != null && render.$$typeof === REACT_MEMO_TYPE) { error( - "React.jsx: type is invalid -- expected a string (for " + - "built-in components) or a class/function (for composite " + - "components) but got: %s.%s", - typeString, - info + "forwardRef requires a render function but received a `memo` " + + "component. Instead of forwardRef(memo(...)), use " + + "memo(forwardRef(...))." + ); + } else if (typeof render !== "function") { + error( + "forwardRef requires a render function but was given %s.", + render === null ? "null" : typeof render ); } else { - // This is a valid element type. - // Skip key warning if the type isn't valid since our key validation logic - // doesn't expect a non-string/function type and can throw confusing - // errors. We don't want exception behavior to differ between dev and - // prod. (Rendering will throw with a helpful message and as soon as the - // type is fixed, the key warnings will appear.) - var children = config.children; - - if (children !== undefined) { - if (isStaticChildren) { - if (isArray(children)) { - for (var i = 0; i < children.length; i++) { - validateChildKeys(children[i], type); - } - - if (Object.freeze) { - Object.freeze(children); - } - } else { - error( - "React.jsx: Static children should always be an array. " + - "You are likely explicitly calling React.jsxs or React.jsxDEV. " + - "Use the Babel transform instead." - ); - } - } else { - validateChildKeys(children, type); - } + if (render.length !== 0 && render.length !== 2) { + error( + "forwardRef render functions accept exactly two parameters: props and ref. %s", + render.length === 1 + ? "Did you forget to use the ref parameter?" + : "Any additional parameter will be undefined." + ); } - } // Warn about key spread regardless of whether the type is valid. - - if (hasOwnProperty.call(config, "key")) { - var componentName = getComponentNameFromType(type); - var keys = Object.keys(config).filter(function (k) { - return k !== "key"; - }); - var beforeExample = - keys.length > 0 - ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" - : "{key: someKey}"; - - if (!didWarnAboutKeySpread[componentName + beforeExample]) { - var afterExample = - keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}"; + } + if (render != null) { + if (render.defaultProps != null) { error( - 'A props object containing a "key" prop is being spread into JSX:\n' + - " let props = %s;\n" + - " <%s {...props} />\n" + - "React keys must be passed directly to JSX without using spread:\n" + - " let props = %s;\n" + - " <%s key={someKey} {...props} />", - beforeExample, - componentName, - afterExample, - componentName + "forwardRef render functions do not support defaultProps. " + + "Did you accidentally pass a React component?" ); - - didWarnAboutKeySpread[componentName + beforeExample] = true; } } + } - var propName; // Reserved names are extracted + var elementType = { + $$typeof: REACT_FORWARD_REF_TYPE, + render: render + }; - 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.
- // or
). We want to deprecate key spread, - // but as an intermediary step, we will use jsxDEV for everything except - //
, because we aren't currently able to tell if - // key is explicitly declared to be undefined or not. + { + var ownName; + Object.defineProperty(elementType, "displayName", { + enumerable: false, + configurable: true, + get: function () { + return ownName; + }, + set: function (name) { + ownName = name; // The inner component shouldn't inherit this display name in most cases, + // because the component may be used elsewhere. + // But it's nice for anonymous functions to inherit the name, + // so that our component-stack generation logic will display their frames. + // An anonymous function generally suggests a pattern like: + // React.forwardRef((props, ref) => {...}); + // This kind of inner function is not used elsewhere so the side effect is okay. - if (maybeKey !== undefined) { - { - checkKeyStringCoercion(maybeKey); + if (!render.name && !render.displayName) { + render.displayName = name; + } } + }); + } - key = "" + maybeKey; - } - - if (hasValidKey(config)) { - { - checkKeyStringCoercion(config.key); - } + return elementType; + } - key = "" + config.key; + function memo(type, compare) { + { + if (!isValidElementType(type)) { + error( + "memo: The first argument must be a component. Instead " + + "received: %s", + type === null ? "null" : typeof type + ); } + } - if (hasValidRef(config)) { - ref = config.ref; - warnIfStringRefCannotBeAutoConverted(config, self); - } // Remaining properties are added to a new props object - - for (propName in config) { - if ( - hasOwnProperty.call(config, propName) && // Skip over reserved prop names - propName !== "key" && // TODO: `ref` will no longer be reserved in the next major - propName !== "ref" - ) { - props[propName] = config[propName]; - } - } // Resolve default props + var elementType = { + $$typeof: REACT_MEMO_TYPE, + type: type, + compare: compare === undefined ? null : compare + }; - if (type && type.defaultProps) { - var defaultProps = type.defaultProps; + { + var ownName; + Object.defineProperty(elementType, "displayName", { + enumerable: false, + configurable: true, + get: function () { + return ownName; + }, + set: function (name) { + ownName = name; // The inner component shouldn't inherit this display name in most cases, + // because the component may be used elsewhere. + // But it's nice for anonymous functions to inherit the name, + // so that our component-stack generation logic will display their frames. + // An anonymous function generally suggests a pattern like: + // React.memo((props) => {...}); + // This kind of inner function is not used elsewhere so the side effect is okay. - for (propName in defaultProps) { - if (props[propName] === undefined) { - props[propName] = defaultProps[propName]; + if (!type.name && !type.displayName) { + type.displayName = name; } } - } + }); + } - if (key || ref) { - var displayName = - typeof type === "function" - ? type.displayName || type.name || "Unknown" - : type; + return elementType; + } - if (key) { - defineKeyPropWarningGetter(props, displayName); - } + function noopCache(fn) { + // On the client (i.e. not a Server Components environment) `cache` has + // no caching behavior. We just return the function as-is. + // + // We intend to implement client caching in a future major release. In the + // meantime, it's only exposed as an API so that Shared Components can use + // per-request caching on the server without breaking on the client. But it + // does mean they need to be aware of the behavioral difference. + // + // The rest of the behavior is the same as the server implementation — it + // returns a new reference, extra properties like `displayName` are not + // preserved, the length of the new function is 0, etc. That way apps can't + // accidentally depend on those details. + return function () { + // $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code. + return fn.apply(null, arguments); + }; + } + var cache = noopCache; - if (ref) { - defineRefPropWarningGetter(props, displayName); - } + function resolveDispatcher() { + var dispatcher = ReactCurrentDispatcher.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://reactjs.org/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. - var element = ReactElement( - type, - key, - ref, - self, - source, - ReactCurrentOwner.current, - props + return dispatcher; + } + + function getCacheSignal() { + var dispatcher = ReactCurrentCache.current; + + if (!dispatcher) { + // If we have no cache to associate with this call, then we don't know + // its lifetime. We abort early since that's safer than letting it live + // for ever. Unlike just caching which can be a functional noop outside + // of React, these should generally always be associated with some React + // render but we're not limiting quite as much as making it a Hook. + // It's safer than erroring early at runtime. + var controller = new AbortController(); + var reason = new Error( + "This CacheSignal was requested outside React which means that it is " + + "immediately aborted." ); + controller.abort(reason); + return controller.signal; + } - if (type === REACT_FRAGMENT_TYPE) { - validateFragmentProps(element); - } else { - validatePropTypes(element); - } + return dispatcher.getCacheSignal(); + } + function getCacheForType(resourceType) { + var dispatcher = ReactCurrentCache.current; - return element; + if (!dispatcher) { + // If there is no dispatcher, then we treat this as not being cached. + return resourceType(); } + + return dispatcher.getCacheForType(resourceType); } + function useContext(Context) { + var dispatcher = resolveDispatcher(); - function getDeclarationErrorAddendum() { { - if (ReactCurrentOwner.current) { - var name = getComponentNameFromType(ReactCurrentOwner.current.type); - - if (name) { - return "\n\nCheck the render method of `" + name + "`."; - } + if (Context.$$typeof === REACT_CONSUMER_TYPE) { + error( + "Calling useContext(Context.Consumer) is not supported and will cause bugs. " + + "Did you mean to call useContext(Context) instead?" + ); } + } - return ""; + return dispatcher.useContext(Context); + } + function useState(initialState) { + var dispatcher = resolveDispatcher(); + return dispatcher.useState(initialState); + } + function useReducer(reducer, initialArg, init) { + var dispatcher = resolveDispatcher(); + return dispatcher.useReducer(reducer, initialArg, init); + } + function useRef(initialValue) { + var dispatcher = resolveDispatcher(); + return dispatcher.useRef(initialValue); + } + function useEffect(create, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useEffect(create, deps); + } + function useInsertionEffect(create, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useInsertionEffect(create, deps); + } + function useLayoutEffect(create, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useLayoutEffect(create, deps); + } + function useCallback(callback, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useCallback(callback, deps); + } + function useMemo(create, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useMemo(create, deps); + } + function useImperativeHandle(ref, create, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useImperativeHandle(ref, create, deps); + } + function useDebugValue(value, formatterFn) { + { + var dispatcher = resolveDispatcher(); + return dispatcher.useDebugValue(value, formatterFn); } } + function useTransition() { + var dispatcher = resolveDispatcher(); + return dispatcher.useTransition(); + } + function useDeferredValue(value, initialValue) { + var dispatcher = resolveDispatcher(); + return dispatcher.useDeferredValue(value, initialValue); + } + function useId() { + var dispatcher = resolveDispatcher(); + return dispatcher.useId(); + } + function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { + var dispatcher = resolveDispatcher(); + return dispatcher.useSyncExternalStore( + subscribe, + getSnapshot, + getServerSnapshot + ); + } + function useCacheRefresh() { + var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional + + return dispatcher.useCacheRefresh(); + } + function use(usable) { + var dispatcher = resolveDispatcher(); + return dispatcher.use(usable); + } + function useMemoCache(size) { + var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional + + return dispatcher.useMemoCache(size); + } + function useEffectEvent(callback) { + var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional + + return dispatcher.useEffectEvent(callback); + } + function useOptimistic(passthrough, reducer) { + var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional + + return dispatcher.useOptimistic(passthrough, reducer); + } + + function startTransition(scope, options) { + 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 + }; + ReactCurrentBatchConfig.transition = transition; + var currentTransition = ReactCurrentBatchConfig.transition; - function getSourceInfoErrorAddendum(source) { { - if (source !== undefined) { - var fileName = source.fileName.replace(/^.*[\\\/]/, ""); - var lineNumber = source.lineNumber; - return "\n\nCheck your code at " + fileName + ":" + lineNumber + "."; - } + ReactCurrentBatchConfig.transition._updatedFibers = new Set(); + } - return ""; + { + // When async actions are not enabled, startTransition does not + // capture errors. + try { + scope(); + } finally { + warnAboutTransitionSubscriptions(prevTransition, currentTransition); + ReactCurrentBatchConfig.transition = prevTransition; + } } } - /** - * Ensure that every element either is passed in a static location, in an - * array with an explicit keys property defined, or in an object literal - * with valid key property. - * - * @internal - * @param {ReactNode} node Statically passed child of any type. - * @param {*} parentType node's parent's type. - */ - function validateChildKeys(node, parentType) { + function warnAboutTransitionSubscriptions( + prevTransition, + currentTransition + ) { { - if (typeof node !== "object" || !node) { - return; + if (prevTransition === null && currentTransition._updatedFibers) { + var updatedFibersCount = currentTransition._updatedFibers.size; + + currentTransition._updatedFibers.clear(); + + if (updatedFibersCount > 10) { + warn( + "Detected a large number of updates inside startTransition. " + + "If this is due to a subscription please re-write it to use React provided hooks. " + + "Otherwise concurrent mode guarantees are off the table." + ); + } } + } + } + // the default for onRecoverableError. - if (node.$$typeof === REACT_CLIENT_REFERENCE); - else if (isArray(node)) { - for (var i = 0; i < node.length; i++) { - var child = node[i]; + typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, + ? // emulating an uncaught JavaScript error. + reportError + : function (error) { + // In older browsers and test environments, fallback to console.error. + // eslint-disable-next-line react-internal/no-production-logging + console["error"](error); + }; - if (isValidElement(child)) { - validateExplicitKey(child, parentType); - } - } - } else if (isValidElement(node)) { - // This element was passed in a valid location. - if (node._store) { - node._store.validated = true; - } - } else { - var iteratorFn = getIteratorFn(node); + var didWarnAboutMessageChannel = false; + var enqueueTaskImpl = null; + function enqueueTask(task) { + if (enqueueTaskImpl === null) { + try { + // read require off the module object to get around the bundlers. + // we don't want them to detect a require and bundle a Node polyfill. + var requireString = ("require" + Math.random()).slice(0, 7); + var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's + // version of setImmediate, bypassing fake timers if any. - if (typeof iteratorFn === "function") { - // Entry iterators used to provide implicit keys, - // but now we print a separate warning for them later. - if (iteratorFn !== node.entries) { - var iterator = iteratorFn.call(node); - var step; + enqueueTaskImpl = nodeRequire.call(module, "timers").setImmediate; + } catch (_err) { + // we're in a browser + // we can't use regular timers because they may still be faked + // so we try MessageChannel+postMessage instead + enqueueTaskImpl = function (callback) { + { + if (didWarnAboutMessageChannel === false) { + didWarnAboutMessageChannel = true; - while (!(step = iterator.next()).done) { - if (isValidElement(step.value)) { - validateExplicitKey(step.value, parentType); + if (typeof MessageChannel === "undefined") { + error( + "This browser does not have a MessageChannel implementation, " + + "so enqueuing tasks via await act(async () => ...) will fail. " + + "Please file an issue at https://github.com/facebook/react/issues " + + "if you encounter this warning." + ); } } } - } + + var channel = new MessageChannel(); + channel.port1.onmessage = callback; + channel.port2.postMessage(undefined); + }; } } - } - /** - * Verifies the object is a ReactElement. - * See https://reactjs.org/docs/react-api.html#isvalidelement - * @param {?object} object - * @return {boolean} True if `object` is a ReactElement. - * @final - */ - function isValidElement(object) { - { - return ( - typeof object === "object" && - object !== null && - object.$$typeof === REACT_ELEMENT_TYPE - ); - } + return enqueueTaskImpl(task); } - var ownerHasKeyUseWarning = {}; - /** - * Warn if the element doesn't have an explicit key assigned to it. - * This element is in an array. The array could grow and shrink or be - * reordered. All children that haven't already been validated are required to - * have a "key" property assigned to it. Error statuses are cached so a warning - * will only be shown once. - * - * @internal - * @param {ReactElement} element Element that requires a key. - * @param {*} parentType element's parent's type. - */ - function validateExplicitKey(element, parentType) { + // number of `act` scopes on the stack. + + var actScopeDepth = 0; // We only warn the first time you neglect to await an async `act` scope. + + var didWarnNoAwaitAct = false; + function act(callback) { { - if ( - !element._store || - element._store.validated || - element.key != null - ) { - return; - } + // 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. + // + // We set this to an empty array when we first enter an `act` scope, and + // only unset it once we've left the outermost `act` scope — remember that + // `act` calls can be nested. + // + // If we're already inside an `act` scope, reuse the existing queue. + var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy; + var prevActQueue = ReactCurrentActQueue.current; + var prevActScopeDepth = actScopeDepth; + actScopeDepth++; + 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. - element._store.validated = true; - var currentComponentErrorInfo = - getCurrentComponentErrorInfo(parentType); + ReactCurrentActQueue.isBatchingLegacy = true; + var result; // This tracks whether the `act` call is awaited. In certain cases, not + // awaiting it is a mistake, so we will detect that and warn. - if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { - return; - } + var didAwaitActCall = false; - ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a - // property, it may be the creator of the child that's responsible for - // assigning it a key. + try { + // Reset this to `false` right before entering the React work loop. The + // 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. + ReactCurrentActQueue.didScheduleLegacyUpdate = false; + result = callback(); + var didScheduleLegacyUpdate = + ReactCurrentActQueue.didScheduleLegacyUpdate; // 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. - var childOwner = ""; + if (!prevIsBatchingLegacy && didScheduleLegacyUpdate) { + flushActQueue(queue); + } // `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!! + + 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!! + ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy; + popActScope(prevActQueue, prevActScopeDepth); + throw error; + } if ( - element && - element._owner && - element._owner !== ReactCurrentOwner.current + result !== null && + typeof result === "object" && // $FlowFixMe[method-unbinding] + typeof result.then === "function" ) { - // Give the component that originally created this child. - childOwner = - " It was passed a child from " + - getComponentNameFromType(element._owner.type) + - "."; - } + // A promise/thenable was returned from the callback. Wait for it to + // resolve before flushing the queue. + // + // If `act` were implemented as an async function, this whole block could + // be a single `await` call. That's really the only difference between + // this branch and the next one. + var thenable = result; // Warn if the an `act` call with an async scope is not awaited. In a + // future release, consider making this an error. + + queueSeveralMicrotasks(function () { + if (!didAwaitActCall && !didWarnNoAwaitAct) { + didWarnNoAwaitAct = true; + + error( + "You called act(async () => ...) without await. " + + "This could lead to unexpected testing behaviour, " + + "interleaving multiple act calls and mixing their " + + "scopes. " + + "You should - await act(async () => ...);" + ); + } + }); + return { + then: function (resolve, reject) { + didAwaitActCall = true; + thenable.then( + function (returnValue) { + popActScope(prevActQueue, prevActScopeDepth); + + if (prevActScopeDepth === 0) { + // We're exiting the outermost `act` scope. Flush the queue. + try { + flushActQueue(queue); + enqueueTask(function () { + return ( + // Recursively flush tasks scheduled by a microtask. + recursivelyFlushAsyncActWork( + returnValue, + resolve, + reject + ) + ); + }); + } catch (error) { + // `thenable` might not be a real promise, and `flushActQueue` + // might throw, so we need to wrap `flushActQueue` in a + // try/catch. + reject(error); + } + } else { + resolve(returnValue); + } + }, + function (error) { + popActScope(prevActQueue, prevActScopeDepth); + reject(error); + } + ); + } + }; + } else { + var returnValue = result; // The callback is not an async function. Exit the current + // scope immediately. + + popActScope(prevActQueue, prevActScopeDepth); + + if (prevActScopeDepth === 0) { + // We're exiting the outermost `act` scope. Flush the queue. + flushActQueue(queue); // If the queue is not empty, it implies that we intentionally yielded + // to the main thread, because something suspended. We will continue + // in an asynchronous task. + // + // Warn if something suspends but the `act` call is not awaited. + // In a future release, consider making this an error. + + if (queue.length !== 0) { + queueSeveralMicrotasks(function () { + if (!didAwaitActCall && !didWarnNoAwaitAct) { + didWarnNoAwaitAct = true; - setCurrentlyValidatingElement(element); + error( + "A component suspended inside an `act` scope, but the " + + "`act` call was not awaited. When testing React " + + "components that depend on asynchronous data, you must " + + "await the result:\n\n" + + "await act(() => ...)" + ); + } + }); + } // Like many things in this module, this is next part is confusing. + // + // We do not currently require every `act` call that is passed a + // callback to be awaited, through arguably we should. Since this + // callback was synchronous, we need to exit the current scope before + // returning. + // + // However, if thenable we're about to return *is* awaited, we'll + // immediately restore the current scope. So it shouldn't observable. + // + // This doesn't affect the case where the scope callback is async, + // because we always require those calls to be awaited. + // + // TODO: In a future version, consider always requiring all `act` calls + // to be awaited, regardless of whether the callback is sync or async. - error( - 'Each child in a list should have a unique "key" prop.' + - "%s%s See https://reactjs.org/link/warning-keys for more information.", - currentComponentErrorInfo, - childOwner - ); + ReactCurrentActQueue.current = null; + } - setCurrentlyValidatingElement(null); - } - } + return { + then: function (resolve, reject) { + didAwaitActCall = true; - function setCurrentlyValidatingElement(element) { - { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - owner ? owner.type : null - ); - ReactDebugCurrentFrame.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame.setExtraStackFrame(null); + 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. + ReactCurrentActQueue.current = queue; + enqueueTask(function () { + return ( + // Recursively flush tasks scheduled by a microtask. + recursivelyFlushAsyncActWork(returnValue, resolve, reject) + ); + }); + } else { + resolve(returnValue); + } + } + }; } } } - function getCurrentComponentErrorInfo(parentType) { + function popActScope(prevActQueue, prevActScopeDepth) { { - var info = getDeclarationErrorAddendum(); - - if (!info) { - var parentName = getComponentNameFromType(parentType); - - if (parentName) { - info = - "\n\nCheck the top-level render call using <" + parentName + ">."; - } + if (prevActScopeDepth !== actScopeDepth - 1) { + error( + "You seem to have overlapping act() calls, this is not supported. " + + "Be sure to await previous act() calls before making a new one. " + ); } - return info; + actScopeDepth = prevActScopeDepth; } } - /** - * Given a fragment, validate that it can only be provided with fragment props - * @param {ReactElement} fragment - */ - function validateFragmentProps(fragment) { + function recursivelyFlushAsyncActWork(returnValue, resolve, reject) { { - var keys = Object.keys(fragment.props); - - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - - if (key !== "children" && key !== "key") { - setCurrentlyValidatingElement(fragment); + // Check if any tasks were scheduled asynchronously. + var queue = ReactCurrentActQueue.current; - error( - "Invalid prop `%s` supplied to `React.Fragment`. " + - "React.Fragment can only have `key` and `children` props.", - key - ); + if (queue !== null) { + if (queue.length !== 0) { + // Async tasks were scheduled, mostly likely in a microtask. + // Keep flushing until there are no more. + try { + flushActQueue(queue); // The work we just performed may have schedule additional async + // tasks. Wait a macrotask and check again. - setCurrentlyValidatingElement(null); - break; + enqueueTask(function () { + return recursivelyFlushAsyncActWork( + returnValue, + resolve, + reject + ); + }); + } catch (error) { + // Leave remaining tasks on the queue if something throws. + reject(error); + } + } else { + // The queue is empty. We can finish. + ReactCurrentActQueue.current = null; + resolve(returnValue); } - } - - if (fragment.ref !== null) { - setCurrentlyValidatingElement(fragment); - - error("Invalid attribute `ref` supplied to `React.Fragment`."); - - setCurrentlyValidatingElement(null); + } else { + resolve(returnValue); } } } - var propTypesMisspellWarningShown = false; - /** - * Given an element, validate that its props follow the propTypes definition, - * provided by the type. - * - * @param {ReactElement} element - */ + var isFlushing = false; - function validatePropTypes(element) { + function flushActQueue(queue) { { - var type = element.type; - - if (type === null || type === undefined || typeof type === "string") { - return; - } - - if (type.$$typeof === REACT_CLIENT_REFERENCE) { - return; - } - - var propTypes; + if (!isFlushing) { + // Prevent re-entrance. + isFlushing = true; + var i = 0; - if (typeof type === "function") { - propTypes = type.propTypes; - } else if ( - typeof type === "object" && - (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - type.$$typeof === REACT_MEMO_TYPE) - ) { - propTypes = type.propTypes; - } else { - return; - } + try { + for (; i < queue.length; i++) { + var callback = queue[i]; - if (propTypes) { - // Intentionally inside to avoid triggering lazy initializers: - var name = getComponentNameFromType(type); - checkPropTypes(propTypes, element.props, "prop", name, element); - } else if ( - type.PropTypes !== undefined && - !propTypesMisspellWarningShown - ) { - propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: + do { + ReactCurrentActQueue.didUsePromise = false; + var continuation = callback(false); - var _name = getComponentNameFromType(type); + if (continuation !== null) { + 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. + queue[i] = callback; + queue.splice(0, i); + return; + } - error( - "Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", - _name || "Unknown" - ); - } + callback = continuation; + } else { + break; + } + } while (true); + } // We flushed the entire queue. - if ( - typeof type.getDefaultProps === "function" && - !type.getDefaultProps.isReactClassApproved - ) { - error( - "getDefaultProps is only used on classic React.createClass " + - "definitions. Use a static property named `defaultProps` instead." - ); + queue.length = 0; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + queue.splice(0, i + 1); + throw error; + } finally { + isFlushing = false; + } } } - } + } // Some of our warnings attempt to detect if the `act` call is awaited by + // checking in an asynchronous task. Wait a few microtasks before checking. The + // only reason one isn't sufficient is we want to accommodate the case where an + // `act` call is returned from an async function without first being awaited, + // since that's a somewhat common pattern. If you do this too many times in a + // nested sequence, you might get a warning, but you can always fix by awaiting + // the call. + // + // A macrotask would also work (and is the fallback) but depending on the test + // environment it may cause the warning to fire too late. + + var queueSeveralMicrotasks = + typeof queueMicrotask === "function" + ? function (callback) { + queueMicrotask(function () { + return queueMicrotask(callback); + }); + } + : enqueueTask; + + var Children = { + map: mapChildren, + forEach: forEachChildren, + count: countChildren, + toArray: toArray, + only: onlyChild + }; var jsx = jsxProdSignatureRunningInDevWithDynamicChildren; // we may want to special case jsxs internally to take advantage of static children. // for now we can ship identical prod functions @@ -3797,7 +3341,7 @@ if (__DEV__) { exports.createRef = createRef; exports.experimental_useEffectEvent = useEffectEvent; exports.forwardRef = forwardRef; - exports.isValidElement = isValidElement$1; + exports.isValidElement = isValidElement; exports.jsx = jsx; exports.jsxDEV = jsxDEV; exports.jsxs = jsxs; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js index 4277b976aab63..08d573d29d955 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<6f68255f8fde261b2b75964a1fab4e09>> + * @generated SignedSource<<41cda10cf320dab6684351ebb1b6c769>> */ "use strict"; @@ -81,9 +81,18 @@ pureComponentPrototype.constructor = PureComponent; assign(pureComponentPrototype, Component.prototype); pureComponentPrototype.isPureReactComponent = !0; var isArrayImpl = Array.isArray, + ReactCurrentDispatcher = { current: null }, + ReactCurrentCache = { current: null }, + ReactCurrentBatchConfig = { transition: null }, + ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentCache: ReactCurrentCache, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: { current: null } + }, hasOwnProperty = Object.prototype.hasOwnProperty, - ReactCurrentOwner$1 = { current: null }; -function ReactElement$1(type, key, ref, owner, props) { + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; +function ReactElement(type, key, ref, self, source, owner, props) { return { $$typeof: REACT_ELEMENT_TYPE, type: type, @@ -93,7 +102,33 @@ function ReactElement$1(type, key, ref, owner, props) { _owner: owner }; } -function createElement$1(type, config, children) { +function jsxProd(type, config, maybeKey) { + var propName, + props = {}, + key = null, + ref = null; + void 0 !== maybeKey && (key = "" + maybeKey); + void 0 !== config.key && (key = "" + config.key); + void 0 !== config.ref && (ref = config.ref); + for (propName in config) + hasOwnProperty.call(config, propName) && + "key" !== propName && + "ref" !== propName && + (props[propName] = config[propName]); + if (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, + ReactCurrentOwner.current, + props + ); +} +function createElement(type, config, children) { var propName, props = {}, key = null, @@ -119,13 +154,23 @@ function createElement$1(type, config, children) { for (propName in ((childrenLength = type.defaultProps), childrenLength)) void 0 === props[propName] && (props[propName] = childrenLength[propName]); - return ReactElement$1(type, key, ref, ReactCurrentOwner$1.current, props); + return ReactElement( + type, + key, + ref, + void 0, + void 0, + ReactCurrentOwner.current, + props + ); } function cloneAndReplaceKey(oldElement, newKey) { - return ReactElement$1( + return ReactElement( oldElement.type, newKey, oldElement.ref, + void 0, + void 0, oldElement._owner, oldElement.props ); @@ -137,15 +182,6 @@ function isValidElement(object) { object.$$typeof === REACT_ELEMENT_TYPE ); } -var ReactCurrentDispatcher = { current: null }, - ReactCurrentCache = { current: null }, - ReactCurrentBatchConfig = { transition: null }, - ReactSharedInternals = { - ReactCurrentDispatcher: ReactCurrentDispatcher, - ReactCurrentCache: ReactCurrentCache, - ReactCurrentBatchConfig: ReactCurrentBatchConfig, - ReactCurrentOwner: ReactCurrentOwner$1 - }; function escape(key) { var escaperLookup = { "=": "=0", ":": "=2" }; return ( @@ -334,32 +370,6 @@ function lazyInitializer(payload) { : function (error) { console.error(error); }; -var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; -function jsxProd(type, config, maybeKey) { - var propName, - props = {}, - key = null, - ref = null; - void 0 !== maybeKey && (key = "" + maybeKey); - void 0 !== config.key && (key = "" + config.key); - void 0 !== config.ref && (ref = config.ref); - for (propName in config) - hasOwnProperty.call(config, propName) && - "key" !== propName && - "ref" !== propName && - (props[propName] = config[propName]); - if (type && type.defaultProps) - for (propName in ((config = type.defaultProps), config)) - void 0 === props[propName] && (props[propName] = config[propName]); - return { - $$typeof: REACT_ELEMENT_TYPE, - type: type, - key: key, - ref: ref, - props: props, - _owner: ReactCurrentOwner.current - }; -} exports.Children = { map: mapChildren, forEach: function (children, forEachFunc, forEachContext) { @@ -422,7 +432,7 @@ exports.cloneElement = function (element, config, children) { owner = element._owner; if (null != config) { void 0 !== config.ref && - ((ref = config.ref), (owner = ReactCurrentOwner$1.current)); + ((ref = config.ref), (owner = ReactCurrentOwner.current)); void 0 !== config.key && (key = "" + config.key); if (element.type && element.type.defaultProps) var defaultProps = element.type.defaultProps; @@ -444,7 +454,7 @@ exports.cloneElement = function (element, config, children) { for (var i = 0; i < propName; i++) defaultProps[i] = arguments[i + 2]; props.children = defaultProps; } - return ReactElement$1(element.type, key, ref, owner, props); + return ReactElement(element.type, key, ref, void 0, void 0, owner, props); }; exports.createContext = function (defaultValue) { defaultValue = { @@ -461,9 +471,9 @@ exports.createContext = function (defaultValue) { }; return (defaultValue.Consumer = defaultValue); }; -exports.createElement = createElement$1; +exports.createElement = createElement; exports.createFactory = function (type) { - var factory = createElement$1.bind(null, type); + var factory = createElement.bind(null, type); factory.type = type; return factory; }; @@ -590,4 +600,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-canary-ec160f32c-20240219"; +exports.version = "18.3.0-canary-5fb2c93f3-20240219"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js index caeef0a7d78e3..211b52b242914 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<2014363963cd257db2e2ba2e30cd8535>> */ "use strict"; @@ -84,9 +84,18 @@ pureComponentPrototype.constructor = PureComponent; assign(pureComponentPrototype, Component.prototype); pureComponentPrototype.isPureReactComponent = !0; var isArrayImpl = Array.isArray, + ReactCurrentDispatcher = { current: null }, + ReactCurrentCache = { current: null }, + ReactCurrentBatchConfig = { transition: null }, + ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentCache: ReactCurrentCache, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: { current: null } + }, hasOwnProperty = Object.prototype.hasOwnProperty, - ReactCurrentOwner$1 = { current: null }; -function ReactElement$1(type, key, ref, owner, props) { + ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; +function ReactElement(type, key, ref, self, source, owner, props) { return { $$typeof: REACT_ELEMENT_TYPE, type: type, @@ -96,11 +105,39 @@ function ReactElement$1(type, key, ref, owner, props) { _owner: owner }; } +function jsxProd(type, config, maybeKey) { + var propName, + props = {}, + key = null, + ref = null; + void 0 !== maybeKey && (key = "" + maybeKey); + void 0 !== config.key && (key = "" + config.key); + void 0 !== config.ref && (ref = config.ref); + for (propName in config) + hasOwnProperty.call(config, propName) && + "key" !== propName && + "ref" !== propName && + (props[propName] = config[propName]); + if (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, + ReactCurrentOwner.current, + props + ); +} function cloneAndReplaceKey(oldElement, newKey) { - return ReactElement$1( + return ReactElement( oldElement.type, newKey, oldElement.ref, + void 0, + void 0, oldElement._owner, oldElement.props ); @@ -112,15 +149,6 @@ function isValidElement(object) { object.$$typeof === REACT_ELEMENT_TYPE ); } -var ReactCurrentDispatcher = { current: null }, - ReactCurrentCache = { current: null }, - ReactCurrentBatchConfig = { transition: null }, - ReactSharedInternals = { - ReactCurrentDispatcher: ReactCurrentDispatcher, - ReactCurrentCache: ReactCurrentCache, - ReactCurrentBatchConfig: ReactCurrentBatchConfig, - ReactCurrentOwner: ReactCurrentOwner$1 - }; function escape(key) { var escaperLookup = { "=": "=0", ":": "=2" }; return ( @@ -309,32 +337,6 @@ function lazyInitializer(payload) { : function (error) { console.error(error); }; -var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; -function jsxProd(type, config, maybeKey) { - var propName, - props = {}, - key = null, - ref = null; - void 0 !== maybeKey && (key = "" + maybeKey); - void 0 !== config.key && (key = "" + config.key); - void 0 !== config.ref && (ref = config.ref); - for (propName in config) - hasOwnProperty.call(config, propName) && - "key" !== propName && - "ref" !== propName && - (props[propName] = config[propName]); - if (type && type.defaultProps) - for (propName in ((config = type.defaultProps), config)) - void 0 === props[propName] && (props[propName] = config[propName]); - return { - $$typeof: REACT_ELEMENT_TYPE, - type: type, - key: key, - ref: ref, - props: props, - _owner: ReactCurrentOwner.current - }; -} exports.Children = { map: mapChildren, forEach: function (children, forEachFunc, forEachContext) { @@ -397,7 +399,7 @@ exports.cloneElement = function (element, config, children) { owner = element._owner; if (null != config) { void 0 !== config.ref && - ((ref = config.ref), (owner = ReactCurrentOwner$1.current)); + ((ref = config.ref), (owner = ReactCurrentOwner.current)); void 0 !== config.key && (key = "" + config.key); if (element.type && element.type.defaultProps) var defaultProps = element.type.defaultProps; @@ -419,7 +421,7 @@ exports.cloneElement = function (element, config, children) { for (var i = 0; i < propName; i++) defaultProps[i] = arguments[i + 2]; props.children = defaultProps; } - return ReactElement$1(element.type, key, ref, owner, props); + return ReactElement(element.type, key, ref, void 0, void 0, owner, props); }; exports.createContext = function (defaultValue) { defaultValue = { @@ -462,7 +464,15 @@ exports.createElement = function (type, config, children) { for (propName in ((childrenLength = type.defaultProps), childrenLength)) void 0 === props[propName] && (props[propName] = childrenLength[propName]); - return ReactElement$1(type, key, ref, ReactCurrentOwner$1.current, props); + return ReactElement( + type, + key, + ref, + void 0, + void 0, + ReactCurrentOwner.current, + props + ); }; exports.createRef = function () { return { current: null }; @@ -586,7 +596,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-canary-ec160f32c-20240219"; +exports.version = "18.3.0-canary-5fb2c93f3-20240219"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index f8e02852335af..f25b87b6efbd5 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -ec160f32c28ccab798c73ecccbb36ce121e1640e +5fb2c93f3924ba980444da5698f60651b5ef0689