From 96bfe1e7b93974c3d16c1f17ef1c5a9647efbe6b Mon Sep 17 00:00:00 2001 From: yungsters Date: Sat, 9 Mar 2024 00:19:11 +0000 Subject: [PATCH] Configure Dynamic Feature Flags for React Native (#28527) ## Summary This PR is a subset of https://github.com/facebook/react/pull/28425, which only includes the feature flags that will be configured as dynamic. The following list summarizes the feature flag changes: * RN FB * Change to Dynamic * consoleManagedByDevToolsDuringStrictMode * enableAsyncActions * enableDeferRootSchedulingToMicrotask * enableRenderableContext * useModernStrictMode ## How did you test this change? Ran the following successfully: ``` $ yarn test $ yarn flow native $ yarn flow fabric ``` DiffTrain build for commit https://github.com/facebook/react/commit/706d95f486fbdec35b771ea4aaf3e78feb907249. --- .../vendor/react-is/cjs/ReactIs-dev.js | 39 +- .../vendor/react-is/cjs/ReactIs-prod.js | 29 +- .../vendor/react-is/cjs/ReactIs-profiling.js | 29 +- .../cjs/ReactTestRenderer-dev.js | 2 +- .../cjs/ReactTestRenderer-prod.js | 4 +- .../cjs/ReactTestRenderer-profiling.js | 4 +- .../vendor/react/cjs/JSXDEVRuntime-dev.js | 35 +- .../vendor/react/cjs/JSXRuntime-dev.js | 35 +- .../RKJSModules/vendor/react/cjs/React-dev.js | 93 +- .../vendor/react/cjs/React-prod.js | 74 +- .../vendor/react/cjs/React-profiling.js | 74 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 1163 ++++++++++++++++- .../implementations/ReactFabric-prod.fb.js | 801 +++++++++--- .../ReactFabric-profiling.fb.js | 845 +++++++++--- .../ReactNativeRenderer-dev.fb.js | 1163 ++++++++++++++++- .../ReactNativeRenderer-prod.fb.js | 880 ++++++++++--- .../ReactNativeRenderer-profiling.fb.js | 945 ++++++++++---- 18 files changed, 5215 insertions(+), 1002 deletions(-) diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-dev.js index defe3c9c5c1cf..3b796344726cd 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<50de4881bc1e7323607d21cae81406f7>> + * @generated SignedSource<<6d931d2de9a1892cd33381697c43409f>> */ "use strict"; @@ -16,6 +16,8 @@ if (__DEV__) { (function () { "use strict"; + var dynamicFlags = require("ReactNativeInternalFeatureFlags"); + // ATTENTION // When adding new symbols to this file, // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' @@ -38,9 +40,12 @@ if (__DEV__) { var REACT_CACHE_TYPE = Symbol.for("react.cache"); // NOTE: There are no flags, currently. Uncomment the stuff below if we add one. + // the exports object every time a flag is read. + + var enableRenderableContext = dynamicFlags.enableRenderableContext; + // The rest of the flags are static for better dead code elimination. var enableDebugTracing = false; var enableScopeAPI = false; - var enableRenderableContext = false; var enableLegacyHidden = false; var enableTransitionTracing = false; @@ -71,8 +76,8 @@ if (__DEV__) { type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || - type.$$typeof === REACT_PROVIDER_TYPE || - enableRenderableContext || + (!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) || + (enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) || 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 @@ -114,12 +119,16 @@ if (__DEV__) { return $$typeofType; case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + return $$typeofType; + } // Fall through - case REACT_PROVIDER_TYPE: { - return $$typeofType; - } + case REACT_PROVIDER_TYPE: + if (!enableRenderableContext) { + return $$typeofType; + } // Fall through @@ -135,8 +144,12 @@ if (__DEV__) { return undefined; } - var ContextConsumer = REACT_CONTEXT_TYPE; - var ContextProvider = REACT_PROVIDER_TYPE; + var ContextConsumer = enableRenderableContext + ? REACT_CONSUMER_TYPE + : REACT_CONTEXT_TYPE; + var ContextProvider = enableRenderableContext + ? REACT_CONTEXT_TYPE + : REACT_PROVIDER_TYPE; var Element = REACT_ELEMENT_TYPE; var ForwardRef = REACT_FORWARD_REF_TYPE; var Fragment = REACT_FRAGMENT_TYPE; @@ -148,12 +161,16 @@ if (__DEV__) { var Suspense = REACT_SUSPENSE_TYPE; var SuspenseList = REACT_SUSPENSE_LIST_TYPE; function isContextConsumer(object) { - { + if (enableRenderableContext) { + return typeOf(object) === REACT_CONSUMER_TYPE; + } else { return typeOf(object) === REACT_CONTEXT_TYPE; } } function isContextProvider(object) { - { + if (enableRenderableContext) { + return typeOf(object) === REACT_CONTEXT_TYPE; + } else { return typeOf(object) === REACT_PROVIDER_TYPE; } } diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-prod.js index 0da3d712bd4a3..74b401627d599 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-prod.js @@ -7,11 +7,12 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; -var REACT_ELEMENT_TYPE = Symbol.for("react.element"), +var dynamicFlags = require("ReactNativeInternalFeatureFlags"), + REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), @@ -26,6 +27,7 @@ var REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"), REACT_CACHE_TYPE = Symbol.for("react.cache"), + enableRenderableContext = dynamicFlags.enableRenderableContext, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); function typeOf(object) { if ("object" === typeof object && null !== object) { @@ -47,8 +49,9 @@ function typeOf(object) { case REACT_MEMO_TYPE: return object; case REACT_CONSUMER_TYPE: + if (enableRenderableContext) return object; case REACT_PROVIDER_TYPE: - return object; + if (!enableRenderableContext) return object; default: return $$typeof; } @@ -58,8 +61,13 @@ function typeOf(object) { } } } -exports.ContextConsumer = REACT_CONTEXT_TYPE; -exports.ContextProvider = REACT_PROVIDER_TYPE; +var ContextProvider = enableRenderableContext + ? REACT_CONTEXT_TYPE + : REACT_PROVIDER_TYPE; +exports.ContextConsumer = enableRenderableContext + ? REACT_CONSUMER_TYPE + : REACT_CONTEXT_TYPE; +exports.ContextProvider = ContextProvider; exports.Element = REACT_ELEMENT_TYPE; exports.ForwardRef = REACT_FORWARD_REF_TYPE; exports.Fragment = REACT_FRAGMENT_TYPE; @@ -71,10 +79,14 @@ exports.StrictMode = REACT_STRICT_MODE_TYPE; exports.Suspense = REACT_SUSPENSE_TYPE; exports.SuspenseList = REACT_SUSPENSE_LIST_TYPE; exports.isContextConsumer = function (object) { - return typeOf(object) === REACT_CONTEXT_TYPE; + return enableRenderableContext + ? typeOf(object) === REACT_CONSUMER_TYPE + : typeOf(object) === REACT_CONTEXT_TYPE; }; exports.isContextProvider = function (object) { - return typeOf(object) === REACT_PROVIDER_TYPE; + return enableRenderableContext + ? typeOf(object) === REACT_CONTEXT_TYPE + : typeOf(object) === REACT_PROVIDER_TYPE; }; exports.isElement = function (object) { return ( @@ -125,7 +137,8 @@ exports.isValidElementType = function (type) { (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || - type.$$typeof === REACT_PROVIDER_TYPE || + (!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) || + (enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || void 0 !== type.getModuleId)) diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-profiling.js index 0da3d712bd4a3..74b401627d599 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-is/cjs/ReactIs-profiling.js @@ -7,11 +7,12 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; -var REACT_ELEMENT_TYPE = Symbol.for("react.element"), +var dynamicFlags = require("ReactNativeInternalFeatureFlags"), + REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), @@ -26,6 +27,7 @@ var REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"), REACT_CACHE_TYPE = Symbol.for("react.cache"), + enableRenderableContext = dynamicFlags.enableRenderableContext, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); function typeOf(object) { if ("object" === typeof object && null !== object) { @@ -47,8 +49,9 @@ function typeOf(object) { case REACT_MEMO_TYPE: return object; case REACT_CONSUMER_TYPE: + if (enableRenderableContext) return object; case REACT_PROVIDER_TYPE: - return object; + if (!enableRenderableContext) return object; default: return $$typeof; } @@ -58,8 +61,13 @@ function typeOf(object) { } } } -exports.ContextConsumer = REACT_CONTEXT_TYPE; -exports.ContextProvider = REACT_PROVIDER_TYPE; +var ContextProvider = enableRenderableContext + ? REACT_CONTEXT_TYPE + : REACT_PROVIDER_TYPE; +exports.ContextConsumer = enableRenderableContext + ? REACT_CONSUMER_TYPE + : REACT_CONTEXT_TYPE; +exports.ContextProvider = ContextProvider; exports.Element = REACT_ELEMENT_TYPE; exports.ForwardRef = REACT_FORWARD_REF_TYPE; exports.Fragment = REACT_FRAGMENT_TYPE; @@ -71,10 +79,14 @@ exports.StrictMode = REACT_STRICT_MODE_TYPE; exports.Suspense = REACT_SUSPENSE_TYPE; exports.SuspenseList = REACT_SUSPENSE_LIST_TYPE; exports.isContextConsumer = function (object) { - return typeOf(object) === REACT_CONTEXT_TYPE; + return enableRenderableContext + ? typeOf(object) === REACT_CONSUMER_TYPE + : typeOf(object) === REACT_CONTEXT_TYPE; }; exports.isContextProvider = function (object) { - return typeOf(object) === REACT_PROVIDER_TYPE; + return enableRenderableContext + ? typeOf(object) === REACT_CONTEXT_TYPE + : typeOf(object) === REACT_PROVIDER_TYPE; }; exports.isElement = function (object) { return ( @@ -125,7 +137,8 @@ exports.isValidElementType = function (type) { (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || - type.$$typeof === REACT_PROVIDER_TYPE || + (!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) || + (enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || void 0 !== type.getModuleId)) 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 3bd4838948c6c..1cd5aba1cf9a6 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 @@ -25677,7 +25677,7 @@ if (__DEV__) { return root; } - var ReactVersion = "18.3.0-canary-71c4699de-20240308"; + var ReactVersion = "18.3.0-canary-706d95f48-20240308"; // 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 6332da89f55fb..2efb95ea996d7 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 @@ -9147,7 +9147,7 @@ var devToolsConfig$jscomp$inline_1016 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-canary-71c4699de-20240308", + version: "18.3.0-canary-706d95f48-20240308", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1194 = { @@ -9178,7 +9178,7 @@ var internals$jscomp$inline_1194 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-71c4699de-20240308" + reconcilerVersion: "18.3.0-canary-706d95f48-20240308" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1195 = __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 676065d1e2e4c..b528ce4067eb3 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 @@ -9575,7 +9575,7 @@ var devToolsConfig$jscomp$inline_1058 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-canary-71c4699de-20240308", + version: "18.3.0-canary-706d95f48-20240308", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1235 = { @@ -9606,7 +9606,7 @@ var internals$jscomp$inline_1235 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-71c4699de-20240308" + reconcilerVersion: "18.3.0-canary-706d95f48-20240308" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1236 = __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 dc2263ec7ddc0..7def44be9cc5b 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<<0d68343aed9ab27512ef97b5ce8c038e>> + * @generated SignedSource<> */ "use strict"; @@ -107,11 +107,11 @@ if (__DEV__) { // the exports object every time a flag is read. var enableComponentStackLocations = - dynamicFlags.enableComponentStackLocations; + dynamicFlags.enableComponentStackLocations, + enableRenderableContext = dynamicFlags.enableRenderableContext; // The rest of the flags are static for better dead code elimination. var enableDebugTracing = false; var enableScopeAPI = false; - var enableRenderableContext = false; var enableLegacyHidden = false; var enableTransitionTracing = false; @@ -188,21 +188,30 @@ if (__DEV__) { } switch (type.$$typeof) { - case REACT_PROVIDER_TYPE: { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } + case REACT_PROVIDER_TYPE: + if (enableRenderableContext) { + return null; + } else { + var provider = type; + return getContextName(provider._context) + ".Provider"; + } case REACT_CONTEXT_TYPE: var context = type; - { + if (enableRenderableContext) { + return getContextName(context) + ".Provider"; + } else { return getContextName(context) + ".Consumer"; } - case REACT_CONSUMER_TYPE: { - return null; - } + case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + var consumer = type; + return getContextName(consumer._context) + ".Consumer"; + } else { + return null; + } case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); @@ -339,8 +348,8 @@ if (__DEV__) { type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || - type.$$typeof === REACT_PROVIDER_TYPE || - enableRenderableContext || + (!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) || + (enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) || 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 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 b36b59a569535..40281325461da 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<<0348b5be4bc4b549012f6abcecdebeb0>> + * @generated SignedSource<<9adef053c6c5541fdc8c531c06ac6d64>> */ "use strict"; @@ -107,11 +107,11 @@ if (__DEV__) { // the exports object every time a flag is read. var enableComponentStackLocations = - dynamicFlags.enableComponentStackLocations; + dynamicFlags.enableComponentStackLocations, + enableRenderableContext = dynamicFlags.enableRenderableContext; // The rest of the flags are static for better dead code elimination. var enableDebugTracing = false; var enableScopeAPI = false; - var enableRenderableContext = false; var enableLegacyHidden = false; var enableTransitionTracing = false; @@ -188,21 +188,30 @@ if (__DEV__) { } switch (type.$$typeof) { - case REACT_PROVIDER_TYPE: { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } + case REACT_PROVIDER_TYPE: + if (enableRenderableContext) { + return null; + } else { + var provider = type; + return getContextName(provider._context) + ".Provider"; + } case REACT_CONTEXT_TYPE: var context = type; - { + if (enableRenderableContext) { + return getContextName(context) + ".Provider"; + } else { return getContextName(context) + ".Consumer"; } - case REACT_CONSUMER_TYPE: { - return null; - } + case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + var consumer = type; + return getContextName(consumer._context) + ".Consumer"; + } else { + return null; + } case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); @@ -339,8 +348,8 @@ if (__DEV__) { type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || - type.$$typeof === REACT_PROVIDER_TYPE || - enableRenderableContext || + (!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) || + (enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) || 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 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 0ebc8c8823b47..3aa965b588d50 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<<1c514e22a878fca97d39b6e7b2cc1c0d>> + * @generated SignedSource<<7d6e6eb20c84cbe47eca19d4810dcb60>> */ "use strict"; @@ -26,7 +26,7 @@ if (__DEV__) { } var dynamicFlags = require("ReactNativeInternalFeatureFlags"); - var ReactVersion = "18.3.0-canary-71c4699de-20240308"; + var ReactVersion = "18.3.0-canary-706d95f48-20240308"; // ATTENTION // When adding new symbols to this file, @@ -493,12 +493,13 @@ if (__DEV__) { // NOTE: There are no flags, currently. Uncomment the stuff below if we add one. // the exports object every time a flag is read. - var enableComponentStackLocations = - dynamicFlags.enableComponentStackLocations; + var enableAsyncActions = dynamicFlags.enableAsyncActions, + enableComponentStackLocations = + dynamicFlags.enableComponentStackLocations, + enableRenderableContext = dynamicFlags.enableRenderableContext; // The rest of the flags are static for better dead code elimination. var enableDebugTracing = false; var enableScopeAPI = false; - var enableRenderableContext = false; var enableLegacyHidden = false; var enableTransitionTracing = false; // because JSX is an extremely hot path. @@ -652,21 +653,30 @@ if (__DEV__) { } switch (type.$$typeof) { - case REACT_PROVIDER_TYPE: { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } + case REACT_PROVIDER_TYPE: + if (enableRenderableContext) { + return null; + } else { + var provider = type; + return getContextName(provider._context) + ".Provider"; + } case REACT_CONTEXT_TYPE: var context = type; - { + if (enableRenderableContext) { + return getContextName(context) + ".Provider"; + } else { return getContextName(context) + ".Consumer"; } - case REACT_CONSUMER_TYPE: { - return null; - } + case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + var consumer = type; + return getContextName(consumer._context) + ".Consumer"; + } else { + return null; + } case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); @@ -727,8 +737,8 @@ if (__DEV__) { type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || - type.$$typeof === REACT_PROVIDER_TYPE || - enableRenderableContext || + (!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) || + (enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) || 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 @@ -2238,7 +2248,7 @@ if (__DEV__) { return index.toString(36); } - function noop() {} + function noop$1() {} function resolveThenable(thenable) { switch (thenable.status) { @@ -2259,7 +2269,7 @@ if (__DEV__) { // some custom userspace implementation. We treat it as "pending". // Attach a dummy listener, to ensure that any lazy initialization can // happen. Flight lazily parses JSON when the value is actually awaited. - thenable.then(noop, noop); + thenable.then(noop$1, noop$1); } else { // This is an uncached thenable that we haven't seen before. // TODO: Detect infinite ping loops caused by uncached promises. @@ -2604,7 +2614,13 @@ if (__DEV__) { Consumer: null }; - { + if (enableRenderableContext) { + context.Provider = context; + context.Consumer = { + $$typeof: REACT_CONSUMER_TYPE, + _context: context + }; + } else { context.Provider = { $$typeof: REACT_PROVIDER_TYPE, _context: context @@ -3120,7 +3136,27 @@ if (__DEV__) { ReactCurrentBatchConfig.transition._updatedFibers = new Set(); } - { + if (enableAsyncActions) { + try { + var returnValue = scope(); + + if ( + typeof returnValue === "object" && + returnValue !== null && + typeof returnValue.then === "function" + ) { + callbacks.forEach(function (callback) { + return callback(currentTransition, returnValue); + }); + returnValue.then(noop, onError); + } + } catch (error) { + onError(error); + } finally { + warnAboutTransitionSubscriptions(prevTransition, currentTransition); + ReactCurrentBatchConfig.transition = prevTransition; + } + } else { // When async actions are not enabled, startTransition does not // capture errors. try { @@ -3152,16 +3188,19 @@ if (__DEV__) { } } } + + function noop() {} // Use reportError, if it exists. Otherwise console.error. This is the same as // 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 onError = + 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; 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 50b4fa30db4e3..249d7383b2fde 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,16 +7,18 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<0993517f18dba2ba924e7d54b3b13100>> + * @generated SignedSource<<0ad08d0ae422694c93c891090ccf41af>> */ "use strict"; -var REACT_ELEMENT_TYPE = Symbol.for("react.element"), +var dynamicFlags = require("ReactNativeInternalFeatureFlags"), + REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_PROVIDER_TYPE = Symbol.for("react.provider"), + REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), @@ -81,6 +83,8 @@ pureComponentPrototype.constructor = PureComponent; assign(pureComponentPrototype, Component.prototype); pureComponentPrototype.isPureReactComponent = !0; var isArrayImpl = Array.isArray, + enableAsyncActions = dynamicFlags.enableAsyncActions, + enableRenderableContext = dynamicFlags.enableRenderableContext, ReactCurrentDispatcher = { current: null }, ReactCurrentCache = { current: null }, ReactCurrentBatchConfig = { transition: null }, @@ -197,7 +201,7 @@ function getElementKey(element, index) { ? escape("" + element.key) : index.toString(36); } -function noop() {} +function noop$1() {} function resolveThenable(thenable) { switch (thenable.status) { case "fulfilled": @@ -207,7 +211,7 @@ function resolveThenable(thenable) { default: switch ( ("string" === typeof thenable.status - ? thenable.then(noop, noop) + ? thenable.then(noop$1, noop$1) : ((thenable.status = "pending"), thenable.then( function (fulfilledValue) { @@ -365,11 +369,13 @@ function lazyInitializer(payload) { if (1 === payload._status) return payload._result.default; throw payload._result; } -"function" === typeof reportError - ? reportError - : function (error) { - console.error(error); - }; +function noop() {} +var onError = + "function" === typeof reportError + ? reportError + : function (error) { + console.error(error); + }; exports.Children = { map: mapChildren, forEach: function (children, forEachFunc, forEachContext) { @@ -463,11 +469,18 @@ exports.createContext = function (defaultValue) { Provider: null, Consumer: null }; - defaultValue.Provider = { - $$typeof: REACT_PROVIDER_TYPE, - _context: defaultValue - }; - return (defaultValue.Consumer = defaultValue); + enableRenderableContext + ? ((defaultValue.Provider = defaultValue), + (defaultValue.Consumer = { + $$typeof: REACT_CONSUMER_TYPE, + _context: defaultValue + })) + : ((defaultValue.Provider = { + $$typeof: REACT_PROVIDER_TYPE, + _context: defaultValue + }), + (defaultValue.Consumer = defaultValue)); + return defaultValue; }; exports.createElement = createElement; exports.createFactory = function (type) { @@ -504,13 +517,30 @@ exports.memo = function (type, compare) { }; exports.startTransition = function (scope) { var prevTransition = ReactCurrentBatchConfig.transition, - transition = { _callbacks: new Set() }; - ReactCurrentBatchConfig.transition = transition; - try { - scope(); - } finally { - ReactCurrentBatchConfig.transition = prevTransition; - } + callbacks = new Set(); + ReactCurrentBatchConfig.transition = { _callbacks: callbacks }; + var currentTransition = ReactCurrentBatchConfig.transition; + if (enableAsyncActions) + try { + var returnValue = scope(); + "object" === typeof returnValue && + null !== returnValue && + "function" === typeof returnValue.then && + (callbacks.forEach(function (callback) { + return callback(currentTransition, returnValue); + }), + returnValue.then(noop, onError)); + } catch (error) { + onError(error); + } finally { + ReactCurrentBatchConfig.transition = prevTransition; + } + else + try { + scope(); + } finally { + ReactCurrentBatchConfig.transition = prevTransition; + } }; exports.unstable_Activity = REACT_OFFSCREEN_TYPE; exports.unstable_Cache = REACT_CACHE_TYPE; @@ -598,4 +628,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-canary-71c4699de-20240308"; +exports.version = "18.3.0-canary-706d95f48-20240308"; 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 10b162c271f1e..d637302303303 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<<0c357b236599560d718ddaa394fc28e0>> + * @generated SignedSource<<9d38179074b2fce93bbd3958437928a4>> */ "use strict"; @@ -15,12 +15,14 @@ "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()); -var REACT_ELEMENT_TYPE = Symbol.for("react.element"), +var dynamicFlags = require("ReactNativeInternalFeatureFlags"), + REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_PROVIDER_TYPE = Symbol.for("react.provider"), + REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), @@ -84,6 +86,8 @@ pureComponentPrototype.constructor = PureComponent; assign(pureComponentPrototype, Component.prototype); pureComponentPrototype.isPureReactComponent = !0; var isArrayImpl = Array.isArray, + enableAsyncActions = dynamicFlags.enableAsyncActions, + enableRenderableContext = dynamicFlags.enableRenderableContext, ReactCurrentDispatcher = { current: null }, ReactCurrentCache = { current: null }, ReactCurrentBatchConfig = { transition: null }, @@ -164,7 +168,7 @@ function getElementKey(element, index) { ? escape("" + element.key) : index.toString(36); } -function noop() {} +function noop$1() {} function resolveThenable(thenable) { switch (thenable.status) { case "fulfilled": @@ -174,7 +178,7 @@ function resolveThenable(thenable) { default: switch ( ("string" === typeof thenable.status - ? thenable.then(noop, noop) + ? thenable.then(noop$1, noop$1) : ((thenable.status = "pending"), thenable.then( function (fulfilledValue) { @@ -332,11 +336,13 @@ function lazyInitializer(payload) { if (1 === payload._status) return payload._result.default; throw payload._result; } -"function" === typeof reportError - ? reportError - : function (error) { - console.error(error); - }; +function noop() {} +var onError = + "function" === typeof reportError + ? reportError + : function (error) { + console.error(error); + }; exports.Children = { map: mapChildren, forEach: function (children, forEachFunc, forEachContext) { @@ -430,11 +436,18 @@ exports.createContext = function (defaultValue) { Provider: null, Consumer: null }; - defaultValue.Provider = { - $$typeof: REACT_PROVIDER_TYPE, - _context: defaultValue - }; - return (defaultValue.Consumer = defaultValue); + enableRenderableContext + ? ((defaultValue.Provider = defaultValue), + (defaultValue.Consumer = { + $$typeof: REACT_CONSUMER_TYPE, + _context: defaultValue + })) + : ((defaultValue.Provider = { + $$typeof: REACT_PROVIDER_TYPE, + _context: defaultValue + }), + (defaultValue.Consumer = defaultValue)); + return defaultValue; }; exports.createElement = function (type, config, children) { var propName, @@ -501,13 +514,30 @@ exports.memo = function (type, compare) { }; exports.startTransition = function (scope) { var prevTransition = ReactCurrentBatchConfig.transition, - transition = { _callbacks: new Set() }; - ReactCurrentBatchConfig.transition = transition; - try { - scope(); - } finally { - ReactCurrentBatchConfig.transition = prevTransition; - } + callbacks = new Set(); + ReactCurrentBatchConfig.transition = { _callbacks: callbacks }; + var currentTransition = ReactCurrentBatchConfig.transition; + if (enableAsyncActions) + try { + var returnValue = scope(); + "object" === typeof returnValue && + null !== returnValue && + "function" === typeof returnValue.then && + (callbacks.forEach(function (callback) { + return callback(currentTransition, returnValue); + }), + returnValue.then(noop, onError)); + } catch (error) { + onError(error); + } finally { + ReactCurrentBatchConfig.transition = prevTransition; + } + else + try { + scope(); + } finally { + ReactCurrentBatchConfig.transition = prevTransition; + } }; exports.unstable_Activity = REACT_OFFSCREEN_TYPE; exports.unstable_Cache = REACT_CACHE_TYPE; @@ -594,7 +624,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-canary-71c4699de-20240308"; +exports.version = "18.3.0-canary-706d95f48-20240308"; "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 6dff1c48fc601..7b289e965ce07 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 @@ -71c4699de36579097098b690b668abf5a0cf9fb6 +706d95f486fbdec35b771ea4aaf3e78feb907249 diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 1c7f3d3cb3c31..0f6d0e4674a1d 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<9c2330dcbae0932d46415008abf39f83>> */ "use strict"; @@ -33,6 +33,12 @@ if (__DEV__) { var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + var suppressWarning = false; + function setSuppressWarning(newSuppressWarning) { + { + suppressWarning = newSuppressWarning; + } + } // In DEV, calls to console.warn and console.error get replaced // by calls to these methods by a Babel plugin. // // In PROD (or in packages without access to React internals), @@ -40,7 +46,7 @@ if (__DEV__) { function warn(format) { { - { + if (!suppressWarning) { for ( var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), @@ -57,7 +63,7 @@ if (__DEV__) { } function error(format) { { - { + if (!suppressWarning) { for ( var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), @@ -3229,18 +3235,23 @@ to return true:wantsResponderID| | // the exports object every time a flag is read. var alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, + consoleManagedByDevToolsDuringStrictMode = + dynamicFlags.consoleManagedByDevToolsDuringStrictMode, + enableAsyncActions = dynamicFlags.enableAsyncActions, enableComponentStackLocations = dynamicFlags.enableComponentStackLocations, enableDeferRootSchedulingToMicrotask = dynamicFlags.enableDeferRootSchedulingToMicrotask, + enableInfiniteRenderLoopDetection = + dynamicFlags.enableInfiniteRenderLoopDetection, + enableRenderableContext = dynamicFlags.enableRenderableContext, + enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, passChildrenWhenCloningPersistedNodes = dynamicFlags.passChildrenWhenCloningPersistedNodes, useMicrotasksForSchedulingInFabric = dynamicFlags.useMicrotasksForSchedulingInFabric, - enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, - enableInfiniteRenderLoopDetection = - dynamicFlags.enableInfiniteRenderLoopDetection; // The rest of the flags are static for better dead code elimination. + useModernStrictMode = dynamicFlags.useModernStrictMode; // The rest of the flags are static for better dead code elimination. var enableSchedulingProfiler = true; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; @@ -3249,7 +3260,6 @@ to return true:wantsResponderID| | var transitionLaneExpirationMs = 5000; var enableLazyContextPropagation = false; var enableLegacyHidden = false; - var enableAsyncActions = false; var enableBigIntSupport = false; // Flow magic to verify the exports of this file match the original version. var NoFlags$1 = @@ -3388,6 +3398,10 @@ to return true:wantsResponderID| | var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; var NormalPriority$1 = Scheduler.unstable_NormalPriority; var IdlePriority = Scheduler.unstable_IdlePriority; // this doesn't actually exist on the scheduler, but it *does* + // on scheduler/unstable_mock, which we'll need for internal testing + + var log$1 = Scheduler.log; + var unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue; // Helpers to patch console.logs to avoid logging during side-effect free // replaying on render function. This currently only patches the object @@ -3654,7 +3668,29 @@ to return true:wantsResponderID| | } } function setIsStrictModeForDevtools(newIsStrictMode) { - { + if (consoleManagedByDevToolsDuringStrictMode) { + if (typeof log$1 === "function") { + // We're in a test because Scheduler.log only exists + // in SchedulerMock. To reduce the noise in strict mode tests, + // suppress warnings and disable scheduler yielding during the double render + unstable_setDisableYieldValue(newIsStrictMode); + setSuppressWarning(newIsStrictMode); + } + + if (injectedHook && typeof injectedHook.setStrictMode === "function") { + try { + injectedHook.setStrictMode(rendererID, newIsStrictMode); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + } + } + } else { if (newIsStrictMode) { disableLogs(); } else { @@ -5251,6 +5287,7 @@ to return true:wantsResponderID| | function waitForCommitToBeReady() { return null; } + var NotPendingTransition = null; // ------------------- // Microtasks // ------------------- @@ -5451,21 +5488,30 @@ to return true:wantsResponderID| | } switch (type.$$typeof) { - case REACT_PROVIDER_TYPE: { - var provider = type; - return getContextName$1(provider._context) + ".Provider"; - } + case REACT_PROVIDER_TYPE: + if (enableRenderableContext) { + return null; + } else { + var provider = type; + return getContextName$1(provider._context) + ".Provider"; + } case REACT_CONTEXT_TYPE: var context = type; - { + if (enableRenderableContext) { + return getContextName$1(context) + ".Provider"; + } else { return getContextName$1(context) + ".Consumer"; } - case REACT_CONSUMER_TYPE: { - return null; - } + case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + var consumer = type; + return getContextName$1(consumer._context) + ".Consumer"; + } else { + return null; + } case REACT_FORWARD_REF_TYPE: return getWrappedName$1(type, type.render, "ForwardRef"); @@ -5518,15 +5564,23 @@ to return true:wantsResponderID| | case CacheComponent: return "Cache"; - case ContextConsumer: { - var context = type; - return getContextName(context) + ".Consumer"; - } + case ContextConsumer: + if (enableRenderableContext) { + var consumer = type; + return getContextName(consumer._context) + ".Consumer"; + } else { + var context = type; + return getContextName(context) + ".Consumer"; + } - case ContextProvider: { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } + case ContextProvider: + if (enableRenderableContext) { + var _context = type; + return getContextName(_context) + ".Provider"; + } else { + var provider = type; + return getContextName(provider._context) + ".Provider"; + } case DehydratedFragment: return "DehydratedFragment"; @@ -6245,6 +6299,25 @@ to return true:wantsResponderID| | var contextStackCursor = createCursor(null); var contextFiberStackCursor = createCursor(null); var rootInstanceStackCursor = createCursor(null); // Represents the nearest host transition provider (in React DOM, a
) + // NOTE: Since forms cannot be nested, and this feature is only implemented by + // React DOM, we don't technically need this to be a stack. It could be a single + // module variable instead. + + var hostTransitionProviderCursor = createCursor(null); // TODO: This should initialize to NotPendingTransition, a constant + // imported from the fiber config. However, because of a cycle in the module + // graph, that value isn't defined during this module's initialization. I can't + // think of a way to work around this without moving that value out of the + // fiber config. For now, the "no provider" case is handled when reading, + // inside useHostTransitionStatus. + + var HostTransitionContext = { + $$typeof: REACT_CONTEXT_TYPE, + _currentValue: null, + _currentValue2: null, + _threadCount: 0, + Provider: null, + Consumer: null + }; function requiredContext(c) { { @@ -6295,6 +6368,16 @@ to return true:wantsResponderID| | } function pushHostContext(fiber) { + if (enableAsyncActions) { + var stateHook = fiber.memoizedState; + + if (stateHook !== null) { + // Only provide context if this fiber has been upgraded by a host + // transition. We use the same optimization for regular host context below. + push(hostTransitionProviderCursor, fiber, fiber); + } + } + var context = requiredContext(contextStackCursor.current); var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. @@ -6313,6 +6396,25 @@ to return true:wantsResponderID| | pop(contextStackCursor, fiber); pop(contextFiberStackCursor, fiber); } + + if (enableAsyncActions) { + if (hostTransitionProviderCursor.current === fiber) { + // Do not pop unless this Fiber provided the current context. This is mostly + // a performance optimization, but conveniently it also prevents a potential + // data race where a host provider is upgraded (i.e. memoizedState becomes + // non-null) during a concurrent event. This is a bit of a flaw in the way + // we upgrade host components, but because we're accounting for it here, it + // should be fine. + pop(hostTransitionProviderCursor, fiber); // When popping the transition provider, we reset the context value back + // to `null`. We can do this because you're not allowd to nest forms. If + // we allowed for multiple nested host transition providers, then we'd + // need to reset this to the parent provider's status. + + { + HostTransitionContext._currentValue2 = null; + } + } + } } var isHydrating = false; // This flag allows for warning supression when we expect there to be mismatches @@ -7035,11 +7137,70 @@ to return true:wantsResponderID| | return currentEventTransitionLane; } + // transition updates that occur while the async action is still in progress + // are treated as part of the action. + // + // The ideal behavior would be to treat each async function as an independent + // action. However, without a mechanism like AsyncContext, we can't tell which + // action an update corresponds to. So instead, we entangle them all into one. + // The listeners to notify once the entangled scope completes. + + var currentEntangledListeners = null; // The number of pending async actions in the entangled scope. + + var currentEntangledPendingCount = 0; // The transition lane shared by all updates in the entangled scope. + var currentEntangledLane = NoLane; // A thenable that resolves when the entangled scope completes. It does not // resolve to a particular value because it's only used for suspending the UI // until the async action scope has completed. var currentEntangledActionThenable = null; + function entangleAsyncAction(transition, thenable) { + // `thenable` is the return value of the async action scope function. Create + // a combined thenable that resolves once every entangled scope function + // has finished. + if (currentEntangledListeners === null) { + // There's no outer async action scope. Create a new one. + var entangledListeners = (currentEntangledListeners = []); + currentEntangledPendingCount = 0; + currentEntangledLane = requestTransitionLane(); + var entangledThenable = { + status: "pending", + value: undefined, + then: function (resolve) { + entangledListeners.push(resolve); + } + }; + currentEntangledActionThenable = entangledThenable; + } + + currentEntangledPendingCount++; + thenable.then(pingEngtangledActionScope, pingEngtangledActionScope); + return thenable; + } + + function pingEngtangledActionScope() { + if ( + currentEntangledListeners !== null && + --currentEntangledPendingCount === 0 + ) { + // All the actions have finished. Close the entangled async action scope + // and notify all the listeners. + if (currentEntangledActionThenable !== null) { + var fulfilledThenable = currentEntangledActionThenable; + fulfilledThenable.status = "fulfilled"; + } + + var listeners = currentEntangledListeners; + currentEntangledListeners = null; + currentEntangledLane = NoLane; + currentEntangledActionThenable = null; + + for (var i = 0; i < listeners.length; i++) { + var listener = listeners[i]; + listener(); + } + } + } function chainThenableValue(thenable, result) { // Equivalent to: Promise.resolve(thenable).then(() => result), except we can @@ -11410,6 +11571,43 @@ to return true:wantsResponderID| | return children; } + + function renderTransitionAwareHostComponentWithHooks( + current, + workInProgress, + lanes + ) { + if (!enableAsyncActions) { + throw new Error("Not implemented."); + } + + return renderWithHooks( + current, + workInProgress, + TransitionAwareHostComponent, + null, + null, + lanes + ); + } + function TransitionAwareHostComponent() { + if (!enableAsyncActions) { + throw new Error("Not implemented."); + } + + var dispatcher = ReactCurrentDispatcher$1.current; + + var _dispatcher$useState = dispatcher.useState(), + maybeThenable = _dispatcher$useState[0]; + + if (typeof maybeThenable.then === "function") { + var thenable = maybeThenable; + return useThenable(thenable); + } else { + var status = maybeThenable; + return status; + } + } function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; // TODO: Don't need to reset the flags here, because they're reset in the // complete phase (bubbleProperties). @@ -11846,7 +12044,11 @@ to return true:wantsResponderID| | ); markSkippedUpdateLanes(updateLane); } else { - { + // This update does have sufficient priority. + // Check if this is an optimistic update. + var revertLane = update.revertLane; + + if (!enableAsyncActions || revertLane === NoLane) { // This is not an optimistic update, and we're going to apply it now. // But, if there were earlier updates that were skipped, we need to // leave this update in the queue so it can be rebased later. @@ -11870,6 +12072,56 @@ to return true:wantsResponderID| | if (updateLane === peekEntangledActionLane()) { didReadFromEntangledAsyncAction = true; } + } else { + // This is an optimistic update. If the "revert" priority is + // sufficient, don't apply the update. Otherwise, apply the update, + // but leave it in the queue so it can be either reverted or + // rebased in a subsequent render. + if (isSubsetOfLanes(renderLanes, revertLane)) { + // The transition that this optimistic update is associated with + // has finished. Pretend the update doesn't exist by skipping + // over it. + update = update.next; // Check if this update is part of a pending async action. If so, + // we'll need to suspend until the action has finished, so that it's + // batched together with future updates in the same action. + + if (revertLane === peekEntangledActionLane()) { + didReadFromEntangledAsyncAction = true; + } + + continue; + } else { + var _clone2 = { + // Once we commit an optimistic update, we shouldn't uncommit it + // until the transition it is associated with has finished + // (represented by revertLane). Using NoLane here works because 0 + // is a subset of all bitmasks, so this will never be skipped by + // the check above. + lane: NoLane, + // Reuse the same revertLane so we know when the transition + // has finished. + revertLane: update.revertLane, + action: update.action, + hasEagerState: update.hasEagerState, + eagerState: update.eagerState, + next: null + }; + + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = _clone2; + newBaseState = newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = _clone2; + } // Update the remaining priority in the queue. + // TODO: Don't need to accumulate this. Instead, we can remove + // renderLanes from the original lanes. + + currentlyRenderingFiber$1.lanes = mergeLanes( + currentlyRenderingFiber$1.lanes, + revertLane + ); + markSkippedUpdateLanes(revertLane); + } } // Process this update. var action = update.action; @@ -12258,6 +12510,320 @@ to return true:wantsResponderID| | return rerenderReducer(basicStateReducer); } + function mountOptimistic(passthrough, reducer) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = hook.baseState = passthrough; + var queue = { + pending: null, + lanes: NoLanes, + dispatch: null, + // Optimistic state does not use the eager update optimization. + lastRenderedReducer: null, + lastRenderedState: null + }; + hook.queue = queue; // This is different than the normal setState function. + + var dispatch = dispatchOptimisticSetState.bind( + null, + currentlyRenderingFiber$1, + true, + queue + ); + queue.dispatch = dispatch; + return [passthrough, dispatch]; + } + + function updateOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + } + + function updateOptimisticImpl(hook, current, passthrough, reducer) { + // Optimistic updates are always rebased on top of the latest value passed in + // as an argument. It's called a passthrough because if there are no pending + // updates, it will be returned as-is. + // + // Reset the base state to the passthrough. Future updates will be applied + // on top of this. + hook.baseState = passthrough; // If a reducer is not provided, default to the same one used by useState. + + var resolvedReducer = + typeof reducer === "function" ? reducer : basicStateReducer; + return updateReducerImpl(hook, currentHook, resolvedReducer); + } + + function rerenderOptimistic(passthrough, reducer) { + // Unlike useState, useOptimistic doesn't support render phase updates. + // Also unlike useState, we need to replay all pending updates again in case + // the passthrough value changed. + // + // So instead of a forked re-render implementation that knows how to handle + // render phase udpates, we can use the same implementation as during a + // regular mount or update. + var hook = updateWorkInProgressHook(); + + if (currentHook !== null) { + // This is an update. Process the update queue. + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + } // This is a mount. No updates to process. + // Reset the base state to the passthrough. Future updates will be applied + // on top of this. + + hook.baseState = passthrough; + var dispatch = hook.queue.dispatch; + return [passthrough, dispatch]; + } // useFormState actions run sequentially, because each action receives the + // previous state as an argument. We store pending actions on a queue. + + function dispatchFormState(fiber, actionQueue, setState, payload) { + if (isRenderPhaseUpdate(fiber)) { + throw new Error("Cannot update form state while rendering."); + } + + var last = actionQueue.pending; + + if (last === null) { + // There are no pending actions; this is the first one. We can run + // it immediately. + var newLast = { + payload: payload, + next: null // circular + }; + newLast.next = actionQueue.pending = newLast; + runFormStateAction(actionQueue, setState, payload); + } else { + // There's already an action running. Add to the queue. + var first = last.next; + var _newLast = { + payload: payload, + next: first + }; + actionQueue.pending = last.next = _newLast; + } + } + + function runFormStateAction(actionQueue, setState, payload) { + var action = actionQueue.action; + var prevState = actionQueue.state; // This is a fork of startTransition + + var prevTransition = ReactCurrentBatchConfig$2.transition; + var currentTransition = { + _callbacks: new Set() + }; + ReactCurrentBatchConfig$2.transition = currentTransition; + + { + ReactCurrentBatchConfig$2.transition._updatedFibers = new Set(); + } + + try { + var returnValue = action(prevState, payload); + + if ( + returnValue !== null && + typeof returnValue === "object" && // $FlowFixMe[method-unbinding] + typeof returnValue.then === "function" + ) { + var thenable = returnValue; + notifyTransitionCallbacks(currentTransition, thenable); // Attach a listener to read the return state of the action. As soon as + // this resolves, we can run the next action in the sequence. + + thenable.then( + function (nextState) { + actionQueue.state = nextState; + finishRunningFormStateAction(actionQueue, setState); + }, + function () { + return finishRunningFormStateAction(actionQueue, setState); + } + ); + setState(thenable); + } else { + setState(returnValue); + var nextState = returnValue; + actionQueue.state = nextState; + finishRunningFormStateAction(actionQueue, setState); + } + } catch (error) { + // This is a trick to get the `useFormState` hook to rethrow the error. + // When it unwraps the thenable with the `use` algorithm, the error + // will be thrown. + var rejectedThenable = { + then: function () {}, + status: "rejected", + reason: error // $FlowFixMe: Not sure why this doesn't work + }; + setState(rejectedThenable); + finishRunningFormStateAction(actionQueue, setState); + } finally { + ReactCurrentBatchConfig$2.transition = prevTransition; + + { + 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." + ); + } + } + } + } + } + + function finishRunningFormStateAction(actionQueue, setState) { + // The action finished running. Pop it from the queue and run the next pending + // action, if there are any. + var last = actionQueue.pending; + + if (last !== null) { + var first = last.next; + + if (first === last) { + // This was the last action in the queue. + actionQueue.pending = null; + } else { + // Remove the first node from the circular queue. + var next = first.next; + last.next = next; // Run the next action. + + runFormStateAction(actionQueue, setState, next.payload); + } + } + } + + function formStateReducer(oldState, newState) { + return newState; + } + + function mountFormState(action, initialStateProp, permalink) { + var initialState = initialStateProp; + // the `use` algorithm during render. + + var stateHook = mountWorkInProgressHook(); + stateHook.memoizedState = stateHook.baseState = initialState; // TODO: Typing this "correctly" results in recursion limit errors + // const stateQueue: UpdateQueue, S | Awaited> = { + + var stateQueue = { + pending: null, + lanes: NoLanes, + dispatch: null, + lastRenderedReducer: formStateReducer, + lastRenderedState: initialState + }; + stateHook.queue = stateQueue; + var setState = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + stateQueue + ); + stateQueue.dispatch = setState; // Action queue hook. This is used to queue pending actions. The queue is + // shared between all instances of the hook. Similar to a regular state queue, + // but different because the actions are run sequentially, and they run in + // an event instead of during render. + + var actionQueueHook = mountWorkInProgressHook(); + var actionQueue = { + state: initialState, + dispatch: null, + // circular + action: action, + pending: null + }; + actionQueueHook.queue = actionQueue; + var dispatch = dispatchFormState.bind( + null, + currentlyRenderingFiber$1, + actionQueue, + setState + ); + actionQueue.dispatch = dispatch; // Stash the action function on the memoized state of the hook. We'll use this + // to detect when the action function changes so we can update it in + // an effect. + + actionQueueHook.memoizedState = action; + return [initialState, dispatch]; + } + + function updateFormState(action, initialState, permalink) { + var stateHook = updateWorkInProgressHook(); + var currentStateHook = currentHook; + return updateFormStateImpl(stateHook, currentStateHook, action); + } + + function updateFormStateImpl( + stateHook, + currentStateHook, + action, + initialState, + permalink + ) { + var _updateReducerImpl = updateReducerImpl( + stateHook, + currentStateHook, + formStateReducer + ), + actionResult = _updateReducerImpl[0]; // This will suspend until the action finishes. + + var state = + typeof actionResult === "object" && + actionResult !== null && // $FlowFixMe[method-unbinding] + typeof actionResult.then === "function" + ? useThenable(actionResult) + : actionResult; + var actionQueueHook = updateWorkInProgressHook(); + var actionQueue = actionQueueHook.queue; + var dispatch = actionQueue.dispatch; // Check if a new action was passed. If so, update it in an effect. + + var prevAction = actionQueueHook.memoizedState; + + if (action !== prevAction) { + currentlyRenderingFiber$1.flags |= Passive$1; + pushEffect( + HasEffect | Passive, + formStateActionEffect.bind(null, actionQueue, action), + createEffectInstance(), + null + ); + } + + return [state, dispatch]; + } + + function formStateActionEffect(actionQueue, action) { + actionQueue.action = action; + } + + function rerenderFormState(action, initialState, permalink) { + // Unlike useState, useFormState doesn't support render phase updates. + // Also unlike useState, we need to replay all pending updates again in case + // the passthrough value changed. + // + // So instead of a forked re-render implementation that knows how to handle + // render phase udpates, we can use the same implementation as during a + // regular mount or update. + var stateHook = updateWorkInProgressHook(); + var currentStateHook = currentHook; + + if (currentStateHook !== null) { + // This is an update. Process the update queue. + return updateFormStateImpl(stateHook, currentStateHook, action); + } // This is a mount. No updates to process. + + var state = stateHook.memoizedState; + var actionQueueHook = updateWorkInProgressHook(); + var actionQueue = actionQueueHook.queue; + var dispatch = actionQueue.dispatch; // This may have changed during the rerender. + + actionQueueHook.memoizedState = action; + return [state, dispatch]; + } + function pushEffect(tag, create, inst, deps) { var effect = { tag: tag, @@ -12737,7 +13303,16 @@ to return true:wantsResponderID| | _callbacks: new Set() }; - { + if (enableAsyncActions) { + // We don't really need to use an optimistic update here, because we + // schedule a second "revert" update below (which we use to suspend the + // transition until the async action scope has finished). But we'll use an + // optimistic update anyway to make it less likely the behavior accidentally + // diverges; for example, both an optimistic update and this one should + // share the same lane. + ReactCurrentBatchConfig$2.transition = currentTransition; + dispatchOptimisticSetState(fiber, false, queue, pendingState); + } else { ReactCurrentBatchConfig$2.transition = null; dispatchSetState(fiber, queue, pendingState); ReactCurrentBatchConfig$2.transition = currentTransition; @@ -12748,15 +13323,50 @@ to return true:wantsResponderID| | } try { - var returnValue, thenable, thenableForFinishedState; - if (enableAsyncActions); - else { + if (enableAsyncActions) { + var returnValue = callback(); // Check if we're inside an async action scope. If so, we'll entangle + // this new action with the existing scope. + // + // If we're not already inside an async action scope, and this action is + // async, then we'll create a new async scope. + // + // In the async case, the resulting render will suspend until the async + // action scope has finished. + + if ( + returnValue !== null && + typeof returnValue === "object" && + typeof returnValue.then === "function" + ) { + var thenable = returnValue; + notifyTransitionCallbacks(currentTransition, thenable); // Create a thenable that resolves to `finishedState` once the async + // action has completed. + + var thenableForFinishedState = chainThenableValue( + thenable, + finishedState + ); + dispatchSetState(fiber, queue, thenableForFinishedState); + } else { + dispatchSetState(fiber, queue, finishedState); + } + } else { // Async actions are not enabled. dispatchSetState(fiber, queue, finishedState); callback(); } } catch (error) { - { + if (enableAsyncActions) { + // This is a trick to get the `useTransition` hook to rethrow the error. + // When it unwraps the thenable with the `use` algorithm, the error + // will be thrown. + var rejectedThenable = { + then: function () {}, + status: "rejected", + reason: error + }; + dispatchSetState(fiber, queue, rejectedThenable); + } else { // The error rethrowing behavior is only enabled when the async actions // feature is on, even for sync actions. throw error; @@ -12824,6 +13434,15 @@ to return true:wantsResponderID| | return [isPending, start]; } + function useHostTransitionStatus() { + if (!enableAsyncActions) { + throw new Error("Not implemented."); + } + + var status = readContext(HostTransitionContext); + return status !== null ? status : NotPendingTransition; + } + function mountId() { var hook = mountWorkInProgressHook(); var root = getWorkInProgressRoot(); // TODO: In Fizz, id generation is specific to each server config. Maybe we @@ -13034,6 +13653,89 @@ to return true:wantsResponderID| | markUpdateInDevTools(fiber, lane); } + function dispatchOptimisticSetState( + fiber, + throwIfDuringRender, + queue, + action + ) { + var transition = requestCurrentTransition(); + + { + if (transition === null) { + // An optimistic update occurred, but startTransition is not on the stack. + // There are two likely scenarios. + // One possibility is that the optimistic update is triggered by a regular + // event handler (e.g. `onSubmit`) instead of an action. This is a mistake + // and we will warn. + // The other possibility is the optimistic update is inside an async + // action, but after an `await`. In this case, we can make it "just work" + // by associating the optimistic update with the pending async action. + // Technically it's possible that the optimistic update is unrelated to + // the pending action, but we don't have a way of knowing this for sure + // because browsers currently do not provide a way to track async scope. + // (The AsyncContext proposal, if it lands, will solve this in the + // future.) However, this is no different than the problem of unrelated + // transitions being grouped together — it's not wrong per se, but it's + // not ideal. + // Once AsyncContext starts landing in browsers, we will provide better + // warnings in development for these cases. + if (peekEntangledActionLane() !== NoLane); + else { + // There's no pending async action. The most likely cause is that we're + // inside a regular event handler (e.g. onSubmit) instead of an action. + error( + "An optimistic state update occurred outside a transition or " + + "action. To fix, move the update to an action, or wrap " + + "with startTransition." + ); + } + } + } + + var update = { + // An optimistic update commits synchronously. + lane: SyncLane, + // After committing, the optimistic update is "reverted" using the same + // lane as the transition it's associated with. + revertLane: requestTransitionLane(), + action: action, + hasEagerState: false, + eagerState: null, + next: null + }; + + if (isRenderPhaseUpdate(fiber)) { + // When calling startTransition during render, this warns instead of + // throwing because throwing would be a breaking change. setOptimisticState + // is a new API so it's OK to throw. + if (throwIfDuringRender) { + throw new Error("Cannot update optimistic state while rendering."); + } else { + // startTransition was called during render. We don't need to do anything + // besides warn here because the render phase update would be overidden by + // the second update, anyway. We can remove this branch and make it throw + // in a future release. + { + error("Cannot call startTransition while rendering."); + } + } + } else { + var root = enqueueConcurrentHookUpdate(fiber, queue, update, SyncLane); + + if (root !== null) { + // NOTE: The optimistic update implementation assumes that the transition + // will never be attempted before the optimistic update. This currently + // holds because the optimistic update is always synchronous. If we ever + // change that, we'll need to account for this. + scheduleUpdateOnFiber(root, fiber, SyncLane); // Optimistic updates are always synchronous, so we don't need to call + // entangleTransitionUpdate here. + } + } + + markUpdateInDevTools(fiber, SyncLane); + } + function isRenderPhaseUpdate(fiber) { var alternate = fiber.alternate; return ( @@ -13114,6 +13816,15 @@ to return true:wantsResponderID| | ContextOnlyDispatcher.useMemoCache = throwInvalidHookError; } + if (enableAsyncActions) { + ContextOnlyDispatcher.useHostTransitionStatus = throwInvalidHookError; + ContextOnlyDispatcher.useFormState = throwInvalidHookError; + } + + if (enableAsyncActions) { + ContextOnlyDispatcher.useOptimistic = throwInvalidHookError; + } + var HooksDispatcherOnMountInDEV = null; var HooksDispatcherOnMountWithHookTypesInDEV = null; var HooksDispatcherOnUpdateInDEV = null; @@ -13270,6 +13981,32 @@ to return true:wantsResponderID| | HooksDispatcherOnMountInDEV.useMemoCache = useMemoCache; } + if (enableAsyncActions) { + HooksDispatcherOnMountInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + HooksDispatcherOnMountInDEV.useFormState = function useFormState( + action, + initialState, + permalink + ) { + currentHookNameInDev = "useFormState"; + mountHookTypesDev(); + return mountFormState(action, initialState); + }; + } + + if (enableAsyncActions) { + HooksDispatcherOnMountInDEV.useOptimistic = function useOptimistic( + passthrough, + reducer + ) { + currentHookNameInDev = "useOptimistic"; + mountHookTypesDev(); + return mountOptimistic(passthrough); + }; + } + HooksDispatcherOnMountWithHookTypesInDEV = { readContext: function (context) { return readContext(context); @@ -13393,6 +14130,27 @@ to return true:wantsResponderID| | HooksDispatcherOnMountWithHookTypesInDEV.useMemoCache = useMemoCache; } + if (enableAsyncActions) { + HooksDispatcherOnMountWithHookTypesInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + HooksDispatcherOnMountWithHookTypesInDEV.useFormState = + function useFormState(action, initialState, permalink) { + currentHookNameInDev = "useFormState"; + updateHookTypesDev(); + return mountFormState(action, initialState); + }; + } + + if (enableAsyncActions) { + HooksDispatcherOnMountWithHookTypesInDEV.useOptimistic = + function useOptimistic(passthrough, reducer) { + currentHookNameInDev = "useOptimistic"; + updateHookTypesDev(); + return mountOptimistic(passthrough); + }; + } + HooksDispatcherOnUpdateInDEV = { readContext: function (context) { return readContext(context); @@ -13516,6 +14274,32 @@ to return true:wantsResponderID| | HooksDispatcherOnUpdateInDEV.useMemoCache = useMemoCache; } + if (enableAsyncActions) { + HooksDispatcherOnUpdateInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + HooksDispatcherOnUpdateInDEV.useFormState = function useFormState( + action, + initialState, + permalink + ) { + currentHookNameInDev = "useFormState"; + updateHookTypesDev(); + return updateFormState(action); + }; + } + + if (enableAsyncActions) { + HooksDispatcherOnUpdateInDEV.useOptimistic = function useOptimistic( + passthrough, + reducer + ) { + currentHookNameInDev = "useOptimistic"; + updateHookTypesDev(); + return updateOptimistic(passthrough, reducer); + }; + } + HooksDispatcherOnRerenderInDEV = { readContext: function (context) { return readContext(context); @@ -13639,6 +14423,32 @@ to return true:wantsResponderID| | HooksDispatcherOnRerenderInDEV.useMemoCache = useMemoCache; } + if (enableAsyncActions) { + HooksDispatcherOnRerenderInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + HooksDispatcherOnRerenderInDEV.useFormState = function useFormState( + action, + initialState, + permalink + ) { + currentHookNameInDev = "useFormState"; + updateHookTypesDev(); + return rerenderFormState(action); + }; + } + + if (enableAsyncActions) { + HooksDispatcherOnRerenderInDEV.useOptimistic = function useOptimistic( + passthrough, + reducer + ) { + currentHookNameInDev = "useOptimistic"; + updateHookTypesDev(); + return rerenderOptimistic(passthrough, reducer); + }; + } + InvalidNestedHooksDispatcherOnMountInDEV = { readContext: function (context) { warnInvalidContextAccess(); @@ -13786,6 +14596,29 @@ to return true:wantsResponderID| | }; } + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnMountInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + InvalidNestedHooksDispatcherOnMountInDEV.useFormState = + function useFormState(action, initialState, permalink) { + currentHookNameInDev = "useFormState"; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountFormState(action, initialState); + }; + } + + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnMountInDEV.useOptimistic = + function useOptimistic(passthrough, reducer) { + currentHookNameInDev = "useOptimistic"; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountOptimistic(passthrough); + }; + } + InvalidNestedHooksDispatcherOnUpdateInDEV = { readContext: function (context) { warnInvalidContextAccess(); @@ -13933,6 +14766,29 @@ to return true:wantsResponderID| | }; } + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnUpdateInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + InvalidNestedHooksDispatcherOnUpdateInDEV.useFormState = + function useFormState(action, initialState, permalink) { + currentHookNameInDev = "useFormState"; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateFormState(action); + }; + } + + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnUpdateInDEV.useOptimistic = + function useOptimistic(passthrough, reducer) { + currentHookNameInDev = "useOptimistic"; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateOptimistic(passthrough, reducer); + }; + } + InvalidNestedHooksDispatcherOnRerenderInDEV = { readContext: function (context) { warnInvalidContextAccess(); @@ -14079,6 +14935,29 @@ to return true:wantsResponderID| | return useMemoCache(size); }; } + + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnRerenderInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + InvalidNestedHooksDispatcherOnRerenderInDEV.useFormState = + function useFormState(action, initialState, permalink) { + currentHookNameInDev = "useFormState"; + warnInvalidHookAccess(); + updateHookTypesDev(); + return rerenderFormState(action); + }; + } + + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnRerenderInDEV.useOptimistic = + function useOptimistic(passthrough, reducer) { + currentHookNameInDev = "useOptimistic"; + warnInvalidHookAccess(); + updateHookTypesDev(); + return rerenderOptimistic(passthrough, reducer); + }; + } } var now = Scheduler.unstable_now; @@ -17055,6 +17934,57 @@ to return true:wantsResponderID| | workInProgress.flags |= ContentReset; } + if (enableAsyncActions) { + var memoizedState = workInProgress.memoizedState; + + if (memoizedState !== null) { + // This fiber has been upgraded to a stateful component. The only way + // happens currently is for form actions. We use hooks to track the + // pending and error state of the form. + // + // Once a fiber is upgraded to be stateful, it remains stateful for the + // rest of its lifetime. + var newState = renderTransitionAwareHostComponentWithHooks( + current, + workInProgress, + renderLanes + ); // If the transition state changed, propagate the change to all the + // descendents. We use Context as an implementation detail for this. + // + // This is intentionally set here instead of pushHostContext because + // pushHostContext gets called before we process the state hook, to avoid + // a state mismatch in the event that something suspends. + // + // NOTE: This assumes that there cannot be nested transition providers, + // because the only renderer that implements this feature is React DOM, + // and forms cannot be nested. If we did support nested providers, then + // we would need to push a context value even for host fibers that + // haven't been upgraded yet. + + { + HostTransitionContext._currentValue2 = newState; + } + + { + if (didReceiveUpdate) { + if (current !== null) { + var oldStateHook = current.memoizedState; + var oldState = oldStateHook.memoizedState; // This uses regular equality instead of Object.is because we assume + // that host transition state doesn't include NaN as a valid type. + + if (oldState !== newState) { + propagateContextChange( + workInProgress, + HostTransitionContext, + renderLanes + ); + } + } + } + } + } + } + markRef(current, workInProgress); reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; @@ -18616,7 +19546,9 @@ to return true:wantsResponderID| | function updateContextProvider(current, workInProgress, renderLanes) { var context; - { + if (enableRenderableContext) { + context = workInProgress.type; + } else { context = workInProgress.type._context; } @@ -18670,7 +19602,10 @@ to return true:wantsResponderID| | function updateContextConsumer(current, workInProgress, renderLanes) { var context; - { + if (enableRenderableContext) { + var consumerType = workInProgress.type; + context = consumerType._context; + } else { context = workInProgress.type; { @@ -18886,7 +19821,9 @@ to return true:wantsResponderID| | var newValue = workInProgress.memoizedProps.value; var context; - { + if (enableRenderableContext) { + context = workInProgress.type; + } else { context = workInProgress.type._context; } @@ -19772,7 +20709,12 @@ to return true:wantsResponderID| | return transition; } - function handleAsyncAction(transition, thenable) {} + function handleAsyncAction(transition, thenable) { + if (enableAsyncActions) { + // This is an async action. + entangleAsyncAction(transition, thenable); + } + } function notifyTransitionCallbacks(transition, returnValue) { var callbacks = transition._callbacks; @@ -20839,7 +21781,9 @@ to return true:wantsResponderID| | // Pop provider fiber var context; - { + if (enableRenderableContext) { + context = workInProgress.type; + } else { context = workInProgress.type._context; } @@ -21285,7 +22229,9 @@ to return true:wantsResponderID| | case ContextProvider: var context; - { + if (enableRenderableContext) { + context = workInProgress.type; + } else { context = workInProgress.type._context; } @@ -21370,7 +22316,9 @@ to return true:wantsResponderID| | case ContextProvider: var context; - { + if (enableRenderableContext) { + context = interruptedWork.type; + } else { context = interruptedWork.type._context; } @@ -27501,9 +28449,121 @@ to return true:wantsResponderID| | } } + function recursivelyTraverseAndDoubleInvokeEffectsInDEV( + root, + parentFiber, + isInStrictMode + ) { + if ( + (parentFiber.subtreeFlags & (PlacementDEV | Visibility)) === + NoFlags$1 + ) { + // Parent's descendants have already had effects double invoked. + // Early exit to avoid unnecessary tree traversal. + return; + } + + var child = parentFiber.child; + + while (child !== null) { + doubleInvokeEffectsInDEVIfNecessary(root, child, isInStrictMode); + child = child.sibling; + } + } // Unconditionally disconnects and connects passive and layout effects. + + function doubleInvokeEffectsOnFiber(root, fiber) { + var shouldDoubleInvokePassiveEffects = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : true; + disappearLayoutEffects(fiber); + + if (shouldDoubleInvokePassiveEffects) { + disconnectPassiveEffect(fiber); + } + + reappearLayoutEffects(root, fiber.alternate, fiber, false); + + if (shouldDoubleInvokePassiveEffects) { + reconnectPassiveEffects(root, fiber, NoLanes, null, false); + } + } + + function doubleInvokeEffectsInDEVIfNecessary( + root, + fiber, + parentIsInStrictMode + ) { + var isStrictModeFiber = fiber.type === REACT_STRICT_MODE_TYPE; + var isInStrictMode = parentIsInStrictMode || isStrictModeFiber; // First case: the fiber **is not** of type OffscreenComponent. No + // special rules apply to double invoking effects. + + if (fiber.tag !== OffscreenComponent) { + if (fiber.flags & PlacementDEV) { + setCurrentFiber(fiber); + + if (isInStrictMode) { + doubleInvokeEffectsOnFiber( + root, + fiber, + (fiber.mode & NoStrictPassiveEffectsMode) === NoMode + ); + } + + resetCurrentFiber(); + } else { + recursivelyTraverseAndDoubleInvokeEffectsInDEV( + root, + fiber, + isInStrictMode + ); + } + + return; + } // Second case: the fiber **is** of type OffscreenComponent. + // This branch contains cases specific to Offscreen. + + if (fiber.memoizedState === null) { + // Only consider Offscreen that is visible. + // TODO (Offscreen) Handle manual mode. + setCurrentFiber(fiber); + + if (isInStrictMode && fiber.flags & Visibility) { + // Double invoke effects on Offscreen's subtree only + // if it is visible and its visibility has changed. + doubleInvokeEffectsOnFiber(root, fiber); + } else if (fiber.subtreeFlags & PlacementDEV) { + // Something in the subtree could have been suspended. + // We need to continue traversal and find newly inserted fibers. + recursivelyTraverseAndDoubleInvokeEffectsInDEV( + root, + fiber, + isInStrictMode + ); + } + + resetCurrentFiber(); + } + } + function commitDoubleInvokeEffectsInDEV(root, hasPassiveEffects) { { - { + if (useModernStrictMode && root.tag !== LegacyRoot) { + var doubleInvokeEffects = true; + + if ( + root.tag === ConcurrentRoot && + !(root.current.mode & (StrictLegacyMode | StrictEffectsMode)) + ) { + doubleInvokeEffects = false; + } + + recursivelyTraverseAndDoubleInvokeEffectsInDEV( + root, + root.current, + doubleInvokeEffects + ); + } else { legacyCommitDoubleInvokeEffectsInDEV(root.current, hasPassiveEffects); } } @@ -28750,19 +29810,28 @@ to return true:wantsResponderID| | default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { - case REACT_PROVIDER_TYPE: { - fiberTag = ContextProvider; - break getTag; - } + case REACT_PROVIDER_TYPE: + if (!enableRenderableContext) { + fiberTag = ContextProvider; + break getTag; + } // Fall through - case REACT_CONTEXT_TYPE: { - fiberTag = ContextConsumer; - break getTag; - } + case REACT_CONTEXT_TYPE: + if (enableRenderableContext) { + fiberTag = ContextProvider; + break getTag; + } else { + fiberTag = ContextConsumer; + break getTag; + } case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + fiberTag = ContextConsumer; + break getTag; + } // Fall through @@ -29115,7 +30184,7 @@ to return true:wantsResponderID| | return root; } - var ReactVersion = "18.3.0-canary-4a78ee9a"; + var ReactVersion = "18.3.0-canary-d10dabcc"; function createPortal$1( children, diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 31f566af6c120..4b00aefac2994 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<8a5881687c738ab974934de5b7cde1fc>> */ "use strict"; @@ -935,7 +935,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_255 = { +var injectedNamesToPlugins$jscomp$inline_254 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -981,32 +981,32 @@ var injectedNamesToPlugins$jscomp$inline_255 = { } } }, - isOrderingDirty$jscomp$inline_256 = !1, - pluginName$jscomp$inline_257; -for (pluginName$jscomp$inline_257 in injectedNamesToPlugins$jscomp$inline_255) + isOrderingDirty$jscomp$inline_255 = !1, + pluginName$jscomp$inline_256; +for (pluginName$jscomp$inline_256 in injectedNamesToPlugins$jscomp$inline_254) if ( - injectedNamesToPlugins$jscomp$inline_255.hasOwnProperty( - pluginName$jscomp$inline_257 + injectedNamesToPlugins$jscomp$inline_254.hasOwnProperty( + pluginName$jscomp$inline_256 ) ) { - var pluginModule$jscomp$inline_258 = - injectedNamesToPlugins$jscomp$inline_255[pluginName$jscomp$inline_257]; + var pluginModule$jscomp$inline_257 = + injectedNamesToPlugins$jscomp$inline_254[pluginName$jscomp$inline_256]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_257) || - namesToPlugins[pluginName$jscomp$inline_257] !== - pluginModule$jscomp$inline_258 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_256) || + namesToPlugins[pluginName$jscomp$inline_256] !== + pluginModule$jscomp$inline_257 ) { - if (namesToPlugins[pluginName$jscomp$inline_257]) + if (namesToPlugins[pluginName$jscomp$inline_256]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_257 + "`.") + (pluginName$jscomp$inline_256 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_257] = - pluginModule$jscomp$inline_258; - isOrderingDirty$jscomp$inline_256 = !0; + namesToPlugins[pluginName$jscomp$inline_256] = + pluginModule$jscomp$inline_257; + isOrderingDirty$jscomp$inline_255 = !0; } } -isOrderingDirty$jscomp$inline_256 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_255 && recomputePluginOrdering(); var emptyObject$1 = {}, removedKeys = null, removedKeyCount = 0, @@ -1310,17 +1310,21 @@ function dispatchEvent(target, topLevelType, nativeEvent) { }); } var alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, + consoleManagedByDevToolsDuringStrictMode = + dynamicFlags.consoleManagedByDevToolsDuringStrictMode, + enableAsyncActions = dynamicFlags.enableAsyncActions, enableComponentStackLocations = dynamicFlags.enableComponentStackLocations, enableDeferRootSchedulingToMicrotask = dynamicFlags.enableDeferRootSchedulingToMicrotask, + enableInfiniteRenderLoopDetection = + dynamicFlags.enableInfiniteRenderLoopDetection, + enableRenderableContext = dynamicFlags.enableRenderableContext, + enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, passChildrenWhenCloningPersistedNodes = dynamicFlags.passChildrenWhenCloningPersistedNodes, useMicrotasksForSchedulingInFabric = dynamicFlags.useMicrotasksForSchedulingInFabric, - enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, - enableInfiniteRenderLoopDetection = - dynamicFlags.enableInfiniteRenderLoopDetection, scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, @@ -1330,6 +1334,8 @@ var alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, NormalPriority$1 = Scheduler.unstable_NormalPriority, IdlePriority = Scheduler.unstable_IdlePriority, + log$1 = Scheduler.log, + unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue, ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, rendererID = null, @@ -1345,6 +1351,17 @@ function onCommitRoot(root) { ); } catch (err) {} } +function setIsStrictModeForDevtools(newIsStrictMode) { + if ( + consoleManagedByDevToolsDuringStrictMode && + ("function" === typeof log$1 && + unstable_setDisableYieldValue(newIsStrictMode), + injectedHook && "function" === typeof injectedHook.setStrictMode) + ) + try { + injectedHook.setStrictMode(rendererID, newIsStrictMode); + } catch (err) {} +} var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, log = Math.log, LN2 = Math.LN2; @@ -1718,9 +1735,16 @@ function getComponentNameFromType(type) { if ("object" === typeof type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - return (type._context.displayName || "Context") + ".Provider"; + if (enableRenderableContext) break; + else return (type._context.displayName || "Context") + ".Provider"; case REACT_CONTEXT_TYPE: - return (type.displayName || "Context") + ".Consumer"; + return enableRenderableContext + ? (type.displayName || "Context") + ".Provider" + : (type.displayName || "Context") + ".Consumer"; + case REACT_CONSUMER_TYPE: + if (enableRenderableContext) + return (type._context.displayName || "Context") + ".Consumer"; + break; case REACT_FORWARD_REF_TYPE: var innerType = type.render; type = type.displayName; @@ -1750,9 +1774,13 @@ function getComponentNameFromFiber(fiber) { case 24: return "Cache"; case 9: - return (type.displayName || "Context") + ".Consumer"; + return enableRenderableContext + ? (type._context.displayName || "Context") + ".Consumer" + : (type.displayName || "Context") + ".Consumer"; case 10: - return (type._context.displayName || "Context") + ".Provider"; + return enableRenderableContext + ? (type.displayName || "Context") + ".Provider" + : (type._context.displayName || "Context") + ".Provider"; case 18: return "DehydratedFragment"; case 11: @@ -1850,36 +1878,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$7 = parentA.child; child$7; ) { - if (child$7 === a) { + for (var didFindChild = !1, child$8 = parentA.child; child$8; ) { + if (child$8 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$7 === b) { + if (child$8 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$7 = child$7.sibling; + child$8 = child$8.sibling; } if (!didFindChild) { - for (child$7 = parentB.child; child$7; ) { - if (child$7 === a) { + for (child$8 = parentB.child; child$8; ) { + if (child$8 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$7 === b) { + if (child$8 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$7 = child$7.sibling; + child$8 = child$8.sibling; } if (!didFindChild) throw Error( @@ -2013,7 +2041,16 @@ function is(x, y) { var objectIs = "function" === typeof Object.is ? Object.is : is, contextStackCursor = createCursor(null), contextFiberStackCursor = createCursor(null), - rootInstanceStackCursor = createCursor(null); + rootInstanceStackCursor = createCursor(null), + hostTransitionProviderCursor = createCursor(null), + HostTransitionContext = { + $$typeof: REACT_CONTEXT_TYPE, + _currentValue: null, + _currentValue2: null, + _threadCount: 0, + Provider: null, + Consumer: null + }; function pushHostContainer(fiber, nextRootInstance) { push(rootInstanceStackCursor, nextRootInstance); push(contextFiberStackCursor, fiber); @@ -2027,6 +2064,9 @@ function popHostContainer() { pop(rootInstanceStackCursor); } function pushHostContext(fiber) { + enableAsyncActions && + null !== fiber.memoizedState && + push(hostTransitionProviderCursor, fiber); var context = contextStackCursor.current; var JSCompiler_inline_result = fiber.type; JSCompiler_inline_result = @@ -2046,6 +2086,10 @@ function pushHostContext(fiber) { function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor), pop(contextFiberStackCursor)); + enableAsyncActions && + hostTransitionProviderCursor.current === fiber && + (pop(hostTransitionProviderCursor), + (HostTransitionContext._currentValue2 = null)); } var hydrationErrors = null, concurrentQueues = [], @@ -2086,6 +2130,10 @@ function enqueueUpdate$1(fiber, queue, update, lane) { fiber = fiber.alternate; null !== fiber && (fiber.lanes |= lane); } +function enqueueConcurrentHookUpdate(fiber, queue, update, lane) { + enqueueUpdate$1(fiber, queue, update, lane); + return getRootForUpdatedFiber(fiber); +} function enqueueConcurrentRenderForLane(fiber, lane) { enqueueUpdate$1(fiber, null, null, lane); return getRootForUpdatedFiber(fiber); @@ -2148,35 +2196,35 @@ function flushSyncWorkAcrossRoots_impl(onlyLegacy) { var didPerformSomeWork = !1; for (var root = firstScheduledRoot; null !== root; ) { if (!onlyLegacy || 0 === root.tag) { - var workInProgressRootRenderLanes$9 = workInProgressRootRenderLanes, + var workInProgressRootRenderLanes$10 = workInProgressRootRenderLanes, nextLanes = getNextLanes( root, - root === workInProgressRoot ? workInProgressRootRenderLanes$9 : 0 + root === workInProgressRoot ? workInProgressRootRenderLanes$10 : 0 ); if (0 !== (nextLanes & 3)) try { didPerformSomeWork = !0; - workInProgressRootRenderLanes$9 = root; + workInProgressRootRenderLanes$10 = root; if (0 !== (executionContext & 6)) throw Error("Should not already be working."); if (!flushPassiveEffects()) { var exitStatus = renderRootSync( - workInProgressRootRenderLanes$9, + workInProgressRootRenderLanes$10, nextLanes ); if ( - 0 !== workInProgressRootRenderLanes$9.tag && + 0 !== workInProgressRootRenderLanes$10.tag && 2 === exitStatus ) { var originallyAttemptedLanes = nextLanes, errorRetryLanes = getLanesToRetrySynchronouslyOnError( - workInProgressRootRenderLanes$9, + workInProgressRootRenderLanes$10, originallyAttemptedLanes ); 0 !== errorRetryLanes && ((nextLanes = errorRetryLanes), (exitStatus = recoverFromConcurrentError( - workInProgressRootRenderLanes$9, + workInProgressRootRenderLanes$10, originallyAttemptedLanes, errorRetryLanes ))); @@ -2184,33 +2232,34 @@ function flushSyncWorkAcrossRoots_impl(onlyLegacy) { if (1 === exitStatus) throw ( ((originallyAttemptedLanes = workInProgressRootFatalError), - prepareFreshStack(workInProgressRootRenderLanes$9, 0), + prepareFreshStack(workInProgressRootRenderLanes$10, 0), markRootSuspended( - workInProgressRootRenderLanes$9, + workInProgressRootRenderLanes$10, nextLanes, 0 ), - ensureRootIsScheduled(workInProgressRootRenderLanes$9), + ensureRootIsScheduled(workInProgressRootRenderLanes$10), originallyAttemptedLanes) ); 6 === exitStatus ? markRootSuspended( - workInProgressRootRenderLanes$9, + workInProgressRootRenderLanes$10, nextLanes, workInProgressDeferredLane ) - : ((workInProgressRootRenderLanes$9.finishedWork = - workInProgressRootRenderLanes$9.current.alternate), - (workInProgressRootRenderLanes$9.finishedLanes = nextLanes), + : ((workInProgressRootRenderLanes$10.finishedWork = + workInProgressRootRenderLanes$10.current.alternate), + (workInProgressRootRenderLanes$10.finishedLanes = + nextLanes), commitRoot( - workInProgressRootRenderLanes$9, + workInProgressRootRenderLanes$10, workInProgressRootRecoverableErrors, workInProgressTransitions, workInProgressRootDidIncludeRecursiveRenderUpdate, workInProgressDeferredLane )); } - ensureRootIsScheduled(workInProgressRootRenderLanes$9); + ensureRootIsScheduled(workInProgressRootRenderLanes$10); } catch (error) { null === errors ? (errors = [error]) : errors.push(error); } @@ -2333,6 +2382,71 @@ function scheduleImmediateTask(cb) { }) : scheduleCallback$3(ImmediatePriority, cb); } +function requestTransitionLane() { + 0 === currentEventTransitionLane && + (currentEventTransitionLane = claimNextTransitionLane()); + return currentEventTransitionLane; +} +var currentEntangledListeners = null, + currentEntangledPendingCount = 0, + currentEntangledLane = 0, + currentEntangledActionThenable = null; +function entangleAsyncAction(transition, thenable) { + if (null === currentEntangledListeners) { + var entangledListeners = (currentEntangledListeners = []); + currentEntangledPendingCount = 0; + currentEntangledLane = requestTransitionLane(); + currentEntangledActionThenable = { + status: "pending", + value: void 0, + then: function (resolve) { + entangledListeners.push(resolve); + } + }; + } + currentEntangledPendingCount++; + thenable.then(pingEngtangledActionScope, pingEngtangledActionScope); + return thenable; +} +function pingEngtangledActionScope() { + if ( + null !== currentEntangledListeners && + 0 === --currentEntangledPendingCount + ) { + null !== currentEntangledActionThenable && + (currentEntangledActionThenable.status = "fulfilled"); + var listeners = currentEntangledListeners; + currentEntangledListeners = null; + currentEntangledLane = 0; + currentEntangledActionThenable = null; + for (var i = 0; i < listeners.length; i++) (0, listeners[i])(); + } +} +function chainThenableValue(thenable, result) { + var listeners = [], + thenableWithOverride = { + status: "pending", + value: null, + reason: null, + then: function (resolve) { + listeners.push(resolve); + } + }; + thenable.then( + function () { + thenableWithOverride.status = "fulfilled"; + thenableWithOverride.value = result; + for (var i = 0; i < listeners.length; i++) (0, listeners[i])(result); + }, + function (error) { + thenableWithOverride.status = "rejected"; + thenableWithOverride.reason = error; + for (error = 0; error < listeners.length; error++) + (0, listeners[error])(void 0); + } + ); + return thenableWithOverride; +} var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { @@ -2428,12 +2542,20 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { : (workInProgress.next = capturedUpdate); queue.lastBaseUpdate = capturedUpdate; } +var didReadFromEntangledAsyncAction = !1; +function suspendIfUpdateReadFromEntangledAsyncAction() { + if (didReadFromEntangledAsyncAction) { + var entangledActionThenable = currentEntangledActionThenable; + if (null !== entangledActionThenable) throw entangledActionThenable; + } +} function processUpdateQueue( workInProgress$jscomp$0, props, instance$jscomp$0, renderLanes ) { + didReadFromEntangledAsyncAction = !1; var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; var firstBaseUpdate = queue.firstBaseUpdate, @@ -2471,6 +2593,9 @@ function processUpdateQueue( ? (workInProgressRootRenderLanes & updateLane) === updateLane : (renderLanes & updateLane) === updateLane ) { + 0 !== updateLane && + updateLane === currentEntangledLane && + (didReadFromEntangledAsyncAction = !0); null !== current && (current = current.next = { @@ -2634,16 +2759,16 @@ function describeNativeComponentFrame(fn, construct) { } else { try { Fake.call(); - } catch (x$15) { - control = x$15; + } catch (x$16) { + control = x$16; } fn.call(Fake.prototype); } } else { try { throw Error(); - } catch (x$16) { - control = x$16; + } catch (x$17) { + control = x$17; } (Fake = fn()) && "function" === typeof Fake.catch && @@ -3771,6 +3896,13 @@ function renderWithHooksAgain(workInProgress, Component, props, secondArg) { } while (didScheduleRenderPhaseUpdateDuringThisPass); return children; } +function TransitionAwareHostComponent() { + if (!enableAsyncActions) throw Error("Not implemented."); + var maybeThenable = ReactCurrentDispatcher$1.current.useState()[0]; + return "function" === typeof maybeThenable.then + ? useThenable(maybeThenable) + : maybeThenable; +} function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; workInProgress.flags &= -2053; @@ -3905,9 +4037,11 @@ function basicStateReducer(state, action) { return "function" === typeof action ? action(state) : action; } function updateReducer(reducer) { - var hook = updateWorkInProgressHook(), - current = currentHook, - queue = hook.queue; + var hook = updateWorkInProgressHook(); + return updateReducerImpl(hook, currentHook, reducer); +} +function updateReducerImpl(hook, current, reducer) { + var queue = hook.queue; if (null === queue) throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." @@ -3930,52 +4064,83 @@ function updateReducer(reducer) { current = baseQueue.next; var newBaseQueueFirst = (baseFirst = null), newBaseQueueLast = null, - update = current; + update = current, + didReadFromEntangledAsyncAction$31 = !1; do { var updateLane = update.lane & -536870913; if ( updateLane !== update.lane ? (workInProgressRootRenderLanes & updateLane) === updateLane : (renderLanes & updateLane) === updateLane - ) - null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = - { + ) { + var revertLane = update.revertLane; + if (enableAsyncActions && 0 !== revertLane) + if ((renderLanes & revertLane) === revertLane) { + update = update.next; + revertLane === currentEntangledLane && + (didReadFromEntangledAsyncAction$31 = !0); + continue; + } else + (updateLane = { lane: 0, - revertLane: 0, + revertLane: update.revertLane, action: update.action, hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }), - (updateLane = update.action), - shouldDoubleInvokeUserFnsInHooksDEV && - reducer(pendingQueue, updateLane), - (pendingQueue = update.hasEagerState - ? update.eagerState - : reducer(pendingQueue, updateLane)); - else { - var clone = { + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = updateLane), + (baseFirst = pendingQueue)) + : (newBaseQueueLast = newBaseQueueLast.next = updateLane), + (currentlyRenderingFiber$1.lanes |= revertLane), + (workInProgressRootSkippedLanes |= revertLane); + else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = + { + lane: 0, + revertLane: 0, + action: update.action, + hasEagerState: update.hasEagerState, + eagerState: update.eagerState, + next: null + }), + updateLane === currentEntangledLane && + (didReadFromEntangledAsyncAction$31 = !0); + updateLane = update.action; + shouldDoubleInvokeUserFnsInHooksDEV && + reducer(pendingQueue, updateLane); + pendingQueue = update.hasEagerState + ? update.eagerState + : reducer(pendingQueue, updateLane); + } else + (revertLane = { lane: updateLane, revertLane: update.revertLane, action: update.action, hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null - }; - null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (baseFirst = pendingQueue)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - currentlyRenderingFiber$1.lanes |= updateLane; - workInProgressRootSkippedLanes |= updateLane; - } + }), + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = revertLane), + (baseFirst = pendingQueue)) + : (newBaseQueueLast = newBaseQueueLast.next = revertLane), + (currentlyRenderingFiber$1.lanes |= updateLane), + (workInProgressRootSkippedLanes |= updateLane); update = update.next; } while (null !== update && update !== current); null === newBaseQueueLast ? (baseFirst = pendingQueue) : (newBaseQueueLast.next = newBaseQueueFirst); - objectIs(pendingQueue, hook.memoizedState) || (didReceiveUpdate = !0); + if ( + !objectIs(pendingQueue, hook.memoizedState) && + ((didReceiveUpdate = !0), + didReadFromEntangledAsyncAction$31 && + ((reducer = currentEntangledActionThenable), null !== reducer)) + ) + throw reducer; hook.memoizedState = pendingQueue; hook.baseState = baseFirst; hook.baseQueue = newBaseQueueLast; @@ -4084,7 +4249,10 @@ function mountStateImpl(initialState) { if ("function" === typeof initialState) { var initialStateInitializer = initialState; initialState = initialStateInitializer(); - shouldDoubleInvokeUserFnsInHooksDEV && initialStateInitializer(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + initialStateInitializer(), + setIsStrictModeForDevtools(!1)); } hook.memoizedState = hook.baseState = initialState; hook.queue = { @@ -4096,6 +4264,180 @@ function mountStateImpl(initialState) { }; return hook; } +function mountOptimistic(passthrough) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = hook.baseState = passthrough; + var queue = { + pending: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: null, + lastRenderedState: null + }; + hook.queue = queue; + hook = dispatchOptimisticSetState.bind( + null, + currentlyRenderingFiber$1, + !0, + queue + ); + queue.dispatch = hook; + return [passthrough, hook]; +} +function updateOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); +} +function updateOptimisticImpl(hook, current, passthrough, reducer) { + hook.baseState = passthrough; + return updateReducerImpl( + hook, + currentHook, + "function" === typeof reducer ? reducer : basicStateReducer + ); +} +function rerenderOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + if (null !== currentHook) + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + hook.baseState = passthrough; + return [passthrough, hook.queue.dispatch]; +} +function dispatchFormState(fiber, actionQueue, setState, payload) { + if (isRenderPhaseUpdate(fiber)) + throw Error("Cannot update form state while rendering."); + fiber = actionQueue.pending; + null === fiber + ? ((fiber = { payload: payload, next: null }), + (fiber.next = actionQueue.pending = fiber), + runFormStateAction(actionQueue, setState, payload)) + : (actionQueue.pending = fiber.next = + { payload: payload, next: fiber.next }); +} +function runFormStateAction(actionQueue, setState, payload) { + var action = actionQueue.action, + prevState = actionQueue.state, + prevTransition = ReactCurrentBatchConfig$2.transition, + currentTransition = { _callbacks: new Set() }; + ReactCurrentBatchConfig$2.transition = currentTransition; + try { + var returnValue = action(prevState, payload); + null !== returnValue && + "object" === typeof returnValue && + "function" === typeof returnValue.then + ? (notifyTransitionCallbacks(currentTransition, returnValue), + returnValue.then( + function (nextState) { + actionQueue.state = nextState; + finishRunningFormStateAction(actionQueue, setState); + }, + function () { + return finishRunningFormStateAction(actionQueue, setState); + } + ), + setState(returnValue)) + : (setState(returnValue), + (actionQueue.state = returnValue), + finishRunningFormStateAction(actionQueue, setState)); + } catch (error) { + setState({ then: function () {}, status: "rejected", reason: error }), + finishRunningFormStateAction(actionQueue, setState); + } finally { + ReactCurrentBatchConfig$2.transition = prevTransition; + } +} +function finishRunningFormStateAction(actionQueue, setState) { + var last = actionQueue.pending; + if (null !== last) { + var first = last.next; + first === last + ? (actionQueue.pending = null) + : ((first = first.next), + (last.next = first), + runFormStateAction(actionQueue, setState, first.payload)); + } +} +function formStateReducer(oldState, newState) { + return newState; +} +function mountFormState(action, initialStateProp) { + var stateHook = mountWorkInProgressHook(); + stateHook.memoizedState = stateHook.baseState = initialStateProp; + var stateQueue = { + pending: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: formStateReducer, + lastRenderedState: initialStateProp + }; + stateHook.queue = stateQueue; + stateHook = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + stateQueue + ); + stateQueue.dispatch = stateHook; + stateQueue = mountWorkInProgressHook(); + var actionQueue = { + state: initialStateProp, + dispatch: null, + action: action, + pending: null + }; + stateQueue.queue = actionQueue; + stateHook = dispatchFormState.bind( + null, + currentlyRenderingFiber$1, + actionQueue, + stateHook + ); + actionQueue.dispatch = stateHook; + stateQueue.memoizedState = action; + return [initialStateProp, stateHook]; +} +function updateFormState(action) { + var stateHook = updateWorkInProgressHook(); + return updateFormStateImpl(stateHook, currentHook, action); +} +function updateFormStateImpl(stateHook, currentStateHook, action) { + stateHook = updateReducerImpl( + stateHook, + currentStateHook, + formStateReducer + )[0]; + stateHook = + "object" === typeof stateHook && + null !== stateHook && + "function" === typeof stateHook.then + ? useThenable(stateHook) + : stateHook; + currentStateHook = updateWorkInProgressHook(); + var actionQueue = currentStateHook.queue, + dispatch = actionQueue.dispatch; + action !== currentStateHook.memoizedState && + ((currentlyRenderingFiber$1.flags |= 2048), + pushEffect( + 9, + formStateActionEffect.bind(null, actionQueue, action), + { destroy: void 0 }, + null + )); + return [stateHook, dispatch]; +} +function formStateActionEffect(actionQueue, action) { + actionQueue.action = action; +} +function rerenderFormState(action) { + var stateHook = updateWorkInProgressHook(), + currentStateHook = currentHook; + if (null !== currentStateHook) + return updateFormStateImpl(stateHook, currentStateHook, action); + stateHook = stateHook.memoizedState; + currentStateHook = updateWorkInProgressHook(); + var dispatch = currentStateHook.queue.dispatch; + currentStateHook.memoizedState = action; + return [stateHook, dispatch]; +} function pushEffect(tag, create, inst, deps) { tag = { tag: tag, create: create, inst: inst, deps: deps, next: null }; create = currentlyRenderingFiber$1.updateQueue; @@ -4187,7 +4529,10 @@ function updateMemo(nextCreate, deps) { if (null !== deps && areHookInputsEqual(deps, prevState[1])) return prevState[0]; prevState = nextCreate(); - shouldDoubleInvokeUserFnsInHooksDEV && nextCreate(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + nextCreate(), + setIsStrictModeForDevtools(!1)); hook.memoizedState = [prevState, deps]; return prevState; } @@ -4221,18 +4566,46 @@ function startTransition(fiber, queue, pendingState, finishedState, callback) { 0 !== previousPriority && 8 > previousPriority ? previousPriority : 8; var prevTransition = ReactCurrentBatchConfig$2.transition, currentTransition = { _callbacks: new Set() }; - ReactCurrentBatchConfig$2.transition = null; - dispatchSetState(fiber, queue, pendingState); - ReactCurrentBatchConfig$2.transition = currentTransition; + enableAsyncActions + ? ((ReactCurrentBatchConfig$2.transition = currentTransition), + dispatchOptimisticSetState(fiber, !1, queue, pendingState)) + : ((ReactCurrentBatchConfig$2.transition = null), + dispatchSetState(fiber, queue, pendingState), + (ReactCurrentBatchConfig$2.transition = currentTransition)); try { - dispatchSetState(fiber, queue, finishedState), callback(); + if (enableAsyncActions) { + var returnValue = callback(); + if ( + null !== returnValue && + "object" === typeof returnValue && + "function" === typeof returnValue.then + ) { + notifyTransitionCallbacks(currentTransition, returnValue); + var thenableForFinishedState = chainThenableValue( + returnValue, + finishedState + ); + dispatchSetState(fiber, queue, thenableForFinishedState); + } else dispatchSetState(fiber, queue, finishedState); + } else dispatchSetState(fiber, queue, finishedState), callback(); } catch (error) { - throw error; + if (enableAsyncActions) + dispatchSetState(fiber, queue, { + then: function () {}, + status: "rejected", + reason: error + }); + else throw error; } finally { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$2.transition = prevTransition); } } +function useHostTransitionStatus() { + if (!enableAsyncActions) throw Error("Not implemented."); + var status = readContext(HostTransitionContext); + return null !== status ? status : null; +} function updateId() { return updateWorkInProgressHook().memoizedState; } @@ -4269,8 +4642,7 @@ function dispatchReducerAction(fiber, queue, action) { }; isRenderPhaseUpdate(fiber) ? enqueueRenderPhaseUpdate(queue, action) - : (enqueueUpdate$1(fiber, queue, action, lane), - (action = getRootForUpdatedFiber(fiber)), + : ((action = enqueueConcurrentHookUpdate(fiber, queue, action, lane)), null !== action && (scheduleUpdateOnFiber(action, fiber, lane), entangleTransitionUpdate(action, queue, lane))); @@ -4306,13 +4678,35 @@ function dispatchSetState(fiber, queue, action) { } catch (error) { } finally { } - enqueueUpdate$1(fiber, queue, update, lane); - action = getRootForUpdatedFiber(fiber); + action = enqueueConcurrentHookUpdate(fiber, queue, update, lane); null !== action && (scheduleUpdateOnFiber(action, fiber, lane), entangleTransitionUpdate(action, queue, lane)); } } +function dispatchOptimisticSetState(fiber, throwIfDuringRender, queue, action) { + requestCurrentTransition(); + action = { + lane: 2, + revertLane: requestTransitionLane(), + action: action, + hasEagerState: !1, + eagerState: null, + next: null + }; + if (isRenderPhaseUpdate(fiber)) { + if (throwIfDuringRender) + throw Error("Cannot update optimistic state while rendering."); + } else + (throwIfDuringRender = enqueueConcurrentHookUpdate( + fiber, + queue, + action, + 2 + )), + null !== throwIfDuringRender && + scheduleUpdateOnFiber(throwIfDuringRender, fiber, 2); +} function isRenderPhaseUpdate(fiber) { var alternate = fiber.alternate; return ( @@ -4359,6 +4753,11 @@ var ContextOnlyDispatcher = { }; ContextOnlyDispatcher.useCacheRefresh = throwInvalidHookError; ContextOnlyDispatcher.useMemoCache = throwInvalidHookError; +enableAsyncActions && + ((ContextOnlyDispatcher.useHostTransitionStatus = throwInvalidHookError), + (ContextOnlyDispatcher.useFormState = throwInvalidHookError)); +enableAsyncActions && + (ContextOnlyDispatcher.useOptimistic = throwInvalidHookError); var HooksDispatcherOnMount = { readContext: readContext, use: use, @@ -4390,7 +4789,10 @@ var HooksDispatcherOnMount = { var hook = mountWorkInProgressHook(); deps = void 0 === deps ? null : deps; var nextValue = nextCreate(); - shouldDoubleInvokeUserFnsInHooksDEV && nextCreate(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + nextCreate(), + setIsStrictModeForDevtools(!1)); hook.memoizedState = [nextValue, deps]; return nextValue; }, @@ -4398,7 +4800,10 @@ var HooksDispatcherOnMount = { var hook = mountWorkInProgressHook(); if (void 0 !== init) { var initialState = init(initialArg); - shouldDoubleInvokeUserFnsInHooksDEV && init(initialArg); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + init(initialArg), + setIsStrictModeForDevtools(!1)); } else initialState = initialArg; hook.memoizedState = hook.baseState = initialState; reducer = { @@ -4491,6 +4896,10 @@ var HooksDispatcherOnMount = { } }; HooksDispatcherOnMount.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnMount.useHostTransitionStatus = useHostTransitionStatus), + (HooksDispatcherOnMount.useFormState = mountFormState)); +enableAsyncActions && (HooksDispatcherOnMount.useOptimistic = mountOptimistic); var HooksDispatcherOnUpdate = { readContext: readContext, use: use, @@ -4531,6 +4940,11 @@ var HooksDispatcherOnUpdate = { }; HooksDispatcherOnUpdate.useCacheRefresh = updateRefresh; HooksDispatcherOnUpdate.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnUpdate.useHostTransitionStatus = useHostTransitionStatus), + (HooksDispatcherOnUpdate.useFormState = updateFormState)); +enableAsyncActions && + (HooksDispatcherOnUpdate.useOptimistic = updateOptimistic); var HooksDispatcherOnRerender = { readContext: readContext, use: use, @@ -4573,6 +4987,12 @@ var HooksDispatcherOnRerender = { }; HooksDispatcherOnRerender.useCacheRefresh = updateRefresh; HooksDispatcherOnRerender.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnRerender.useHostTransitionStatus = + useHostTransitionStatus), + (HooksDispatcherOnRerender.useFormState = rerenderFormState)); +enableAsyncActions && + (HooksDispatcherOnRerender.useOptimistic = rerenderOptimistic); function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = assign({}, baseProps); @@ -4728,6 +5148,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), processUpdateQueue(workInProgress, newProps, instance, renderLanes), + suspendIfUpdateReadFromEntangledAsyncAction(), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); @@ -5281,6 +5702,7 @@ function updateClassComponent( var oldState = workInProgress.memoizedState; instance.state = oldState; processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -5360,6 +5782,7 @@ function updateClassComponent( oldState = workInProgress.memoizedState; instance.state = oldState; processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); var newState = workInProgress.memoizedState; oldProps !== hasNewLifecycles || oldState !== newState || @@ -6044,7 +6467,9 @@ function attemptEarlyBailoutIfNoScheduledUpdate( case 10: pushProvider( workInProgress, - workInProgress.type._context, + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context, workInProgress.memoizedProps.value ); break; @@ -6274,7 +6699,19 @@ function releaseCache(cache) { }); } var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; -function handleAsyncAction() {} +function requestCurrentTransition() { + var transition = ReactCurrentBatchConfig$1.transition; + null !== transition && transition._callbacks.add(handleAsyncAction); + return transition; +} +function handleAsyncAction(transition, thenable) { + enableAsyncActions && entangleAsyncAction(transition, thenable); +} +function notifyTransitionCallbacks(transition, returnValue) { + transition._callbacks.forEach(function (callback) { + return callback(transition, returnValue); + }); +} var resumedCache = createCursor(null); function peekCacheFromPool() { var cacheResumedFromPreviousRender = resumedCache.current; @@ -6426,14 +6863,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$68 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$68 = lastTailNode), + for (var lastTailNode$72 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$72 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$68 + null === lastTailNode$72 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$68.sibling = null); + : (lastTailNode$72.sibling = null); } } function bubbleProperties(completedWork) { @@ -6443,19 +6880,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$69 = completedWork.child; null !== child$69; ) - (newChildLanes |= child$69.lanes | child$69.childLanes), - (subtreeFlags |= child$69.subtreeFlags & 31457280), - (subtreeFlags |= child$69.flags & 31457280), - (child$69.return = completedWork), - (child$69 = child$69.sibling); + for (var child$73 = completedWork.child; null !== child$73; ) + (newChildLanes |= child$73.lanes | child$73.childLanes), + (subtreeFlags |= child$73.subtreeFlags & 31457280), + (subtreeFlags |= child$73.flags & 31457280), + (child$73.return = completedWork), + (child$73 = child$73.sibling); else - for (child$69 = completedWork.child; null !== child$69; ) - (newChildLanes |= child$69.lanes | child$69.childLanes), - (subtreeFlags |= child$69.subtreeFlags), - (subtreeFlags |= child$69.flags), - (child$69.return = completedWork), - (child$69 = child$69.sibling); + for (child$73 = completedWork.child; null !== child$73; ) + (newChildLanes |= child$73.lanes | child$73.childLanes), + (subtreeFlags |= child$73.subtreeFlags), + (subtreeFlags |= child$73.flags), + (child$73.return = completedWork), + (child$73 = child$73.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6697,7 +7134,11 @@ function completeWork(current, workInProgress, renderLanes) { ); case 10: return ( - popProvider(workInProgress.type._context), + popProvider( + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context + ), bubbleProperties(workInProgress), null ); @@ -6889,7 +7330,14 @@ function unwindWork(current, workInProgress) { case 4: return popHostContainer(), null; case 10: - return popProvider(workInProgress.type._context), null; + return ( + popProvider( + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context + ), + null + ); case 22: case 23: return ( @@ -6936,7 +7384,11 @@ function unwindInterruptedWork(current, interruptedWork) { pop(suspenseStackCursor); break; case 10: - popProvider(interruptedWork.type._context); + popProvider( + enableRenderableContext + ? interruptedWork.type + : interruptedWork.type._context + ); break; case 22: case 23: @@ -6991,8 +7443,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$91) { - captureCommitPhaseError(current, nearestMountedAncestor, error$91); + } catch (error$95) { + captureCommitPhaseError(current, nearestMountedAncestor, error$95); } else ref.current = null; } @@ -7096,10 +7548,10 @@ function commitHookEffectListMount(flags, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & flags) === flags) { - var create$92 = effect.create, + var create$96 = effect.create, inst = effect.inst; - create$92 = create$92(); - inst.destroy = create$92; + create$96 = create$96(); + inst.destroy = create$96; } effect = effect.next; } while (effect !== finishedWork); @@ -7162,11 +7614,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$93) { + } catch (error$97) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$93 + error$97 ); } } @@ -7460,8 +7912,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$95) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$95); + } catch (error$99) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$99); } } break; @@ -8222,13 +8674,10 @@ function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 2; if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; - fiber = ReactCurrentBatchConfig$1.transition; - null !== fiber && fiber._callbacks.add(handleAsyncAction); - if (null !== fiber) + if (null !== requestCurrentTransition()) return ( - 0 === currentEventTransitionLane && - (currentEventTransitionLane = claimNextTransitionLane()), - currentEventTransitionLane + (fiber = currentEntangledLane), + 0 !== fiber ? fiber : requestTransitionLane() ); fiber = currentUpdatePriority; if (0 === fiber) @@ -8669,8 +9118,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$107) { - handleThrow(root, thrownValue$107); + } catch (thrownValue$111) { + handleThrow(root, thrownValue$111); } while (1); lanes && root.shellSuspendCounter++; @@ -8778,8 +9227,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$109) { - handleThrow(root, thrownValue$109); + } catch (thrownValue$113) { + handleThrow(root, thrownValue$113); } while (1); resetContextDependencies(); @@ -9399,6 +9848,7 @@ beginWork = function (current, workInProgress, renderLanes) { pushProvider(workInProgress, CacheContext, nextCache); nextCache !== context.cache && propagateContextChange(workInProgress, CacheContext, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); context = nextProps.element; context === Component ? (workInProgress = bailoutOnAlreadyFinishedWork( @@ -9412,13 +9862,31 @@ beginWork = function (current, workInProgress, renderLanes) { case 26: case 27: case 5: - return ( - pushHostContext(workInProgress), - (Component = workInProgress.pendingProps.children), - markRef(current, workInProgress), - reconcileChildren(current, workInProgress, Component, renderLanes), - workInProgress.child - ); + pushHostContext(workInProgress); + Component = workInProgress.pendingProps.children; + if (enableAsyncActions && null !== workInProgress.memoizedState) { + if (!enableAsyncActions) throw Error("Not implemented."); + context = renderWithHooks( + current, + workInProgress, + TransitionAwareHostComponent, + null, + null, + renderLanes + ); + HostTransitionContext._currentValue2 = context; + didReceiveUpdate && + null !== current && + current.memoizedState.memoizedState !== context && + propagateContextChange( + workInProgress, + HostTransitionContext, + renderLanes + ); + } + markRef(current, workInProgress); + reconcileChildren(current, workInProgress, Component, renderLanes); + return workInProgress.child; case 6: return null; case 13: @@ -9488,7 +9956,9 @@ beginWork = function (current, workInProgress, renderLanes) { ); case 10: a: { - Component = workInProgress.type._context; + Component = enableRenderableContext + ? workInProgress.type + : workInProgress.type._context; context = workInProgress.pendingProps; nextProps = workInProgress.memoizedProps; nextCache = context.value; @@ -9518,7 +9988,9 @@ beginWork = function (current, workInProgress, renderLanes) { return workInProgress; case 9: return ( - (context = workInProgress.type), + (context = enableRenderableContext + ? workInProgress.type._context + : workInProgress.type), (Component = workInProgress.pendingProps.children), prepareToReadContext(workInProgress, renderLanes), (context = readContext(context)), @@ -9598,7 +10070,8 @@ beginWork = function (current, workInProgress, renderLanes) { pushProvider(workInProgress, CacheContext, context)) : (0 !== (current.lanes & renderLanes) && (cloneUpdateQueue(current, workInProgress), - processUpdateQueue(workInProgress, null, null, renderLanes)), + processUpdateQueue(workInProgress, null, null, renderLanes), + suspendIfUpdateReadFromEntangledAsyncAction()), (context = current.memoizedState), (nextProps = workInProgress.memoizedState), context.parent !== Component @@ -9802,12 +10275,18 @@ function createFiberFromTypeAndProps( if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 10; - break a; + if (!enableRenderableContext) { + fiberTag = 10; + break a; + } case REACT_CONTEXT_TYPE: - fiberTag = 9; + fiberTag = enableRenderableContext ? 10 : 9; break a; case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + fiberTag = 9; + break a; + } case REACT_FORWARD_REF_TYPE: fiberTag = 11; break a; @@ -10160,10 +10639,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1143 = { + devToolsConfig$jscomp$inline_1106 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-canary-0e1fb276", + version: "18.3.0-canary-0c0f95bf", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10179,11 +10658,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1369 = { - bundleType: devToolsConfig$jscomp$inline_1143.bundleType, - version: devToolsConfig$jscomp$inline_1143.version, - rendererPackageName: devToolsConfig$jscomp$inline_1143.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1143.rendererConfig, +var internals$jscomp$inline_1333 = { + bundleType: devToolsConfig$jscomp$inline_1106.bundleType, + version: devToolsConfig$jscomp$inline_1106.version, + rendererPackageName: devToolsConfig$jscomp$inline_1106.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1106.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10199,26 +10678,26 @@ var internals$jscomp$inline_1369 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1143.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1106.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-0e1fb276" + reconcilerVersion: "18.3.0-canary-0c0f95bf" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1370 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1334 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1370.isDisabled && - hook$jscomp$inline_1370.supportsFiber + !hook$jscomp$inline_1334.isDisabled && + hook$jscomp$inline_1334.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1370.inject( - internals$jscomp$inline_1369 + (rendererID = hook$jscomp$inline_1334.inject( + internals$jscomp$inline_1333 )), - (injectedHook = hook$jscomp$inline_1370); + (injectedHook = hook$jscomp$inline_1334); } catch (err) {} } exports.createPortal = function (children, containerTag) { diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 8fc88a1ed2e56..ae1145681bc28 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<4ddef8d76b2d3d7eab303bf118ac38d7>> + * @generated SignedSource<> */ "use strict"; @@ -939,7 +939,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_271 = { +var injectedNamesToPlugins$jscomp$inline_270 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -985,32 +985,32 @@ var injectedNamesToPlugins$jscomp$inline_271 = { } } }, - isOrderingDirty$jscomp$inline_272 = !1, - pluginName$jscomp$inline_273; -for (pluginName$jscomp$inline_273 in injectedNamesToPlugins$jscomp$inline_271) + isOrderingDirty$jscomp$inline_271 = !1, + pluginName$jscomp$inline_272; +for (pluginName$jscomp$inline_272 in injectedNamesToPlugins$jscomp$inline_270) if ( - injectedNamesToPlugins$jscomp$inline_271.hasOwnProperty( - pluginName$jscomp$inline_273 + injectedNamesToPlugins$jscomp$inline_270.hasOwnProperty( + pluginName$jscomp$inline_272 ) ) { - var pluginModule$jscomp$inline_274 = - injectedNamesToPlugins$jscomp$inline_271[pluginName$jscomp$inline_273]; + var pluginModule$jscomp$inline_273 = + injectedNamesToPlugins$jscomp$inline_270[pluginName$jscomp$inline_272]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_273) || - namesToPlugins[pluginName$jscomp$inline_273] !== - pluginModule$jscomp$inline_274 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_272) || + namesToPlugins[pluginName$jscomp$inline_272] !== + pluginModule$jscomp$inline_273 ) { - if (namesToPlugins[pluginName$jscomp$inline_273]) + if (namesToPlugins[pluginName$jscomp$inline_272]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_273 + "`.") + (pluginName$jscomp$inline_272 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_273] = - pluginModule$jscomp$inline_274; - isOrderingDirty$jscomp$inline_272 = !0; + namesToPlugins[pluginName$jscomp$inline_272] = + pluginModule$jscomp$inline_273; + isOrderingDirty$jscomp$inline_271 = !0; } } -isOrderingDirty$jscomp$inline_272 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_271 && recomputePluginOrdering(); var emptyObject$1 = {}, removedKeys = null, removedKeyCount = 0, @@ -1314,17 +1314,21 @@ function dispatchEvent(target, topLevelType, nativeEvent) { }); } var alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, + consoleManagedByDevToolsDuringStrictMode = + dynamicFlags.consoleManagedByDevToolsDuringStrictMode, + enableAsyncActions = dynamicFlags.enableAsyncActions, enableComponentStackLocations = dynamicFlags.enableComponentStackLocations, enableDeferRootSchedulingToMicrotask = dynamicFlags.enableDeferRootSchedulingToMicrotask, + enableInfiniteRenderLoopDetection = + dynamicFlags.enableInfiniteRenderLoopDetection, + enableRenderableContext = dynamicFlags.enableRenderableContext, + enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, passChildrenWhenCloningPersistedNodes = dynamicFlags.passChildrenWhenCloningPersistedNodes, useMicrotasksForSchedulingInFabric = dynamicFlags.useMicrotasksForSchedulingInFabric, - enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, - enableInfiniteRenderLoopDetection = - dynamicFlags.enableInfiniteRenderLoopDetection, scheduleCallback$3 = Scheduler.unstable_scheduleCallback, cancelCallback$1 = Scheduler.unstable_cancelCallback, shouldYield = Scheduler.unstable_shouldYield, @@ -1334,6 +1338,8 @@ var alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, NormalPriority$1 = Scheduler.unstable_NormalPriority, IdlePriority = Scheduler.unstable_IdlePriority, + log$1 = Scheduler.log, + unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue, ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, rendererID = null, @@ -1368,6 +1374,17 @@ function onCommitRoot(root, eventPriority) { ); } catch (err) {} } +function setIsStrictModeForDevtools(newIsStrictMode) { + if ( + consoleManagedByDevToolsDuringStrictMode && + ("function" === typeof log$1 && + unstable_setDisableYieldValue(newIsStrictMode), + injectedHook && "function" === typeof injectedHook.setStrictMode) + ) + try { + injectedHook.setStrictMode(rendererID, newIsStrictMode); + } catch (err) {} +} function injectProfilingHooks(profilingHooks) { injectedProfilingHooks = profilingHooks; } @@ -1840,9 +1857,16 @@ function getComponentNameFromType(type) { if ("object" === typeof type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - return (type._context.displayName || "Context") + ".Provider"; + if (enableRenderableContext) break; + else return (type._context.displayName || "Context") + ".Provider"; case REACT_CONTEXT_TYPE: - return (type.displayName || "Context") + ".Consumer"; + return enableRenderableContext + ? (type.displayName || "Context") + ".Provider" + : (type.displayName || "Context") + ".Consumer"; + case REACT_CONSUMER_TYPE: + if (enableRenderableContext) + return (type._context.displayName || "Context") + ".Consumer"; + break; case REACT_FORWARD_REF_TYPE: var innerType = type.render; type = type.displayName; @@ -1872,9 +1896,13 @@ function getComponentNameFromFiber(fiber) { case 24: return "Cache"; case 9: - return (type.displayName || "Context") + ".Consumer"; + return enableRenderableContext + ? (type._context.displayName || "Context") + ".Consumer" + : (type.displayName || "Context") + ".Consumer"; case 10: - return (type._context.displayName || "Context") + ".Provider"; + return enableRenderableContext + ? (type.displayName || "Context") + ".Provider" + : (type._context.displayName || "Context") + ".Provider"; case 18: return "DehydratedFragment"; case 11: @@ -1972,36 +2000,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$10 = parentA.child; child$10; ) { - if (child$10 === a) { + for (var didFindChild = !1, child$11 = parentA.child; child$11; ) { + if (child$11 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$10 === b) { + if (child$11 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$10 = child$10.sibling; + child$11 = child$11.sibling; } if (!didFindChild) { - for (child$10 = parentB.child; child$10; ) { - if (child$10 === a) { + for (child$11 = parentB.child; child$11; ) { + if (child$11 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$10 === b) { + if (child$11 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$10 = child$10.sibling; + child$11 = child$11.sibling; } if (!didFindChild) throw Error( @@ -2135,7 +2163,16 @@ function is(x, y) { var objectIs = "function" === typeof Object.is ? Object.is : is, contextStackCursor = createCursor(null), contextFiberStackCursor = createCursor(null), - rootInstanceStackCursor = createCursor(null); + rootInstanceStackCursor = createCursor(null), + hostTransitionProviderCursor = createCursor(null), + HostTransitionContext = { + $$typeof: REACT_CONTEXT_TYPE, + _currentValue: null, + _currentValue2: null, + _threadCount: 0, + Provider: null, + Consumer: null + }; function pushHostContainer(fiber, nextRootInstance) { push(rootInstanceStackCursor, nextRootInstance); push(contextFiberStackCursor, fiber); @@ -2149,6 +2186,9 @@ function popHostContainer() { pop(rootInstanceStackCursor); } function pushHostContext(fiber) { + enableAsyncActions && + null !== fiber.memoizedState && + push(hostTransitionProviderCursor, fiber); var context = contextStackCursor.current; var JSCompiler_inline_result = fiber.type; JSCompiler_inline_result = @@ -2168,6 +2208,10 @@ function pushHostContext(fiber) { function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor), pop(contextFiberStackCursor)); + enableAsyncActions && + hostTransitionProviderCursor.current === fiber && + (pop(hostTransitionProviderCursor), + (HostTransitionContext._currentValue2 = null)); } var hydrationErrors = null, concurrentQueues = [], @@ -2208,6 +2252,10 @@ function enqueueUpdate$1(fiber, queue, update, lane) { fiber = fiber.alternate; null !== fiber && (fiber.lanes |= lane); } +function enqueueConcurrentHookUpdate(fiber, queue, update, lane) { + enqueueUpdate$1(fiber, queue, update, lane); + return getRootForUpdatedFiber(fiber); +} function enqueueConcurrentRenderForLane(fiber, lane) { enqueueUpdate$1(fiber, null, null, lane); return getRootForUpdatedFiber(fiber); @@ -2270,37 +2318,37 @@ function flushSyncWorkAcrossRoots_impl(onlyLegacy) { var didPerformSomeWork = !1; for (var root = firstScheduledRoot; null !== root; ) { if (!onlyLegacy || 0 === root.tag) { - var workInProgressRootRenderLanes$12 = workInProgressRootRenderLanes, + var workInProgressRootRenderLanes$13 = workInProgressRootRenderLanes, nextLanes = getNextLanes( root, - root === workInProgressRoot ? workInProgressRootRenderLanes$12 : 0 + root === workInProgressRoot ? workInProgressRootRenderLanes$13 : 0 ); if (0 !== (nextLanes & 3)) try { didPerformSomeWork = !0; - workInProgressRootRenderLanes$12 = root; + workInProgressRootRenderLanes$13 = root; if (0 !== (executionContext & 6)) throw Error("Should not already be working."); if (!flushPassiveEffects()) { currentUpdateIsNested = nestedUpdateScheduled; nestedUpdateScheduled = !1; var exitStatus = renderRootSync( - workInProgressRootRenderLanes$12, + workInProgressRootRenderLanes$13, nextLanes ); if ( - 0 !== workInProgressRootRenderLanes$12.tag && + 0 !== workInProgressRootRenderLanes$13.tag && 2 === exitStatus ) { var originallyAttemptedLanes = nextLanes, errorRetryLanes = getLanesToRetrySynchronouslyOnError( - workInProgressRootRenderLanes$12, + workInProgressRootRenderLanes$13, originallyAttemptedLanes ); 0 !== errorRetryLanes && ((nextLanes = errorRetryLanes), (exitStatus = recoverFromConcurrentError( - workInProgressRootRenderLanes$12, + workInProgressRootRenderLanes$13, originallyAttemptedLanes, errorRetryLanes ))); @@ -2308,34 +2356,34 @@ function flushSyncWorkAcrossRoots_impl(onlyLegacy) { if (1 === exitStatus) throw ( ((originallyAttemptedLanes = workInProgressRootFatalError), - prepareFreshStack(workInProgressRootRenderLanes$12, 0), + prepareFreshStack(workInProgressRootRenderLanes$13, 0), markRootSuspended( - workInProgressRootRenderLanes$12, + workInProgressRootRenderLanes$13, nextLanes, 0 ), - ensureRootIsScheduled(workInProgressRootRenderLanes$12), + ensureRootIsScheduled(workInProgressRootRenderLanes$13), originallyAttemptedLanes) ); 6 === exitStatus ? markRootSuspended( - workInProgressRootRenderLanes$12, + workInProgressRootRenderLanes$13, nextLanes, workInProgressDeferredLane ) - : ((workInProgressRootRenderLanes$12.finishedWork = - workInProgressRootRenderLanes$12.current.alternate), - (workInProgressRootRenderLanes$12.finishedLanes = + : ((workInProgressRootRenderLanes$13.finishedWork = + workInProgressRootRenderLanes$13.current.alternate), + (workInProgressRootRenderLanes$13.finishedLanes = nextLanes), commitRoot( - workInProgressRootRenderLanes$12, + workInProgressRootRenderLanes$13, workInProgressRootRecoverableErrors, workInProgressTransitions, workInProgressRootDidIncludeRecursiveRenderUpdate, workInProgressDeferredLane )); } - ensureRootIsScheduled(workInProgressRootRenderLanes$12); + ensureRootIsScheduled(workInProgressRootRenderLanes$13); } catch (error) { null === errors ? (errors = [error]) : errors.push(error); } @@ -2458,6 +2506,71 @@ function scheduleImmediateTask(cb) { }) : scheduleCallback$3(ImmediatePriority, cb); } +function requestTransitionLane() { + 0 === currentEventTransitionLane && + (currentEventTransitionLane = claimNextTransitionLane()); + return currentEventTransitionLane; +} +var currentEntangledListeners = null, + currentEntangledPendingCount = 0, + currentEntangledLane = 0, + currentEntangledActionThenable = null; +function entangleAsyncAction(transition, thenable) { + if (null === currentEntangledListeners) { + var entangledListeners = (currentEntangledListeners = []); + currentEntangledPendingCount = 0; + currentEntangledLane = requestTransitionLane(); + currentEntangledActionThenable = { + status: "pending", + value: void 0, + then: function (resolve) { + entangledListeners.push(resolve); + } + }; + } + currentEntangledPendingCount++; + thenable.then(pingEngtangledActionScope, pingEngtangledActionScope); + return thenable; +} +function pingEngtangledActionScope() { + if ( + null !== currentEntangledListeners && + 0 === --currentEntangledPendingCount + ) { + null !== currentEntangledActionThenable && + (currentEntangledActionThenable.status = "fulfilled"); + var listeners = currentEntangledListeners; + currentEntangledListeners = null; + currentEntangledLane = 0; + currentEntangledActionThenable = null; + for (var i = 0; i < listeners.length; i++) (0, listeners[i])(); + } +} +function chainThenableValue(thenable, result) { + var listeners = [], + thenableWithOverride = { + status: "pending", + value: null, + reason: null, + then: function (resolve) { + listeners.push(resolve); + } + }; + thenable.then( + function () { + thenableWithOverride.status = "fulfilled"; + thenableWithOverride.value = result; + for (var i = 0; i < listeners.length; i++) (0, listeners[i])(result); + }, + function (error) { + thenableWithOverride.status = "rejected"; + thenableWithOverride.reason = error; + for (error = 0; error < listeners.length; error++) + (0, listeners[error])(void 0); + } + ); + return thenableWithOverride; +} var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { @@ -2553,12 +2666,20 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { : (workInProgress.next = capturedUpdate); queue.lastBaseUpdate = capturedUpdate; } +var didReadFromEntangledAsyncAction = !1; +function suspendIfUpdateReadFromEntangledAsyncAction() { + if (didReadFromEntangledAsyncAction) { + var entangledActionThenable = currentEntangledActionThenable; + if (null !== entangledActionThenable) throw entangledActionThenable; + } +} function processUpdateQueue( workInProgress$jscomp$0, props, instance$jscomp$0, renderLanes ) { + didReadFromEntangledAsyncAction = !1; var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; var firstBaseUpdate = queue.firstBaseUpdate, @@ -2596,6 +2717,9 @@ function processUpdateQueue( ? (workInProgressRootRenderLanes & updateLane) === updateLane : (renderLanes & updateLane) === updateLane ) { + 0 !== updateLane && + updateLane === currentEntangledLane && + (didReadFromEntangledAsyncAction = !0); null !== current && (current = current.next = { @@ -2759,16 +2883,16 @@ function describeNativeComponentFrame(fn, construct) { } else { try { Fake.call(); - } catch (x$18) { - control = x$18; + } catch (x$19) { + control = x$19; } fn.call(Fake.prototype); } } else { try { throw Error(); - } catch (x$19) { - control = x$19; + } catch (x$20) { + control = x$20; } (Fake = fn()) && "function" === typeof Fake.catch && @@ -3896,6 +4020,13 @@ function renderWithHooksAgain(workInProgress, Component, props, secondArg) { } while (didScheduleRenderPhaseUpdateDuringThisPass); return children; } +function TransitionAwareHostComponent() { + if (!enableAsyncActions) throw Error("Not implemented."); + var maybeThenable = ReactCurrentDispatcher$1.current.useState()[0]; + return "function" === typeof maybeThenable.then + ? useThenable(maybeThenable) + : maybeThenable; +} function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; workInProgress.flags &= -2053; @@ -4030,9 +4161,11 @@ function basicStateReducer(state, action) { return "function" === typeof action ? action(state) : action; } function updateReducer(reducer) { - var hook = updateWorkInProgressHook(), - current = currentHook, - queue = hook.queue; + var hook = updateWorkInProgressHook(); + return updateReducerImpl(hook, currentHook, reducer); +} +function updateReducerImpl(hook, current, reducer) { + var queue = hook.queue; if (null === queue) throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." @@ -4055,52 +4188,83 @@ function updateReducer(reducer) { current = baseQueue.next; var newBaseQueueFirst = (baseFirst = null), newBaseQueueLast = null, - update = current; + update = current, + didReadFromEntangledAsyncAction$34 = !1; do { var updateLane = update.lane & -536870913; if ( updateLane !== update.lane ? (workInProgressRootRenderLanes & updateLane) === updateLane : (renderLanes & updateLane) === updateLane - ) - null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = - { + ) { + var revertLane = update.revertLane; + if (enableAsyncActions && 0 !== revertLane) + if ((renderLanes & revertLane) === revertLane) { + update = update.next; + revertLane === currentEntangledLane && + (didReadFromEntangledAsyncAction$34 = !0); + continue; + } else + (updateLane = { lane: 0, - revertLane: 0, + revertLane: update.revertLane, action: update.action, hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }), - (updateLane = update.action), - shouldDoubleInvokeUserFnsInHooksDEV && - reducer(pendingQueue, updateLane), - (pendingQueue = update.hasEagerState - ? update.eagerState - : reducer(pendingQueue, updateLane)); - else { - var clone = { + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = updateLane), + (baseFirst = pendingQueue)) + : (newBaseQueueLast = newBaseQueueLast.next = updateLane), + (currentlyRenderingFiber$1.lanes |= revertLane), + (workInProgressRootSkippedLanes |= revertLane); + else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = + { + lane: 0, + revertLane: 0, + action: update.action, + hasEagerState: update.hasEagerState, + eagerState: update.eagerState, + next: null + }), + updateLane === currentEntangledLane && + (didReadFromEntangledAsyncAction$34 = !0); + updateLane = update.action; + shouldDoubleInvokeUserFnsInHooksDEV && + reducer(pendingQueue, updateLane); + pendingQueue = update.hasEagerState + ? update.eagerState + : reducer(pendingQueue, updateLane); + } else + (revertLane = { lane: updateLane, revertLane: update.revertLane, action: update.action, hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null - }; - null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (baseFirst = pendingQueue)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - currentlyRenderingFiber$1.lanes |= updateLane; - workInProgressRootSkippedLanes |= updateLane; - } + }), + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = revertLane), + (baseFirst = pendingQueue)) + : (newBaseQueueLast = newBaseQueueLast.next = revertLane), + (currentlyRenderingFiber$1.lanes |= updateLane), + (workInProgressRootSkippedLanes |= updateLane); update = update.next; } while (null !== update && update !== current); null === newBaseQueueLast ? (baseFirst = pendingQueue) : (newBaseQueueLast.next = newBaseQueueFirst); - objectIs(pendingQueue, hook.memoizedState) || (didReceiveUpdate = !0); + if ( + !objectIs(pendingQueue, hook.memoizedState) && + ((didReceiveUpdate = !0), + didReadFromEntangledAsyncAction$34 && + ((reducer = currentEntangledActionThenable), null !== reducer)) + ) + throw reducer; hook.memoizedState = pendingQueue; hook.baseState = baseFirst; hook.baseQueue = newBaseQueueLast; @@ -4209,7 +4373,10 @@ function mountStateImpl(initialState) { if ("function" === typeof initialState) { var initialStateInitializer = initialState; initialState = initialStateInitializer(); - shouldDoubleInvokeUserFnsInHooksDEV && initialStateInitializer(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + initialStateInitializer(), + setIsStrictModeForDevtools(!1)); } hook.memoizedState = hook.baseState = initialState; hook.queue = { @@ -4221,6 +4388,180 @@ function mountStateImpl(initialState) { }; return hook; } +function mountOptimistic(passthrough) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = hook.baseState = passthrough; + var queue = { + pending: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: null, + lastRenderedState: null + }; + hook.queue = queue; + hook = dispatchOptimisticSetState.bind( + null, + currentlyRenderingFiber$1, + !0, + queue + ); + queue.dispatch = hook; + return [passthrough, hook]; +} +function updateOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); +} +function updateOptimisticImpl(hook, current, passthrough, reducer) { + hook.baseState = passthrough; + return updateReducerImpl( + hook, + currentHook, + "function" === typeof reducer ? reducer : basicStateReducer + ); +} +function rerenderOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + if (null !== currentHook) + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + hook.baseState = passthrough; + return [passthrough, hook.queue.dispatch]; +} +function dispatchFormState(fiber, actionQueue, setState, payload) { + if (isRenderPhaseUpdate(fiber)) + throw Error("Cannot update form state while rendering."); + fiber = actionQueue.pending; + null === fiber + ? ((fiber = { payload: payload, next: null }), + (fiber.next = actionQueue.pending = fiber), + runFormStateAction(actionQueue, setState, payload)) + : (actionQueue.pending = fiber.next = + { payload: payload, next: fiber.next }); +} +function runFormStateAction(actionQueue, setState, payload) { + var action = actionQueue.action, + prevState = actionQueue.state, + prevTransition = ReactCurrentBatchConfig$2.transition, + currentTransition = { _callbacks: new Set() }; + ReactCurrentBatchConfig$2.transition = currentTransition; + try { + var returnValue = action(prevState, payload); + null !== returnValue && + "object" === typeof returnValue && + "function" === typeof returnValue.then + ? (notifyTransitionCallbacks(currentTransition, returnValue), + returnValue.then( + function (nextState) { + actionQueue.state = nextState; + finishRunningFormStateAction(actionQueue, setState); + }, + function () { + return finishRunningFormStateAction(actionQueue, setState); + } + ), + setState(returnValue)) + : (setState(returnValue), + (actionQueue.state = returnValue), + finishRunningFormStateAction(actionQueue, setState)); + } catch (error) { + setState({ then: function () {}, status: "rejected", reason: error }), + finishRunningFormStateAction(actionQueue, setState); + } finally { + ReactCurrentBatchConfig$2.transition = prevTransition; + } +} +function finishRunningFormStateAction(actionQueue, setState) { + var last = actionQueue.pending; + if (null !== last) { + var first = last.next; + first === last + ? (actionQueue.pending = null) + : ((first = first.next), + (last.next = first), + runFormStateAction(actionQueue, setState, first.payload)); + } +} +function formStateReducer(oldState, newState) { + return newState; +} +function mountFormState(action, initialStateProp) { + var stateHook = mountWorkInProgressHook(); + stateHook.memoizedState = stateHook.baseState = initialStateProp; + var stateQueue = { + pending: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: formStateReducer, + lastRenderedState: initialStateProp + }; + stateHook.queue = stateQueue; + stateHook = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + stateQueue + ); + stateQueue.dispatch = stateHook; + stateQueue = mountWorkInProgressHook(); + var actionQueue = { + state: initialStateProp, + dispatch: null, + action: action, + pending: null + }; + stateQueue.queue = actionQueue; + stateHook = dispatchFormState.bind( + null, + currentlyRenderingFiber$1, + actionQueue, + stateHook + ); + actionQueue.dispatch = stateHook; + stateQueue.memoizedState = action; + return [initialStateProp, stateHook]; +} +function updateFormState(action) { + var stateHook = updateWorkInProgressHook(); + return updateFormStateImpl(stateHook, currentHook, action); +} +function updateFormStateImpl(stateHook, currentStateHook, action) { + stateHook = updateReducerImpl( + stateHook, + currentStateHook, + formStateReducer + )[0]; + stateHook = + "object" === typeof stateHook && + null !== stateHook && + "function" === typeof stateHook.then + ? useThenable(stateHook) + : stateHook; + currentStateHook = updateWorkInProgressHook(); + var actionQueue = currentStateHook.queue, + dispatch = actionQueue.dispatch; + action !== currentStateHook.memoizedState && + ((currentlyRenderingFiber$1.flags |= 2048), + pushEffect( + 9, + formStateActionEffect.bind(null, actionQueue, action), + { destroy: void 0 }, + null + )); + return [stateHook, dispatch]; +} +function formStateActionEffect(actionQueue, action) { + actionQueue.action = action; +} +function rerenderFormState(action) { + var stateHook = updateWorkInProgressHook(), + currentStateHook = currentHook; + if (null !== currentStateHook) + return updateFormStateImpl(stateHook, currentStateHook, action); + stateHook = stateHook.memoizedState; + currentStateHook = updateWorkInProgressHook(); + var dispatch = currentStateHook.queue.dispatch; + currentStateHook.memoizedState = action; + return [stateHook, dispatch]; +} function pushEffect(tag, create, inst, deps) { tag = { tag: tag, create: create, inst: inst, deps: deps, next: null }; create = currentlyRenderingFiber$1.updateQueue; @@ -4312,7 +4653,10 @@ function updateMemo(nextCreate, deps) { if (null !== deps && areHookInputsEqual(deps, prevState[1])) return prevState[0]; prevState = nextCreate(); - shouldDoubleInvokeUserFnsInHooksDEV && nextCreate(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + nextCreate(), + setIsStrictModeForDevtools(!1)); hook.memoizedState = [prevState, deps]; return prevState; } @@ -4346,18 +4690,46 @@ function startTransition(fiber, queue, pendingState, finishedState, callback) { 0 !== previousPriority && 8 > previousPriority ? previousPriority : 8; var prevTransition = ReactCurrentBatchConfig$2.transition, currentTransition = { _callbacks: new Set() }; - ReactCurrentBatchConfig$2.transition = null; - dispatchSetState(fiber, queue, pendingState); - ReactCurrentBatchConfig$2.transition = currentTransition; + enableAsyncActions + ? ((ReactCurrentBatchConfig$2.transition = currentTransition), + dispatchOptimisticSetState(fiber, !1, queue, pendingState)) + : ((ReactCurrentBatchConfig$2.transition = null), + dispatchSetState(fiber, queue, pendingState), + (ReactCurrentBatchConfig$2.transition = currentTransition)); try { - dispatchSetState(fiber, queue, finishedState), callback(); + if (enableAsyncActions) { + var returnValue = callback(); + if ( + null !== returnValue && + "object" === typeof returnValue && + "function" === typeof returnValue.then + ) { + notifyTransitionCallbacks(currentTransition, returnValue); + var thenableForFinishedState = chainThenableValue( + returnValue, + finishedState + ); + dispatchSetState(fiber, queue, thenableForFinishedState); + } else dispatchSetState(fiber, queue, finishedState); + } else dispatchSetState(fiber, queue, finishedState), callback(); } catch (error) { - throw error; + if (enableAsyncActions) + dispatchSetState(fiber, queue, { + then: function () {}, + status: "rejected", + reason: error + }); + else throw error; } finally { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$2.transition = prevTransition); } } +function useHostTransitionStatus() { + if (!enableAsyncActions) throw Error("Not implemented."); + var status = readContext(HostTransitionContext); + return null !== status ? status : null; +} function updateId() { return updateWorkInProgressHook().memoizedState; } @@ -4394,8 +4766,7 @@ function dispatchReducerAction(fiber, queue, action) { }; isRenderPhaseUpdate(fiber) ? enqueueRenderPhaseUpdate(queue, action) - : (enqueueUpdate$1(fiber, queue, action, lane), - (action = getRootForUpdatedFiber(fiber)), + : ((action = enqueueConcurrentHookUpdate(fiber, queue, action, lane)), null !== action && (scheduleUpdateOnFiber(action, fiber, lane), entangleTransitionUpdate(action, queue, lane))); @@ -4432,14 +4803,37 @@ function dispatchSetState(fiber, queue, action) { } catch (error) { } finally { } - enqueueUpdate$1(fiber, queue, update, lane); - action = getRootForUpdatedFiber(fiber); + action = enqueueConcurrentHookUpdate(fiber, queue, update, lane); null !== action && (scheduleUpdateOnFiber(action, fiber, lane), entangleTransitionUpdate(action, queue, lane)); } markStateUpdateScheduled(fiber, lane); } +function dispatchOptimisticSetState(fiber, throwIfDuringRender, queue, action) { + requestCurrentTransition(); + action = { + lane: 2, + revertLane: requestTransitionLane(), + action: action, + hasEagerState: !1, + eagerState: null, + next: null + }; + if (isRenderPhaseUpdate(fiber)) { + if (throwIfDuringRender) + throw Error("Cannot update optimistic state while rendering."); + } else + (throwIfDuringRender = enqueueConcurrentHookUpdate( + fiber, + queue, + action, + 2 + )), + null !== throwIfDuringRender && + scheduleUpdateOnFiber(throwIfDuringRender, fiber, 2); + markStateUpdateScheduled(fiber, 2); +} function isRenderPhaseUpdate(fiber) { var alternate = fiber.alternate; return ( @@ -4486,6 +4880,11 @@ var ContextOnlyDispatcher = { }; ContextOnlyDispatcher.useCacheRefresh = throwInvalidHookError; ContextOnlyDispatcher.useMemoCache = throwInvalidHookError; +enableAsyncActions && + ((ContextOnlyDispatcher.useHostTransitionStatus = throwInvalidHookError), + (ContextOnlyDispatcher.useFormState = throwInvalidHookError)); +enableAsyncActions && + (ContextOnlyDispatcher.useOptimistic = throwInvalidHookError); var HooksDispatcherOnMount = { readContext: readContext, use: use, @@ -4517,7 +4916,10 @@ var HooksDispatcherOnMount = { var hook = mountWorkInProgressHook(); deps = void 0 === deps ? null : deps; var nextValue = nextCreate(); - shouldDoubleInvokeUserFnsInHooksDEV && nextCreate(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + nextCreate(), + setIsStrictModeForDevtools(!1)); hook.memoizedState = [nextValue, deps]; return nextValue; }, @@ -4525,7 +4927,10 @@ var HooksDispatcherOnMount = { var hook = mountWorkInProgressHook(); if (void 0 !== init) { var initialState = init(initialArg); - shouldDoubleInvokeUserFnsInHooksDEV && init(initialArg); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + init(initialArg), + setIsStrictModeForDevtools(!1)); } else initialState = initialArg; hook.memoizedState = hook.baseState = initialState; reducer = { @@ -4618,6 +5023,10 @@ var HooksDispatcherOnMount = { } }; HooksDispatcherOnMount.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnMount.useHostTransitionStatus = useHostTransitionStatus), + (HooksDispatcherOnMount.useFormState = mountFormState)); +enableAsyncActions && (HooksDispatcherOnMount.useOptimistic = mountOptimistic); var HooksDispatcherOnUpdate = { readContext: readContext, use: use, @@ -4658,6 +5067,11 @@ var HooksDispatcherOnUpdate = { }; HooksDispatcherOnUpdate.useCacheRefresh = updateRefresh; HooksDispatcherOnUpdate.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnUpdate.useHostTransitionStatus = useHostTransitionStatus), + (HooksDispatcherOnUpdate.useFormState = updateFormState)); +enableAsyncActions && + (HooksDispatcherOnUpdate.useOptimistic = updateOptimistic); var HooksDispatcherOnRerender = { readContext: readContext, use: use, @@ -4700,6 +5114,12 @@ var HooksDispatcherOnRerender = { }; HooksDispatcherOnRerender.useCacheRefresh = updateRefresh; HooksDispatcherOnRerender.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnRerender.useHostTransitionStatus = + useHostTransitionStatus), + (HooksDispatcherOnRerender.useFormState = rerenderFormState)); +enableAsyncActions && + (HooksDispatcherOnRerender.useOptimistic = rerenderOptimistic); var now = Scheduler.unstable_now, commitTime = 0, layoutEffectStartTime = -1, @@ -4922,6 +5342,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), processUpdateQueue(workInProgress, newProps, instance, renderLanes), + suspendIfUpdateReadFromEntangledAsyncAction(), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); @@ -5482,6 +5903,7 @@ function updateClassComponent( var oldState = workInProgress.memoizedState; instance.state = oldState; processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -5561,6 +5983,7 @@ function updateClassComponent( oldState = workInProgress.memoizedState; instance.state = oldState; processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); var newState = workInProgress.memoizedState; oldProps !== hasNewLifecycles || oldState !== newState || @@ -6263,7 +6686,9 @@ function attemptEarlyBailoutIfNoScheduledUpdate( case 10: pushProvider( workInProgress, - workInProgress.type._context, + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context, workInProgress.memoizedProps.value ); break; @@ -6500,7 +6925,19 @@ function releaseCache(cache) { }); } var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; -function handleAsyncAction() {} +function requestCurrentTransition() { + var transition = ReactCurrentBatchConfig$1.transition; + null !== transition && transition._callbacks.add(handleAsyncAction); + return transition; +} +function handleAsyncAction(transition, thenable) { + enableAsyncActions && entangleAsyncAction(transition, thenable); +} +function notifyTransitionCallbacks(transition, returnValue) { + transition._callbacks.forEach(function (callback) { + return callback(transition, returnValue); + }); +} var resumedCache = createCursor(null); function peekCacheFromPool() { var cacheResumedFromPreviousRender = resumedCache.current; @@ -6652,14 +7089,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$72 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$72 = lastTailNode), + for (var lastTailNode$76 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$76 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$72 + null === lastTailNode$76 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$72.sibling = null); + : (lastTailNode$76.sibling = null); } } function bubbleProperties(completedWork) { @@ -6671,53 +7108,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$74 = completedWork.selfBaseDuration, - child$75 = completedWork.child; - null !== child$75; + var treeBaseDuration$78 = completedWork.selfBaseDuration, + child$79 = completedWork.child; + null !== child$79; ) - (newChildLanes |= child$75.lanes | child$75.childLanes), - (subtreeFlags |= child$75.subtreeFlags & 31457280), - (subtreeFlags |= child$75.flags & 31457280), - (treeBaseDuration$74 += child$75.treeBaseDuration), - (child$75 = child$75.sibling); - completedWork.treeBaseDuration = treeBaseDuration$74; + (newChildLanes |= child$79.lanes | child$79.childLanes), + (subtreeFlags |= child$79.subtreeFlags & 31457280), + (subtreeFlags |= child$79.flags & 31457280), + (treeBaseDuration$78 += child$79.treeBaseDuration), + (child$79 = child$79.sibling); + completedWork.treeBaseDuration = treeBaseDuration$78; } else for ( - treeBaseDuration$74 = completedWork.child; - null !== treeBaseDuration$74; + treeBaseDuration$78 = completedWork.child; + null !== treeBaseDuration$78; ) (newChildLanes |= - treeBaseDuration$74.lanes | treeBaseDuration$74.childLanes), - (subtreeFlags |= treeBaseDuration$74.subtreeFlags & 31457280), - (subtreeFlags |= treeBaseDuration$74.flags & 31457280), - (treeBaseDuration$74.return = completedWork), - (treeBaseDuration$74 = treeBaseDuration$74.sibling); + treeBaseDuration$78.lanes | treeBaseDuration$78.childLanes), + (subtreeFlags |= treeBaseDuration$78.subtreeFlags & 31457280), + (subtreeFlags |= treeBaseDuration$78.flags & 31457280), + (treeBaseDuration$78.return = completedWork), + (treeBaseDuration$78 = treeBaseDuration$78.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$74 = completedWork.actualDuration; - child$75 = completedWork.selfBaseDuration; + treeBaseDuration$78 = completedWork.actualDuration; + child$79 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$74 += child.actualDuration), - (child$75 += child.treeBaseDuration), + (treeBaseDuration$78 += child.actualDuration), + (child$79 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$74; - completedWork.treeBaseDuration = child$75; + completedWork.actualDuration = treeBaseDuration$78; + completedWork.treeBaseDuration = child$79; } else for ( - treeBaseDuration$74 = completedWork.child; - null !== treeBaseDuration$74; + treeBaseDuration$78 = completedWork.child; + null !== treeBaseDuration$78; ) (newChildLanes |= - treeBaseDuration$74.lanes | treeBaseDuration$74.childLanes), - (subtreeFlags |= treeBaseDuration$74.subtreeFlags), - (subtreeFlags |= treeBaseDuration$74.flags), - (treeBaseDuration$74.return = completedWork), - (treeBaseDuration$74 = treeBaseDuration$74.sibling); + treeBaseDuration$78.lanes | treeBaseDuration$78.childLanes), + (subtreeFlags |= treeBaseDuration$78.subtreeFlags), + (subtreeFlags |= treeBaseDuration$78.flags), + (treeBaseDuration$78.return = completedWork), + (treeBaseDuration$78 = treeBaseDuration$78.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6974,7 +7411,11 @@ function completeWork(current, workInProgress, renderLanes) { ); case 10: return ( - popProvider(workInProgress.type._context), + popProvider( + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context + ), bubbleProperties(workInProgress), null ); @@ -7172,7 +7613,14 @@ function unwindWork(current, workInProgress) { case 4: return popHostContainer(), null; case 10: - return popProvider(workInProgress.type._context), null; + return ( + popProvider( + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context + ), + null + ); case 22: case 23: return ( @@ -7222,7 +7670,11 @@ function unwindInterruptedWork(current, interruptedWork) { pop(suspenseStackCursor); break; case 10: - popProvider(interruptedWork.type._context); + popProvider( + enableRenderableContext + ? interruptedWork.type + : interruptedWork.type._context + ); break; case 22: case 23: @@ -7311,8 +7763,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (error$100) { - captureCommitPhaseError(current, nearestMountedAncestor, error$100); + } catch (error$104) { + captureCommitPhaseError(current, nearestMountedAncestor, error$104); } else ref.current = null; } @@ -7445,10 +7897,10 @@ function commitHookEffectListMount(flags, finishedWork) { injectedProfilingHooks.markComponentLayoutEffectMountStarted( finishedWork ); - var create$101 = effect.create, + var create$105 = effect.create, inst = effect.inst; - create$101 = create$101(); - inst.destroy = create$101; + create$105 = create$105(); + inst.destroy = create$105; 0 !== (flags & 8) ? null !== injectedProfilingHooks && "function" === @@ -7476,8 +7928,8 @@ function commitHookLayoutEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$103) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$103); + } catch (error$107) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$107); } } function commitClassCallbacks(finishedWork) { @@ -7566,11 +8018,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { } else try { finishedRoot.componentDidMount(); - } catch (error$104) { + } catch (error$108) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$104 + error$108 ); } else { @@ -7587,11 +8039,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$105) { + } catch (error$109) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$105 + error$109 ); } recordLayoutEffectDuration(finishedWork); @@ -7602,11 +8054,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$106) { + } catch (error$110) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$106 + error$110 ); } } @@ -7927,22 +8379,22 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { startLayoutEffectTimer(), commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$109) { + } catch (error$113) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$109 + error$113 ); } recordLayoutEffectDuration(finishedWork); } else try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$110) { + } catch (error$114) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$110 + error$114 ); } } @@ -8239,8 +8691,8 @@ function commitHookPassiveMountEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$118) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$118); + } catch (error$122) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$122); } } function commitOffscreenPassiveMountEffects(current, finishedWork) { @@ -8746,13 +9198,10 @@ function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 2; if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; - fiber = ReactCurrentBatchConfig$1.transition; - null !== fiber && fiber._callbacks.add(handleAsyncAction); - if (null !== fiber) + if (null !== requestCurrentTransition()) return ( - 0 === currentEventTransitionLane && - (currentEventTransitionLane = claimNextTransitionLane()), - currentEventTransitionLane + (fiber = currentEntangledLane), + 0 !== fiber ? fiber : requestTransitionLane() ); fiber = currentUpdatePriority; if (0 === fiber) @@ -9233,8 +9682,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$123) { - handleThrow(root, thrownValue$123); + } catch (thrownValue$127) { + handleThrow(root, thrownValue$127); } while (1); lanes && root.shellSuspendCounter++; @@ -9353,8 +9802,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$125) { - handleThrow(root, thrownValue$125); + } catch (thrownValue$129) { + handleThrow(root, thrownValue$129); } while (1); resetContextDependencies(); @@ -9725,7 +10174,7 @@ function flushPassiveEffects() { _finishedWork$memoize = finishedWork.memoizedProps, id = _finishedWork$memoize.id, onPostCommit = _finishedWork$memoize.onPostCommit, - commitTime$102 = commitTime, + commitTime$106 = commitTime, phase = null === finishedWork.alternate ? "mount" : "update"; currentUpdateIsNested && (phase = "nested-update"); "function" === typeof onPostCommit && @@ -9733,7 +10182,7 @@ function flushPassiveEffects() { id, phase, passiveEffectDuration, - commitTime$102 + commitTime$106 ); var parentFiber = finishedWork.return; b: for (; null !== parentFiber; ) { @@ -10074,6 +10523,7 @@ beginWork = function (current, workInProgress, renderLanes) { pushProvider(workInProgress, CacheContext, nextCache); nextCache !== context.cache && propagateContextChange(workInProgress, CacheContext, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); context = nextProps.element; context === Component ? (workInProgress = bailoutOnAlreadyFinishedWork( @@ -10087,13 +10537,31 @@ beginWork = function (current, workInProgress, renderLanes) { case 26: case 27: case 5: - return ( - pushHostContext(workInProgress), - (Component = workInProgress.pendingProps.children), - markRef(current, workInProgress), - reconcileChildren(current, workInProgress, Component, renderLanes), - workInProgress.child - ); + pushHostContext(workInProgress); + Component = workInProgress.pendingProps.children; + if (enableAsyncActions && null !== workInProgress.memoizedState) { + if (!enableAsyncActions) throw Error("Not implemented."); + context = renderWithHooks( + current, + workInProgress, + TransitionAwareHostComponent, + null, + null, + renderLanes + ); + HostTransitionContext._currentValue2 = context; + didReceiveUpdate && + null !== current && + current.memoizedState.memoizedState !== context && + propagateContextChange( + workInProgress, + HostTransitionContext, + renderLanes + ); + } + markRef(current, workInProgress); + reconcileChildren(current, workInProgress, Component, renderLanes); + return workInProgress.child; case 6: return null; case 13: @@ -10167,7 +10635,9 @@ beginWork = function (current, workInProgress, renderLanes) { ); case 10: a: { - Component = workInProgress.type._context; + Component = enableRenderableContext + ? workInProgress.type + : workInProgress.type._context; context = workInProgress.pendingProps; nextProps = workInProgress.memoizedProps; nextCache = context.value; @@ -10197,7 +10667,9 @@ beginWork = function (current, workInProgress, renderLanes) { return workInProgress; case 9: return ( - (context = workInProgress.type), + (context = enableRenderableContext + ? workInProgress.type._context + : workInProgress.type), (Component = workInProgress.pendingProps.children), prepareToReadContext(workInProgress, renderLanes), (context = readContext(context)), @@ -10279,7 +10751,8 @@ beginWork = function (current, workInProgress, renderLanes) { pushProvider(workInProgress, CacheContext, context)) : (0 !== (current.lanes & renderLanes) && (cloneUpdateQueue(current, workInProgress), - processUpdateQueue(workInProgress, null, null, renderLanes)), + processUpdateQueue(workInProgress, null, null, renderLanes), + suspendIfUpdateReadFromEntangledAsyncAction()), (context = current.memoizedState), (nextProps = workInProgress.memoizedState), context.parent !== Component @@ -10501,12 +10974,18 @@ function createFiberFromTypeAndProps( if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 10; - break a; + if (!enableRenderableContext) { + fiberTag = 10; + break a; + } case REACT_CONTEXT_TYPE: - fiberTag = 9; + fiberTag = enableRenderableContext ? 10 : 9; break a; case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + fiberTag = 9; + break a; + } case REACT_FORWARD_REF_TYPE: fiberTag = 11; break a; @@ -10866,10 +11345,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1220 = { + devToolsConfig$jscomp$inline_1187 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-canary-240f597a", + version: "18.3.0-canary-ad533779", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10899,10 +11378,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1220.bundleType, - version: devToolsConfig$jscomp$inline_1220.version, - rendererPackageName: devToolsConfig$jscomp$inline_1220.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1220.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1187.bundleType, + version: devToolsConfig$jscomp$inline_1187.version, + rendererPackageName: devToolsConfig$jscomp$inline_1187.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1187.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10918,14 +11397,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1220.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1187.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-240f597a" + reconcilerVersion: "18.3.0-canary-ad533779" }); exports.createPortal = function (children, containerTag) { return createPortal$1( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 5b777c8076104..bedfd1c788395 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<1ea7fc22c471105831f871779387cf21>> + * @generated SignedSource<> */ "use strict"; @@ -33,6 +33,12 @@ if (__DEV__) { var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + var suppressWarning = false; + function setSuppressWarning(newSuppressWarning) { + { + suppressWarning = newSuppressWarning; + } + } // In DEV, calls to console.warn and console.error get replaced // by calls to these methods by a Babel plugin. // // In PROD (or in packages without access to React internals), @@ -40,7 +46,7 @@ if (__DEV__) { function warn(format) { { - { + if (!suppressWarning) { for ( var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), @@ -57,7 +63,7 @@ if (__DEV__) { } function error(format) { { - { + if (!suppressWarning) { for ( var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), @@ -2940,14 +2946,19 @@ to return true:wantsResponderID| | // the exports object every time a flag is read. var alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, + consoleManagedByDevToolsDuringStrictMode = + dynamicFlags.consoleManagedByDevToolsDuringStrictMode, + enableAsyncActions = dynamicFlags.enableAsyncActions, enableComponentStackLocations = dynamicFlags.enableComponentStackLocations, enableDeferRootSchedulingToMicrotask = dynamicFlags.enableDeferRootSchedulingToMicrotask, - enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, - enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, enableInfiniteRenderLoopDetection = - dynamicFlags.enableInfiniteRenderLoopDetection; // The rest of the flags are static for better dead code elimination. + dynamicFlags.enableInfiniteRenderLoopDetection, + enableRenderableContext = dynamicFlags.enableRenderableContext, + enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, + enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, + useModernStrictMode = dynamicFlags.useModernStrictMode; // The rest of the flags are static for better dead code elimination. var enableSchedulingProfiler = true; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; @@ -2956,7 +2967,6 @@ to return true:wantsResponderID| | var transitionLaneExpirationMs = 5000; var enableLazyContextPropagation = false; var enableLegacyHidden = false; - var enableAsyncActions = false; var enableBigIntSupport = false; // Flow magic to verify the exports of this file match the original version. // ATTENTION @@ -3075,21 +3085,30 @@ to return true:wantsResponderID| | } switch (type.$$typeof) { - case REACT_PROVIDER_TYPE: { - var provider = type; - return getContextName$1(provider._context) + ".Provider"; - } + case REACT_PROVIDER_TYPE: + if (enableRenderableContext) { + return null; + } else { + var provider = type; + return getContextName$1(provider._context) + ".Provider"; + } case REACT_CONTEXT_TYPE: var context = type; - { + if (enableRenderableContext) { + return getContextName$1(context) + ".Provider"; + } else { return getContextName$1(context) + ".Consumer"; } - case REACT_CONSUMER_TYPE: { - return null; - } + case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + var consumer = type; + return getContextName$1(consumer._context) + ".Consumer"; + } else { + return null; + } case REACT_FORWARD_REF_TYPE: return getWrappedName$1(type, type.render, "ForwardRef"); @@ -3142,15 +3161,23 @@ to return true:wantsResponderID| | case CacheComponent: return "Cache"; - case ContextConsumer: { - var context = type; - return getContextName(context) + ".Consumer"; - } + case ContextConsumer: + if (enableRenderableContext) { + var consumer = type; + return getContextName(consumer._context) + ".Consumer"; + } else { + var context = type; + return getContextName(context) + ".Consumer"; + } - case ContextProvider: { - var provider = type; - return getContextName(provider._context) + ".Provider"; - } + case ContextProvider: + if (enableRenderableContext) { + var _context = type; + return getContextName(_context) + ".Provider"; + } else { + var provider = type; + return getContextName(provider._context) + ".Provider"; + } case DehydratedFragment: return "DehydratedFragment"; @@ -4282,6 +4309,10 @@ to return true:wantsResponderID| | var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; var NormalPriority$1 = Scheduler.unstable_NormalPriority; var IdlePriority = Scheduler.unstable_IdlePriority; // this doesn't actually exist on the scheduler, but it *does* + // on scheduler/unstable_mock, which we'll need for internal testing + + var log$1 = Scheduler.log; + var unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue; // Helpers to patch console.logs to avoid logging during side-effect free // replaying on render function. This currently only patches the object @@ -4548,7 +4579,29 @@ to return true:wantsResponderID| | } } function setIsStrictModeForDevtools(newIsStrictMode) { - { + if (consoleManagedByDevToolsDuringStrictMode) { + if (typeof log$1 === "function") { + // We're in a test because Scheduler.log only exists + // in SchedulerMock. To reduce the noise in strict mode tests, + // suppress warnings and disable scheduler yielding during the double render + unstable_setDisableYieldValue(newIsStrictMode); + setSuppressWarning(newIsStrictMode); + } + + if (injectedHook && typeof injectedHook.setStrictMode === "function") { + try { + injectedHook.setStrictMode(rendererID, newIsStrictMode); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + } + } + } else { if (newIsStrictMode) { disableLogs(); } else { @@ -6182,6 +6235,7 @@ to return true:wantsResponderID| | function waitForCommitToBeReady() { return null; } + var NotPendingTransition = null; var valueStack = []; var fiberStack; @@ -6540,6 +6594,25 @@ to return true:wantsResponderID| | var contextStackCursor = createCursor(null); var contextFiberStackCursor = createCursor(null); var rootInstanceStackCursor = createCursor(null); // Represents the nearest host transition provider (in React DOM, a ) + // NOTE: Since forms cannot be nested, and this feature is only implemented by + // React DOM, we don't technically need this to be a stack. It could be a single + // module variable instead. + + var hostTransitionProviderCursor = createCursor(null); // TODO: This should initialize to NotPendingTransition, a constant + // imported from the fiber config. However, because of a cycle in the module + // graph, that value isn't defined during this module's initialization. I can't + // think of a way to work around this without moving that value out of the + // fiber config. For now, the "no provider" case is handled when reading, + // inside useHostTransitionStatus. + + var HostTransitionContext = { + $$typeof: REACT_CONTEXT_TYPE, + _currentValue: null, + _currentValue2: null, + _threadCount: 0, + Provider: null, + Consumer: null + }; function requiredContext(c) { { @@ -6590,6 +6663,16 @@ to return true:wantsResponderID| | } function pushHostContext(fiber) { + if (enableAsyncActions) { + var stateHook = fiber.memoizedState; + + if (stateHook !== null) { + // Only provide context if this fiber has been upgraded by a host + // transition. We use the same optimization for regular host context below. + push(hostTransitionProviderCursor, fiber, fiber); + } + } + var context = requiredContext(contextStackCursor.current); var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. @@ -6608,6 +6691,25 @@ to return true:wantsResponderID| | pop(contextStackCursor, fiber); pop(contextFiberStackCursor, fiber); } + + if (enableAsyncActions) { + if (hostTransitionProviderCursor.current === fiber) { + // Do not pop unless this Fiber provided the current context. This is mostly + // a performance optimization, but conveniently it also prevents a potential + // data race where a host provider is upgraded (i.e. memoizedState becomes + // non-null) during a concurrent event. This is a bit of a flaw in the way + // we upgrade host components, but because we're accounting for it here, it + // should be fine. + pop(hostTransitionProviderCursor, fiber); // When popping the transition provider, we reset the context value back + // to `null`. We can do this because you're not allowd to nest forms. If + // we allowed for multiple nested host transition providers, then we'd + // need to reset this to the parent provider's status. + + { + HostTransitionContext._currentValue = null; + } + } + } } var isHydrating = false; // This flag allows for warning supression when we expect there to be mismatches @@ -7306,11 +7408,70 @@ to return true:wantsResponderID| | return currentEventTransitionLane; } + // transition updates that occur while the async action is still in progress + // are treated as part of the action. + // + // The ideal behavior would be to treat each async function as an independent + // action. However, without a mechanism like AsyncContext, we can't tell which + // action an update corresponds to. So instead, we entangle them all into one. + // The listeners to notify once the entangled scope completes. + + var currentEntangledListeners = null; // The number of pending async actions in the entangled scope. + + var currentEntangledPendingCount = 0; // The transition lane shared by all updates in the entangled scope. + var currentEntangledLane = NoLane; // A thenable that resolves when the entangled scope completes. It does not // resolve to a particular value because it's only used for suspending the UI // until the async action scope has completed. var currentEntangledActionThenable = null; + function entangleAsyncAction(transition, thenable) { + // `thenable` is the return value of the async action scope function. Create + // a combined thenable that resolves once every entangled scope function + // has finished. + if (currentEntangledListeners === null) { + // There's no outer async action scope. Create a new one. + var entangledListeners = (currentEntangledListeners = []); + currentEntangledPendingCount = 0; + currentEntangledLane = requestTransitionLane(); + var entangledThenable = { + status: "pending", + value: undefined, + then: function (resolve) { + entangledListeners.push(resolve); + } + }; + currentEntangledActionThenable = entangledThenable; + } + + currentEntangledPendingCount++; + thenable.then(pingEngtangledActionScope, pingEngtangledActionScope); + return thenable; + } + + function pingEngtangledActionScope() { + if ( + currentEntangledListeners !== null && + --currentEntangledPendingCount === 0 + ) { + // All the actions have finished. Close the entangled async action scope + // and notify all the listeners. + if (currentEntangledActionThenable !== null) { + var fulfilledThenable = currentEntangledActionThenable; + fulfilledThenable.status = "fulfilled"; + } + + var listeners = currentEntangledListeners; + currentEntangledListeners = null; + currentEntangledLane = NoLane; + currentEntangledActionThenable = null; + + for (var i = 0; i < listeners.length; i++) { + var listener = listeners[i]; + listener(); + } + } + } function chainThenableValue(thenable, result) { // Equivalent to: Promise.resolve(thenable).then(() => result), except we can @@ -11681,6 +11842,43 @@ to return true:wantsResponderID| | return children; } + + function renderTransitionAwareHostComponentWithHooks( + current, + workInProgress, + lanes + ) { + if (!enableAsyncActions) { + throw new Error("Not implemented."); + } + + return renderWithHooks( + current, + workInProgress, + TransitionAwareHostComponent, + null, + null, + lanes + ); + } + function TransitionAwareHostComponent() { + if (!enableAsyncActions) { + throw new Error("Not implemented."); + } + + var dispatcher = ReactCurrentDispatcher$1.current; + + var _dispatcher$useState = dispatcher.useState(), + maybeThenable = _dispatcher$useState[0]; + + if (typeof maybeThenable.then === "function") { + var thenable = maybeThenable; + return useThenable(thenable); + } else { + var status = maybeThenable; + return status; + } + } function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; // TODO: Don't need to reset the flags here, because they're reset in the // complete phase (bubbleProperties). @@ -12117,7 +12315,11 @@ to return true:wantsResponderID| | ); markSkippedUpdateLanes(updateLane); } else { - { + // This update does have sufficient priority. + // Check if this is an optimistic update. + var revertLane = update.revertLane; + + if (!enableAsyncActions || revertLane === NoLane) { // This is not an optimistic update, and we're going to apply it now. // But, if there were earlier updates that were skipped, we need to // leave this update in the queue so it can be rebased later. @@ -12141,6 +12343,56 @@ to return true:wantsResponderID| | if (updateLane === peekEntangledActionLane()) { didReadFromEntangledAsyncAction = true; } + } else { + // This is an optimistic update. If the "revert" priority is + // sufficient, don't apply the update. Otherwise, apply the update, + // but leave it in the queue so it can be either reverted or + // rebased in a subsequent render. + if (isSubsetOfLanes(renderLanes, revertLane)) { + // The transition that this optimistic update is associated with + // has finished. Pretend the update doesn't exist by skipping + // over it. + update = update.next; // Check if this update is part of a pending async action. If so, + // we'll need to suspend until the action has finished, so that it's + // batched together with future updates in the same action. + + if (revertLane === peekEntangledActionLane()) { + didReadFromEntangledAsyncAction = true; + } + + continue; + } else { + var _clone2 = { + // Once we commit an optimistic update, we shouldn't uncommit it + // until the transition it is associated with has finished + // (represented by revertLane). Using NoLane here works because 0 + // is a subset of all bitmasks, so this will never be skipped by + // the check above. + lane: NoLane, + // Reuse the same revertLane so we know when the transition + // has finished. + revertLane: update.revertLane, + action: update.action, + hasEagerState: update.hasEagerState, + eagerState: update.eagerState, + next: null + }; + + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = _clone2; + newBaseState = newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = _clone2; + } // Update the remaining priority in the queue. + // TODO: Don't need to accumulate this. Instead, we can remove + // renderLanes from the original lanes. + + currentlyRenderingFiber$1.lanes = mergeLanes( + currentlyRenderingFiber$1.lanes, + revertLane + ); + markSkippedUpdateLanes(revertLane); + } } // Process this update. var action = update.action; @@ -12529,6 +12781,320 @@ to return true:wantsResponderID| | return rerenderReducer(basicStateReducer); } + function mountOptimistic(passthrough, reducer) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = hook.baseState = passthrough; + var queue = { + pending: null, + lanes: NoLanes, + dispatch: null, + // Optimistic state does not use the eager update optimization. + lastRenderedReducer: null, + lastRenderedState: null + }; + hook.queue = queue; // This is different than the normal setState function. + + var dispatch = dispatchOptimisticSetState.bind( + null, + currentlyRenderingFiber$1, + true, + queue + ); + queue.dispatch = dispatch; + return [passthrough, dispatch]; + } + + function updateOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + } + + function updateOptimisticImpl(hook, current, passthrough, reducer) { + // Optimistic updates are always rebased on top of the latest value passed in + // as an argument. It's called a passthrough because if there are no pending + // updates, it will be returned as-is. + // + // Reset the base state to the passthrough. Future updates will be applied + // on top of this. + hook.baseState = passthrough; // If a reducer is not provided, default to the same one used by useState. + + var resolvedReducer = + typeof reducer === "function" ? reducer : basicStateReducer; + return updateReducerImpl(hook, currentHook, resolvedReducer); + } + + function rerenderOptimistic(passthrough, reducer) { + // Unlike useState, useOptimistic doesn't support render phase updates. + // Also unlike useState, we need to replay all pending updates again in case + // the passthrough value changed. + // + // So instead of a forked re-render implementation that knows how to handle + // render phase udpates, we can use the same implementation as during a + // regular mount or update. + var hook = updateWorkInProgressHook(); + + if (currentHook !== null) { + // This is an update. Process the update queue. + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + } // This is a mount. No updates to process. + // Reset the base state to the passthrough. Future updates will be applied + // on top of this. + + hook.baseState = passthrough; + var dispatch = hook.queue.dispatch; + return [passthrough, dispatch]; + } // useFormState actions run sequentially, because each action receives the + // previous state as an argument. We store pending actions on a queue. + + function dispatchFormState(fiber, actionQueue, setState, payload) { + if (isRenderPhaseUpdate(fiber)) { + throw new Error("Cannot update form state while rendering."); + } + + var last = actionQueue.pending; + + if (last === null) { + // There are no pending actions; this is the first one. We can run + // it immediately. + var newLast = { + payload: payload, + next: null // circular + }; + newLast.next = actionQueue.pending = newLast; + runFormStateAction(actionQueue, setState, payload); + } else { + // There's already an action running. Add to the queue. + var first = last.next; + var _newLast = { + payload: payload, + next: first + }; + actionQueue.pending = last.next = _newLast; + } + } + + function runFormStateAction(actionQueue, setState, payload) { + var action = actionQueue.action; + var prevState = actionQueue.state; // This is a fork of startTransition + + var prevTransition = ReactCurrentBatchConfig$2.transition; + var currentTransition = { + _callbacks: new Set() + }; + ReactCurrentBatchConfig$2.transition = currentTransition; + + { + ReactCurrentBatchConfig$2.transition._updatedFibers = new Set(); + } + + try { + var returnValue = action(prevState, payload); + + if ( + returnValue !== null && + typeof returnValue === "object" && // $FlowFixMe[method-unbinding] + typeof returnValue.then === "function" + ) { + var thenable = returnValue; + notifyTransitionCallbacks(currentTransition, thenable); // Attach a listener to read the return state of the action. As soon as + // this resolves, we can run the next action in the sequence. + + thenable.then( + function (nextState) { + actionQueue.state = nextState; + finishRunningFormStateAction(actionQueue, setState); + }, + function () { + return finishRunningFormStateAction(actionQueue, setState); + } + ); + setState(thenable); + } else { + setState(returnValue); + var nextState = returnValue; + actionQueue.state = nextState; + finishRunningFormStateAction(actionQueue, setState); + } + } catch (error) { + // This is a trick to get the `useFormState` hook to rethrow the error. + // When it unwraps the thenable with the `use` algorithm, the error + // will be thrown. + var rejectedThenable = { + then: function () {}, + status: "rejected", + reason: error // $FlowFixMe: Not sure why this doesn't work + }; + setState(rejectedThenable); + finishRunningFormStateAction(actionQueue, setState); + } finally { + ReactCurrentBatchConfig$2.transition = prevTransition; + + { + 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." + ); + } + } + } + } + } + + function finishRunningFormStateAction(actionQueue, setState) { + // The action finished running. Pop it from the queue and run the next pending + // action, if there are any. + var last = actionQueue.pending; + + if (last !== null) { + var first = last.next; + + if (first === last) { + // This was the last action in the queue. + actionQueue.pending = null; + } else { + // Remove the first node from the circular queue. + var next = first.next; + last.next = next; // Run the next action. + + runFormStateAction(actionQueue, setState, next.payload); + } + } + } + + function formStateReducer(oldState, newState) { + return newState; + } + + function mountFormState(action, initialStateProp, permalink) { + var initialState = initialStateProp; + // the `use` algorithm during render. + + var stateHook = mountWorkInProgressHook(); + stateHook.memoizedState = stateHook.baseState = initialState; // TODO: Typing this "correctly" results in recursion limit errors + // const stateQueue: UpdateQueue, S | Awaited> = { + + var stateQueue = { + pending: null, + lanes: NoLanes, + dispatch: null, + lastRenderedReducer: formStateReducer, + lastRenderedState: initialState + }; + stateHook.queue = stateQueue; + var setState = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + stateQueue + ); + stateQueue.dispatch = setState; // Action queue hook. This is used to queue pending actions. The queue is + // shared between all instances of the hook. Similar to a regular state queue, + // but different because the actions are run sequentially, and they run in + // an event instead of during render. + + var actionQueueHook = mountWorkInProgressHook(); + var actionQueue = { + state: initialState, + dispatch: null, + // circular + action: action, + pending: null + }; + actionQueueHook.queue = actionQueue; + var dispatch = dispatchFormState.bind( + null, + currentlyRenderingFiber$1, + actionQueue, + setState + ); + actionQueue.dispatch = dispatch; // Stash the action function on the memoized state of the hook. We'll use this + // to detect when the action function changes so we can update it in + // an effect. + + actionQueueHook.memoizedState = action; + return [initialState, dispatch]; + } + + function updateFormState(action, initialState, permalink) { + var stateHook = updateWorkInProgressHook(); + var currentStateHook = currentHook; + return updateFormStateImpl(stateHook, currentStateHook, action); + } + + function updateFormStateImpl( + stateHook, + currentStateHook, + action, + initialState, + permalink + ) { + var _updateReducerImpl = updateReducerImpl( + stateHook, + currentStateHook, + formStateReducer + ), + actionResult = _updateReducerImpl[0]; // This will suspend until the action finishes. + + var state = + typeof actionResult === "object" && + actionResult !== null && // $FlowFixMe[method-unbinding] + typeof actionResult.then === "function" + ? useThenable(actionResult) + : actionResult; + var actionQueueHook = updateWorkInProgressHook(); + var actionQueue = actionQueueHook.queue; + var dispatch = actionQueue.dispatch; // Check if a new action was passed. If so, update it in an effect. + + var prevAction = actionQueueHook.memoizedState; + + if (action !== prevAction) { + currentlyRenderingFiber$1.flags |= Passive$1; + pushEffect( + HasEffect | Passive, + formStateActionEffect.bind(null, actionQueue, action), + createEffectInstance(), + null + ); + } + + return [state, dispatch]; + } + + function formStateActionEffect(actionQueue, action) { + actionQueue.action = action; + } + + function rerenderFormState(action, initialState, permalink) { + // Unlike useState, useFormState doesn't support render phase updates. + // Also unlike useState, we need to replay all pending updates again in case + // the passthrough value changed. + // + // So instead of a forked re-render implementation that knows how to handle + // render phase udpates, we can use the same implementation as during a + // regular mount or update. + var stateHook = updateWorkInProgressHook(); + var currentStateHook = currentHook; + + if (currentStateHook !== null) { + // This is an update. Process the update queue. + return updateFormStateImpl(stateHook, currentStateHook, action); + } // This is a mount. No updates to process. + + var state = stateHook.memoizedState; + var actionQueueHook = updateWorkInProgressHook(); + var actionQueue = actionQueueHook.queue; + var dispatch = actionQueue.dispatch; // This may have changed during the rerender. + + actionQueueHook.memoizedState = action; + return [state, dispatch]; + } + function pushEffect(tag, create, inst, deps) { var effect = { tag: tag, @@ -13008,7 +13574,16 @@ to return true:wantsResponderID| | _callbacks: new Set() }; - { + if (enableAsyncActions) { + // We don't really need to use an optimistic update here, because we + // schedule a second "revert" update below (which we use to suspend the + // transition until the async action scope has finished). But we'll use an + // optimistic update anyway to make it less likely the behavior accidentally + // diverges; for example, both an optimistic update and this one should + // share the same lane. + ReactCurrentBatchConfig$2.transition = currentTransition; + dispatchOptimisticSetState(fiber, false, queue, pendingState); + } else { ReactCurrentBatchConfig$2.transition = null; dispatchSetState(fiber, queue, pendingState); ReactCurrentBatchConfig$2.transition = currentTransition; @@ -13019,15 +13594,50 @@ to return true:wantsResponderID| | } try { - var returnValue, thenable, thenableForFinishedState; - if (enableAsyncActions); - else { + if (enableAsyncActions) { + var returnValue = callback(); // Check if we're inside an async action scope. If so, we'll entangle + // this new action with the existing scope. + // + // If we're not already inside an async action scope, and this action is + // async, then we'll create a new async scope. + // + // In the async case, the resulting render will suspend until the async + // action scope has finished. + + if ( + returnValue !== null && + typeof returnValue === "object" && + typeof returnValue.then === "function" + ) { + var thenable = returnValue; + notifyTransitionCallbacks(currentTransition, thenable); // Create a thenable that resolves to `finishedState` once the async + // action has completed. + + var thenableForFinishedState = chainThenableValue( + thenable, + finishedState + ); + dispatchSetState(fiber, queue, thenableForFinishedState); + } else { + dispatchSetState(fiber, queue, finishedState); + } + } else { // Async actions are not enabled. dispatchSetState(fiber, queue, finishedState); callback(); } } catch (error) { - { + if (enableAsyncActions) { + // This is a trick to get the `useTransition` hook to rethrow the error. + // When it unwraps the thenable with the `use` algorithm, the error + // will be thrown. + var rejectedThenable = { + then: function () {}, + status: "rejected", + reason: error + }; + dispatchSetState(fiber, queue, rejectedThenable); + } else { // The error rethrowing behavior is only enabled when the async actions // feature is on, even for sync actions. throw error; @@ -13095,6 +13705,15 @@ to return true:wantsResponderID| | return [isPending, start]; } + function useHostTransitionStatus() { + if (!enableAsyncActions) { + throw new Error("Not implemented."); + } + + var status = readContext(HostTransitionContext); + return status !== null ? status : NotPendingTransition; + } + function mountId() { var hook = mountWorkInProgressHook(); var root = getWorkInProgressRoot(); // TODO: In Fizz, id generation is specific to each server config. Maybe we @@ -13305,6 +13924,89 @@ to return true:wantsResponderID| | markUpdateInDevTools(fiber, lane); } + function dispatchOptimisticSetState( + fiber, + throwIfDuringRender, + queue, + action + ) { + var transition = requestCurrentTransition(); + + { + if (transition === null) { + // An optimistic update occurred, but startTransition is not on the stack. + // There are two likely scenarios. + // One possibility is that the optimistic update is triggered by a regular + // event handler (e.g. `onSubmit`) instead of an action. This is a mistake + // and we will warn. + // The other possibility is the optimistic update is inside an async + // action, but after an `await`. In this case, we can make it "just work" + // by associating the optimistic update with the pending async action. + // Technically it's possible that the optimistic update is unrelated to + // the pending action, but we don't have a way of knowing this for sure + // because browsers currently do not provide a way to track async scope. + // (The AsyncContext proposal, if it lands, will solve this in the + // future.) However, this is no different than the problem of unrelated + // transitions being grouped together — it's not wrong per se, but it's + // not ideal. + // Once AsyncContext starts landing in browsers, we will provide better + // warnings in development for these cases. + if (peekEntangledActionLane() !== NoLane); + else { + // There's no pending async action. The most likely cause is that we're + // inside a regular event handler (e.g. onSubmit) instead of an action. + error( + "An optimistic state update occurred outside a transition or " + + "action. To fix, move the update to an action, or wrap " + + "with startTransition." + ); + } + } + } + + var update = { + // An optimistic update commits synchronously. + lane: SyncLane, + // After committing, the optimistic update is "reverted" using the same + // lane as the transition it's associated with. + revertLane: requestTransitionLane(), + action: action, + hasEagerState: false, + eagerState: null, + next: null + }; + + if (isRenderPhaseUpdate(fiber)) { + // When calling startTransition during render, this warns instead of + // throwing because throwing would be a breaking change. setOptimisticState + // is a new API so it's OK to throw. + if (throwIfDuringRender) { + throw new Error("Cannot update optimistic state while rendering."); + } else { + // startTransition was called during render. We don't need to do anything + // besides warn here because the render phase update would be overidden by + // the second update, anyway. We can remove this branch and make it throw + // in a future release. + { + error("Cannot call startTransition while rendering."); + } + } + } else { + var root = enqueueConcurrentHookUpdate(fiber, queue, update, SyncLane); + + if (root !== null) { + // NOTE: The optimistic update implementation assumes that the transition + // will never be attempted before the optimistic update. This currently + // holds because the optimistic update is always synchronous. If we ever + // change that, we'll need to account for this. + scheduleUpdateOnFiber(root, fiber, SyncLane); // Optimistic updates are always synchronous, so we don't need to call + // entangleTransitionUpdate here. + } + } + + markUpdateInDevTools(fiber, SyncLane); + } + function isRenderPhaseUpdate(fiber) { var alternate = fiber.alternate; return ( @@ -13385,6 +14087,15 @@ to return true:wantsResponderID| | ContextOnlyDispatcher.useMemoCache = throwInvalidHookError; } + if (enableAsyncActions) { + ContextOnlyDispatcher.useHostTransitionStatus = throwInvalidHookError; + ContextOnlyDispatcher.useFormState = throwInvalidHookError; + } + + if (enableAsyncActions) { + ContextOnlyDispatcher.useOptimistic = throwInvalidHookError; + } + var HooksDispatcherOnMountInDEV = null; var HooksDispatcherOnMountWithHookTypesInDEV = null; var HooksDispatcherOnUpdateInDEV = null; @@ -13541,6 +14252,32 @@ to return true:wantsResponderID| | HooksDispatcherOnMountInDEV.useMemoCache = useMemoCache; } + if (enableAsyncActions) { + HooksDispatcherOnMountInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + HooksDispatcherOnMountInDEV.useFormState = function useFormState( + action, + initialState, + permalink + ) { + currentHookNameInDev = "useFormState"; + mountHookTypesDev(); + return mountFormState(action, initialState); + }; + } + + if (enableAsyncActions) { + HooksDispatcherOnMountInDEV.useOptimistic = function useOptimistic( + passthrough, + reducer + ) { + currentHookNameInDev = "useOptimistic"; + mountHookTypesDev(); + return mountOptimistic(passthrough); + }; + } + HooksDispatcherOnMountWithHookTypesInDEV = { readContext: function (context) { return readContext(context); @@ -13664,6 +14401,27 @@ to return true:wantsResponderID| | HooksDispatcherOnMountWithHookTypesInDEV.useMemoCache = useMemoCache; } + if (enableAsyncActions) { + HooksDispatcherOnMountWithHookTypesInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + HooksDispatcherOnMountWithHookTypesInDEV.useFormState = + function useFormState(action, initialState, permalink) { + currentHookNameInDev = "useFormState"; + updateHookTypesDev(); + return mountFormState(action, initialState); + }; + } + + if (enableAsyncActions) { + HooksDispatcherOnMountWithHookTypesInDEV.useOptimistic = + function useOptimistic(passthrough, reducer) { + currentHookNameInDev = "useOptimistic"; + updateHookTypesDev(); + return mountOptimistic(passthrough); + }; + } + HooksDispatcherOnUpdateInDEV = { readContext: function (context) { return readContext(context); @@ -13787,6 +14545,32 @@ to return true:wantsResponderID| | HooksDispatcherOnUpdateInDEV.useMemoCache = useMemoCache; } + if (enableAsyncActions) { + HooksDispatcherOnUpdateInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + HooksDispatcherOnUpdateInDEV.useFormState = function useFormState( + action, + initialState, + permalink + ) { + currentHookNameInDev = "useFormState"; + updateHookTypesDev(); + return updateFormState(action); + }; + } + + if (enableAsyncActions) { + HooksDispatcherOnUpdateInDEV.useOptimistic = function useOptimistic( + passthrough, + reducer + ) { + currentHookNameInDev = "useOptimistic"; + updateHookTypesDev(); + return updateOptimistic(passthrough, reducer); + }; + } + HooksDispatcherOnRerenderInDEV = { readContext: function (context) { return readContext(context); @@ -13910,6 +14694,32 @@ to return true:wantsResponderID| | HooksDispatcherOnRerenderInDEV.useMemoCache = useMemoCache; } + if (enableAsyncActions) { + HooksDispatcherOnRerenderInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + HooksDispatcherOnRerenderInDEV.useFormState = function useFormState( + action, + initialState, + permalink + ) { + currentHookNameInDev = "useFormState"; + updateHookTypesDev(); + return rerenderFormState(action); + }; + } + + if (enableAsyncActions) { + HooksDispatcherOnRerenderInDEV.useOptimistic = function useOptimistic( + passthrough, + reducer + ) { + currentHookNameInDev = "useOptimistic"; + updateHookTypesDev(); + return rerenderOptimistic(passthrough, reducer); + }; + } + InvalidNestedHooksDispatcherOnMountInDEV = { readContext: function (context) { warnInvalidContextAccess(); @@ -14057,6 +14867,29 @@ to return true:wantsResponderID| | }; } + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnMountInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + InvalidNestedHooksDispatcherOnMountInDEV.useFormState = + function useFormState(action, initialState, permalink) { + currentHookNameInDev = "useFormState"; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountFormState(action, initialState); + }; + } + + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnMountInDEV.useOptimistic = + function useOptimistic(passthrough, reducer) { + currentHookNameInDev = "useOptimistic"; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountOptimistic(passthrough); + }; + } + InvalidNestedHooksDispatcherOnUpdateInDEV = { readContext: function (context) { warnInvalidContextAccess(); @@ -14204,6 +15037,29 @@ to return true:wantsResponderID| | }; } + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnUpdateInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + InvalidNestedHooksDispatcherOnUpdateInDEV.useFormState = + function useFormState(action, initialState, permalink) { + currentHookNameInDev = "useFormState"; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateFormState(action); + }; + } + + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnUpdateInDEV.useOptimistic = + function useOptimistic(passthrough, reducer) { + currentHookNameInDev = "useOptimistic"; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateOptimistic(passthrough, reducer); + }; + } + InvalidNestedHooksDispatcherOnRerenderInDEV = { readContext: function (context) { warnInvalidContextAccess(); @@ -14350,6 +15206,29 @@ to return true:wantsResponderID| | return useMemoCache(size); }; } + + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnRerenderInDEV.useHostTransitionStatus = + useHostTransitionStatus; + + InvalidNestedHooksDispatcherOnRerenderInDEV.useFormState = + function useFormState(action, initialState, permalink) { + currentHookNameInDev = "useFormState"; + warnInvalidHookAccess(); + updateHookTypesDev(); + return rerenderFormState(action); + }; + } + + if (enableAsyncActions) { + InvalidNestedHooksDispatcherOnRerenderInDEV.useOptimistic = + function useOptimistic(passthrough, reducer) { + currentHookNameInDev = "useOptimistic"; + warnInvalidHookAccess(); + updateHookTypesDev(); + return rerenderOptimistic(passthrough, reducer); + }; + } } var now = Scheduler.unstable_now; @@ -17326,6 +18205,57 @@ to return true:wantsResponderID| | workInProgress.flags |= ContentReset; } + if (enableAsyncActions) { + var memoizedState = workInProgress.memoizedState; + + if (memoizedState !== null) { + // This fiber has been upgraded to a stateful component. The only way + // happens currently is for form actions. We use hooks to track the + // pending and error state of the form. + // + // Once a fiber is upgraded to be stateful, it remains stateful for the + // rest of its lifetime. + var newState = renderTransitionAwareHostComponentWithHooks( + current, + workInProgress, + renderLanes + ); // If the transition state changed, propagate the change to all the + // descendents. We use Context as an implementation detail for this. + // + // This is intentionally set here instead of pushHostContext because + // pushHostContext gets called before we process the state hook, to avoid + // a state mismatch in the event that something suspends. + // + // NOTE: This assumes that there cannot be nested transition providers, + // because the only renderer that implements this feature is React DOM, + // and forms cannot be nested. If we did support nested providers, then + // we would need to push a context value even for host fibers that + // haven't been upgraded yet. + + { + HostTransitionContext._currentValue = newState; + } + + { + if (didReceiveUpdate) { + if (current !== null) { + var oldStateHook = current.memoizedState; + var oldState = oldStateHook.memoizedState; // This uses regular equality instead of Object.is because we assume + // that host transition state doesn't include NaN as a valid type. + + if (oldState !== newState) { + propagateContextChange( + workInProgress, + HostTransitionContext, + renderLanes + ); + } + } + } + } + } + } + markRef(current, workInProgress); reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; @@ -18887,7 +19817,9 @@ to return true:wantsResponderID| | function updateContextProvider(current, workInProgress, renderLanes) { var context; - { + if (enableRenderableContext) { + context = workInProgress.type; + } else { context = workInProgress.type._context; } @@ -18941,7 +19873,10 @@ to return true:wantsResponderID| | function updateContextConsumer(current, workInProgress, renderLanes) { var context; - { + if (enableRenderableContext) { + var consumerType = workInProgress.type; + context = consumerType._context; + } else { context = workInProgress.type; { @@ -19157,7 +20092,9 @@ to return true:wantsResponderID| | var newValue = workInProgress.memoizedProps.value; var context; - { + if (enableRenderableContext) { + context = workInProgress.type; + } else { context = workInProgress.type._context; } @@ -20042,7 +20979,12 @@ to return true:wantsResponderID| | return transition; } - function handleAsyncAction(transition, thenable) {} + function handleAsyncAction(transition, thenable) { + if (enableAsyncActions) { + // This is an async action. + entangleAsyncAction(transition, thenable); + } + } function notifyTransitionCallbacks(transition, returnValue) { var callbacks = transition._callbacks; @@ -20880,7 +21822,9 @@ to return true:wantsResponderID| | // Pop provider fiber var context; - { + if (enableRenderableContext) { + context = workInProgress.type; + } else { context = workInProgress.type._context; } @@ -21326,7 +22270,9 @@ to return true:wantsResponderID| | case ContextProvider: var context; - { + if (enableRenderableContext) { + context = workInProgress.type; + } else { context = workInProgress.type._context; } @@ -21411,7 +22357,9 @@ to return true:wantsResponderID| | case ContextProvider: var context; - { + if (enableRenderableContext) { + context = interruptedWork.type; + } else { context = interruptedWork.type._context; } @@ -27941,9 +28889,121 @@ to return true:wantsResponderID| | } } + function recursivelyTraverseAndDoubleInvokeEffectsInDEV( + root, + parentFiber, + isInStrictMode + ) { + if ( + (parentFiber.subtreeFlags & (PlacementDEV | Visibility)) === + NoFlags$1 + ) { + // Parent's descendants have already had effects double invoked. + // Early exit to avoid unnecessary tree traversal. + return; + } + + var child = parentFiber.child; + + while (child !== null) { + doubleInvokeEffectsInDEVIfNecessary(root, child, isInStrictMode); + child = child.sibling; + } + } // Unconditionally disconnects and connects passive and layout effects. + + function doubleInvokeEffectsOnFiber(root, fiber) { + var shouldDoubleInvokePassiveEffects = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : true; + disappearLayoutEffects(fiber); + + if (shouldDoubleInvokePassiveEffects) { + disconnectPassiveEffect(fiber); + } + + reappearLayoutEffects(root, fiber.alternate, fiber, false); + + if (shouldDoubleInvokePassiveEffects) { + reconnectPassiveEffects(root, fiber, NoLanes, null, false); + } + } + + function doubleInvokeEffectsInDEVIfNecessary( + root, + fiber, + parentIsInStrictMode + ) { + var isStrictModeFiber = fiber.type === REACT_STRICT_MODE_TYPE; + var isInStrictMode = parentIsInStrictMode || isStrictModeFiber; // First case: the fiber **is not** of type OffscreenComponent. No + // special rules apply to double invoking effects. + + if (fiber.tag !== OffscreenComponent) { + if (fiber.flags & PlacementDEV) { + setCurrentFiber(fiber); + + if (isInStrictMode) { + doubleInvokeEffectsOnFiber( + root, + fiber, + (fiber.mode & NoStrictPassiveEffectsMode) === NoMode + ); + } + + resetCurrentFiber(); + } else { + recursivelyTraverseAndDoubleInvokeEffectsInDEV( + root, + fiber, + isInStrictMode + ); + } + + return; + } // Second case: the fiber **is** of type OffscreenComponent. + // This branch contains cases specific to Offscreen. + + if (fiber.memoizedState === null) { + // Only consider Offscreen that is visible. + // TODO (Offscreen) Handle manual mode. + setCurrentFiber(fiber); + + if (isInStrictMode && fiber.flags & Visibility) { + // Double invoke effects on Offscreen's subtree only + // if it is visible and its visibility has changed. + doubleInvokeEffectsOnFiber(root, fiber); + } else if (fiber.subtreeFlags & PlacementDEV) { + // Something in the subtree could have been suspended. + // We need to continue traversal and find newly inserted fibers. + recursivelyTraverseAndDoubleInvokeEffectsInDEV( + root, + fiber, + isInStrictMode + ); + } + + resetCurrentFiber(); + } + } + function commitDoubleInvokeEffectsInDEV(root, hasPassiveEffects) { { - { + if (useModernStrictMode && root.tag !== LegacyRoot) { + var doubleInvokeEffects = true; + + if ( + root.tag === ConcurrentRoot && + !(root.current.mode & (StrictLegacyMode | StrictEffectsMode)) + ) { + doubleInvokeEffects = false; + } + + recursivelyTraverseAndDoubleInvokeEffectsInDEV( + root, + root.current, + doubleInvokeEffects + ); + } else { legacyCommitDoubleInvokeEffectsInDEV(root.current, hasPassiveEffects); } } @@ -29190,19 +30250,28 @@ to return true:wantsResponderID| | default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { - case REACT_PROVIDER_TYPE: { - fiberTag = ContextProvider; - break getTag; - } + case REACT_PROVIDER_TYPE: + if (!enableRenderableContext) { + fiberTag = ContextProvider; + break getTag; + } // Fall through - case REACT_CONTEXT_TYPE: { - fiberTag = ContextConsumer; - break getTag; - } + case REACT_CONTEXT_TYPE: + if (enableRenderableContext) { + fiberTag = ContextProvider; + break getTag; + } else { + fiberTag = ContextConsumer; + break getTag; + } case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + fiberTag = ContextConsumer; + break getTag; + } // Fall through @@ -29555,7 +30624,7 @@ to return true:wantsResponderID| | return root; } - var ReactVersion = "18.3.0-canary-3893fb04"; + var ReactVersion = "18.3.0-canary-e7e333a2"; function createPortal$1( children, diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index d19c12b4b65fa..1b548c4c2e763 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<1d4631a2bcf4dccb86fbee6bdfbcb510>> */ "use strict"; @@ -935,7 +935,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_262 = { +var injectedNamesToPlugins$jscomp$inline_261 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -981,32 +981,32 @@ var injectedNamesToPlugins$jscomp$inline_262 = { } } }, - isOrderingDirty$jscomp$inline_263 = !1, - pluginName$jscomp$inline_264; -for (pluginName$jscomp$inline_264 in injectedNamesToPlugins$jscomp$inline_262) + isOrderingDirty$jscomp$inline_262 = !1, + pluginName$jscomp$inline_263; +for (pluginName$jscomp$inline_263 in injectedNamesToPlugins$jscomp$inline_261) if ( - injectedNamesToPlugins$jscomp$inline_262.hasOwnProperty( - pluginName$jscomp$inline_264 + injectedNamesToPlugins$jscomp$inline_261.hasOwnProperty( + pluginName$jscomp$inline_263 ) ) { - var pluginModule$jscomp$inline_265 = - injectedNamesToPlugins$jscomp$inline_262[pluginName$jscomp$inline_264]; + var pluginModule$jscomp$inline_264 = + injectedNamesToPlugins$jscomp$inline_261[pluginName$jscomp$inline_263]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_264) || - namesToPlugins[pluginName$jscomp$inline_264] !== - pluginModule$jscomp$inline_265 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_263) || + namesToPlugins[pluginName$jscomp$inline_263] !== + pluginModule$jscomp$inline_264 ) { - if (namesToPlugins[pluginName$jscomp$inline_264]) + if (namesToPlugins[pluginName$jscomp$inline_263]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_264 + "`.") + (pluginName$jscomp$inline_263 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_264] = - pluginModule$jscomp$inline_265; - isOrderingDirty$jscomp$inline_263 = !0; + namesToPlugins[pluginName$jscomp$inline_263] = + pluginModule$jscomp$inline_264; + isOrderingDirty$jscomp$inline_262 = !0; } } -isOrderingDirty$jscomp$inline_263 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_262 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1155,13 +1155,17 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, + consoleManagedByDevToolsDuringStrictMode = + dynamicFlags.consoleManagedByDevToolsDuringStrictMode, + enableAsyncActions = dynamicFlags.enableAsyncActions, enableComponentStackLocations = dynamicFlags.enableComponentStackLocations, enableDeferRootSchedulingToMicrotask = dynamicFlags.enableDeferRootSchedulingToMicrotask, - enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, - enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, enableInfiniteRenderLoopDetection = dynamicFlags.enableInfiniteRenderLoopDetection, + enableRenderableContext = dynamicFlags.enableRenderableContext, + enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, + enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -1217,9 +1221,16 @@ function getComponentNameFromType(type) { if ("object" === typeof type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - return (type._context.displayName || "Context") + ".Provider"; + if (enableRenderableContext) break; + else return (type._context.displayName || "Context") + ".Provider"; case REACT_CONTEXT_TYPE: - return (type.displayName || "Context") + ".Consumer"; + return enableRenderableContext + ? (type.displayName || "Context") + ".Provider" + : (type.displayName || "Context") + ".Consumer"; + case REACT_CONSUMER_TYPE: + if (enableRenderableContext) + return (type._context.displayName || "Context") + ".Consumer"; + break; case REACT_FORWARD_REF_TYPE: var innerType = type.render; type = type.displayName; @@ -1249,9 +1260,13 @@ function getComponentNameFromFiber(fiber) { case 24: return "Cache"; case 9: - return (type.displayName || "Context") + ".Consumer"; + return enableRenderableContext + ? (type._context.displayName || "Context") + ".Consumer" + : (type.displayName || "Context") + ".Consumer"; case 10: - return (type._context.displayName || "Context") + ".Provider"; + return enableRenderableContext + ? (type.displayName || "Context") + ".Provider" + : (type._context.displayName || "Context") + ".Provider"; case 18: return "DehydratedFragment"; case 11: @@ -1349,36 +1364,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$1 = parentA.child; child$1; ) { - if (child$1 === a) { + for (var didFindChild = !1, child$2 = parentA.child; child$2; ) { + if (child$2 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$1 === b) { + if (child$2 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$1 = child$1.sibling; + child$2 = child$2.sibling; } if (!didFindChild) { - for (child$1 = parentB.child; child$1; ) { - if (child$1 === a) { + for (child$2 = parentB.child; child$2; ) { + if (child$2 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$1 === b) { + if (child$2 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$1 = child$1.sibling; + child$2 = child$2.sibling; } if (!didFindChild) throw Error( @@ -1612,19 +1627,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var propKey$3 in prevProps) - void 0 === nextProps[propKey$3] && - (!(attributeConfig = validAttributes[propKey$3]) || - (updatePayload && void 0 !== updatePayload[propKey$3]) || - ((prevProp = prevProps[propKey$3]), + for (var propKey$4 in prevProps) + void 0 === nextProps[propKey$4] && + (!(attributeConfig = validAttributes[propKey$4]) || + (updatePayload && void 0 !== updatePayload[propKey$4]) || + ((prevProp = prevProps[propKey$4]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[propKey$3] = null), + ? (((updatePayload || (updatePayload = {}))[propKey$4] = null), removedKeys || (removedKeys = {}), - removedKeys[propKey$3] || - ((removedKeys[propKey$3] = !0), removedKeyCount++)) + removedKeys[propKey$4] || + ((removedKeys[propKey$4] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1706,6 +1721,8 @@ var ReactNativeFiberHostComponent = (function () { UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, NormalPriority$1 = Scheduler.unstable_NormalPriority, IdlePriority = Scheduler.unstable_IdlePriority, + log$1 = Scheduler.log, + unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue, rendererID = null, injectedHook = null; function onCommitRoot(root) { @@ -1719,6 +1736,17 @@ function onCommitRoot(root) { ); } catch (err) {} } +function setIsStrictModeForDevtools(newIsStrictMode) { + if ( + consoleManagedByDevToolsDuringStrictMode && + ("function" === typeof log$1 && + unstable_setDisableYieldValue(newIsStrictMode), + injectedHook && "function" === typeof injectedHook.setStrictMode) + ) + try { + injectedHook.setStrictMode(rendererID, newIsStrictMode); + } catch (err) {} +} var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, log = Math.log, LN2 = Math.LN2; @@ -1891,18 +1919,18 @@ function markRootFinished(root, remainingLanes, spawnedLane) { 0 < noLongerPendingLanes; ) { - var index$7 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$7; - remainingLanes[index$7] = 0; - expirationTimes[index$7] = -1; - var hiddenUpdatesForLane = hiddenUpdates[index$7]; + var index$8 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$8; + remainingLanes[index$8] = 0; + expirationTimes[index$8] = -1; + var hiddenUpdatesForLane = hiddenUpdates[index$8]; if (null !== hiddenUpdatesForLane) for ( - hiddenUpdates[index$7] = null, index$7 = 0; - index$7 < hiddenUpdatesForLane.length; - index$7++ + hiddenUpdates[index$8] = null, index$8 = 0; + index$8 < hiddenUpdatesForLane.length; + index$8++ ) { - var update = hiddenUpdatesForLane[index$7]; + var update = hiddenUpdatesForLane[index$8]; null !== update && (update.lane &= -536870913); } noLongerPendingLanes &= ~lane; @@ -1922,10 +1950,10 @@ function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) { function markRootEntangled(root, entangledLanes) { var rootEntangledLanes = (root.entangledLanes |= entangledLanes); for (root = root.entanglements; rootEntangledLanes; ) { - var index$8 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$8; - (lane & entangledLanes) | (root[index$8] & entangledLanes) && - (root[index$8] |= entangledLanes); + var index$9 = 31 - clz32(rootEntangledLanes), + lane = 1 << index$9; + (lane & entangledLanes) | (root[index$9] & entangledLanes) && + (root[index$9] |= entangledLanes); rootEntangledLanes &= ~lane; } } @@ -2085,7 +2113,16 @@ function is(x, y) { var objectIs = "function" === typeof Object.is ? Object.is : is, contextStackCursor = createCursor(null), contextFiberStackCursor = createCursor(null), - rootInstanceStackCursor = createCursor(null); + rootInstanceStackCursor = createCursor(null), + hostTransitionProviderCursor = createCursor(null), + HostTransitionContext = { + $$typeof: REACT_CONTEXT_TYPE, + _currentValue: null, + _currentValue2: null, + _threadCount: 0, + Provider: null, + Consumer: null + }; function pushHostContainer(fiber, nextRootInstance) { push(rootInstanceStackCursor, nextRootInstance); push(contextFiberStackCursor, fiber); @@ -2099,6 +2136,9 @@ function popHostContainer() { pop(rootInstanceStackCursor); } function pushHostContext(fiber) { + enableAsyncActions && + null !== fiber.memoizedState && + push(hostTransitionProviderCursor, fiber); var context = contextStackCursor.current; var JSCompiler_inline_result = fiber.type; JSCompiler_inline_result = @@ -2118,6 +2158,10 @@ function pushHostContext(fiber) { function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor), pop(contextFiberStackCursor)); + enableAsyncActions && + hostTransitionProviderCursor.current === fiber && + (pop(hostTransitionProviderCursor), + (HostTransitionContext._currentValue = null)); } var hydrationErrors = null, concurrentQueues = [], @@ -2158,6 +2202,10 @@ function enqueueUpdate$1(fiber, queue, update, lane) { fiber = fiber.alternate; null !== fiber && (fiber.lanes |= lane); } +function enqueueConcurrentHookUpdate(fiber, queue, update, lane) { + enqueueUpdate$1(fiber, queue, update, lane); + return getRootForUpdatedFiber(fiber); +} function enqueueConcurrentRenderForLane(fiber, lane) { enqueueUpdate$1(fiber, null, null, lane); return getRootForUpdatedFiber(fiber); @@ -2220,35 +2268,35 @@ function flushSyncWorkAcrossRoots_impl(onlyLegacy) { var didPerformSomeWork = !1; for (var root = firstScheduledRoot; null !== root; ) { if (!onlyLegacy || 0 === root.tag) { - var workInProgressRootRenderLanes$11 = workInProgressRootRenderLanes, + var workInProgressRootRenderLanes$12 = workInProgressRootRenderLanes, nextLanes = getNextLanes( root, - root === workInProgressRoot ? workInProgressRootRenderLanes$11 : 0 + root === workInProgressRoot ? workInProgressRootRenderLanes$12 : 0 ); if (0 !== (nextLanes & 3)) try { didPerformSomeWork = !0; - workInProgressRootRenderLanes$11 = root; + workInProgressRootRenderLanes$12 = root; if (0 !== (executionContext & 6)) throw Error("Should not already be working."); if (!flushPassiveEffects()) { var exitStatus = renderRootSync( - workInProgressRootRenderLanes$11, + workInProgressRootRenderLanes$12, nextLanes ); if ( - 0 !== workInProgressRootRenderLanes$11.tag && + 0 !== workInProgressRootRenderLanes$12.tag && 2 === exitStatus ) { var originallyAttemptedLanes = nextLanes, errorRetryLanes = getLanesToRetrySynchronouslyOnError( - workInProgressRootRenderLanes$11, + workInProgressRootRenderLanes$12, originallyAttemptedLanes ); 0 !== errorRetryLanes && ((nextLanes = errorRetryLanes), (exitStatus = recoverFromConcurrentError( - workInProgressRootRenderLanes$11, + workInProgressRootRenderLanes$12, originallyAttemptedLanes, errorRetryLanes ))); @@ -2256,34 +2304,34 @@ function flushSyncWorkAcrossRoots_impl(onlyLegacy) { if (1 === exitStatus) throw ( ((originallyAttemptedLanes = workInProgressRootFatalError), - prepareFreshStack(workInProgressRootRenderLanes$11, 0), + prepareFreshStack(workInProgressRootRenderLanes$12, 0), markRootSuspended( - workInProgressRootRenderLanes$11, + workInProgressRootRenderLanes$12, nextLanes, 0 ), - ensureRootIsScheduled(workInProgressRootRenderLanes$11), + ensureRootIsScheduled(workInProgressRootRenderLanes$12), originallyAttemptedLanes) ); 6 === exitStatus ? markRootSuspended( - workInProgressRootRenderLanes$11, + workInProgressRootRenderLanes$12, nextLanes, workInProgressDeferredLane ) - : ((workInProgressRootRenderLanes$11.finishedWork = - workInProgressRootRenderLanes$11.current.alternate), - (workInProgressRootRenderLanes$11.finishedLanes = + : ((workInProgressRootRenderLanes$12.finishedWork = + workInProgressRootRenderLanes$12.current.alternate), + (workInProgressRootRenderLanes$12.finishedLanes = nextLanes), commitRoot( - workInProgressRootRenderLanes$11, + workInProgressRootRenderLanes$12, workInProgressRootRecoverableErrors, workInProgressTransitions, workInProgressRootDidIncludeRecursiveRenderUpdate, workInProgressDeferredLane )); } - ensureRootIsScheduled(workInProgressRootRenderLanes$11); + ensureRootIsScheduled(workInProgressRootRenderLanes$12); } catch (error) { null === errors ? (errors = [error]) : errors.push(error); } @@ -2336,12 +2384,12 @@ function scheduleTaskForRootDuringMicrotask(root, currentTime) { 0 < lanes; ) { - var index$5 = 31 - clz32(lanes), - lane = 1 << index$5, - expirationTime = expirationTimes[index$5]; + var index$6 = 31 - clz32(lanes), + lane = 1 << index$6, + expirationTime = expirationTimes[index$6]; if (-1 === expirationTime) { if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$5] = computeExpirationTime(lane, currentTime); + expirationTimes[index$6] = computeExpirationTime(lane, currentTime); } else expirationTime <= currentTime && (root.expiredLanes |= lane); lanes &= ~lane; } @@ -2398,6 +2446,71 @@ function scheduleTaskForRootDuringMicrotask(root, currentTime) { root.callbackNode = suspendedLanes; return currentTime; } +function requestTransitionLane() { + 0 === currentEventTransitionLane && + (currentEventTransitionLane = claimNextTransitionLane()); + return currentEventTransitionLane; +} +var currentEntangledListeners = null, + currentEntangledPendingCount = 0, + currentEntangledLane = 0, + currentEntangledActionThenable = null; +function entangleAsyncAction(transition, thenable) { + if (null === currentEntangledListeners) { + var entangledListeners = (currentEntangledListeners = []); + currentEntangledPendingCount = 0; + currentEntangledLane = requestTransitionLane(); + currentEntangledActionThenable = { + status: "pending", + value: void 0, + then: function (resolve) { + entangledListeners.push(resolve); + } + }; + } + currentEntangledPendingCount++; + thenable.then(pingEngtangledActionScope, pingEngtangledActionScope); + return thenable; +} +function pingEngtangledActionScope() { + if ( + null !== currentEntangledListeners && + 0 === --currentEntangledPendingCount + ) { + null !== currentEntangledActionThenable && + (currentEntangledActionThenable.status = "fulfilled"); + var listeners = currentEntangledListeners; + currentEntangledListeners = null; + currentEntangledLane = 0; + currentEntangledActionThenable = null; + for (var i = 0; i < listeners.length; i++) (0, listeners[i])(); + } +} +function chainThenableValue(thenable, result) { + var listeners = [], + thenableWithOverride = { + status: "pending", + value: null, + reason: null, + then: function (resolve) { + listeners.push(resolve); + } + }; + thenable.then( + function () { + thenableWithOverride.status = "fulfilled"; + thenableWithOverride.value = result; + for (var i = 0; i < listeners.length; i++) (0, listeners[i])(result); + }, + function (error) { + thenableWithOverride.status = "rejected"; + thenableWithOverride.reason = error; + for (error = 0; error < listeners.length; error++) + (0, listeners[error])(void 0); + } + ); + return thenableWithOverride; +} var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { @@ -2493,12 +2606,20 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { : (workInProgress.next = capturedUpdate); queue.lastBaseUpdate = capturedUpdate; } +var didReadFromEntangledAsyncAction = !1; +function suspendIfUpdateReadFromEntangledAsyncAction() { + if (didReadFromEntangledAsyncAction) { + var entangledActionThenable = currentEntangledActionThenable; + if (null !== entangledActionThenable) throw entangledActionThenable; + } +} function processUpdateQueue( workInProgress$jscomp$0, props, instance$jscomp$0, renderLanes ) { + didReadFromEntangledAsyncAction = !1; var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; var firstBaseUpdate = queue.firstBaseUpdate, @@ -2536,6 +2657,9 @@ function processUpdateQueue( ? (workInProgressRootRenderLanes & updateLane) === updateLane : (renderLanes & updateLane) === updateLane ) { + 0 !== updateLane && + updateLane === currentEntangledLane && + (didReadFromEntangledAsyncAction = !0); null !== current && (current = current.next = { @@ -2699,16 +2823,16 @@ function describeNativeComponentFrame(fn, construct) { } else { try { Fake.call(); - } catch (x$17) { - control = x$17; + } catch (x$18) { + control = x$18; } fn.call(Fake.prototype); } } else { try { throw Error(); - } catch (x$18) { - control = x$18; + } catch (x$19) { + control = x$19; } (Fake = fn()) && "function" === typeof Fake.catch && @@ -3836,6 +3960,13 @@ function renderWithHooksAgain(workInProgress, Component, props, secondArg) { } while (didScheduleRenderPhaseUpdateDuringThisPass); return children; } +function TransitionAwareHostComponent() { + if (!enableAsyncActions) throw Error("Not implemented."); + var maybeThenable = ReactCurrentDispatcher$1.current.useState()[0]; + return "function" === typeof maybeThenable.then + ? useThenable(maybeThenable) + : maybeThenable; +} function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; workInProgress.flags &= -2053; @@ -3970,9 +4101,11 @@ function basicStateReducer(state, action) { return "function" === typeof action ? action(state) : action; } function updateReducer(reducer) { - var hook = updateWorkInProgressHook(), - current = currentHook, - queue = hook.queue; + var hook = updateWorkInProgressHook(); + return updateReducerImpl(hook, currentHook, reducer); +} +function updateReducerImpl(hook, current, reducer) { + var queue = hook.queue; if (null === queue) throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." @@ -3995,52 +4128,83 @@ function updateReducer(reducer) { current = baseQueue.next; var newBaseQueueFirst = (baseFirst = null), newBaseQueueLast = null, - update = current; + update = current, + didReadFromEntangledAsyncAction$33 = !1; do { var updateLane = update.lane & -536870913; if ( updateLane !== update.lane ? (workInProgressRootRenderLanes & updateLane) === updateLane : (renderLanes & updateLane) === updateLane - ) - null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = - { + ) { + var revertLane = update.revertLane; + if (enableAsyncActions && 0 !== revertLane) + if ((renderLanes & revertLane) === revertLane) { + update = update.next; + revertLane === currentEntangledLane && + (didReadFromEntangledAsyncAction$33 = !0); + continue; + } else + (updateLane = { lane: 0, - revertLane: 0, + revertLane: update.revertLane, action: update.action, hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }), - (updateLane = update.action), - shouldDoubleInvokeUserFnsInHooksDEV && - reducer(pendingQueue, updateLane), - (pendingQueue = update.hasEagerState - ? update.eagerState - : reducer(pendingQueue, updateLane)); - else { - var clone = { + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = updateLane), + (baseFirst = pendingQueue)) + : (newBaseQueueLast = newBaseQueueLast.next = updateLane), + (currentlyRenderingFiber$1.lanes |= revertLane), + (workInProgressRootSkippedLanes |= revertLane); + else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = + { + lane: 0, + revertLane: 0, + action: update.action, + hasEagerState: update.hasEagerState, + eagerState: update.eagerState, + next: null + }), + updateLane === currentEntangledLane && + (didReadFromEntangledAsyncAction$33 = !0); + updateLane = update.action; + shouldDoubleInvokeUserFnsInHooksDEV && + reducer(pendingQueue, updateLane); + pendingQueue = update.hasEagerState + ? update.eagerState + : reducer(pendingQueue, updateLane); + } else + (revertLane = { lane: updateLane, revertLane: update.revertLane, action: update.action, hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null - }; - null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (baseFirst = pendingQueue)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - currentlyRenderingFiber$1.lanes |= updateLane; - workInProgressRootSkippedLanes |= updateLane; - } + }), + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = revertLane), + (baseFirst = pendingQueue)) + : (newBaseQueueLast = newBaseQueueLast.next = revertLane), + (currentlyRenderingFiber$1.lanes |= updateLane), + (workInProgressRootSkippedLanes |= updateLane); update = update.next; } while (null !== update && update !== current); null === newBaseQueueLast ? (baseFirst = pendingQueue) : (newBaseQueueLast.next = newBaseQueueFirst); - objectIs(pendingQueue, hook.memoizedState) || (didReceiveUpdate = !0); + if ( + !objectIs(pendingQueue, hook.memoizedState) && + ((didReceiveUpdate = !0), + didReadFromEntangledAsyncAction$33 && + ((reducer = currentEntangledActionThenable), null !== reducer)) + ) + throw reducer; hook.memoizedState = pendingQueue; hook.baseState = baseFirst; hook.baseQueue = newBaseQueueLast; @@ -4149,7 +4313,10 @@ function mountStateImpl(initialState) { if ("function" === typeof initialState) { var initialStateInitializer = initialState; initialState = initialStateInitializer(); - shouldDoubleInvokeUserFnsInHooksDEV && initialStateInitializer(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + initialStateInitializer(), + setIsStrictModeForDevtools(!1)); } hook.memoizedState = hook.baseState = initialState; hook.queue = { @@ -4161,6 +4328,180 @@ function mountStateImpl(initialState) { }; return hook; } +function mountOptimistic(passthrough) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = hook.baseState = passthrough; + var queue = { + pending: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: null, + lastRenderedState: null + }; + hook.queue = queue; + hook = dispatchOptimisticSetState.bind( + null, + currentlyRenderingFiber$1, + !0, + queue + ); + queue.dispatch = hook; + return [passthrough, hook]; +} +function updateOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); +} +function updateOptimisticImpl(hook, current, passthrough, reducer) { + hook.baseState = passthrough; + return updateReducerImpl( + hook, + currentHook, + "function" === typeof reducer ? reducer : basicStateReducer + ); +} +function rerenderOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + if (null !== currentHook) + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + hook.baseState = passthrough; + return [passthrough, hook.queue.dispatch]; +} +function dispatchFormState(fiber, actionQueue, setState, payload) { + if (isRenderPhaseUpdate(fiber)) + throw Error("Cannot update form state while rendering."); + fiber = actionQueue.pending; + null === fiber + ? ((fiber = { payload: payload, next: null }), + (fiber.next = actionQueue.pending = fiber), + runFormStateAction(actionQueue, setState, payload)) + : (actionQueue.pending = fiber.next = + { payload: payload, next: fiber.next }); +} +function runFormStateAction(actionQueue, setState, payload) { + var action = actionQueue.action, + prevState = actionQueue.state, + prevTransition = ReactCurrentBatchConfig$2.transition, + currentTransition = { _callbacks: new Set() }; + ReactCurrentBatchConfig$2.transition = currentTransition; + try { + var returnValue = action(prevState, payload); + null !== returnValue && + "object" === typeof returnValue && + "function" === typeof returnValue.then + ? (notifyTransitionCallbacks(currentTransition, returnValue), + returnValue.then( + function (nextState) { + actionQueue.state = nextState; + finishRunningFormStateAction(actionQueue, setState); + }, + function () { + return finishRunningFormStateAction(actionQueue, setState); + } + ), + setState(returnValue)) + : (setState(returnValue), + (actionQueue.state = returnValue), + finishRunningFormStateAction(actionQueue, setState)); + } catch (error) { + setState({ then: function () {}, status: "rejected", reason: error }), + finishRunningFormStateAction(actionQueue, setState); + } finally { + ReactCurrentBatchConfig$2.transition = prevTransition; + } +} +function finishRunningFormStateAction(actionQueue, setState) { + var last = actionQueue.pending; + if (null !== last) { + var first = last.next; + first === last + ? (actionQueue.pending = null) + : ((first = first.next), + (last.next = first), + runFormStateAction(actionQueue, setState, first.payload)); + } +} +function formStateReducer(oldState, newState) { + return newState; +} +function mountFormState(action, initialStateProp) { + var stateHook = mountWorkInProgressHook(); + stateHook.memoizedState = stateHook.baseState = initialStateProp; + var stateQueue = { + pending: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: formStateReducer, + lastRenderedState: initialStateProp + }; + stateHook.queue = stateQueue; + stateHook = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + stateQueue + ); + stateQueue.dispatch = stateHook; + stateQueue = mountWorkInProgressHook(); + var actionQueue = { + state: initialStateProp, + dispatch: null, + action: action, + pending: null + }; + stateQueue.queue = actionQueue; + stateHook = dispatchFormState.bind( + null, + currentlyRenderingFiber$1, + actionQueue, + stateHook + ); + actionQueue.dispatch = stateHook; + stateQueue.memoizedState = action; + return [initialStateProp, stateHook]; +} +function updateFormState(action) { + var stateHook = updateWorkInProgressHook(); + return updateFormStateImpl(stateHook, currentHook, action); +} +function updateFormStateImpl(stateHook, currentStateHook, action) { + stateHook = updateReducerImpl( + stateHook, + currentStateHook, + formStateReducer + )[0]; + stateHook = + "object" === typeof stateHook && + null !== stateHook && + "function" === typeof stateHook.then + ? useThenable(stateHook) + : stateHook; + currentStateHook = updateWorkInProgressHook(); + var actionQueue = currentStateHook.queue, + dispatch = actionQueue.dispatch; + action !== currentStateHook.memoizedState && + ((currentlyRenderingFiber$1.flags |= 2048), + pushEffect( + 9, + formStateActionEffect.bind(null, actionQueue, action), + { destroy: void 0 }, + null + )); + return [stateHook, dispatch]; +} +function formStateActionEffect(actionQueue, action) { + actionQueue.action = action; +} +function rerenderFormState(action) { + var stateHook = updateWorkInProgressHook(), + currentStateHook = currentHook; + if (null !== currentStateHook) + return updateFormStateImpl(stateHook, currentStateHook, action); + stateHook = stateHook.memoizedState; + currentStateHook = updateWorkInProgressHook(); + var dispatch = currentStateHook.queue.dispatch; + currentStateHook.memoizedState = action; + return [stateHook, dispatch]; +} function pushEffect(tag, create, inst, deps) { tag = { tag: tag, create: create, inst: inst, deps: deps, next: null }; create = currentlyRenderingFiber$1.updateQueue; @@ -4252,7 +4593,10 @@ function updateMemo(nextCreate, deps) { if (null !== deps && areHookInputsEqual(deps, prevState[1])) return prevState[0]; prevState = nextCreate(); - shouldDoubleInvokeUserFnsInHooksDEV && nextCreate(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + nextCreate(), + setIsStrictModeForDevtools(!1)); hook.memoizedState = [prevState, deps]; return prevState; } @@ -4286,18 +4630,46 @@ function startTransition(fiber, queue, pendingState, finishedState, callback) { 0 !== previousPriority && 8 > previousPriority ? previousPriority : 8; var prevTransition = ReactCurrentBatchConfig$2.transition, currentTransition = { _callbacks: new Set() }; - ReactCurrentBatchConfig$2.transition = null; - dispatchSetState(fiber, queue, pendingState); - ReactCurrentBatchConfig$2.transition = currentTransition; + enableAsyncActions + ? ((ReactCurrentBatchConfig$2.transition = currentTransition), + dispatchOptimisticSetState(fiber, !1, queue, pendingState)) + : ((ReactCurrentBatchConfig$2.transition = null), + dispatchSetState(fiber, queue, pendingState), + (ReactCurrentBatchConfig$2.transition = currentTransition)); try { - dispatchSetState(fiber, queue, finishedState), callback(); + if (enableAsyncActions) { + var returnValue = callback(); + if ( + null !== returnValue && + "object" === typeof returnValue && + "function" === typeof returnValue.then + ) { + notifyTransitionCallbacks(currentTransition, returnValue); + var thenableForFinishedState = chainThenableValue( + returnValue, + finishedState + ); + dispatchSetState(fiber, queue, thenableForFinishedState); + } else dispatchSetState(fiber, queue, finishedState); + } else dispatchSetState(fiber, queue, finishedState), callback(); } catch (error) { - throw error; + if (enableAsyncActions) + dispatchSetState(fiber, queue, { + then: function () {}, + status: "rejected", + reason: error + }); + else throw error; } finally { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$2.transition = prevTransition); } } +function useHostTransitionStatus() { + if (!enableAsyncActions) throw Error("Not implemented."); + var status = readContext(HostTransitionContext); + return null !== status ? status : null; +} function updateId() { return updateWorkInProgressHook().memoizedState; } @@ -4334,8 +4706,7 @@ function dispatchReducerAction(fiber, queue, action) { }; isRenderPhaseUpdate(fiber) ? enqueueRenderPhaseUpdate(queue, action) - : (enqueueUpdate$1(fiber, queue, action, lane), - (action = getRootForUpdatedFiber(fiber)), + : ((action = enqueueConcurrentHookUpdate(fiber, queue, action, lane)), null !== action && (scheduleUpdateOnFiber(action, fiber, lane), entangleTransitionUpdate(action, queue, lane))); @@ -4371,13 +4742,35 @@ function dispatchSetState(fiber, queue, action) { } catch (error) { } finally { } - enqueueUpdate$1(fiber, queue, update, lane); - action = getRootForUpdatedFiber(fiber); + action = enqueueConcurrentHookUpdate(fiber, queue, update, lane); null !== action && (scheduleUpdateOnFiber(action, fiber, lane), entangleTransitionUpdate(action, queue, lane)); } } +function dispatchOptimisticSetState(fiber, throwIfDuringRender, queue, action) { + requestCurrentTransition(); + action = { + lane: 2, + revertLane: requestTransitionLane(), + action: action, + hasEagerState: !1, + eagerState: null, + next: null + }; + if (isRenderPhaseUpdate(fiber)) { + if (throwIfDuringRender) + throw Error("Cannot update optimistic state while rendering."); + } else + (throwIfDuringRender = enqueueConcurrentHookUpdate( + fiber, + queue, + action, + 2 + )), + null !== throwIfDuringRender && + scheduleUpdateOnFiber(throwIfDuringRender, fiber, 2); +} function isRenderPhaseUpdate(fiber) { var alternate = fiber.alternate; return ( @@ -4424,6 +4817,11 @@ var ContextOnlyDispatcher = { }; ContextOnlyDispatcher.useCacheRefresh = throwInvalidHookError; ContextOnlyDispatcher.useMemoCache = throwInvalidHookError; +enableAsyncActions && + ((ContextOnlyDispatcher.useHostTransitionStatus = throwInvalidHookError), + (ContextOnlyDispatcher.useFormState = throwInvalidHookError)); +enableAsyncActions && + (ContextOnlyDispatcher.useOptimistic = throwInvalidHookError); var HooksDispatcherOnMount = { readContext: readContext, use: use, @@ -4455,7 +4853,10 @@ var HooksDispatcherOnMount = { var hook = mountWorkInProgressHook(); deps = void 0 === deps ? null : deps; var nextValue = nextCreate(); - shouldDoubleInvokeUserFnsInHooksDEV && nextCreate(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + nextCreate(), + setIsStrictModeForDevtools(!1)); hook.memoizedState = [nextValue, deps]; return nextValue; }, @@ -4463,7 +4864,10 @@ var HooksDispatcherOnMount = { var hook = mountWorkInProgressHook(); if (void 0 !== init) { var initialState = init(initialArg); - shouldDoubleInvokeUserFnsInHooksDEV && init(initialArg); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + init(initialArg), + setIsStrictModeForDevtools(!1)); } else initialState = initialArg; hook.memoizedState = hook.baseState = initialState; reducer = { @@ -4556,6 +4960,10 @@ var HooksDispatcherOnMount = { } }; HooksDispatcherOnMount.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnMount.useHostTransitionStatus = useHostTransitionStatus), + (HooksDispatcherOnMount.useFormState = mountFormState)); +enableAsyncActions && (HooksDispatcherOnMount.useOptimistic = mountOptimistic); var HooksDispatcherOnUpdate = { readContext: readContext, use: use, @@ -4596,6 +5004,11 @@ var HooksDispatcherOnUpdate = { }; HooksDispatcherOnUpdate.useCacheRefresh = updateRefresh; HooksDispatcherOnUpdate.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnUpdate.useHostTransitionStatus = useHostTransitionStatus), + (HooksDispatcherOnUpdate.useFormState = updateFormState)); +enableAsyncActions && + (HooksDispatcherOnUpdate.useOptimistic = updateOptimistic); var HooksDispatcherOnRerender = { readContext: readContext, use: use, @@ -4638,6 +5051,12 @@ var HooksDispatcherOnRerender = { }; HooksDispatcherOnRerender.useCacheRefresh = updateRefresh; HooksDispatcherOnRerender.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnRerender.useHostTransitionStatus = + useHostTransitionStatus), + (HooksDispatcherOnRerender.useFormState = rerenderFormState)); +enableAsyncActions && + (HooksDispatcherOnRerender.useOptimistic = rerenderOptimistic); function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = assign({}, baseProps); @@ -4793,6 +5212,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), processUpdateQueue(workInProgress, newProps, instance, renderLanes), + suspendIfUpdateReadFromEntangledAsyncAction(), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); @@ -5346,6 +5766,7 @@ function updateClassComponent( var oldState = workInProgress.memoizedState; instance.state = oldState; processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -5425,6 +5846,7 @@ function updateClassComponent( oldState = workInProgress.memoizedState; instance.state = oldState; processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); var newState = workInProgress.memoizedState; oldProps !== hasNewLifecycles || oldState !== newState || @@ -6109,7 +6531,9 @@ function attemptEarlyBailoutIfNoScheduledUpdate( case 10: pushProvider( workInProgress, - workInProgress.type._context, + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context, workInProgress.memoizedProps.value ); break; @@ -6339,7 +6763,19 @@ function releaseCache(cache) { }); } var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; -function handleAsyncAction() {} +function requestCurrentTransition() { + var transition = ReactCurrentBatchConfig$1.transition; + null !== transition && transition._callbacks.add(handleAsyncAction); + return transition; +} +function handleAsyncAction(transition, thenable) { + enableAsyncActions && entangleAsyncAction(transition, thenable); +} +function notifyTransitionCallbacks(transition, returnValue) { + transition._callbacks.forEach(function (callback) { + return callback(transition, returnValue); + }); +} var resumedCache = createCursor(null); function peekCacheFromPool() { var cacheResumedFromPreviousRender = resumedCache.current; @@ -6380,14 +6816,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$68 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$68 = lastTailNode), + for (var lastTailNode$72 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$72 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$68 + null === lastTailNode$72 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$68.sibling = null); + : (lastTailNode$72.sibling = null); } } function bubbleProperties(completedWork) { @@ -6397,19 +6833,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$69 = completedWork.child; null !== child$69; ) - (newChildLanes |= child$69.lanes | child$69.childLanes), - (subtreeFlags |= child$69.subtreeFlags & 31457280), - (subtreeFlags |= child$69.flags & 31457280), - (child$69.return = completedWork), - (child$69 = child$69.sibling); + for (var child$73 = completedWork.child; null !== child$73; ) + (newChildLanes |= child$73.lanes | child$73.childLanes), + (subtreeFlags |= child$73.subtreeFlags & 31457280), + (subtreeFlags |= child$73.flags & 31457280), + (child$73.return = completedWork), + (child$73 = child$73.sibling); else - for (child$69 = completedWork.child; null !== child$69; ) - (newChildLanes |= child$69.lanes | child$69.childLanes), - (subtreeFlags |= child$69.subtreeFlags), - (subtreeFlags |= child$69.flags), - (child$69.return = completedWork), - (child$69 = child$69.sibling); + for (child$73 = completedWork.child; null !== child$73; ) + (newChildLanes |= child$73.lanes | child$73.childLanes), + (subtreeFlags |= child$73.subtreeFlags), + (subtreeFlags |= child$73.flags), + (child$73.return = completedWork), + (child$73 = child$73.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6604,7 +7040,11 @@ function completeWork(current, workInProgress, renderLanes) { return popHostContainer(), bubbleProperties(workInProgress), null; case 10: return ( - popProvider(workInProgress.type._context), + popProvider( + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context + ), bubbleProperties(workInProgress), null ); @@ -6798,7 +7238,14 @@ function unwindWork(current, workInProgress) { case 4: return popHostContainer(), null; case 10: - return popProvider(workInProgress.type._context), null; + return ( + popProvider( + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context + ), + null + ); case 22: case 23: return ( @@ -6845,7 +7292,11 @@ function unwindInterruptedWork(current, interruptedWork) { pop(suspenseStackCursor); break; case 10: - popProvider(interruptedWork.type._context); + popProvider( + enableRenderableContext + ? interruptedWork.type + : interruptedWork.type._context + ); break; case 22: case 23: @@ -6900,8 +7351,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { else if ("function" === typeof ref) try { ref(null); - } catch (error$91) { - captureCommitPhaseError(current, nearestMountedAncestor, error$91); + } catch (error$95) { + captureCommitPhaseError(current, nearestMountedAncestor, error$95); } else ref.current = null; } @@ -7005,10 +7456,10 @@ function commitHookEffectListMount(flags, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & flags) === flags) { - var create$92 = effect.create, + var create$96 = effect.create, inst = effect.inst; - create$92 = create$92(); - inst.destroy = create$92; + create$96 = create$96(); + inst.destroy = create$96; } effect = effect.next; } while (effect !== finishedWork); @@ -7062,11 +7513,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$93) { + } catch (error$97) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$93 + error$97 ); } } @@ -7529,8 +7980,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { } try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$101) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$101); + } catch (error$105) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$105); } } break; @@ -7577,8 +8028,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { viewConfig.uiViewClassName, updatePayload ); - } catch (error$104) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$104); + } catch (error$108) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$108); } } break; @@ -7598,8 +8049,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { "RCTRawText", { text: current } ); - } catch (error$105) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$105); + } catch (error$109) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$109); } } break; @@ -7711,11 +8162,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { throw Error("Not yet implemented."); - } catch (error$95) { + } catch (error$99) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$95 + error$99 ); } } else if ( @@ -7789,12 +8240,12 @@ function commitReconciliationEffects(finishedWork) { break; case 3: case 4: - var parent$96 = JSCompiler_inline_result.stateNode.containerInfo, - before$97 = getHostSibling(finishedWork); + var parent$100 = JSCompiler_inline_result.stateNode.containerInfo, + before$101 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$97, - parent$96 + before$101, + parent$100 ); break; default: @@ -8444,13 +8895,10 @@ function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 2; if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; - fiber = ReactCurrentBatchConfig$1.transition; - null !== fiber && fiber._callbacks.add(handleAsyncAction); - if (null !== fiber) + if (null !== requestCurrentTransition()) return ( - 0 === currentEventTransitionLane && - (currentEventTransitionLane = claimNextTransitionLane()), - currentEventTransitionLane + (fiber = currentEntangledLane), + 0 !== fiber ? fiber : requestTransitionLane() ); fiber = currentUpdatePriority; return 0 !== fiber ? fiber : 32; @@ -8722,9 +9170,9 @@ function markRootSuspended(root, suspendedLanes, spawnedLane) { 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6; - expirationTimes[index$6] = -1; + var index$7 = 31 - clz32(lanes), + lane = 1 << index$7; + expirationTimes[index$7] = -1; lanes &= ~lane; } 0 !== spawnedLane && @@ -8781,9 +9229,9 @@ function prepareFreshStack(root, lanes) { 0 < allEntangledLanes; ) { - var index$4 = 31 - clz32(allEntangledLanes), - lane = 1 << index$4; - lanes |= root[index$4]; + var index$5 = 31 - clz32(allEntangledLanes), + lane = 1 << index$5; + lanes |= root[index$5]; allEntangledLanes &= ~lane; } entangledRenderLanes = lanes; @@ -8878,8 +9326,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$113) { - handleThrow(root, thrownValue$113); + } catch (thrownValue$117) { + handleThrow(root, thrownValue$117); } while (1); lanes && root.shellSuspendCounter++; @@ -8987,8 +9435,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$115) { - handleThrow(root, thrownValue$115); + } catch (thrownValue$119) { + handleThrow(root, thrownValue$119); } while (1); resetContextDependencies(); @@ -9608,6 +10056,7 @@ beginWork = function (current, workInProgress, renderLanes) { pushProvider(workInProgress, CacheContext, nextCache); nextCache !== context.cache && propagateContextChange(workInProgress, CacheContext, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); context = nextProps.element; context === Component ? (workInProgress = bailoutOnAlreadyFinishedWork( @@ -9621,13 +10070,31 @@ beginWork = function (current, workInProgress, renderLanes) { case 26: case 27: case 5: - return ( - pushHostContext(workInProgress), - (Component = workInProgress.pendingProps.children), - markRef(current, workInProgress), - reconcileChildren(current, workInProgress, Component, renderLanes), - workInProgress.child - ); + pushHostContext(workInProgress); + Component = workInProgress.pendingProps.children; + if (enableAsyncActions && null !== workInProgress.memoizedState) { + if (!enableAsyncActions) throw Error("Not implemented."); + context = renderWithHooks( + current, + workInProgress, + TransitionAwareHostComponent, + null, + null, + renderLanes + ); + HostTransitionContext._currentValue = context; + didReceiveUpdate && + null !== current && + current.memoizedState.memoizedState !== context && + propagateContextChange( + workInProgress, + HostTransitionContext, + renderLanes + ); + } + markRef(current, workInProgress); + reconcileChildren(current, workInProgress, Component, renderLanes); + return workInProgress.child; case 6: return null; case 13: @@ -9697,7 +10164,9 @@ beginWork = function (current, workInProgress, renderLanes) { ); case 10: a: { - Component = workInProgress.type._context; + Component = enableRenderableContext + ? workInProgress.type + : workInProgress.type._context; context = workInProgress.pendingProps; nextProps = workInProgress.memoizedProps; nextCache = context.value; @@ -9727,7 +10196,9 @@ beginWork = function (current, workInProgress, renderLanes) { return workInProgress; case 9: return ( - (context = workInProgress.type), + (context = enableRenderableContext + ? workInProgress.type._context + : workInProgress.type), (Component = workInProgress.pendingProps.children), prepareToReadContext(workInProgress, renderLanes), (context = readContext(context)), @@ -9807,7 +10278,8 @@ beginWork = function (current, workInProgress, renderLanes) { pushProvider(workInProgress, CacheContext, context)) : (0 !== (current.lanes & renderLanes) && (cloneUpdateQueue(current, workInProgress), - processUpdateQueue(workInProgress, null, null, renderLanes)), + processUpdateQueue(workInProgress, null, null, renderLanes), + suspendIfUpdateReadFromEntangledAsyncAction()), (context = current.memoizedState), (nextProps = workInProgress.memoizedState), context.parent !== Component @@ -10011,12 +10483,18 @@ function createFiberFromTypeAndProps( if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 10; - break a; + if (!enableRenderableContext) { + fiberTag = 10; + break a; + } case REACT_CONTEXT_TYPE: - fiberTag = 9; + fiberTag = enableRenderableContext ? 10 : 9; break a; case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + fiberTag = 9; + break a; + } case REACT_FORWARD_REF_TYPE: fiberTag = 11; break a; @@ -10376,10 +10854,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1212 = { + devToolsConfig$jscomp$inline_1175 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-canary-616ff908", + version: "18.3.0-canary-3ee67a63", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10395,11 +10873,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1452 = { - bundleType: devToolsConfig$jscomp$inline_1212.bundleType, - version: devToolsConfig$jscomp$inline_1212.version, - rendererPackageName: devToolsConfig$jscomp$inline_1212.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1212.rendererConfig, +var internals$jscomp$inline_1416 = { + bundleType: devToolsConfig$jscomp$inline_1175.bundleType, + version: devToolsConfig$jscomp$inline_1175.version, + rendererPackageName: devToolsConfig$jscomp$inline_1175.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1175.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10415,26 +10893,26 @@ var internals$jscomp$inline_1452 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1212.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1175.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-616ff908" + reconcilerVersion: "18.3.0-canary-3ee67a63" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1453 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1417 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1453.isDisabled && - hook$jscomp$inline_1453.supportsFiber + !hook$jscomp$inline_1417.isDisabled && + hook$jscomp$inline_1417.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1453.inject( - internals$jscomp$inline_1452 + (rendererID = hook$jscomp$inline_1417.inject( + internals$jscomp$inline_1416 )), - (injectedHook = hook$jscomp$inline_1453); + (injectedHook = hook$jscomp$inline_1417); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index a34d8a421da21..1d5b50c440fe6 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<4bb498281f0ee9de51d06a86a2edfd96>> + * @generated SignedSource<<40cce64c667942ad2417fd8c5505f8c3>> */ "use strict"; @@ -939,7 +939,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_278 = { +var injectedNamesToPlugins$jscomp$inline_277 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -985,32 +985,32 @@ var injectedNamesToPlugins$jscomp$inline_278 = { } } }, - isOrderingDirty$jscomp$inline_279 = !1, - pluginName$jscomp$inline_280; -for (pluginName$jscomp$inline_280 in injectedNamesToPlugins$jscomp$inline_278) + isOrderingDirty$jscomp$inline_278 = !1, + pluginName$jscomp$inline_279; +for (pluginName$jscomp$inline_279 in injectedNamesToPlugins$jscomp$inline_277) if ( - injectedNamesToPlugins$jscomp$inline_278.hasOwnProperty( - pluginName$jscomp$inline_280 + injectedNamesToPlugins$jscomp$inline_277.hasOwnProperty( + pluginName$jscomp$inline_279 ) ) { - var pluginModule$jscomp$inline_281 = - injectedNamesToPlugins$jscomp$inline_278[pluginName$jscomp$inline_280]; + var pluginModule$jscomp$inline_280 = + injectedNamesToPlugins$jscomp$inline_277[pluginName$jscomp$inline_279]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_280) || - namesToPlugins[pluginName$jscomp$inline_280] !== - pluginModule$jscomp$inline_281 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_279) || + namesToPlugins[pluginName$jscomp$inline_279] !== + pluginModule$jscomp$inline_280 ) { - if (namesToPlugins[pluginName$jscomp$inline_280]) + if (namesToPlugins[pluginName$jscomp$inline_279]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_280 + "`.") + (pluginName$jscomp$inline_279 + "`.") ); - namesToPlugins[pluginName$jscomp$inline_280] = - pluginModule$jscomp$inline_281; - isOrderingDirty$jscomp$inline_279 = !0; + namesToPlugins[pluginName$jscomp$inline_279] = + pluginModule$jscomp$inline_280; + isOrderingDirty$jscomp$inline_278 = !0; } } -isOrderingDirty$jscomp$inline_279 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_278 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1159,13 +1159,17 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries, + consoleManagedByDevToolsDuringStrictMode = + dynamicFlags.consoleManagedByDevToolsDuringStrictMode, + enableAsyncActions = dynamicFlags.enableAsyncActions, enableComponentStackLocations = dynamicFlags.enableComponentStackLocations, enableDeferRootSchedulingToMicrotask = dynamicFlags.enableDeferRootSchedulingToMicrotask, - enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, - enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, enableInfiniteRenderLoopDetection = dynamicFlags.enableInfiniteRenderLoopDetection, + enableRenderableContext = dynamicFlags.enableRenderableContext, + enableUnifiedSyncLane = dynamicFlags.enableUnifiedSyncLane, + enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning, REACT_ELEMENT_TYPE = Symbol.for("react.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), @@ -1221,9 +1225,16 @@ function getComponentNameFromType(type) { if ("object" === typeof type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - return (type._context.displayName || "Context") + ".Provider"; + if (enableRenderableContext) break; + else return (type._context.displayName || "Context") + ".Provider"; case REACT_CONTEXT_TYPE: - return (type.displayName || "Context") + ".Consumer"; + return enableRenderableContext + ? (type.displayName || "Context") + ".Provider" + : (type.displayName || "Context") + ".Consumer"; + case REACT_CONSUMER_TYPE: + if (enableRenderableContext) + return (type._context.displayName || "Context") + ".Consumer"; + break; case REACT_FORWARD_REF_TYPE: var innerType = type.render; type = type.displayName; @@ -1253,9 +1264,13 @@ function getComponentNameFromFiber(fiber) { case 24: return "Cache"; case 9: - return (type.displayName || "Context") + ".Consumer"; + return enableRenderableContext + ? (type._context.displayName || "Context") + ".Consumer" + : (type.displayName || "Context") + ".Consumer"; case 10: - return (type._context.displayName || "Context") + ".Provider"; + return enableRenderableContext + ? (type.displayName || "Context") + ".Provider" + : (type._context.displayName || "Context") + ".Provider"; case 18: return "DehydratedFragment"; case 11: @@ -1353,36 +1368,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$1 = parentA.child; child$1; ) { - if (child$1 === a) { + for (var didFindChild = !1, child$2 = parentA.child; child$2; ) { + if (child$2 === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$1 === b) { + if (child$2 === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$1 = child$1.sibling; + child$2 = child$2.sibling; } if (!didFindChild) { - for (child$1 = parentB.child; child$1; ) { - if (child$1 === a) { + for (child$2 = parentB.child; child$2; ) { + if (child$2 === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$1 === b) { + if (child$2 === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$1 = child$1.sibling; + child$2 = child$2.sibling; } if (!didFindChild) throw Error( @@ -1616,19 +1631,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var propKey$3 in prevProps) - void 0 === nextProps[propKey$3] && - (!(attributeConfig = validAttributes[propKey$3]) || - (updatePayload && void 0 !== updatePayload[propKey$3]) || - ((prevProp = prevProps[propKey$3]), + for (var propKey$4 in prevProps) + void 0 === nextProps[propKey$4] && + (!(attributeConfig = validAttributes[propKey$4]) || + (updatePayload && void 0 !== updatePayload[propKey$4]) || + ((prevProp = prevProps[propKey$4]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[propKey$3] = null), + ? (((updatePayload || (updatePayload = {}))[propKey$4] = null), removedKeys || (removedKeys = {}), - removedKeys[propKey$3] || - ((removedKeys[propKey$3] = !0), removedKeyCount++)) + removedKeys[propKey$4] || + ((removedKeys[propKey$4] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1710,6 +1725,8 @@ var ReactNativeFiberHostComponent = (function () { UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, NormalPriority$1 = Scheduler.unstable_NormalPriority, IdlePriority = Scheduler.unstable_IdlePriority, + log$1 = Scheduler.log, + unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue, rendererID = null, injectedHook = null, injectedProfilingHooks = null, @@ -1742,11 +1759,22 @@ function onCommitRoot(root, eventPriority) { ); } catch (err) {} } +function setIsStrictModeForDevtools(newIsStrictMode) { + if ( + consoleManagedByDevToolsDuringStrictMode && + ("function" === typeof log$1 && + unstable_setDisableYieldValue(newIsStrictMode), + injectedHook && "function" === typeof injectedHook.setStrictMode) + ) + try { + injectedHook.setStrictMode(rendererID, newIsStrictMode); + } catch (err) {} +} function injectProfilingHooks(profilingHooks) { injectedProfilingHooks = profilingHooks; } function getLaneLabelMap() { - for (var map = new Map(), lane = 1, index$4 = 0; 31 > index$4; index$4++) { + for (var map = new Map(), lane = 1, index$5 = 0; 31 > index$5; index$5++) { var label = getLabelForLane(lane); map.set(lane, label); lane *= 2; @@ -1983,18 +2011,18 @@ function markRootFinished(root, remainingLanes, spawnedLane) { 0 < noLongerPendingLanes; ) { - var index$8 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$8; - remainingLanes[index$8] = 0; - expirationTimes[index$8] = -1; - var hiddenUpdatesForLane = hiddenUpdates[index$8]; + var index$9 = 31 - clz32(noLongerPendingLanes), + lane = 1 << index$9; + remainingLanes[index$9] = 0; + expirationTimes[index$9] = -1; + var hiddenUpdatesForLane = hiddenUpdates[index$9]; if (null !== hiddenUpdatesForLane) for ( - hiddenUpdates[index$8] = null, index$8 = 0; - index$8 < hiddenUpdatesForLane.length; - index$8++ + hiddenUpdates[index$9] = null, index$9 = 0; + index$9 < hiddenUpdatesForLane.length; + index$9++ ) { - var update = hiddenUpdatesForLane[index$8]; + var update = hiddenUpdatesForLane[index$9]; null !== update && (update.lane &= -536870913); } noLongerPendingLanes &= ~lane; @@ -2014,19 +2042,19 @@ function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) { function markRootEntangled(root, entangledLanes) { var rootEntangledLanes = (root.entangledLanes |= entangledLanes); for (root = root.entanglements; rootEntangledLanes; ) { - var index$9 = 31 - clz32(rootEntangledLanes), - lane = 1 << index$9; - (lane & entangledLanes) | (root[index$9] & entangledLanes) && - (root[index$9] |= entangledLanes); + var index$10 = 31 - clz32(rootEntangledLanes), + lane = 1 << index$10; + (lane & entangledLanes) | (root[index$10] & entangledLanes) && + (root[index$10] |= entangledLanes); rootEntangledLanes &= ~lane; } } function addFiberToLanesMap(root, fiber, lanes) { if (isDevToolsPresent) for (root = root.pendingUpdatersLaneMap; 0 < lanes; ) { - var index$10 = 31 - clz32(lanes), - lane = 1 << index$10; - root[index$10].add(fiber); + var index$11 = 31 - clz32(lanes), + lane = 1 << index$11; + root[index$11].add(fiber); lanes &= ~lane; } } @@ -2038,16 +2066,16 @@ function movePendingFibersToMemoized(root, lanes) { 0 < lanes; ) { - var index$11 = 31 - clz32(lanes); - root = 1 << index$11; - index$11 = pendingUpdatersLaneMap[index$11]; - 0 < index$11.size && - (index$11.forEach(function (fiber) { + var index$12 = 31 - clz32(lanes); + root = 1 << index$12; + index$12 = pendingUpdatersLaneMap[index$12]; + 0 < index$12.size && + (index$12.forEach(function (fiber) { var alternate = fiber.alternate; (null !== alternate && memoizedUpdaters.has(alternate)) || memoizedUpdaters.add(fiber); }), - index$11.clear()); + index$12.clear()); lanes &= ~root; } } @@ -2207,7 +2235,16 @@ function is(x, y) { var objectIs = "function" === typeof Object.is ? Object.is : is, contextStackCursor = createCursor(null), contextFiberStackCursor = createCursor(null), - rootInstanceStackCursor = createCursor(null); + rootInstanceStackCursor = createCursor(null), + hostTransitionProviderCursor = createCursor(null), + HostTransitionContext = { + $$typeof: REACT_CONTEXT_TYPE, + _currentValue: null, + _currentValue2: null, + _threadCount: 0, + Provider: null, + Consumer: null + }; function pushHostContainer(fiber, nextRootInstance) { push(rootInstanceStackCursor, nextRootInstance); push(contextFiberStackCursor, fiber); @@ -2221,6 +2258,9 @@ function popHostContainer() { pop(rootInstanceStackCursor); } function pushHostContext(fiber) { + enableAsyncActions && + null !== fiber.memoizedState && + push(hostTransitionProviderCursor, fiber); var context = contextStackCursor.current; var JSCompiler_inline_result = fiber.type; JSCompiler_inline_result = @@ -2240,6 +2280,10 @@ function pushHostContext(fiber) { function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor), pop(contextFiberStackCursor)); + enableAsyncActions && + hostTransitionProviderCursor.current === fiber && + (pop(hostTransitionProviderCursor), + (HostTransitionContext._currentValue = null)); } var hydrationErrors = null, concurrentQueues = [], @@ -2280,6 +2324,10 @@ function enqueueUpdate$1(fiber, queue, update, lane) { fiber = fiber.alternate; null !== fiber && (fiber.lanes |= lane); } +function enqueueConcurrentHookUpdate(fiber, queue, update, lane) { + enqueueUpdate$1(fiber, queue, update, lane); + return getRootForUpdatedFiber(fiber); +} function enqueueConcurrentRenderForLane(fiber, lane) { enqueueUpdate$1(fiber, null, null, lane); return getRootForUpdatedFiber(fiber); @@ -2342,37 +2390,37 @@ function flushSyncWorkAcrossRoots_impl(onlyLegacy) { var didPerformSomeWork = !1; for (var root = firstScheduledRoot; null !== root; ) { if (!onlyLegacy || 0 === root.tag) { - var workInProgressRootRenderLanes$14 = workInProgressRootRenderLanes, + var workInProgressRootRenderLanes$15 = workInProgressRootRenderLanes, nextLanes = getNextLanes( root, - root === workInProgressRoot ? workInProgressRootRenderLanes$14 : 0 + root === workInProgressRoot ? workInProgressRootRenderLanes$15 : 0 ); if (0 !== (nextLanes & 3)) try { didPerformSomeWork = !0; - workInProgressRootRenderLanes$14 = root; + workInProgressRootRenderLanes$15 = root; if (0 !== (executionContext & 6)) throw Error("Should not already be working."); if (!flushPassiveEffects()) { currentUpdateIsNested = nestedUpdateScheduled; nestedUpdateScheduled = !1; var exitStatus = renderRootSync( - workInProgressRootRenderLanes$14, + workInProgressRootRenderLanes$15, nextLanes ); if ( - 0 !== workInProgressRootRenderLanes$14.tag && + 0 !== workInProgressRootRenderLanes$15.tag && 2 === exitStatus ) { var originallyAttemptedLanes = nextLanes, errorRetryLanes = getLanesToRetrySynchronouslyOnError( - workInProgressRootRenderLanes$14, + workInProgressRootRenderLanes$15, originallyAttemptedLanes ); 0 !== errorRetryLanes && ((nextLanes = errorRetryLanes), (exitStatus = recoverFromConcurrentError( - workInProgressRootRenderLanes$14, + workInProgressRootRenderLanes$15, originallyAttemptedLanes, errorRetryLanes ))); @@ -2380,34 +2428,34 @@ function flushSyncWorkAcrossRoots_impl(onlyLegacy) { if (1 === exitStatus) throw ( ((originallyAttemptedLanes = workInProgressRootFatalError), - prepareFreshStack(workInProgressRootRenderLanes$14, 0), + prepareFreshStack(workInProgressRootRenderLanes$15, 0), markRootSuspended( - workInProgressRootRenderLanes$14, + workInProgressRootRenderLanes$15, nextLanes, 0 ), - ensureRootIsScheduled(workInProgressRootRenderLanes$14), + ensureRootIsScheduled(workInProgressRootRenderLanes$15), originallyAttemptedLanes) ); 6 === exitStatus ? markRootSuspended( - workInProgressRootRenderLanes$14, + workInProgressRootRenderLanes$15, nextLanes, workInProgressDeferredLane ) - : ((workInProgressRootRenderLanes$14.finishedWork = - workInProgressRootRenderLanes$14.current.alternate), - (workInProgressRootRenderLanes$14.finishedLanes = + : ((workInProgressRootRenderLanes$15.finishedWork = + workInProgressRootRenderLanes$15.current.alternate), + (workInProgressRootRenderLanes$15.finishedLanes = nextLanes), commitRoot( - workInProgressRootRenderLanes$14, + workInProgressRootRenderLanes$15, workInProgressRootRecoverableErrors, workInProgressTransitions, workInProgressRootDidIncludeRecursiveRenderUpdate, workInProgressDeferredLane )); } - ensureRootIsScheduled(workInProgressRootRenderLanes$14); + ensureRootIsScheduled(workInProgressRootRenderLanes$15); } catch (error) { null === errors ? (errors = [error]) : errors.push(error); } @@ -2460,12 +2508,12 @@ function scheduleTaskForRootDuringMicrotask(root, currentTime) { 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6, - expirationTime = expirationTimes[index$6]; + var index$7 = 31 - clz32(lanes), + lane = 1 << index$7, + expirationTime = expirationTimes[index$7]; if (-1 === expirationTime) { if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) - expirationTimes[index$6] = computeExpirationTime(lane, currentTime); + expirationTimes[index$7] = computeExpirationTime(lane, currentTime); } else expirationTime <= currentTime && (root.expiredLanes |= lane); lanes &= ~lane; } @@ -2522,6 +2570,71 @@ function scheduleTaskForRootDuringMicrotask(root, currentTime) { root.callbackNode = suspendedLanes; return currentTime; } +function requestTransitionLane() { + 0 === currentEventTransitionLane && + (currentEventTransitionLane = claimNextTransitionLane()); + return currentEventTransitionLane; +} +var currentEntangledListeners = null, + currentEntangledPendingCount = 0, + currentEntangledLane = 0, + currentEntangledActionThenable = null; +function entangleAsyncAction(transition, thenable) { + if (null === currentEntangledListeners) { + var entangledListeners = (currentEntangledListeners = []); + currentEntangledPendingCount = 0; + currentEntangledLane = requestTransitionLane(); + currentEntangledActionThenable = { + status: "pending", + value: void 0, + then: function (resolve) { + entangledListeners.push(resolve); + } + }; + } + currentEntangledPendingCount++; + thenable.then(pingEngtangledActionScope, pingEngtangledActionScope); + return thenable; +} +function pingEngtangledActionScope() { + if ( + null !== currentEntangledListeners && + 0 === --currentEntangledPendingCount + ) { + null !== currentEntangledActionThenable && + (currentEntangledActionThenable.status = "fulfilled"); + var listeners = currentEntangledListeners; + currentEntangledListeners = null; + currentEntangledLane = 0; + currentEntangledActionThenable = null; + for (var i = 0; i < listeners.length; i++) (0, listeners[i])(); + } +} +function chainThenableValue(thenable, result) { + var listeners = [], + thenableWithOverride = { + status: "pending", + value: null, + reason: null, + then: function (resolve) { + listeners.push(resolve); + } + }; + thenable.then( + function () { + thenableWithOverride.status = "fulfilled"; + thenableWithOverride.value = result; + for (var i = 0; i < listeners.length; i++) (0, listeners[i])(result); + }, + function (error) { + thenableWithOverride.status = "rejected"; + thenableWithOverride.reason = error; + for (error = 0; error < listeners.length; error++) + (0, listeners[error])(void 0); + } + ); + return thenableWithOverride; +} var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { @@ -2617,12 +2730,20 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) { : (workInProgress.next = capturedUpdate); queue.lastBaseUpdate = capturedUpdate; } +var didReadFromEntangledAsyncAction = !1; +function suspendIfUpdateReadFromEntangledAsyncAction() { + if (didReadFromEntangledAsyncAction) { + var entangledActionThenable = currentEntangledActionThenable; + if (null !== entangledActionThenable) throw entangledActionThenable; + } +} function processUpdateQueue( workInProgress$jscomp$0, props, instance$jscomp$0, renderLanes ) { + didReadFromEntangledAsyncAction = !1; var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; var firstBaseUpdate = queue.firstBaseUpdate, @@ -2660,6 +2781,9 @@ function processUpdateQueue( ? (workInProgressRootRenderLanes & updateLane) === updateLane : (renderLanes & updateLane) === updateLane ) { + 0 !== updateLane && + updateLane === currentEntangledLane && + (didReadFromEntangledAsyncAction = !0); null !== current && (current = current.next = { @@ -2823,16 +2947,16 @@ function describeNativeComponentFrame(fn, construct) { } else { try { Fake.call(); - } catch (x$20) { - control = x$20; + } catch (x$21) { + control = x$21; } fn.call(Fake.prototype); } } else { try { throw Error(); - } catch (x$21) { - control = x$21; + } catch (x$22) { + control = x$22; } (Fake = fn()) && "function" === typeof Fake.catch && @@ -3960,6 +4084,13 @@ function renderWithHooksAgain(workInProgress, Component, props, secondArg) { } while (didScheduleRenderPhaseUpdateDuringThisPass); return children; } +function TransitionAwareHostComponent() { + if (!enableAsyncActions) throw Error("Not implemented."); + var maybeThenable = ReactCurrentDispatcher$1.current.useState()[0]; + return "function" === typeof maybeThenable.then + ? useThenable(maybeThenable) + : maybeThenable; +} function bailoutHooks(current, workInProgress, lanes) { workInProgress.updateQueue = current.updateQueue; workInProgress.flags &= -2053; @@ -4094,9 +4225,11 @@ function basicStateReducer(state, action) { return "function" === typeof action ? action(state) : action; } function updateReducer(reducer) { - var hook = updateWorkInProgressHook(), - current = currentHook, - queue = hook.queue; + var hook = updateWorkInProgressHook(); + return updateReducerImpl(hook, currentHook, reducer); +} +function updateReducerImpl(hook, current, reducer) { + var queue = hook.queue; if (null === queue) throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." @@ -4119,52 +4252,83 @@ function updateReducer(reducer) { current = baseQueue.next; var newBaseQueueFirst = (baseFirst = null), newBaseQueueLast = null, - update = current; + update = current, + didReadFromEntangledAsyncAction$36 = !1; do { var updateLane = update.lane & -536870913; if ( updateLane !== update.lane ? (workInProgressRootRenderLanes & updateLane) === updateLane : (renderLanes & updateLane) === updateLane - ) - null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = - { + ) { + var revertLane = update.revertLane; + if (enableAsyncActions && 0 !== revertLane) + if ((renderLanes & revertLane) === revertLane) { + update = update.next; + revertLane === currentEntangledLane && + (didReadFromEntangledAsyncAction$36 = !0); + continue; + } else + (updateLane = { lane: 0, - revertLane: 0, + revertLane: update.revertLane, action: update.action, hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }), - (updateLane = update.action), - shouldDoubleInvokeUserFnsInHooksDEV && - reducer(pendingQueue, updateLane), - (pendingQueue = update.hasEagerState - ? update.eagerState - : reducer(pendingQueue, updateLane)); - else { - var clone = { + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = updateLane), + (baseFirst = pendingQueue)) + : (newBaseQueueLast = newBaseQueueLast.next = updateLane), + (currentlyRenderingFiber$1.lanes |= revertLane), + (workInProgressRootSkippedLanes |= revertLane); + else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = + { + lane: 0, + revertLane: 0, + action: update.action, + hasEagerState: update.hasEagerState, + eagerState: update.eagerState, + next: null + }), + updateLane === currentEntangledLane && + (didReadFromEntangledAsyncAction$36 = !0); + updateLane = update.action; + shouldDoubleInvokeUserFnsInHooksDEV && + reducer(pendingQueue, updateLane); + pendingQueue = update.hasEagerState + ? update.eagerState + : reducer(pendingQueue, updateLane); + } else + (revertLane = { lane: updateLane, revertLane: update.revertLane, action: update.action, hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null - }; - null === newBaseQueueLast - ? ((newBaseQueueFirst = newBaseQueueLast = clone), - (baseFirst = pendingQueue)) - : (newBaseQueueLast = newBaseQueueLast.next = clone); - currentlyRenderingFiber$1.lanes |= updateLane; - workInProgressRootSkippedLanes |= updateLane; - } + }), + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = revertLane), + (baseFirst = pendingQueue)) + : (newBaseQueueLast = newBaseQueueLast.next = revertLane), + (currentlyRenderingFiber$1.lanes |= updateLane), + (workInProgressRootSkippedLanes |= updateLane); update = update.next; } while (null !== update && update !== current); null === newBaseQueueLast ? (baseFirst = pendingQueue) : (newBaseQueueLast.next = newBaseQueueFirst); - objectIs(pendingQueue, hook.memoizedState) || (didReceiveUpdate = !0); + if ( + !objectIs(pendingQueue, hook.memoizedState) && + ((didReceiveUpdate = !0), + didReadFromEntangledAsyncAction$36 && + ((reducer = currentEntangledActionThenable), null !== reducer)) + ) + throw reducer; hook.memoizedState = pendingQueue; hook.baseState = baseFirst; hook.baseQueue = newBaseQueueLast; @@ -4273,7 +4437,10 @@ function mountStateImpl(initialState) { if ("function" === typeof initialState) { var initialStateInitializer = initialState; initialState = initialStateInitializer(); - shouldDoubleInvokeUserFnsInHooksDEV && initialStateInitializer(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + initialStateInitializer(), + setIsStrictModeForDevtools(!1)); } hook.memoizedState = hook.baseState = initialState; hook.queue = { @@ -4285,6 +4452,180 @@ function mountStateImpl(initialState) { }; return hook; } +function mountOptimistic(passthrough) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = hook.baseState = passthrough; + var queue = { + pending: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: null, + lastRenderedState: null + }; + hook.queue = queue; + hook = dispatchOptimisticSetState.bind( + null, + currentlyRenderingFiber$1, + !0, + queue + ); + queue.dispatch = hook; + return [passthrough, hook]; +} +function updateOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); +} +function updateOptimisticImpl(hook, current, passthrough, reducer) { + hook.baseState = passthrough; + return updateReducerImpl( + hook, + currentHook, + "function" === typeof reducer ? reducer : basicStateReducer + ); +} +function rerenderOptimistic(passthrough, reducer) { + var hook = updateWorkInProgressHook(); + if (null !== currentHook) + return updateOptimisticImpl(hook, currentHook, passthrough, reducer); + hook.baseState = passthrough; + return [passthrough, hook.queue.dispatch]; +} +function dispatchFormState(fiber, actionQueue, setState, payload) { + if (isRenderPhaseUpdate(fiber)) + throw Error("Cannot update form state while rendering."); + fiber = actionQueue.pending; + null === fiber + ? ((fiber = { payload: payload, next: null }), + (fiber.next = actionQueue.pending = fiber), + runFormStateAction(actionQueue, setState, payload)) + : (actionQueue.pending = fiber.next = + { payload: payload, next: fiber.next }); +} +function runFormStateAction(actionQueue, setState, payload) { + var action = actionQueue.action, + prevState = actionQueue.state, + prevTransition = ReactCurrentBatchConfig$2.transition, + currentTransition = { _callbacks: new Set() }; + ReactCurrentBatchConfig$2.transition = currentTransition; + try { + var returnValue = action(prevState, payload); + null !== returnValue && + "object" === typeof returnValue && + "function" === typeof returnValue.then + ? (notifyTransitionCallbacks(currentTransition, returnValue), + returnValue.then( + function (nextState) { + actionQueue.state = nextState; + finishRunningFormStateAction(actionQueue, setState); + }, + function () { + return finishRunningFormStateAction(actionQueue, setState); + } + ), + setState(returnValue)) + : (setState(returnValue), + (actionQueue.state = returnValue), + finishRunningFormStateAction(actionQueue, setState)); + } catch (error) { + setState({ then: function () {}, status: "rejected", reason: error }), + finishRunningFormStateAction(actionQueue, setState); + } finally { + ReactCurrentBatchConfig$2.transition = prevTransition; + } +} +function finishRunningFormStateAction(actionQueue, setState) { + var last = actionQueue.pending; + if (null !== last) { + var first = last.next; + first === last + ? (actionQueue.pending = null) + : ((first = first.next), + (last.next = first), + runFormStateAction(actionQueue, setState, first.payload)); + } +} +function formStateReducer(oldState, newState) { + return newState; +} +function mountFormState(action, initialStateProp) { + var stateHook = mountWorkInProgressHook(); + stateHook.memoizedState = stateHook.baseState = initialStateProp; + var stateQueue = { + pending: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: formStateReducer, + lastRenderedState: initialStateProp + }; + stateHook.queue = stateQueue; + stateHook = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + stateQueue + ); + stateQueue.dispatch = stateHook; + stateQueue = mountWorkInProgressHook(); + var actionQueue = { + state: initialStateProp, + dispatch: null, + action: action, + pending: null + }; + stateQueue.queue = actionQueue; + stateHook = dispatchFormState.bind( + null, + currentlyRenderingFiber$1, + actionQueue, + stateHook + ); + actionQueue.dispatch = stateHook; + stateQueue.memoizedState = action; + return [initialStateProp, stateHook]; +} +function updateFormState(action) { + var stateHook = updateWorkInProgressHook(); + return updateFormStateImpl(stateHook, currentHook, action); +} +function updateFormStateImpl(stateHook, currentStateHook, action) { + stateHook = updateReducerImpl( + stateHook, + currentStateHook, + formStateReducer + )[0]; + stateHook = + "object" === typeof stateHook && + null !== stateHook && + "function" === typeof stateHook.then + ? useThenable(stateHook) + : stateHook; + currentStateHook = updateWorkInProgressHook(); + var actionQueue = currentStateHook.queue, + dispatch = actionQueue.dispatch; + action !== currentStateHook.memoizedState && + ((currentlyRenderingFiber$1.flags |= 2048), + pushEffect( + 9, + formStateActionEffect.bind(null, actionQueue, action), + { destroy: void 0 }, + null + )); + return [stateHook, dispatch]; +} +function formStateActionEffect(actionQueue, action) { + actionQueue.action = action; +} +function rerenderFormState(action) { + var stateHook = updateWorkInProgressHook(), + currentStateHook = currentHook; + if (null !== currentStateHook) + return updateFormStateImpl(stateHook, currentStateHook, action); + stateHook = stateHook.memoizedState; + currentStateHook = updateWorkInProgressHook(); + var dispatch = currentStateHook.queue.dispatch; + currentStateHook.memoizedState = action; + return [stateHook, dispatch]; +} function pushEffect(tag, create, inst, deps) { tag = { tag: tag, create: create, inst: inst, deps: deps, next: null }; create = currentlyRenderingFiber$1.updateQueue; @@ -4376,7 +4717,10 @@ function updateMemo(nextCreate, deps) { if (null !== deps && areHookInputsEqual(deps, prevState[1])) return prevState[0]; prevState = nextCreate(); - shouldDoubleInvokeUserFnsInHooksDEV && nextCreate(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + nextCreate(), + setIsStrictModeForDevtools(!1)); hook.memoizedState = [prevState, deps]; return prevState; } @@ -4410,18 +4754,46 @@ function startTransition(fiber, queue, pendingState, finishedState, callback) { 0 !== previousPriority && 8 > previousPriority ? previousPriority : 8; var prevTransition = ReactCurrentBatchConfig$2.transition, currentTransition = { _callbacks: new Set() }; - ReactCurrentBatchConfig$2.transition = null; - dispatchSetState(fiber, queue, pendingState); - ReactCurrentBatchConfig$2.transition = currentTransition; + enableAsyncActions + ? ((ReactCurrentBatchConfig$2.transition = currentTransition), + dispatchOptimisticSetState(fiber, !1, queue, pendingState)) + : ((ReactCurrentBatchConfig$2.transition = null), + dispatchSetState(fiber, queue, pendingState), + (ReactCurrentBatchConfig$2.transition = currentTransition)); try { - dispatchSetState(fiber, queue, finishedState), callback(); + if (enableAsyncActions) { + var returnValue = callback(); + if ( + null !== returnValue && + "object" === typeof returnValue && + "function" === typeof returnValue.then + ) { + notifyTransitionCallbacks(currentTransition, returnValue); + var thenableForFinishedState = chainThenableValue( + returnValue, + finishedState + ); + dispatchSetState(fiber, queue, thenableForFinishedState); + } else dispatchSetState(fiber, queue, finishedState); + } else dispatchSetState(fiber, queue, finishedState), callback(); } catch (error) { - throw error; + if (enableAsyncActions) + dispatchSetState(fiber, queue, { + then: function () {}, + status: "rejected", + reason: error + }); + else throw error; } finally { (currentUpdatePriority = previousPriority), (ReactCurrentBatchConfig$2.transition = prevTransition); } } +function useHostTransitionStatus() { + if (!enableAsyncActions) throw Error("Not implemented."); + var status = readContext(HostTransitionContext); + return null !== status ? status : null; +} function updateId() { return updateWorkInProgressHook().memoizedState; } @@ -4458,8 +4830,7 @@ function dispatchReducerAction(fiber, queue, action) { }; isRenderPhaseUpdate(fiber) ? enqueueRenderPhaseUpdate(queue, action) - : (enqueueUpdate$1(fiber, queue, action, lane), - (action = getRootForUpdatedFiber(fiber)), + : ((action = enqueueConcurrentHookUpdate(fiber, queue, action, lane)), null !== action && (scheduleUpdateOnFiber(action, fiber, lane), entangleTransitionUpdate(action, queue, lane))); @@ -4496,14 +4867,37 @@ function dispatchSetState(fiber, queue, action) { } catch (error) { } finally { } - enqueueUpdate$1(fiber, queue, update, lane); - action = getRootForUpdatedFiber(fiber); + action = enqueueConcurrentHookUpdate(fiber, queue, update, lane); null !== action && (scheduleUpdateOnFiber(action, fiber, lane), entangleTransitionUpdate(action, queue, lane)); } markStateUpdateScheduled(fiber, lane); } +function dispatchOptimisticSetState(fiber, throwIfDuringRender, queue, action) { + requestCurrentTransition(); + action = { + lane: 2, + revertLane: requestTransitionLane(), + action: action, + hasEagerState: !1, + eagerState: null, + next: null + }; + if (isRenderPhaseUpdate(fiber)) { + if (throwIfDuringRender) + throw Error("Cannot update optimistic state while rendering."); + } else + (throwIfDuringRender = enqueueConcurrentHookUpdate( + fiber, + queue, + action, + 2 + )), + null !== throwIfDuringRender && + scheduleUpdateOnFiber(throwIfDuringRender, fiber, 2); + markStateUpdateScheduled(fiber, 2); +} function isRenderPhaseUpdate(fiber) { var alternate = fiber.alternate; return ( @@ -4550,6 +4944,11 @@ var ContextOnlyDispatcher = { }; ContextOnlyDispatcher.useCacheRefresh = throwInvalidHookError; ContextOnlyDispatcher.useMemoCache = throwInvalidHookError; +enableAsyncActions && + ((ContextOnlyDispatcher.useHostTransitionStatus = throwInvalidHookError), + (ContextOnlyDispatcher.useFormState = throwInvalidHookError)); +enableAsyncActions && + (ContextOnlyDispatcher.useOptimistic = throwInvalidHookError); var HooksDispatcherOnMount = { readContext: readContext, use: use, @@ -4581,7 +4980,10 @@ var HooksDispatcherOnMount = { var hook = mountWorkInProgressHook(); deps = void 0 === deps ? null : deps; var nextValue = nextCreate(); - shouldDoubleInvokeUserFnsInHooksDEV && nextCreate(); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + nextCreate(), + setIsStrictModeForDevtools(!1)); hook.memoizedState = [nextValue, deps]; return nextValue; }, @@ -4589,7 +4991,10 @@ var HooksDispatcherOnMount = { var hook = mountWorkInProgressHook(); if (void 0 !== init) { var initialState = init(initialArg); - shouldDoubleInvokeUserFnsInHooksDEV && init(initialArg); + shouldDoubleInvokeUserFnsInHooksDEV && + (setIsStrictModeForDevtools(!0), + init(initialArg), + setIsStrictModeForDevtools(!1)); } else initialState = initialArg; hook.memoizedState = hook.baseState = initialState; reducer = { @@ -4682,6 +5087,10 @@ var HooksDispatcherOnMount = { } }; HooksDispatcherOnMount.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnMount.useHostTransitionStatus = useHostTransitionStatus), + (HooksDispatcherOnMount.useFormState = mountFormState)); +enableAsyncActions && (HooksDispatcherOnMount.useOptimistic = mountOptimistic); var HooksDispatcherOnUpdate = { readContext: readContext, use: use, @@ -4722,6 +5131,11 @@ var HooksDispatcherOnUpdate = { }; HooksDispatcherOnUpdate.useCacheRefresh = updateRefresh; HooksDispatcherOnUpdate.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnUpdate.useHostTransitionStatus = useHostTransitionStatus), + (HooksDispatcherOnUpdate.useFormState = updateFormState)); +enableAsyncActions && + (HooksDispatcherOnUpdate.useOptimistic = updateOptimistic); var HooksDispatcherOnRerender = { readContext: readContext, use: use, @@ -4764,6 +5178,12 @@ var HooksDispatcherOnRerender = { }; HooksDispatcherOnRerender.useCacheRefresh = updateRefresh; HooksDispatcherOnRerender.useMemoCache = useMemoCache; +enableAsyncActions && + ((HooksDispatcherOnRerender.useHostTransitionStatus = + useHostTransitionStatus), + (HooksDispatcherOnRerender.useFormState = rerenderFormState)); +enableAsyncActions && + (HooksDispatcherOnRerender.useOptimistic = rerenderOptimistic); var now = Scheduler.unstable_now, commitTime = 0, layoutEffectStartTime = -1, @@ -4986,6 +5406,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), processUpdateQueue(workInProgress, newProps, instance, renderLanes), + suspendIfUpdateReadFromEntangledAsyncAction(), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); @@ -5546,6 +5967,7 @@ function updateClassComponent( var oldState = workInProgress.memoizedState; instance.state = oldState; processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -5625,6 +6047,7 @@ function updateClassComponent( oldState = workInProgress.memoizedState; instance.state = oldState; processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); var newState = workInProgress.memoizedState; oldProps !== hasNewLifecycles || oldState !== newState || @@ -6327,7 +6750,9 @@ function attemptEarlyBailoutIfNoScheduledUpdate( case 10: pushProvider( workInProgress, - workInProgress.type._context, + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context, workInProgress.memoizedProps.value ); break; @@ -6564,7 +6989,19 @@ function releaseCache(cache) { }); } var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; -function handleAsyncAction() {} +function requestCurrentTransition() { + var transition = ReactCurrentBatchConfig$1.transition; + null !== transition && transition._callbacks.add(handleAsyncAction); + return transition; +} +function handleAsyncAction(transition, thenable) { + enableAsyncActions && entangleAsyncAction(transition, thenable); +} +function notifyTransitionCallbacks(transition, returnValue) { + transition._callbacks.forEach(function (callback) { + return callback(transition, returnValue); + }); +} var resumedCache = createCursor(null); function peekCacheFromPool() { var cacheResumedFromPreviousRender = resumedCache.current; @@ -6605,14 +7042,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$72 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$72 = lastTailNode), + for (var lastTailNode$76 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$76 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$72 + null === lastTailNode$76 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$72.sibling = null); + : (lastTailNode$76.sibling = null); } } function bubbleProperties(completedWork) { @@ -6624,53 +7061,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$74 = completedWork.selfBaseDuration, - child$75 = completedWork.child; - null !== child$75; + var treeBaseDuration$78 = completedWork.selfBaseDuration, + child$79 = completedWork.child; + null !== child$79; ) - (newChildLanes |= child$75.lanes | child$75.childLanes), - (subtreeFlags |= child$75.subtreeFlags & 31457280), - (subtreeFlags |= child$75.flags & 31457280), - (treeBaseDuration$74 += child$75.treeBaseDuration), - (child$75 = child$75.sibling); - completedWork.treeBaseDuration = treeBaseDuration$74; + (newChildLanes |= child$79.lanes | child$79.childLanes), + (subtreeFlags |= child$79.subtreeFlags & 31457280), + (subtreeFlags |= child$79.flags & 31457280), + (treeBaseDuration$78 += child$79.treeBaseDuration), + (child$79 = child$79.sibling); + completedWork.treeBaseDuration = treeBaseDuration$78; } else for ( - treeBaseDuration$74 = completedWork.child; - null !== treeBaseDuration$74; + treeBaseDuration$78 = completedWork.child; + null !== treeBaseDuration$78; ) (newChildLanes |= - treeBaseDuration$74.lanes | treeBaseDuration$74.childLanes), - (subtreeFlags |= treeBaseDuration$74.subtreeFlags & 31457280), - (subtreeFlags |= treeBaseDuration$74.flags & 31457280), - (treeBaseDuration$74.return = completedWork), - (treeBaseDuration$74 = treeBaseDuration$74.sibling); + treeBaseDuration$78.lanes | treeBaseDuration$78.childLanes), + (subtreeFlags |= treeBaseDuration$78.subtreeFlags & 31457280), + (subtreeFlags |= treeBaseDuration$78.flags & 31457280), + (treeBaseDuration$78.return = completedWork), + (treeBaseDuration$78 = treeBaseDuration$78.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$74 = completedWork.actualDuration; - child$75 = completedWork.selfBaseDuration; + treeBaseDuration$78 = completedWork.actualDuration; + child$79 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$74 += child.actualDuration), - (child$75 += child.treeBaseDuration), + (treeBaseDuration$78 += child.actualDuration), + (child$79 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$74; - completedWork.treeBaseDuration = child$75; + completedWork.actualDuration = treeBaseDuration$78; + completedWork.treeBaseDuration = child$79; } else for ( - treeBaseDuration$74 = completedWork.child; - null !== treeBaseDuration$74; + treeBaseDuration$78 = completedWork.child; + null !== treeBaseDuration$78; ) (newChildLanes |= - treeBaseDuration$74.lanes | treeBaseDuration$74.childLanes), - (subtreeFlags |= treeBaseDuration$74.subtreeFlags), - (subtreeFlags |= treeBaseDuration$74.flags), - (treeBaseDuration$74.return = completedWork), - (treeBaseDuration$74 = treeBaseDuration$74.sibling); + treeBaseDuration$78.lanes | treeBaseDuration$78.childLanes), + (subtreeFlags |= treeBaseDuration$78.subtreeFlags), + (subtreeFlags |= treeBaseDuration$78.flags), + (treeBaseDuration$78.return = completedWork), + (treeBaseDuration$78 = treeBaseDuration$78.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -6880,7 +7317,11 @@ function completeWork(current, workInProgress, renderLanes) { return popHostContainer(), bubbleProperties(workInProgress), null; case 10: return ( - popProvider(workInProgress.type._context), + popProvider( + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context + ), bubbleProperties(workInProgress), null ); @@ -7080,7 +7521,14 @@ function unwindWork(current, workInProgress) { case 4: return popHostContainer(), null; case 10: - return popProvider(workInProgress.type._context), null; + return ( + popProvider( + enableRenderableContext + ? workInProgress.type + : workInProgress.type._context + ), + null + ); case 22: case 23: return ( @@ -7130,7 +7578,11 @@ function unwindInterruptedWork(current, interruptedWork) { pop(suspenseStackCursor); break; case 10: - popProvider(interruptedWork.type._context); + popProvider( + enableRenderableContext + ? interruptedWork.type + : interruptedWork.type._context + ); break; case 22: case 23: @@ -7219,8 +7671,8 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (error$100) { - captureCommitPhaseError(current, nearestMountedAncestor, error$100); + } catch (error$104) { + captureCommitPhaseError(current, nearestMountedAncestor, error$104); } else ref.current = null; } @@ -7353,10 +7805,10 @@ function commitHookEffectListMount(flags, finishedWork) { injectedProfilingHooks.markComponentLayoutEffectMountStarted( finishedWork ); - var create$101 = effect.create, + var create$105 = effect.create, inst = effect.inst; - create$101 = create$101(); - inst.destroy = create$101; + create$105 = create$105(); + inst.destroy = create$105; 0 !== (flags & 8) ? null !== injectedProfilingHooks && "function" === @@ -7384,8 +7836,8 @@ function commitHookLayoutEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$103) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$103); + } catch (error$107) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$107); } } function commitClassCallbacks(finishedWork) { @@ -7465,11 +7917,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { } else try { finishedRoot.componentDidMount(); - } catch (error$104) { + } catch (error$108) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$104 + error$108 ); } else { @@ -7486,11 +7938,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$105) { + } catch (error$109) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$105 + error$109 ); } recordLayoutEffectDuration(finishedWork); @@ -7501,11 +7953,11 @@ function commitLayoutEffectOnFiber(finishedRoot, current, finishedWork) { current, finishedRoot.__reactInternalSnapshotBeforeUpdate ); - } catch (error$106) { + } catch (error$110) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$106 + error$110 ); } } @@ -7995,22 +8447,22 @@ function commitMutationEffectsOnFiber(finishedWork, root) { try { startLayoutEffectTimer(), commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$115) { + } catch (error$119) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$115 + error$119 ); } recordLayoutEffectDuration(finishedWork); } else try { commitHookEffectListUnmount(5, finishedWork, finishedWork.return); - } catch (error$116) { + } catch (error$120) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$116 + error$120 ); } } @@ -8058,8 +8510,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { viewConfig.uiViewClassName, updatePayload ); - } catch (error$119) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$119); + } catch (error$123) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$123); } } break; @@ -8079,8 +8531,8 @@ function commitMutationEffectsOnFiber(finishedWork, root) { "RCTRawText", { text: current } ); - } catch (error$120) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$120); + } catch (error$124) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$124); } } break; @@ -8192,11 +8644,11 @@ function commitMutationEffectsOnFiber(finishedWork, root) { if (null === current) try { throw Error("Not yet implemented."); - } catch (error$109) { + } catch (error$113) { captureCommitPhaseError( finishedWork, finishedWork.return, - error$109 + error$113 ); } } else if ( @@ -8270,12 +8722,12 @@ function commitReconciliationEffects(finishedWork) { break; case 3: case 4: - var parent$110 = JSCompiler_inline_result.stateNode.containerInfo, - before$111 = getHostSibling(finishedWork); + var parent$114 = JSCompiler_inline_result.stateNode.containerInfo, + before$115 = getHostSibling(finishedWork); insertOrAppendPlacementNodeIntoContainer( finishedWork, - before$111, - parent$110 + before$115, + parent$114 ); break; default: @@ -8461,8 +8913,8 @@ function commitHookPassiveMountEffects(finishedWork, hookFlags) { } else try { commitHookEffectListMount(hookFlags, finishedWork); - } catch (error$124) { - captureCommitPhaseError(finishedWork, finishedWork.return, error$124); + } catch (error$128) { + captureCommitPhaseError(finishedWork, finishedWork.return, error$128); } } function commitOffscreenPassiveMountEffects(current, finishedWork) { @@ -8968,13 +9420,10 @@ function requestUpdateLane(fiber) { if (0 === (fiber.mode & 1)) return 2; if (0 !== (executionContext & 2) && 0 !== workInProgressRootRenderLanes) return workInProgressRootRenderLanes & -workInProgressRootRenderLanes; - fiber = ReactCurrentBatchConfig$1.transition; - null !== fiber && fiber._callbacks.add(handleAsyncAction); - if (null !== fiber) + if (null !== requestCurrentTransition()) return ( - 0 === currentEventTransitionLane && - (currentEventTransitionLane = claimNextTransitionLane()), - currentEventTransitionLane + (fiber = currentEntangledLane), + 0 !== fiber ? fiber : requestTransitionLane() ); fiber = currentUpdatePriority; return 0 !== fiber ? fiber : 32; @@ -9248,9 +9697,9 @@ function markRootSuspended(root, suspendedLanes, spawnedLane) { 0 < lanes; ) { - var index$7 = 31 - clz32(lanes), - lane = 1 << index$7; - expirationTimes[index$7] = -1; + var index$8 = 31 - clz32(lanes), + lane = 1 << index$8; + expirationTimes[index$8] = -1; lanes &= ~lane; } 0 !== spawnedLane && @@ -9307,9 +9756,9 @@ function prepareFreshStack(root, lanes) { 0 < allEntangledLanes; ) { - var index$5 = 31 - clz32(allEntangledLanes), - lane = 1 << index$5; - lanes |= root[index$5]; + var index$6 = 31 - clz32(allEntangledLanes), + lane = 1 << index$6; + lanes |= root[index$6]; allEntangledLanes &= ~lane; } entangledRenderLanes = lanes; @@ -9442,8 +9891,8 @@ function renderRootSync(root, lanes) { } workLoopSync(); break; - } catch (thrownValue$129) { - handleThrow(root, thrownValue$129); + } catch (thrownValue$133) { + handleThrow(root, thrownValue$133); } while (1); lanes && root.shellSuspendCounter++; @@ -9562,8 +10011,8 @@ function renderRootConcurrent(root, lanes) { } workLoopConcurrent(); break; - } catch (thrownValue$131) { - handleThrow(root, thrownValue$131); + } catch (thrownValue$135) { + handleThrow(root, thrownValue$135); } while (1); resetContextDependencies(); @@ -9934,7 +10383,7 @@ function flushPassiveEffects() { _finishedWork$memoize = finishedWork.memoizedProps, id = _finishedWork$memoize.id, onPostCommit = _finishedWork$memoize.onPostCommit, - commitTime$102 = commitTime, + commitTime$106 = commitTime, phase = null === finishedWork.alternate ? "mount" : "update"; currentUpdateIsNested && (phase = "nested-update"); "function" === typeof onPostCommit && @@ -9942,7 +10391,7 @@ function flushPassiveEffects() { id, phase, passiveEffectDuration, - commitTime$102 + commitTime$106 ); var parentFiber = finishedWork.return; b: for (; null !== parentFiber; ) { @@ -10283,6 +10732,7 @@ beginWork = function (current, workInProgress, renderLanes) { pushProvider(workInProgress, CacheContext, nextCache); nextCache !== context.cache && propagateContextChange(workInProgress, CacheContext, renderLanes); + suspendIfUpdateReadFromEntangledAsyncAction(); context = nextProps.element; context === Component ? (workInProgress = bailoutOnAlreadyFinishedWork( @@ -10296,13 +10746,31 @@ beginWork = function (current, workInProgress, renderLanes) { case 26: case 27: case 5: - return ( - pushHostContext(workInProgress), - (Component = workInProgress.pendingProps.children), - markRef(current, workInProgress), - reconcileChildren(current, workInProgress, Component, renderLanes), - workInProgress.child - ); + pushHostContext(workInProgress); + Component = workInProgress.pendingProps.children; + if (enableAsyncActions && null !== workInProgress.memoizedState) { + if (!enableAsyncActions) throw Error("Not implemented."); + context = renderWithHooks( + current, + workInProgress, + TransitionAwareHostComponent, + null, + null, + renderLanes + ); + HostTransitionContext._currentValue = context; + didReceiveUpdate && + null !== current && + current.memoizedState.memoizedState !== context && + propagateContextChange( + workInProgress, + HostTransitionContext, + renderLanes + ); + } + markRef(current, workInProgress); + reconcileChildren(current, workInProgress, Component, renderLanes); + return workInProgress.child; case 6: return null; case 13: @@ -10376,7 +10844,9 @@ beginWork = function (current, workInProgress, renderLanes) { ); case 10: a: { - Component = workInProgress.type._context; + Component = enableRenderableContext + ? workInProgress.type + : workInProgress.type._context; context = workInProgress.pendingProps; nextProps = workInProgress.memoizedProps; nextCache = context.value; @@ -10406,7 +10876,9 @@ beginWork = function (current, workInProgress, renderLanes) { return workInProgress; case 9: return ( - (context = workInProgress.type), + (context = enableRenderableContext + ? workInProgress.type._context + : workInProgress.type), (Component = workInProgress.pendingProps.children), prepareToReadContext(workInProgress, renderLanes), (context = readContext(context)), @@ -10488,7 +10960,8 @@ beginWork = function (current, workInProgress, renderLanes) { pushProvider(workInProgress, CacheContext, context)) : (0 !== (current.lanes & renderLanes) && (cloneUpdateQueue(current, workInProgress), - processUpdateQueue(workInProgress, null, null, renderLanes)), + processUpdateQueue(workInProgress, null, null, renderLanes), + suspendIfUpdateReadFromEntangledAsyncAction()), (context = current.memoizedState), (nextProps = workInProgress.memoizedState), context.parent !== Component @@ -10710,12 +11183,18 @@ function createFiberFromTypeAndProps( if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 10; - break a; + if (!enableRenderableContext) { + fiberTag = 10; + break a; + } case REACT_CONTEXT_TYPE: - fiberTag = 9; + fiberTag = enableRenderableContext ? 10 : 9; break a; case REACT_CONSUMER_TYPE: + if (enableRenderableContext) { + fiberTag = 9; + break a; + } case REACT_FORWARD_REF_TYPE: fiberTag = 11; break a; @@ -11082,10 +11561,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1289 = { + devToolsConfig$jscomp$inline_1256 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-canary-6c66ecdb", + version: "18.3.0-canary-b5d8787a", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -11115,10 +11594,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1289.bundleType, - version: devToolsConfig$jscomp$inline_1289.version, - rendererPackageName: devToolsConfig$jscomp$inline_1289.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1289.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1256.bundleType, + version: devToolsConfig$jscomp$inline_1256.version, + rendererPackageName: devToolsConfig$jscomp$inline_1256.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1256.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -11134,14 +11613,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1289.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1256.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-6c66ecdb" + reconcilerVersion: "18.3.0-canary-b5d8787a" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) {