diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index ab4a639da9c77..176d83a494b94 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -9f8daa6cb5aae476cf54611874ea7522243c6ba6 +a0537160771bafae90c6fd3154eeead2f2c903e7 diff --git a/compiled/facebook-www/ReactART-dev.classic.js b/compiled/facebook-www/ReactART-dev.classic.js index b2ff96c7b0641..cabe4f7e42b58 100644 --- a/compiled/facebook-www/ReactART-dev.classic.js +++ b/compiled/facebook-www/ReactART-dev.classic.js @@ -66,7 +66,7 @@ if (__DEV__) { return self; } - var ReactVersion = "19.0.0-www-classic-ca0b9726"; + var ReactVersion = "19.0.0-www-classic-6cf2b9d5"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -14557,145 +14557,98 @@ if (__DEV__) { }; } - var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); - - if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { - throw new Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); - } - - function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; - return ReactFiberErrorDialogWWW.showErrorDialog(capturedError); - } - - var reportGlobalError = - typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, - ? // emulating an uncaught JavaScript error. - reportError - : function (error) { - if ( - typeof window === "object" && - typeof window.ErrorEvent === "function" - ) { - // Browser Polyfill - var message = - typeof error === "object" && - error !== null && - typeof error.message === "string" // eslint-disable-next-line react-internal/safe-string-coercion - ? String(error.message) // eslint-disable-next-line react-internal/safe-string-coercion - : String(error); - var event = new window.ErrorEvent("error", { - bubbles: true, - cancelable: true, - message: message, - error: error - }); - var shouldLog = window.dispatchEvent(event); + typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, + ? // emulating an uncaught JavaScript error. + reportError + : function (error) { + if ( + typeof window === "object" && + typeof window.ErrorEvent === "function" + ) { + // Browser Polyfill + var message = + typeof error === "object" && + error !== null && + typeof error.message === "string" // eslint-disable-next-line react-internal/safe-string-coercion + ? String(error.message) // eslint-disable-next-line react-internal/safe-string-coercion + : String(error); + var event = new window.ErrorEvent("error", { + bubbles: true, + cancelable: true, + message: message, + error: error + }); + var shouldLog = window.dispatchEvent(event); - if (!shouldLog) { - return; - } - } else if ( - typeof process === "object" && // $FlowFixMe[method-unbinding] - typeof process.emit === "function" - ) { - // Node Polyfill - process.emit("uncaughtException", error); + if (!shouldLog) { return; - } // eslint-disable-next-line react-internal/no-production-logging + } + } else if ( + typeof process === "object" && // $FlowFixMe[method-unbinding] + typeof process.emit === "function" + ) { + // Node Polyfill + process.emit("uncaughtException", error); + return; + } // eslint-disable-next-line react-internal/no-production-logging - console["error"](error); - }; + console["error"](error); + }; - var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; - function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API - if (logError === false) { - return; + var componentName = null; + var errorBoundaryName = null; + function logUncaughtError(root, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = null; } var error = errorInfo.value; - if (boundary.tag === HostRoot) { - if (true && ReactCurrentActQueue$2.current !== null) { - // For uncaught errors inside act, we track them on the act and then - // rethrow them into the test. - ReactCurrentActQueue$2.thrownErrors.push(error); - return; - } // For uncaught root errors we report them as uncaught to the browser's - // onerror callback. This won't have component stacks and the error addendum. - // So we add those into a separate console.warn. - - reportGlobalError(error); + if (true && ReactCurrentActQueue$2.current !== null) { + // For uncaught errors inside act, we track them on the act and then + // rethrow them into the test. + ReactCurrentActQueue$2.thrownErrors.push(error); + return; + } - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var componentName = source - ? getComponentNameFromFiber(source) - : null; - var componentNameMessage = componentName - ? "An error occurred in the <" + componentName + "> component:" - : "An error occurred in one of your React components:"; - console["warn"]( - "%s\n%s\n\n%s", - componentNameMessage, - componentStack, - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." - ); - } - } else { - // Caught by error boundary - if (true) { - var _source = errorInfo.source; - var _stack = errorInfo.stack; - - var _componentStack = _stack !== null ? _stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var _componentName = _source - ? getComponentNameFromFiber(_source) - : null; - - var _componentNameMessage = _componentName - ? "The above error occurred in the <" + - _componentName + - "> component:" - : "The above error occurred in one of your React components:"; - - var errorBoundaryName = - getComponentNameFromFiber(boundary) || "Anonymous"; // In development, we provide our own message which includes the component stack - // in addition to the error. - // Don't transform to our wrapper - - console["error"]( - "%o\n\n%s\n%s\n\n%s", - error, - _componentNameMessage, - _componentStack, - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + - errorBoundaryName + - ".") - ); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(error, { + componentStack: errorInfo.stack + }); + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function () { + throw e; + }); + } + } + function logCaughtError(root, boundary, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = getComponentNameFromFiber(boundary); } + + var error = errorInfo.value; + var onCaughtError = root.onCaughtError; + onCaughtError(error, { + componentStack: errorInfo.stack, + errorBoundary: + boundary.tag === ClassComponent + ? boundary.stateNode // This should always be the case as long as we only have class boundaries + : null + }); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -14707,7 +14660,7 @@ if (__DEV__) { } } - function createRootErrorUpdate(fiber, errorInfo, lane) { + function createRootErrorUpdate(root, errorInfo, lane) { var update = createUpdate(lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property @@ -14718,15 +14671,19 @@ if (__DEV__) { }; update.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return update; } - function createClassErrorUpdate(fiber, errorInfo, lane) { + function createClassErrorUpdate(lane) { var update = createUpdate(lane); update.tag = CaptureUpdate; + return update; + } + + function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { @@ -14741,7 +14698,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); }; } @@ -14754,7 +14711,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, @@ -14787,8 +14744,6 @@ if (__DEV__) { } }; } - - return update; } function resetSuspendedComponent(sourceFiber, rootRenderLanes) { @@ -15158,7 +15113,7 @@ if (__DEV__) { var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); var update = createRootErrorUpdate( - workInProgress, + workInProgress.stateNode, _errorInfo, lane ); @@ -15185,12 +15140,14 @@ if (__DEV__) { workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update = createClassErrorUpdate( + var _update = createClassErrorUpdate(_lane); + + initializeClassErrorUpdate( + _update, + root, workInProgress, - errorInfo, - _lane + errorInfo ); - enqueueCapturedUpdate(workInProgress, _update); return false; } @@ -16278,10 +16235,20 @@ if (__DEV__) { var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state - var update = createClassErrorUpdate( + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var update = createClassErrorUpdate(lane); + initializeClassErrorUpdate( + update, + root, workInProgress, - createCapturedValueAtFiber(error$1, workInProgress), - lane + createCapturedValueAtFiber(error$1, workInProgress) ); enqueueCapturedUpdate(workInProgress, update); break; @@ -27058,8 +27025,8 @@ if (__DEV__) { if (erroredWork === null) { // This is a fatal error workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); return; @@ -27884,10 +27851,7 @@ if (__DEV__) { // caught by an error boundary. This is a fatal error, or panic condition, // because we've run out of ways to recover. workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, - createCapturedValueAtFiber(error, root.current) - ); // Set `workInProgress` to null. This represents advancing to the next + logUncaughtError(root, createCapturedValueAtFiber(error, root.current)); // Set `workInProgress` to null. This represents advancing to the next // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're @@ -28612,7 +28576,11 @@ if (__DEV__) { function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValueAtFiber(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate( + rootFiber.stateNode, + errorInfo, + SyncLane + ); var root = enqueueUpdate(rootFiber, update, SyncLane); if (root !== null) { @@ -28653,10 +28621,11 @@ if (__DEV__) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValueAtFiber(error$1, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate(SyncLane); var root = enqueueUpdate(fiber, update, SyncLane); if (root !== null) { + initializeClassErrorUpdate(update, root, fiber, errorInfo); markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } @@ -30459,6 +30428,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -30487,6 +30458,8 @@ if (__DEV__) { this.entanglements = createLaneMap(NoLanes); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; { @@ -30549,6 +30522,8 @@ if (__DEV__) { // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -30559,6 +30534,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -30638,6 +30615,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ) { @@ -30652,6 +30631,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null diff --git a/compiled/facebook-www/ReactART-dev.modern.js b/compiled/facebook-www/ReactART-dev.modern.js index 5ed6fe4639f6d..7a603cd6a31b8 100644 --- a/compiled/facebook-www/ReactART-dev.modern.js +++ b/compiled/facebook-www/ReactART-dev.modern.js @@ -66,7 +66,7 @@ if (__DEV__) { return self; } - var ReactVersion = "19.0.0-www-modern-29ab981d"; + var ReactVersion = "19.0.0-www-modern-6f507aaf"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -14281,145 +14281,98 @@ if (__DEV__) { }; } - var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); - - if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { - throw new Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); - } - - function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; - return ReactFiberErrorDialogWWW.showErrorDialog(capturedError); - } - - var reportGlobalError = - typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, - ? // emulating an uncaught JavaScript error. - reportError - : function (error) { - if ( - typeof window === "object" && - typeof window.ErrorEvent === "function" - ) { - // Browser Polyfill - var message = - typeof error === "object" && - error !== null && - typeof error.message === "string" // eslint-disable-next-line react-internal/safe-string-coercion - ? String(error.message) // eslint-disable-next-line react-internal/safe-string-coercion - : String(error); - var event = new window.ErrorEvent("error", { - bubbles: true, - cancelable: true, - message: message, - error: error - }); - var shouldLog = window.dispatchEvent(event); + typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, + ? // emulating an uncaught JavaScript error. + reportError + : function (error) { + if ( + typeof window === "object" && + typeof window.ErrorEvent === "function" + ) { + // Browser Polyfill + var message = + typeof error === "object" && + error !== null && + typeof error.message === "string" // eslint-disable-next-line react-internal/safe-string-coercion + ? String(error.message) // eslint-disable-next-line react-internal/safe-string-coercion + : String(error); + var event = new window.ErrorEvent("error", { + bubbles: true, + cancelable: true, + message: message, + error: error + }); + var shouldLog = window.dispatchEvent(event); - if (!shouldLog) { - return; - } - } else if ( - typeof process === "object" && // $FlowFixMe[method-unbinding] - typeof process.emit === "function" - ) { - // Node Polyfill - process.emit("uncaughtException", error); + if (!shouldLog) { return; - } // eslint-disable-next-line react-internal/no-production-logging + } + } else if ( + typeof process === "object" && // $FlowFixMe[method-unbinding] + typeof process.emit === "function" + ) { + // Node Polyfill + process.emit("uncaughtException", error); + return; + } // eslint-disable-next-line react-internal/no-production-logging - console["error"](error); - }; + console["error"](error); + }; - var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; - function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API - if (logError === false) { - return; + var componentName = null; + var errorBoundaryName = null; + function logUncaughtError(root, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = null; } var error = errorInfo.value; - if (boundary.tag === HostRoot) { - if (true && ReactCurrentActQueue$2.current !== null) { - // For uncaught errors inside act, we track them on the act and then - // rethrow them into the test. - ReactCurrentActQueue$2.thrownErrors.push(error); - return; - } // For uncaught root errors we report them as uncaught to the browser's - // onerror callback. This won't have component stacks and the error addendum. - // So we add those into a separate console.warn. - - reportGlobalError(error); + if (true && ReactCurrentActQueue$2.current !== null) { + // For uncaught errors inside act, we track them on the act and then + // rethrow them into the test. + ReactCurrentActQueue$2.thrownErrors.push(error); + return; + } - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var componentName = source - ? getComponentNameFromFiber(source) - : null; - var componentNameMessage = componentName - ? "An error occurred in the <" + componentName + "> component:" - : "An error occurred in one of your React components:"; - console["warn"]( - "%s\n%s\n\n%s", - componentNameMessage, - componentStack, - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." - ); - } - } else { - // Caught by error boundary - if (true) { - var _source = errorInfo.source; - var _stack = errorInfo.stack; - - var _componentStack = _stack !== null ? _stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var _componentName = _source - ? getComponentNameFromFiber(_source) - : null; - - var _componentNameMessage = _componentName - ? "The above error occurred in the <" + - _componentName + - "> component:" - : "The above error occurred in one of your React components:"; - - var errorBoundaryName = - getComponentNameFromFiber(boundary) || "Anonymous"; // In development, we provide our own message which includes the component stack - // in addition to the error. - // Don't transform to our wrapper - - console["error"]( - "%o\n\n%s\n%s\n\n%s", - error, - _componentNameMessage, - _componentStack, - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + - errorBoundaryName + - ".") - ); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(error, { + componentStack: errorInfo.stack + }); + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function () { + throw e; + }); + } + } + function logCaughtError(root, boundary, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = getComponentNameFromFiber(boundary); } + + var error = errorInfo.value; + var onCaughtError = root.onCaughtError; + onCaughtError(error, { + componentStack: errorInfo.stack, + errorBoundary: + boundary.tag === ClassComponent + ? boundary.stateNode // This should always be the case as long as we only have class boundaries + : null + }); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -14431,7 +14384,7 @@ if (__DEV__) { } } - function createRootErrorUpdate(fiber, errorInfo, lane) { + function createRootErrorUpdate(root, errorInfo, lane) { var update = createUpdate(lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property @@ -14442,15 +14395,19 @@ if (__DEV__) { }; update.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return update; } - function createClassErrorUpdate(fiber, errorInfo, lane) { + function createClassErrorUpdate(lane) { var update = createUpdate(lane); update.tag = CaptureUpdate; + return update; + } + + function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { @@ -14465,7 +14422,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); }; } @@ -14478,7 +14435,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, @@ -14511,8 +14468,6 @@ if (__DEV__) { } }; } - - return update; } function resetSuspendedComponent(sourceFiber, rootRenderLanes) { @@ -14882,7 +14837,7 @@ if (__DEV__) { var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); var update = createRootErrorUpdate( - workInProgress, + workInProgress.stateNode, _errorInfo, lane ); @@ -14909,12 +14864,14 @@ if (__DEV__) { workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update = createClassErrorUpdate( + var _update = createClassErrorUpdate(_lane); + + initializeClassErrorUpdate( + _update, + root, workInProgress, - errorInfo, - _lane + errorInfo ); - enqueueCapturedUpdate(workInProgress, _update); return false; } @@ -15993,10 +15950,20 @@ if (__DEV__) { var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state - var update = createClassErrorUpdate( + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var update = createClassErrorUpdate(lane); + initializeClassErrorUpdate( + update, + root, workInProgress, - createCapturedValueAtFiber(error$1, workInProgress), - lane + createCapturedValueAtFiber(error$1, workInProgress) ); enqueueCapturedUpdate(workInProgress, update); break; @@ -26717,8 +26684,8 @@ if (__DEV__) { if (erroredWork === null) { // This is a fatal error workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); return; @@ -27534,10 +27501,7 @@ if (__DEV__) { // caught by an error boundary. This is a fatal error, or panic condition, // because we've run out of ways to recover. workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, - createCapturedValueAtFiber(error, root.current) - ); // Set `workInProgress` to null. This represents advancing to the next + logUncaughtError(root, createCapturedValueAtFiber(error, root.current)); // Set `workInProgress` to null. This represents advancing to the next // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're @@ -28262,7 +28226,11 @@ if (__DEV__) { function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValueAtFiber(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate( + rootFiber.stateNode, + errorInfo, + SyncLane + ); var root = enqueueUpdate(rootFiber, update, SyncLane); if (root !== null) { @@ -28303,10 +28271,11 @@ if (__DEV__) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValueAtFiber(error$1, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate(SyncLane); var root = enqueueUpdate(fiber, update, SyncLane); if (root !== null) { + initializeClassErrorUpdate(update, root, fiber, errorInfo); markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } @@ -30109,6 +30078,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -30137,6 +30108,8 @@ if (__DEV__) { this.entanglements = createLaneMap(NoLanes); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; { @@ -30199,6 +30172,8 @@ if (__DEV__) { // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -30209,6 +30184,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -30288,6 +30265,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ) { @@ -30302,6 +30281,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null diff --git a/compiled/facebook-www/ReactART-prod.classic.js b/compiled/facebook-www/ReactART-prod.classic.js index 46c3d1c23e10a..f5bf8090c461a 100644 --- a/compiled/facebook-www/ReactART-prod.classic.js +++ b/compiled/facebook-www/ReactART-prod.classic.js @@ -3982,85 +3982,87 @@ function createCapturedValueFromError(value, digest, stack) { digest: null != digest ? digest : null }; } -var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); -if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) - throw Error(formatProdErrorMessage(320)); -var reportGlobalError = - "function" === typeof reportError - ? reportError - : function (error) { - if ( - "object" === typeof window && - "function" === typeof window.ErrorEvent - ) { - var event = new window.ErrorEvent("error", { - bubbles: !0, - cancelable: !0, - message: - "object" === typeof error && - null !== error && - "string" === typeof error.message - ? String(error.message) - : String(error), - error: error - }); - if (!window.dispatchEvent(event)) return; - } else if ( - "object" === typeof process && - "function" === typeof process.emit - ) { - process.emit("uncaughtException", error); - return; - } - console.error(error); - }; -function logCapturedError(boundary, errorInfo) { +"function" === typeof reportError + ? reportError + : function (error) { + if ( + "object" === typeof window && + "function" === typeof window.ErrorEvent + ) { + var event = new window.ErrorEvent("error", { + bubbles: !0, + cancelable: !0, + message: + "object" === typeof error && + null !== error && + "string" === typeof error.message + ? String(error.message) + : String(error), + error: error + }); + if (!window.dispatchEvent(event)) return; + } else if ( + "object" === typeof process && + "function" === typeof process.emit + ) { + process.emit("uncaughtException", error); + return; + } + console.error(error); + }; +function logUncaughtError(root, errorInfo) { try { - if ( - !1 !== - ReactFiberErrorDialogWWW.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) - ) { - var error = errorInfo.value; - 3 === boundary.tag ? reportGlobalError(error) : console.error(error); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(errorInfo.value, { componentStack: errorInfo.stack }); + } catch (e) { + setTimeout(function () { + throw e; + }); + } +} +function logCaughtError(root, boundary, errorInfo) { + try { + var onCaughtError = root.onCaughtError; + onCaughtError(errorInfo.value, { + componentStack: errorInfo.stack, + errorBoundary: 1 === boundary.tag ? boundary.stateNode : null + }); } catch (e) { setTimeout(function () { throw e; }); } } -function createRootErrorUpdate(fiber, errorInfo, lane) { +function createRootErrorUpdate(root, errorInfo, lane) { lane = createUpdate(lane); lane.tag = 3; lane.payload = { element: null }; lane.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return lane; } -function createClassErrorUpdate(fiber, errorInfo, lane) { +function createClassErrorUpdate(lane) { lane = createUpdate(lane); lane.tag = 3; + return lane; +} +function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error = errorInfo.value; - lane.payload = function () { + update.payload = function () { return getDerivedStateFromError(error); }; - lane.callback = function () { - logCapturedError(fiber, errorInfo); + update.callback = function () { + logCaughtError(root, fiber, errorInfo); }; } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && - (lane.callback = function () { - logCapturedError(fiber, errorInfo); + (update.callback = function () { + logCaughtError(root, fiber, errorInfo); "function" !== typeof getDerivedStateFromError && (null === legacyErrorBoundariesThatAlreadyFailed ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) @@ -4070,7 +4072,6 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { componentStack: null !== stack ? stack : "" }); }); - return lane; } function throwException( root, @@ -4085,43 +4086,36 @@ function throwException( "object" === typeof value && "function" === typeof value.then ) { - if (enableLazyContextPropagation) { - var currentSourceFiber = sourceFiber.alternate; - null !== currentSourceFiber && - propagateParentContextChanges( - currentSourceFiber, - sourceFiber, - rootRenderLanes, - !0 - ); - } - currentSourceFiber = sourceFiber.tag; + var wakeable = value; + enableLazyContextPropagation && + ((value = sourceFiber.alternate), + null !== value && + propagateParentContextChanges(value, sourceFiber, rootRenderLanes, !0)); + value = sourceFiber.tag; 0 !== (sourceFiber.mode & 1) || - (0 !== currentSourceFiber && - 11 !== currentSourceFiber && - 15 !== currentSourceFiber) || - ((currentSourceFiber = sourceFiber.alternate) - ? ((sourceFiber.updateQueue = currentSourceFiber.updateQueue), - (sourceFiber.memoizedState = currentSourceFiber.memoizedState), - (sourceFiber.lanes = currentSourceFiber.lanes)) + (0 !== value && 11 !== value && 15 !== value) || + ((value = sourceFiber.alternate) + ? ((sourceFiber.updateQueue = value.updateQueue), + (sourceFiber.memoizedState = value.memoizedState), + (sourceFiber.lanes = value.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null))); - currentSourceFiber = suspenseHandlerStackCursor.current; - if (null !== currentSourceFiber) { - switch (currentSourceFiber.tag) { + value = suspenseHandlerStackCursor.current; + if (null !== value) { + switch (value.tag) { case 13: return ( sourceFiber.mode & 1 && (null === shellBoundary ? renderDidSuspendDelayIfPossible() - : null === currentSourceFiber.alternate && + : null === value.alternate && 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 3)), - (currentSourceFiber.flags &= -257), - 0 === (currentSourceFiber.mode & 1) - ? currentSourceFiber === returnFiber - ? (currentSourceFiber.flags |= 65536) - : ((currentSourceFiber.flags |= 128), + (value.flags &= -257), + 0 === (value.mode & 1) + ? value === returnFiber + ? (value.flags |= 65536) + : ((value.flags |= 128), (sourceFiber.flags |= 131072), (sourceFiber.flags &= -52805), 1 === sourceFiber.tag && @@ -4131,101 +4125,101 @@ function throwException( (returnFiber.tag = 2), enqueueUpdate(sourceFiber, returnFiber, 2))), (sourceFiber.lanes |= 2)) - : ((currentSourceFiber.flags |= 65536), - (currentSourceFiber.lanes = rootRenderLanes)), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + : ((value.flags |= 65536), (value.lanes = rootRenderLanes)), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber - ? (currentSourceFiber.updateQueue = new Set([value])) - : returnFiber.add(value), - currentSourceFiber.mode & 1 && - attachPingListener(root, value, rootRenderLanes)), + ? (value.updateQueue = new Set([wakeable])) + : returnFiber.add(wakeable), + value.mode & 1 && + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); case 22: - if (currentSourceFiber.mode & 1) + if (value.mode & 1) return ( - (currentSourceFiber.flags |= 65536), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + (value.flags |= 65536), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber ? ((returnFiber = { transitions: null, markerInstances: null, - retryQueue: new Set([value]) + retryQueue: new Set([wakeable]) }), - (currentSourceFiber.updateQueue = returnFiber)) + (value.updateQueue = returnFiber)) : ((sourceFiber = returnFiber.retryQueue), null === sourceFiber - ? (returnFiber.retryQueue = new Set([value])) - : sourceFiber.add(value)), - attachPingListener(root, value, rootRenderLanes)), + ? (returnFiber.retryQueue = new Set([wakeable])) + : sourceFiber.add(wakeable)), + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); } - throw Error(formatProdErrorMessage(435, currentSourceFiber.tag)); + throw Error(formatProdErrorMessage(435, value.tag)); } if (1 === root.tag) return ( - attachPingListener(root, value, rootRenderLanes), + attachPingListener(root, wakeable, rootRenderLanes), renderDidSuspendDelayIfPossible(), !1 ); value = Error(formatProdErrorMessage(426)); } - root = value = createCapturedValueAtFiber(value, sourceFiber); + wakeable = value = createCapturedValueAtFiber(value, sourceFiber); 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + ? (workInProgressRootConcurrentErrors = [wakeable]) + : workInProgressRootConcurrentErrors.push(wakeable); if (null === returnFiber) return !0; - root = returnFiber; + wakeable = returnFiber; do { - switch (root.tag) { + switch (wakeable.tag) { case 3: return ( - (root.flags |= 65536), + (root = value), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createRootErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (root = createRootErrorUpdate( + wakeable.stateNode, root, - value, rootRenderLanes )), - enqueueCapturedUpdate(root, rootRenderLanes), + enqueueCapturedUpdate(wakeable, root), !1 ); case 1: + returnFiber = value; + sourceFiber = wakeable.type; + var instance = wakeable.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.type), - (currentSourceFiber = root.stateNode), - 0 === (root.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + 0 === (wakeable.flags & 128) && + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) return ( - (root.flags |= 65536), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createClassErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (rootRenderLanes = createClassErrorUpdate(rootRenderLanes)), + initializeClassErrorUpdate( + rootRenderLanes, root, - returnFiber, - rootRenderLanes - )), - enqueueCapturedUpdate(root, rootRenderLanes), + wakeable, + returnFiber + ), + enqueueCapturedUpdate(wakeable, rootRenderLanes), !1 ); } - root = root.return; - } while (null !== root); + wakeable = wakeable.return; + } while (null !== wakeable); return !1; } function processTransitionCallbacks(pendingTransitions, endTime, callbacks) { @@ -9439,8 +9433,8 @@ function handleThrow(root, thrownValue) { workInProgressThrownValue = thrownValue; null === workInProgress && ((workInProgressRootExitStatus = 1), - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) )); } @@ -9700,8 +9694,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { ) ) { workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -9710,8 +9704,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { } catch (error) { if (null !== returnFiber) throw ((workInProgress = returnFiber), error); workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -9945,7 +9939,7 @@ function flushPassiveEffectsImpl() { } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 2); + sourceFiber = createRootErrorUpdate(rootFiber.stateNode, sourceFiber, 2); rootFiber = enqueueUpdate(rootFiber, sourceFiber, 2); null !== rootFiber && (markRootUpdated(rootFiber, 2), ensureRootIsScheduled(rootFiber)); @@ -9972,19 +9966,17 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - nearestMountedAncestor = enqueueUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 2), - ensureRootIsScheduled(nearestMountedAncestor)); + error = createClassErrorUpdate(2); + instance = enqueueUpdate(nearestMountedAncestor, error, 2); + null !== instance && + (initializeClassErrorUpdate( + error, + instance, + nearestMountedAncestor, + sourceFiber + ), + markRootUpdated(instance, 2), + ensureRootIsScheduled(instance)); break; } } @@ -10382,6 +10374,8 @@ function FiberRootNode( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -10413,6 +10407,8 @@ function FiberRootNode( this.entanglements = createLaneMap(0); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; this.pooledCache = null; this.pooledCacheLanes = 0; @@ -10530,7 +10526,16 @@ var slice = Array.prototype.slice, +_this$props.height, this._tagRef ); - _this$props = new FiberRootNode(this._surface, 0, !1, "", void 0, null); + _this$props = new FiberRootNode( + this._surface, + 0, + !1, + "", + void 0, + void 0, + void 0, + null + ); _this$props.hydrationCallbacks = null; enableTransitionTracing && (_this$props.transitionCallbacks = void 0); var JSCompiler_inline_result = createFiber(3, null, null, 0); @@ -10604,19 +10609,19 @@ var slice = Array.prototype.slice, }; return Text; })(React.Component), - devToolsConfig$jscomp$inline_1118 = { + devToolsConfig$jscomp$inline_1120 = { findFiberByHostInstance: function () { return null; }, bundleType: 0, - version: "19.0.0-www-classic-dbdf50de", + version: "19.0.0-www-classic-d94b9177", rendererPackageName: "react-art" }; -var internals$jscomp$inline_1321 = { - bundleType: devToolsConfig$jscomp$inline_1118.bundleType, - version: devToolsConfig$jscomp$inline_1118.version, - rendererPackageName: devToolsConfig$jscomp$inline_1118.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1118.rendererConfig, +var internals$jscomp$inline_1325 = { + bundleType: devToolsConfig$jscomp$inline_1120.bundleType, + version: devToolsConfig$jscomp$inline_1120.version, + rendererPackageName: devToolsConfig$jscomp$inline_1120.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1120.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10633,26 +10638,26 @@ var internals$jscomp$inline_1321 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1118.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1120.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-dbdf50de" + reconcilerVersion: "19.0.0-www-classic-d94b9177" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1322 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1326 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1322.isDisabled && - hook$jscomp$inline_1322.supportsFiber + !hook$jscomp$inline_1326.isDisabled && + hook$jscomp$inline_1326.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1322.inject( - internals$jscomp$inline_1321 + (rendererID = hook$jscomp$inline_1326.inject( + internals$jscomp$inline_1325 )), - (injectedHook = hook$jscomp$inline_1322); + (injectedHook = hook$jscomp$inline_1326); } catch (err) {} } var Path = Mode$1.Path; diff --git a/compiled/facebook-www/ReactART-prod.modern.js b/compiled/facebook-www/ReactART-prod.modern.js index 1b4cfda973a1f..c4f41fba5ba0e 100644 --- a/compiled/facebook-www/ReactART-prod.modern.js +++ b/compiled/facebook-www/ReactART-prod.modern.js @@ -3763,85 +3763,87 @@ function createCapturedValueFromError(value, digest, stack) { digest: null != digest ? digest : null }; } -var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); -if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) - throw Error(formatProdErrorMessage(320)); -var reportGlobalError = - "function" === typeof reportError - ? reportError - : function (error) { - if ( - "object" === typeof window && - "function" === typeof window.ErrorEvent - ) { - var event = new window.ErrorEvent("error", { - bubbles: !0, - cancelable: !0, - message: - "object" === typeof error && - null !== error && - "string" === typeof error.message - ? String(error.message) - : String(error), - error: error - }); - if (!window.dispatchEvent(event)) return; - } else if ( - "object" === typeof process && - "function" === typeof process.emit - ) { - process.emit("uncaughtException", error); - return; - } - console.error(error); - }; -function logCapturedError(boundary, errorInfo) { +"function" === typeof reportError + ? reportError + : function (error) { + if ( + "object" === typeof window && + "function" === typeof window.ErrorEvent + ) { + var event = new window.ErrorEvent("error", { + bubbles: !0, + cancelable: !0, + message: + "object" === typeof error && + null !== error && + "string" === typeof error.message + ? String(error.message) + : String(error), + error: error + }); + if (!window.dispatchEvent(event)) return; + } else if ( + "object" === typeof process && + "function" === typeof process.emit + ) { + process.emit("uncaughtException", error); + return; + } + console.error(error); + }; +function logUncaughtError(root, errorInfo) { try { - if ( - !1 !== - ReactFiberErrorDialogWWW.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) - ) { - var error = errorInfo.value; - 3 === boundary.tag ? reportGlobalError(error) : console.error(error); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(errorInfo.value, { componentStack: errorInfo.stack }); + } catch (e) { + setTimeout(function () { + throw e; + }); + } +} +function logCaughtError(root, boundary, errorInfo) { + try { + var onCaughtError = root.onCaughtError; + onCaughtError(errorInfo.value, { + componentStack: errorInfo.stack, + errorBoundary: 1 === boundary.tag ? boundary.stateNode : null + }); } catch (e) { setTimeout(function () { throw e; }); } } -function createRootErrorUpdate(fiber, errorInfo, lane) { +function createRootErrorUpdate(root, errorInfo, lane) { lane = createUpdate(lane); lane.tag = 3; lane.payload = { element: null }; lane.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return lane; } -function createClassErrorUpdate(fiber, errorInfo, lane) { +function createClassErrorUpdate(lane) { lane = createUpdate(lane); lane.tag = 3; + return lane; +} +function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error = errorInfo.value; - lane.payload = function () { + update.payload = function () { return getDerivedStateFromError(error); }; - lane.callback = function () { - logCapturedError(fiber, errorInfo); + update.callback = function () { + logCaughtError(root, fiber, errorInfo); }; } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && - (lane.callback = function () { - logCapturedError(fiber, errorInfo); + (update.callback = function () { + logCaughtError(root, fiber, errorInfo); "function" !== typeof getDerivedStateFromError && (null === legacyErrorBoundariesThatAlreadyFailed ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) @@ -3851,7 +3853,6 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { componentStack: null !== stack ? stack : "" }); }); - return lane; } function throwException( root, @@ -3866,43 +3867,36 @@ function throwException( "object" === typeof value && "function" === typeof value.then ) { - if (enableLazyContextPropagation) { - var currentSourceFiber = sourceFiber.alternate; - null !== currentSourceFiber && - propagateParentContextChanges( - currentSourceFiber, - sourceFiber, - rootRenderLanes, - !0 - ); - } - currentSourceFiber = sourceFiber.tag; + var wakeable = value; + enableLazyContextPropagation && + ((value = sourceFiber.alternate), + null !== value && + propagateParentContextChanges(value, sourceFiber, rootRenderLanes, !0)); + value = sourceFiber.tag; 0 !== (sourceFiber.mode & 1) || - (0 !== currentSourceFiber && - 11 !== currentSourceFiber && - 15 !== currentSourceFiber) || - ((currentSourceFiber = sourceFiber.alternate) - ? ((sourceFiber.updateQueue = currentSourceFiber.updateQueue), - (sourceFiber.memoizedState = currentSourceFiber.memoizedState), - (sourceFiber.lanes = currentSourceFiber.lanes)) + (0 !== value && 11 !== value && 15 !== value) || + ((value = sourceFiber.alternate) + ? ((sourceFiber.updateQueue = value.updateQueue), + (sourceFiber.memoizedState = value.memoizedState), + (sourceFiber.lanes = value.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null))); - currentSourceFiber = suspenseHandlerStackCursor.current; - if (null !== currentSourceFiber) { - switch (currentSourceFiber.tag) { + value = suspenseHandlerStackCursor.current; + if (null !== value) { + switch (value.tag) { case 13: return ( sourceFiber.mode & 1 && (null === shellBoundary ? renderDidSuspendDelayIfPossible() - : null === currentSourceFiber.alternate && + : null === value.alternate && 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 3)), - (currentSourceFiber.flags &= -257), - 0 === (currentSourceFiber.mode & 1) - ? currentSourceFiber === returnFiber - ? (currentSourceFiber.flags |= 65536) - : ((currentSourceFiber.flags |= 128), + (value.flags &= -257), + 0 === (value.mode & 1) + ? value === returnFiber + ? (value.flags |= 65536) + : ((value.flags |= 128), (sourceFiber.flags |= 131072), (sourceFiber.flags &= -52805), 1 === sourceFiber.tag && @@ -3912,101 +3906,101 @@ function throwException( (returnFiber.tag = 2), enqueueUpdate(sourceFiber, returnFiber, 2))), (sourceFiber.lanes |= 2)) - : ((currentSourceFiber.flags |= 65536), - (currentSourceFiber.lanes = rootRenderLanes)), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + : ((value.flags |= 65536), (value.lanes = rootRenderLanes)), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber - ? (currentSourceFiber.updateQueue = new Set([value])) - : returnFiber.add(value), - currentSourceFiber.mode & 1 && - attachPingListener(root, value, rootRenderLanes)), + ? (value.updateQueue = new Set([wakeable])) + : returnFiber.add(wakeable), + value.mode & 1 && + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); case 22: - if (currentSourceFiber.mode & 1) + if (value.mode & 1) return ( - (currentSourceFiber.flags |= 65536), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + (value.flags |= 65536), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber ? ((returnFiber = { transitions: null, markerInstances: null, - retryQueue: new Set([value]) + retryQueue: new Set([wakeable]) }), - (currentSourceFiber.updateQueue = returnFiber)) + (value.updateQueue = returnFiber)) : ((sourceFiber = returnFiber.retryQueue), null === sourceFiber - ? (returnFiber.retryQueue = new Set([value])) - : sourceFiber.add(value)), - attachPingListener(root, value, rootRenderLanes)), + ? (returnFiber.retryQueue = new Set([wakeable])) + : sourceFiber.add(wakeable)), + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); } - throw Error(formatProdErrorMessage(435, currentSourceFiber.tag)); + throw Error(formatProdErrorMessage(435, value.tag)); } if (1 === root.tag) return ( - attachPingListener(root, value, rootRenderLanes), + attachPingListener(root, wakeable, rootRenderLanes), renderDidSuspendDelayIfPossible(), !1 ); value = Error(formatProdErrorMessage(426)); } - root = value = createCapturedValueAtFiber(value, sourceFiber); + wakeable = value = createCapturedValueAtFiber(value, sourceFiber); 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + ? (workInProgressRootConcurrentErrors = [wakeable]) + : workInProgressRootConcurrentErrors.push(wakeable); if (null === returnFiber) return !0; - root = returnFiber; + wakeable = returnFiber; do { - switch (root.tag) { + switch (wakeable.tag) { case 3: return ( - (root.flags |= 65536), + (root = value), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createRootErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (root = createRootErrorUpdate( + wakeable.stateNode, root, - value, rootRenderLanes )), - enqueueCapturedUpdate(root, rootRenderLanes), + enqueueCapturedUpdate(wakeable, root), !1 ); case 1: + returnFiber = value; + sourceFiber = wakeable.type; + var instance = wakeable.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.type), - (currentSourceFiber = root.stateNode), - 0 === (root.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + 0 === (wakeable.flags & 128) && + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) return ( - (root.flags |= 65536), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createClassErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (rootRenderLanes = createClassErrorUpdate(rootRenderLanes)), + initializeClassErrorUpdate( + rootRenderLanes, root, - returnFiber, - rootRenderLanes - )), - enqueueCapturedUpdate(root, rootRenderLanes), + wakeable, + returnFiber + ), + enqueueCapturedUpdate(wakeable, rootRenderLanes), !1 ); } - root = root.return; - } while (null !== root); + wakeable = wakeable.return; + } while (null !== wakeable); return !1; } function processTransitionCallbacks(pendingTransitions, endTime, callbacks) { @@ -9138,8 +9132,8 @@ function handleThrow(root, thrownValue) { workInProgressThrownValue = thrownValue; null === workInProgress && ((workInProgressRootExitStatus = 1), - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) )); } @@ -9395,8 +9389,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { ) ) { workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -9405,8 +9399,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { } catch (error) { if (null !== returnFiber) throw ((workInProgress = returnFiber), error); workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -9640,7 +9634,7 @@ function flushPassiveEffectsImpl() { } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 2); + sourceFiber = createRootErrorUpdate(rootFiber.stateNode, sourceFiber, 2); rootFiber = enqueueUpdate(rootFiber, sourceFiber, 2); null !== rootFiber && (markRootUpdated(rootFiber, 2), ensureRootIsScheduled(rootFiber)); @@ -9667,19 +9661,17 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - nearestMountedAncestor = enqueueUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 2), - ensureRootIsScheduled(nearestMountedAncestor)); + error = createClassErrorUpdate(2); + instance = enqueueUpdate(nearestMountedAncestor, error, 2); + null !== instance && + (initializeClassErrorUpdate( + error, + instance, + nearestMountedAncestor, + sourceFiber + ), + markRootUpdated(instance, 2), + ensureRootIsScheduled(instance)); break; } } @@ -10077,6 +10069,8 @@ function FiberRootNode( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -10108,6 +10102,8 @@ function FiberRootNode( this.entanglements = createLaneMap(0); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; this.pooledCache = null; this.pooledCacheLanes = 0; @@ -10185,7 +10181,16 @@ var slice = Array.prototype.slice, +_this$props.height, this._tagRef ); - _this$props = new FiberRootNode(this._surface, 0, !1, "", void 0, null); + _this$props = new FiberRootNode( + this._surface, + 0, + !1, + "", + void 0, + void 0, + void 0, + null + ); _this$props.hydrationCallbacks = null; enableTransitionTracing && (_this$props.transitionCallbacks = void 0); var JSCompiler_inline_result = createFiber(3, null, null, 0); @@ -10259,19 +10264,19 @@ var slice = Array.prototype.slice, }; return Text; })(React.Component), - devToolsConfig$jscomp$inline_1098 = { + devToolsConfig$jscomp$inline_1100 = { findFiberByHostInstance: function () { return null; }, bundleType: 0, - version: "19.0.0-www-modern-c67e9532", + version: "19.0.0-www-modern-e692ec0d", rendererPackageName: "react-art" }; -var internals$jscomp$inline_1301 = { - bundleType: devToolsConfig$jscomp$inline_1098.bundleType, - version: devToolsConfig$jscomp$inline_1098.version, - rendererPackageName: devToolsConfig$jscomp$inline_1098.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1098.rendererConfig, +var internals$jscomp$inline_1305 = { + bundleType: devToolsConfig$jscomp$inline_1100.bundleType, + version: devToolsConfig$jscomp$inline_1100.version, + rendererPackageName: devToolsConfig$jscomp$inline_1100.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1100.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10288,26 +10293,26 @@ var internals$jscomp$inline_1301 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1098.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1100.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-c67e9532" + reconcilerVersion: "19.0.0-www-modern-e692ec0d" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1302 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1306 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1302.isDisabled && - hook$jscomp$inline_1302.supportsFiber + !hook$jscomp$inline_1306.isDisabled && + hook$jscomp$inline_1306.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1302.inject( - internals$jscomp$inline_1301 + (rendererID = hook$jscomp$inline_1306.inject( + internals$jscomp$inline_1305 )), - (injectedHook = hook$jscomp$inline_1302); + (injectedHook = hook$jscomp$inline_1306); } catch (err) {} } var Path = Mode$1.Path; diff --git a/compiled/facebook-www/ReactDOM-dev.classic.js b/compiled/facebook-www/ReactDOM-dev.classic.js index 6bf70aa183a6b..1ac990c64b8d1 100644 --- a/compiled/facebook-www/ReactDOM-dev.classic.js +++ b/compiled/facebook-www/ReactDOM-dev.classic.js @@ -18101,7 +18101,7 @@ if (__DEV__) { Object.freeze(fakeInternalInstance); } - function warnOnInvalidCallback$1(callback) { + function warnOnInvalidCallback$2(callback) { { if (callback === null || typeof callback === "function") { return; @@ -18188,7 +18188,7 @@ if (__DEV__) { if (callback !== undefined && callback !== null) { { - warnOnInvalidCallback$1(callback); + warnOnInvalidCallback$2(callback); } update.callback = callback; @@ -18223,7 +18223,7 @@ if (__DEV__) { if (callback !== undefined && callback !== null) { { - warnOnInvalidCallback$1(callback); + warnOnInvalidCallback$2(callback); } update.callback = callback; @@ -18258,7 +18258,7 @@ if (__DEV__) { if (callback !== undefined && callback !== null) { { - warnOnInvalidCallback$1(callback); + warnOnInvalidCallback$2(callback); } update.callback = callback; @@ -19289,26 +19289,6 @@ if (__DEV__) { }; } - var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); - - if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { - throw new Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); - } - - function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; - return ReactFiberErrorDialogWWW.showErrorDialog(capturedError); - } - var reportGlobalError = typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, ? // emulating an uncaught JavaScript error. @@ -19348,86 +19328,111 @@ if (__DEV__) { console["error"](error); }; - var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; - function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API - if (logError === false) { - return; + var componentName = null; + var errorBoundaryName = null; + function defaultOnUncaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // For uncaught root errors we report them as uncaught to the browser's + // onerror callback. This won't have component stacks and the error addendum. + // So we add those into a separate console.warn. + reportGlobalError(error); + + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "An error occurred in the <" + componentName + "> component:" + : "An error occurred in one of your React components:"; + console["warn"]( + "%s\n%s\n\n%s", + componentNameMessage, + componentStack || "", + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." + ); + } + } + function defaultOnCaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // Caught by error boundary + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; // In development, we provide our own message which includes the component stack + // in addition to the error. + // Don't transform to our wrapper + + console["error"]( + "%o\n\n%s\n%s\n\n%s", + error, + componentNameMessage, + componentStack, + "React will try to recreate this component tree from scratch " + + ("using the error boundary you provided, " + + (errorBoundaryName || "Anonymous") + + ".") + ); + } + } + function defaultOnRecoverableError(error, errorInfo) { + reportGlobalError(error); + } + function logUncaughtError(root, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = null; } var error = errorInfo.value; - if (boundary.tag === HostRoot) { - if (true && ReactCurrentActQueue$2.current !== null) { - // For uncaught errors inside act, we track them on the act and then - // rethrow them into the test. - ReactCurrentActQueue$2.thrownErrors.push(error); - return; - } // For uncaught root errors we report them as uncaught to the browser's - // onerror callback. This won't have component stacks and the error addendum. - // So we add those into a separate console.warn. - - reportGlobalError(error); + if (true && ReactCurrentActQueue$2.current !== null) { + // For uncaught errors inside act, we track them on the act and then + // rethrow them into the test. + ReactCurrentActQueue$2.thrownErrors.push(error); + return; + } - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var componentName = source - ? getComponentNameFromFiber(source) - : null; - var componentNameMessage = componentName - ? "An error occurred in the <" + componentName + "> component:" - : "An error occurred in one of your React components:"; - console["warn"]( - "%s\n%s\n\n%s", - componentNameMessage, - componentStack, - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." - ); - } - } else { - // Caught by error boundary - if (true) { - var _source = errorInfo.source; - var _stack = errorInfo.stack; - - var _componentStack = _stack !== null ? _stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var _componentName = _source - ? getComponentNameFromFiber(_source) - : null; - - var _componentNameMessage = _componentName - ? "The above error occurred in the <" + - _componentName + - "> component:" - : "The above error occurred in one of your React components:"; - - var errorBoundaryName = - getComponentNameFromFiber(boundary) || "Anonymous"; // In development, we provide our own message which includes the component stack - // in addition to the error. - // Don't transform to our wrapper - - console["error"]( - "%o\n\n%s\n%s\n\n%s", - error, - _componentNameMessage, - _componentStack, - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + - errorBoundaryName + - ".") - ); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(error, { + componentStack: errorInfo.stack + }); + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function () { + throw e; + }); + } + } + function logCaughtError(root, boundary, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = getComponentNameFromFiber(boundary); } + + var error = errorInfo.value; + var onCaughtError = root.onCaughtError; + onCaughtError(error, { + componentStack: errorInfo.stack, + errorBoundary: + boundary.tag === ClassComponent + ? boundary.stateNode // This should always be the case as long as we only have class boundaries + : null + }); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -19439,7 +19444,7 @@ if (__DEV__) { } } - function createRootErrorUpdate(fiber, errorInfo, lane) { + function createRootErrorUpdate(root, errorInfo, lane) { var update = createUpdate(lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property @@ -19450,15 +19455,19 @@ if (__DEV__) { }; update.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return update; } - function createClassErrorUpdate(fiber, errorInfo, lane) { + function createClassErrorUpdate(lane) { var update = createUpdate(lane); update.tag = CaptureUpdate; + return update; + } + + function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { @@ -19473,7 +19482,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); }; } @@ -19486,7 +19495,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, @@ -19519,8 +19528,6 @@ if (__DEV__) { } }; } - - return update; } function resetSuspendedComponent(sourceFiber, rootRenderLanes) { @@ -19925,7 +19932,7 @@ if (__DEV__) { var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); var update = createRootErrorUpdate( - workInProgress, + workInProgress.stateNode, _errorInfo, lane ); @@ -19952,12 +19959,14 @@ if (__DEV__) { workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update = createClassErrorUpdate( + var _update = createClassErrorUpdate(_lane); + + initializeClassErrorUpdate( + _update, + root, workInProgress, - errorInfo, - _lane + errorInfo ); - enqueueCapturedUpdate(workInProgress, _update); return false; } @@ -21062,10 +21071,20 @@ if (__DEV__) { var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state - var update = createClassErrorUpdate( + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var update = createClassErrorUpdate(lane); + initializeClassErrorUpdate( + update, + root, workInProgress, - createCapturedValueAtFiber(error$1, workInProgress), - lane + createCapturedValueAtFiber(error$1, workInProgress) ); enqueueCapturedUpdate(workInProgress, update); break; @@ -32711,8 +32730,8 @@ if (__DEV__) { if (erroredWork === null) { // This is a fatal error workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); return; @@ -33537,10 +33556,7 @@ if (__DEV__) { // caught by an error boundary. This is a fatal error, or panic condition, // because we've run out of ways to recover. workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, - createCapturedValueAtFiber(error, root.current) - ); // Set `workInProgress` to null. This represents advancing to the next + logUncaughtError(root, createCapturedValueAtFiber(error, root.current)); // Set `workInProgress` to null. This represents advancing to the next // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're @@ -34313,7 +34329,11 @@ if (__DEV__) { function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValueAtFiber(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate( + rootFiber.stateNode, + errorInfo, + SyncLane + ); var root = enqueueUpdate(rootFiber, update, SyncLane); if (root !== null) { @@ -34354,10 +34374,11 @@ if (__DEV__) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValueAtFiber(error$1, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate(SyncLane); var root = enqueueUpdate(fiber, update, SyncLane); if (root !== null) { + initializeClassErrorUpdate(update, root, fiber, errorInfo); markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } @@ -36170,6 +36191,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -36198,6 +36221,8 @@ if (__DEV__) { this.entanglements = createLaneMap(NoLanes); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; { @@ -36260,6 +36285,8 @@ if (__DEV__) { // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -36270,6 +36297,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -36315,7 +36344,7 @@ if (__DEV__) { return root; } - var ReactVersion = "19.0.0-www-classic-45168b08"; + var ReactVersion = "19.0.0-www-classic-58243be2"; function createPortal$1( children, @@ -36447,6 +36476,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ) { @@ -36461,6 +36492,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -36475,6 +36508,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -36489,6 +36524,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -48402,10 +48439,6 @@ if (__DEV__) { } } - function defaultOnRecoverableError(error, errorInfo) { - reportGlobalError(error); - } // $FlowFixMe[missing-this-annot] - function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } // $FlowFixMe[prop-missing] found when upgrading Flow @@ -48483,6 +48516,8 @@ if (__DEV__) { var isStrictMode = false; var concurrentUpdatesByDefaultOverride = false; var identifierPrefix = ""; + var onUncaughtError = defaultOnUncaughtError; + var onCaughtError = defaultOnCaughtError; var onRecoverableError = defaultOnRecoverableError; var transitionCallbacks = null; @@ -48521,6 +48556,14 @@ if (__DEV__) { identifierPrefix = options.identifierPrefix; } + if (options.onUncaughtError !== undefined) { + onUncaughtError = options.onUncaughtError; + } + + if (options.onCaughtError !== undefined) { + onCaughtError = options.onCaughtError; + } + if (options.onRecoverableError !== undefined) { onRecoverableError = options.onRecoverableError; } @@ -48537,6 +48580,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ); @@ -48581,6 +48626,8 @@ if (__DEV__) { var isStrictMode = false; var concurrentUpdatesByDefaultOverride = false; var identifierPrefix = ""; + var onUncaughtError = defaultOnUncaughtError; + var onCaughtError = defaultOnCaughtError; var onRecoverableError = defaultOnRecoverableError; var transitionCallbacks = null; var formState = null; @@ -48598,6 +48645,14 @@ if (__DEV__) { identifierPrefix = options.identifierPrefix; } + if (options.onUncaughtError !== undefined) { + onUncaughtError = options.onUncaughtError; + } + + if (options.onCaughtError !== undefined) { + onCaughtError = options.onCaughtError; + } + if (options.onRecoverableError !== undefined) { onRecoverableError = options.onRecoverableError; } @@ -48622,6 +48677,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -48675,10 +48732,10 @@ if (__DEV__) { } var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; - var topLevelUpdateWarnings; + var topLevelUpdateWarnings$1; { - topLevelUpdateWarnings = function (container) { + topLevelUpdateWarnings$1 = function (container) { if ( container._reactRootContainer && container.nodeType !== COMMENT_NODE @@ -48700,7 +48757,7 @@ if (__DEV__) { } var isRootRenderedBySomeReact = !!container._reactRootContainer; - var rootEl = getReactRootElementInContainer(container); + var rootEl = getReactRootElementInContainer$1(container); var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl)); if (hasNonRootReactChild && !isRootRenderedBySomeReact) { @@ -48714,7 +48771,7 @@ if (__DEV__) { }; } - function getReactRootElementInContainer(container) { + function getReactRootElementInContainer$1(container) { if (!container) { return null; } @@ -48726,12 +48783,12 @@ if (__DEV__) { } } - function noopOnRecoverableError() { + function noopOnRecoverableError$1() { // This isn't reachable because onRecoverableError isn't called in the // legacy API. } - function legacyCreateRootFromDOMContainer( + function legacyCreateRootFromDOMContainer$1( container, initialChildren, parentComponent, @@ -48757,7 +48814,9 @@ if (__DEV__) { false, // isStrictMode false, // concurrentUpdatesByDefaultOverride, "", // identifierPrefix - noopOnRecoverableError, // TODO(luna) Support hydration later + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, // TODO(luna) Support hydration later null, null ); @@ -48792,7 +48851,9 @@ if (__DEV__) { false, // isStrictMode false, // concurrentUpdatesByDefaultOverride, "", // identifierPrefix - noopOnRecoverableError, // onRecoverableError + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, null // transitionCallbacks ); @@ -48813,7 +48874,7 @@ if (__DEV__) { } } - function warnOnInvalidCallback(callback) { + function warnOnInvalidCallback$1(callback) { { if (callback !== null && typeof callback !== "function") { error( @@ -48825,7 +48886,7 @@ if (__DEV__) { } } - function legacyRenderSubtreeIntoContainer( + function legacyRenderSubtreeIntoContainer$1( parentComponent, children, container, @@ -48833,8 +48894,8 @@ if (__DEV__) { callback ) { { - topLevelUpdateWarnings(container); - warnOnInvalidCallback(callback === undefined ? null : callback); + topLevelUpdateWarnings$1(container); + warnOnInvalidCallback$1(callback === undefined ? null : callback); } var maybeRoot = container._reactRootContainer; @@ -48842,7 +48903,7 @@ if (__DEV__) { if (!maybeRoot) { // Initial mount - root = legacyCreateRootFromDOMContainer( + root = legacyCreateRootFromDOMContainer$1( container, children, parentComponent, @@ -48902,42 +48963,6 @@ if (__DEV__) { return findHostInstanceWithWarning(componentOrElement, "findDOMNode"); } } - function render(element, container, callback) { - { - error( - "ReactDOM.render has not been supported since React 18. Use createRoot " + - "instead. Until you switch to the new API, your app will behave as " + - "if it's running React 17. Learn " + - "more: https://react.dev/link/switch-to-createroot" - ); - } - - if (!isValidContainerLegacy(container)) { - throw new Error("Target container is not a DOM element."); - } - - { - var isModernRoot = - isContainerMarkedAsRoot(container) && - container._reactRootContainer === undefined; - - if (isModernRoot) { - error( - "You are calling ReactDOM.render() on a container that was previously " + - "passed to ReactDOMClient.createRoot(). This is not supported. " + - "Did you mean to call root.render(element)?" - ); - } - } - - return legacyRenderSubtreeIntoContainer( - null, - element, - container, - false, - callback - ); - } function unstable_renderSubtreeIntoContainer( parentComponent, element, @@ -48961,7 +48986,7 @@ if (__DEV__) { throw new Error("parentComponent must be a valid React Component"); } - return legacyRenderSubtreeIntoContainer( + return legacyRenderSubtreeIntoContainer$1( parentComponent, element, containerNode, @@ -48989,7 +49014,7 @@ if (__DEV__) { if (container._reactRootContainer) { { - var rootEl = getReactRootElementInContainer(container); + var rootEl = getReactRootElementInContainer$1(container); var renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl); if (renderedByDifferentReact) { @@ -49001,7 +49026,7 @@ if (__DEV__) { } // Unmount should not be batched. flushSync$1(function () { - legacyRenderSubtreeIntoContainer( + legacyRenderSubtreeIntoContainer$1( null, null, container, @@ -49018,7 +49043,7 @@ if (__DEV__) { return true; } else { { - var _rootEl = getReactRootElementInContainer(container); + var _rootEl = getReactRootElementInContainer$1(container); var hasNonRootReactChild = !!( _rootEl && getInstanceFromNode(_rootEl) @@ -49566,32 +49591,6 @@ if (__DEV__) { callback ); } - - function createRoot(container, options) { - { - if (!Internals.usingClientEntryPoint && !false) { - error( - 'You are importing createRoot from "react-dom" which is not supported. ' + - 'You should instead import it from "react-dom/client".' - ); - } - } - - return createRoot$1(container, options); - } - - function hydrateRoot(container, initialChildren, options) { - { - if (!Internals.usingClientEntryPoint && !false) { - error( - 'You are importing hydrateRoot from "react-dom" which is not supported. ' + - 'You should instead import it from "react-dom/client".' - ); - } - } - - return hydrateRoot$1(container, initialChildren, options); - } // Overload the definition to the two valid signatures. // Warning, this opts-out of checking the function body. // eslint-disable-next-line no-redeclare // eslint-disable-next-line no-redeclare @@ -49653,6 +49652,307 @@ if (__DEV__) { } } + var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); + + if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { + throw new Error( + "Expected ReactFiberErrorDialog.showErrorDialog to be a function." + ); + } + + function wwwOnUncaughtError(error, errorInfo) { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var logError = ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: null, + error: error, + componentStack: componentStack + }); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. + + if (logError === false) { + return; + } + + defaultOnUncaughtError(error, errorInfo); + } + + function wwwOnCaughtError(error, errorInfo) { + var errorBoundary = errorInfo.errorBoundary; + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var logError = ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: errorBoundary, + error: error, + componentStack: componentStack + }); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. + + if (logError === false) { + return; + } + + defaultOnCaughtError(error, errorInfo); + } + + function createRoot(container, options) { + return createRoot$1( + container, + assign( + { + onUncaughtError: wwwOnUncaughtError, + onCaughtError: wwwOnCaughtError + }, + options + ) + ); + } + function hydrateRoot(container, initialChildren, options) { + return hydrateRoot$1( + container, + initialChildren, + assign( + { + onUncaughtError: wwwOnUncaughtError, + onCaughtError: wwwOnCaughtError + }, + options + ) + ); + } + var topLevelUpdateWarnings; + + { + topLevelUpdateWarnings = function (container) { + if ( + container._reactRootContainer && + container.nodeType !== COMMENT_NODE + ) { + var hostInstance = findHostInstanceWithNoPortals( + container._reactRootContainer.current + ); + + if (hostInstance) { + if (hostInstance.parentNode !== container) { + error( + "It looks like the React-rendered content of this " + + "container was removed without using React. This is not " + + "supported and will cause errors. Instead, call " + + "ReactDOM.unmountComponentAtNode to empty a container." + ); + } + } + } + + var isRootRenderedBySomeReact = !!container._reactRootContainer; + var rootEl = getReactRootElementInContainer(container); + var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl)); + + if (hasNonRootReactChild && !isRootRenderedBySomeReact) { + error( + "Replacing React-rendered children with a new root " + + "component. If you intended to update the children of this node, " + + "you should instead have the existing children update their state " + + "and render the new components instead of calling ReactDOM.render." + ); + } + }; + } + + function getReactRootElementInContainer(container) { + if (!container) { + return null; + } + + if (container.nodeType === DOCUMENT_NODE) { + return container.documentElement; + } else { + return container.firstChild; + } + } + + function noopOnRecoverableError() { + // This isn't reachable because onRecoverableError isn't called in the + // legacy API. + } + + function legacyCreateRootFromDOMContainer( + container, + initialChildren, + parentComponent, + callback, + isHydrationContainer + ) { + if (isHydrationContainer) { + if (typeof callback === "function") { + var originalCallback = callback; + + callback = function () { + var instance = getPublicRootInstance(root); + originalCallback.call(instance); + }; + } + + var root = createHydrationContainer( + initialChildren, + callback, + container, + LegacyRoot, + null, // hydrationCallbacks + false, // isStrictMode + false, // concurrentUpdatesByDefaultOverride, + "", // identifierPrefix + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, // TODO(luna) Support hydration later + null, + null + ); + container._reactRootContainer = root; + markContainerAsRoot(root.current, container); + var rootContainerElement = + container.nodeType === COMMENT_NODE + ? container.parentNode + : container; // $FlowFixMe[incompatible-call] + + listenToAllSupportedEvents(rootContainerElement); + flushSync$1(); + return root; + } else { + // First clear any existing content. + clearContainer(container); + + if (typeof callback === "function") { + var _originalCallback = callback; + + callback = function () { + var instance = getPublicRootInstance(_root); + + _originalCallback.call(instance); + }; + } + + var _root = createContainer( + container, + LegacyRoot, + null, // hydrationCallbacks + false, // isStrictMode + false, // concurrentUpdatesByDefaultOverride, + "", // identifierPrefix + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, + null // transitionCallbacks + ); + + container._reactRootContainer = _root; + markContainerAsRoot(_root.current, container); + + var _rootContainerElement = + container.nodeType === COMMENT_NODE + ? container.parentNode + : container; // $FlowFixMe[incompatible-call] + + listenToAllSupportedEvents(_rootContainerElement); // Initial mount should not be batched. + + flushSync$1(function () { + updateContainer(initialChildren, _root, parentComponent, callback); + }); + return _root; + } + } + + function warnOnInvalidCallback(callback) { + { + if (callback !== null && typeof callback !== "function") { + error( + "Expected the last optional `callback` argument to be a " + + "function. Instead received: %s.", + callback + ); + } + } + } + + function legacyRenderSubtreeIntoContainer( + parentComponent, + children, + container, + forceHydrate, + callback + ) { + { + topLevelUpdateWarnings(container); + warnOnInvalidCallback(callback === undefined ? null : callback); + } + + var maybeRoot = container._reactRootContainer; + var root; + + if (!maybeRoot) { + // Initial mount + root = legacyCreateRootFromDOMContainer( + container, + children, + parentComponent, + callback, + forceHydrate + ); + } else { + root = maybeRoot; + + if (typeof callback === "function") { + var originalCallback = callback; + + callback = function () { + var instance = getPublicRootInstance(root); + originalCallback.call(instance); + }; + } // Update + + updateContainer(children, root, parentComponent, callback); + } + + return getPublicRootInstance(root); + } + + function render(element, container, callback) { + { + error( + "ReactDOM.render has not been supported since React 18. Use createRoot " + + "instead. Until you switch to the new API, your app will behave as " + + "if it's running React 17. Learn " + + "more: https://react.dev/link/switch-to-createroot" + ); + } + + if (!isValidContainerLegacy(container)) { + throw new Error("Target container is not a DOM element."); + } + + { + var isModernRoot = + isContainerMarkedAsRoot(container) && + container._reactRootContainer === undefined; + + if (isModernRoot) { + error( + "You are calling ReactDOM.render() on a container that was previously " + + "passed to ReactDOMClient.createRoot(). This is not supported. " + + "Did you mean to call root.render(element)?" + ); + } + } + + return legacyRenderSubtreeIntoContainer( + null, + element, + container, + false, + callback + ); + } + assign(Internals, { ReactBrowserEventEmitter: { isEnabled: isEnabled diff --git a/compiled/facebook-www/ReactDOM-dev.modern.js b/compiled/facebook-www/ReactDOM-dev.modern.js index f005ab3fd6e8a..3af6d792d2018 100644 --- a/compiled/facebook-www/ReactDOM-dev.modern.js +++ b/compiled/facebook-www/ReactDOM-dev.modern.js @@ -19210,26 +19210,6 @@ if (__DEV__) { }; } - var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); - - if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { - throw new Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); - } - - function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; - return ReactFiberErrorDialogWWW.showErrorDialog(capturedError); - } - var reportGlobalError = typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, ? // emulating an uncaught JavaScript error. @@ -19269,86 +19249,111 @@ if (__DEV__) { console["error"](error); }; - var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; - function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API - if (logError === false) { - return; + var componentName = null; + var errorBoundaryName = null; + function defaultOnUncaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // For uncaught root errors we report them as uncaught to the browser's + // onerror callback. This won't have component stacks and the error addendum. + // So we add those into a separate console.warn. + reportGlobalError(error); + + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "An error occurred in the <" + componentName + "> component:" + : "An error occurred in one of your React components:"; + console["warn"]( + "%s\n%s\n\n%s", + componentNameMessage, + componentStack || "", + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." + ); + } + } + function defaultOnCaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // Caught by error boundary + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; // In development, we provide our own message which includes the component stack + // in addition to the error. + // Don't transform to our wrapper + + console["error"]( + "%o\n\n%s\n%s\n\n%s", + error, + componentNameMessage, + componentStack, + "React will try to recreate this component tree from scratch " + + ("using the error boundary you provided, " + + (errorBoundaryName || "Anonymous") + + ".") + ); + } + } + function defaultOnRecoverableError(error, errorInfo) { + reportGlobalError(error); + } + function logUncaughtError(root, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = null; } var error = errorInfo.value; - if (boundary.tag === HostRoot) { - if (true && ReactCurrentActQueue$2.current !== null) { - // For uncaught errors inside act, we track them on the act and then - // rethrow them into the test. - ReactCurrentActQueue$2.thrownErrors.push(error); - return; - } // For uncaught root errors we report them as uncaught to the browser's - // onerror callback. This won't have component stacks and the error addendum. - // So we add those into a separate console.warn. - - reportGlobalError(error); + if (true && ReactCurrentActQueue$2.current !== null) { + // For uncaught errors inside act, we track them on the act and then + // rethrow them into the test. + ReactCurrentActQueue$2.thrownErrors.push(error); + return; + } - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var componentName = source - ? getComponentNameFromFiber(source) - : null; - var componentNameMessage = componentName - ? "An error occurred in the <" + componentName + "> component:" - : "An error occurred in one of your React components:"; - console["warn"]( - "%s\n%s\n\n%s", - componentNameMessage, - componentStack, - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." - ); - } - } else { - // Caught by error boundary - if (true) { - var _source = errorInfo.source; - var _stack = errorInfo.stack; - - var _componentStack = _stack !== null ? _stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var _componentName = _source - ? getComponentNameFromFiber(_source) - : null; - - var _componentNameMessage = _componentName - ? "The above error occurred in the <" + - _componentName + - "> component:" - : "The above error occurred in one of your React components:"; - - var errorBoundaryName = - getComponentNameFromFiber(boundary) || "Anonymous"; // In development, we provide our own message which includes the component stack - // in addition to the error. - // Don't transform to our wrapper - - console["error"]( - "%o\n\n%s\n%s\n\n%s", - error, - _componentNameMessage, - _componentStack, - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + - errorBoundaryName + - ".") - ); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(error, { + componentStack: errorInfo.stack + }); + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function () { + throw e; + }); + } + } + function logCaughtError(root, boundary, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = getComponentNameFromFiber(boundary); } + + var error = errorInfo.value; + var onCaughtError = root.onCaughtError; + onCaughtError(error, { + componentStack: errorInfo.stack, + errorBoundary: + boundary.tag === ClassComponent + ? boundary.stateNode // This should always be the case as long as we only have class boundaries + : null + }); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -19360,7 +19365,7 @@ if (__DEV__) { } } - function createRootErrorUpdate(fiber, errorInfo, lane) { + function createRootErrorUpdate(root, errorInfo, lane) { var update = createUpdate(lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property @@ -19371,15 +19376,19 @@ if (__DEV__) { }; update.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return update; } - function createClassErrorUpdate(fiber, errorInfo, lane) { + function createClassErrorUpdate(lane) { var update = createUpdate(lane); update.tag = CaptureUpdate; + return update; + } + + function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { @@ -19394,7 +19403,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); }; } @@ -19407,7 +19416,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, @@ -19440,8 +19449,6 @@ if (__DEV__) { } }; } - - return update; } function resetSuspendedComponent(sourceFiber, rootRenderLanes) { @@ -19846,7 +19853,7 @@ if (__DEV__) { var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); var update = createRootErrorUpdate( - workInProgress, + workInProgress.stateNode, _errorInfo, lane ); @@ -19873,12 +19880,14 @@ if (__DEV__) { workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update = createClassErrorUpdate( + var _update = createClassErrorUpdate(_lane); + + initializeClassErrorUpdate( + _update, + root, workInProgress, - errorInfo, - _lane + errorInfo ); - enqueueCapturedUpdate(workInProgress, _update); return false; } @@ -20974,10 +20983,20 @@ if (__DEV__) { var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state - var update = createClassErrorUpdate( + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var update = createClassErrorUpdate(lane); + initializeClassErrorUpdate( + update, + root, workInProgress, - createCapturedValueAtFiber(error$1, workInProgress), - lane + createCapturedValueAtFiber(error$1, workInProgress) ); enqueueCapturedUpdate(workInProgress, update); break; @@ -32567,8 +32586,8 @@ if (__DEV__) { if (erroredWork === null) { // This is a fatal error workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); return; @@ -33384,10 +33403,7 @@ if (__DEV__) { // caught by an error boundary. This is a fatal error, or panic condition, // because we've run out of ways to recover. workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, - createCapturedValueAtFiber(error, root.current) - ); // Set `workInProgress` to null. This represents advancing to the next + logUncaughtError(root, createCapturedValueAtFiber(error, root.current)); // Set `workInProgress` to null. This represents advancing to the next // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're @@ -34160,7 +34176,11 @@ if (__DEV__) { function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValueAtFiber(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate( + rootFiber.stateNode, + errorInfo, + SyncLane + ); var root = enqueueUpdate(rootFiber, update, SyncLane); if (root !== null) { @@ -34201,10 +34221,11 @@ if (__DEV__) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValueAtFiber(error$1, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate(SyncLane); var root = enqueueUpdate(fiber, update, SyncLane); if (root !== null) { + initializeClassErrorUpdate(update, root, fiber, errorInfo); markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } @@ -36017,6 +36038,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -36045,6 +36068,8 @@ if (__DEV__) { this.entanglements = createLaneMap(NoLanes); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; { @@ -36107,6 +36132,8 @@ if (__DEV__) { // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -36117,6 +36144,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -36162,7 +36191,7 @@ if (__DEV__) { return root; } - var ReactVersion = "19.0.0-www-modern-2212f44c"; + var ReactVersion = "19.0.0-www-modern-92674784"; function createPortal$1( children, @@ -36222,6 +36251,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ) { @@ -36236,6 +36267,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -36250,6 +36283,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -36264,6 +36299,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -47885,10 +47922,6 @@ if (__DEV__) { var NotPendingTransition = NotPending; - function defaultOnRecoverableError(error, errorInfo) { - reportGlobalError(error); - } // $FlowFixMe[missing-this-annot] - function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } // $FlowFixMe[prop-missing] found when upgrading Flow @@ -47966,6 +47999,8 @@ if (__DEV__) { var isStrictMode = false; var concurrentUpdatesByDefaultOverride = false; var identifierPrefix = ""; + var onUncaughtError = defaultOnUncaughtError; + var onCaughtError = defaultOnCaughtError; var onRecoverableError = defaultOnRecoverableError; var transitionCallbacks = null; @@ -48004,6 +48039,14 @@ if (__DEV__) { identifierPrefix = options.identifierPrefix; } + if (options.onUncaughtError !== undefined) { + onUncaughtError = options.onUncaughtError; + } + + if (options.onCaughtError !== undefined) { + onCaughtError = options.onCaughtError; + } + if (options.onRecoverableError !== undefined) { onRecoverableError = options.onRecoverableError; } @@ -48020,6 +48063,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ); @@ -48064,6 +48109,8 @@ if (__DEV__) { var isStrictMode = false; var concurrentUpdatesByDefaultOverride = false; var identifierPrefix = ""; + var onUncaughtError = defaultOnUncaughtError; + var onCaughtError = defaultOnCaughtError; var onRecoverableError = defaultOnRecoverableError; var transitionCallbacks = null; var formState = null; @@ -48081,6 +48128,14 @@ if (__DEV__) { identifierPrefix = options.identifierPrefix; } + if (options.onUncaughtError !== undefined) { + onUncaughtError = options.onUncaughtError; + } + + if (options.onCaughtError !== undefined) { + onCaughtError = options.onCaughtError; + } + if (options.onRecoverableError !== undefined) { onRecoverableError = options.onRecoverableError; } @@ -48105,6 +48160,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -48650,32 +48707,6 @@ if (__DEV__) { return createPortal$1(children, container, null, key); } - - function createRoot(container, options) { - { - if (!Internals.usingClientEntryPoint && !false) { - error( - 'You are importing createRoot from "react-dom" which is not supported. ' + - 'You should instead import it from "react-dom/client".' - ); - } - } - - return createRoot$1(container, options); - } - - function hydrateRoot(container, initialChildren, options) { - { - if (!Internals.usingClientEntryPoint && !false) { - error( - 'You are importing hydrateRoot from "react-dom" which is not supported. ' + - 'You should instead import it from "react-dom/client".' - ); - } - } - - return hydrateRoot$1(container, initialChildren, options); - } // Overload the definition to the two valid signatures. // Warning, this opts-out of checking the function body. // eslint-disable-next-line no-redeclare // eslint-disable-next-line no-redeclare @@ -48737,6 +48768,75 @@ if (__DEV__) { } } + var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); + + if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { + throw new Error( + "Expected ReactFiberErrorDialog.showErrorDialog to be a function." + ); + } + + function wwwOnUncaughtError(error, errorInfo) { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var logError = ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: null, + error: error, + componentStack: componentStack + }); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. + + if (logError === false) { + return; + } + + defaultOnUncaughtError(error, errorInfo); + } + + function wwwOnCaughtError(error, errorInfo) { + var errorBoundary = errorInfo.errorBoundary; + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var logError = ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: errorBoundary, + error: error, + componentStack: componentStack + }); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. + + if (logError === false) { + return; + } + + defaultOnCaughtError(error, errorInfo); + } + + function createRoot(container, options) { + return createRoot$1( + container, + assign( + { + onUncaughtError: wwwOnUncaughtError, + onCaughtError: wwwOnCaughtError + }, + options + ) + ); + } + function hydrateRoot(container, initialChildren, options) { + return hydrateRoot$1( + container, + initialChildren, + assign( + { + onUncaughtError: wwwOnUncaughtError, + onCaughtError: wwwOnCaughtError + }, + options + ) + ); + } + exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; exports.createPortal = createPortal; exports.createRoot = createRoot; diff --git a/compiled/facebook-www/ReactDOM-prod.classic.js b/compiled/facebook-www/ReactDOM-prod.classic.js index 8388e18aff9a0..e2e962b0a4ac5 100644 --- a/compiled/facebook-www/ReactDOM-prod.classic.js +++ b/compiled/facebook-www/ReactDOM-prod.classic.js @@ -4838,9 +4838,6 @@ function createCapturedValueFromError(value, digest, stack) { digest: null != digest ? digest : null }; } -var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); -if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) - throw Error(formatProdErrorMessage(320)); var reportGlobalError = "function" === typeof reportError ? reportError @@ -4870,53 +4867,68 @@ var reportGlobalError = } console.error(error); }; -function logCapturedError(boundary, errorInfo) { +function defaultOnUncaughtError(error) { + reportGlobalError(error); +} +function defaultOnCaughtError(error) { + console.error(error); +} +function defaultOnRecoverableError(error) { + reportGlobalError(error); +} +function logUncaughtError(root, errorInfo) { try { - if ( - !1 !== - ReactFiberErrorDialogWWW.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) - ) { - var error = errorInfo.value; - 3 === boundary.tag ? reportGlobalError(error) : console.error(error); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(errorInfo.value, { componentStack: errorInfo.stack }); } catch (e) { setTimeout(function () { throw e; }); } } -function createRootErrorUpdate(fiber, errorInfo, lane) { +function logCaughtError(root, boundary, errorInfo) { + try { + var onCaughtError = root.onCaughtError; + onCaughtError(errorInfo.value, { + componentStack: errorInfo.stack, + errorBoundary: 1 === boundary.tag ? boundary.stateNode : null + }); + } catch (e) { + setTimeout(function () { + throw e; + }); + } +} +function createRootErrorUpdate(root, errorInfo, lane) { lane = createUpdate(lane); lane.tag = 3; lane.payload = { element: null }; lane.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return lane; } -function createClassErrorUpdate(fiber, errorInfo, lane) { +function createClassErrorUpdate(lane) { lane = createUpdate(lane); lane.tag = 3; + return lane; +} +function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error = errorInfo.value; - lane.payload = function () { + update.payload = function () { return getDerivedStateFromError(error); }; - lane.callback = function () { - logCapturedError(fiber, errorInfo); + update.callback = function () { + logCaughtError(root, fiber, errorInfo); }; } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && - (lane.callback = function () { - logCapturedError(fiber, errorInfo); + (update.callback = function () { + logCaughtError(root, fiber, errorInfo); "function" !== typeof getDerivedStateFromError && (null === legacyErrorBoundariesThatAlreadyFailed ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) @@ -4926,7 +4938,6 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { componentStack: null !== stack ? stack : "" }); }); - return lane; } function markSuspenseBoundaryShouldCapture( suspenseBoundary, @@ -4968,83 +4979,76 @@ function throwException( "object" === typeof value && "function" === typeof value.then ) { - if (enableLazyContextPropagation) { - var currentSourceFiber = sourceFiber.alternate; - null !== currentSourceFiber && - propagateParentContextChanges( - currentSourceFiber, - sourceFiber, - rootRenderLanes, - !0 - ); - } - currentSourceFiber = sourceFiber.tag; + var wakeable = value; + enableLazyContextPropagation && + ((value = sourceFiber.alternate), + null !== value && + propagateParentContextChanges(value, sourceFiber, rootRenderLanes, !0)); + value = sourceFiber.tag; 0 !== (sourceFiber.mode & 1) || - (0 !== currentSourceFiber && - 11 !== currentSourceFiber && - 15 !== currentSourceFiber) || - ((currentSourceFiber = sourceFiber.alternate) - ? ((sourceFiber.updateQueue = currentSourceFiber.updateQueue), - (sourceFiber.memoizedState = currentSourceFiber.memoizedState), - (sourceFiber.lanes = currentSourceFiber.lanes)) + (0 !== value && 11 !== value && 15 !== value) || + ((value = sourceFiber.alternate) + ? ((sourceFiber.updateQueue = value.updateQueue), + (sourceFiber.memoizedState = value.memoizedState), + (sourceFiber.lanes = value.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null))); - currentSourceFiber = suspenseHandlerStackCursor.current; - if (null !== currentSourceFiber) { - switch (currentSourceFiber.tag) { + value = suspenseHandlerStackCursor.current; + if (null !== value) { + switch (value.tag) { case 13: return ( sourceFiber.mode & 1 && (null === shellBoundary ? renderDidSuspendDelayIfPossible() - : null === currentSourceFiber.alternate && + : null === value.alternate && 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 3)), - (currentSourceFiber.flags &= -257), + (value.flags &= -257), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + value, returnFiber, sourceFiber, root, rootRenderLanes ), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber - ? (currentSourceFiber.updateQueue = new Set([value])) - : returnFiber.add(value), - currentSourceFiber.mode & 1 && - attachPingListener(root, value, rootRenderLanes)), + ? (value.updateQueue = new Set([wakeable])) + : returnFiber.add(wakeable), + value.mode & 1 && + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); case 22: - if (currentSourceFiber.mode & 1) + if (value.mode & 1) return ( - (currentSourceFiber.flags |= 65536), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + (value.flags |= 65536), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber ? ((returnFiber = { transitions: null, markerInstances: null, - retryQueue: new Set([value]) + retryQueue: new Set([wakeable]) }), - (currentSourceFiber.updateQueue = returnFiber)) + (value.updateQueue = returnFiber)) : ((sourceFiber = returnFiber.retryQueue), null === sourceFiber - ? (returnFiber.retryQueue = new Set([value])) - : sourceFiber.add(value)), - attachPingListener(root, value, rootRenderLanes)), + ? (returnFiber.retryQueue = new Set([wakeable])) + : sourceFiber.add(wakeable)), + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); } - throw Error(formatProdErrorMessage(435, currentSourceFiber.tag)); + throw Error(formatProdErrorMessage(435, value.tag)); } if (1 === root.tag) return ( - attachPingListener(root, value, rootRenderLanes), + attachPingListener(root, wakeable, rootRenderLanes), renderDidSuspendDelayIfPossible(), !1 ); @@ -5053,14 +5057,12 @@ function throwException( if ( isHydrating && sourceFiber.mode & 1 && - ((currentSourceFiber = suspenseHandlerStackCursor.current), - null !== currentSourceFiber) + ((wakeable = suspenseHandlerStackCursor.current), null !== wakeable) ) return ( - 0 === (currentSourceFiber.flags & 65536) && - (currentSourceFiber.flags |= 256), + 0 === (wakeable.flags & 65536) && (wakeable.flags |= 256), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + wakeable, returnFiber, sourceFiber, root, @@ -5069,57 +5071,58 @@ function throwException( queueHydrationError(createCapturedValueAtFiber(value, sourceFiber)), !1 ); - root = value = createCapturedValueAtFiber(value, sourceFiber); + wakeable = value = createCapturedValueAtFiber(value, sourceFiber); 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + ? (workInProgressRootConcurrentErrors = [wakeable]) + : workInProgressRootConcurrentErrors.push(wakeable); if (null === returnFiber) return !0; - root = returnFiber; + wakeable = returnFiber; do { - switch (root.tag) { + switch (wakeable.tag) { case 3: return ( - (root.flags |= 65536), + (root = value), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createRootErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (root = createRootErrorUpdate( + wakeable.stateNode, root, - value, rootRenderLanes )), - enqueueCapturedUpdate(root, rootRenderLanes), + enqueueCapturedUpdate(wakeable, root), !1 ); case 1: + returnFiber = value; + sourceFiber = wakeable.type; + var instance = wakeable.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.type), - (currentSourceFiber = root.stateNode), - 0 === (root.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + 0 === (wakeable.flags & 128) && + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) return ( - (root.flags |= 65536), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createClassErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (rootRenderLanes = createClassErrorUpdate(rootRenderLanes)), + initializeClassErrorUpdate( + rootRenderLanes, root, - returnFiber, - rootRenderLanes - )), - enqueueCapturedUpdate(root, rootRenderLanes), + wakeable, + returnFiber + ), + enqueueCapturedUpdate(wakeable, rootRenderLanes), !1 ); } - root = root.return; - } while (null !== root); + wakeable = wakeable.return; + } while (null !== wakeable); return !1; } function processTransitionCallbacks(pendingTransitions, endTime, callbacks) { @@ -11264,8 +11267,8 @@ function handleThrow(root, thrownValue) { workInProgressThrownValue = thrownValue; null === workInProgress && ((workInProgressRootExitStatus = 1), - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) )); } @@ -11540,8 +11543,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { ) ) { workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -11550,8 +11553,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { } catch (error) { if (null !== returnFiber) throw ((workInProgress = returnFiber), error); workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -11812,7 +11815,7 @@ function flushPassiveEffectsImpl() { } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 2); + sourceFiber = createRootErrorUpdate(rootFiber.stateNode, sourceFiber, 2); rootFiber = enqueueUpdate(rootFiber, sourceFiber, 2); null !== rootFiber && (markRootUpdated(rootFiber, 2), ensureRootIsScheduled(rootFiber)); @@ -11839,19 +11842,17 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - nearestMountedAncestor = enqueueUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 2), - ensureRootIsScheduled(nearestMountedAncestor)); + error = createClassErrorUpdate(2); + instance = enqueueUpdate(nearestMountedAncestor, error, 2); + null !== instance && + (initializeClassErrorUpdate( + error, + instance, + nearestMountedAncestor, + sourceFiber + ), + markRootUpdated(instance, 2), + ensureRootIsScheduled(instance)); break; } } @@ -12258,6 +12259,8 @@ function FiberRootNode( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -12289,6 +12292,8 @@ function FiberRootNode( this.entanglements = createLaneMap(0); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; this.pooledCache = null; this.pooledCacheLanes = 0; @@ -12314,6 +12319,8 @@ function createFiberRoot( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -12323,6 +12330,8 @@ function createFiberRoot( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -12407,6 +12416,8 @@ function createHydrationContainer( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -12420,6 +12431,8 @@ function createHydrationContainer( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -13038,19 +13051,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$343; + var JSCompiler_inline_result$jscomp$347; if (canUseDOM) { - var isSupported$jscomp$inline_1494 = "oninput" in document; - if (!isSupported$jscomp$inline_1494) { - var element$jscomp$inline_1495 = document.createElement("div"); - element$jscomp$inline_1495.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1494 = - "function" === typeof element$jscomp$inline_1495.oninput; + var isSupported$jscomp$inline_1498 = "oninput" in document; + if (!isSupported$jscomp$inline_1498) { + var element$jscomp$inline_1499 = document.createElement("div"); + element$jscomp$inline_1499.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1498 = + "function" === typeof element$jscomp$inline_1499.oninput; } - JSCompiler_inline_result$jscomp$343 = isSupported$jscomp$inline_1494; - } else JSCompiler_inline_result$jscomp$343 = !1; + JSCompiler_inline_result$jscomp$347 = isSupported$jscomp$inline_1498; + } else JSCompiler_inline_result$jscomp$347 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$343 && + JSCompiler_inline_result$jscomp$347 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13422,20 +13435,20 @@ function extractEvents$1( } } for ( - var i$jscomp$inline_1535 = 0; - i$jscomp$inline_1535 < simpleEventPluginEvents.length; - i$jscomp$inline_1535++ + var i$jscomp$inline_1539 = 0; + i$jscomp$inline_1539 < simpleEventPluginEvents.length; + i$jscomp$inline_1539++ ) { - var eventName$jscomp$inline_1536 = - simpleEventPluginEvents[i$jscomp$inline_1535], - domEventName$jscomp$inline_1537 = - eventName$jscomp$inline_1536.toLowerCase(), - capitalizedEvent$jscomp$inline_1538 = - eventName$jscomp$inline_1536[0].toUpperCase() + - eventName$jscomp$inline_1536.slice(1); + var eventName$jscomp$inline_1540 = + simpleEventPluginEvents[i$jscomp$inline_1539], + domEventName$jscomp$inline_1541 = + eventName$jscomp$inline_1540.toLowerCase(), + capitalizedEvent$jscomp$inline_1542 = + eventName$jscomp$inline_1540[0].toUpperCase() + + eventName$jscomp$inline_1540.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1537, - "on" + capitalizedEvent$jscomp$inline_1538 + domEventName$jscomp$inline_1541, + "on" + capitalizedEvent$jscomp$inline_1542 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -16872,9 +16885,6 @@ function getEventPriority(domEventName) { return 32; } } -function defaultOnRecoverableError(error) { - reportGlobalError(error); -} function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } @@ -16934,8 +16944,8 @@ function isValidContainerLegacy(node) { " react-mount-point-unstable " !== node.nodeValue)) ); } -function noopOnRecoverableError() {} -function legacyCreateRootFromDOMContainer( +function noopOnRecoverableError$1() {} +function legacyCreateRootFromDOMContainer$1( container, initialChildren, parentComponent, @@ -16959,7 +16969,9 @@ function legacyCreateRootFromDOMContainer( !1, !1, "", - noopOnRecoverableError, + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, null, null ); @@ -16988,7 +17000,9 @@ function legacyCreateRootFromDOMContainer( !1, !1, "", - noopOnRecoverableError, + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, null, null ); @@ -17002,7 +17016,7 @@ function legacyCreateRootFromDOMContainer( }); return root$285; } -function legacyRenderSubtreeIntoContainer( +function legacyRenderSubtreeIntoContainer$1( parentComponent, children, container, @@ -17021,7 +17035,7 @@ function legacyRenderSubtreeIntoContainer( } updateContainer(children, root, parentComponent, callback); } else - root = legacyCreateRootFromDOMContainer( + root = legacyCreateRootFromDOMContainer$1( container, children, parentComponent, @@ -17065,17 +17079,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1751 = { +var devToolsConfig$jscomp$inline_1733 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-classic-8ed83df1", + version: "19.0.0-www-classic-18cf9401", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2143 = { - bundleType: devToolsConfig$jscomp$inline_1751.bundleType, - version: devToolsConfig$jscomp$inline_1751.version, - rendererPackageName: devToolsConfig$jscomp$inline_1751.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1751.rendererConfig, +var internals$jscomp$inline_2160 = { + bundleType: devToolsConfig$jscomp$inline_1733.bundleType, + version: devToolsConfig$jscomp$inline_1733.version, + rendererPackageName: devToolsConfig$jscomp$inline_1733.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1733.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17091,28 +17105,149 @@ var internals$jscomp$inline_2143 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1751.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1733.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-8ed83df1" + reconcilerVersion: "19.0.0-www-classic-18cf9401" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2144 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2161 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2144.isDisabled && - hook$jscomp$inline_2144.supportsFiber + !hook$jscomp$inline_2161.isDisabled && + hook$jscomp$inline_2161.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2144.inject( - internals$jscomp$inline_2143 + (rendererID = hook$jscomp$inline_2161.inject( + internals$jscomp$inline_2160 )), - (injectedHook = hook$jscomp$inline_2144); + (injectedHook = hook$jscomp$inline_2161); } catch (err) {} } +var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); +if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) + throw Error(formatProdErrorMessage(320)); +function wwwOnUncaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: null, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && reportGlobalError(error); +} +function wwwOnCaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: errorInfo.errorBoundary, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && defaultOnCaughtError(error); +} +function noopOnRecoverableError() {} +function legacyCreateRootFromDOMContainer( + container, + initialChildren, + parentComponent, + callback, + isHydrationContainer +) { + if (isHydrationContainer) { + if ("function" === typeof callback) { + var originalCallback = callback; + callback = function () { + var instance = getPublicRootInstance(root$287); + originalCallback.call(instance); + }; + } + var root$287 = createHydrationContainer( + initialChildren, + callback, + container, + 0, + null, + !1, + !1, + "", + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, + null, + null + ); + container._reactRootContainer = root$287; + container[internalContainerInstanceKey] = root$287.current; + listenToAllSupportedEvents( + 8 === container.nodeType ? container.parentNode : container + ); + flushSync$1(); + return root$287; + } + clearContainer(container); + if ("function" === typeof callback) { + var originalCallback$288 = callback; + callback = function () { + var instance = getPublicRootInstance(root$289); + originalCallback$288.call(instance); + }; + } + var root$289 = createFiberRoot( + container, + 0, + !1, + null, + null, + !1, + !1, + "", + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, + null, + null + ); + container._reactRootContainer = root$289; + container[internalContainerInstanceKey] = root$289.current; + listenToAllSupportedEvents( + 8 === container.nodeType ? container.parentNode : container + ); + flushSync$1(function () { + updateContainer(initialChildren, root$289, parentComponent, callback); + }); + return root$289; +} +function legacyRenderSubtreeIntoContainer( + parentComponent, + children, + container, + forceHydrate, + callback +) { + var maybeRoot = container._reactRootContainer; + if (maybeRoot) { + var root = maybeRoot; + if ("function" === typeof callback) { + var originalCallback = callback; + callback = function () { + var instance = getPublicRootInstance(root); + originalCallback.call(instance); + }; + } + updateContainer(children, root, parentComponent, callback); + } else + root = legacyCreateRootFromDOMContainer( + container, + children, + parentComponent, + callback, + forceHydrate + ); + return getPublicRootInstance(root); +} assign(Internals, { ReactBrowserEventEmitter: { isEnabled: function () { @@ -17128,10 +17263,16 @@ exports.createPortal = function (children, container) { return createPortal$1(children, container, null, key); }; exports.createRoot = function (container, options) { + options = assign( + { onUncaughtError: wwwOnUncaughtError, onCaughtError: wwwOnCaughtError }, + options + ); if (!isValidContainer(container)) throw Error(formatProdErrorMessage(299)); var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null; null !== options && @@ -17141,6 +17282,9 @@ exports.createRoot = function (container, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17154,6 +17298,8 @@ exports.createRoot = function (container, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -17183,10 +17329,16 @@ exports.flushSync = function (fn) { return flushSync$1(fn); }; exports.hydrateRoot = function (container, initialChildren, options) { + options = assign( + { onUncaughtError: wwwOnUncaughtError, onCaughtError: wwwOnCaughtError }, + options + ); if (!isValidContainer(container)) throw Error(formatProdErrorMessage(299)); var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null, formState = null; @@ -17197,6 +17349,9 @@ exports.hydrateRoot = function (container, initialChildren, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17211,6 +17366,8 @@ exports.hydrateRoot = function (container, initialChildren, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -17345,7 +17502,7 @@ exports.unmountComponentAtNode = function (container) { throw Error(formatProdErrorMessage(299)); return container._reactRootContainer ? (flushSync$1(function () { - legacyRenderSubtreeIntoContainer( + legacyRenderSubtreeIntoContainer$1( null, null, container, @@ -17399,7 +17556,7 @@ exports.unstable_renderSubtreeIntoContainer = function ( throw Error(formatProdErrorMessage(299)); if (null == parentComponent || void 0 === parentComponent._reactInternals) throw Error(formatProdErrorMessage(38)); - return legacyRenderSubtreeIntoContainer( + return legacyRenderSubtreeIntoContainer$1( parentComponent, element, containerNode, @@ -17418,4 +17575,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactCurrentDispatcher$2.current.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-classic-8ed83df1"; +exports.version = "19.0.0-www-classic-18cf9401"; diff --git a/compiled/facebook-www/ReactDOM-prod.modern.js b/compiled/facebook-www/ReactDOM-prod.modern.js index 6d51637f924cc..710c83eed5ed8 100644 --- a/compiled/facebook-www/ReactDOM-prod.modern.js +++ b/compiled/facebook-www/ReactDOM-prod.modern.js @@ -4717,9 +4717,6 @@ function createCapturedValueFromError(value, digest, stack) { digest: null != digest ? digest : null }; } -var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); -if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) - throw Error(formatProdErrorMessage(320)); var reportGlobalError = "function" === typeof reportError ? reportError @@ -4749,53 +4746,68 @@ var reportGlobalError = } console.error(error); }; -function logCapturedError(boundary, errorInfo) { +function defaultOnUncaughtError(error) { + reportGlobalError(error); +} +function defaultOnCaughtError(error) { + console.error(error); +} +function defaultOnRecoverableError(error) { + reportGlobalError(error); +} +function logUncaughtError(root, errorInfo) { try { - if ( - !1 !== - ReactFiberErrorDialogWWW.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) - ) { - var error = errorInfo.value; - 3 === boundary.tag ? reportGlobalError(error) : console.error(error); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(errorInfo.value, { componentStack: errorInfo.stack }); } catch (e) { setTimeout(function () { throw e; }); } } -function createRootErrorUpdate(fiber, errorInfo, lane) { +function logCaughtError(root, boundary, errorInfo) { + try { + var onCaughtError = root.onCaughtError; + onCaughtError(errorInfo.value, { + componentStack: errorInfo.stack, + errorBoundary: 1 === boundary.tag ? boundary.stateNode : null + }); + } catch (e) { + setTimeout(function () { + throw e; + }); + } +} +function createRootErrorUpdate(root, errorInfo, lane) { lane = createUpdate(lane); lane.tag = 3; lane.payload = { element: null }; lane.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return lane; } -function createClassErrorUpdate(fiber, errorInfo, lane) { +function createClassErrorUpdate(lane) { lane = createUpdate(lane); lane.tag = 3; + return lane; +} +function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error = errorInfo.value; - lane.payload = function () { + update.payload = function () { return getDerivedStateFromError(error); }; - lane.callback = function () { - logCapturedError(fiber, errorInfo); + update.callback = function () { + logCaughtError(root, fiber, errorInfo); }; } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && - (lane.callback = function () { - logCapturedError(fiber, errorInfo); + (update.callback = function () { + logCaughtError(root, fiber, errorInfo); "function" !== typeof getDerivedStateFromError && (null === legacyErrorBoundariesThatAlreadyFailed ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) @@ -4805,7 +4817,6 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { componentStack: null !== stack ? stack : "" }); }); - return lane; } function markSuspenseBoundaryShouldCapture( suspenseBoundary, @@ -4847,83 +4858,76 @@ function throwException( "object" === typeof value && "function" === typeof value.then ) { - if (enableLazyContextPropagation) { - var currentSourceFiber = sourceFiber.alternate; - null !== currentSourceFiber && - propagateParentContextChanges( - currentSourceFiber, - sourceFiber, - rootRenderLanes, - !0 - ); - } - currentSourceFiber = sourceFiber.tag; + var wakeable = value; + enableLazyContextPropagation && + ((value = sourceFiber.alternate), + null !== value && + propagateParentContextChanges(value, sourceFiber, rootRenderLanes, !0)); + value = sourceFiber.tag; 0 !== (sourceFiber.mode & 1) || - (0 !== currentSourceFiber && - 11 !== currentSourceFiber && - 15 !== currentSourceFiber) || - ((currentSourceFiber = sourceFiber.alternate) - ? ((sourceFiber.updateQueue = currentSourceFiber.updateQueue), - (sourceFiber.memoizedState = currentSourceFiber.memoizedState), - (sourceFiber.lanes = currentSourceFiber.lanes)) + (0 !== value && 11 !== value && 15 !== value) || + ((value = sourceFiber.alternate) + ? ((sourceFiber.updateQueue = value.updateQueue), + (sourceFiber.memoizedState = value.memoizedState), + (sourceFiber.lanes = value.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null))); - currentSourceFiber = suspenseHandlerStackCursor.current; - if (null !== currentSourceFiber) { - switch (currentSourceFiber.tag) { + value = suspenseHandlerStackCursor.current; + if (null !== value) { + switch (value.tag) { case 13: return ( sourceFiber.mode & 1 && (null === shellBoundary ? renderDidSuspendDelayIfPossible() - : null === currentSourceFiber.alternate && + : null === value.alternate && 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 3)), - (currentSourceFiber.flags &= -257), + (value.flags &= -257), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + value, returnFiber, sourceFiber, root, rootRenderLanes ), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber - ? (currentSourceFiber.updateQueue = new Set([value])) - : returnFiber.add(value), - currentSourceFiber.mode & 1 && - attachPingListener(root, value, rootRenderLanes)), + ? (value.updateQueue = new Set([wakeable])) + : returnFiber.add(wakeable), + value.mode & 1 && + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); case 22: - if (currentSourceFiber.mode & 1) + if (value.mode & 1) return ( - (currentSourceFiber.flags |= 65536), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + (value.flags |= 65536), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber ? ((returnFiber = { transitions: null, markerInstances: null, - retryQueue: new Set([value]) + retryQueue: new Set([wakeable]) }), - (currentSourceFiber.updateQueue = returnFiber)) + (value.updateQueue = returnFiber)) : ((sourceFiber = returnFiber.retryQueue), null === sourceFiber - ? (returnFiber.retryQueue = new Set([value])) - : sourceFiber.add(value)), - attachPingListener(root, value, rootRenderLanes)), + ? (returnFiber.retryQueue = new Set([wakeable])) + : sourceFiber.add(wakeable)), + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); } - throw Error(formatProdErrorMessage(435, currentSourceFiber.tag)); + throw Error(formatProdErrorMessage(435, value.tag)); } if (1 === root.tag) return ( - attachPingListener(root, value, rootRenderLanes), + attachPingListener(root, wakeable, rootRenderLanes), renderDidSuspendDelayIfPossible(), !1 ); @@ -4932,14 +4936,12 @@ function throwException( if ( isHydrating && sourceFiber.mode & 1 && - ((currentSourceFiber = suspenseHandlerStackCursor.current), - null !== currentSourceFiber) + ((wakeable = suspenseHandlerStackCursor.current), null !== wakeable) ) return ( - 0 === (currentSourceFiber.flags & 65536) && - (currentSourceFiber.flags |= 256), + 0 === (wakeable.flags & 65536) && (wakeable.flags |= 256), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + wakeable, returnFiber, sourceFiber, root, @@ -4948,57 +4950,58 @@ function throwException( queueHydrationError(createCapturedValueAtFiber(value, sourceFiber)), !1 ); - root = value = createCapturedValueAtFiber(value, sourceFiber); + wakeable = value = createCapturedValueAtFiber(value, sourceFiber); 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + ? (workInProgressRootConcurrentErrors = [wakeable]) + : workInProgressRootConcurrentErrors.push(wakeable); if (null === returnFiber) return !0; - root = returnFiber; + wakeable = returnFiber; do { - switch (root.tag) { + switch (wakeable.tag) { case 3: return ( - (root.flags |= 65536), + (root = value), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createRootErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (root = createRootErrorUpdate( + wakeable.stateNode, root, - value, rootRenderLanes )), - enqueueCapturedUpdate(root, rootRenderLanes), + enqueueCapturedUpdate(wakeable, root), !1 ); case 1: + returnFiber = value; + sourceFiber = wakeable.type; + var instance = wakeable.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.type), - (currentSourceFiber = root.stateNode), - 0 === (root.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + 0 === (wakeable.flags & 128) && + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) return ( - (root.flags |= 65536), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createClassErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (rootRenderLanes = createClassErrorUpdate(rootRenderLanes)), + initializeClassErrorUpdate( + rootRenderLanes, root, - returnFiber, - rootRenderLanes - )), - enqueueCapturedUpdate(root, rootRenderLanes), + wakeable, + returnFiber + ), + enqueueCapturedUpdate(wakeable, rootRenderLanes), !1 ); } - root = root.return; - } while (null !== root); + wakeable = wakeable.return; + } while (null !== wakeable); return !1; } function processTransitionCallbacks(pendingTransitions, endTime, callbacks) { @@ -11077,8 +11080,8 @@ function handleThrow(root, thrownValue) { workInProgressThrownValue = thrownValue; null === workInProgress && ((workInProgressRootExitStatus = 1), - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) )); } @@ -11349,8 +11352,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { ) ) { workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -11359,8 +11362,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { } catch (error) { if (null !== returnFiber) throw ((workInProgress = returnFiber), error); workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -11621,7 +11624,7 @@ function flushPassiveEffectsImpl() { } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 2); + sourceFiber = createRootErrorUpdate(rootFiber.stateNode, sourceFiber, 2); rootFiber = enqueueUpdate(rootFiber, sourceFiber, 2); null !== rootFiber && (markRootUpdated(rootFiber, 2), ensureRootIsScheduled(rootFiber)); @@ -11648,19 +11651,17 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - nearestMountedAncestor = enqueueUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 2), - ensureRootIsScheduled(nearestMountedAncestor)); + error = createClassErrorUpdate(2); + instance = enqueueUpdate(nearestMountedAncestor, error, 2); + null !== instance && + (initializeClassErrorUpdate( + error, + instance, + nearestMountedAncestor, + sourceFiber + ), + markRootUpdated(instance, 2), + ensureRootIsScheduled(instance)); break; } } @@ -12067,6 +12068,8 @@ function FiberRootNode( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -12098,6 +12101,8 @@ function FiberRootNode( this.entanglements = createLaneMap(0); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; this.pooledCache = null; this.pooledCacheLanes = 0; @@ -12123,6 +12128,8 @@ function createFiberRoot( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -12132,6 +12139,8 @@ function createFiberRoot( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -16494,9 +16503,6 @@ function insertStylesheetIntoRoot(root, resource) { resource.state.loading |= 4; } } -function defaultOnRecoverableError(error) { - reportGlobalError(error); -} function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } @@ -16581,17 +16587,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1710 = { +var devToolsConfig$jscomp$inline_1688 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-modern-97929618", + version: "19.0.0-www-modern-62bcede1", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2107 = { - bundleType: devToolsConfig$jscomp$inline_1710.bundleType, - version: devToolsConfig$jscomp$inline_1710.version, - rendererPackageName: devToolsConfig$jscomp$inline_1710.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1710.rendererConfig, +var internals$jscomp$inline_2114 = { + bundleType: devToolsConfig$jscomp$inline_1688.bundleType, + version: devToolsConfig$jscomp$inline_1688.version, + rendererPackageName: devToolsConfig$jscomp$inline_1688.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1688.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -16608,28 +16614,49 @@ var internals$jscomp$inline_2107 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1710.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1688.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-97929618" + reconcilerVersion: "19.0.0-www-modern-62bcede1" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2108 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2115 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2108.isDisabled && - hook$jscomp$inline_2108.supportsFiber + !hook$jscomp$inline_2115.isDisabled && + hook$jscomp$inline_2115.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2108.inject( - internals$jscomp$inline_2107 + (rendererID = hook$jscomp$inline_2115.inject( + internals$jscomp$inline_2114 )), - (injectedHook = hook$jscomp$inline_2108); + (injectedHook = hook$jscomp$inline_2115); } catch (err) {} } +var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); +if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) + throw Error(formatProdErrorMessage(320)); +function wwwOnUncaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: null, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && reportGlobalError(error); +} +function wwwOnCaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: errorInfo.errorBoundary, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && defaultOnCaughtError(error); +} exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; exports.createPortal = function (children, container) { var key = @@ -16638,10 +16665,16 @@ exports.createPortal = function (children, container) { return createPortal$1(children, container, null, key); }; exports.createRoot = function (container, options) { + options = assign( + { onUncaughtError: wwwOnUncaughtError, onCaughtError: wwwOnCaughtError }, + options + ); if (!isValidContainer(container)) throw Error(formatProdErrorMessage(299)); var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null; null !== options && @@ -16651,6 +16684,9 @@ exports.createRoot = function (container, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -16664,6 +16700,8 @@ exports.createRoot = function (container, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -16678,10 +16716,16 @@ exports.flushSync = function (fn) { return flushSync$1(fn); }; exports.hydrateRoot = function (container, initialChildren, options) { + options = assign( + { onUncaughtError: wwwOnUncaughtError, onCaughtError: wwwOnCaughtError }, + options + ); if (!isValidContainer(container)) throw Error(formatProdErrorMessage(299)); var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null, formState = null; @@ -16692,6 +16736,9 @@ exports.hydrateRoot = function (container, initialChildren, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -16706,6 +16753,8 @@ exports.hydrateRoot = function (container, initialChildren, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -16874,4 +16923,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactCurrentDispatcher$2.current.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-modern-97929618"; +exports.version = "19.0.0-www-modern-62bcede1"; diff --git a/compiled/facebook-www/ReactDOM-profiling.classic.js b/compiled/facebook-www/ReactDOM-profiling.classic.js index 03bcb9daa03c7..4a3390ff4db4c 100644 --- a/compiled/facebook-www/ReactDOM-profiling.classic.js +++ b/compiled/facebook-www/ReactDOM-profiling.classic.js @@ -5046,9 +5046,6 @@ function createCapturedValueFromError(value, digest, stack) { digest: null != digest ? digest : null }; } -var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); -if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) - throw Error(formatProdErrorMessage(320)); var reportGlobalError = "function" === typeof reportError ? reportError @@ -5078,53 +5075,68 @@ var reportGlobalError = } console.error(error); }; -function logCapturedError(boundary, errorInfo) { +function defaultOnUncaughtError(error) { + reportGlobalError(error); +} +function defaultOnCaughtError(error) { + console.error(error); +} +function defaultOnRecoverableError(error) { + reportGlobalError(error); +} +function logUncaughtError(root, errorInfo) { try { - if ( - !1 !== - ReactFiberErrorDialogWWW.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) - ) { - var error = errorInfo.value; - 3 === boundary.tag ? reportGlobalError(error) : console.error(error); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(errorInfo.value, { componentStack: errorInfo.stack }); } catch (e) { setTimeout(function () { throw e; }); } } -function createRootErrorUpdate(fiber, errorInfo, lane) { +function logCaughtError(root, boundary, errorInfo) { + try { + var onCaughtError = root.onCaughtError; + onCaughtError(errorInfo.value, { + componentStack: errorInfo.stack, + errorBoundary: 1 === boundary.tag ? boundary.stateNode : null + }); + } catch (e) { + setTimeout(function () { + throw e; + }); + } +} +function createRootErrorUpdate(root, errorInfo, lane) { lane = createUpdate(lane); lane.tag = 3; lane.payload = { element: null }; lane.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return lane; } -function createClassErrorUpdate(fiber, errorInfo, lane) { +function createClassErrorUpdate(lane) { lane = createUpdate(lane); lane.tag = 3; + return lane; +} +function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error = errorInfo.value; - lane.payload = function () { + update.payload = function () { return getDerivedStateFromError(error); }; - lane.callback = function () { - logCapturedError(fiber, errorInfo); + update.callback = function () { + logCaughtError(root, fiber, errorInfo); }; } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && - (lane.callback = function () { - logCapturedError(fiber, errorInfo); + (update.callback = function () { + logCaughtError(root, fiber, errorInfo); "function" !== typeof getDerivedStateFromError && (null === legacyErrorBoundariesThatAlreadyFailed ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) @@ -5134,7 +5146,6 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { componentStack: null !== stack ? stack : "" }); }); - return lane; } function markSuspenseBoundaryShouldCapture( suspenseBoundary, @@ -5177,83 +5188,76 @@ function throwException( "object" === typeof value && "function" === typeof value.then ) { - if (enableLazyContextPropagation) { - var currentSourceFiber = sourceFiber.alternate; - null !== currentSourceFiber && - propagateParentContextChanges( - currentSourceFiber, - sourceFiber, - rootRenderLanes, - !0 - ); - } - currentSourceFiber = sourceFiber.tag; + var wakeable = value; + enableLazyContextPropagation && + ((value = sourceFiber.alternate), + null !== value && + propagateParentContextChanges(value, sourceFiber, rootRenderLanes, !0)); + value = sourceFiber.tag; 0 !== (sourceFiber.mode & 1) || - (0 !== currentSourceFiber && - 11 !== currentSourceFiber && - 15 !== currentSourceFiber) || - ((currentSourceFiber = sourceFiber.alternate) - ? ((sourceFiber.updateQueue = currentSourceFiber.updateQueue), - (sourceFiber.memoizedState = currentSourceFiber.memoizedState), - (sourceFiber.lanes = currentSourceFiber.lanes)) + (0 !== value && 11 !== value && 15 !== value) || + ((value = sourceFiber.alternate) + ? ((sourceFiber.updateQueue = value.updateQueue), + (sourceFiber.memoizedState = value.memoizedState), + (sourceFiber.lanes = value.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null))); - currentSourceFiber = suspenseHandlerStackCursor.current; - if (null !== currentSourceFiber) { - switch (currentSourceFiber.tag) { + value = suspenseHandlerStackCursor.current; + if (null !== value) { + switch (value.tag) { case 13: return ( sourceFiber.mode & 1 && (null === shellBoundary ? renderDidSuspendDelayIfPossible() - : null === currentSourceFiber.alternate && + : null === value.alternate && 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 3)), - (currentSourceFiber.flags &= -257), + (value.flags &= -257), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + value, returnFiber, sourceFiber, root, rootRenderLanes ), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber - ? (currentSourceFiber.updateQueue = new Set([value])) - : returnFiber.add(value), - currentSourceFiber.mode & 1 && - attachPingListener(root, value, rootRenderLanes)), + ? (value.updateQueue = new Set([wakeable])) + : returnFiber.add(wakeable), + value.mode & 1 && + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); case 22: - if (currentSourceFiber.mode & 1) + if (value.mode & 1) return ( - (currentSourceFiber.flags |= 65536), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + (value.flags |= 65536), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber ? ((returnFiber = { transitions: null, markerInstances: null, - retryQueue: new Set([value]) + retryQueue: new Set([wakeable]) }), - (currentSourceFiber.updateQueue = returnFiber)) + (value.updateQueue = returnFiber)) : ((sourceFiber = returnFiber.retryQueue), null === sourceFiber - ? (returnFiber.retryQueue = new Set([value])) - : sourceFiber.add(value)), - attachPingListener(root, value, rootRenderLanes)), + ? (returnFiber.retryQueue = new Set([wakeable])) + : sourceFiber.add(wakeable)), + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); } - throw Error(formatProdErrorMessage(435, currentSourceFiber.tag)); + throw Error(formatProdErrorMessage(435, value.tag)); } if (1 === root.tag) return ( - attachPingListener(root, value, rootRenderLanes), + attachPingListener(root, wakeable, rootRenderLanes), renderDidSuspendDelayIfPossible(), !1 ); @@ -5262,14 +5266,12 @@ function throwException( if ( isHydrating && sourceFiber.mode & 1 && - ((currentSourceFiber = suspenseHandlerStackCursor.current), - null !== currentSourceFiber) + ((wakeable = suspenseHandlerStackCursor.current), null !== wakeable) ) return ( - 0 === (currentSourceFiber.flags & 65536) && - (currentSourceFiber.flags |= 256), + 0 === (wakeable.flags & 65536) && (wakeable.flags |= 256), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + wakeable, returnFiber, sourceFiber, root, @@ -5278,57 +5280,58 @@ function throwException( queueHydrationError(createCapturedValueAtFiber(value, sourceFiber)), !1 ); - root = value = createCapturedValueAtFiber(value, sourceFiber); + wakeable = value = createCapturedValueAtFiber(value, sourceFiber); 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + ? (workInProgressRootConcurrentErrors = [wakeable]) + : workInProgressRootConcurrentErrors.push(wakeable); if (null === returnFiber) return !0; - root = returnFiber; + wakeable = returnFiber; do { - switch (root.tag) { + switch (wakeable.tag) { case 3: return ( - (root.flags |= 65536), + (root = value), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createRootErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (root = createRootErrorUpdate( + wakeable.stateNode, root, - value, rootRenderLanes )), - enqueueCapturedUpdate(root, rootRenderLanes), + enqueueCapturedUpdate(wakeable, root), !1 ); case 1: + returnFiber = value; + sourceFiber = wakeable.type; + var instance = wakeable.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.type), - (currentSourceFiber = root.stateNode), - 0 === (root.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + 0 === (wakeable.flags & 128) && + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) return ( - (root.flags |= 65536), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createClassErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (rootRenderLanes = createClassErrorUpdate(rootRenderLanes)), + initializeClassErrorUpdate( + rootRenderLanes, root, - returnFiber, - rootRenderLanes - )), - enqueueCapturedUpdate(root, rootRenderLanes), + wakeable, + returnFiber + ), + enqueueCapturedUpdate(wakeable, rootRenderLanes), !1 ); } - root = root.return; - } while (null !== root); + wakeable = wakeable.return; + } while (null !== wakeable); return !1; } function processTransitionCallbacks(pendingTransitions, endTime, callbacks) { @@ -11862,8 +11865,8 @@ function handleThrow(root, thrownValue) { var erroredWork = workInProgress; if (null === erroredWork) (workInProgressRootExitStatus = 1), - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); else if ( @@ -12206,8 +12209,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { ) ) { workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -12216,8 +12219,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { } catch (error) { if (null !== returnFiber) throw ((workInProgress = returnFiber), error); workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -12533,7 +12536,7 @@ function flushPassiveEffectsImpl() { } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 2); + sourceFiber = createRootErrorUpdate(rootFiber.stateNode, sourceFiber, 2); rootFiber = enqueueUpdate(rootFiber, sourceFiber, 2); null !== rootFiber && (markRootUpdated(rootFiber, 2), ensureRootIsScheduled(rootFiber)); @@ -12560,19 +12563,17 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - nearestMountedAncestor = enqueueUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 2), - ensureRootIsScheduled(nearestMountedAncestor)); + error = createClassErrorUpdate(2); + instance = enqueueUpdate(nearestMountedAncestor, error, 2); + null !== instance && + (initializeClassErrorUpdate( + error, + instance, + nearestMountedAncestor, + sourceFiber + ), + markRootUpdated(instance, 2), + ensureRootIsScheduled(instance)); break; } } @@ -12998,6 +12999,8 @@ function FiberRootNode( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -13029,6 +13032,8 @@ function FiberRootNode( this.entanglements = createLaneMap(0); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; this.pooledCache = null; this.pooledCacheLanes = 0; @@ -13058,6 +13063,8 @@ function createFiberRoot( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -13067,6 +13074,8 @@ function createFiberRoot( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -13152,6 +13161,8 @@ function createHydrationContainer( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -13165,6 +13176,8 @@ function createHydrationContainer( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -13788,19 +13801,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$364; + var JSCompiler_inline_result$jscomp$368; if (canUseDOM) { - var isSupported$jscomp$inline_1580 = "oninput" in document; - if (!isSupported$jscomp$inline_1580) { - var element$jscomp$inline_1581 = document.createElement("div"); - element$jscomp$inline_1581.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1580 = - "function" === typeof element$jscomp$inline_1581.oninput; + var isSupported$jscomp$inline_1584 = "oninput" in document; + if (!isSupported$jscomp$inline_1584) { + var element$jscomp$inline_1585 = document.createElement("div"); + element$jscomp$inline_1585.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1584 = + "function" === typeof element$jscomp$inline_1585.oninput; } - JSCompiler_inline_result$jscomp$364 = isSupported$jscomp$inline_1580; - } else JSCompiler_inline_result$jscomp$364 = !1; + JSCompiler_inline_result$jscomp$368 = isSupported$jscomp$inline_1584; + } else JSCompiler_inline_result$jscomp$368 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$364 && + JSCompiler_inline_result$jscomp$368 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -14172,20 +14185,20 @@ function extractEvents$1( } } for ( - var i$jscomp$inline_1621 = 0; - i$jscomp$inline_1621 < simpleEventPluginEvents.length; - i$jscomp$inline_1621++ + var i$jscomp$inline_1625 = 0; + i$jscomp$inline_1625 < simpleEventPluginEvents.length; + i$jscomp$inline_1625++ ) { - var eventName$jscomp$inline_1622 = - simpleEventPluginEvents[i$jscomp$inline_1621], - domEventName$jscomp$inline_1623 = - eventName$jscomp$inline_1622.toLowerCase(), - capitalizedEvent$jscomp$inline_1624 = - eventName$jscomp$inline_1622[0].toUpperCase() + - eventName$jscomp$inline_1622.slice(1); + var eventName$jscomp$inline_1626 = + simpleEventPluginEvents[i$jscomp$inline_1625], + domEventName$jscomp$inline_1627 = + eventName$jscomp$inline_1626.toLowerCase(), + capitalizedEvent$jscomp$inline_1628 = + eventName$jscomp$inline_1626[0].toUpperCase() + + eventName$jscomp$inline_1626.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1623, - "on" + capitalizedEvent$jscomp$inline_1624 + domEventName$jscomp$inline_1627, + "on" + capitalizedEvent$jscomp$inline_1628 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -17622,9 +17635,6 @@ function getEventPriority(domEventName) { return 32; } } -function defaultOnRecoverableError(error) { - reportGlobalError(error); -} function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } @@ -17684,8 +17694,8 @@ function isValidContainerLegacy(node) { " react-mount-point-unstable " !== node.nodeValue)) ); } -function noopOnRecoverableError() {} -function legacyCreateRootFromDOMContainer( +function noopOnRecoverableError$1() {} +function legacyCreateRootFromDOMContainer$1( container, initialChildren, parentComponent, @@ -17709,7 +17719,9 @@ function legacyCreateRootFromDOMContainer( !1, !1, "", - noopOnRecoverableError, + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, null, null ); @@ -17738,7 +17750,9 @@ function legacyCreateRootFromDOMContainer( !1, !1, "", - noopOnRecoverableError, + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, null, null ); @@ -17752,7 +17766,7 @@ function legacyCreateRootFromDOMContainer( }); return root$306; } -function legacyRenderSubtreeIntoContainer( +function legacyRenderSubtreeIntoContainer$1( parentComponent, children, container, @@ -17771,7 +17785,7 @@ function legacyRenderSubtreeIntoContainer( } updateContainer(children, root, parentComponent, callback); } else - root = legacyCreateRootFromDOMContainer( + root = legacyCreateRootFromDOMContainer$1( container, children, parentComponent, @@ -17815,10 +17829,10 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1837 = { +var devToolsConfig$jscomp$inline_1819 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-classic-0d0cff6f", + version: "19.0.0-www-classic-a81f7a5a", rendererPackageName: "react-dom" }; (function (internals) { @@ -17836,10 +17850,10 @@ var devToolsConfig$jscomp$inline_1837 = { } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1837.bundleType, - version: devToolsConfig$jscomp$inline_1837.version, - rendererPackageName: devToolsConfig$jscomp$inline_1837.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1837.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1819.bundleType, + version: devToolsConfig$jscomp$inline_1819.version, + rendererPackageName: devToolsConfig$jscomp$inline_1819.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1819.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17855,15 +17869,136 @@ var devToolsConfig$jscomp$inline_1837 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1837.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1819.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-0d0cff6f" + reconcilerVersion: "19.0.0-www-classic-a81f7a5a" }); +var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); +if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) + throw Error(formatProdErrorMessage(320)); +function wwwOnUncaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: null, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && reportGlobalError(error); +} +function wwwOnCaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: errorInfo.errorBoundary, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && defaultOnCaughtError(error); +} +function noopOnRecoverableError() {} +function legacyCreateRootFromDOMContainer( + container, + initialChildren, + parentComponent, + callback, + isHydrationContainer +) { + if (isHydrationContainer) { + if ("function" === typeof callback) { + var originalCallback = callback; + callback = function () { + var instance = getPublicRootInstance(root$308); + originalCallback.call(instance); + }; + } + var root$308 = createHydrationContainer( + initialChildren, + callback, + container, + 0, + null, + !1, + !1, + "", + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, + null, + null + ); + container._reactRootContainer = root$308; + container[internalContainerInstanceKey] = root$308.current; + listenToAllSupportedEvents( + 8 === container.nodeType ? container.parentNode : container + ); + flushSync$1(); + return root$308; + } + clearContainer(container); + if ("function" === typeof callback) { + var originalCallback$309 = callback; + callback = function () { + var instance = getPublicRootInstance(root$310); + originalCallback$309.call(instance); + }; + } + var root$310 = createFiberRoot( + container, + 0, + !1, + null, + null, + !1, + !1, + "", + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, + null, + null + ); + container._reactRootContainer = root$310; + container[internalContainerInstanceKey] = root$310.current; + listenToAllSupportedEvents( + 8 === container.nodeType ? container.parentNode : container + ); + flushSync$1(function () { + updateContainer(initialChildren, root$310, parentComponent, callback); + }); + return root$310; +} +function legacyRenderSubtreeIntoContainer( + parentComponent, + children, + container, + forceHydrate, + callback +) { + var maybeRoot = container._reactRootContainer; + if (maybeRoot) { + var root = maybeRoot; + if ("function" === typeof callback) { + var originalCallback = callback; + callback = function () { + var instance = getPublicRootInstance(root); + originalCallback.call(instance); + }; + } + updateContainer(children, root, parentComponent, callback); + } else + root = legacyCreateRootFromDOMContainer( + container, + children, + parentComponent, + callback, + forceHydrate + ); + return getPublicRootInstance(root); +} assign(Internals, { ReactBrowserEventEmitter: { isEnabled: function () { @@ -17879,10 +18014,16 @@ exports.createPortal = function (children, container) { return createPortal$1(children, container, null, key); }; exports.createRoot = function (container, options) { + options = assign( + { onUncaughtError: wwwOnUncaughtError, onCaughtError: wwwOnCaughtError }, + options + ); if (!isValidContainer(container)) throw Error(formatProdErrorMessage(299)); var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null; null !== options && @@ -17892,6 +18033,9 @@ exports.createRoot = function (container, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17905,6 +18049,8 @@ exports.createRoot = function (container, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -17934,10 +18080,16 @@ exports.flushSync = function (fn) { return flushSync$1(fn); }; exports.hydrateRoot = function (container, initialChildren, options) { + options = assign( + { onUncaughtError: wwwOnUncaughtError, onCaughtError: wwwOnCaughtError }, + options + ); if (!isValidContainer(container)) throw Error(formatProdErrorMessage(299)); var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null, formState = null; @@ -17948,6 +18100,9 @@ exports.hydrateRoot = function (container, initialChildren, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17962,6 +18117,8 @@ exports.hydrateRoot = function (container, initialChildren, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -18096,7 +18253,7 @@ exports.unmountComponentAtNode = function (container) { throw Error(formatProdErrorMessage(299)); return container._reactRootContainer ? (flushSync$1(function () { - legacyRenderSubtreeIntoContainer( + legacyRenderSubtreeIntoContainer$1( null, null, container, @@ -18150,7 +18307,7 @@ exports.unstable_renderSubtreeIntoContainer = function ( throw Error(formatProdErrorMessage(299)); if (null == parentComponent || void 0 === parentComponent._reactInternals) throw Error(formatProdErrorMessage(38)); - return legacyRenderSubtreeIntoContainer( + return legacyRenderSubtreeIntoContainer$1( parentComponent, element, containerNode, @@ -18169,7 +18326,7 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactCurrentDispatcher$2.current.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-classic-0d0cff6f"; +exports.version = "19.0.0-www-classic-a81f7a5a"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled/facebook-www/ReactDOM-profiling.modern.js b/compiled/facebook-www/ReactDOM-profiling.modern.js index 55d63b87354ec..75c2340b76fee 100644 --- a/compiled/facebook-www/ReactDOM-profiling.modern.js +++ b/compiled/facebook-www/ReactDOM-profiling.modern.js @@ -4925,9 +4925,6 @@ function createCapturedValueFromError(value, digest, stack) { digest: null != digest ? digest : null }; } -var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); -if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) - throw Error(formatProdErrorMessage(320)); var reportGlobalError = "function" === typeof reportError ? reportError @@ -4957,53 +4954,68 @@ var reportGlobalError = } console.error(error); }; -function logCapturedError(boundary, errorInfo) { +function defaultOnUncaughtError(error) { + reportGlobalError(error); +} +function defaultOnCaughtError(error) { + console.error(error); +} +function defaultOnRecoverableError(error) { + reportGlobalError(error); +} +function logUncaughtError(root, errorInfo) { try { - if ( - !1 !== - ReactFiberErrorDialogWWW.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) - ) { - var error = errorInfo.value; - 3 === boundary.tag ? reportGlobalError(error) : console.error(error); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(errorInfo.value, { componentStack: errorInfo.stack }); } catch (e) { setTimeout(function () { throw e; }); } } -function createRootErrorUpdate(fiber, errorInfo, lane) { +function logCaughtError(root, boundary, errorInfo) { + try { + var onCaughtError = root.onCaughtError; + onCaughtError(errorInfo.value, { + componentStack: errorInfo.stack, + errorBoundary: 1 === boundary.tag ? boundary.stateNode : null + }); + } catch (e) { + setTimeout(function () { + throw e; + }); + } +} +function createRootErrorUpdate(root, errorInfo, lane) { lane = createUpdate(lane); lane.tag = 3; lane.payload = { element: null }; lane.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return lane; } -function createClassErrorUpdate(fiber, errorInfo, lane) { +function createClassErrorUpdate(lane) { lane = createUpdate(lane); lane.tag = 3; + return lane; +} +function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error = errorInfo.value; - lane.payload = function () { + update.payload = function () { return getDerivedStateFromError(error); }; - lane.callback = function () { - logCapturedError(fiber, errorInfo); + update.callback = function () { + logCaughtError(root, fiber, errorInfo); }; } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && - (lane.callback = function () { - logCapturedError(fiber, errorInfo); + (update.callback = function () { + logCaughtError(root, fiber, errorInfo); "function" !== typeof getDerivedStateFromError && (null === legacyErrorBoundariesThatAlreadyFailed ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) @@ -5013,7 +5025,6 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { componentStack: null !== stack ? stack : "" }); }); - return lane; } function markSuspenseBoundaryShouldCapture( suspenseBoundary, @@ -5056,83 +5067,76 @@ function throwException( "object" === typeof value && "function" === typeof value.then ) { - if (enableLazyContextPropagation) { - var currentSourceFiber = sourceFiber.alternate; - null !== currentSourceFiber && - propagateParentContextChanges( - currentSourceFiber, - sourceFiber, - rootRenderLanes, - !0 - ); - } - currentSourceFiber = sourceFiber.tag; + var wakeable = value; + enableLazyContextPropagation && + ((value = sourceFiber.alternate), + null !== value && + propagateParentContextChanges(value, sourceFiber, rootRenderLanes, !0)); + value = sourceFiber.tag; 0 !== (sourceFiber.mode & 1) || - (0 !== currentSourceFiber && - 11 !== currentSourceFiber && - 15 !== currentSourceFiber) || - ((currentSourceFiber = sourceFiber.alternate) - ? ((sourceFiber.updateQueue = currentSourceFiber.updateQueue), - (sourceFiber.memoizedState = currentSourceFiber.memoizedState), - (sourceFiber.lanes = currentSourceFiber.lanes)) + (0 !== value && 11 !== value && 15 !== value) || + ((value = sourceFiber.alternate) + ? ((sourceFiber.updateQueue = value.updateQueue), + (sourceFiber.memoizedState = value.memoizedState), + (sourceFiber.lanes = value.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null))); - currentSourceFiber = suspenseHandlerStackCursor.current; - if (null !== currentSourceFiber) { - switch (currentSourceFiber.tag) { + value = suspenseHandlerStackCursor.current; + if (null !== value) { + switch (value.tag) { case 13: return ( sourceFiber.mode & 1 && (null === shellBoundary ? renderDidSuspendDelayIfPossible() - : null === currentSourceFiber.alternate && + : null === value.alternate && 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 3)), - (currentSourceFiber.flags &= -257), + (value.flags &= -257), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + value, returnFiber, sourceFiber, root, rootRenderLanes ), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber - ? (currentSourceFiber.updateQueue = new Set([value])) - : returnFiber.add(value), - currentSourceFiber.mode & 1 && - attachPingListener(root, value, rootRenderLanes)), + ? (value.updateQueue = new Set([wakeable])) + : returnFiber.add(wakeable), + value.mode & 1 && + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); case 22: - if (currentSourceFiber.mode & 1) + if (value.mode & 1) return ( - (currentSourceFiber.flags |= 65536), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + (value.flags |= 65536), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber ? ((returnFiber = { transitions: null, markerInstances: null, - retryQueue: new Set([value]) + retryQueue: new Set([wakeable]) }), - (currentSourceFiber.updateQueue = returnFiber)) + (value.updateQueue = returnFiber)) : ((sourceFiber = returnFiber.retryQueue), null === sourceFiber - ? (returnFiber.retryQueue = new Set([value])) - : sourceFiber.add(value)), - attachPingListener(root, value, rootRenderLanes)), + ? (returnFiber.retryQueue = new Set([wakeable])) + : sourceFiber.add(wakeable)), + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); } - throw Error(formatProdErrorMessage(435, currentSourceFiber.tag)); + throw Error(formatProdErrorMessage(435, value.tag)); } if (1 === root.tag) return ( - attachPingListener(root, value, rootRenderLanes), + attachPingListener(root, wakeable, rootRenderLanes), renderDidSuspendDelayIfPossible(), !1 ); @@ -5141,14 +5145,12 @@ function throwException( if ( isHydrating && sourceFiber.mode & 1 && - ((currentSourceFiber = suspenseHandlerStackCursor.current), - null !== currentSourceFiber) + ((wakeable = suspenseHandlerStackCursor.current), null !== wakeable) ) return ( - 0 === (currentSourceFiber.flags & 65536) && - (currentSourceFiber.flags |= 256), + 0 === (wakeable.flags & 65536) && (wakeable.flags |= 256), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + wakeable, returnFiber, sourceFiber, root, @@ -5157,57 +5159,58 @@ function throwException( queueHydrationError(createCapturedValueAtFiber(value, sourceFiber)), !1 ); - root = value = createCapturedValueAtFiber(value, sourceFiber); + wakeable = value = createCapturedValueAtFiber(value, sourceFiber); 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + ? (workInProgressRootConcurrentErrors = [wakeable]) + : workInProgressRootConcurrentErrors.push(wakeable); if (null === returnFiber) return !0; - root = returnFiber; + wakeable = returnFiber; do { - switch (root.tag) { + switch (wakeable.tag) { case 3: return ( - (root.flags |= 65536), + (root = value), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createRootErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (root = createRootErrorUpdate( + wakeable.stateNode, root, - value, rootRenderLanes )), - enqueueCapturedUpdate(root, rootRenderLanes), + enqueueCapturedUpdate(wakeable, root), !1 ); case 1: + returnFiber = value; + sourceFiber = wakeable.type; + var instance = wakeable.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.type), - (currentSourceFiber = root.stateNode), - 0 === (root.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + 0 === (wakeable.flags & 128) && + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) return ( - (root.flags |= 65536), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createClassErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (rootRenderLanes = createClassErrorUpdate(rootRenderLanes)), + initializeClassErrorUpdate( + rootRenderLanes, root, - returnFiber, - rootRenderLanes - )), - enqueueCapturedUpdate(root, rootRenderLanes), + wakeable, + returnFiber + ), + enqueueCapturedUpdate(wakeable, rootRenderLanes), !1 ); } - root = root.return; - } while (null !== root); + wakeable = wakeable.return; + } while (null !== wakeable); return !1; } function processTransitionCallbacks(pendingTransitions, endTime, callbacks) { @@ -11669,8 +11672,8 @@ function handleThrow(root, thrownValue) { var erroredWork = workInProgress; if (null === erroredWork) (workInProgressRootExitStatus = 1), - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); else if ( @@ -12009,8 +12012,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { ) ) { workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -12019,8 +12022,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { } catch (error) { if (null !== returnFiber) throw ((workInProgress = returnFiber), error); workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -12336,7 +12339,7 @@ function flushPassiveEffectsImpl() { } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 2); + sourceFiber = createRootErrorUpdate(rootFiber.stateNode, sourceFiber, 2); rootFiber = enqueueUpdate(rootFiber, sourceFiber, 2); null !== rootFiber && (markRootUpdated(rootFiber, 2), ensureRootIsScheduled(rootFiber)); @@ -12363,19 +12366,17 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - nearestMountedAncestor = enqueueUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 2), - ensureRootIsScheduled(nearestMountedAncestor)); + error = createClassErrorUpdate(2); + instance = enqueueUpdate(nearestMountedAncestor, error, 2); + null !== instance && + (initializeClassErrorUpdate( + error, + instance, + nearestMountedAncestor, + sourceFiber + ), + markRootUpdated(instance, 2), + ensureRootIsScheduled(instance)); break; } } @@ -12801,6 +12802,8 @@ function FiberRootNode( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -12832,6 +12835,8 @@ function FiberRootNode( this.entanglements = createLaneMap(0); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; this.pooledCache = null; this.pooledCacheLanes = 0; @@ -12861,6 +12866,8 @@ function createFiberRoot( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -12870,6 +12877,8 @@ function createFiberRoot( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -17238,9 +17247,6 @@ function insertStylesheetIntoRoot(root, resource) { resource.state.loading |= 4; } } -function defaultOnRecoverableError(error) { - reportGlobalError(error); -} function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } @@ -17325,10 +17331,10 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1796 = { +var devToolsConfig$jscomp$inline_1774 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-modern-599b6b62", + version: "19.0.0-www-modern-a33108b9", rendererPackageName: "react-dom" }; (function (internals) { @@ -17346,10 +17352,10 @@ var devToolsConfig$jscomp$inline_1796 = { } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1796.bundleType, - version: devToolsConfig$jscomp$inline_1796.version, - rendererPackageName: devToolsConfig$jscomp$inline_1796.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1796.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1774.bundleType, + version: devToolsConfig$jscomp$inline_1774.version, + rendererPackageName: devToolsConfig$jscomp$inline_1774.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1774.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17366,15 +17372,36 @@ var devToolsConfig$jscomp$inline_1796 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1796.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1774.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-599b6b62" + reconcilerVersion: "19.0.0-www-modern-a33108b9" }); +var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); +if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) + throw Error(formatProdErrorMessage(320)); +function wwwOnUncaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: null, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && reportGlobalError(error); +} +function wwwOnCaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: errorInfo.errorBoundary, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && defaultOnCaughtError(error); +} exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; exports.createPortal = function (children, container) { var key = @@ -17383,10 +17410,16 @@ exports.createPortal = function (children, container) { return createPortal$1(children, container, null, key); }; exports.createRoot = function (container, options) { + options = assign( + { onUncaughtError: wwwOnUncaughtError, onCaughtError: wwwOnCaughtError }, + options + ); if (!isValidContainer(container)) throw Error(formatProdErrorMessage(299)); var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null; null !== options && @@ -17396,6 +17429,9 @@ exports.createRoot = function (container, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17409,6 +17445,8 @@ exports.createRoot = function (container, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -17423,10 +17461,16 @@ exports.flushSync = function (fn) { return flushSync$1(fn); }; exports.hydrateRoot = function (container, initialChildren, options) { + options = assign( + { onUncaughtError: wwwOnUncaughtError, onCaughtError: wwwOnCaughtError }, + options + ); if (!isValidContainer(container)) throw Error(formatProdErrorMessage(299)); var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null, formState = null; @@ -17437,6 +17481,9 @@ exports.hydrateRoot = function (container, initialChildren, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17451,6 +17498,8 @@ exports.hydrateRoot = function (container, initialChildren, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -17619,7 +17668,7 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactCurrentDispatcher$2.current.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-modern-599b6b62"; +exports.version = "19.0.0-www-modern-a33108b9"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled/facebook-www/ReactDOMTesting-dev.classic.js b/compiled/facebook-www/ReactDOMTesting-dev.classic.js index e2c0d8c161fa8..7bff69b2ac07d 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.classic.js @@ -18238,7 +18238,7 @@ if (__DEV__) { Object.freeze(fakeInternalInstance); } - function warnOnInvalidCallback$1(callback) { + function warnOnInvalidCallback$2(callback) { { if (callback === null || typeof callback === "function") { return; @@ -18325,7 +18325,7 @@ if (__DEV__) { if (callback !== undefined && callback !== null) { { - warnOnInvalidCallback$1(callback); + warnOnInvalidCallback$2(callback); } update.callback = callback; @@ -18360,7 +18360,7 @@ if (__DEV__) { if (callback !== undefined && callback !== null) { { - warnOnInvalidCallback$1(callback); + warnOnInvalidCallback$2(callback); } update.callback = callback; @@ -18395,7 +18395,7 @@ if (__DEV__) { if (callback !== undefined && callback !== null) { { - warnOnInvalidCallback$1(callback); + warnOnInvalidCallback$2(callback); } update.callback = callback; @@ -19426,26 +19426,6 @@ if (__DEV__) { }; } - var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); - - if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { - throw new Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); - } - - function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; - return ReactFiberErrorDialogWWW.showErrorDialog(capturedError); - } - var reportGlobalError = typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, ? // emulating an uncaught JavaScript error. @@ -19485,86 +19465,111 @@ if (__DEV__) { console["error"](error); }; - var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; - function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API - if (logError === false) { - return; + var componentName = null; + var errorBoundaryName = null; + function defaultOnUncaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // For uncaught root errors we report them as uncaught to the browser's + // onerror callback. This won't have component stacks and the error addendum. + // So we add those into a separate console.warn. + reportGlobalError(error); + + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "An error occurred in the <" + componentName + "> component:" + : "An error occurred in one of your React components:"; + console["warn"]( + "%s\n%s\n\n%s", + componentNameMessage, + componentStack || "", + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." + ); + } + } + function defaultOnCaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // Caught by error boundary + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; // In development, we provide our own message which includes the component stack + // in addition to the error. + // Don't transform to our wrapper + + console["error"]( + "%o\n\n%s\n%s\n\n%s", + error, + componentNameMessage, + componentStack, + "React will try to recreate this component tree from scratch " + + ("using the error boundary you provided, " + + (errorBoundaryName || "Anonymous") + + ".") + ); + } + } + function defaultOnRecoverableError(error, errorInfo) { + reportGlobalError(error); + } + function logUncaughtError(root, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = null; } var error = errorInfo.value; - if (boundary.tag === HostRoot) { - if (true && ReactCurrentActQueue$2.current !== null) { - // For uncaught errors inside act, we track them on the act and then - // rethrow them into the test. - ReactCurrentActQueue$2.thrownErrors.push(error); - return; - } // For uncaught root errors we report them as uncaught to the browser's - // onerror callback. This won't have component stacks and the error addendum. - // So we add those into a separate console.warn. - - reportGlobalError(error); + if (true && ReactCurrentActQueue$2.current !== null) { + // For uncaught errors inside act, we track them on the act and then + // rethrow them into the test. + ReactCurrentActQueue$2.thrownErrors.push(error); + return; + } - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var componentName = source - ? getComponentNameFromFiber(source) - : null; - var componentNameMessage = componentName - ? "An error occurred in the <" + componentName + "> component:" - : "An error occurred in one of your React components:"; - console["warn"]( - "%s\n%s\n\n%s", - componentNameMessage, - componentStack, - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." - ); - } - } else { - // Caught by error boundary - if (true) { - var _source = errorInfo.source; - var _stack = errorInfo.stack; - - var _componentStack = _stack !== null ? _stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var _componentName = _source - ? getComponentNameFromFiber(_source) - : null; - - var _componentNameMessage = _componentName - ? "The above error occurred in the <" + - _componentName + - "> component:" - : "The above error occurred in one of your React components:"; - - var errorBoundaryName = - getComponentNameFromFiber(boundary) || "Anonymous"; // In development, we provide our own message which includes the component stack - // in addition to the error. - // Don't transform to our wrapper - - console["error"]( - "%o\n\n%s\n%s\n\n%s", - error, - _componentNameMessage, - _componentStack, - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + - errorBoundaryName + - ".") - ); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(error, { + componentStack: errorInfo.stack + }); + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function () { + throw e; + }); + } + } + function logCaughtError(root, boundary, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = getComponentNameFromFiber(boundary); } + + var error = errorInfo.value; + var onCaughtError = root.onCaughtError; + onCaughtError(error, { + componentStack: errorInfo.stack, + errorBoundary: + boundary.tag === ClassComponent + ? boundary.stateNode // This should always be the case as long as we only have class boundaries + : null + }); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -19576,7 +19581,7 @@ if (__DEV__) { } } - function createRootErrorUpdate(fiber, errorInfo, lane) { + function createRootErrorUpdate(root, errorInfo, lane) { var update = createUpdate(lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property @@ -19587,15 +19592,19 @@ if (__DEV__) { }; update.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return update; } - function createClassErrorUpdate(fiber, errorInfo, lane) { + function createClassErrorUpdate(lane) { var update = createUpdate(lane); update.tag = CaptureUpdate; + return update; + } + + function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { @@ -19610,7 +19619,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); }; } @@ -19623,7 +19632,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, @@ -19656,8 +19665,6 @@ if (__DEV__) { } }; } - - return update; } function resetSuspendedComponent(sourceFiber, rootRenderLanes) { @@ -20062,7 +20069,7 @@ if (__DEV__) { var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); var update = createRootErrorUpdate( - workInProgress, + workInProgress.stateNode, _errorInfo, lane ); @@ -20089,12 +20096,14 @@ if (__DEV__) { workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update = createClassErrorUpdate( + var _update = createClassErrorUpdate(_lane); + + initializeClassErrorUpdate( + _update, + root, workInProgress, - errorInfo, - _lane + errorInfo ); - enqueueCapturedUpdate(workInProgress, _update); return false; } @@ -21199,10 +21208,20 @@ if (__DEV__) { var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state - var update = createClassErrorUpdate( + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var update = createClassErrorUpdate(lane); + initializeClassErrorUpdate( + update, + root, workInProgress, - createCapturedValueAtFiber(error$1, workInProgress), - lane + createCapturedValueAtFiber(error$1, workInProgress) ); enqueueCapturedUpdate(workInProgress, update); break; @@ -33335,8 +33354,8 @@ if (__DEV__) { if (erroredWork === null) { // This is a fatal error workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); return; @@ -34161,10 +34180,7 @@ if (__DEV__) { // caught by an error boundary. This is a fatal error, or panic condition, // because we've run out of ways to recover. workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, - createCapturedValueAtFiber(error, root.current) - ); // Set `workInProgress` to null. This represents advancing to the next + logUncaughtError(root, createCapturedValueAtFiber(error, root.current)); // Set `workInProgress` to null. This represents advancing to the next // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're @@ -34937,7 +34953,11 @@ if (__DEV__) { function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValueAtFiber(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate( + rootFiber.stateNode, + errorInfo, + SyncLane + ); var root = enqueueUpdate(rootFiber, update, SyncLane); if (root !== null) { @@ -34978,10 +34998,11 @@ if (__DEV__) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValueAtFiber(error$1, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate(SyncLane); var root = enqueueUpdate(fiber, update, SyncLane); if (root !== null) { + initializeClassErrorUpdate(update, root, fiber, errorInfo); markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } @@ -36794,6 +36815,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -36822,6 +36845,8 @@ if (__DEV__) { this.entanglements = createLaneMap(NoLanes); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; { @@ -36884,6 +36909,8 @@ if (__DEV__) { // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -36894,6 +36921,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -36939,7 +36968,7 @@ if (__DEV__) { return root; } - var ReactVersion = "19.0.0-www-classic-475fb13a"; + var ReactVersion = "19.0.0-www-classic-af94e1ac"; function createPortal$1( children, @@ -37071,6 +37100,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ) { @@ -37085,6 +37116,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -37099,6 +37132,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -37113,6 +37148,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -49158,10 +49195,6 @@ if (__DEV__) { } } - function defaultOnRecoverableError(error, errorInfo) { - reportGlobalError(error); - } // $FlowFixMe[missing-this-annot] - function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } // $FlowFixMe[prop-missing] found when upgrading Flow @@ -49239,6 +49272,8 @@ if (__DEV__) { var isStrictMode = false; var concurrentUpdatesByDefaultOverride = false; var identifierPrefix = ""; + var onUncaughtError = defaultOnUncaughtError; + var onCaughtError = defaultOnCaughtError; var onRecoverableError = defaultOnRecoverableError; var transitionCallbacks = null; @@ -49277,6 +49312,14 @@ if (__DEV__) { identifierPrefix = options.identifierPrefix; } + if (options.onUncaughtError !== undefined) { + onUncaughtError = options.onUncaughtError; + } + + if (options.onCaughtError !== undefined) { + onCaughtError = options.onCaughtError; + } + if (options.onRecoverableError !== undefined) { onRecoverableError = options.onRecoverableError; } @@ -49293,6 +49336,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ); @@ -49337,6 +49382,8 @@ if (__DEV__) { var isStrictMode = false; var concurrentUpdatesByDefaultOverride = false; var identifierPrefix = ""; + var onUncaughtError = defaultOnUncaughtError; + var onCaughtError = defaultOnCaughtError; var onRecoverableError = defaultOnRecoverableError; var transitionCallbacks = null; var formState = null; @@ -49354,6 +49401,14 @@ if (__DEV__) { identifierPrefix = options.identifierPrefix; } + if (options.onUncaughtError !== undefined) { + onUncaughtError = options.onUncaughtError; + } + + if (options.onCaughtError !== undefined) { + onCaughtError = options.onCaughtError; + } + if (options.onRecoverableError !== undefined) { onRecoverableError = options.onRecoverableError; } @@ -49378,6 +49433,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -49431,10 +49488,10 @@ if (__DEV__) { } var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; - var topLevelUpdateWarnings; + var topLevelUpdateWarnings$1; { - topLevelUpdateWarnings = function (container) { + topLevelUpdateWarnings$1 = function (container) { if ( container._reactRootContainer && container.nodeType !== COMMENT_NODE @@ -49456,7 +49513,7 @@ if (__DEV__) { } var isRootRenderedBySomeReact = !!container._reactRootContainer; - var rootEl = getReactRootElementInContainer(container); + var rootEl = getReactRootElementInContainer$1(container); var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl)); if (hasNonRootReactChild && !isRootRenderedBySomeReact) { @@ -49470,7 +49527,7 @@ if (__DEV__) { }; } - function getReactRootElementInContainer(container) { + function getReactRootElementInContainer$1(container) { if (!container) { return null; } @@ -49482,12 +49539,12 @@ if (__DEV__) { } } - function noopOnRecoverableError() { + function noopOnRecoverableError$1() { // This isn't reachable because onRecoverableError isn't called in the // legacy API. } - function legacyCreateRootFromDOMContainer( + function legacyCreateRootFromDOMContainer$1( container, initialChildren, parentComponent, @@ -49513,7 +49570,9 @@ if (__DEV__) { false, // isStrictMode false, // concurrentUpdatesByDefaultOverride, "", // identifierPrefix - noopOnRecoverableError, // TODO(luna) Support hydration later + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, // TODO(luna) Support hydration later null, null ); @@ -49548,7 +49607,9 @@ if (__DEV__) { false, // isStrictMode false, // concurrentUpdatesByDefaultOverride, "", // identifierPrefix - noopOnRecoverableError, // onRecoverableError + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, null // transitionCallbacks ); @@ -49569,7 +49630,7 @@ if (__DEV__) { } } - function warnOnInvalidCallback(callback) { + function warnOnInvalidCallback$1(callback) { { if (callback !== null && typeof callback !== "function") { error( @@ -49581,7 +49642,7 @@ if (__DEV__) { } } - function legacyRenderSubtreeIntoContainer( + function legacyRenderSubtreeIntoContainer$1( parentComponent, children, container, @@ -49589,8 +49650,8 @@ if (__DEV__) { callback ) { { - topLevelUpdateWarnings(container); - warnOnInvalidCallback(callback === undefined ? null : callback); + topLevelUpdateWarnings$1(container); + warnOnInvalidCallback$1(callback === undefined ? null : callback); } var maybeRoot = container._reactRootContainer; @@ -49598,7 +49659,7 @@ if (__DEV__) { if (!maybeRoot) { // Initial mount - root = legacyCreateRootFromDOMContainer( + root = legacyCreateRootFromDOMContainer$1( container, children, parentComponent, @@ -49658,42 +49719,6 @@ if (__DEV__) { return findHostInstanceWithWarning(componentOrElement, "findDOMNode"); } } - function render(element, container, callback) { - { - error( - "ReactDOM.render has not been supported since React 18. Use createRoot " + - "instead. Until you switch to the new API, your app will behave as " + - "if it's running React 17. Learn " + - "more: https://react.dev/link/switch-to-createroot" - ); - } - - if (!isValidContainerLegacy(container)) { - throw new Error("Target container is not a DOM element."); - } - - { - var isModernRoot = - isContainerMarkedAsRoot(container) && - container._reactRootContainer === undefined; - - if (isModernRoot) { - error( - "You are calling ReactDOM.render() on a container that was previously " + - "passed to ReactDOMClient.createRoot(). This is not supported. " + - "Did you mean to call root.render(element)?" - ); - } - } - - return legacyRenderSubtreeIntoContainer( - null, - element, - container, - false, - callback - ); - } function unstable_renderSubtreeIntoContainer( parentComponent, element, @@ -49717,7 +49742,7 @@ if (__DEV__) { throw new Error("parentComponent must be a valid React Component"); } - return legacyRenderSubtreeIntoContainer( + return legacyRenderSubtreeIntoContainer$1( parentComponent, element, containerNode, @@ -49745,7 +49770,7 @@ if (__DEV__) { if (container._reactRootContainer) { { - var rootEl = getReactRootElementInContainer(container); + var rootEl = getReactRootElementInContainer$1(container); var renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl); if (renderedByDifferentReact) { @@ -49757,7 +49782,7 @@ if (__DEV__) { } // Unmount should not be batched. flushSync$1(function () { - legacyRenderSubtreeIntoContainer( + legacyRenderSubtreeIntoContainer$1( null, null, container, @@ -49774,7 +49799,7 @@ if (__DEV__) { return true; } else { { - var _rootEl = getReactRootElementInContainer(container); + var _rootEl = getReactRootElementInContainer$1(container); var hasNonRootReactChild = !!( _rootEl && getInstanceFromNode(_rootEl) @@ -50409,6 +50434,281 @@ if (__DEV__) { } } + var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); + + if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { + throw new Error( + "Expected ReactFiberErrorDialog.showErrorDialog to be a function." + ); + } + + function wwwOnUncaughtError(error, errorInfo) { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var logError = ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: null, + error: error, + componentStack: componentStack + }); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. + + if (logError === false) { + return; + } + + defaultOnUncaughtError(error, errorInfo); + } + + function wwwOnCaughtError(error, errorInfo) { + var errorBoundary = errorInfo.errorBoundary; + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var logError = ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: errorBoundary, + error: error, + componentStack: componentStack + }); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. + + if (logError === false) { + return; + } + + defaultOnCaughtError(error, errorInfo); + } + var topLevelUpdateWarnings; + + { + topLevelUpdateWarnings = function (container) { + if ( + container._reactRootContainer && + container.nodeType !== COMMENT_NODE + ) { + var hostInstance = findHostInstanceWithNoPortals( + container._reactRootContainer.current + ); + + if (hostInstance) { + if (hostInstance.parentNode !== container) { + error( + "It looks like the React-rendered content of this " + + "container was removed without using React. This is not " + + "supported and will cause errors. Instead, call " + + "ReactDOM.unmountComponentAtNode to empty a container." + ); + } + } + } + + var isRootRenderedBySomeReact = !!container._reactRootContainer; + var rootEl = getReactRootElementInContainer(container); + var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl)); + + if (hasNonRootReactChild && !isRootRenderedBySomeReact) { + error( + "Replacing React-rendered children with a new root " + + "component. If you intended to update the children of this node, " + + "you should instead have the existing children update their state " + + "and render the new components instead of calling ReactDOM.render." + ); + } + }; + } + + function getReactRootElementInContainer(container) { + if (!container) { + return null; + } + + if (container.nodeType === DOCUMENT_NODE) { + return container.documentElement; + } else { + return container.firstChild; + } + } + + function noopOnRecoverableError() { + // This isn't reachable because onRecoverableError isn't called in the + // legacy API. + } + + function legacyCreateRootFromDOMContainer( + container, + initialChildren, + parentComponent, + callback, + isHydrationContainer + ) { + if (isHydrationContainer) { + if (typeof callback === "function") { + var originalCallback = callback; + + callback = function () { + var instance = getPublicRootInstance(root); + originalCallback.call(instance); + }; + } + + var root = createHydrationContainer( + initialChildren, + callback, + container, + LegacyRoot, + null, // hydrationCallbacks + false, // isStrictMode + false, // concurrentUpdatesByDefaultOverride, + "", // identifierPrefix + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, // TODO(luna) Support hydration later + null, + null + ); + container._reactRootContainer = root; + markContainerAsRoot(root.current, container); + var rootContainerElement = + container.nodeType === COMMENT_NODE + ? container.parentNode + : container; // $FlowFixMe[incompatible-call] + + listenToAllSupportedEvents(rootContainerElement); + flushSync$1(); + return root; + } else { + // First clear any existing content. + clearContainer(container); + + if (typeof callback === "function") { + var _originalCallback = callback; + + callback = function () { + var instance = getPublicRootInstance(_root); + + _originalCallback.call(instance); + }; + } + + var _root = createContainer( + container, + LegacyRoot, + null, // hydrationCallbacks + false, // isStrictMode + false, // concurrentUpdatesByDefaultOverride, + "", // identifierPrefix + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, + null // transitionCallbacks + ); + + container._reactRootContainer = _root; + markContainerAsRoot(_root.current, container); + + var _rootContainerElement = + container.nodeType === COMMENT_NODE + ? container.parentNode + : container; // $FlowFixMe[incompatible-call] + + listenToAllSupportedEvents(_rootContainerElement); // Initial mount should not be batched. + + flushSync$1(function () { + updateContainer(initialChildren, _root, parentComponent, callback); + }); + return _root; + } + } + + function warnOnInvalidCallback(callback) { + { + if (callback !== null && typeof callback !== "function") { + error( + "Expected the last optional `callback` argument to be a " + + "function. Instead received: %s.", + callback + ); + } + } + } + + function legacyRenderSubtreeIntoContainer( + parentComponent, + children, + container, + forceHydrate, + callback + ) { + { + topLevelUpdateWarnings(container); + warnOnInvalidCallback(callback === undefined ? null : callback); + } + + var maybeRoot = container._reactRootContainer; + var root; + + if (!maybeRoot) { + // Initial mount + root = legacyCreateRootFromDOMContainer( + container, + children, + parentComponent, + callback, + forceHydrate + ); + } else { + root = maybeRoot; + + if (typeof callback === "function") { + var originalCallback = callback; + + callback = function () { + var instance = getPublicRootInstance(root); + originalCallback.call(instance); + }; + } // Update + + updateContainer(children, root, parentComponent, callback); + } + + return getPublicRootInstance(root); + } + + function render(element, container, callback) { + { + error( + "ReactDOM.render has not been supported since React 18. Use createRoot " + + "instead. Until you switch to the new API, your app will behave as " + + "if it's running React 17. Learn " + + "more: https://react.dev/link/switch-to-createroot" + ); + } + + if (!isValidContainerLegacy(container)) { + throw new Error("Target container is not a DOM element."); + } + + { + var isModernRoot = + isContainerMarkedAsRoot(container) && + container._reactRootContainer === undefined; + + if (isModernRoot) { + error( + "You are calling ReactDOM.render() on a container that was previously " + + "passed to ReactDOMClient.createRoot(). This is not supported. " + + "Did you mean to call root.render(element)?" + ); + } + } + + return legacyRenderSubtreeIntoContainer( + null, + element, + container, + false, + callback + ); + } + assign(Internals, { ReactBrowserEventEmitter: { isEnabled: isEnabled diff --git a/compiled/facebook-www/ReactDOMTesting-dev.modern.js b/compiled/facebook-www/ReactDOMTesting-dev.modern.js index b77d31d243006..2703f2ebe3615 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.modern.js @@ -19347,26 +19347,6 @@ if (__DEV__) { }; } - var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); - - if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { - throw new Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); - } - - function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; - return ReactFiberErrorDialogWWW.showErrorDialog(capturedError); - } - var reportGlobalError = typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, ? // emulating an uncaught JavaScript error. @@ -19406,86 +19386,111 @@ if (__DEV__) { console["error"](error); }; - var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; - function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API - if (logError === false) { - return; + var componentName = null; + var errorBoundaryName = null; + function defaultOnUncaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // For uncaught root errors we report them as uncaught to the browser's + // onerror callback. This won't have component stacks and the error addendum. + // So we add those into a separate console.warn. + reportGlobalError(error); + + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "An error occurred in the <" + componentName + "> component:" + : "An error occurred in one of your React components:"; + console["warn"]( + "%s\n%s\n\n%s", + componentNameMessage, + componentStack || "", + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." + ); + } + } + function defaultOnCaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // Caught by error boundary + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; // In development, we provide our own message which includes the component stack + // in addition to the error. + // Don't transform to our wrapper + + console["error"]( + "%o\n\n%s\n%s\n\n%s", + error, + componentNameMessage, + componentStack, + "React will try to recreate this component tree from scratch " + + ("using the error boundary you provided, " + + (errorBoundaryName || "Anonymous") + + ".") + ); + } + } + function defaultOnRecoverableError(error, errorInfo) { + reportGlobalError(error); + } + function logUncaughtError(root, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = null; } var error = errorInfo.value; - if (boundary.tag === HostRoot) { - if (true && ReactCurrentActQueue$2.current !== null) { - // For uncaught errors inside act, we track them on the act and then - // rethrow them into the test. - ReactCurrentActQueue$2.thrownErrors.push(error); - return; - } // For uncaught root errors we report them as uncaught to the browser's - // onerror callback. This won't have component stacks and the error addendum. - // So we add those into a separate console.warn. - - reportGlobalError(error); + if (true && ReactCurrentActQueue$2.current !== null) { + // For uncaught errors inside act, we track them on the act and then + // rethrow them into the test. + ReactCurrentActQueue$2.thrownErrors.push(error); + return; + } - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var componentName = source - ? getComponentNameFromFiber(source) - : null; - var componentNameMessage = componentName - ? "An error occurred in the <" + componentName + "> component:" - : "An error occurred in one of your React components:"; - console["warn"]( - "%s\n%s\n\n%s", - componentNameMessage, - componentStack, - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." - ); - } - } else { - // Caught by error boundary - if (true) { - var _source = errorInfo.source; - var _stack = errorInfo.stack; - - var _componentStack = _stack !== null ? _stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var _componentName = _source - ? getComponentNameFromFiber(_source) - : null; - - var _componentNameMessage = _componentName - ? "The above error occurred in the <" + - _componentName + - "> component:" - : "The above error occurred in one of your React components:"; - - var errorBoundaryName = - getComponentNameFromFiber(boundary) || "Anonymous"; // In development, we provide our own message which includes the component stack - // in addition to the error. - // Don't transform to our wrapper - - console["error"]( - "%o\n\n%s\n%s\n\n%s", - error, - _componentNameMessage, - _componentStack, - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + - errorBoundaryName + - ".") - ); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(error, { + componentStack: errorInfo.stack + }); + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function () { + throw e; + }); + } + } + function logCaughtError(root, boundary, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = getComponentNameFromFiber(boundary); } + + var error = errorInfo.value; + var onCaughtError = root.onCaughtError; + onCaughtError(error, { + componentStack: errorInfo.stack, + errorBoundary: + boundary.tag === ClassComponent + ? boundary.stateNode // This should always be the case as long as we only have class boundaries + : null + }); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -19497,7 +19502,7 @@ if (__DEV__) { } } - function createRootErrorUpdate(fiber, errorInfo, lane) { + function createRootErrorUpdate(root, errorInfo, lane) { var update = createUpdate(lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property @@ -19508,15 +19513,19 @@ if (__DEV__) { }; update.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return update; } - function createClassErrorUpdate(fiber, errorInfo, lane) { + function createClassErrorUpdate(lane) { var update = createUpdate(lane); update.tag = CaptureUpdate; + return update; + } + + function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { @@ -19531,7 +19540,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); }; } @@ -19544,7 +19553,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, @@ -19577,8 +19586,6 @@ if (__DEV__) { } }; } - - return update; } function resetSuspendedComponent(sourceFiber, rootRenderLanes) { @@ -19983,7 +19990,7 @@ if (__DEV__) { var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); var update = createRootErrorUpdate( - workInProgress, + workInProgress.stateNode, _errorInfo, lane ); @@ -20010,12 +20017,14 @@ if (__DEV__) { workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update = createClassErrorUpdate( + var _update = createClassErrorUpdate(_lane); + + initializeClassErrorUpdate( + _update, + root, workInProgress, - errorInfo, - _lane + errorInfo ); - enqueueCapturedUpdate(workInProgress, _update); return false; } @@ -21111,10 +21120,20 @@ if (__DEV__) { var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state - var update = createClassErrorUpdate( + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var update = createClassErrorUpdate(lane); + initializeClassErrorUpdate( + update, + root, workInProgress, - createCapturedValueAtFiber(error$1, workInProgress), - lane + createCapturedValueAtFiber(error$1, workInProgress) ); enqueueCapturedUpdate(workInProgress, update); break; @@ -33191,8 +33210,8 @@ if (__DEV__) { if (erroredWork === null) { // This is a fatal error workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); return; @@ -34008,10 +34027,7 @@ if (__DEV__) { // caught by an error boundary. This is a fatal error, or panic condition, // because we've run out of ways to recover. workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, - createCapturedValueAtFiber(error, root.current) - ); // Set `workInProgress` to null. This represents advancing to the next + logUncaughtError(root, createCapturedValueAtFiber(error, root.current)); // Set `workInProgress` to null. This represents advancing to the next // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're @@ -34784,7 +34800,11 @@ if (__DEV__) { function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValueAtFiber(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate( + rootFiber.stateNode, + errorInfo, + SyncLane + ); var root = enqueueUpdate(rootFiber, update, SyncLane); if (root !== null) { @@ -34825,10 +34845,11 @@ if (__DEV__) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValueAtFiber(error$1, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate(SyncLane); var root = enqueueUpdate(fiber, update, SyncLane); if (root !== null) { + initializeClassErrorUpdate(update, root, fiber, errorInfo); markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } @@ -36641,6 +36662,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -36669,6 +36692,8 @@ if (__DEV__) { this.entanglements = createLaneMap(NoLanes); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; { @@ -36731,6 +36756,8 @@ if (__DEV__) { // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -36741,6 +36768,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -36786,7 +36815,7 @@ if (__DEV__) { return root; } - var ReactVersion = "19.0.0-www-modern-5757544c"; + var ReactVersion = "19.0.0-www-modern-48f9be72"; function createPortal$1( children, @@ -36846,6 +36875,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ) { @@ -36860,6 +36891,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -36874,6 +36907,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -36888,6 +36923,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -48641,10 +48678,6 @@ if (__DEV__) { var NotPendingTransition = NotPending; - function defaultOnRecoverableError(error, errorInfo) { - reportGlobalError(error); - } // $FlowFixMe[missing-this-annot] - function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } // $FlowFixMe[prop-missing] found when upgrading Flow @@ -48722,6 +48755,8 @@ if (__DEV__) { var isStrictMode = false; var concurrentUpdatesByDefaultOverride = false; var identifierPrefix = ""; + var onUncaughtError = defaultOnUncaughtError; + var onCaughtError = defaultOnCaughtError; var onRecoverableError = defaultOnRecoverableError; var transitionCallbacks = null; @@ -48760,6 +48795,14 @@ if (__DEV__) { identifierPrefix = options.identifierPrefix; } + if (options.onUncaughtError !== undefined) { + onUncaughtError = options.onUncaughtError; + } + + if (options.onCaughtError !== undefined) { + onCaughtError = options.onCaughtError; + } + if (options.onRecoverableError !== undefined) { onRecoverableError = options.onRecoverableError; } @@ -48776,6 +48819,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ); @@ -48820,6 +48865,8 @@ if (__DEV__) { var isStrictMode = false; var concurrentUpdatesByDefaultOverride = false; var identifierPrefix = ""; + var onUncaughtError = defaultOnUncaughtError; + var onCaughtError = defaultOnCaughtError; var onRecoverableError = defaultOnRecoverableError; var transitionCallbacks = null; var formState = null; @@ -48837,6 +48884,14 @@ if (__DEV__) { identifierPrefix = options.identifierPrefix; } + if (options.onUncaughtError !== undefined) { + onUncaughtError = options.onUncaughtError; + } + + if (options.onCaughtError !== undefined) { + onCaughtError = options.onCaughtError; + } + if (options.onRecoverableError !== undefined) { onRecoverableError = options.onRecoverableError; } @@ -48861,6 +48916,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -49493,6 +49550,14 @@ if (__DEV__) { } } + var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); + + if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { + throw new Error( + "Expected ReactFiberErrorDialog.showErrorDialog to be a function." + ); + } + function createRoot(container, options) { { Internals.usingClientEntryPoint = true; diff --git a/compiled/facebook-www/ReactDOMTesting-prod.classic.js b/compiled/facebook-www/ReactDOMTesting-prod.classic.js index d52c8a56a635f..f7e068fae5ff8 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.classic.js @@ -4924,9 +4924,6 @@ function createCapturedValueFromError(value, digest, stack) { digest: null != digest ? digest : null }; } -var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); -if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) - throw Error(formatProdErrorMessage(320)); var reportGlobalError = "function" === typeof reportError ? reportError @@ -4956,53 +4953,68 @@ var reportGlobalError = } console.error(error); }; -function logCapturedError(boundary, errorInfo) { +function defaultOnUncaughtError(error) { + reportGlobalError(error); +} +function defaultOnCaughtError(error) { + console.error(error); +} +function defaultOnRecoverableError(error) { + reportGlobalError(error); +} +function logUncaughtError(root, errorInfo) { try { - if ( - !1 !== - ReactFiberErrorDialogWWW.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) - ) { - var error = errorInfo.value; - 3 === boundary.tag ? reportGlobalError(error) : console.error(error); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(errorInfo.value, { componentStack: errorInfo.stack }); } catch (e) { setTimeout(function () { throw e; }); } } -function createRootErrorUpdate(fiber, errorInfo, lane) { +function logCaughtError(root, boundary, errorInfo) { + try { + var onCaughtError = root.onCaughtError; + onCaughtError(errorInfo.value, { + componentStack: errorInfo.stack, + errorBoundary: 1 === boundary.tag ? boundary.stateNode : null + }); + } catch (e) { + setTimeout(function () { + throw e; + }); + } +} +function createRootErrorUpdate(root, errorInfo, lane) { lane = createUpdate(lane); lane.tag = 3; lane.payload = { element: null }; lane.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return lane; } -function createClassErrorUpdate(fiber, errorInfo, lane) { +function createClassErrorUpdate(lane) { lane = createUpdate(lane); lane.tag = 3; + return lane; +} +function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error = errorInfo.value; - lane.payload = function () { + update.payload = function () { return getDerivedStateFromError(error); }; - lane.callback = function () { - logCapturedError(fiber, errorInfo); + update.callback = function () { + logCaughtError(root, fiber, errorInfo); }; } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && - (lane.callback = function () { - logCapturedError(fiber, errorInfo); + (update.callback = function () { + logCaughtError(root, fiber, errorInfo); "function" !== typeof getDerivedStateFromError && (null === legacyErrorBoundariesThatAlreadyFailed ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) @@ -5012,7 +5024,6 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { componentStack: null !== stack ? stack : "" }); }); - return lane; } function markSuspenseBoundaryShouldCapture( suspenseBoundary, @@ -5054,83 +5065,76 @@ function throwException( "object" === typeof value && "function" === typeof value.then ) { - if (enableLazyContextPropagation) { - var currentSourceFiber = sourceFiber.alternate; - null !== currentSourceFiber && - propagateParentContextChanges( - currentSourceFiber, - sourceFiber, - rootRenderLanes, - !0 - ); - } - currentSourceFiber = sourceFiber.tag; + var wakeable = value; + enableLazyContextPropagation && + ((value = sourceFiber.alternate), + null !== value && + propagateParentContextChanges(value, sourceFiber, rootRenderLanes, !0)); + value = sourceFiber.tag; 0 !== (sourceFiber.mode & 1) || - (0 !== currentSourceFiber && - 11 !== currentSourceFiber && - 15 !== currentSourceFiber) || - ((currentSourceFiber = sourceFiber.alternate) - ? ((sourceFiber.updateQueue = currentSourceFiber.updateQueue), - (sourceFiber.memoizedState = currentSourceFiber.memoizedState), - (sourceFiber.lanes = currentSourceFiber.lanes)) + (0 !== value && 11 !== value && 15 !== value) || + ((value = sourceFiber.alternate) + ? ((sourceFiber.updateQueue = value.updateQueue), + (sourceFiber.memoizedState = value.memoizedState), + (sourceFiber.lanes = value.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null))); - currentSourceFiber = suspenseHandlerStackCursor.current; - if (null !== currentSourceFiber) { - switch (currentSourceFiber.tag) { + value = suspenseHandlerStackCursor.current; + if (null !== value) { + switch (value.tag) { case 13: return ( sourceFiber.mode & 1 && (null === shellBoundary ? renderDidSuspendDelayIfPossible() - : null === currentSourceFiber.alternate && + : null === value.alternate && 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 3)), - (currentSourceFiber.flags &= -257), + (value.flags &= -257), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + value, returnFiber, sourceFiber, root, rootRenderLanes ), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber - ? (currentSourceFiber.updateQueue = new Set([value])) - : returnFiber.add(value), - currentSourceFiber.mode & 1 && - attachPingListener(root, value, rootRenderLanes)), + ? (value.updateQueue = new Set([wakeable])) + : returnFiber.add(wakeable), + value.mode & 1 && + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); case 22: - if (currentSourceFiber.mode & 1) + if (value.mode & 1) return ( - (currentSourceFiber.flags |= 65536), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + (value.flags |= 65536), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber ? ((returnFiber = { transitions: null, markerInstances: null, - retryQueue: new Set([value]) + retryQueue: new Set([wakeable]) }), - (currentSourceFiber.updateQueue = returnFiber)) + (value.updateQueue = returnFiber)) : ((sourceFiber = returnFiber.retryQueue), null === sourceFiber - ? (returnFiber.retryQueue = new Set([value])) - : sourceFiber.add(value)), - attachPingListener(root, value, rootRenderLanes)), + ? (returnFiber.retryQueue = new Set([wakeable])) + : sourceFiber.add(wakeable)), + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); } - throw Error(formatProdErrorMessage(435, currentSourceFiber.tag)); + throw Error(formatProdErrorMessage(435, value.tag)); } if (1 === root.tag) return ( - attachPingListener(root, value, rootRenderLanes), + attachPingListener(root, wakeable, rootRenderLanes), renderDidSuspendDelayIfPossible(), !1 ); @@ -5139,14 +5143,12 @@ function throwException( if ( isHydrating && sourceFiber.mode & 1 && - ((currentSourceFiber = suspenseHandlerStackCursor.current), - null !== currentSourceFiber) + ((wakeable = suspenseHandlerStackCursor.current), null !== wakeable) ) return ( - 0 === (currentSourceFiber.flags & 65536) && - (currentSourceFiber.flags |= 256), + 0 === (wakeable.flags & 65536) && (wakeable.flags |= 256), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + wakeable, returnFiber, sourceFiber, root, @@ -5155,57 +5157,58 @@ function throwException( queueHydrationError(createCapturedValueAtFiber(value, sourceFiber)), !1 ); - root = value = createCapturedValueAtFiber(value, sourceFiber); + wakeable = value = createCapturedValueAtFiber(value, sourceFiber); 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + ? (workInProgressRootConcurrentErrors = [wakeable]) + : workInProgressRootConcurrentErrors.push(wakeable); if (null === returnFiber) return !0; - root = returnFiber; + wakeable = returnFiber; do { - switch (root.tag) { + switch (wakeable.tag) { case 3: return ( - (root.flags |= 65536), + (root = value), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createRootErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (root = createRootErrorUpdate( + wakeable.stateNode, root, - value, rootRenderLanes )), - enqueueCapturedUpdate(root, rootRenderLanes), + enqueueCapturedUpdate(wakeable, root), !1 ); case 1: + returnFiber = value; + sourceFiber = wakeable.type; + var instance = wakeable.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.type), - (currentSourceFiber = root.stateNode), - 0 === (root.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + 0 === (wakeable.flags & 128) && + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) return ( - (root.flags |= 65536), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createClassErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (rootRenderLanes = createClassErrorUpdate(rootRenderLanes)), + initializeClassErrorUpdate( + rootRenderLanes, root, - returnFiber, - rootRenderLanes - )), - enqueueCapturedUpdate(root, rootRenderLanes), + wakeable, + returnFiber + ), + enqueueCapturedUpdate(wakeable, rootRenderLanes), !1 ); } - root = root.return; - } while (null !== root); + wakeable = wakeable.return; + } while (null !== wakeable); return !1; } function processTransitionCallbacks(pendingTransitions, endTime, callbacks) { @@ -11536,8 +11539,8 @@ function handleThrow(root, thrownValue) { workInProgressThrownValue = thrownValue; null === workInProgress && ((workInProgressRootExitStatus = 1), - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) )); } @@ -11812,8 +11815,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { ) ) { workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -11822,8 +11825,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { } catch (error) { if (null !== returnFiber) throw ((workInProgress = returnFiber), error); workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -12084,7 +12087,7 @@ function flushPassiveEffectsImpl() { } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 2); + sourceFiber = createRootErrorUpdate(rootFiber.stateNode, sourceFiber, 2); rootFiber = enqueueUpdate(rootFiber, sourceFiber, 2); null !== rootFiber && (markRootUpdated(rootFiber, 2), ensureRootIsScheduled(rootFiber)); @@ -12111,19 +12114,17 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - nearestMountedAncestor = enqueueUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 2), - ensureRootIsScheduled(nearestMountedAncestor)); + error = createClassErrorUpdate(2); + instance = enqueueUpdate(nearestMountedAncestor, error, 2); + null !== instance && + (initializeClassErrorUpdate( + error, + instance, + nearestMountedAncestor, + sourceFiber + ), + markRootUpdated(instance, 2), + ensureRootIsScheduled(instance)); break; } } @@ -12530,6 +12531,8 @@ function FiberRootNode( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -12561,6 +12564,8 @@ function FiberRootNode( this.entanglements = createLaneMap(0); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; this.pooledCache = null; this.pooledCacheLanes = 0; @@ -12586,6 +12591,8 @@ function createFiberRoot( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -12595,6 +12602,8 @@ function createFiberRoot( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -12679,6 +12688,8 @@ function createHydrationContainer( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -12692,6 +12703,8 @@ function createHydrationContainer( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -13310,19 +13323,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) { } var isInputEventSupported = !1; if (canUseDOM) { - var JSCompiler_inline_result$jscomp$345; + var JSCompiler_inline_result$jscomp$349; if (canUseDOM) { - var isSupported$jscomp$inline_1521 = "oninput" in document; - if (!isSupported$jscomp$inline_1521) { - var element$jscomp$inline_1522 = document.createElement("div"); - element$jscomp$inline_1522.setAttribute("oninput", "return;"); - isSupported$jscomp$inline_1521 = - "function" === typeof element$jscomp$inline_1522.oninput; + var isSupported$jscomp$inline_1525 = "oninput" in document; + if (!isSupported$jscomp$inline_1525) { + var element$jscomp$inline_1526 = document.createElement("div"); + element$jscomp$inline_1526.setAttribute("oninput", "return;"); + isSupported$jscomp$inline_1525 = + "function" === typeof element$jscomp$inline_1526.oninput; } - JSCompiler_inline_result$jscomp$345 = isSupported$jscomp$inline_1521; - } else JSCompiler_inline_result$jscomp$345 = !1; + JSCompiler_inline_result$jscomp$349 = isSupported$jscomp$inline_1525; + } else JSCompiler_inline_result$jscomp$349 = !1; isInputEventSupported = - JSCompiler_inline_result$jscomp$345 && + JSCompiler_inline_result$jscomp$349 && (!document.documentMode || 9 < document.documentMode); } function stopWatchingForValueChange() { @@ -13694,20 +13707,20 @@ function extractEvents$1( } } for ( - var i$jscomp$inline_1562 = 0; - i$jscomp$inline_1562 < simpleEventPluginEvents.length; - i$jscomp$inline_1562++ + var i$jscomp$inline_1566 = 0; + i$jscomp$inline_1566 < simpleEventPluginEvents.length; + i$jscomp$inline_1566++ ) { - var eventName$jscomp$inline_1563 = - simpleEventPluginEvents[i$jscomp$inline_1562], - domEventName$jscomp$inline_1564 = - eventName$jscomp$inline_1563.toLowerCase(), - capitalizedEvent$jscomp$inline_1565 = - eventName$jscomp$inline_1563[0].toUpperCase() + - eventName$jscomp$inline_1563.slice(1); + var eventName$jscomp$inline_1567 = + simpleEventPluginEvents[i$jscomp$inline_1566], + domEventName$jscomp$inline_1568 = + eventName$jscomp$inline_1567.toLowerCase(), + capitalizedEvent$jscomp$inline_1569 = + eventName$jscomp$inline_1567[0].toUpperCase() + + eventName$jscomp$inline_1567.slice(1); registerSimpleEvent( - domEventName$jscomp$inline_1564, - "on" + capitalizedEvent$jscomp$inline_1565 + domEventName$jscomp$inline_1568, + "on" + capitalizedEvent$jscomp$inline_1569 ); } registerSimpleEvent(ANIMATION_END, "onAnimationEnd"); @@ -17201,9 +17214,6 @@ function getEventPriority(domEventName) { return 32; } } -function defaultOnRecoverableError(error) { - reportGlobalError(error); -} function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } @@ -17263,8 +17273,8 @@ function isValidContainerLegacy(node) { " react-mount-point-unstable " !== node.nodeValue)) ); } -function noopOnRecoverableError() {} -function legacyCreateRootFromDOMContainer( +function noopOnRecoverableError$1() {} +function legacyCreateRootFromDOMContainer$1( container, initialChildren, parentComponent, @@ -17288,7 +17298,9 @@ function legacyCreateRootFromDOMContainer( !1, !1, "", - noopOnRecoverableError, + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, null, null ); @@ -17317,7 +17329,9 @@ function legacyCreateRootFromDOMContainer( !1, !1, "", - noopOnRecoverableError, + defaultOnUncaughtError, + defaultOnCaughtError, + noopOnRecoverableError$1, null, null ); @@ -17331,7 +17345,7 @@ function legacyCreateRootFromDOMContainer( }); return root$286; } -function legacyRenderSubtreeIntoContainer( +function legacyRenderSubtreeIntoContainer$1( parentComponent, children, container, @@ -17350,7 +17364,7 @@ function legacyRenderSubtreeIntoContainer( } updateContainer(children, root, parentComponent, callback); } else - root = legacyCreateRootFromDOMContainer( + root = legacyCreateRootFromDOMContainer$1( container, children, parentComponent, @@ -17394,17 +17408,17 @@ Internals.Events = [ restoreStateIfNeeded, batchedUpdates$1 ]; -var devToolsConfig$jscomp$inline_1756 = { +var devToolsConfig$jscomp$inline_1760 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-classic-4f8b066b", + version: "19.0.0-www-classic-4d284a43", rendererPackageName: "react-dom" }; -var internals$jscomp$inline_2155 = { - bundleType: devToolsConfig$jscomp$inline_1756.bundleType, - version: devToolsConfig$jscomp$inline_1756.version, - rendererPackageName: devToolsConfig$jscomp$inline_1756.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1756.rendererConfig, +var internals$jscomp$inline_2168 = { + bundleType: devToolsConfig$jscomp$inline_1760.bundleType, + version: devToolsConfig$jscomp$inline_1760.version, + rendererPackageName: devToolsConfig$jscomp$inline_1760.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1760.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -17420,28 +17434,149 @@ var internals$jscomp$inline_2155 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1756.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1760.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-classic-4f8b066b" + reconcilerVersion: "19.0.0-www-classic-4d284a43" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_2156 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_2169 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_2156.isDisabled && - hook$jscomp$inline_2156.supportsFiber + !hook$jscomp$inline_2169.isDisabled && + hook$jscomp$inline_2169.supportsFiber ) try { - (rendererID = hook$jscomp$inline_2156.inject( - internals$jscomp$inline_2155 + (rendererID = hook$jscomp$inline_2169.inject( + internals$jscomp$inline_2168 )), - (injectedHook = hook$jscomp$inline_2156); + (injectedHook = hook$jscomp$inline_2169); } catch (err) {} } +var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); +if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) + throw Error(formatProdErrorMessage(320)); +function wwwOnUncaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: null, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && reportGlobalError(error); +} +function wwwOnCaughtError(error, errorInfo) { + !1 !== + ReactFiberErrorDialogWWW.showErrorDialog({ + errorBoundary: errorInfo.errorBoundary, + error: error, + componentStack: + null != errorInfo.componentStack ? errorInfo.componentStack : "" + }) && defaultOnCaughtError(error); +} +function noopOnRecoverableError() {} +function legacyCreateRootFromDOMContainer( + container, + initialChildren, + parentComponent, + callback, + isHydrationContainer +) { + if (isHydrationContainer) { + if ("function" === typeof callback) { + var originalCallback = callback; + callback = function () { + var instance = getPublicRootInstance(root$288); + originalCallback.call(instance); + }; + } + var root$288 = createHydrationContainer( + initialChildren, + callback, + container, + 0, + null, + !1, + !1, + "", + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, + null, + null + ); + container._reactRootContainer = root$288; + container[internalContainerInstanceKey] = root$288.current; + listenToAllSupportedEvents( + 8 === container.nodeType ? container.parentNode : container + ); + flushSync$1(); + return root$288; + } + clearContainer(container); + if ("function" === typeof callback) { + var originalCallback$289 = callback; + callback = function () { + var instance = getPublicRootInstance(root$290); + originalCallback$289.call(instance); + }; + } + var root$290 = createFiberRoot( + container, + 0, + !1, + null, + null, + !1, + !1, + "", + wwwOnUncaughtError, + wwwOnCaughtError, + noopOnRecoverableError, + null, + null + ); + container._reactRootContainer = root$290; + container[internalContainerInstanceKey] = root$290.current; + listenToAllSupportedEvents( + 8 === container.nodeType ? container.parentNode : container + ); + flushSync$1(function () { + updateContainer(initialChildren, root$290, parentComponent, callback); + }); + return root$290; +} +function legacyRenderSubtreeIntoContainer( + parentComponent, + children, + container, + forceHydrate, + callback +) { + var maybeRoot = container._reactRootContainer; + if (maybeRoot) { + var root = maybeRoot; + if ("function" === typeof callback) { + var originalCallback = callback; + callback = function () { + var instance = getPublicRootInstance(root); + originalCallback.call(instance); + }; + } + updateContainer(children, root, parentComponent, callback); + } else + root = legacyCreateRootFromDOMContainer( + container, + children, + parentComponent, + callback, + forceHydrate + ); + return getPublicRootInstance(root); +} assign(Internals, { ReactBrowserEventEmitter: { isEnabled: function () { @@ -17470,6 +17605,8 @@ exports.createRoot = function (container, options) { var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null; null !== options && @@ -17479,6 +17616,9 @@ exports.createRoot = function (container, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17492,6 +17632,8 @@ exports.createRoot = function (container, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -17649,6 +17791,8 @@ exports.hydrateRoot = function (container, children, options) { var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null, formState = null; @@ -17659,6 +17803,9 @@ exports.hydrateRoot = function (container, children, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17673,6 +17820,8 @@ exports.hydrateRoot = function (container, children, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -17825,7 +17974,7 @@ exports.unmountComponentAtNode = function (container) { throw Error(formatProdErrorMessage(299)); return container._reactRootContainer ? (flushSync$1(function () { - legacyRenderSubtreeIntoContainer( + legacyRenderSubtreeIntoContainer$1( null, null, container, @@ -17879,7 +18028,7 @@ exports.unstable_renderSubtreeIntoContainer = function ( throw Error(formatProdErrorMessage(299)); if (null == parentComponent || void 0 === parentComponent._reactInternals) throw Error(formatProdErrorMessage(38)); - return legacyRenderSubtreeIntoContainer( + return legacyRenderSubtreeIntoContainer$1( parentComponent, element, containerNode, @@ -17898,4 +18047,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactCurrentDispatcher$2.current.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-classic-4f8b066b"; +exports.version = "19.0.0-www-classic-4d284a43"; diff --git a/compiled/facebook-www/ReactDOMTesting-prod.modern.js b/compiled/facebook-www/ReactDOMTesting-prod.modern.js index 5aee272fbbe2f..bbe67b80e92a9 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.modern.js @@ -4864,9 +4864,6 @@ function createCapturedValueFromError(value, digest, stack) { digest: null != digest ? digest : null }; } -var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); -if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog) - throw Error(formatProdErrorMessage(320)); var reportGlobalError = "function" === typeof reportError ? reportError @@ -4896,53 +4893,68 @@ var reportGlobalError = } console.error(error); }; -function logCapturedError(boundary, errorInfo) { +function defaultOnUncaughtError(error) { + reportGlobalError(error); +} +function defaultOnCaughtError(error) { + console.error(error); +} +function defaultOnRecoverableError(error) { + reportGlobalError(error); +} +function logUncaughtError(root, errorInfo) { try { - if ( - !1 !== - ReactFiberErrorDialogWWW.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) - ) { - var error = errorInfo.value; - 3 === boundary.tag ? reportGlobalError(error) : console.error(error); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(errorInfo.value, { componentStack: errorInfo.stack }); } catch (e) { setTimeout(function () { throw e; }); } } -function createRootErrorUpdate(fiber, errorInfo, lane) { +function logCaughtError(root, boundary, errorInfo) { + try { + var onCaughtError = root.onCaughtError; + onCaughtError(errorInfo.value, { + componentStack: errorInfo.stack, + errorBoundary: 1 === boundary.tag ? boundary.stateNode : null + }); + } catch (e) { + setTimeout(function () { + throw e; + }); + } +} +function createRootErrorUpdate(root, errorInfo, lane) { lane = createUpdate(lane); lane.tag = 3; lane.payload = { element: null }; lane.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return lane; } -function createClassErrorUpdate(fiber, errorInfo, lane) { +function createClassErrorUpdate(lane) { lane = createUpdate(lane); lane.tag = 3; + return lane; +} +function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error = errorInfo.value; - lane.payload = function () { + update.payload = function () { return getDerivedStateFromError(error); }; - lane.callback = function () { - logCapturedError(fiber, errorInfo); + update.callback = function () { + logCaughtError(root, fiber, errorInfo); }; } var inst = fiber.stateNode; null !== inst && "function" === typeof inst.componentDidCatch && - (lane.callback = function () { - logCapturedError(fiber, errorInfo); + (update.callback = function () { + logCaughtError(root, fiber, errorInfo); "function" !== typeof getDerivedStateFromError && (null === legacyErrorBoundariesThatAlreadyFailed ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) @@ -4952,7 +4964,6 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { componentStack: null !== stack ? stack : "" }); }); - return lane; } function markSuspenseBoundaryShouldCapture( suspenseBoundary, @@ -4994,83 +5005,76 @@ function throwException( "object" === typeof value && "function" === typeof value.then ) { - if (enableLazyContextPropagation) { - var currentSourceFiber = sourceFiber.alternate; - null !== currentSourceFiber && - propagateParentContextChanges( - currentSourceFiber, - sourceFiber, - rootRenderLanes, - !0 - ); - } - currentSourceFiber = sourceFiber.tag; + var wakeable = value; + enableLazyContextPropagation && + ((value = sourceFiber.alternate), + null !== value && + propagateParentContextChanges(value, sourceFiber, rootRenderLanes, !0)); + value = sourceFiber.tag; 0 !== (sourceFiber.mode & 1) || - (0 !== currentSourceFiber && - 11 !== currentSourceFiber && - 15 !== currentSourceFiber) || - ((currentSourceFiber = sourceFiber.alternate) - ? ((sourceFiber.updateQueue = currentSourceFiber.updateQueue), - (sourceFiber.memoizedState = currentSourceFiber.memoizedState), - (sourceFiber.lanes = currentSourceFiber.lanes)) + (0 !== value && 11 !== value && 15 !== value) || + ((value = sourceFiber.alternate) + ? ((sourceFiber.updateQueue = value.updateQueue), + (sourceFiber.memoizedState = value.memoizedState), + (sourceFiber.lanes = value.lanes)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null))); - currentSourceFiber = suspenseHandlerStackCursor.current; - if (null !== currentSourceFiber) { - switch (currentSourceFiber.tag) { + value = suspenseHandlerStackCursor.current; + if (null !== value) { + switch (value.tag) { case 13: return ( sourceFiber.mode & 1 && (null === shellBoundary ? renderDidSuspendDelayIfPossible() - : null === currentSourceFiber.alternate && + : null === value.alternate && 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 3)), - (currentSourceFiber.flags &= -257), + (value.flags &= -257), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + value, returnFiber, sourceFiber, root, rootRenderLanes ), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber - ? (currentSourceFiber.updateQueue = new Set([value])) - : returnFiber.add(value), - currentSourceFiber.mode & 1 && - attachPingListener(root, value, rootRenderLanes)), + ? (value.updateQueue = new Set([wakeable])) + : returnFiber.add(wakeable), + value.mode & 1 && + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); case 22: - if (currentSourceFiber.mode & 1) + if (value.mode & 1) return ( - (currentSourceFiber.flags |= 65536), - value === noopSuspenseyCommitThenable - ? (currentSourceFiber.flags |= 16384) - : ((returnFiber = currentSourceFiber.updateQueue), + (value.flags |= 65536), + wakeable === noopSuspenseyCommitThenable + ? (value.flags |= 16384) + : ((returnFiber = value.updateQueue), null === returnFiber ? ((returnFiber = { transitions: null, markerInstances: null, - retryQueue: new Set([value]) + retryQueue: new Set([wakeable]) }), - (currentSourceFiber.updateQueue = returnFiber)) + (value.updateQueue = returnFiber)) : ((sourceFiber = returnFiber.retryQueue), null === sourceFiber - ? (returnFiber.retryQueue = new Set([value])) - : sourceFiber.add(value)), - attachPingListener(root, value, rootRenderLanes)), + ? (returnFiber.retryQueue = new Set([wakeable])) + : sourceFiber.add(wakeable)), + attachPingListener(root, wakeable, rootRenderLanes)), !1 ); } - throw Error(formatProdErrorMessage(435, currentSourceFiber.tag)); + throw Error(formatProdErrorMessage(435, value.tag)); } if (1 === root.tag) return ( - attachPingListener(root, value, rootRenderLanes), + attachPingListener(root, wakeable, rootRenderLanes), renderDidSuspendDelayIfPossible(), !1 ); @@ -5079,14 +5083,12 @@ function throwException( if ( isHydrating && sourceFiber.mode & 1 && - ((currentSourceFiber = suspenseHandlerStackCursor.current), - null !== currentSourceFiber) + ((wakeable = suspenseHandlerStackCursor.current), null !== wakeable) ) return ( - 0 === (currentSourceFiber.flags & 65536) && - (currentSourceFiber.flags |= 256), + 0 === (wakeable.flags & 65536) && (wakeable.flags |= 256), markSuspenseBoundaryShouldCapture( - currentSourceFiber, + wakeable, returnFiber, sourceFiber, root, @@ -5095,57 +5097,58 @@ function throwException( queueHydrationError(createCapturedValueAtFiber(value, sourceFiber)), !1 ); - root = value = createCapturedValueAtFiber(value, sourceFiber); + wakeable = value = createCapturedValueAtFiber(value, sourceFiber); 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); null === workInProgressRootConcurrentErrors - ? (workInProgressRootConcurrentErrors = [root]) - : workInProgressRootConcurrentErrors.push(root); + ? (workInProgressRootConcurrentErrors = [wakeable]) + : workInProgressRootConcurrentErrors.push(wakeable); if (null === returnFiber) return !0; - root = returnFiber; + wakeable = returnFiber; do { - switch (root.tag) { + switch (wakeable.tag) { case 3: return ( - (root.flags |= 65536), + (root = value), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createRootErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (root = createRootErrorUpdate( + wakeable.stateNode, root, - value, rootRenderLanes )), - enqueueCapturedUpdate(root, rootRenderLanes), + enqueueCapturedUpdate(wakeable, root), !1 ); case 1: + returnFiber = value; + sourceFiber = wakeable.type; + var instance = wakeable.stateNode; if ( - ((returnFiber = value), - (sourceFiber = root.type), - (currentSourceFiber = root.stateNode), - 0 === (root.flags & 128) && - ("function" === typeof sourceFiber.getDerivedStateFromError || - (null !== currentSourceFiber && - "function" === typeof currentSourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - currentSourceFiber - ))))) + 0 === (wakeable.flags & 128) && + ("function" === typeof sourceFiber.getDerivedStateFromError || + (null !== instance && + "function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) return ( - (root.flags |= 65536), + (wakeable.flags |= 65536), (rootRenderLanes &= -rootRenderLanes), - (root.lanes |= rootRenderLanes), - (rootRenderLanes = createClassErrorUpdate( + (wakeable.lanes |= rootRenderLanes), + (rootRenderLanes = createClassErrorUpdate(rootRenderLanes)), + initializeClassErrorUpdate( + rootRenderLanes, root, - returnFiber, - rootRenderLanes - )), - enqueueCapturedUpdate(root, rootRenderLanes), + wakeable, + returnFiber + ), + enqueueCapturedUpdate(wakeable, rootRenderLanes), !1 ); } - root = root.return; - } while (null !== root); + wakeable = wakeable.return; + } while (null !== wakeable); return !1; } function processTransitionCallbacks(pendingTransitions, endTime, callbacks) { @@ -11410,8 +11413,8 @@ function handleThrow(root, thrownValue) { workInProgressThrownValue = thrownValue; null === workInProgress && ((workInProgressRootExitStatus = 1), - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) )); } @@ -11682,8 +11685,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { ) ) { workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -11692,8 +11695,8 @@ function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) { } catch (error) { if (null !== returnFiber) throw ((workInProgress = returnFiber), error); workInProgressRootExitStatus = 1; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); workInProgress = null; @@ -11954,7 +11957,7 @@ function flushPassiveEffectsImpl() { } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 2); + sourceFiber = createRootErrorUpdate(rootFiber.stateNode, sourceFiber, 2); rootFiber = enqueueUpdate(rootFiber, sourceFiber, 2); null !== rootFiber && (markRootUpdated(rootFiber, 2), ensureRootIsScheduled(rootFiber)); @@ -11981,19 +11984,17 @@ function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValueAtFiber(error, sourceFiber); - sourceFiber = createClassErrorUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - nearestMountedAncestor = enqueueUpdate( - nearestMountedAncestor, - sourceFiber, - 2 - ); - null !== nearestMountedAncestor && - (markRootUpdated(nearestMountedAncestor, 2), - ensureRootIsScheduled(nearestMountedAncestor)); + error = createClassErrorUpdate(2); + instance = enqueueUpdate(nearestMountedAncestor, error, 2); + null !== instance && + (initializeClassErrorUpdate( + error, + instance, + nearestMountedAncestor, + sourceFiber + ), + markRootUpdated(instance, 2), + ensureRootIsScheduled(instance)); break; } } @@ -12400,6 +12401,8 @@ function FiberRootNode( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -12431,6 +12434,8 @@ function FiberRootNode( this.entanglements = createLaneMap(0); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; this.pooledCache = null; this.pooledCacheLanes = 0; @@ -12456,6 +12461,8 @@ function createFiberRoot( isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -12465,6 +12472,8 @@ function createFiberRoot( tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -16884,9 +16893,6 @@ function insertStylesheetIntoRoot(root, resource) { resource.state.loading |= 4; } } -function defaultOnRecoverableError(error) { - reportGlobalError(error); -} function ReactDOMRoot(internalRoot) { this._internalRoot = internalRoot; } @@ -16974,7 +16980,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1715 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "19.0.0-www-modern-1cfb690a", + version: "19.0.0-www-modern-b404b762", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2118 = { @@ -17005,7 +17011,7 @@ var internals$jscomp$inline_2118 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-www-modern-1cfb690a" + reconcilerVersion: "19.0.0-www-modern-b404b762" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2119 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -17020,6 +17026,8 @@ if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { (injectedHook = hook$jscomp$inline_2119); } catch (err) {} } +if ("function" !== typeof require("ReactFiberErrorDialog").showErrorDialog) + throw Error(formatProdErrorMessage(320)); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; exports.createComponentSelector = function (component) { return { $$typeof: COMPONENT_TYPE, value: component }; @@ -17041,6 +17049,8 @@ exports.createRoot = function (container, options) { var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null; null !== options && @@ -17050,6 +17060,9 @@ exports.createRoot = function (container, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17063,6 +17076,8 @@ exports.createRoot = function (container, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -17205,6 +17220,8 @@ exports.hydrateRoot = function (container, children, options) { var isStrictMode = !1, concurrentUpdatesByDefaultOverride = !1, identifierPrefix = "", + onUncaughtError = defaultOnUncaughtError, + onCaughtError = defaultOnCaughtError, onRecoverableError = defaultOnRecoverableError, transitionCallbacks = null, formState = null; @@ -17215,6 +17232,9 @@ exports.hydrateRoot = function (container, children, options) { (concurrentUpdatesByDefaultOverride = !0), void 0 !== options.identifierPrefix && (identifierPrefix = options.identifierPrefix), + void 0 !== options.onUncaughtError && + (onUncaughtError = options.onUncaughtError), + void 0 !== options.onCaughtError && (onCaughtError = options.onCaughtError), void 0 !== options.onRecoverableError && (onRecoverableError = options.onRecoverableError), void 0 !== options.unstable_transitionCallbacks && @@ -17229,6 +17249,8 @@ exports.hydrateRoot = function (container, children, options) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -17414,4 +17436,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactCurrentDispatcher$2.current.useHostTransitionStatus(); }; -exports.version = "19.0.0-www-modern-1cfb690a"; +exports.version = "19.0.0-www-modern-b404b762"; diff --git a/compiled/facebook-www/ReactTestRenderer-dev.classic.js b/compiled/facebook-www/ReactTestRenderer-dev.classic.js index 755a97706a6d3..9bbb9915dff56 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.classic.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.classic.js @@ -13107,26 +13107,6 @@ if (__DEV__) { }; } - var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); - - if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { - throw new Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); - } - - function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; - return ReactFiberErrorDialogWWW.showErrorDialog(capturedError); - } - var reportGlobalError = typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, ? // emulating an uncaught JavaScript error. @@ -13166,86 +13146,111 @@ if (__DEV__) { console["error"](error); }; - var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; - function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API - if (logError === false) { - return; + var componentName = null; + var errorBoundaryName = null; + function defaultOnUncaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // For uncaught root errors we report them as uncaught to the browser's + // onerror callback. This won't have component stacks and the error addendum. + // So we add those into a separate console.warn. + reportGlobalError(error); + + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "An error occurred in the <" + componentName + "> component:" + : "An error occurred in one of your React components:"; + console["warn"]( + "%s\n%s\n\n%s", + componentNameMessage, + componentStack || "", + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." + ); + } + } + function defaultOnCaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // Caught by error boundary + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; // In development, we provide our own message which includes the component stack + // in addition to the error. + // Don't transform to our wrapper + + console["error"]( + "%o\n\n%s\n%s\n\n%s", + error, + componentNameMessage, + componentStack, + "React will try to recreate this component tree from scratch " + + ("using the error boundary you provided, " + + (errorBoundaryName || "Anonymous") + + ".") + ); + } + } + function defaultOnRecoverableError(error, errorInfo) { + reportGlobalError(error); + } + function logUncaughtError(root, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = null; } var error = errorInfo.value; - if (boundary.tag === HostRoot) { - if (true && ReactCurrentActQueue$2.current !== null) { - // For uncaught errors inside act, we track them on the act and then - // rethrow them into the test. - ReactCurrentActQueue$2.thrownErrors.push(error); - return; - } // For uncaught root errors we report them as uncaught to the browser's - // onerror callback. This won't have component stacks and the error addendum. - // So we add those into a separate console.warn. - - reportGlobalError(error); + if (true && ReactCurrentActQueue$2.current !== null) { + // For uncaught errors inside act, we track them on the act and then + // rethrow them into the test. + ReactCurrentActQueue$2.thrownErrors.push(error); + return; + } - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var componentName = source - ? getComponentNameFromFiber(source) - : null; - var componentNameMessage = componentName - ? "An error occurred in the <" + componentName + "> component:" - : "An error occurred in one of your React components:"; - console["warn"]( - "%s\n%s\n\n%s", - componentNameMessage, - componentStack, - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." - ); - } - } else { - // Caught by error boundary - if (true) { - var _source = errorInfo.source; - var _stack = errorInfo.stack; - - var _componentStack = _stack !== null ? _stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var _componentName = _source - ? getComponentNameFromFiber(_source) - : null; - - var _componentNameMessage = _componentName - ? "The above error occurred in the <" + - _componentName + - "> component:" - : "The above error occurred in one of your React components:"; - - var errorBoundaryName = - getComponentNameFromFiber(boundary) || "Anonymous"; // In development, we provide our own message which includes the component stack - // in addition to the error. - // Don't transform to our wrapper - - console["error"]( - "%o\n\n%s\n%s\n\n%s", - error, - _componentNameMessage, - _componentStack, - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + - errorBoundaryName + - ".") - ); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(error, { + componentStack: errorInfo.stack + }); + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function () { + throw e; + }); + } + } + function logCaughtError(root, boundary, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = getComponentNameFromFiber(boundary); } + + var error = errorInfo.value; + var onCaughtError = root.onCaughtError; + onCaughtError(error, { + componentStack: errorInfo.stack, + errorBoundary: + boundary.tag === ClassComponent + ? boundary.stateNode // This should always be the case as long as we only have class boundaries + : null + }); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -13257,7 +13262,7 @@ if (__DEV__) { } } - function createRootErrorUpdate(fiber, errorInfo, lane) { + function createRootErrorUpdate(root, errorInfo, lane) { var update = createUpdate(lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property @@ -13268,15 +13273,19 @@ if (__DEV__) { }; update.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return update; } - function createClassErrorUpdate(fiber, errorInfo, lane) { + function createClassErrorUpdate(lane) { var update = createUpdate(lane); update.tag = CaptureUpdate; + return update; + } + + function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { @@ -13291,7 +13300,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); }; } @@ -13304,7 +13313,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, @@ -13337,8 +13346,6 @@ if (__DEV__) { } }; } - - return update; } function resetSuspendedComponent(sourceFiber, rootRenderLanes) { @@ -13675,7 +13682,7 @@ if (__DEV__) { var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); var update = createRootErrorUpdate( - workInProgress, + workInProgress.stateNode, _errorInfo, lane ); @@ -13702,12 +13709,14 @@ if (__DEV__) { workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update = createClassErrorUpdate( + var _update = createClassErrorUpdate(_lane); + + initializeClassErrorUpdate( + _update, + root, workInProgress, - errorInfo, - _lane + errorInfo ); - enqueueCapturedUpdate(workInProgress, _update); return false; } @@ -14466,10 +14475,20 @@ if (__DEV__) { var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state - var update = createClassErrorUpdate( + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var update = createClassErrorUpdate(lane); + initializeClassErrorUpdate( + update, + root, workInProgress, - createCapturedValueAtFiber(error$1, workInProgress), - lane + createCapturedValueAtFiber(error$1, workInProgress) ); enqueueCapturedUpdate(workInProgress, update); break; @@ -23686,8 +23705,8 @@ if (__DEV__) { if (erroredWork === null) { // This is a fatal error workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); return; @@ -24406,10 +24425,7 @@ if (__DEV__) { // caught by an error boundary. This is a fatal error, or panic condition, // because we've run out of ways to recover. workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, - createCapturedValueAtFiber(error, root.current) - ); // Set `workInProgress` to null. This represents advancing to the next + logUncaughtError(root, createCapturedValueAtFiber(error, root.current)); // Set `workInProgress` to null. This represents advancing to the next // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're @@ -25033,7 +25049,11 @@ if (__DEV__) { function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValueAtFiber(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate( + rootFiber.stateNode, + errorInfo, + SyncLane + ); var root = enqueueUpdate(rootFiber, update, SyncLane); if (root !== null) { @@ -25074,10 +25094,11 @@ if (__DEV__) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValueAtFiber(error$1, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate(SyncLane); var root = enqueueUpdate(fiber, update, SyncLane); if (root !== null) { + initializeClassErrorUpdate(update, root, fiber, errorInfo); markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } @@ -26667,6 +26688,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -26695,6 +26718,8 @@ if (__DEV__) { this.entanglements = createLaneMap(NoLanes); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; { @@ -26739,6 +26764,8 @@ if (__DEV__) { // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -26749,6 +26776,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -26790,7 +26819,7 @@ if (__DEV__) { return root; } - var ReactVersion = "19.0.0-www-classic-e5e51a68"; + var ReactVersion = "19.0.0-www-classic-44eec7ba"; // Might add PROFILE later. @@ -26826,6 +26855,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ) { @@ -26840,6 +26871,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -27674,12 +27707,6 @@ if (__DEV__) { } return true; - } // $FlowFixMe[missing-local-annot] - - function onRecoverableError(error$1) { - // TODO: Expose onRecoverableError option to userspace - // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args - error(error$1); } function create(element, options) { @@ -27723,7 +27750,9 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefault, "", - onRecoverableError, + defaultOnUncaughtError, + defaultOnCaughtError, + defaultOnRecoverableError, null ); diff --git a/compiled/facebook-www/ReactTestRenderer-dev.modern.js b/compiled/facebook-www/ReactTestRenderer-dev.modern.js index 1de804a0a824d..212463d3643c1 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.modern.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.modern.js @@ -13107,26 +13107,6 @@ if (__DEV__) { }; } - var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog"); - - if (typeof ReactFiberErrorDialogWWW.showErrorDialog !== "function") { - throw new Error( - "Expected ReactFiberErrorDialog.showErrorDialog to be a function." - ); - } - - function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; - return ReactFiberErrorDialogWWW.showErrorDialog(capturedError); - } - var reportGlobalError = typeof reportError === "function" // In modern browsers, reportError will dispatch an error event, ? // emulating an uncaught JavaScript error. @@ -13166,86 +13146,111 @@ if (__DEV__) { console["error"](error); }; - var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; - function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. + var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // Side-channel since I'm not sure we want to make this part of the public API - if (logError === false) { - return; + var componentName = null; + var errorBoundaryName = null; + function defaultOnUncaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // For uncaught root errors we report them as uncaught to the browser's + // onerror callback. This won't have component stacks and the error addendum. + // So we add those into a separate console.warn. + reportGlobalError(error); + + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "An error occurred in the <" + componentName + "> component:" + : "An error occurred in one of your React components:"; + console["warn"]( + "%s\n%s\n\n%s", + componentNameMessage, + componentStack || "", + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." + ); + } + } + function defaultOnCaughtError(error, errorInfo) { + // Overriding this can silence these warnings e.g. for tests. + // See https://github.com/facebook/react/pull/13384 + // Caught by error boundary + { + var componentStack = + errorInfo.componentStack != null ? errorInfo.componentStack : ""; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; // In development, we provide our own message which includes the component stack + // in addition to the error. + // Don't transform to our wrapper + + console["error"]( + "%o\n\n%s\n%s\n\n%s", + error, + componentNameMessage, + componentStack, + "React will try to recreate this component tree from scratch " + + ("using the error boundary you provided, " + + (errorBoundaryName || "Anonymous") + + ".") + ); + } + } + function defaultOnRecoverableError(error, errorInfo) { + reportGlobalError(error); + } + function logUncaughtError(root, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = null; } var error = errorInfo.value; - if (boundary.tag === HostRoot) { - if (true && ReactCurrentActQueue$2.current !== null) { - // For uncaught errors inside act, we track them on the act and then - // rethrow them into the test. - ReactCurrentActQueue$2.thrownErrors.push(error); - return; - } // For uncaught root errors we report them as uncaught to the browser's - // onerror callback. This won't have component stacks and the error addendum. - // So we add those into a separate console.warn. - - reportGlobalError(error); + if (true && ReactCurrentActQueue$2.current !== null) { + // For uncaught errors inside act, we track them on the act and then + // rethrow them into the test. + ReactCurrentActQueue$2.thrownErrors.push(error); + return; + } - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var componentName = source - ? getComponentNameFromFiber(source) - : null; - var componentNameMessage = componentName - ? "An error occurred in the <" + componentName + "> component:" - : "An error occurred in one of your React components:"; - console["warn"]( - "%s\n%s\n\n%s", - componentNameMessage, - componentStack, - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://react.dev/link/error-boundaries to learn more about error boundaries." - ); - } - } else { - // Caught by error boundary - if (true) { - var _source = errorInfo.source; - var _stack = errorInfo.stack; - - var _componentStack = _stack !== null ? _stack : ""; // TODO: There's no longer a way to silence these warnings e.g. for tests. - // See https://github.com/facebook/react/pull/13384 - - var _componentName = _source - ? getComponentNameFromFiber(_source) - : null; - - var _componentNameMessage = _componentName - ? "The above error occurred in the <" + - _componentName + - "> component:" - : "The above error occurred in one of your React components:"; - - var errorBoundaryName = - getComponentNameFromFiber(boundary) || "Anonymous"; // In development, we provide our own message which includes the component stack - // in addition to the error. - // Don't transform to our wrapper - - console["error"]( - "%o\n\n%s\n%s\n\n%s", - error, - _componentNameMessage, - _componentStack, - "React will try to recreate this component tree from scratch " + - ("using the error boundary you provided, " + - errorBoundaryName + - ".") - ); - } + var onUncaughtError = root.onUncaughtError; + onUncaughtError(error, { + componentStack: errorInfo.stack + }); + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function () { + throw e; + }); + } + } + function logCaughtError(root, boundary, errorInfo) { + try { + if (true) { + componentName = errorInfo.source + ? getComponentNameFromFiber(errorInfo.source) + : null; + errorBoundaryName = getComponentNameFromFiber(boundary); } + + var error = errorInfo.value; + var onCaughtError = root.onCaughtError; + onCaughtError(error, { + componentStack: errorInfo.stack, + errorBoundary: + boundary.tag === ClassComponent + ? boundary.stateNode // This should always be the case as long as we only have class boundaries + : null + }); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -13257,7 +13262,7 @@ if (__DEV__) { } } - function createRootErrorUpdate(fiber, errorInfo, lane) { + function createRootErrorUpdate(root, errorInfo, lane) { var update = createUpdate(lane); // Unmount the root by rendering null. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property @@ -13268,15 +13273,19 @@ if (__DEV__) { }; update.callback = function () { - logCapturedError(fiber, errorInfo); + logUncaughtError(root, errorInfo); }; return update; } - function createClassErrorUpdate(fiber, errorInfo, lane) { + function createClassErrorUpdate(lane) { var update = createUpdate(lane); update.tag = CaptureUpdate; + return update; + } + + function initializeClassErrorUpdate(update, root, fiber, errorInfo) { var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if (typeof getDerivedStateFromError === "function") { @@ -13291,7 +13300,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); }; } @@ -13304,7 +13313,7 @@ if (__DEV__) { markFailedErrorBoundaryForHotReloading(fiber); } - logCapturedError(fiber, errorInfo); + logCaughtError(root, fiber, errorInfo); if (typeof getDerivedStateFromError !== "function") { // To preserve the preexisting retry behavior of error boundaries, @@ -13337,8 +13346,6 @@ if (__DEV__) { } }; } - - return update; } function resetSuspendedComponent(sourceFiber, rootRenderLanes) { @@ -13675,7 +13682,7 @@ if (__DEV__) { var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); var update = createRootErrorUpdate( - workInProgress, + workInProgress.stateNode, _errorInfo, lane ); @@ -13702,12 +13709,14 @@ if (__DEV__) { workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update = createClassErrorUpdate( + var _update = createClassErrorUpdate(_lane); + + initializeClassErrorUpdate( + _update, + root, workInProgress, - errorInfo, - _lane + errorInfo ); - enqueueCapturedUpdate(workInProgress, _update); return false; } @@ -14466,10 +14475,20 @@ if (__DEV__) { var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state - var update = createClassErrorUpdate( + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); + } + + var update = createClassErrorUpdate(lane); + initializeClassErrorUpdate( + update, + root, workInProgress, - createCapturedValueAtFiber(error$1, workInProgress), - lane + createCapturedValueAtFiber(error$1, workInProgress) ); enqueueCapturedUpdate(workInProgress, update); break; @@ -23686,8 +23705,8 @@ if (__DEV__) { if (erroredWork === null) { // This is a fatal error workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, + logUncaughtError( + root, createCapturedValueAtFiber(thrownValue, root.current) ); return; @@ -24406,10 +24425,7 @@ if (__DEV__) { // caught by an error boundary. This is a fatal error, or panic condition, // because we've run out of ways to recover. workInProgressRootExitStatus = RootFatalErrored; - logCapturedError( - root.current, - createCapturedValueAtFiber(error, root.current) - ); // Set `workInProgress` to null. This represents advancing to the next + logUncaughtError(root, createCapturedValueAtFiber(error, root.current)); // Set `workInProgress` to null. This represents advancing to the next // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're @@ -25033,7 +25049,11 @@ if (__DEV__) { function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValueAtFiber(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate( + rootFiber.stateNode, + errorInfo, + SyncLane + ); var root = enqueueUpdate(rootFiber, update, SyncLane); if (root !== null) { @@ -25074,10 +25094,11 @@ if (__DEV__) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValueAtFiber(error$1, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate(SyncLane); var root = enqueueUpdate(fiber, update, SyncLane); if (root !== null) { + initializeClassErrorUpdate(update, root, fiber, errorInfo); markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } @@ -26667,6 +26688,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ) { @@ -26695,6 +26718,8 @@ if (__DEV__) { this.entanglements = createLaneMap(NoLanes); this.hiddenUpdates = createLaneMap(null); this.identifierPrefix = identifierPrefix; + this.onUncaughtError = onUncaughtError; + this.onCaughtError = onCaughtError; this.onRecoverableError = onRecoverableError; { @@ -26739,6 +26764,8 @@ if (__DEV__) { // them through the root constructor. Perhaps we should put them all into a // single type, like a DynamicHostConfig that is defined by the renderer. identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, formState @@ -26749,6 +26776,8 @@ if (__DEV__) { tag, hydrate, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, formState ); @@ -26790,7 +26819,7 @@ if (__DEV__) { return root; } - var ReactVersion = "19.0.0-www-modern-e5e51a68"; + var ReactVersion = "19.0.0-www-modern-44eec7ba"; // Might add PROFILE later. @@ -26826,6 +26855,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks ) { @@ -26840,6 +26871,8 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, + onUncaughtError, + onCaughtError, onRecoverableError, transitionCallbacks, null @@ -27674,12 +27707,6 @@ if (__DEV__) { } return true; - } // $FlowFixMe[missing-local-annot] - - function onRecoverableError(error$1) { - // TODO: Expose onRecoverableError option to userspace - // eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args - error(error$1); } function create(element, options) { @@ -27723,7 +27750,9 @@ if (__DEV__) { isStrictMode, concurrentUpdatesByDefault, "", - onRecoverableError, + defaultOnUncaughtError, + defaultOnCaughtError, + defaultOnRecoverableError, null );