From 47d848abac0afdf2976287bae1e4ce0a29e5c302 Mon Sep 17 00:00:00 2001 From: gnoff Date: Thu, 20 Apr 2023 22:13:35 +0000 Subject: [PATCH] [Fiber] InvokeGuardedCallback without metaprogramming (#26569) InvokeGuardedCallback is now implemented with the browser fork done at error-time rather than module-load-time. Originally it also tried to freeze the window/document references to avoid mismatches in prototype chains when testing React in different documents however we have since updated our tests to not do this and it was a test only feature so I removed it. DiffTrain build for commit https://github.com/facebook/react/commit/cc93a8533264618b7a8e3d6fb56df917214c19d7. --- .../cjs/ReactTestRenderer-dev.js | 127 ++++++++---------- .../cjs/ReactTestRenderer-prod.js | 4 +- .../cjs/ReactTestRenderer-profiling.js | 4 +- .../RKJSModules/vendor/react/cjs/React-dev.js | 2 +- .../vendor/react/cjs/React-prod.js | 2 +- .../vendor/react/cjs/React-profiling.js | 2 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 127 ++++++++---------- .../implementations/ReactFabric-prod.fb.js | 4 +- .../ReactFabric-profiling.fb.js | 4 +- .../ReactNativeRenderer-dev.fb.js | 127 ++++++++---------- .../ReactNativeRenderer-prod.fb.js | 4 +- .../ReactNativeRenderer-profiling.fb.js | 4 +- 13 files changed, 175 insertions(+), 238 deletions(-) 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 0819b21bb05f0..60d317aff71d0 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 @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<43355784ad4a055ab0a02e5c5e648c88>> + * @generated SignedSource<> */ 'use strict'; @@ -16152,71 +16152,40 @@ function unwindInterruptedWork(current, interruptedWork, renderLanes) { } } -// $FlowFixMe[missing-this-annot] -function invokeGuardedCallbackProd(name, func, context) { - // $FlowFixMe[method-unbinding] - var funcArgs = Array.prototype.slice.call(arguments, 3); - - try { - // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. - func.apply(context, funcArgs); - } catch (error) { - this.onError(error); - } -} - -var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; +var fakeNode = null; { - // In DEV mode, we swap out invokeGuardedCallback for a special version - // that plays more nicely with the browser's DevTools. The idea is to preserve - // "Pause on exceptions" behavior. Because React wraps all user-provided - // functions in invokeGuardedCallback, and the production version of - // invokeGuardedCallback uses a try-catch, all user exceptions are treated - // like caught exceptions, and the DevTools won't pause unless the developer - // takes the extra step of enabling pause on caught exceptions. This is - // unintuitive, though, because even though React has caught the error, from - // the developer's perspective, the error is uncaught. - // - // To preserve the expected "Pause on exceptions" behavior, we don't use a - // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake - // DOM node, and call the user-provided callback from inside an event handler - // for that fake event. If the callback throws, the error is "captured" using - // a global event handler. But because the error happens in a different - // event loop context, it does not interrupt the normal program flow. - // Effectively, this gives us try-catch behavior without actually using - // try-catch. Neat! - // Check that the browser supports the APIs we need to implement our special - // DEV version of invokeGuardedCallback if ( typeof window !== "undefined" && typeof window.dispatchEvent === "function" && typeof document !== "undefined" && // $FlowFixMe[method-unbinding] typeof document.createEvent === "function" ) { - var fakeNode = document.createElement("react"); - - invokeGuardedCallbackImpl = function invokeGuardedCallbackDev( - name, - func, - context - ) { - // If document doesn't exist we know for sure we will crash in this method - // when we call document.createEvent(). However this can cause confusing - // errors: https://github.com/facebook/create-react-app/issues/3482 - // So we preemptively throw with a better message instead. - if (typeof document === "undefined" || document === null) { - throw new Error( - "The `document` global was defined when React was initialized, but is not " + - "defined anymore. This can happen in a test environment if a component " + - "schedules an update from an asynchronous callback, but the test has already " + - "finished running. To solve this, you can either unmount the component at " + - "the end of your test (and ensure that any asynchronous operations get " + - "canceled in `componentWillUnmount`), or you can change the test itself " + - "to be asynchronous." - ); - } + fakeNode = document.createElement("react"); + } +} +function invokeGuardedCallbackImpl(name, func, context) { + { + // In DEV mode, we use a special version + // that plays more nicely with the browser's DevTools. The idea is to preserve + // "Pause on exceptions" behavior. Because React wraps all user-provided + // functions in invokeGuardedCallback, and the production version of + // invokeGuardedCallback uses a try-catch, all user exceptions are treated + // like caught exceptions, and the DevTools won't pause unless the developer + // takes the extra step of enabling pause on caught exceptions. This is + // unintuitive, though, because even though React has caught the error, from + // the developer's perspective, the error is uncaught. + // + // To preserve the expected "Pause on exceptions" behavior, we don't use a + // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake + // DOM node, and call the user-provided callback from inside an event handler + // for that fake event. If the callback throws, the error is "captured" using + // event loop context, it does not interrupt the normal program flow. + // Effectively, this gives us try-catch behavior without actually using + // try-catch. Neat! + // fakeNode signifies we are in an environment with a document and window object + if (fakeNode) { var evt = document.createEvent("Event"); var didCall = false; // Keeps track of whether the user-provided callback threw an error. We // set this to true at the beginning, then set it to false right after @@ -16237,7 +16206,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; "event" ); - function restoreAfterDispatch() { + var restoreAfterDispatch = function () { // We immediately remove the callback from event listeners so that // nested `invokeGuardedCallback` calls do not clash. Otherwise, a // nested call would trigger the fake event handlers of any call higher @@ -16253,20 +16222,20 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ) { window.event = windowEvent; } - } // Create an event handler for our fake event. We will synchronously + }; // Create an event handler for our fake event. We will synchronously // dispatch our fake event using `dispatchEvent`. Inside the handler, we // call the user-provided callback. // $FlowFixMe[method-unbinding] - var funcArgs = Array.prototype.slice.call(arguments, 3); + var _funcArgs = Array.prototype.slice.call(arguments, 3); - function callCallback() { + var callCallback = function () { didCall = true; restoreAfterDispatch(); // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. - func.apply(context, funcArgs); + func.apply(context, _funcArgs); didError = false; - } // Create a global error event handler. We use this to capture the value + }; // Create a global error event handler. We use this to capture the value // that was thrown. It's possible that this error handler will fire more // than once; for example, if non-React code also calls `dispatchEvent` // and a handler for that event throws. We should be resilient to most of @@ -16281,9 +16250,9 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; var error; // Use this to track whether the error event is ever called. var didSetError = false; - var isCrossOriginError = false; // $FlowFixMe[missing-local-annot] + var isCrossOriginError = false; - function handleWindowError(event) { + var handleWindowError = function (event) { error = event.error; didSetError = true; @@ -16303,7 +16272,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; } } } - } // Create a fake event type. + }; // Create a fake event type. var evtType = "react-" + (name ? name : "invokeguardedcallback"); // Attach our event handlers @@ -16346,20 +16315,30 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; window.removeEventListener("error", handleWindowError); - if (!didCall) { + if (didCall) { + return; + } else { // Something went really wrong, and our event was not dispatched. // https://github.com/facebook/react/issues/16734 // https://github.com/facebook/react/issues/16585 // Fall back to the production implementation. - restoreAfterDispatch(); - return invokeGuardedCallbackProd.apply(this, arguments); + restoreAfterDispatch(); // we fall through and call the prod version instead } - }; + } // We only get here if we are in an environment that either does not support the browser + // variant or we had trouble getting the browser to emit the error. + // $FlowFixMe[method-unbinding] + + var funcArgs = Array.prototype.slice.call(arguments, 3); + + try { + // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. + func.apply(context, funcArgs); + } catch (error) { + this.onError(error); + } } } -var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; - var hasError = false; var caughtError = null; // Used by event system to capture/rethrow the first error. var reporter = { @@ -16385,7 +16364,7 @@ var reporter = { function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { hasError = false; caughtError = null; - invokeGuardedCallbackImpl$1.apply(reporter, arguments); + invokeGuardedCallbackImpl.apply(reporter, arguments); } function clearCaughtError() { if (hasError) { @@ -23859,7 +23838,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-fdad813ac-20230420"; +var ReactVersion = "18.3.0-next-cc93a8533-20230420"; // 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 bd8ae5cfe2118..a8fddaeced4b5 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 @@ -8599,7 +8599,7 @@ var devToolsConfig$jscomp$inline_1021 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-next-fdad813ac-20230420", + version: "18.3.0-next-cc93a8533-20230420", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1206 = { @@ -8630,7 +8630,7 @@ var internals$jscomp$inline_1206 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-fdad813ac-20230420" + reconcilerVersion: "18.3.0-next-cc93a8533-20230420" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1207 = __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 d44474d7ada5a..3daa53e4661d2 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 @@ -9025,7 +9025,7 @@ var devToolsConfig$jscomp$inline_1063 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-next-fdad813ac-20230420", + version: "18.3.0-next-cc93a8533-20230420", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1247 = { @@ -9056,7 +9056,7 @@ var internals$jscomp$inline_1247 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-fdad813ac-20230420" + reconcilerVersion: "18.3.0-next-cc93a8533-20230420" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1248 = __REACT_DEVTOOLS_GLOBAL_HOOK__; 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 7b4fbf124db29..3d81156efe817 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 @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-next-fdad813ac-20230420"; +var ReactVersion = "18.3.0-next-cc93a8533-20230420"; // ATTENTION // When adding new symbols to this file, 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 008a237e1644b..d3cbe88967aee 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 @@ -639,4 +639,4 @@ exports.useSyncExternalStore = function ( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-next-fdad813ac-20230420"; +exports.version = "18.3.0-next-cc93a8533-20230420"; 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 e61c9f18e4618..d7fc20d9609ee 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 @@ -642,7 +642,7 @@ exports.useSyncExternalStore = function ( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-next-fdad813ac-20230420"; +exports.version = "18.3.0-next-cc93a8533-20230420"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( 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 cd1156654f43d..affe75a80fd45 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 @@ -fdad813ac765e901e2957b8d36fba87e5504e5f4 +cc93a8533264618b7a8e3d6fb56df917214c19d7 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 b302cebc0ece4..f64830705c73e 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<<78a825a4d424f226b6f344ef3a16b2ec>> + * @generated SignedSource<<40e2743803d8d937ee642c7e74254e74>> */ 'use strict'; @@ -100,71 +100,40 @@ function printWarning(level, format, args) { } } -// $FlowFixMe[missing-this-annot] -function invokeGuardedCallbackProd(name, func, context) { - // $FlowFixMe[method-unbinding] - var funcArgs = Array.prototype.slice.call(arguments, 3); - - try { - // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. - func.apply(context, funcArgs); - } catch (error) { - this.onError(error); - } -} - -var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; +var fakeNode = null; { - // In DEV mode, we swap out invokeGuardedCallback for a special version - // that plays more nicely with the browser's DevTools. The idea is to preserve - // "Pause on exceptions" behavior. Because React wraps all user-provided - // functions in invokeGuardedCallback, and the production version of - // invokeGuardedCallback uses a try-catch, all user exceptions are treated - // like caught exceptions, and the DevTools won't pause unless the developer - // takes the extra step of enabling pause on caught exceptions. This is - // unintuitive, though, because even though React has caught the error, from - // the developer's perspective, the error is uncaught. - // - // To preserve the expected "Pause on exceptions" behavior, we don't use a - // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake - // DOM node, and call the user-provided callback from inside an event handler - // for that fake event. If the callback throws, the error is "captured" using - // a global event handler. But because the error happens in a different - // event loop context, it does not interrupt the normal program flow. - // Effectively, this gives us try-catch behavior without actually using - // try-catch. Neat! - // Check that the browser supports the APIs we need to implement our special - // DEV version of invokeGuardedCallback if ( typeof window !== "undefined" && typeof window.dispatchEvent === "function" && typeof document !== "undefined" && // $FlowFixMe[method-unbinding] typeof document.createEvent === "function" ) { - var fakeNode = document.createElement("react"); - - invokeGuardedCallbackImpl = function invokeGuardedCallbackDev( - name, - func, - context - ) { - // If document doesn't exist we know for sure we will crash in this method - // when we call document.createEvent(). However this can cause confusing - // errors: https://github.com/facebook/create-react-app/issues/3482 - // So we preemptively throw with a better message instead. - if (typeof document === "undefined" || document === null) { - throw new Error( - "The `document` global was defined when React was initialized, but is not " + - "defined anymore. This can happen in a test environment if a component " + - "schedules an update from an asynchronous callback, but the test has already " + - "finished running. To solve this, you can either unmount the component at " + - "the end of your test (and ensure that any asynchronous operations get " + - "canceled in `componentWillUnmount`), or you can change the test itself " + - "to be asynchronous." - ); - } + fakeNode = document.createElement("react"); + } +} +function invokeGuardedCallbackImpl(name, func, context) { + { + // In DEV mode, we use a special version + // that plays more nicely with the browser's DevTools. The idea is to preserve + // "Pause on exceptions" behavior. Because React wraps all user-provided + // functions in invokeGuardedCallback, and the production version of + // invokeGuardedCallback uses a try-catch, all user exceptions are treated + // like caught exceptions, and the DevTools won't pause unless the developer + // takes the extra step of enabling pause on caught exceptions. This is + // unintuitive, though, because even though React has caught the error, from + // the developer's perspective, the error is uncaught. + // + // To preserve the expected "Pause on exceptions" behavior, we don't use a + // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake + // DOM node, and call the user-provided callback from inside an event handler + // for that fake event. If the callback throws, the error is "captured" using + // event loop context, it does not interrupt the normal program flow. + // Effectively, this gives us try-catch behavior without actually using + // try-catch. Neat! + // fakeNode signifies we are in an environment with a document and window object + if (fakeNode) { var evt = document.createEvent("Event"); var didCall = false; // Keeps track of whether the user-provided callback threw an error. We // set this to true at the beginning, then set it to false right after @@ -185,7 +154,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; "event" ); - function restoreAfterDispatch() { + var restoreAfterDispatch = function () { // We immediately remove the callback from event listeners so that // nested `invokeGuardedCallback` calls do not clash. Otherwise, a // nested call would trigger the fake event handlers of any call higher @@ -201,20 +170,20 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ) { window.event = windowEvent; } - } // Create an event handler for our fake event. We will synchronously + }; // Create an event handler for our fake event. We will synchronously // dispatch our fake event using `dispatchEvent`. Inside the handler, we // call the user-provided callback. // $FlowFixMe[method-unbinding] - var funcArgs = Array.prototype.slice.call(arguments, 3); + var _funcArgs = Array.prototype.slice.call(arguments, 3); - function callCallback() { + var callCallback = function () { didCall = true; restoreAfterDispatch(); // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. - func.apply(context, funcArgs); + func.apply(context, _funcArgs); didError = false; - } // Create a global error event handler. We use this to capture the value + }; // Create a global error event handler. We use this to capture the value // that was thrown. It's possible that this error handler will fire more // than once; for example, if non-React code also calls `dispatchEvent` // and a handler for that event throws. We should be resilient to most of @@ -229,9 +198,9 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; var error; // Use this to track whether the error event is ever called. var didSetError = false; - var isCrossOriginError = false; // $FlowFixMe[missing-local-annot] + var isCrossOriginError = false; - function handleWindowError(event) { + var handleWindowError = function (event) { error = event.error; didSetError = true; @@ -251,7 +220,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; } } } - } // Create a fake event type. + }; // Create a fake event type. var evtType = "react-" + (name ? name : "invokeguardedcallback"); // Attach our event handlers @@ -294,20 +263,30 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; window.removeEventListener("error", handleWindowError); - if (!didCall) { + if (didCall) { + return; + } else { // Something went really wrong, and our event was not dispatched. // https://github.com/facebook/react/issues/16734 // https://github.com/facebook/react/issues/16585 // Fall back to the production implementation. - restoreAfterDispatch(); - return invokeGuardedCallbackProd.apply(this, arguments); + restoreAfterDispatch(); // we fall through and call the prod version instead } - }; + } // We only get here if we are in an environment that either does not support the browser + // variant or we had trouble getting the browser to emit the error. + // $FlowFixMe[method-unbinding] + + var funcArgs = Array.prototype.slice.call(arguments, 3); + + try { + // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. + func.apply(context, funcArgs); + } catch (error) { + this.onError(error); + } } } -var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; - var hasError = false; var caughtError = null; // Used by event system to capture/rethrow the first error. @@ -336,7 +315,7 @@ var reporter = { function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { hasError = false; caughtError = null; - invokeGuardedCallbackImpl$1.apply(reporter, arguments); + invokeGuardedCallbackImpl.apply(reporter, arguments); } /** * Same as invokeGuardedCallback, but instead of returning an error, it stores @@ -27169,7 +27148,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-fdad813ac-20230420"; +var ReactVersion = "18.3.0-next-cc93a8533-20230420"; 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 a8b67b81987c8..d29e40c57e93e 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 @@ -9470,7 +9470,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1045 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-next-fdad813ac-20230420", + version: "18.3.0-next-cc93a8533-20230420", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -9512,7 +9512,7 @@ var internals$jscomp$inline_1276 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-fdad813ac-20230420" + reconcilerVersion: "18.3.0-next-cc93a8533-20230420" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1277 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index d165ed2354236..bfd795e9086a0 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 @@ -10179,7 +10179,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1123 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-next-fdad813ac-20230420", + version: "18.3.0-next-cc93a8533-20230420", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -10234,7 +10234,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-fdad813ac-20230420" + reconcilerVersion: "18.3.0-next-cc93a8533-20230420" }); 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 d1e4eaff354d0..9e87de176d8d3 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<> + * @generated SignedSource<<36dfe2e6840704492b6fbf0d00f5b91a>> */ 'use strict'; @@ -100,71 +100,40 @@ function printWarning(level, format, args) { } } -// $FlowFixMe[missing-this-annot] -function invokeGuardedCallbackProd(name, func, context) { - // $FlowFixMe[method-unbinding] - var funcArgs = Array.prototype.slice.call(arguments, 3); - - try { - // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. - func.apply(context, funcArgs); - } catch (error) { - this.onError(error); - } -} - -var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; +var fakeNode = null; { - // In DEV mode, we swap out invokeGuardedCallback for a special version - // that plays more nicely with the browser's DevTools. The idea is to preserve - // "Pause on exceptions" behavior. Because React wraps all user-provided - // functions in invokeGuardedCallback, and the production version of - // invokeGuardedCallback uses a try-catch, all user exceptions are treated - // like caught exceptions, and the DevTools won't pause unless the developer - // takes the extra step of enabling pause on caught exceptions. This is - // unintuitive, though, because even though React has caught the error, from - // the developer's perspective, the error is uncaught. - // - // To preserve the expected "Pause on exceptions" behavior, we don't use a - // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake - // DOM node, and call the user-provided callback from inside an event handler - // for that fake event. If the callback throws, the error is "captured" using - // a global event handler. But because the error happens in a different - // event loop context, it does not interrupt the normal program flow. - // Effectively, this gives us try-catch behavior without actually using - // try-catch. Neat! - // Check that the browser supports the APIs we need to implement our special - // DEV version of invokeGuardedCallback if ( typeof window !== "undefined" && typeof window.dispatchEvent === "function" && typeof document !== "undefined" && // $FlowFixMe[method-unbinding] typeof document.createEvent === "function" ) { - var fakeNode = document.createElement("react"); - - invokeGuardedCallbackImpl = function invokeGuardedCallbackDev( - name, - func, - context - ) { - // If document doesn't exist we know for sure we will crash in this method - // when we call document.createEvent(). However this can cause confusing - // errors: https://github.com/facebook/create-react-app/issues/3482 - // So we preemptively throw with a better message instead. - if (typeof document === "undefined" || document === null) { - throw new Error( - "The `document` global was defined when React was initialized, but is not " + - "defined anymore. This can happen in a test environment if a component " + - "schedules an update from an asynchronous callback, but the test has already " + - "finished running. To solve this, you can either unmount the component at " + - "the end of your test (and ensure that any asynchronous operations get " + - "canceled in `componentWillUnmount`), or you can change the test itself " + - "to be asynchronous." - ); - } + fakeNode = document.createElement("react"); + } +} +function invokeGuardedCallbackImpl(name, func, context) { + { + // In DEV mode, we use a special version + // that plays more nicely with the browser's DevTools. The idea is to preserve + // "Pause on exceptions" behavior. Because React wraps all user-provided + // functions in invokeGuardedCallback, and the production version of + // invokeGuardedCallback uses a try-catch, all user exceptions are treated + // like caught exceptions, and the DevTools won't pause unless the developer + // takes the extra step of enabling pause on caught exceptions. This is + // unintuitive, though, because even though React has caught the error, from + // the developer's perspective, the error is uncaught. + // + // To preserve the expected "Pause on exceptions" behavior, we don't use a + // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake + // DOM node, and call the user-provided callback from inside an event handler + // for that fake event. If the callback throws, the error is "captured" using + // event loop context, it does not interrupt the normal program flow. + // Effectively, this gives us try-catch behavior without actually using + // try-catch. Neat! + // fakeNode signifies we are in an environment with a document and window object + if (fakeNode) { var evt = document.createEvent("Event"); var didCall = false; // Keeps track of whether the user-provided callback threw an error. We // set this to true at the beginning, then set it to false right after @@ -185,7 +154,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; "event" ); - function restoreAfterDispatch() { + var restoreAfterDispatch = function () { // We immediately remove the callback from event listeners so that // nested `invokeGuardedCallback` calls do not clash. Otherwise, a // nested call would trigger the fake event handlers of any call higher @@ -201,20 +170,20 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ) { window.event = windowEvent; } - } // Create an event handler for our fake event. We will synchronously + }; // Create an event handler for our fake event. We will synchronously // dispatch our fake event using `dispatchEvent`. Inside the handler, we // call the user-provided callback. // $FlowFixMe[method-unbinding] - var funcArgs = Array.prototype.slice.call(arguments, 3); + var _funcArgs = Array.prototype.slice.call(arguments, 3); - function callCallback() { + var callCallback = function () { didCall = true; restoreAfterDispatch(); // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. - func.apply(context, funcArgs); + func.apply(context, _funcArgs); didError = false; - } // Create a global error event handler. We use this to capture the value + }; // Create a global error event handler. We use this to capture the value // that was thrown. It's possible that this error handler will fire more // than once; for example, if non-React code also calls `dispatchEvent` // and a handler for that event throws. We should be resilient to most of @@ -229,9 +198,9 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; var error; // Use this to track whether the error event is ever called. var didSetError = false; - var isCrossOriginError = false; // $FlowFixMe[missing-local-annot] + var isCrossOriginError = false; - function handleWindowError(event) { + var handleWindowError = function (event) { error = event.error; didSetError = true; @@ -251,7 +220,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; } } } - } // Create a fake event type. + }; // Create a fake event type. var evtType = "react-" + (name ? name : "invokeguardedcallback"); // Attach our event handlers @@ -294,20 +263,30 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; window.removeEventListener("error", handleWindowError); - if (!didCall) { + if (didCall) { + return; + } else { // Something went really wrong, and our event was not dispatched. // https://github.com/facebook/react/issues/16734 // https://github.com/facebook/react/issues/16585 // Fall back to the production implementation. - restoreAfterDispatch(); - return invokeGuardedCallbackProd.apply(this, arguments); + restoreAfterDispatch(); // we fall through and call the prod version instead } - }; + } // We only get here if we are in an environment that either does not support the browser + // variant or we had trouble getting the browser to emit the error. + // $FlowFixMe[method-unbinding] + + var funcArgs = Array.prototype.slice.call(arguments, 3); + + try { + // $FlowFixMe[incompatible-call] Flow doesn't understand the arguments splicing. + func.apply(context, funcArgs); + } catch (error) { + this.onError(error); + } } } -var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; - var hasError = false; var caughtError = null; // Used by event system to capture/rethrow the first error. @@ -336,7 +315,7 @@ var reporter = { function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { hasError = false; caughtError = null; - invokeGuardedCallbackImpl$1.apply(reporter, arguments); + invokeGuardedCallbackImpl.apply(reporter, arguments); } /** * Same as invokeGuardedCallback, but instead of returning an error, it stores @@ -27682,7 +27661,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-fdad813ac-20230420"; +var ReactVersion = "18.3.0-next-cc93a8533-20230420"; 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 68a5ef39fa197..7bbb14d3bfc76 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 @@ -9729,7 +9729,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1100 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-next-fdad813ac-20230420", + version: "18.3.0-next-cc93a8533-20230420", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -9771,7 +9771,7 @@ var internals$jscomp$inline_1345 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-fdad813ac-20230420" + reconcilerVersion: "18.3.0-next-cc93a8533-20230420" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1346 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 8b0ee352570fc..dc4a035cbca27 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 @@ -10438,7 +10438,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1178 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-next-fdad813ac-20230420", + version: "18.3.0-next-cc93a8533-20230420", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -10493,7 +10493,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-fdad813ac-20230420" + reconcilerVersion: "18.3.0-next-cc93a8533-20230420" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) {