diff --git a/.github/.react-version b/.github/.react-version index fb6823b755076..2de43dcf77c1f 100644 --- a/.github/.react-version +++ b/.github/.react-version @@ -1 +1 @@ -19.0.0-rc-76002254-20240724 \ No newline at end of file +19.0.0-rc-6230622a1a-20240610 \ No newline at end of file diff --git a/examples/reproduction-template/package.json b/examples/reproduction-template/package.json index a457d72ebd894..9c0776817d8a6 100644 --- a/examples/reproduction-template/package.json +++ b/examples/reproduction-template/package.json @@ -7,8 +7,8 @@ }, "dependencies": { "next": "canary", - "react": "19.0.0-rc-76002254-20240724", - "react-dom": "19.0.0-rc-76002254-20240724" + "react": "19.0.0-rc.0", + "react-dom": "19.0.0-rc.0" }, "devDependencies": { "@types/node": "20.12.12", diff --git a/package.json b/package.json index b5e7cb6ff7c03..2a4e99aad939b 100644 --- a/package.json +++ b/package.json @@ -200,19 +200,19 @@ "pretty-bytes": "5.3.0", "pretty-ms": "7.0.0", "random-seed": "0.3.0", - "react": "19.0.0-rc-76002254-20240724", + "react": "19.0.0-rc-6230622a1a-20240610", "react-17": "npm:react@17.0.2", - "react-builtin": "npm:react@19.0.0-rc-76002254-20240724", - "react-dom": "19.0.0-rc-76002254-20240724", + "react-builtin": "npm:react@19.0.0-rc-6230622a1a-20240610", + "react-dom": "19.0.0-rc-6230622a1a-20240610", "react-dom-17": "npm:react-dom@17.0.2", - "react-dom-builtin": "npm:react-dom@19.0.0-rc-76002254-20240724", - "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-76002254-20240724", - "react-experimental-builtin": "npm:react@0.0.0-experimental-76002254-20240724", - "react-is-builtin": "npm:react-is@19.0.0-rc-76002254-20240724", - "react-server-dom-turbopack": "19.0.0-rc-76002254-20240724", - "react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-76002254-20240724", - "react-server-dom-webpack": "19.0.0-rc-76002254-20240724", - "react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-76002254-20240724", + "react-dom-builtin": "npm:react-dom@19.0.0-rc-6230622a1a-20240610", + "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-6230622a1a-20240610", + "react-experimental-builtin": "npm:react@0.0.0-experimental-6230622a1a-20240610", + "react-is-builtin": "npm:react-is@19.0.0-rc-6230622a1a-20240610", + "react-server-dom-turbopack": "19.0.0-rc-6230622a1a-20240610", + "react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-6230622a1a-20240610", + "react-server-dom-webpack": "19.0.0-rc-6230622a1a-20240610", + "react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-6230622a1a-20240610", "react-ssr-prepass": "1.0.8", "react-virtualized": "9.22.3", "relay-compiler": "13.0.2", @@ -222,8 +222,8 @@ "resolve-from": "5.0.0", "sass": "1.54.0", "satori": "0.10.9", - "scheduler-builtin": "npm:scheduler@0.25.0-rc-76002254-20240724", - "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-76002254-20240724", + "scheduler-builtin": "npm:scheduler@0.25.0-rc-6230622a1a-20240610", + "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-6230622a1a-20240610", "seedrandom": "3.0.5", "semver": "7.3.7", "shell-quote": "1.7.3", @@ -263,10 +263,10 @@ "@babel/traverse": "7.22.5", "@types/react": "npm:types-react@19.0.0-rc.0", "@types/react-dom": "npm:types-react-dom@19.0.0-rc.0", - "react": "19.0.0-rc-76002254-20240724", - "react-dom": "19.0.0-rc-76002254-20240724", - "react-is": "19.0.0-rc-76002254-20240724", - "scheduler": "0.25.0-rc-76002254-20240724" + "react": "19.0.0-rc-6230622a1a-20240610", + "react-dom": "19.0.0-rc-6230622a1a-20240610", + "react-is": "19.0.0-rc-6230622a1a-20240610", + "scheduler": "0.25.0-rc-6230622a1a-20240610" }, "patchedDependencies": { "webpack-sources@3.2.3": "patches/webpack-sources@3.2.3.patch" diff --git a/packages/create-next-app/templates/index.ts b/packages/create-next-app/templates/index.ts index 7995c792913d8..1d54f8ae0e63c 100644 --- a/packages/create-next-app/templates/index.ts +++ b/packages/create-next-app/templates/index.ts @@ -184,8 +184,8 @@ export const installTemplate = async ({ * Default dependencies. */ dependencies: { - react: "19.0.0-rc-76002254-20240724", - "react-dom": "19.0.0-rc-76002254-20240724", + react: "19.0.0-rc.0", + "react-dom": "19.0.0-rc.0", next: version, }, devDependencies: {}, diff --git a/packages/next/package.json b/packages/next/package.json index ebb7f9a5002ef..1063450e36dd2 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -106,8 +106,8 @@ "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.41.2", "babel-plugin-react-compiler": "*", - "react": "19.0.0-rc-76002254-20240724", - "react-dom": "19.0.0-rc-76002254-20240724", + "react": "19.0.0-rc.0", + "react-dom": "19.0.0-rc.0", "sass": "^1.3.0" }, "peerDependenciesMeta": { diff --git a/packages/next/src/client/components/react-dev-overlay/internal/helpers/hydration-error-info.ts b/packages/next/src/client/components/react-dev-overlay/internal/helpers/hydration-error-info.ts index f99a6e41c55d0..67f93a4ad3070 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/helpers/hydration-error-info.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/helpers/hydration-error-info.ts @@ -17,10 +17,10 @@ export const hydrationErrorState: HydrationErrorState = {} // https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference const htmlTagsWarnings = new Set([ - 'In HTML, %s cannot be a child of <%s>.%s\nThis will cause a hydration error.%s', - 'In HTML, %s cannot be a descendant of <%s>.\nThis will cause a hydration error.%s', - 'In HTML, text nodes cannot be a child of <%s>.\nThis will cause a hydration error.', - "In HTML, whitespace text nodes cannot be a child of <%s>. Make sure you don't have any extra whitespace between tags on each line of your source code.\nThis will cause a hydration error.", + 'Warning: In HTML, %s cannot be a child of <%s>.%s\nThis will cause a hydration error.%s', + 'Warning: In HTML, %s cannot be a descendant of <%s>.\nThis will cause a hydration error.%s', + 'Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will cause a hydration error.', + "Warning: In HTML, whitespace text nodes cannot be a child of <%s>. Make sure you don't have any extra whitespace between tags on each line of your source code.\nThis will cause a hydration error.", ]) export const getHydrationWarningType = (msg: NullableText): 'tag' | 'text' => { diff --git a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-client.development.js b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-client.development.js index 1bd59d15cf6fb..b1262973216c8 100644 --- a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-client.development.js +++ b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-client.development.js @@ -8,24852 +8,38414 @@ * LICENSE file in the root directory of this source tree. */ -/* - Modernizr 3.0.0pre (Custom Build) | MIT -*/ -"use strict"; -"production" !== process.env.NODE_ENV && - (function () { - function findHook(fiber, id) { - for (fiber = fiber.memoizedState; null !== fiber && 0 < id; ) - (fiber = fiber.next), id--; - return fiber; - } - function copyWithSetImpl(obj, path, index, value) { - if (index >= path.length) return value; - var key = path[index], - updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj); - updated[key] = copyWithSetImpl(obj[key], path, index + 1, value); - return updated; - } - function copyWithRename(obj, oldPath, newPath) { - if (oldPath.length !== newPath.length) - console.warn("copyWithRename() expects paths of the same length"); - else { - for (var i = 0; i < newPath.length - 1; i++) - if (oldPath[i] !== newPath[i]) { - console.warn( - "copyWithRename() expects paths to be the same except for the deepest key" - ); - return; - } - return copyWithRenameImpl(obj, oldPath, newPath, 0); - } - } - function copyWithRenameImpl(obj, oldPath, newPath, index) { - var oldKey = oldPath[index], - updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj); - index + 1 === oldPath.length - ? ((updated[newPath[index]] = updated[oldKey]), - isArrayImpl(updated) - ? updated.splice(oldKey, 1) - : delete updated[oldKey]) - : (updated[oldKey] = copyWithRenameImpl( - obj[oldKey], - oldPath, - newPath, - index + 1 - )); - return updated; - } - function copyWithDeleteImpl(obj, path, index) { - var key = path[index], - updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj); - if (index + 1 === path.length) - return ( - isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], - updated - ); - updated[key] = copyWithDeleteImpl(obj[key], path, index + 1); - return updated; - } - function shouldSuspendImpl() { - return !1; - } - function shouldErrorImpl() { - return null; - } - function createFiber(tag, pendingProps, key, mode) { - return new FiberNode(tag, pendingProps, key, mode); +'use strict'; + +if (process.env.NODE_ENV !== "production") { + (function() { +'use strict'; +if ( + typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && + typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === + 'function' +) { + __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); +} +var React = require("next/dist/compiled/react-experimental"); +var Scheduler = require("next/dist/compiled/scheduler-experimental"); +var ReactDOM = require('react-dom'); + +var ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; + +// ----------------------------------------------------------------------------- +// Killswitch +// +// Flags that exist solely to turn off a change in case it causes a regression +// when it rolls out to prod. We should remove these as soon as possible. +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// Land or remove (moderate effort) +// +// Flags that can be probably deleted or landed, but might require extra effort +// like migrating internal callers or performance testing. +// ----------------------------------------------------------------------------- +// TODO: Finish rolling out in www + +var favorSafetyOverHydrationPerf = true; +var enableAsyncActions = true; // Need to remove didTimeout argument from Scheduler before landing + +var disableDefaultPropsExceptForClasses = true; // ----------------------------------------------------------------------------- +// Slated for removal in the future (significant effort) +// +// These are experiments that didn't work out, and never shipped, but we can't +// delete from the codebase until we migrate internal callers. +// ----------------------------------------------------------------------------- +// Add a callback property to suspense to notify which promises are currently +// in the update queue. This allows reporting and tracing of what is causing +// the user to see a loading state. +// +// Also allows hydration callbacks to fire when a dehydrated boundary gets +// hydrated or deleted. +// +// This will eventually be replaced by the Transition Tracing proposal. + +var enableSuspenseCallback = false; // Experimental Scope support. + +var enableLazyContextPropagation = false; // FB-only usage. The new API has different semantics. + +var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber +var alwaysThrottleRetries = true; +var enableOwnerStacks = true; +var syncLaneExpirationMs = 250; +var transitionLaneExpirationMs = 5000; // ----------------------------------------------------------------------------- +// Remove IE and MsApp specific workarounds for innerHTML + +var disableIEWorkarounds = true; // Filter certain DOM attributes (e.g. src, href) if their values are empty +// This allows us to land breaking changes to remove legacy mode APIs in experimental builds +// before removing them in stable in the next Major + +var disableLegacyMode = true; // Make equivalent to instead of +// React DOM Chopping Block +// +// Similar to main Chopping Block but only flags related to React DOM. These are +// grouped because we will likely batch all of them into a single major release. +// ----------------------------------------------------------------------------- +// Disable support for comment nodes as React DOM containers. Already disabled +// in open source, but www codebase still relies on it. Need to remove. + +var disableCommentsAsDOMContainers = true; +// Debugging and DevTools +// ----------------------------------------------------------------------------- +// Adds user timing marks for e.g. state updates, suspense, and work loop stuff, +// for an experimental timeline tool. + +var enableSchedulingProfiler = true; // Helps identify side effects in render-phase lifecycle hooks and setState + +var enableProfilerTimer = true; // Record durations for commit and passive effects phases. + +var enableProfilerCommitHooks = true; // Phase param passed to onRender callback differentiates between an "update" and a "cascading-update". + +var enableProfilerNestedUpdatePhase = true; // Adds verbose console logging for e.g. state updates, suspense, and work loop + +var suppressWarning = false; +function setSuppressWarning(newSuppressWarning) { + { + suppressWarning = newSuppressWarning; + } +} // In DEV, calls to console.warn and console.error get replaced +// by calls to these methods by a Babel plugin. +// +// In PROD (or in packages without access to React internals), +// they are left as they are instead. + +function warn(format) { + { + if (!suppressWarning) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + printWarning('warn', format, args, new Error('react-stack-top-frame')); } - function warnInvalidHookAccess() { - console.error( - "Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks" - ); + } +} +function error(format) { + { + if (!suppressWarning) { + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + printWarning('error', format, args, new Error('react-stack-top-frame')); } - function warnInvalidContextAccess() { - console.error( - "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." - ); + } +} // eslint-disable-next-line react-internal/no-production-logging + +var supportsCreateTask = !!console.createTask; + +function printWarning(level, format, args, currentStack) { + // When changing this logic, you might want to also + // update consoleWithStackDev.www.js as well. + { + var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; + + if (!supportsCreateTask && ReactSharedInternals.getCurrentStack) { + // We only add the current stack to the console when createTask is not supported. + // Since createTask requires DevTools to be open to work, this means that stacks + // can be lost while DevTools isn't open but we can't detect this. + var stack = ReactSharedInternals.getCurrentStack(currentStack); + + if (stack !== '') { + format += '%s'; + args = args.concat([stack]); + } } - function noop$2() {} - function warnForMissingKey() {} - function setToSortedString(set) { - var array = []; - set.forEach(function (value) { - array.push(value); + + if (isErrorLogger) { + // Don't prefix our default logging formatting in ReactFiberErrorLoggger. + // Don't toString the arguments. + args.unshift(format); + } else { + // TODO: Remove this prefix and stop toStringing in the wrapper and + // instead do it at each callsite as needed. + // Careful: RN currently depends on this prefix + // eslint-disable-next-line react-internal/safe-string-coercion + args = args.map(function (item) { + return String(item); }); - return array.sort().join(", "); - } - function findHostInstancesForRefresh(root, families) { - var hostInstances = new Set(); - families = new Set( - families.map(function (family) { - return family.current; - }) - ); - findHostInstancesForMatchingFibersRecursively( - root.current, - families, - hostInstances - ); - return hostInstances; - } - function scheduleRoot(root, element) { - root.context === emptyContextObject && - (updateContainerSync(element, root, null, null), flushSyncWork$1()); + args.unshift('Warning: ' + format); + } // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + // eslint-disable-next-line react-internal/no-production-logging + + + Function.prototype.apply.call(console[level], console, args); + } +} + +/** + * HTML nodeType values that represent the type of the node + */ +var ELEMENT_NODE = 1; +var TEXT_NODE = 3; +var COMMENT_NODE = 8; +var DOCUMENT_NODE = 9; +var DOCUMENT_TYPE_NODE = 10; +var DOCUMENT_FRAGMENT_NODE = 11; + +function isValidContainer(node) { + return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || !disableCommentsAsDOMContainers )); +} // TODO: Remove this function which also includes comment nodes. + +/** + * `ReactInstanceMap` maintains a mapping from a public facing stateful + * instance (key) and the internal representation (value). This allows public + * methods to accept the user facing instance as an argument and map them back + * to internal methods. + * + * Note that this module is currently shared and assumed to be stateless. + * If this becomes an actual Map, that will break. + */ +function get(key) { + return key._reactInternals; +} +function set(key, value) { + key._reactInternals = value; +} + +var FunctionComponent = 0; +var ClassComponent = 1; +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. + +var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. + +var HostComponent = 5; +var HostText = 6; +var Fragment = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; +var DehydratedFragment = 18; +var SuspenseListComponent = 19; +var ScopeComponent = 21; +var OffscreenComponent = 22; +var LegacyHiddenComponent = 23; +var CacheComponent = 24; +var TracingMarkerComponent = 25; +var HostHoistable = 26; +var HostSingleton = 27; +var IncompleteFunctionComponent = 28; + +// When adding new symbols to this file, +// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' +// The Symbol used to tag the ReactElement-like types. + +var REACT_LEGACY_ELEMENT_TYPE = Symbol.for('react.element'); +var REACT_ELEMENT_TYPE = Symbol.for('react.transitional.element') ; +var REACT_PORTAL_TYPE = Symbol.for('react.portal'); +var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); +var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); +var REACT_PROFILER_TYPE = Symbol.for('react.profiler'); +var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); // TODO: Delete with enableRenderableContext + +var REACT_CONSUMER_TYPE = Symbol.for('react.consumer'); +var REACT_CONTEXT_TYPE = Symbol.for('react.context'); +var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); +var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); +var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); +var REACT_MEMO_TYPE = Symbol.for('react.memo'); +var REACT_LAZY_TYPE = Symbol.for('react.lazy'); +var REACT_SCOPE_TYPE = Symbol.for('react.scope'); +var REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for('react.debug_trace_mode'); +var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); +var REACT_LEGACY_HIDDEN_TYPE = Symbol.for('react.legacy_hidden'); +var REACT_TRACING_MARKER_TYPE = Symbol.for('react.tracing_marker'); +var REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel'); +var REACT_POSTPONE_TYPE = Symbol.for('react.postpone'); +var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; +var FAUX_ITERATOR_SYMBOL = '@@iterator'; +function getIteratorFn(maybeIterable) { + if (maybeIterable === null || typeof maybeIterable !== 'object') { + return null; + } + + var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; + + if (typeof maybeIterator === 'function') { + return maybeIterator; + } + + return null; +} +var ASYNC_ITERATOR = Symbol.asyncIterator; + +function getWrappedName$1(outerType, innerType, wrapperName) { + var displayName = outerType.displayName; + + if (displayName) { + return displayName; + } + + var functionName = innerType.displayName || innerType.name || ''; + return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName; +} // Keep in sync with react-reconciler/getComponentNameFromFiber + + +function getContextName$1(type) { + return type.displayName || 'Context'; +} + +var REACT_CLIENT_REFERENCE = Symbol.for('react.client.reference'); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead. + +function getComponentNameFromType(type) { + if (type == null) { + // Host root, text node or just invalid type. + return null; + } + + if (typeof type === 'function') { + if (type.$$typeof === REACT_CLIENT_REFERENCE) { + // TODO: Create a convention for naming client references with debug info. + return null; } - function scheduleRefresh(root, update) { - if (null !== resolveFamily) { - var staleFamilies = update.staleFamilies; - update = update.updatedFamilies; - flushPassiveEffects(); - scheduleFibersWithFamiliesRecursively( - root.current, - update, - staleFamilies - ); - flushSyncWork$1(); + + return type.displayName || type.name || null; + } + + if (typeof type === 'string') { + return type; + } + + switch (type) { + case REACT_FRAGMENT_TYPE: + return 'Fragment'; + + case REACT_PORTAL_TYPE: + return 'Portal'; + + case REACT_PROFILER_TYPE: + return 'Profiler'; + + case REACT_STRICT_MODE_TYPE: + return 'StrictMode'; + + case REACT_SUSPENSE_TYPE: + return 'Suspense'; + + case REACT_SUSPENSE_LIST_TYPE: + return 'SuspenseList'; + + } + + if (typeof type === 'object') { + { + if (typeof type.tag === 'number') { + error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.'); } } - function setRefreshHandler(handler) { - resolveFamily = handler; - } - function isValidContainer(node) { - return !( - !node || - (1 !== node.nodeType && 9 !== node.nodeType && 11 !== node.nodeType) - ); - } - function getIteratorFn(maybeIterable) { - if (null === maybeIterable || "object" !== typeof maybeIterable) - return null; - maybeIterable = - (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || - maybeIterable["@@iterator"]; - return "function" === typeof maybeIterable ? maybeIterable : null; - } - function getComponentNameFromType(type) { - if (null == type) return null; - if ("function" === typeof type) - return type.$$typeof === REACT_CLIENT_REFERENCE - ? null - : type.displayName || type.name || null; - if ("string" === typeof type) return type; - switch (type) { - case REACT_FRAGMENT_TYPE: - return "Fragment"; - case REACT_PORTAL_TYPE: - return "Portal"; - case REACT_PROFILER_TYPE: - return "Profiler"; - case REACT_STRICT_MODE_TYPE: - return "StrictMode"; - case REACT_SUSPENSE_TYPE: - return "Suspense"; - case REACT_SUSPENSE_LIST_TYPE: - return "SuspenseList"; - } - if ("object" === typeof type) - switch ( - ("number" === typeof type.tag && - console.error( - "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue." - ), - type.$$typeof) - ) { - case REACT_CONTEXT_TYPE: - return (type.displayName || "Context") + ".Provider"; - case REACT_CONSUMER_TYPE: - return (type._context.displayName || "Context") + ".Consumer"; - case REACT_FORWARD_REF_TYPE: - var innerType = type.render; - type = type.displayName; - type || - ((type = innerType.displayName || innerType.name || ""), - (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef")); - return type; - case REACT_MEMO_TYPE: - return ( - (innerType = type.displayName || null), - null !== innerType - ? innerType - : getComponentNameFromType(type.type) || "Memo" - ); - case REACT_LAZY_TYPE: - innerType = type._payload; - type = type._init; - try { - return getComponentNameFromType(type(innerType)); - } catch (x) {} + + switch (type.$$typeof) { + case REACT_PROVIDER_TYPE: + { + return null; + } + + case REACT_CONTEXT_TYPE: + var context = type; + + { + return getContextName$1(context) + '.Provider'; + } + + case REACT_CONSUMER_TYPE: + { + var consumer = type; + return getContextName$1(consumer._context) + '.Consumer'; + } + + case REACT_FORWARD_REF_TYPE: + return getWrappedName$1(type, type.render, 'ForwardRef'); + + case REACT_MEMO_TYPE: + var outerName = type.displayName || null; + + if (outerName !== null) { + return outerName; + } + + return getComponentNameFromType(type.type) || 'Memo'; + + case REACT_LAZY_TYPE: + { + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + + try { + return getComponentNameFromType(init(payload)); + } catch (x) { + return null; + } } - return null; - } - function getComponentNameFromOwner(owner) { - return "number" === typeof owner.tag - ? getComponentNameFromFiber(owner) - : "string" === typeof owner.name - ? owner.name - : null; } - function getComponentNameFromFiber(fiber) { - var type = fiber.type; - switch (fiber.tag) { - case 24: - return "Cache"; - case 9: - return (type._context.displayName || "Context") + ".Consumer"; - case 10: - return (type.displayName || "Context") + ".Provider"; - case 18: - return "DehydratedFragment"; - case 11: - return ( - (fiber = type.render), - (fiber = fiber.displayName || fiber.name || ""), - type.displayName || - ("" !== fiber ? "ForwardRef(" + fiber + ")" : "ForwardRef") - ); - case 7: - return "Fragment"; - case 26: - case 27: - case 5: - return type; - case 4: - return "Portal"; - case 3: - return "Root"; - case 6: - return "Text"; - case 16: - return getComponentNameFromType(type); - case 8: - return type === REACT_STRICT_MODE_TYPE ? "StrictMode" : "Mode"; - case 22: - return "Offscreen"; - case 12: - return "Profiler"; - case 21: - return "Scope"; - case 13: - return "Suspense"; - case 19: - return "SuspenseList"; - case 25: - return "TracingMarker"; - case 1: - case 0: - case 14: - case 15: - if ("function" === typeof type) - return type.displayName || type.name || null; - if ("string" === typeof type) return type; - break; - case 29: - type = fiber._debugInfo; - if (null != type) - for (var i = type.length - 1; 0 <= i; i--) - if ("string" === typeof type[i].name) return type[i].name; - if (null !== fiber.return) - return getComponentNameFromFiber(fiber.return); + } + + return null; +} + +function getWrappedName(outerType, innerType, wrapperName) { + var functionName = innerType.displayName || innerType.name || ''; + return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); +} // Keep in sync with shared/getComponentNameFromType + + +function getContextName(type) { + return type.displayName || 'Context'; +} + +function getComponentNameFromOwner(owner) { + if (typeof owner.tag === 'number') { + return getComponentNameFromFiber(owner); + } + + if (typeof owner.name === 'string') { + return owner.name; + } + + return null; +} +function getComponentNameFromFiber(fiber) { + var tag = fiber.tag, + type = fiber.type; + + switch (tag) { + case CacheComponent: + return 'Cache'; + + case ContextConsumer: + { + var consumer = type; + return getContextName(consumer._context) + '.Consumer'; } - return null; - } - function disabledLog() {} - function disableLogs() { - if (0 === disabledDepth) { - prevLog = console.log; - prevInfo = console.info; - prevWarn = console.warn; - prevError = console.error; - prevGroup = console.group; - prevGroupCollapsed = console.groupCollapsed; - prevGroupEnd = console.groupEnd; - var props = { - configurable: !0, - enumerable: !0, - value: disabledLog, - writable: !0 - }; - Object.defineProperties(console, { - info: props, - log: props, - warn: props, - error: props, - group: props, - groupCollapsed: props, - groupEnd: props - }); + + case ContextProvider: + { + var _context = type; + return getContextName(_context) + '.Provider'; } - disabledDepth++; - } - function reenableLogs() { - disabledDepth--; - if (0 === disabledDepth) { - var props = { configurable: !0, enumerable: !0, writable: !0 }; - Object.defineProperties(console, { - log: assign({}, props, { value: prevLog }), - info: assign({}, props, { value: prevInfo }), - warn: assign({}, props, { value: prevWarn }), - error: assign({}, props, { value: prevError }), - group: assign({}, props, { value: prevGroup }), - groupCollapsed: assign({}, props, { value: prevGroupCollapsed }), - groupEnd: assign({}, props, { value: prevGroupEnd }) - }); + + case DehydratedFragment: + return 'DehydratedFragment'; + + case ForwardRef: + return getWrappedName(type, type.render, 'ForwardRef'); + + case Fragment: + return 'Fragment'; + + case HostHoistable: + case HostSingleton: + case HostComponent: + // Host component type is the display name (e.g. "div", "View") + return type; + + case HostPortal: + return 'Portal'; + + case HostRoot: + return 'Root'; + + case HostText: + return 'Text'; + + case LazyComponent: + // Name comes from the type in this case; we don't have a tag. + return getComponentNameFromType(type); + + case Mode: + if (type === REACT_STRICT_MODE_TYPE) { + // Don't be less specific than shared/getComponentNameFromType + return 'StrictMode'; } - 0 > disabledDepth && - console.error( - "disabledDepth fell below zero. This is a bug in React. Please file an issue." - ); - } - function describeBuiltInComponentFrame(name) { - if (void 0 === prefix) - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = (match && match[1]) || ""; - suffix = - -1 < x.stack.indexOf("\n at") - ? " ()" - : -1 < x.stack.indexOf("@") - ? "@unknown:0:0" - : ""; - } - return "\n" + prefix + name + suffix; - } - function describeNativeComponentFrame(fn, construct) { - if (!fn || reentry) return ""; - var frame = componentFrameCache.get(fn); - if (void 0 !== frame) return frame; - reentry = !0; - frame = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - var previousDispatcher = null; - previousDispatcher = ReactSharedInternals.H; - ReactSharedInternals.H = null; - disableLogs(); - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - try { - if (construct) { - var Fake = function () { - throw Error(); - }; - Object.defineProperty(Fake.prototype, "props", { - set: function () { - throw Error(); - } - }); - if ("object" === typeof Reflect && Reflect.construct) { - try { - Reflect.construct(Fake, []); - } catch (x) { - var control = x; - } - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x$0) { - control = x$0; - } - fn.call(Fake.prototype); - } - } else { - try { - throw Error(); - } catch (x$1) { - control = x$1; - } - (Fake = fn()) && - "function" === typeof Fake.catch && - Fake.catch(function () {}); - } - } catch (sample) { - if (sample && control && "string" === typeof sample.stack) - return [sample.stack, control.stack]; - } - return [null, null]; - } - }; - RunInRootFrame.DetermineComponentFrameRoot.displayName = - "DetermineComponentFrameRoot"; - var namePropDescriptor = Object.getOwnPropertyDescriptor( - RunInRootFrame.DetermineComponentFrameRoot, - "name" - ); - namePropDescriptor && - namePropDescriptor.configurable && - Object.defineProperty( - RunInRootFrame.DetermineComponentFrameRoot, - "name", - { value: "DetermineComponentFrameRoot" } - ); - try { - var _RunInRootFrame$Deter = - RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; - if (sampleStack && controlStack) { - var sampleLines = sampleStack.split("\n"), - controlLines = controlStack.split("\n"); - for ( - sampleStack = _RunInRootFrame$Deter = 0; - _RunInRootFrame$Deter < sampleLines.length && - !sampleLines[_RunInRootFrame$Deter].includes( - "DetermineComponentFrameRoot" - ); - ) - _RunInRootFrame$Deter++; - for ( - ; - sampleStack < controlLines.length && - !controlLines[sampleStack].includes("DetermineComponentFrameRoot"); - - ) - sampleStack++; - if ( - _RunInRootFrame$Deter === sampleLines.length || - sampleStack === controlLines.length - ) - for ( - _RunInRootFrame$Deter = sampleLines.length - 1, - sampleStack = controlLines.length - 1; - 1 <= _RunInRootFrame$Deter && - 0 <= sampleStack && - sampleLines[_RunInRootFrame$Deter] !== controlLines[sampleStack]; - - ) - sampleStack--; - for ( - ; - 1 <= _RunInRootFrame$Deter && 0 <= sampleStack; - _RunInRootFrame$Deter--, sampleStack-- - ) - if ( - sampleLines[_RunInRootFrame$Deter] !== controlLines[sampleStack] - ) { - if (1 !== _RunInRootFrame$Deter || 1 !== sampleStack) { - do - if ( - (_RunInRootFrame$Deter--, - sampleStack--, - 0 > sampleStack || - sampleLines[_RunInRootFrame$Deter] !== - controlLines[sampleStack]) - ) { - var _frame = - "\n" + - sampleLines[_RunInRootFrame$Deter].replace( - " at new ", - " at " - ); - fn.displayName && - _frame.includes("") && - (_frame = _frame.replace("", fn.displayName)); - "function" === typeof fn && - componentFrameCache.set(fn, _frame); - return _frame; - } - while (1 <= _RunInRootFrame$Deter && 0 <= sampleStack); - } - break; - } - } - } finally { - (reentry = !1), - (ReactSharedInternals.H = previousDispatcher), - reenableLogs(), - (Error.prepareStackTrace = frame); - } - sampleLines = (sampleLines = fn ? fn.displayName || fn.name : "") - ? describeBuiltInComponentFrame(sampleLines) - : ""; - "function" === typeof fn && componentFrameCache.set(fn, sampleLines); - return sampleLines; - } - function formatOwnerStack(error) { - var prevPrepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - error = error.stack; - Error.prepareStackTrace = prevPrepareStackTrace; - error.startsWith("Error: react-stack-top-frame\n") && - (error = error.slice(29)); - prevPrepareStackTrace = error.indexOf("\n"); - -1 !== prevPrepareStackTrace && - (error = error.slice(prevPrepareStackTrace + 1)); - prevPrepareStackTrace = error.indexOf("react-stack-bottom-frame"); - -1 !== prevPrepareStackTrace && - (prevPrepareStackTrace = error.lastIndexOf( - "\n", - prevPrepareStackTrace - )); - if (-1 !== prevPrepareStackTrace) - error = error.slice(0, prevPrepareStackTrace); - else return ""; - return error; - } - function describeFiber(fiber) { - switch (fiber.tag) { - case 26: - case 27: - case 5: - return describeBuiltInComponentFrame(fiber.type); - case 16: - return describeBuiltInComponentFrame("Lazy"); - case 13: - return describeBuiltInComponentFrame("Suspense"); - case 19: - return describeBuiltInComponentFrame("SuspenseList"); - case 0: - case 15: - return (fiber = describeNativeComponentFrame(fiber.type, !1)), fiber; - case 11: - return ( - (fiber = describeNativeComponentFrame(fiber.type.render, !1)), fiber - ); - case 1: - return (fiber = describeNativeComponentFrame(fiber.type, !0)), fiber; - default: - return ""; + return 'Mode'; + + case OffscreenComponent: + return 'Offscreen'; + + case Profiler: + return 'Profiler'; + + case ScopeComponent: + return 'Scope'; + + case SuspenseComponent: + return 'Suspense'; + + case SuspenseListComponent: + return 'SuspenseList'; + + case TracingMarkerComponent: + return 'TracingMarker'; + // The display name for these tags come from the user-provided type: + + case IncompleteClassComponent: + case IncompleteFunctionComponent: + { + break; } - } - function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - do { - info += describeFiber(workInProgress); - var debugInfo = workInProgress._debugInfo; - if (debugInfo) - for (var i = debugInfo.length - 1; 0 <= i; i--) { - var entry = debugInfo[i]; - if ("string" === typeof entry.name) { - var JSCompiler_temp_const = info, - env = entry.env; - var JSCompiler_inline_result = describeBuiltInComponentFrame( - entry.name + (env ? " [" + env + "]" : "") - ); - info = JSCompiler_temp_const + JSCompiler_inline_result; - } - } - workInProgress = workInProgress.return; - } while (workInProgress); - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; + + // Fallthrough + + case ClassComponent: + case FunctionComponent: + case MemoComponent: + case SimpleMemoComponent: + if (typeof type === 'function') { + return type.displayName || type.name || null; + } + + if (typeof type === 'string') { + return type; } + + break; + + } + + return null; +} + +var NoFlags$1 = +/* */ +0; +var PerformedWork = +/* */ +1; +var Placement = +/* */ +2; +var DidCapture = +/* */ +128; +var Hydrating = +/* */ +4096; // You can change the rest (and add more). + +var Update = +/* */ +4; +/* Skipped value: 0b0000000000000000000000001000; */ + +var ChildDeletion = +/* */ +16; +var ContentReset = +/* */ +32; +var Callback = +/* */ +64; +/* Used by DidCapture: 0b0000000000000000000010000000; */ + +var ForceClientRender = +/* */ +256; +var Ref = +/* */ +512; +var Snapshot = +/* */ +1024; +var Passive$1 = +/* */ +2048; +/* Used by Hydrating: 0b0000000000000001000000000000; */ + +var Visibility = +/* */ +8192; +var StoreConsistency = +/* */ +16384; // It's OK to reuse these bits because these flags are mutually exclusive for +// different fiber types. We should really be doing this for as many flags as +// possible, because we're about to run out of bits. + +var ScheduleRetry = StoreConsistency; +var ShouldSuspendCommit = Visibility; +var DidDefer = ContentReset; +var FormReset = Snapshot; + +var HostEffectMask = +/* */ +32767; // These are not really side effects, but we still reuse this field. + +var Incomplete = +/* */ +32768; +var ShouldCapture = +/* */ +65536; +var ForceUpdateForLegacySuspense = +/* */ +131072; +var Forked = +/* */ +1048576; // Static tags describe aspects of a fiber that are not specific to a render, +// e.g. a fiber uses a passive effect (even if there are no updates on this particular render). +// This enables us to defer more work in the unmount case, +// since we can defer traversing the tree during layout to look for Passive effects, +// and instead rely on the static flag as a signal that there may be cleanup work. + +var RefStatic = +/* */ +2097152; +var LayoutStatic = +/* */ +4194304; +var PassiveStatic = +/* */ +8388608; +var MaySuspendCommit = +/* */ +16777216; // Flag used to identify newly inserted fibers. It isn't reset after commit unlike `Placement`. + +var PlacementDEV = +/* */ +33554432; +var MountLayoutDev = +/* */ +67108864; +var MountPassiveDev = +/* */ +134217728; // Groups of flags that are used in the commit phase to skip over trees that +// don't contain effects, by checking subtreeFlags. + +var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visibility +// flag logic (see #20043) +Update | Snapshot | (0); +var MutationMask = Placement | Update | ChildDeletion | ContentReset | Ref | Hydrating | Visibility | FormReset; +var LayoutMask = Update | Callback | Ref | Visibility; // TODO: Split into PassiveMountMask and PassiveUnmountMask + +var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that don't get reset on clones. +// This allows certain concepts to persist without recalculating them, +// e.g. whether a subtree contains passive effects or portals. + +var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; + +var assign = Object.assign; + +// Helpers to patch console.logs to avoid logging during side-effect free +// replaying on render function. This currently only patches the object +// lazily which won't cover if the log function was extracted eagerly. +// We could also eagerly patch the method. +var disabledDepth = 0; +var prevLog; +var prevInfo; +var prevWarn; +var prevError; +var prevGroup; +var prevGroupCollapsed; +var prevGroupEnd; + +function disabledLog() {} + +disabledLog.__reactDisabledLog = true; +function disableLogs() { + { + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + prevLog = console.log; + prevInfo = console.info; + prevWarn = console.warn; + prevError = console.error; + prevGroup = console.group; + prevGroupCollapsed = console.groupCollapsed; + prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 + + var props = { + configurable: true, + enumerable: true, + value: disabledLog, + writable: true + }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. + + Object.defineProperties(console, { + info: props, + log: props, + warn: props, + error: props, + group: props, + groupCollapsed: props, + groupEnd: props + }); + /* eslint-enable react-internal/no-production-logging */ } - function describeFunctionComponentFrameWithoutLineNumber(fn) { - return (fn = fn ? fn.displayName || fn.name : "") - ? describeBuiltInComponentFrame(fn) - : ""; + + disabledDepth++; + } +} +function reenableLogs() { + { + disabledDepth--; + + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + var props = { + configurable: true, + enumerable: true, + writable: true + }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. + + Object.defineProperties(console, { + log: assign({}, props, { + value: prevLog + }), + info: assign({}, props, { + value: prevInfo + }), + warn: assign({}, props, { + value: prevWarn + }), + error: assign({}, props, { + value: prevError + }), + group: assign({}, props, { + value: prevGroup + }), + groupCollapsed: assign({}, props, { + value: prevGroupCollapsed + }), + groupEnd: assign({}, props, { + value: prevGroupEnd + }) + }); + /* eslint-enable react-internal/no-production-logging */ } - function getCurrentFiberOwnerNameInDevOrNull() { - if (null === current) return null; - var owner = current._debugOwner; - return null != owner ? getComponentNameFromOwner(owner) : null; + + if (disabledDepth < 0) { + error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); } - function getCurrentFiberStackInDev() { - if (null === current) return ""; - var workInProgress = current; + } +} + +var prefix; +function describeBuiltInComponentFrame(name) { + { + if (prefix === undefined) { + // Extract the VM specific prefix used by each line. try { - var info = ""; - 6 === workInProgress.tag && (workInProgress = workInProgress.return); - switch (workInProgress.tag) { - case 26: - case 27: - case 5: - info += describeBuiltInComponentFrame(workInProgress.type); - break; - case 13: - info += describeBuiltInComponentFrame("Suspense"); - break; - case 19: - info += describeBuiltInComponentFrame("SuspenseList"); - break; - case 0: - case 15: - case 1: - workInProgress._debugOwner || - "" !== info || - (info += describeFunctionComponentFrameWithoutLineNumber( - workInProgress.type - )); - break; - case 11: - workInProgress._debugOwner || - "" !== info || - (info += describeFunctionComponentFrameWithoutLineNumber( - workInProgress.type.render - )); - } - for (; workInProgress; ) - if ("number" === typeof workInProgress.tag) { - var fiber = workInProgress; - workInProgress = fiber._debugOwner; - var debugStack = fiber._debugStack; - workInProgress && - debugStack && - ("string" !== typeof debugStack && - (fiber._debugStack = debugStack = formatOwnerStack(debugStack)), - "" !== debugStack && (info += "\n" + debugStack)); - } else if (null != workInProgress.debugStack) { - var ownerStack = workInProgress.debugStack; - (workInProgress = workInProgress.owner) && - ownerStack && - (info += "\n" + formatOwnerStack(ownerStack)); - } else break; - var JSCompiler_inline_result = info; + throw Error(); } catch (x) { - JSCompiler_inline_result = - "\nError generating stack: " + x.message + "\n" + x.stack; + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = match && match[1] || ''; } - return JSCompiler_inline_result; + } // We use the prefix to ensure our stacks line up with native stack frames. + + + return '\n' + prefix + name; + } +} +function describeDebugInfoFrame(name, env) { + return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : '')); +} +var reentry = false; +var componentFrameCache; + +{ + var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap$1(); +} +/** + * Leverages native browser/VM stack frames to get proper details (e.g. + * filename, line + col number) for a single component in a component stack. We + * do this by: + * (1) throwing and catching an error in the function - this will be our + * control error. + * (2) calling the component which will eventually throw an error that we'll + * catch - this will be our sample error. + * (3) diffing the control and sample error stacks to find the stack frame + * which represents our component. + */ + + +function describeNativeComponentFrame(fn, construct) { + // If something asked for a stack inside a fake render, it should get ignored. + if (!fn || reentry) { + return ''; + } + + { + var frame = componentFrameCache.get(fn); + + if (frame !== undefined) { + return frame; } - function runWithFiberInDEV(fiber, callback, arg0, arg1, arg2, arg3, arg4) { - var previousFiber = current; - ReactSharedInternals.getCurrentStack = - null === fiber ? null : getCurrentFiberStackInDev; - isRendering = !1; - current = fiber; + } + + reentry = true; + var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. + + Error.prepareStackTrace = undefined; + var previousDispatcher = null; + + { + previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function + // for warnings. + + ReactSharedInternals.H = null; + disableLogs(); + } + /** + * Finding a common stack frame between sample and control errors can be + * tricky given the different types and levels of stack trace truncation from + * different JS VMs. So instead we'll attempt to control what that common + * frame should be through this object method: + * Having both the sample and control errors be in the function under the + * `DescribeNativeComponentFrameRoot` property, + setting the `name` and + * `displayName` properties of the function ensures that a stack + * frame exists that has the method name `DescribeNativeComponentFrameRoot` in + * it for both control and sample stacks. + */ + + + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + var control; + try { - return null !== fiber && fiber._debugTask - ? fiber._debugTask.run( - callback.bind(null, arg0, arg1, arg2, arg3, arg4) - ) - : callback(arg0, arg1, arg2, arg3, arg4); - } finally { - current = previousFiber; - } - throw Error( - "runWithFiberInDEV should never be called in production. This is a bug in React." - ); - } - function getNearestMountedFiber(fiber) { - var node = fiber, - nearestMounted = fiber; - if (fiber.alternate) for (; node.return; ) node = node.return; - else { - fiber = node; - do - (node = fiber), - 0 !== (node.flags & 4098) && (nearestMounted = node.return), - (fiber = node.return); - while (fiber); - } - return 3 === node.tag ? nearestMounted : null; - } - function getSuspenseInstanceFromFiber(fiber) { - if (13 === fiber.tag) { - var suspenseState = fiber.memoizedState; - null === suspenseState && - ((fiber = fiber.alternate), - null !== fiber && (suspenseState = fiber.memoizedState)); - if (null !== suspenseState) return suspenseState.dehydrated; - } - return null; - } - function assertIsMounted(fiber) { - if (getNearestMountedFiber(fiber) !== fiber) - throw Error("Unable to find node on an unmounted component."); - } - function findCurrentFiberUsingSlowPath(fiber) { - var alternate = fiber.alternate; - if (!alternate) { - alternate = getNearestMountedFiber(fiber); - if (null === alternate) - throw Error("Unable to find node on an unmounted component."); - return alternate !== fiber ? null : fiber; - } - for (var a = fiber, b = alternate; ; ) { - var parentA = a.return; - if (null === parentA) break; - var parentB = parentA.alternate; - if (null === parentB) { - b = parentA.return; - if (null !== b) { - a = b; - continue; - } - break; - } - if (parentA.child === parentB.child) { - for (parentB = parentA.child; parentB; ) { - if (parentB === a) return assertIsMounted(parentA), fiber; - if (parentB === b) return assertIsMounted(parentA), alternate; - parentB = parentB.sibling; - } - throw Error("Unable to find node on an unmounted component."); - } - if (a.return !== b.return) (a = parentA), (b = parentB); - else { - for (var didFindChild = !1, _child = parentA.child; _child; ) { - if (_child === a) { - didFindChild = !0; - a = parentA; - b = parentB; - break; - } - if (_child === b) { - didFindChild = !0; - b = parentA; - a = parentB; - break; - } - _child = _child.sibling; - } - if (!didFindChild) { - for (_child = parentB.child; _child; ) { - if (_child === a) { - didFindChild = !0; - a = parentB; - b = parentA; - break; - } - if (_child === b) { - didFindChild = !0; - b = parentB; - a = parentA; - break; - } - _child = _child.sibling; + // This should throw. + if (construct) { + // Something should be setting the props in the constructor. + var Fake = function () { + throw Error(); + }; // $FlowFixMe[prop-missing] + + + Object.defineProperty(Fake.prototype, 'props', { + set: function () { + // We use a throwing setter instead of frozen or non-writable props + // because that won't throw in a non-strict mode function. + throw Error(); } - if (!didFindChild) - throw Error( - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." - ); - } - } - if (a.alternate !== b) - throw Error( - "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." - ); - } - if (3 !== a.tag) - throw Error("Unable to find node on an unmounted component."); - return a.stateNode.current === a ? fiber : alternate; - } - function findCurrentHostFiber(parent) { - parent = findCurrentFiberUsingSlowPath(parent); - return null !== parent ? findCurrentHostFiberImpl(parent) : null; - } - function findCurrentHostFiberImpl(node) { - var tag = node.tag; - if (5 === tag || 26 === tag || 27 === tag || 6 === tag) return node; - for (node = node.child; null !== node; ) { - tag = findCurrentHostFiberImpl(node); - if (null !== tag) return tag; - node = node.sibling; - } - return null; - } - function createCursor(defaultValue) { - return { current: defaultValue }; - } - function pop(cursor, fiber) { - 0 > index$jscomp$0 - ? console.error("Unexpected pop.") - : (fiber !== fiberStack[index$jscomp$0] && - console.error("Unexpected Fiber popped."), - (cursor.current = valueStack[index$jscomp$0]), - (valueStack[index$jscomp$0] = null), - (fiberStack[index$jscomp$0] = null), - index$jscomp$0--); - } - function push(cursor, value, fiber) { - index$jscomp$0++; - valueStack[index$jscomp$0] = cursor.current; - fiberStack[index$jscomp$0] = fiber; - cursor.current = value; - } - function requiredContext(c) { - null === c && - console.error( - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." - ); - return c; - } - function pushHostContainer(fiber, nextRootInstance) { - push(rootInstanceStackCursor, nextRootInstance, fiber); - push(contextFiberStackCursor, fiber, fiber); - push(contextStackCursor, null, fiber); - var nextRootContext = nextRootInstance.nodeType; - switch (nextRootContext) { - case 9: - case 11: - nextRootContext = 9 === nextRootContext ? "#document" : "#fragment"; - nextRootInstance = (nextRootInstance = - nextRootInstance.documentElement) - ? (nextRootInstance = nextRootInstance.namespaceURI) - ? getOwnHostContext(nextRootInstance) - : HostContextNamespaceNone - : HostContextNamespaceNone; - break; - default: - if ( - ((nextRootInstance = - 8 === nextRootContext - ? nextRootInstance.parentNode - : nextRootInstance), - (nextRootContext = nextRootInstance.tagName), - (nextRootInstance = nextRootInstance.namespaceURI)) - ) - (nextRootInstance = getOwnHostContext(nextRootInstance)), - (nextRootInstance = getChildHostContextProd( - nextRootInstance, - nextRootContext - )); - else - switch (nextRootContext) { - case "svg": - nextRootInstance = HostContextNamespaceSvg; - break; - case "math": - nextRootInstance = HostContextNamespaceMath; - break; - default: - nextRootInstance = HostContextNamespaceNone; + }); + + if (typeof Reflect === 'object' && Reflect.construct) { + // We construct a different control for this case to include any extra + // frames added by the construct call. + try { + Reflect.construct(Fake, []); + } catch (x) { + control = x; } + + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x) { + control = x; + } // $FlowFixMe[prop-missing] found when upgrading Flow + + + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x) { + control = x; + } // TODO(luna): This will currently only throw if the function component + // tries to access React/ReactDOM/props. We should probably make this throw + // in simple components too + + + var maybePromise = fn(); // If the function component returns a promise, it's likely an async + // component, which we don't yet support. Attach a noop catch handler to + // silence the error. + // TODO: Implement component stacks for async client components? + + if (maybePromise && typeof maybePromise.catch === 'function') { + maybePromise.catch(function () {}); + } + } + } catch (sample) { + // This is inlined manually because closure doesn't do it for us. + if (sample && control && typeof sample.stack === 'string') { + return [sample.stack, control.stack]; + } } - nextRootContext = nextRootContext.toLowerCase(); - nextRootContext = updatedAncestorInfoDev(null, nextRootContext); - nextRootContext = { - context: nextRootInstance, - ancestorInfo: nextRootContext - }; - pop(contextStackCursor, fiber); - push(contextStackCursor, nextRootContext, fiber); - } - function popHostContainer(fiber) { - pop(contextStackCursor, fiber); - pop(contextFiberStackCursor, fiber); - pop(rootInstanceStackCursor, fiber); - } - function getHostContext() { - return requiredContext(contextStackCursor.current); - } - function pushHostContext(fiber) { - null !== fiber.memoizedState && - push(hostTransitionProviderCursor, fiber, fiber); - var context = requiredContext(contextStackCursor.current); - var type = fiber.type; - var nextContext = getChildHostContextProd(context.context, type); - type = updatedAncestorInfoDev(context.ancestorInfo, type); - nextContext = { context: nextContext, ancestorInfo: type }; - context !== nextContext && - (push(contextFiberStackCursor, fiber, fiber), - push(contextStackCursor, nextContext, fiber)); - } - function popHostContext(fiber) { - contextFiberStackCursor.current === fiber && - (pop(contextStackCursor, fiber), pop(contextFiberStackCursor, fiber)); - hostTransitionProviderCursor.current === fiber && - (pop(hostTransitionProviderCursor, fiber), - (HostTransitionContext._currentValue = null)); - } - function typeName(value) { - return ( - ("function" === typeof Symbol && - Symbol.toStringTag && - value[Symbol.toStringTag]) || - value.constructor.name || - "Object" - ); + + return [null, null]; } - function willCoercionThrow(value) { - try { - return testStringCoercion(value), !1; - } catch (e) { - return !0; - } - } - function testStringCoercion(value) { - return "" + value; - } - function checkAttributeStringCoercion(value, attributeName) { - if (willCoercionThrow(value)) - return ( - console.error( - "The provided `%s` attribute is an unsupported type %s. This value must be coerced to a string before using it here.", - attributeName, - typeName(value) - ), - testStringCoercion(value) - ); - } - function checkCSSPropertyStringCoercion(value, propName) { - if (willCoercionThrow(value)) - return ( - console.error( - "The provided `%s` CSS property is an unsupported type %s. This value must be coerced to a string before using it here.", - propName, - typeName(value) - ), - testStringCoercion(value) - ); - } - function checkFormFieldValueStringCoercion(value) { - if (willCoercionThrow(value)) - return ( - console.error( - "Form field values (value, checked, defaultValue, or defaultChecked props) must be strings, not %s. This value must be coerced to a string before using it here.", - typeName(value) - ), - testStringCoercion(value) - ); - } - function injectInternals(internals) { - if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1; - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if (hook.isDisabled) return !0; - if (!hook.supportsFiber) - return ( - console.error( - "The installed version of React DevTools is too old and will not work with the current version of React. Please update React DevTools. https://react.dev/link/react-devtools" - ), - !0 - ); - try { - (internals = assign({}, internals, { - getLaneLabelMap: getLaneLabelMap, - injectProfilingHooks: injectProfilingHooks - })), - (rendererID = hook.inject(internals)), - (injectedHook = hook); - } catch (err) { - console.error("React instrumentation encountered an error: %s.", err); + }; // $FlowFixMe[prop-missing] + + RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; + var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable. + + if (namePropDescriptor && namePropDescriptor.configurable) { + // V8 utilizes a function's `name` property when generating a stack trace. + Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor + // is set to `false`. + // $FlowFixMe[cannot-write] + 'name', { + value: 'DetermineComponentFrameRoot' + }); + } + + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; + + if (sampleStack && controlStack) { + // This extracts the first frame from the sample that isn't also in the control. + // Skipping one frame that we assume is the frame that calls the two. + var sampleLines = sampleStack.split('\n'); + var controlLines = controlStack.split('\n'); + var s = 0; + var c = 0; + + while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { + s++; } - return hook.checkDCE ? !0 : !1; - } - function onCommitRoot$1(root, eventPriority) { - if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) - try { - var didError = 128 === (root.current.flags & 128); - switch (eventPriority) { - case DiscreteEventPriority: - var schedulerPriority = ImmediatePriority; - break; - case ContinuousEventPriority: - schedulerPriority = UserBlockingPriority; - break; - case DefaultEventPriority: - schedulerPriority = NormalPriority$1; - break; - case IdleEventPriority: - schedulerPriority = IdlePriority; - break; - default: - schedulerPriority = NormalPriority$1; - } - injectedHook.onCommitFiberRoot( - rendererID, - root, - schedulerPriority, - didError - ); - } catch (err) { - hasLoggedError || - ((hasLoggedError = !0), - console.error( - "React instrumentation encountered an error: %s", - err - )); - } - } - function setIsStrictModeForDevtools(newIsStrictMode) { - "function" === typeof log$1 && - unstable_setDisableYieldValue(newIsStrictMode); - if (injectedHook && "function" === typeof injectedHook.setStrictMode) - try { - injectedHook.setStrictMode(rendererID, newIsStrictMode); - } catch (err) { - hasLoggedError || - ((hasLoggedError = !0), - console.error( - "React instrumentation encountered an error: %s", - err - )); - } - } - function injectProfilingHooks(profilingHooks) { - injectedProfilingHooks = profilingHooks; - } - function getLaneLabelMap() { - for ( - var map = new Map(), lane = 1, index = 0; - index < TotalLanes; - index++ - ) { - var label = getLabelForLane(lane); - map.set(lane, label); - lane *= 2; - } - return map; - } - function markCommitStopped() { - null !== injectedProfilingHooks && - "function" === typeof injectedProfilingHooks.markCommitStopped && - injectedProfilingHooks.markCommitStopped(); - } - function markComponentRenderStarted(fiber) { - null !== injectedProfilingHooks && - "function" === - typeof injectedProfilingHooks.markComponentRenderStarted && - injectedProfilingHooks.markComponentRenderStarted(fiber); - } - function markComponentRenderStopped() { - null !== injectedProfilingHooks && - "function" === - typeof injectedProfilingHooks.markComponentRenderStopped && - injectedProfilingHooks.markComponentRenderStopped(); - } - function markComponentLayoutEffectUnmountStarted(fiber) { - null !== injectedProfilingHooks && - "function" === - typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStarted && - injectedProfilingHooks.markComponentLayoutEffectUnmountStarted(fiber); - } - function markComponentLayoutEffectUnmountStopped() { - null !== injectedProfilingHooks && - "function" === - typeof injectedProfilingHooks.markComponentLayoutEffectUnmountStopped && - injectedProfilingHooks.markComponentLayoutEffectUnmountStopped(); - } - function markRenderStarted(lanes) { - null !== injectedProfilingHooks && - "function" === typeof injectedProfilingHooks.markRenderStarted && - injectedProfilingHooks.markRenderStarted(lanes); - } - function markRenderStopped() { - null !== injectedProfilingHooks && - "function" === typeof injectedProfilingHooks.markRenderStopped && - injectedProfilingHooks.markRenderStopped(); - } - function markStateUpdateScheduled(fiber, lane) { - null !== injectedProfilingHooks && - "function" === typeof injectedProfilingHooks.markStateUpdateScheduled && - injectedProfilingHooks.markStateUpdateScheduled(fiber, lane); - } - function clz32Fallback(x) { - x >>>= 0; - return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0; - } - function getLabelForLane(lane) { - if (lane & SyncHydrationLane) return "SyncHydrationLane"; - if (lane & SyncLane) return "Sync"; - if (lane & InputContinuousHydrationLane) - return "InputContinuousHydration"; - if (lane & InputContinuousLane) return "InputContinuous"; - if (lane & DefaultHydrationLane) return "DefaultHydration"; - if (lane & DefaultLane) return "Default"; - if (lane & TransitionHydrationLane) return "TransitionHydration"; - if (lane & TransitionLanes) return "Transition"; - if (lane & RetryLanes) return "Retry"; - if (lane & SelectiveHydrationLane) return "SelectiveHydration"; - if (lane & IdleHydrationLane) return "IdleHydration"; - if (lane & IdleLane) return "Idle"; - if (lane & OffscreenLane) return "Offscreen"; - if (lane & DeferredLane) return "Deferred"; - } - function getHighestPriorityLanes(lanes) { - var pendingSyncLanes = lanes & SyncUpdateLanes; - if (0 !== pendingSyncLanes) return pendingSyncLanes; - switch (lanes & -lanes) { - case SyncHydrationLane: - return SyncHydrationLane; - case SyncLane: - return SyncLane; - case InputContinuousHydrationLane: - return InputContinuousHydrationLane; - case InputContinuousLane: - return InputContinuousLane; - case DefaultHydrationLane: - return DefaultHydrationLane; - case DefaultLane: - return DefaultLane; - case TransitionHydrationLane: - return TransitionHydrationLane; - case 128: - case 256: - case 512: - case 1024: - case 2048: - case 4096: - case 8192: - case 16384: - case 32768: - case 65536: - case 131072: - case 262144: - case 524288: - case 1048576: - case 2097152: - return lanes & TransitionLanes; - case 4194304: - case 8388608: - case 16777216: - case 33554432: - return lanes & RetryLanes; - case SelectiveHydrationLane: - return SelectiveHydrationLane; - case IdleHydrationLane: - return IdleHydrationLane; - case IdleLane: - return IdleLane; - case OffscreenLane: - return OffscreenLane; - case DeferredLane: - return 0; - default: - return ( - console.error( - "Should have found matching lanes. This is a bug in React." - ), - lanes - ); - } - } - function getNextLanes(root, wipLanes) { - var pendingLanes = root.pendingLanes; - if (0 === pendingLanes) return 0; - var nextLanes = 0, - suspendedLanes = root.suspendedLanes; - root = root.pingedLanes; - var nonIdlePendingLanes = pendingLanes & 134217727; - 0 !== nonIdlePendingLanes - ? ((pendingLanes = nonIdlePendingLanes & ~suspendedLanes), - 0 !== pendingLanes - ? (nextLanes = getHighestPriorityLanes(pendingLanes)) - : ((root &= nonIdlePendingLanes), - 0 !== root && (nextLanes = getHighestPriorityLanes(root)))) - : ((pendingLanes &= ~suspendedLanes), - 0 !== pendingLanes - ? (nextLanes = getHighestPriorityLanes(pendingLanes)) - : 0 !== root && (nextLanes = getHighestPriorityLanes(root))); - return 0 === nextLanes - ? 0 - : 0 !== wipLanes && - wipLanes !== nextLanes && - 0 === (wipLanes & suspendedLanes) && - ((suspendedLanes = nextLanes & -nextLanes), - (root = wipLanes & -wipLanes), - suspendedLanes >= root || - (suspendedLanes === DefaultLane && - 0 !== (root & TransitionLanes))) - ? wipLanes - : nextLanes; - } - function computeExpirationTime(lane, currentTime) { - switch (lane) { - case SyncHydrationLane: - case SyncLane: - case InputContinuousHydrationLane: - case InputContinuousLane: - return currentTime + 250; - case DefaultHydrationLane: - case DefaultLane: - case TransitionHydrationLane: - case 128: - case 256: - case 512: - case 1024: - case 2048: - case 4096: - case 8192: - case 16384: - case 32768: - case 65536: - case 131072: - case 262144: - case 524288: - case 1048576: - case 2097152: - return currentTime + 5e3; - case 4194304: - case 8388608: - case 16777216: - case 33554432: - return -1; - case SelectiveHydrationLane: - case IdleHydrationLane: - case IdleLane: - case OffscreenLane: - case DeferredLane: - return -1; - default: - return ( - console.error( - "Should have found matching lanes. This is a bug in React." - ), - -1 - ); - } - } - function getLanesToRetrySynchronouslyOnError( - root, - originallyAttemptedLanes - ) { - if (root.errorRecoveryDisabledLanes & originallyAttemptedLanes) return 0; - root = root.pendingLanes & ~OffscreenLane; - return 0 !== root ? root : root & OffscreenLane ? OffscreenLane : 0; - } - function claimNextTransitionLane() { - var lane = nextTransitionLane; - nextTransitionLane <<= 1; - 0 === (nextTransitionLane & TransitionLanes) && - (nextTransitionLane = 128); - return lane; - } - function claimNextRetryLane() { - var lane = nextRetryLane; - nextRetryLane <<= 1; - 0 === (nextRetryLane & RetryLanes) && (nextRetryLane = 4194304); - return lane; - } - function createLaneMap(initial) { - for (var laneMap = [], i = 0; i < TotalLanes; i++) laneMap.push(initial); - return laneMap; - } - function markRootFinished(root, remainingLanes, spawnedLane) { - var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; - root.pendingLanes = remainingLanes; - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes; - root.entangledLanes &= remainingLanes; - root.errorRecoveryDisabledLanes &= remainingLanes; - root.shellSuspendCounter = 0; - remainingLanes = root.entanglements; - for ( - var expirationTimes = root.expirationTimes, - hiddenUpdates = root.hiddenUpdates; - 0 < noLongerPendingLanes; - - ) { - var index = 31 - clz32(noLongerPendingLanes), - lane = 1 << index; - remainingLanes[index] = 0; - expirationTimes[index] = -1; - var hiddenUpdatesForLane = hiddenUpdates[index]; - if (null !== hiddenUpdatesForLane) - for ( - hiddenUpdates[index] = null, index = 0; - index < hiddenUpdatesForLane.length; - index++ - ) { - var update = hiddenUpdatesForLane[index]; - null !== update && (update.lane &= ~OffscreenLane); - } - noLongerPendingLanes &= ~lane; - } - 0 !== spawnedLane && markSpawnedDeferredLane(root, spawnedLane, 0); - } - function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) { - root.pendingLanes |= spawnedLane; - root.suspendedLanes &= ~spawnedLane; - var spawnedLaneIndex = 31 - clz32(spawnedLane); - root.entangledLanes |= spawnedLane; - root.entanglements[spawnedLaneIndex] = - root.entanglements[spawnedLaneIndex] | - DeferredLane | - (entangledLanes & UpdateLanes); - } - function markRootEntangled(root, entangledLanes) { - var rootEntangledLanes = (root.entangledLanes |= entangledLanes); - for (root = root.entanglements; rootEntangledLanes; ) { - var index = 31 - clz32(rootEntangledLanes), - lane = 1 << index; - (lane & entangledLanes) | (root[index] & entangledLanes) && - (root[index] |= entangledLanes); - rootEntangledLanes &= ~lane; - } - } - function addFiberToLanesMap(root, fiber, lanes) { - if (isDevToolsPresent) - for (root = root.pendingUpdatersLaneMap; 0 < lanes; ) { - var index = 31 - clz32(lanes), - lane = 1 << index; - root[index].add(fiber); - lanes &= ~lane; - } - } - function movePendingFibersToMemoized(root, lanes) { - if (isDevToolsPresent) - for ( - var pendingUpdatersLaneMap = root.pendingUpdatersLaneMap, - memoizedUpdaters = root.memoizedUpdaters; - 0 < lanes; - - ) { - var index = 31 - clz32(lanes); - root = 1 << index; - index = pendingUpdatersLaneMap[index]; - 0 < index.size && - (index.forEach(function (fiber) { - var alternate = fiber.alternate; - (null !== alternate && memoizedUpdaters.has(alternate)) || - memoizedUpdaters.add(fiber); - }), - index.clear()); - lanes &= ~root; - } - } - function lanesToEventPriority(lanes) { - lanes &= -lanes; - return 0 !== DiscreteEventPriority && DiscreteEventPriority < lanes - ? 0 !== ContinuousEventPriority && ContinuousEventPriority < lanes - ? 0 !== (lanes & 134217727) - ? DefaultEventPriority - : IdleEventPriority - : ContinuousEventPriority - : DiscreteEventPriority; - } - function resolveUpdatePriority() { - var updatePriority = ReactDOMSharedInternals.p; - if (0 !== updatePriority) return updatePriority; - updatePriority = window.event; - return void 0 === updatePriority - ? DefaultEventPriority - : getEventPriority(updatePriority.type); - } - function runWithPriority(priority, fn) { - var previousPriority = ReactDOMSharedInternals.p; - try { - return (ReactDOMSharedInternals.p = priority), fn(); - } finally { - ReactDOMSharedInternals.p = previousPriority; - } - } - function detachDeletedInstance(node) { - delete node[internalInstanceKey]; - delete node[internalPropsKey]; - delete node[internalEventHandlersKey]; - delete node[internalEventHandlerListenersKey]; - delete node[internalEventHandlesSetKey]; - } - function getClosestInstanceFromNode(targetNode) { - var targetInst = targetNode[internalInstanceKey]; - if (targetInst) return targetInst; - for (var parentNode = targetNode.parentNode; parentNode; ) { - if ( - (targetInst = - parentNode[internalContainerInstanceKey] || - parentNode[internalInstanceKey]) - ) { - parentNode = targetInst.alternate; - if ( - null !== targetInst.child || - (null !== parentNode && null !== parentNode.child) - ) - for ( - targetNode = getParentSuspenseInstance(targetNode); - null !== targetNode; - - ) { - if ((parentNode = targetNode[internalInstanceKey])) - return parentNode; - targetNode = getParentSuspenseInstance(targetNode); - } - return targetInst; + + while (c < controlLines.length && !controlLines[c].includes('DetermineComponentFrameRoot')) { + c++; + } // We couldn't find our intentionally injected common root frame, attempt + // to find another common root frame by search from the bottom of the + // control stack... + + + if (s === sampleLines.length || c === controlLines.length) { + s = sampleLines.length - 1; + c = controlLines.length - 1; + + while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { + // We expect at least one stack frame to be shared. + // Typically this will be the root most one. However, stack frames may be + // cut off due to maximum stack limits. In this case, one maybe cut off + // earlier than the other. We assume that the sample is longer or the same + // and there for cut off earlier. So we should find the root most frame in + // the sample somewhere in the control. + c--; } - targetNode = parentNode; - parentNode = targetNode.parentNode; - } - return null; - } - function getInstanceFromNode(node) { - if ( - (node = node[internalInstanceKey] || node[internalContainerInstanceKey]) - ) { - var tag = node.tag; - if ( - 5 === tag || - 6 === tag || - 13 === tag || - 26 === tag || - 27 === tag || - 3 === tag - ) - return node; } - return null; - } - function getNodeFromInstance(inst) { - var tag = inst.tag; - if (5 === tag || 26 === tag || 27 === tag || 6 === tag) - return inst.stateNode; - throw Error("getNodeFromInstance: Invalid argument."); - } - function getResourcesFromRoot(root) { - var resources = root[internalRootNodeResourcesKey]; - resources || - (resources = root[internalRootNodeResourcesKey] = - { hoistableStyles: new Map(), hoistableScripts: new Map() }); - return resources; - } - function markNodeAsHoistable(node) { - node[internalHoistableMarker] = !0; - } - function registerTwoPhaseEvent(registrationName, dependencies) { - registerDirectEvent(registrationName, dependencies); - registerDirectEvent(registrationName + "Capture", dependencies); - } - function registerDirectEvent(registrationName, dependencies) { - registrationNameDependencies[registrationName] && - console.error( - "EventRegistry: More than one plugin attempted to publish the same registration name, `%s`.", - registrationName - ); - registrationNameDependencies[registrationName] = dependencies; - var lowerCasedName = registrationName.toLowerCase(); - possibleRegistrationNames[lowerCasedName] = registrationName; - "onDoubleClick" === registrationName && - (possibleRegistrationNames.ondblclick = registrationName); - for ( - registrationName = 0; - registrationName < dependencies.length; - registrationName++ - ) - allNativeEvents.add(dependencies[registrationName]); - } - function checkControlledValueProps(tagName, props) { - hasReadOnlyValue[props.type] || - props.onChange || - props.onInput || - props.readOnly || - props.disabled || - null == props.value || - ("select" === tagName - ? console.error( - "You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set `onChange`." - ) - : console.error( - "You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`." - )); - props.onChange || - props.readOnly || - props.disabled || - null == props.checked || - console.error( - "You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`." - ); - } - function isAttributeNameSafe(attributeName) { - if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) - return !0; - if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) - return !1; - if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) - return (validatedAttributeNameCache[attributeName] = !0); - illegalAttributeNameCache[attributeName] = !0; - console.error("Invalid attribute name: `%s`", attributeName); - return !1; - } - function getValueForAttributeOnCustomComponent(node, name, expected) { - if (isAttributeNameSafe(name)) { - if (!node.hasAttribute(name)) { - switch (typeof expected) { - case "symbol": - case "object": - return expected; - case "function": - return expected; - case "boolean": - if (!1 === expected) return expected; - } - return void 0 === expected ? void 0 : null; - } - node = node.getAttribute(name); - if ("" === node && !0 === expected) return !0; - checkAttributeStringCoercion(expected, name); - return node === "" + expected ? expected : node; - } - } - function setValueForAttribute(node, name, value) { - if (isAttributeNameSafe(name)) - if (null === value) node.removeAttribute(name); - else { - switch (typeof value) { - case "undefined": - case "function": - case "symbol": - node.removeAttribute(name); - return; - case "boolean": - var prefix = name.toLowerCase().slice(0, 5); - if ("data-" !== prefix && "aria-" !== prefix) { - node.removeAttribute(name); - return; + + for (; s >= 1 && c >= 0; s--, c--) { + // Next we find the first one that isn't the same which should be the + // frame that called our sample function and the control. + if (sampleLines[s] !== controlLines[c]) { + // In V8, the first line is describing the message but other VMs don't. + // If we're about to return the first line, and the control is also on the same + // line, that's a pretty good indicator that our sample threw at same line as + // the control. I.e. before we entered the sample frame. So we ignore this result. + // This can happen if you passed a class to function component, or non-function. + if (s !== 1 || c !== 1) { + do { + s--; + c--; // We may still have similar intermediate frames from the construct call. + // The next one that isn't the same should be our match though. + + if (c < 0 || sampleLines[s] !== controlLines[c]) { + // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. + var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "" + // but we have a user-provided "displayName" + // splice it in to make the stack more readable. + + + if (fn.displayName && _frame.includes('')) { + _frame = _frame.replace('', fn.displayName); + } + + if (true) { + if (typeof fn === 'function') { + componentFrameCache.set(fn, _frame); + } + } // Return the line we found. + + + return _frame; } + } while (s >= 1 && c >= 0); } - checkAttributeStringCoercion(value, name); - node.setAttribute(name, "" + value); - } - } - function setValueForKnownAttribute(node, name, value) { - if (null === value) node.removeAttribute(name); - else { - switch (typeof value) { - case "undefined": - case "function": - case "symbol": - case "boolean": - node.removeAttribute(name); - return; + + break; } - checkAttributeStringCoercion(value, name); - node.setAttribute(name, "" + value); } } - function setValueForNamespacedAttribute(node, namespace, name, value) { - if (null === value) node.removeAttribute(name); - else { - switch (typeof value) { - case "undefined": - case "function": - case "symbol": - case "boolean": - node.removeAttribute(name); - return; - } - checkAttributeStringCoercion(value, name); - node.setAttributeNS(namespace, name, "" + value); - } + } finally { + reentry = false; + + { + ReactSharedInternals.H = previousDispatcher; + reenableLogs(); } - function getToStringValue(value) { - switch (typeof value) { - case "bigint": - case "boolean": - case "number": - case "string": - case "undefined": - return value; - case "object": - return checkFormFieldValueStringCoercion(value), value; - default: - return ""; - } + + Error.prepareStackTrace = previousPrepareStackTrace; + } // Fallback to just using the name if we couldn't make it throw. + + + var name = fn ? fn.displayName || fn.name : ''; + var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; + + { + if (typeof fn === 'function') { + componentFrameCache.set(fn, syntheticFrame); } - function isCheckable(elem) { - var type = elem.type; - return ( - (elem = elem.nodeName) && - "input" === elem.toLowerCase() && - ("checkbox" === type || "radio" === type) - ); + } + + return syntheticFrame; +} + +function describeClassComponentFrame(ctor) { + { + return describeNativeComponentFrame(ctor, true); + } +} +function describeFunctionComponentFrame(fn) { + { + return describeNativeComponentFrame(fn, false); + } +} + +// TODO: Consider marking the whole bundle instead of these boundaries. + +/** @noinline */ + +function callComponentInDEV(Component, props, secondArg) { + var wasRendering = isRendering; + setIsRendering(true); + + try { + var result = Component(props, secondArg); + return result; + } finally { + setIsRendering(wasRendering); + } +} +/** @noinline */ + +function callRenderInDEV(instance) { + var wasRendering = isRendering; + setIsRendering(true); + + try { + var result = instance.render(); + return result; + } finally { + setIsRendering(wasRendering); + } +} +/** @noinline */ + +function callLazyInitInDEV(lazy) { + var payload = lazy._payload; + var init = lazy._init; + return init(payload); +} + +var externalRegExp = /\/node\_modules\/|\(\\)/; +var callComponentFrame = null; +var callIteratorFrame = null; +var callLazyInitFrame = null; + +function isNotExternal(stackFrame) { + return !externalRegExp.test(stackFrame); +} + +function initCallComponentFrame() { + // Extract the stack frame of the callComponentInDEV function. + var error = callComponentInDEV(Error, 'react-stack-top-frame', {}); + var stack = error.stack; + var startIdx = stack.startsWith('Error: react-stack-top-frame\n') ? 29 : 0; + var endIdx = stack.indexOf('\n', startIdx); + + if (endIdx === -1) { + return stack.slice(startIdx); + } + + return stack.slice(startIdx, endIdx); +} + +function initCallRenderFrame() { + // Extract the stack frame of the callRenderInDEV function. + try { + callRenderInDEV({ + render: null + }); + return ''; + } catch (error) { + var stack = error.stack; + var startIdx = stack.startsWith('TypeError: ') ? stack.indexOf('\n') + 1 : 0; + var endIdx = stack.indexOf('\n', startIdx); + + if (endIdx === -1) { + return stack.slice(startIdx); } - function trackValueOnNode(node) { - var valueField = isCheckable(node) ? "checked" : "value", - descriptor = Object.getOwnPropertyDescriptor( - node.constructor.prototype, - valueField - ); - checkFormFieldValueStringCoercion(node[valueField]); - var currentValue = "" + node[valueField]; - if ( - !node.hasOwnProperty(valueField) && - "undefined" !== typeof descriptor && - "function" === typeof descriptor.get && - "function" === typeof descriptor.set - ) { - var get = descriptor.get, - set = descriptor.set; - Object.defineProperty(node, valueField, { - configurable: !0, - get: function () { - return get.call(this); - }, - set: function (value) { - checkFormFieldValueStringCoercion(value); - currentValue = "" + value; - set.call(this, value); - } - }); - Object.defineProperty(node, valueField, { - enumerable: descriptor.enumerable - }); - return { - getValue: function () { - return currentValue; - }, - setValue: function (value) { - checkFormFieldValueStringCoercion(value); - currentValue = "" + value; - }, - stopTracking: function () { - node._valueTracker = null; - delete node[valueField]; - } - }; - } + + return stack.slice(startIdx, endIdx); + } +} + +function initCallLazyInitFrame() { + // Extract the stack frame of the callLazyInitInDEV function. + var error = callLazyInitInDEV({ + $$typeof: REACT_LAZY_TYPE, + _init: Error, + _payload: 'react-stack-top-frame' + }); + var stack = error.stack; + var startIdx = stack.startsWith('Error: react-stack-top-frame\n') ? 29 : 0; + var endIdx = stack.indexOf('\n', startIdx); + + if (endIdx === -1) { + return stack.slice(startIdx); + } + + return stack.slice(startIdx, endIdx); +} + +function filterDebugStack(error) { + // Since stacks can be quite large and we pass a lot of them, we filter them out eagerly + // to save bandwidth even in DEV. We'll also replay these stacks on the client so by + // stripping them early we avoid that overhead. Otherwise we'd normally just rely on + // the DevTools or framework's ignore lists to filter them out. + var stack = error.stack; + + if (stack.startsWith('Error: react-stack-top-frame\n')) { + // V8's default formatting prefixes with the error message which we + // don't want/need. + stack = stack.slice(29); + } + + var frames = stack.split('\n').slice(1); + + if (callComponentFrame === null) { + callComponentFrame = initCallComponentFrame(); + } + + var lastFrameIdx = frames.indexOf(callComponentFrame); + + if (lastFrameIdx === -1) { + if (callLazyInitFrame === null) { + callLazyInitFrame = initCallLazyInitFrame(); } - function track(node) { - node._valueTracker || (node._valueTracker = trackValueOnNode(node)); - } - function updateValueIfChanged(node) { - if (!node) return !1; - var tracker = node._valueTracker; - if (!tracker) return !0; - var lastValue = tracker.getValue(); - var value = ""; - node && - (value = isCheckable(node) - ? node.checked - ? "true" - : "false" - : node.value); - node = value; - return node !== lastValue ? (tracker.setValue(node), !0) : !1; - } - function getActiveElement(doc) { - doc = doc || ("undefined" !== typeof document ? document : void 0); - if ("undefined" === typeof doc) return null; - try { - return doc.activeElement || doc.body; - } catch (e) { - return doc.body; + + lastFrameIdx = frames.indexOf(callLazyInitFrame); + + if (lastFrameIdx === -1) { + if (callIteratorFrame === null) { + callIteratorFrame = initCallRenderFrame(); } + + lastFrameIdx = frames.indexOf(callIteratorFrame); } - function escapeSelectorAttributeValueInsideDoubleQuotes(value) { - return value.replace( - escapeSelectorAttributeValueInsideDoubleQuotesRegex, - function (ch) { - return "\\" + ch.charCodeAt(0).toString(16) + " "; - } - ); - } - function validateInputProps(element, props) { - void 0 === props.checked || - void 0 === props.defaultChecked || - didWarnCheckedDefaultChecked || - (console.error( - "%s contains an input of type %s with both checked and defaultChecked props. Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://react.dev/link/controlled-components", - getCurrentFiberOwnerNameInDevOrNull() || "A component", - props.type - ), - (didWarnCheckedDefaultChecked = !0)); - void 0 === props.value || - void 0 === props.defaultValue || - didWarnValueDefaultValue$1 || - (console.error( - "%s contains an input of type %s with both value and defaultValue props. Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://react.dev/link/controlled-components", - getCurrentFiberOwnerNameInDevOrNull() || "A component", - props.type - ), - (didWarnValueDefaultValue$1 = !0)); - } - function updateInput( - element, - value, - defaultValue, - lastDefaultValue, - checked, - defaultChecked, - type, - name - ) { - element.name = ""; - null != type && - "function" !== typeof type && - "symbol" !== typeof type && - "boolean" !== typeof type - ? (checkAttributeStringCoercion(type, "type"), (element.type = type)) - : element.removeAttribute("type"); - if (null != value) - if ("number" === type) { - if ((0 === value && "" === element.value) || element.value != value) - element.value = "" + getToStringValue(value); - } else - element.value !== "" + getToStringValue(value) && - (element.value = "" + getToStringValue(value)); - else - ("submit" !== type && "reset" !== type) || - element.removeAttribute("value"); - null != value - ? setDefaultValue(element, type, getToStringValue(value)) - : null != defaultValue - ? setDefaultValue(element, type, getToStringValue(defaultValue)) - : null != lastDefaultValue && element.removeAttribute("value"); - null == checked && - null != defaultChecked && - (element.defaultChecked = !!defaultChecked); - null != checked && - (element.checked = - checked && - "function" !== typeof checked && - "symbol" !== typeof checked); - null != name && - "function" !== typeof name && - "symbol" !== typeof name && - "boolean" !== typeof name - ? (checkAttributeStringCoercion(name, "name"), - (element.name = "" + getToStringValue(name))) - : element.removeAttribute("name"); - } - function initInput( - element, - value, - defaultValue, - checked, - defaultChecked, - type, - name, - isHydrating - ) { - null != type && - "function" !== typeof type && - "symbol" !== typeof type && - "boolean" !== typeof type && - (checkAttributeStringCoercion(type, "type"), (element.type = type)); - if (null != value || null != defaultValue) { - if ( - !( - ("submit" !== type && "reset" !== type) || - (void 0 !== value && null !== value) - ) - ) - return; - defaultValue = - null != defaultValue ? "" + getToStringValue(defaultValue) : ""; - value = null != value ? "" + getToStringValue(value) : defaultValue; - isHydrating || value === element.value || (element.value = value); - element.defaultValue = value; - } - checked = null != checked ? checked : defaultChecked; - checked = - "function" !== typeof checked && - "symbol" !== typeof checked && - !!checked; - element.checked = isHydrating ? element.checked : !!checked; - element.defaultChecked = !!checked; - null != name && - "function" !== typeof name && - "symbol" !== typeof name && - "boolean" !== typeof name && - (checkAttributeStringCoercion(name, "name"), (element.name = name)); - } - function setDefaultValue(node, type, value) { - ("number" === type && getActiveElement(node.ownerDocument) === node) || - node.defaultValue === "" + value || - (node.defaultValue = "" + value); - } - function validateOptionProps(element, props) { - null == props.value && - ("object" === typeof props.children && null !== props.children - ? React.Children.forEach(props.children, function (child) { - null == child || - "string" === typeof child || - "number" === typeof child || - "bigint" === typeof child || - didWarnInvalidChild || - ((didWarnInvalidChild = !0), - console.error( - "Cannot infer the option value of complex children. Pass a `value` prop or use a plain string as children to