From 8d3002618fceb937348148c2412b8c3563d90dfa Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Tue, 20 Feb 2024 23:18:00 +0100 Subject: [PATCH] Upgrade react --- package.json | 20 +- ...t-dom-server-legacy.browser.development.js | 3786 +++++++++-------- ...ct-dom-server-legacy.browser.production.js | 744 ++-- ...om-server-legacy.browser.production.min.js | 323 +- ...eact-dom-server-legacy.node.development.js | 3786 +++++++++-------- ...react-dom-server-legacy.node.production.js | 744 ++-- ...t-dom-server-legacy.node.production.min.js | 348 +- ...t-dom-server-rendering-stub.development.js | 2 +- ...ct-dom-server-rendering-stub.production.js | 2 +- ...om-server-rendering-stub.production.min.js | 2 +- .../react-dom-server.browser.development.js | 3786 +++++++++-------- .../react-dom-server.browser.production.js | 744 ++-- ...react-dom-server.browser.production.min.js | 357 +- .../cjs/react-dom-server.bun.production.js | 744 ++-- .../cjs/react-dom-server.edge.development.js | 3786 +++++++++-------- .../cjs/react-dom-server.edge.production.js | 744 ++-- .../react-dom-server.edge.production.min.js | 383 +- .../cjs/react-dom-server.node.development.js | 3786 +++++++++-------- .../cjs/react-dom-server.node.production.js | 744 ++-- .../react-dom-server.node.production.min.js | 382 +- .../react-dom-unstable_testing.development.js | 911 ++-- .../react-dom-unstable_testing.production.js | 350 +- ...act-dom-unstable_testing.production.min.js | 739 ++-- .../cjs/react-dom.development.js | 911 ++-- .../cjs/react-dom.production.js | 350 +- .../cjs/react-dom.production.min.js | 743 ++-- .../cjs/react-dom.profiling.js | 350 +- .../cjs/react-dom.profiling.min.js | 687 ++- .../react-dom-experimental/package.json | 4 +- ...t-dom-server-legacy.browser.development.js | 2190 +++++----- ...ct-dom-server-legacy.browser.production.js | 746 ++-- ...om-server-legacy.browser.production.min.js | 313 +- ...eact-dom-server-legacy.node.development.js | 2190 +++++----- ...react-dom-server-legacy.node.production.js | 746 ++-- ...t-dom-server-legacy.node.production.min.js | 336 +- ...t-dom-server-rendering-stub.development.js | 2 +- ...ct-dom-server-rendering-stub.production.js | 2 +- ...om-server-rendering-stub.production.min.js | 2 +- .../react-dom-server.browser.development.js | 2190 +++++----- .../react-dom-server.browser.production.js | 746 ++-- ...react-dom-server.browser.production.min.js | 333 +- .../cjs/react-dom-server.bun.production.js | 746 ++-- .../cjs/react-dom-server.edge.development.js | 2190 +++++----- .../cjs/react-dom-server.edge.production.js | 746 ++-- .../react-dom-server.edge.production.min.js | 355 +- .../cjs/react-dom-server.node.development.js | 2190 +++++----- .../cjs/react-dom-server.node.production.js | 746 ++-- .../react-dom-server.node.production.min.js | 352 +- .../react-dom/cjs/react-dom.development.js | 828 ++-- .../react-dom/cjs/react-dom.production.js | 350 +- .../react-dom/cjs/react-dom.production.min.js | 737 ++-- .../react-dom/cjs/react-dom.profiling.js | 350 +- .../react-dom/cjs/react-dom.profiling.min.js | 748 ++-- .../next/src/compiled/react-dom/package.json | 4 +- .../cjs/react-jsx-dev-runtime.development.js | 684 ++- .../cjs/react-jsx-runtime.development.js | 734 ++-- .../cjs/react-jsx-runtime.production.js | 8 +- .../cjs/react-jsx-runtime.profiling.js | 8 +- ...ct-jsx-runtime.react-server.development.js | 737 ++-- ...act-jsx-runtime.react-server.production.js | 11 +- ...jsx-runtime.react-server.production.min.js | 2 +- .../cjs/react.development.js | 1794 ++++---- .../cjs/react.production.js | 196 +- .../cjs/react.production.min.js | 45 +- .../cjs/react.react-server.development.js | 1826 ++++---- .../cjs/react.react-server.production.js | 115 +- .../cjs/react.react-server.production.min.js | 46 +- .../jsx-runtime.react-server.js | 7 + ...om-turbopack-client.browser.development.js | 47 +- ...dom-turbopack-client.browser.production.js | 13 +- ...turbopack-client.browser.production.min.js | 22 +- ...r-dom-turbopack-client.edge.development.js | 103 +- ...er-dom-turbopack-client.edge.production.js | 59 +- ...om-turbopack-client.edge.production.min.js | 46 +- ...r-dom-turbopack-client.node.development.js | 103 +- ...er-dom-turbopack-client.node.production.js | 59 +- ...om-turbopack-client.node.production.min.js | 44 +- ...opack-client.node.unbundled.development.js | 103 +- ...bopack-client.node.unbundled.production.js | 59 +- ...ck-client.node.unbundled.production.min.js | 40 +- ...om-turbopack-server.browser.development.js | 328 +- ...dom-turbopack-server.browser.production.js | 230 +- ...turbopack-server.browser.production.min.js | 131 +- ...r-dom-turbopack-server.edge.development.js | 328 +- ...er-dom-turbopack-server.edge.production.js | 230 +- ...om-turbopack-server.edge.production.min.js | 133 +- ...r-dom-turbopack-server.node.development.js | 328 +- ...er-dom-turbopack-server.node.production.js | 228 +- ...om-turbopack-server.node.production.min.js | 135 +- ...opack-server.node.unbundled.development.js | 328 +- ...bopack-server.node.unbundled.production.js | 228 +- ...ck-server.node.unbundled.production.min.js | 131 +- .../package.json | 4 +- ...om-turbopack-client.browser.development.js | 47 +- ...dom-turbopack-client.browser.production.js | 13 +- ...turbopack-client.browser.production.min.js | 30 +- ...r-dom-turbopack-client.edge.development.js | 103 +- ...er-dom-turbopack-client.edge.production.js | 59 +- ...om-turbopack-client.edge.production.min.js | 48 +- ...r-dom-turbopack-client.node.development.js | 103 +- ...er-dom-turbopack-client.node.production.js | 59 +- ...om-turbopack-client.node.production.min.js | 36 +- ...opack-client.node.unbundled.development.js | 103 +- ...bopack-client.node.unbundled.production.js | 59 +- ...ck-client.node.unbundled.production.min.js | 60 +- ...om-turbopack-server.browser.development.js | 327 +- ...dom-turbopack-server.browser.production.js | 231 +- ...turbopack-server.browser.production.min.js | 118 +- ...r-dom-turbopack-server.edge.development.js | 327 +- ...er-dom-turbopack-server.edge.production.js | 231 +- ...om-turbopack-server.edge.production.min.js | 122 +- ...r-dom-turbopack-server.node.development.js | 327 +- ...er-dom-turbopack-server.node.production.js | 229 +- ...om-turbopack-server.node.production.min.js | 126 +- ...opack-server.node.unbundled.development.js | 327 +- ...bopack-server.node.unbundled.production.js | 229 +- ...ck-server.node.unbundled.production.min.js | 120 +- .../react-server-dom-turbopack/package.json | 4 +- ...-dom-webpack-client.browser.development.js | 47 +- ...r-dom-webpack-client.browser.production.js | 13 +- ...m-webpack-client.browser.production.min.js | 26 +- ...ver-dom-webpack-client.edge.development.js | 103 +- ...rver-dom-webpack-client.edge.production.js | 59 +- ...-dom-webpack-client.edge.production.min.js | 46 +- ...ver-dom-webpack-client.node.development.js | 103 +- ...rver-dom-webpack-client.node.production.js | 59 +- ...-dom-webpack-client.node.production.min.js | 44 +- ...bpack-client.node.unbundled.development.js | 103 +- ...ebpack-client.node.unbundled.production.js | 59 +- ...ck-client.node.unbundled.production.min.js | 40 +- ...-dom-webpack-server.browser.development.js | 172 +- ...r-dom-webpack-server.browser.production.js | 67 +- ...m-webpack-server.browser.production.min.js | 105 +- ...ver-dom-webpack-server.edge.development.js | 172 +- ...rver-dom-webpack-server.edge.production.js | 67 +- ...-dom-webpack-server.edge.production.min.js | 107 +- ...ver-dom-webpack-server.node.development.js | 172 +- ...rver-dom-webpack-server.node.production.js | 67 +- ...-dom-webpack-server.node.production.min.js | 111 +- ...bpack-server.node.unbundled.development.js | 172 +- ...ebpack-server.node.unbundled.production.js | 67 +- ...ck-server.node.unbundled.production.min.js | 107 +- .../package.json | 4 +- ...-dom-webpack-client.browser.development.js | 47 +- ...r-dom-webpack-client.browser.production.js | 13 +- ...m-webpack-client.browser.production.min.js | 32 +- ...ver-dom-webpack-client.edge.development.js | 103 +- ...rver-dom-webpack-client.edge.production.js | 59 +- ...-dom-webpack-client.edge.production.min.js | 48 +- ...ver-dom-webpack-client.node.development.js | 103 +- ...rver-dom-webpack-client.node.production.js | 59 +- ...-dom-webpack-client.node.production.min.js | 36 +- ...bpack-client.node.unbundled.development.js | 103 +- ...ebpack-client.node.unbundled.production.js | 59 +- ...ck-client.node.unbundled.production.min.js | 60 +- ...-dom-webpack-server.browser.development.js | 173 +- ...r-dom-webpack-server.browser.production.js | 68 +- ...m-webpack-server.browser.production.min.js | 96 +- ...ver-dom-webpack-server.edge.development.js | 173 +- ...rver-dom-webpack-server.edge.production.js | 68 +- ...-dom-webpack-server.edge.production.min.js | 98 +- ...ver-dom-webpack-server.node.development.js | 173 +- ...rver-dom-webpack-server.node.production.js | 68 +- ...-dom-webpack-server.node.production.min.js | 102 +- ...bpack-server.node.unbundled.development.js | 173 +- ...ebpack-server.node.unbundled.production.js | 68 +- ...ck-server.node.unbundled.production.min.js | 96 +- .../react-server-dom-webpack/package.json | 4 +- .../cjs/react-jsx-dev-runtime.development.js | 684 ++- .../cjs/react-jsx-runtime.development.js | 734 ++-- .../react/cjs/react-jsx-runtime.production.js | 8 +- .../react/cjs/react-jsx-runtime.profiling.js | 8 +- ...ct-jsx-runtime.react-server.development.js | 737 ++-- ...act-jsx-runtime.react-server.production.js | 11 +- ...jsx-runtime.react-server.production.min.js | 2 +- .../compiled/react/cjs/react.development.js | 1794 ++++---- .../compiled/react/cjs/react.production.js | 196 +- .../react/cjs/react.production.min.js | 34 +- .../cjs/react.react-server.development.js | 1826 ++++---- .../cjs/react.react-server.production.js | 115 +- .../cjs/react.react-server.production.min.js | 33 +- .../react/jsx-runtime.react-server.js | 7 + pnpm-lock.yaml | 104 +- 183 files changed, 40726 insertions(+), 33248 deletions(-) create mode 100644 packages/next/src/compiled/react-experimental/jsx-runtime.react-server.js create mode 100644 packages/next/src/compiled/react/jsx-runtime.react-server.js diff --git a/package.json b/package.json index 10bbec389ec84..5cd05bf38186a 100644 --- a/package.json +++ b/package.json @@ -198,16 +198,16 @@ "random-seed": "0.3.0", "react": "18.2.0", "react-17": "npm:react@17.0.2", - "react-builtin": "npm:react@18.3.0-canary-ba5e6a832-20240208", + "react-builtin": "npm:react@18.3.0-canary-a515d753b-20240220", "react-dom": "18.2.0", "react-dom-17": "npm:react-dom@17.0.2", - "react-dom-builtin": "npm:react-dom@18.3.0-canary-ba5e6a832-20240208", - "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-ba5e6a832-20240208", - "react-experimental-builtin": "npm:react@0.0.0-experimental-ba5e6a832-20240208", - "react-server-dom-turbopack": "18.3.0-canary-ba5e6a832-20240208", - "react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-ba5e6a832-20240208", - "react-server-dom-webpack": "18.3.0-canary-ba5e6a832-20240208", - "react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-ba5e6a832-20240208", + "react-dom-builtin": "npm:react-dom@18.3.0-canary-a515d753b-20240220", + "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-a515d753b-20240220", + "react-experimental-builtin": "npm:react@0.0.0-experimental-a515d753b-20240220", + "react-server-dom-turbopack": "18.3.0-canary-a515d753b-20240220", + "react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-a515d753b-20240220", + "react-server-dom-webpack": "18.3.0-canary-a515d753b-20240220", + "react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-a515d753b-20240220", "react-ssr-prepass": "1.0.8", "react-virtualized": "9.22.3", "relay-compiler": "13.0.2", @@ -217,8 +217,8 @@ "resolve-from": "5.0.0", "sass": "1.54.0", "satori": "0.10.9", - "scheduler-builtin": "npm:scheduler@0.24.0-canary-ba5e6a832-20240208", - "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-ba5e6a832-20240208", + "scheduler-builtin": "npm:scheduler@0.24.0-canary-a515d753b-20240220", + "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-a515d753b-20240220", "seedrandom": "3.0.5", "selenium-webdriver": "4.0.0-beta.4", "semver": "7.3.7", diff --git a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.development.js b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.development.js index 35206525646f9..eda842f982009 100644 --- a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.development.js +++ b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.development.js @@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") { var React = require("next/dist/compiled/react-experimental"); var ReactDOM = require('react-dom'); -var ReactVersion = '18.3.0-experimental-ba5e6a832-20240208'; +var ReactVersion = '18.3.0-experimental-a515d753b-20240220'; var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; @@ -74,6 +74,329 @@ function printWarning(level, format, args) { } } +// ----------------------------------------------------------------------------- +var enableFloat = true; // Enables unstable_useMemoCache hook, intended as a compilation target for + +// ATTENTION +// 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_ELEMENT_TYPE = Symbol.for('react.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_CACHE_TYPE = Symbol.for('react.cache'); +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 isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare + +function isArray(a) { + return isArrayImpl(a); +} + +// in case they error. + +var jsxPropsParents = new WeakMap(); +var jsxChildrenParents = new WeakMap(); +function objectName(object) { + // $FlowFixMe[method-unbinding] + var name = Object.prototype.toString.call(object); + return name.replace(/^\[object (.*)\]$/, function (m, p0) { + return p0; + }); +} + +function describeKeyForErrorMessage(key) { + var encodedKey = JSON.stringify(key); + return '"' + key + '"' === encodedKey ? key : encodedKey; +} + +function describeValueForErrorMessage(value) { + switch (typeof value) { + case 'string': + { + return JSON.stringify(value.length <= 10 ? value : value.slice(0, 10) + '...'); + } + + case 'object': + { + if (isArray(value)) { + return '[...]'; + } + + if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + + var name = objectName(value); + + if (name === 'Object') { + return '{...}'; + } + + return name; + } + + case 'function': + { + if (value.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } + + var _name = value.displayName || value.name; + + return _name ? 'function ' + _name : 'function'; + } + + default: + // eslint-disable-next-line react-internal/safe-string-coercion + return String(value); + } +} + +function describeElementType(type) { + if (typeof type === 'string') { + return type; + } + + switch (type) { + case REACT_SUSPENSE_TYPE: + return 'Suspense'; + + case REACT_SUSPENSE_LIST_TYPE: + return 'SuspenseList'; + } + + if (typeof type === 'object') { + switch (type.$$typeof) { + case REACT_FORWARD_REF_TYPE: + return describeElementType(type.render); + + case REACT_MEMO_TYPE: + return describeElementType(type.type); + + case REACT_LAZY_TYPE: + { + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + + try { + // Lazy may contain any component type so we recursively resolve it. + return describeElementType(init(payload)); + } catch (x) {} + } + } + } + + return ''; +} + +var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference'); + +function describeClientReference(ref) { + return 'client'; +} + +function describeObjectForErrorMessage(objectOrArray, expandedName) { + var objKind = objectName(objectOrArray); + + if (objKind !== 'Object' && objKind !== 'Array') { + return objKind; + } + + var str = ''; + var start = -1; + var length = 0; + + if (isArray(objectOrArray)) { + if (jsxChildrenParents.has(objectOrArray)) { + // Print JSX Children + var type = jsxChildrenParents.get(objectOrArray); + str = '<' + describeElementType(type) + '>'; + var array = objectOrArray; + + for (var i = 0; i < array.length; i++) { + var value = array[i]; + var substr = void 0; + + if (typeof value === 'string') { + substr = value; + } else if (typeof value === 'object' && value !== null) { + substr = '{' + describeObjectForErrorMessage(value) + '}'; + } else { + substr = '{' + describeValueForErrorMessage(value) + '}'; + } + + if ('' + i === expandedName) { + start = str.length; + length = substr.length; + str += substr; + } else if (substr.length < 15 && str.length + substr.length < 40) { + str += substr; + } else { + str += '{...}'; + } + } + + str += ''; + } else { + // Print Array + str = '['; + var _array = objectOrArray; + + for (var _i = 0; _i < _array.length; _i++) { + if (_i > 0) { + str += ', '; + } + + var _value = _array[_i]; + + var _substr = void 0; + + if (typeof _value === 'object' && _value !== null) { + _substr = describeObjectForErrorMessage(_value); + } else { + _substr = describeValueForErrorMessage(_value); + } + + if ('' + _i === expandedName) { + start = str.length; + length = _substr.length; + str += _substr; + } else if (_substr.length < 10 && str.length + _substr.length < 40) { + str += _substr; + } else { + str += '...'; + } + } + + str += ']'; + } + } else { + if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) { + str = '<' + describeElementType(objectOrArray.type) + '/>'; + } else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) { + return describeClientReference(); + } else if (jsxPropsParents.has(objectOrArray)) { + // Print JSX + var _type = jsxPropsParents.get(objectOrArray); + + str = '<' + (describeElementType(_type) || '...'); + var object = objectOrArray; + var names = Object.keys(object); + + for (var _i2 = 0; _i2 < names.length; _i2++) { + str += ' '; + var name = names[_i2]; + str += describeKeyForErrorMessage(name) + '='; + var _value2 = object[name]; + + var _substr2 = void 0; + + if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) { + _substr2 = describeObjectForErrorMessage(_value2); + } else { + _substr2 = describeValueForErrorMessage(_value2); + } + + if (typeof _value2 !== 'string') { + _substr2 = '{' + _substr2 + '}'; + } + + if (name === expandedName) { + start = str.length; + length = _substr2.length; + str += _substr2; + } else if (_substr2.length < 10 && str.length + _substr2.length < 40) { + str += _substr2; + } else { + str += '...'; + } + } + + str += '>'; + } else { + // Print Object + str = '{'; + var _object = objectOrArray; + + var _names = Object.keys(_object); + + for (var _i3 = 0; _i3 < _names.length; _i3++) { + if (_i3 > 0) { + str += ', '; + } + + var _name2 = _names[_i3]; + str += describeKeyForErrorMessage(_name2) + ': '; + var _value3 = _object[_name2]; + + var _substr3 = void 0; + + if (typeof _value3 === 'object' && _value3 !== null) { + _substr3 = describeObjectForErrorMessage(_value3); + } else { + _substr3 = describeValueForErrorMessage(_value3); + } + + if (_name2 === expandedName) { + start = str.length; + length = _substr3.length; + str += _substr3; + } else if (_substr3.length < 10 && str.length + _substr3.length < 40) { + str += _substr3; + } else { + str += '...'; + } + } + + str += '}'; + } + } + + if (expandedName === undefined) { + return str; + } + + if (start > -1 && length > 0) { + var highlight = ' '.repeat(start) + '^'.repeat(length); + return '\n ' + str + '\n ' + highlight; + } + + return '\n ' + str; +} + // A pure JS implementation of a string hashing function. We do not use it for // security or obfuscation purposes, only to create compact hashes. So we // prioritize speed over collision avoidance. For example, we use this to hash @@ -292,9 +615,6 @@ function checkHtmlStringCoercion(value) { } } -// ----------------------------------------------------------------------------- -var enableFloat = true; // Enables unstable_useMemoCache hook, intended as a compilation target for - // $FlowFixMe[method-unbinding] var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -1607,12 +1927,6 @@ function sanitizeURL(url) { return url; } -var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare - -function isArray(a) { - return isArrayImpl(a); -} - // The build script is at scripts/rollup/generate-inline-fizz-runtime.js. // Run `yarn generate-inline-fizz-runtime` to generate. var clientRenderBoundary = '$RX=function(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};'; @@ -6670,45 +6984,6 @@ function writeEndClientRenderedSuspenseBoundary(destination, renderState) { } var NotPendingTransition = NotPending; -// ATTENTION -// 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_ELEMENT_TYPE = Symbol.for('react.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'); -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_CACHE_TYPE = Symbol.for('react.cache'); -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; -} - function getWrappedName(outerType, innerType, wrapperName) { var displayName = outerType.displayName; @@ -6780,13 +7055,23 @@ function getComponentNameFromType(type) { } switch (type.$$typeof) { + case REACT_PROVIDER_TYPE: + { + var provider = type; + return getContextName(provider._context) + '.Provider'; + } + case REACT_CONTEXT_TYPE: var context = type; - return getContextName(context) + '.Consumer'; - case REACT_PROVIDER_TYPE: - var provider = type; - return getContextName(provider._context) + '.Provider'; + { + return getContextName(context) + '.Consumer'; + } + + case REACT_CONSUMER_TYPE: + { + return null; + } case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, 'ForwardRef'); @@ -6818,1209 +7103,705 @@ function getComponentNameFromType(type) { return null; } -// 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; +var warnedAboutMissingGetChildContext; -function disabledLog() {} +{ + warnedAboutMissingGetChildContext = {}; +} -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 emptyContextObject = {}; - var props = { - configurable: true, - enumerable: true, - value: disabledLog, - writable: true - }; // $FlowFixMe[cannot-write] Flow thinks console is immutable. +{ + Object.freeze(emptyContextObject); +} - 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 getMaskedContext(type, unmaskedContext) { + { + var contextTypes = type.contextTypes; + + if (!contextTypes) { + return emptyContextObject; } - disabledDepth++; + var context = {}; + + for (var key in contextTypes) { + context[key] = unmaskedContext[key]; + } + + return context; } } -function reenableLogs() { +function processChildContext(instance, type, parentContext, childContextTypes) { { - disabledDepth--; + // TODO (bvaughn) Replace this behavior with an invariant() in the future. + // It has only been added in Fiber to match the (unintentional) behavior in Stack. + if (typeof instance.getChildContext !== 'function') { + { + var componentName = getComponentNameFromType(type) || 'Unknown'; - 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. + if (!warnedAboutMissingGetChildContext[componentName]) { + warnedAboutMissingGetChildContext[componentName] = true; - 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 */ + error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); + } + } + + return parentContext; } - if (disabledDepth < 0) { - error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); + var childContext = instance.getChildContext(); + + for (var contextKey in childContext) { + if (!(contextKey in childContextTypes)) { + throw new Error((getComponentNameFromType(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."); + } } + + return assign({}, parentContext, childContext); } } -var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher; -var prefix; -function describeBuiltInComponentFrame(name, ownerFn) { - { - if (prefix === undefined) { - // Extract the VM specific prefix used by each line. - try { - throw Error(); - } catch (x) { - var match = x.stack.trim().match(/\n( *(at )?)/); - prefix = match && match[1] || ''; - } - } // We use the prefix to ensure our stacks line up with native stack frames. +var rendererSigil; +{ + // Use this to detect multiple renderers using the same context + rendererSigil = {}; +} // Used to store the parent path of all context overrides in a shared linked list. +// Forming a reverse tree. +// The structure of a context snapshot is an implementation of this file. +// Currently, it's implemented as tracking the current active node. - return '\n' + prefix + name; + +var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances. +// This global (actually thread local) state represents what state all those "current", +// fields are currently in. + +var currentActiveSnapshot = null; + +function popNode(prev) { + { + prev.context._currentValue2 = prev.parentValue; } } -var reentry = false; -var componentFrameCache; -{ - var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; - componentFrameCache = new PossiblyWeakMap(); +function pushNode(next) { + { + next.context._currentValue2 = next.value; + } } -/** - * 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 popToNearestCommonAncestor(prev, next) { + if (prev === next) ; else { + popNode(prev); + var parentPrev = prev.parent; + var parentNext = next.parent; -function describeNativeComponentFrame(fn, construct) { - // If something asked for a stack inside a fake render, it should get ignored. - if (!fn || reentry) { - return ''; - } + if (parentPrev === null) { + if (parentNext !== null) { + throw new Error('The stacks must reach the root at the same time. This is a bug in React.'); + } + } else { + if (parentNext === null) { + throw new Error('The stacks must reach the root at the same time. This is a bug in React.'); + } - { - var frame = componentFrameCache.get(fn); + popToNearestCommonAncestor(parentPrev, parentNext); + } // On the way back, we push the new ones that weren't common. - if (frame !== undefined) { - return frame; - } + + pushNode(next); } +} - reentry = true; - var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. +function popAllPrevious(prev) { + popNode(prev); + var parentPrev = prev.parent; - Error.prepareStackTrace = undefined; - var previousDispatcher; + if (parentPrev !== null) { + popAllPrevious(parentPrev); + } +} - { - previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function - // for warnings. +function pushAllNext(next) { + var parentNext = next.parent; - ReactCurrentDispatcher$1.current = null; - disableLogs(); + if (parentNext !== null) { + pushAllNext(parentNext); } - /** - * 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. - */ + pushNode(next); +} - var RunInRootFrame = { - DetermineComponentFrameRoot: function () { - var control; +function popPreviousToCommonLevel(prev, next) { + popNode(prev); + var parentPrev = prev.parent; - try { - // This should throw. - if (construct) { - // Something should be setting the props in the constructor. - var Fake = function () { - throw Error(); - }; // $FlowFixMe[prop-missing] + if (parentPrev === null) { + throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.'); + } + if (parentPrev.depth === next.depth) { + // We found the same level. Now we just need to find a shared ancestor. + popToNearestCommonAncestor(parentPrev, next); + } else { + // We must still be deeper. + popPreviousToCommonLevel(parentPrev, next); + } +} - 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(); - } - }); +function popNextToCommonLevel(prev, next) { + var parentNext = next.parent; - 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; - } + if (parentNext === null) { + throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.'); + } - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x) { - control = x; - } // $FlowFixMe[prop-missing] found when upgrading Flow + if (prev.depth === parentNext.depth) { + // We found the same level. Now we just need to find a shared ancestor. + popToNearestCommonAncestor(prev, parentNext); + } else { + // We must still be deeper. + popNextToCommonLevel(prev, parentNext); + } + pushNode(next); +} // Perform context switching to the new snapshot. +// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by +// updating all the context's current values. That way reads, always just read the current value. +// At the cost of updating contexts even if they're never read by this subtree. - 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 +function switchContext(newSnapshot) { + // The basic algorithm we need to do is to pop back any contexts that are no longer on the stack. + // We also need to update any new contexts that are now on the stack with the deepest value. + // The easiest way to update new contexts is to just reapply them in reverse order from the + // perspective of the backpointers. To avoid allocating a lot when switching, we use the stack + // for that. Therefore this algorithm is recursive. + // 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go. + // 2) Then we find the nearest common ancestor from there. Popping old contexts as we go. + // 3) Then we reapply new contexts on the way back up the stack. + var prev = currentActiveSnapshot; + var next = newSnapshot; - 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 (prev !== next) { + if (prev === null) { + // $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev. + pushAllNext(next); + } else if (next === null) { + popAllPrevious(prev); + } else if (prev.depth === next.depth) { + popToNearestCommonAncestor(prev, next); + } else if (prev.depth > next.depth) { + popPreviousToCommonLevel(prev, next); + } else { + popNextToCommonLevel(prev, next); + } - 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]; - } + currentActiveSnapshot = next; + } +} +function pushProvider(context, nextValue) { + var prevValue; + + { + prevValue = context._currentValue2; + context._currentValue2 = nextValue; + + { + if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) { + error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); } - return [null, null]; + context._currentRenderer2 = rendererSigil; } - }; // $FlowFixMe[prop-missing] + } - RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; - var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable. + var prevNode = currentActiveSnapshot; + var newNode = { + parent: prevNode, + depth: prevNode === null ? 0 : prevNode.depth + 1, + context: context, + parentValue: prevValue, + value: nextValue + }; + currentActiveSnapshot = newNode; + return newNode; +} +function popProvider(context) { + var prevSnapshot = currentActiveSnapshot; - 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' - }); + if (prevSnapshot === null) { + throw new Error('Tried to pop a Context at the root of the app. This is a bug in React.'); } - try { - var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), - sampleStack = _RunInRootFrame$Deter[0], - controlStack = _RunInRootFrame$Deter[1]; + { + if (prevSnapshot.context !== context) { + error('The parent context is not the expected context. This is probably a bug in React.'); + } + } - 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; + { + var _value = prevSnapshot.parentValue; + prevSnapshot.context._currentValue2 = _value; - while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { - s++; + { + if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) { + error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); } - 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... + context._currentRenderer2 = rendererSigil; + } + } + return currentActiveSnapshot = prevSnapshot.parent; +} +function getActiveContext() { + return currentActiveSnapshot; +} +function readContext$1(context) { + var value = context._currentValue2; + return value; +} - if (s === sampleLines.length || c === controlLines.length) { - s = sampleLines.length - 1; - c = controlLines.length - 1; +/** + * `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; +} - 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--; - } - } +var didWarnAboutNoopUpdateForComponent = {}; +var didWarnAboutDeprecatedWillMount = {}; +var didWarnAboutUninitializedState; +var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; +var didWarnAboutLegacyLifecyclesAndDerivedState; +var didWarnAboutUndefinedDerivedState; +var didWarnAboutDirectlyAssigningPropsToState; +var didWarnAboutContextTypeAndContextTypes; +var didWarnAboutInvalidateContextType; +var didWarnOnInvalidCallback; - 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. +{ + didWarnAboutUninitializedState = new Set(); + didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); + didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); + didWarnAboutDirectlyAssigningPropsToState = new Set(); + didWarnAboutUndefinedDerivedState = new Set(); + didWarnAboutContextTypeAndContextTypes = new Set(); + didWarnAboutInvalidateContextType = new Set(); + didWarnOnInvalidCallback = new Set(); +} - 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. +function warnOnInvalidCallback(callback, callerName) { + { + if (callback === null || typeof callback === 'function') { + return; + } + var key = callerName + '_' + callback; - if (fn.displayName && _frame.includes('')) { - _frame = _frame.replace('', fn.displayName); - } + if (!didWarnOnInvalidCallback.has(key)) { + didWarnOnInvalidCallback.add(key); - if (true) { - if (typeof fn === 'function') { - componentFrameCache.set(fn, _frame); - } - } // Return the line we found. + error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); + } + } +} +function warnOnUndefinedDerivedState(type, partialState) { + { + if (partialState === undefined) { + var componentName = getComponentNameFromType(type) || 'Component'; - return _frame; - } - } while (s >= 1 && c >= 0); - } + if (!didWarnAboutUndefinedDerivedState.has(componentName)) { + didWarnAboutUndefinedDerivedState.add(componentName); - break; - } + error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName); } } - } finally { - reentry = false; - - { - ReactCurrentDispatcher$1.current = previousDispatcher; - reenableLogs(); - } - - 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) : ''; + } +} +function warnNoop(publicInstance, callerName) { { - if (typeof fn === 'function') { - componentFrameCache.set(fn, syntheticFrame); + var _constructor = publicInstance.constructor; + var componentName = _constructor && getComponentNameFromType(_constructor) || 'ReactClass'; + var warningKey = componentName + '.' + callerName; + + if (didWarnAboutNoopUpdateForComponent[warningKey]) { + return; } - } - return syntheticFrame; -} + error('%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName); -function describeClassComponentFrame(ctor, ownerFn) { - { - return describeNativeComponentFrame(ctor, true); - } -} -function describeFunctionComponentFrame(fn, ownerFn) { - { - return describeNativeComponentFrame(fn, false); + didWarnAboutNoopUpdateForComponent[warningKey] = true; } } -function shouldConstruct$1(Component) { - var prototype = Component.prototype; - return !!(prototype && prototype.isReactComponent); -} +var classComponentUpdater = { + isMounted: function (inst) { + return false; + }, + // $FlowFixMe[missing-local-annot] + enqueueSetState: function (inst, payload, callback) { + var internals = get(inst); -function describeUnknownElementTypeFrameInDEV(type, ownerFn) { + if (internals.queue === null) { + warnNoop(inst, 'setState'); + } else { + internals.queue.push(payload); - if (type == null) { - return ''; - } + { + if (callback !== undefined && callback !== null) { + warnOnInvalidCallback(callback, 'setState'); + } + } + } + }, + enqueueReplaceState: function (inst, payload, callback) { + var internals = get(inst); + internals.replace = true; + internals.queue = [payload]; - if (typeof type === 'function') { { - return describeNativeComponentFrame(type, shouldConstruct$1(type)); + if (callback !== undefined && callback !== null) { + warnOnInvalidCallback(callback, 'setState'); + } } - } + }, + // $FlowFixMe[missing-local-annot] + enqueueForceUpdate: function (inst, callback) { + var internals = get(inst); - if (typeof type === 'string') { - return describeBuiltInComponentFrame(type); + if (internals.queue === null) { + warnNoop(inst, 'forceUpdate'); + } else { + { + if (callback !== undefined && callback !== null) { + warnOnInvalidCallback(callback, 'setState'); + } + } + } } +}; - switch (type) { - case REACT_SUSPENSE_TYPE: - return describeBuiltInComponentFrame('Suspense'); +function applyDerivedStateFromProps(instance, ctor, getDerivedStateFromProps, prevState, nextProps) { + var partialState = getDerivedStateFromProps(nextProps, prevState); - case REACT_SUSPENSE_LIST_TYPE: - return describeBuiltInComponentFrame('SuspenseList'); - } + { + warnOnUndefinedDerivedState(ctor, partialState); + } // Merge the partial state and the previous state. - if (typeof type === 'object') { - switch (type.$$typeof) { - case REACT_FORWARD_REF_TYPE: - return describeFunctionComponentFrame(type.render); - case REACT_MEMO_TYPE: - // Memo may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(type.type, ownerFn); + var newState = partialState === null || partialState === undefined ? prevState : assign({}, prevState, partialState); + return newState; +} - case REACT_LAZY_TYPE: - { - var lazyComponent = type; - var payload = lazyComponent._payload; - var init = lazyComponent._init; +function constructClassInstance(ctor, props, maskedLegacyContext) { + var context = emptyContextObject; + var contextType = ctor.contextType; - try { - // Lazy may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(init(payload), ownerFn); - } catch (x) {} + { + if ('contextType' in ctor) { + var isValid = // Allow null for conditional declaration + contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE; + + if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { + didWarnAboutInvalidateContextType.add(ctor); + var addendum = ''; + + if (contextType === undefined) { + addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.'; + } else if (typeof contextType !== 'object') { + addendum = ' However, it is set to a ' + typeof contextType + '.'; + } else if (contextType.$$typeof === REACT_CONSUMER_TYPE) { + addendum = ' Did you accidentally pass the Context.Consumer instead?'; + } else { + addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; } + + error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentNameFromType(ctor) || 'Component', addendum); + } } } - return ''; -} + if (typeof contextType === 'object' && contextType !== null) { + context = readContext$1(contextType); + } else { + context = maskedLegacyContext; + } -var loggedTypeFailures = {}; -var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; + var instance = new ctor(props, context); -function setCurrentlyValidatingElement(element) { { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV(element.type, owner ? owner.type : null); - ReactDebugCurrentFrame$1.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame$1.setExtraStackFrame(null); - } - } -} + if (typeof ctor.getDerivedStateFromProps === 'function' && (instance.state === null || instance.state === undefined)) { + var componentName = getComponentNameFromType(ctor) || 'Component'; -function checkPropTypes(typeSpecs, values, location, componentName, element) { - { - // $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it. - var has = Function.call.bind(hasOwnProperty); - - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== 'function') { - // eslint-disable-next-line react-internal/prod-error-codes - var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'); - err.name = 'Invariant Violation'; - throw err; - } + if (!didWarnAboutUninitializedState.has(componentName)) { + didWarnAboutUninitializedState.add(componentName); - error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); - } catch (ex) { - error$1 = ex; - } + error('`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName); + } + } // If new component APIs are defined, "unsafe" lifecycles won't be called. + // Warn about these lifecycles if they are present. + // Don't warn about react-lifecycles-compat polyfilled methods though. - if (error$1 && !(error$1 instanceof Error)) { - setCurrentlyValidatingElement(element); - error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1); + if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') { + var foundWillMountName = null; + var foundWillReceivePropsName = null; + var foundWillUpdateName = null; - setCurrentlyValidatingElement(null); - } + if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { + foundWillMountName = 'componentWillMount'; + } else if (typeof instance.UNSAFE_componentWillMount === 'function') { + foundWillMountName = 'UNSAFE_componentWillMount'; + } + + if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { + foundWillReceivePropsName = 'componentWillReceiveProps'; + } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { + foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; + } + + if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { + foundWillUpdateName = 'componentWillUpdate'; + } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { + foundWillUpdateName = 'UNSAFE_componentWillUpdate'; + } + + if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { + var _componentName = getComponentNameFromType(ctor) || 'Component'; - if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error$1.message] = true; - setCurrentlyValidatingElement(element); + var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; - error('Failed %s type: %s', location, error$1.message); + if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { + didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); - setCurrentlyValidatingElement(null); + error('Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://reactjs.org/link/unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : ''); } } } } -} - -var warnedAboutMissingGetChildContext; - -{ - warnedAboutMissingGetChildContext = {}; -} - -var emptyContextObject = {}; -{ - Object.freeze(emptyContextObject); + return instance; } -function getMaskedContext(type, unmaskedContext) { +function checkClassInstance(instance, ctor, newProps) { { - var contextTypes = type.contextTypes; + var name = getComponentNameFromType(ctor) || 'Component'; + var renderPresent = instance.render; - if (!contextTypes) { - return emptyContextObject; + if (!renderPresent) { + if (ctor.prototype && typeof ctor.prototype.render === 'function') { + error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); + } else { + error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); + } } - var context = {}; - - for (var key in contextTypes) { - context[key] = unmaskedContext[key]; + if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) { + error('getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name); } - { - var name = getComponentNameFromType(type) || 'Unknown'; - checkPropTypes(contextTypes, context, 'context', name); + if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) { + error('getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name); } - return context; - } -} -function processChildContext(instance, type, parentContext, childContextTypes) { - { - // TODO (bvaughn) Replace this behavior with an invariant() in the future. - // It has only been added in Fiber to match the (unintentional) behavior in Stack. - if (typeof instance.getChildContext !== 'function') { - { - var componentName = getComponentNameFromType(type) || 'Unknown'; + if (instance.propTypes) { + error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name); + } - if (!warnedAboutMissingGetChildContext[componentName]) { - warnedAboutMissingGetChildContext[componentName] = true; + if (instance.contextType) { + error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name); + } - error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); - } + { + if (instance.contextTypes) { + error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name); } - return parentContext; - } - - var childContext = instance.getChildContext(); + if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) { + didWarnAboutContextTypeAndContextTypes.add(ctor); - for (var contextKey in childContext) { - if (!(contextKey in childContextTypes)) { - throw new Error((getComponentNameFromType(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."); + error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name); } } - { - var name = getComponentNameFromType(type) || 'Unknown'; - checkPropTypes(childContextTypes, childContext, 'child context', name); + if (typeof instance.componentShouldUpdate === 'function') { + error('%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name); } - return assign({}, parentContext, childContext); - } -} + if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { + error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentNameFromType(ctor) || 'A pure component'); + } -var rendererSigil; + if (typeof instance.componentDidUnmount === 'function') { + error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name); + } -{ - // Use this to detect multiple renderers using the same context - rendererSigil = {}; -} // Used to store the parent path of all context overrides in a shared linked list. -// Forming a reverse tree. -// The structure of a context snapshot is an implementation of this file. -// Currently, it's implemented as tracking the current active node. + if (typeof instance.componentDidReceiveProps === 'function') { + error('%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name); + } + if (typeof instance.componentWillRecieveProps === 'function') { + error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name); + } -var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances. -// This global (actually thread local) state represents what state all those "current", -// fields are currently in. + if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') { + error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name); + } -var currentActiveSnapshot = null; + var hasMutatedProps = instance.props !== newProps; -function popNode(prev) { - { - prev.context._currentValue2 = prev.parentValue; - } -} + if (instance.props !== undefined && hasMutatedProps) { + error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name); + } -function pushNode(next) { - { - next.context._currentValue2 = next.value; - } -} + if (instance.defaultProps) { + error('Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name); + } -function popToNearestCommonAncestor(prev, next) { - if (prev === next) ; else { - popNode(prev); - var parentPrev = prev.parent; - var parentNext = next.parent; + if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) { + didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); - if (parentPrev === null) { - if (parentNext !== null) { - throw new Error('The stacks must reach the root at the same time. This is a bug in React.'); - } - } else { - if (parentNext === null) { - throw new Error('The stacks must reach the root at the same time. This is a bug in React.'); - } + error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentNameFromType(ctor)); + } - popToNearestCommonAncestor(parentPrev, parentNext); - } // On the way back, we push the new ones that weren't common. + if (typeof instance.getDerivedStateFromProps === 'function') { + error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); + } + if (typeof instance.getDerivedStateFromError === 'function') { + error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); + } - pushNode(next); - } -} + if (typeof ctor.getSnapshotBeforeUpdate === 'function') { + error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name); + } -function popAllPrevious(prev) { - popNode(prev); - var parentPrev = prev.parent; + var state = instance.state; - if (parentPrev !== null) { - popAllPrevious(parentPrev); + if (state && (typeof state !== 'object' || isArray(state))) { + error('%s.state: must be set to an object or null', name); + } + + if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') { + error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name); + } } } -function pushAllNext(next) { - var parentNext = next.parent; +function callComponentWillMount(type, instance) { + var oldState = instance.state; - if (parentNext !== null) { - pushAllNext(parentNext); - } + if (typeof instance.componentWillMount === 'function') { + { + if (instance.componentWillMount.__suppressDeprecationWarning !== true) { + var componentName = getComponentNameFromType(type) || 'Unknown'; - pushNode(next); -} + if (!didWarnAboutDeprecatedWillMount[componentName]) { + warn( // keep this warning in sync with ReactStrictModeWarning.js + 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code from componentWillMount to componentDidMount (preferred in most cases) ' + 'or the constructor.\n' + '\nPlease update the following components: %s', componentName); -function popPreviousToCommonLevel(prev, next) { - popNode(prev); - var parentPrev = prev.parent; + didWarnAboutDeprecatedWillMount[componentName] = true; + } + } + } - if (parentPrev === null) { - throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.'); + instance.componentWillMount(); } - if (parentPrev.depth === next.depth) { - // We found the same level. Now we just need to find a shared ancestor. - popToNearestCommonAncestor(parentPrev, next); - } else { - // We must still be deeper. - popPreviousToCommonLevel(parentPrev, next); + if (typeof instance.UNSAFE_componentWillMount === 'function') { + instance.UNSAFE_componentWillMount(); } -} -function popNextToCommonLevel(prev, next) { - var parentNext = next.parent; + if (oldState !== instance.state) { + { + error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentNameFromType(type) || 'Component'); + } - if (parentNext === null) { - throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.'); + classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } +} - if (prev.depth === parentNext.depth) { - // We found the same level. Now we just need to find a shared ancestor. - popToNearestCommonAncestor(prev, parentNext); - } else { - // We must still be deeper. - popNextToCommonLevel(prev, parentNext); - } +function processUpdateQueue(internalInstance, inst, props, maskedLegacyContext) { + if (internalInstance.queue !== null && internalInstance.queue.length > 0) { + var oldQueue = internalInstance.queue; + var oldReplace = internalInstance.replace; + internalInstance.queue = null; + internalInstance.replace = false; - pushNode(next); -} // Perform context switching to the new snapshot. -// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by -// updating all the context's current values. That way reads, always just read the current value. -// At the cost of updating contexts even if they're never read by this subtree. + if (oldReplace && oldQueue.length === 1) { + inst.state = oldQueue[0]; + } else { + var nextState = oldReplace ? oldQueue[0] : inst.state; + var dontMutate = true; + for (var i = oldReplace ? 1 : 0; i < oldQueue.length; i++) { + var partial = oldQueue[i]; + var partialState = typeof partial === 'function' ? partial.call(inst, nextState, props, maskedLegacyContext) : partial; -function switchContext(newSnapshot) { - // The basic algorithm we need to do is to pop back any contexts that are no longer on the stack. - // We also need to update any new contexts that are now on the stack with the deepest value. - // The easiest way to update new contexts is to just reapply them in reverse order from the - // perspective of the backpointers. To avoid allocating a lot when switching, we use the stack - // for that. Therefore this algorithm is recursive. - // 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go. - // 2) Then we find the nearest common ancestor from there. Popping old contexts as we go. - // 3) Then we reapply new contexts on the way back up the stack. - var prev = currentActiveSnapshot; - var next = newSnapshot; + if (partialState != null) { + if (dontMutate) { + dontMutate = false; + nextState = assign({}, nextState, partialState); + } else { + assign(nextState, partialState); + } + } + } - if (prev !== next) { - if (prev === null) { - // $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev. - pushAllNext(next); - } else if (next === null) { - popAllPrevious(prev); - } else if (prev.depth === next.depth) { - popToNearestCommonAncestor(prev, next); - } else if (prev.depth > next.depth) { - popPreviousToCommonLevel(prev, next); - } else { - popNextToCommonLevel(prev, next); + inst.state = nextState; } - - currentActiveSnapshot = next; + } else { + internalInstance.queue = null; } -} -function pushProvider(context, nextValue) { - var prevValue; - - { - prevValue = context._currentValue2; - context._currentValue2 = nextValue; +} // Invokes the mount life-cycles on a previously never rendered instance. - { - if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) { - error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); - } - context._currentRenderer2 = rendererSigil; - } +function mountClassInstance(instance, ctor, newProps, maskedLegacyContext) { + { + checkClassInstance(instance, ctor, newProps); } - var prevNode = currentActiveSnapshot; - var newNode = { - parent: prevNode, - depth: prevNode === null ? 0 : prevNode.depth + 1, - context: context, - parentValue: prevValue, - value: nextValue + var initialState = instance.state !== undefined ? instance.state : null; + instance.updater = classComponentUpdater; + instance.props = newProps; + instance.state = initialState; // We don't bother initializing the refs object on the server, since we're not going to resolve them anyway. + // The internal instance will be used to manage updates that happen during this mount. + + var internalInstance = { + queue: [], + replace: false }; - currentActiveSnapshot = newNode; - return newNode; -} -function popProvider(context) { - var prevSnapshot = currentActiveSnapshot; + set(instance, internalInstance); + var contextType = ctor.contextType; - if (prevSnapshot === null) { - throw new Error('Tried to pop a Context at the root of the app. This is a bug in React.'); + if (typeof contextType === 'object' && contextType !== null) { + instance.context = readContext$1(contextType); + } else { + instance.context = maskedLegacyContext; } { - if (prevSnapshot.context !== context) { - error('The parent context is not the expected context. This is probably a bug in React.'); - } - } + if (instance.state === newProps) { + var componentName = getComponentNameFromType(ctor) || 'Component'; - { - var _value = prevSnapshot.parentValue; - prevSnapshot.context._currentValue2 = _value; + if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { + didWarnAboutDirectlyAssigningPropsToState.add(componentName); - { - if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) { - error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); - } - - context._currentRenderer2 = rendererSigil; - } - } - - return currentActiveSnapshot = prevSnapshot.parent; -} -function getActiveContext() { - return currentActiveSnapshot; -} -function readContext$1(context) { - var value = context._currentValue2; - return value; -} - -/** - * `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 didWarnAboutNoopUpdateForComponent = {}; -var didWarnAboutDeprecatedWillMount = {}; -var didWarnAboutUninitializedState; -var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; -var didWarnAboutLegacyLifecyclesAndDerivedState; -var didWarnAboutUndefinedDerivedState; -var didWarnAboutDirectlyAssigningPropsToState; -var didWarnAboutContextTypeAndContextTypes; -var didWarnAboutInvalidateContextType; -var didWarnOnInvalidCallback; - -{ - didWarnAboutUninitializedState = new Set(); - didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); - didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); - didWarnAboutDirectlyAssigningPropsToState = new Set(); - didWarnAboutUndefinedDerivedState = new Set(); - didWarnAboutContextTypeAndContextTypes = new Set(); - didWarnAboutInvalidateContextType = new Set(); - didWarnOnInvalidCallback = new Set(); -} - -function warnOnInvalidCallback(callback, callerName) { - { - if (callback === null || typeof callback === 'function') { - return; - } - - var key = callerName + '_' + callback; - - if (!didWarnOnInvalidCallback.has(key)) { - didWarnOnInvalidCallback.add(key); - - error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); - } - } -} - -function warnOnUndefinedDerivedState(type, partialState) { - { - if (partialState === undefined) { - var componentName = getComponentNameFromType(type) || 'Component'; - - if (!didWarnAboutUndefinedDerivedState.has(componentName)) { - didWarnAboutUndefinedDerivedState.add(componentName); - - error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName); - } - } - } -} - -function warnNoop(publicInstance, callerName) { - { - var _constructor = publicInstance.constructor; - var componentName = _constructor && getComponentNameFromType(_constructor) || 'ReactClass'; - var warningKey = componentName + '.' + callerName; - - if (didWarnAboutNoopUpdateForComponent[warningKey]) { - return; - } - - error('%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName); - - didWarnAboutNoopUpdateForComponent[warningKey] = true; - } -} - -var classComponentUpdater = { - isMounted: function (inst) { - return false; - }, - // $FlowFixMe[missing-local-annot] - enqueueSetState: function (inst, payload, callback) { - var internals = get(inst); - - if (internals.queue === null) { - warnNoop(inst, 'setState'); - } else { - internals.queue.push(payload); - - { - if (callback !== undefined && callback !== null) { - warnOnInvalidCallback(callback, 'setState'); - } - } - } - }, - enqueueReplaceState: function (inst, payload, callback) { - var internals = get(inst); - internals.replace = true; - internals.queue = [payload]; - - { - if (callback !== undefined && callback !== null) { - warnOnInvalidCallback(callback, 'setState'); - } - } - }, - // $FlowFixMe[missing-local-annot] - enqueueForceUpdate: function (inst, callback) { - var internals = get(inst); - - if (internals.queue === null) { - warnNoop(inst, 'forceUpdate'); - } else { - { - if (callback !== undefined && callback !== null) { - warnOnInvalidCallback(callback, 'setState'); - } - } - } - } -}; - -function applyDerivedStateFromProps(instance, ctor, getDerivedStateFromProps, prevState, nextProps) { - var partialState = getDerivedStateFromProps(nextProps, prevState); - - { - warnOnUndefinedDerivedState(ctor, partialState); - } // Merge the partial state and the previous state. - - - var newState = partialState === null || partialState === undefined ? prevState : assign({}, prevState, partialState); - return newState; -} - -function constructClassInstance(ctor, props, maskedLegacyContext) { - var context = emptyContextObject; - var contextType = ctor.contextType; - - { - if ('contextType' in ctor) { - var isValid = // Allow null for conditional declaration - contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a - - if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { - didWarnAboutInvalidateContextType.add(ctor); - var addendum = ''; - - if (contextType === undefined) { - addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.'; - } else if (typeof contextType !== 'object') { - addendum = ' However, it is set to a ' + typeof contextType + '.'; - } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { - addendum = ' Did you accidentally pass the Context.Provider instead?'; - } else if (contextType._context !== undefined) { - // - addendum = ' Did you accidentally pass the Context.Consumer instead?'; - } else { - addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; - } - - error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentNameFromType(ctor) || 'Component', addendum); - } - } - } - - if (typeof contextType === 'object' && contextType !== null) { - context = readContext$1(contextType); - } else { - context = maskedLegacyContext; - } - - var instance = new ctor(props, context); - - { - if (typeof ctor.getDerivedStateFromProps === 'function' && (instance.state === null || instance.state === undefined)) { - var componentName = getComponentNameFromType(ctor) || 'Component'; - - if (!didWarnAboutUninitializedState.has(componentName)) { - didWarnAboutUninitializedState.add(componentName); - - error('`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName); - } - } // If new component APIs are defined, "unsafe" lifecycles won't be called. - // Warn about these lifecycles if they are present. - // Don't warn about react-lifecycles-compat polyfilled methods though. - - - if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') { - var foundWillMountName = null; - var foundWillReceivePropsName = null; - var foundWillUpdateName = null; - - if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { - foundWillMountName = 'componentWillMount'; - } else if (typeof instance.UNSAFE_componentWillMount === 'function') { - foundWillMountName = 'UNSAFE_componentWillMount'; - } - - if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { - foundWillReceivePropsName = 'componentWillReceiveProps'; - } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { - foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; - } - - if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { - foundWillUpdateName = 'componentWillUpdate'; - } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { - foundWillUpdateName = 'UNSAFE_componentWillUpdate'; - } - - if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { - var _componentName = getComponentNameFromType(ctor) || 'Component'; - - var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; - - if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { - didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); - - error('Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://reactjs.org/link/unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : ''); - } - } - } - } - - return instance; -} - -function checkClassInstance(instance, ctor, newProps) { - { - var name = getComponentNameFromType(ctor) || 'Component'; - var renderPresent = instance.render; - - if (!renderPresent) { - if (ctor.prototype && typeof ctor.prototype.render === 'function') { - error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); - } else { - error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); - } - } - - if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) { - error('getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name); - } - - if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) { - error('getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name); - } - - if (instance.propTypes) { - error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name); - } - - if (instance.contextType) { - error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name); - } - - { - if (instance.contextTypes) { - error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name); - } - - if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) { - didWarnAboutContextTypeAndContextTypes.add(ctor); - - error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name); - } - } - - if (typeof instance.componentShouldUpdate === 'function') { - error('%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name); - } - - if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { - error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentNameFromType(ctor) || 'A pure component'); - } - - if (typeof instance.componentDidUnmount === 'function') { - error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name); - } - - if (typeof instance.componentDidReceiveProps === 'function') { - error('%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name); - } - - if (typeof instance.componentWillRecieveProps === 'function') { - error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name); - } - - if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') { - error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name); - } - - var hasMutatedProps = instance.props !== newProps; - - if (instance.props !== undefined && hasMutatedProps) { - error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name); - } - - if (instance.defaultProps) { - error('Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name); - } - - if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) { - didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); - - error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentNameFromType(ctor)); - } - - if (typeof instance.getDerivedStateFromProps === 'function') { - error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); - } - - if (typeof instance.getDerivedStateFromError === 'function') { - error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); - } - - if (typeof ctor.getSnapshotBeforeUpdate === 'function') { - error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name); - } - - var state = instance.state; - - if (state && (typeof state !== 'object' || isArray(state))) { - error('%s.state: must be set to an object or null', name); - } - - if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') { - error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name); - } - } -} - -function callComponentWillMount(type, instance) { - var oldState = instance.state; - - if (typeof instance.componentWillMount === 'function') { - { - if (instance.componentWillMount.__suppressDeprecationWarning !== true) { - var componentName = getComponentNameFromType(type) || 'Unknown'; - - if (!didWarnAboutDeprecatedWillMount[componentName]) { - warn( // keep this warning in sync with ReactStrictModeWarning.js - 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code from componentWillMount to componentDidMount (preferred in most cases) ' + 'or the constructor.\n' + '\nPlease update the following components: %s', componentName); - - didWarnAboutDeprecatedWillMount[componentName] = true; - } - } - } - - instance.componentWillMount(); - } - - if (typeof instance.UNSAFE_componentWillMount === 'function') { - instance.UNSAFE_componentWillMount(); - } - - if (oldState !== instance.state) { - { - error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentNameFromType(type) || 'Component'); - } - - classComponentUpdater.enqueueReplaceState(instance, instance.state, null); - } -} - -function processUpdateQueue(internalInstance, inst, props, maskedLegacyContext) { - if (internalInstance.queue !== null && internalInstance.queue.length > 0) { - var oldQueue = internalInstance.queue; - var oldReplace = internalInstance.replace; - internalInstance.queue = null; - internalInstance.replace = false; - - if (oldReplace && oldQueue.length === 1) { - inst.state = oldQueue[0]; - } else { - var nextState = oldReplace ? oldQueue[0] : inst.state; - var dontMutate = true; - - for (var i = oldReplace ? 1 : 0; i < oldQueue.length; i++) { - var partial = oldQueue[i]; - var partialState = typeof partial === 'function' ? partial.call(inst, nextState, props, maskedLegacyContext) : partial; - - if (partialState != null) { - if (dontMutate) { - dontMutate = false; - nextState = assign({}, nextState, partialState); - } else { - assign(nextState, partialState); - } - } - } - - inst.state = nextState; - } - } else { - internalInstance.queue = null; - } -} // Invokes the mount life-cycles on a previously never rendered instance. - - -function mountClassInstance(instance, ctor, newProps, maskedLegacyContext) { - { - checkClassInstance(instance, ctor, newProps); - } - - var initialState = instance.state !== undefined ? instance.state : null; - instance.updater = classComponentUpdater; - instance.props = newProps; - instance.state = initialState; // We don't bother initializing the refs object on the server, since we're not going to resolve them anyway. - // The internal instance will be used to manage updates that happen during this mount. - - var internalInstance = { - queue: [], - replace: false - }; - set(instance, internalInstance); - var contextType = ctor.contextType; - - if (typeof contextType === 'object' && contextType !== null) { - instance.context = readContext$1(contextType); - } else { - instance.context = maskedLegacyContext; - } - - { - if (instance.state === newProps) { - var componentName = getComponentNameFromType(ctor) || 'Component'; - - if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { - didWarnAboutDirectlyAssigningPropsToState.add(componentName); - - error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName); + error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName); } } } @@ -8102,917 +7883,1289 @@ function getTreeId(context) { var id = idWithLeadingBit & ~getLeadingBit(idWithLeadingBit); return id.toString(32) + overflow; } -function pushTreeContext(baseContext, totalChildren, index) { - var baseIdWithLeadingBit = baseContext.id; - var baseOverflow = baseContext.overflow; // The leftmost 1 marks the end of the sequence, non-inclusive. It's not part - // of the id; we use it to account for leading 0s. +function pushTreeContext(baseContext, totalChildren, index) { + var baseIdWithLeadingBit = baseContext.id; + var baseOverflow = baseContext.overflow; // The leftmost 1 marks the end of the sequence, non-inclusive. It's not part + // of the id; we use it to account for leading 0s. + + var baseLength = getBitLength(baseIdWithLeadingBit) - 1; + var baseId = baseIdWithLeadingBit & ~(1 << baseLength); + var slot = index + 1; + var length = getBitLength(totalChildren) + baseLength; // 30 is the max length we can store without overflowing, taking into + // consideration the leading 1 we use to mark the end of the sequence. + + if (length > 30) { + // We overflowed the bitwise-safe range. Fall back to slower algorithm. + // This branch assumes the length of the base id is greater than 5; it won't + // work for smaller ids, because you need 5 bits per character. + // + // We encode the id in multiple steps: first the base id, then the + // remaining digits. + // + // Each 5 bit sequence corresponds to a single base 32 character. So for + // example, if the current id is 23 bits long, we can convert 20 of those + // bits into a string of 4 characters, with 3 bits left over. + // + // First calculate how many bits in the base id represent a complete + // sequence of characters. + var numberOfOverflowBits = baseLength - baseLength % 5; // Then create a bitmask that selects only those bits. + + var newOverflowBits = (1 << numberOfOverflowBits) - 1; // Select the bits, and convert them to a base 32 string. + + var newOverflow = (baseId & newOverflowBits).toString(32); // Now we can remove those bits from the base id. + + var restOfBaseId = baseId >> numberOfOverflowBits; + var restOfBaseLength = baseLength - numberOfOverflowBits; // Finally, encode the rest of the bits using the normal algorithm. Because + // we made more room, this time it won't overflow. + + var restOfLength = getBitLength(totalChildren) + restOfBaseLength; + var restOfNewBits = slot << restOfBaseLength; + var id = restOfNewBits | restOfBaseId; + var overflow = newOverflow + baseOverflow; + return { + id: 1 << restOfLength | id, + overflow: overflow + }; + } else { + // Normal path + var newBits = slot << baseLength; + + var _id = newBits | baseId; + + var _overflow = baseOverflow; + return { + id: 1 << length | _id, + overflow: _overflow + }; + } +} + +function getBitLength(number) { + return 32 - clz32(number); +} + +function getLeadingBit(id) { + return 1 << getBitLength(id) - 1; +} // TODO: Math.clz32 is supported in Node 12+. Maybe we can drop the fallback. + + +var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. +// Based on: +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 + +var log = Math.log; +var LN2 = Math.LN2; + +function clz32Fallback(x) { + var asUint = x >>> 0; + + if (asUint === 0) { + return 32; + } + + return 31 - (log(asUint) / LN2 | 0) | 0; +} + +// Corresponds to ReactFiberWakeable and ReactFlightWakeable modules. Generally, +// changes to one module should be reflected in the others. +// TODO: Rename this module and the corresponding Fiber one to "Thenable" +// instead of "Wakeable". Or some other more appropriate name. +// An error that is thrown (e.g. by `use`) to trigger Suspense. If we +// detect this is caught by userspace, we'll log a warning in development. +var SuspenseException = new Error("Suspense Exception: This is not a real error! It's an implementation " + 'detail of `use` to interrupt the current render. You must either ' + 'rethrow it immediately, or move the `use` call outside of the ' + '`try/catch` block. Capturing without rethrowing will lead to ' + 'unexpected behavior.\n\n' + 'To handle async errors, wrap your component in an error boundary, or ' + "call the promise's `.catch` method and pass the result to `use`"); +function createThenableState() { + // The ThenableState is created the first time a component suspends. If it + // suspends again, we'll reuse the same state. + return []; +} + +function noop$2() {} + +function trackUsedThenable(thenableState, thenable, index) { + var previous = thenableState[index]; + + if (previous === undefined) { + thenableState.push(thenable); + } else { + if (previous !== thenable) { + // Reuse the previous thenable, and drop the new one. We can assume + // they represent the same value, because components are idempotent. + // Avoid an unhandled rejection errors for the Promises that we'll + // intentionally ignore. + thenable.then(noop$2, noop$2); + thenable = previous; + } + } // We use an expando to track the status and result of a thenable so that we + // can synchronously unwrap the value. Think of this as an extension of the + // Promise API, or a custom interface that is a superset of Thenable. + // + // If the thenable doesn't have a status, set it to "pending" and attach + // a listener that will update its status and result when it resolves. + + + switch (thenable.status) { + case 'fulfilled': + { + var fulfilledValue = thenable.value; + return fulfilledValue; + } + + case 'rejected': + { + var rejectedError = thenable.reason; + throw rejectedError; + } + + default: + { + if (typeof thenable.status === 'string') ; else { + var pendingThenable = thenable; + pendingThenable.status = 'pending'; + pendingThenable.then(function (fulfilledValue) { + if (thenable.status === 'pending') { + var fulfilledThenable = thenable; + fulfilledThenable.status = 'fulfilled'; + fulfilledThenable.value = fulfilledValue; + } + }, function (error) { + if (thenable.status === 'pending') { + var rejectedThenable = thenable; + rejectedThenable.status = 'rejected'; + rejectedThenable.reason = error; + } + }); // Check one more time in case the thenable resolved synchronously + + switch (thenable.status) { + case 'fulfilled': + { + var fulfilledThenable = thenable; + return fulfilledThenable.value; + } + + case 'rejected': + { + var rejectedThenable = thenable; + throw rejectedThenable.reason; + } + } + } // Suspend. + // + // Throwing here is an implementation detail that allows us to unwind the + // call stack. But we shouldn't allow it to leak into userspace. Throw an + // opaque placeholder value instead of the actual thenable. If it doesn't + // get captured by the work loop, log a warning, because that means + // something in userspace must have caught it. + + + suspendedThenable = thenable; + throw SuspenseException; + } + } +} // This is used to track the actual thenable that suspended so it can be +// passed to the rest of the Suspense implementation — which, for historical +// reasons, expects to receive a thenable. + +var suspendedThenable = null; +function getSuspendedThenable() { + // This is called right after `use` suspends by throwing an exception. `use` + // throws an opaque value instead of the thenable itself so that it can't be + // caught in userspace. Then the work loop accesses the actual thenable using + // this function. + if (suspendedThenable === null) { + throw new Error('Expected a suspended thenable. This is a bug in React. Please file ' + 'an issue.'); + } + + var thenable = suspendedThenable; + suspendedThenable = null; + return thenable; +} + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare + ; +} + +var objectIs = // $FlowFixMe[method-unbinding] +typeof Object.is === 'function' ? Object.is : is; + +var currentlyRenderingComponent = null; +var currentlyRenderingTask = null; +var currentlyRenderingRequest = null; +var currentlyRenderingKeyPath = null; +var firstWorkInProgressHook = null; +var workInProgressHook = null; // Whether the work-in-progress hook is a re-rendered hook + +var isReRender = false; // Whether an update was scheduled during the currently executing render pass. + +var didScheduleRenderPhaseUpdate = false; // Counts the number of useId hooks in this component + +var localIdCounter = 0; // Chunks that should be pushed to the stream once the component +// finishes rendering. +// Counts the number of useFormState calls in this component + +var formStateCounter = 0; // The index of the useFormState hook that matches the one passed in at the +// root during an MPA navigation, if any. + +var formStateMatchingIndex = -1; // Counts the number of use(thenable) calls in this component + +var thenableIndexCounter = 0; +var thenableState = null; // Lazily created map of render-phase updates + +var renderPhaseUpdates = null; // Counter to prevent infinite loops. + +var numberOfReRenders = 0; +var RE_RENDER_LIMIT = 25; +var isInHookUserCodeInDev = false; // In DEV, this is the name of the currently executing primitive hook + +var currentHookNameInDev; + +function resolveCurrentlyRenderingComponent() { + if (currentlyRenderingComponent === null) { + throw new Error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.'); + } + + { + if (isInHookUserCodeInDev) { + 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://reactjs.org/link/rules-of-hooks'); + } + } + + return currentlyRenderingComponent; +} - var baseLength = getBitLength(baseIdWithLeadingBit) - 1; - var baseId = baseIdWithLeadingBit & ~(1 << baseLength); - var slot = index + 1; - var length = getBitLength(totalChildren) + baseLength; // 30 is the max length we can store without overflowing, taking into - // consideration the leading 1 we use to mark the end of the sequence. +function areHookInputsEqual(nextDeps, prevDeps) { + if (prevDeps === null) { + { + error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev); + } - if (length > 30) { - // We overflowed the bitwise-safe range. Fall back to slower algorithm. - // This branch assumes the length of the base id is greater than 5; it won't - // work for smaller ids, because you need 5 bits per character. - // - // We encode the id in multiple steps: first the base id, then the - // remaining digits. - // - // Each 5 bit sequence corresponds to a single base 32 character. So for - // example, if the current id is 23 bits long, we can convert 20 of those - // bits into a string of 4 characters, with 3 bits left over. - // - // First calculate how many bits in the base id represent a complete - // sequence of characters. - var numberOfOverflowBits = baseLength - baseLength % 5; // Then create a bitmask that selects only those bits. + return false; + } - var newOverflowBits = (1 << numberOfOverflowBits) - 1; // Select the bits, and convert them to a base 32 string. + { + // Don't bother comparing lengths in prod because these arrays should be + // passed inline. + if (nextDeps.length !== prevDeps.length) { + error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + nextDeps.join(', ') + "]", "[" + prevDeps.join(', ') + "]"); + } + } // $FlowFixMe[incompatible-use] found when upgrading Flow - var newOverflow = (baseId & newOverflowBits).toString(32); // Now we can remove those bits from the base id. - var restOfBaseId = baseId >> numberOfOverflowBits; - var restOfBaseLength = baseLength - numberOfOverflowBits; // Finally, encode the rest of the bits using the normal algorithm. Because - // we made more room, this time it won't overflow. + for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) { + // $FlowFixMe[incompatible-use] found when upgrading Flow + if (objectIs(nextDeps[i], prevDeps[i])) { + continue; + } - var restOfLength = getBitLength(totalChildren) + restOfBaseLength; - var restOfNewBits = slot << restOfBaseLength; - var id = restOfNewBits | restOfBaseId; - var overflow = newOverflow + baseOverflow; - return { - id: 1 << restOfLength | id, - overflow: overflow - }; - } else { - // Normal path - var newBits = slot << baseLength; + return false; + } - var _id = newBits | baseId; + return true; +} - var _overflow = baseOverflow; - return { - id: 1 << length | _id, - overflow: _overflow - }; +function createHook() { + if (numberOfReRenders > 0) { + throw new Error('Rendered more hooks than during the previous render'); } + + return { + memoizedState: null, + queue: null, + next: null + }; } -function getBitLength(number) { - return 32 - clz32(number); +function createWorkInProgressHook() { + if (workInProgressHook === null) { + // This is the first hook in the list + if (firstWorkInProgressHook === null) { + isReRender = false; + firstWorkInProgressHook = workInProgressHook = createHook(); + } else { + // There's already a work-in-progress. Reuse it. + isReRender = true; + workInProgressHook = firstWorkInProgressHook; + } + } else { + if (workInProgressHook.next === null) { + isReRender = false; // Append to the end of the list + + workInProgressHook = workInProgressHook.next = createHook(); + } else { + // There's already a work-in-progress. Reuse it. + isReRender = true; + workInProgressHook = workInProgressHook.next; + } + } + + return workInProgressHook; } -function getLeadingBit(id) { - return 1 << getBitLength(id) - 1; -} // TODO: Math.clz32 is supported in Node 12+. Maybe we can drop the fallback. +function prepareToUseHooks(request, task, keyPath, componentIdentity, prevThenableState) { + currentlyRenderingComponent = componentIdentity; + currentlyRenderingTask = task; + currentlyRenderingRequest = request; + currentlyRenderingKeyPath = keyPath; + { + isInHookUserCodeInDev = false; + } // The following should have already been reset + // didScheduleRenderPhaseUpdate = false; + // firstWorkInProgressHook = null; + // numberOfReRenders = 0; + // renderPhaseUpdates = null; + // workInProgressHook = null; -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. -// Based on: -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 -var log = Math.log; -var LN2 = Math.LN2; + localIdCounter = 0; + formStateCounter = 0; + formStateMatchingIndex = -1; + thenableIndexCounter = 0; + thenableState = prevThenableState; +} +function finishHooks(Component, props, children, refOrContext) { + // This must be called after every function component to prevent hooks from + // being used in classes. + while (didScheduleRenderPhaseUpdate) { + // Updates were scheduled during the render phase. They are stored in + // the `renderPhaseUpdates` map. Call the component again, reusing the + // work-in-progress hooks and applying the additional updates on top. Keep + // restarting until no more updates are scheduled. + didScheduleRenderPhaseUpdate = false; + localIdCounter = 0; + formStateCounter = 0; + formStateMatchingIndex = -1; + thenableIndexCounter = 0; + numberOfReRenders += 1; // Start over from the beginning of the list -function clz32Fallback(x) { - var asUint = x >>> 0; + workInProgressHook = null; + children = Component(props, refOrContext); + } - if (asUint === 0) { - return 32; + resetHooksState(); + return children; +} +function getThenableStateAfterSuspending() { + var state = thenableState; + thenableState = null; + return state; +} +function checkDidRenderIdHook() { + // This should be called immediately after every finishHooks call. + // Conceptually, it's part of the return value of finishHooks; it's only a + // separate function to avoid using an array tuple. + var didRenderIdHook = localIdCounter !== 0; + return didRenderIdHook; +} +function getFormStateCount() { + // This should be called immediately after every finishHooks call. + // Conceptually, it's part of the return value of finishHooks; it's only a + // separate function to avoid using an array tuple. + return formStateCounter; +} +function getFormStateMatchingIndex() { + // This should be called immediately after every finishHooks call. + // Conceptually, it's part of the return value of finishHooks; it's only a + // separate function to avoid using an array tuple. + return formStateMatchingIndex; +} // Reset the internal hooks state if an error occurs while rendering a component + +function resetHooksState() { + { + isInHookUserCodeInDev = false; } - return 31 - (log(asUint) / LN2 | 0) | 0; + currentlyRenderingComponent = null; + currentlyRenderingTask = null; + currentlyRenderingRequest = null; + currentlyRenderingKeyPath = null; + didScheduleRenderPhaseUpdate = false; + firstWorkInProgressHook = null; + numberOfReRenders = 0; + renderPhaseUpdates = null; + workInProgressHook = null; } -// Corresponds to ReactFiberWakeable and ReactFlightWakeable modules. Generally, -// changes to one module should be reflected in the others. -// TODO: Rename this module and the corresponding Fiber one to "Thenable" -// instead of "Wakeable". Or some other more appropriate name. -// An error that is thrown (e.g. by `use`) to trigger Suspense. If we -// detect this is caught by userspace, we'll log a warning in development. -var SuspenseException = new Error("Suspense Exception: This is not a real error! It's an implementation " + 'detail of `use` to interrupt the current render. You must either ' + 'rethrow it immediately, or move the `use` call outside of the ' + '`try/catch` block. Capturing without rethrowing will lead to ' + 'unexpected behavior.\n\n' + 'To handle async errors, wrap your component in an error boundary, or ' + "call the promise's `.catch` method and pass the result to `use`"); -function createThenableState() { - // The ThenableState is created the first time a component suspends. If it - // suspends again, we'll reuse the same state. - return []; +function readContext(context) { + { + if (isInHookUserCodeInDev) { + 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().'); + } + } + + return readContext$1(context); } -function noop$2() {} +function useContext(context) { + { + currentHookNameInDev = 'useContext'; + } -function trackUsedThenable(thenableState, thenable, index) { - var previous = thenableState[index]; + resolveCurrentlyRenderingComponent(); + return readContext$1(context); +} - if (previous === undefined) { - thenableState.push(thenable); - } else { - if (previous !== thenable) { - // Reuse the previous thenable, and drop the new one. We can assume - // they represent the same value, because components are idempotent. - // Avoid an unhandled rejection errors for the Promises that we'll - // intentionally ignore. - thenable.then(noop$2, noop$2); - thenable = previous; - } - } // We use an expando to track the status and result of a thenable so that we - // can synchronously unwrap the value. Think of this as an extension of the - // Promise API, or a custom interface that is a superset of Thenable. - // - // If the thenable doesn't have a status, set it to "pending" and attach - // a listener that will update its status and result when it resolves. +function basicStateReducer(state, action) { + // $FlowFixMe[incompatible-use]: Flow doesn't like mixed types + return typeof action === 'function' ? action(state) : action; +} + +function useState(initialState) { + { + currentHookNameInDev = 'useState'; + } + + return useReducer(basicStateReducer, // useReducer has a special case to support lazy useState initializers + initialState); +} +function useReducer(reducer, initialArg, init) { + { + if (reducer !== basicStateReducer) { + currentHookNameInDev = 'useReducer'; + } + } + currentlyRenderingComponent = resolveCurrentlyRenderingComponent(); + workInProgressHook = createWorkInProgressHook(); - switch (thenable.status) { - case 'fulfilled': - { - var fulfilledValue = thenable.value; - return fulfilledValue; - } + if (isReRender) { + // This is a re-render. Apply the new render phase updates to the previous + // current hook. + var queue = workInProgressHook.queue; + var dispatch = queue.dispatch; - case 'rejected': - { - var rejectedError = thenable.reason; - throw rejectedError; - } + if (renderPhaseUpdates !== null) { + // Render phase updates are stored in a map of queue -> linked list + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); - default: - { - if (typeof thenable.status === 'string') ; else { - var pendingThenable = thenable; - pendingThenable.status = 'pending'; - pendingThenable.then(function (fulfilledValue) { - if (thenable.status === 'pending') { - var fulfilledThenable = thenable; - fulfilledThenable.status = 'fulfilled'; - fulfilledThenable.value = fulfilledValue; - } - }, function (error) { - if (thenable.status === 'pending') { - var rejectedThenable = thenable; - rejectedThenable.status = 'rejected'; - rejectedThenable.reason = error; - } - }); // Check one more time in case the thenable resolved synchronously + if (firstRenderPhaseUpdate !== undefined) { + // $FlowFixMe[incompatible-use] found when upgrading Flow + renderPhaseUpdates.delete(queue); // $FlowFixMe[incompatible-use] found when upgrading Flow - switch (thenable.status) { - case 'fulfilled': - { - var fulfilledThenable = thenable; - return fulfilledThenable.value; - } + var newState = workInProgressHook.memoizedState; + var update = firstRenderPhaseUpdate; - case 'rejected': - { - var rejectedThenable = thenable; - throw rejectedThenable.reason; - } + do { + // Process this render phase update. We don't have to check the + // priority because it will always be the same as the current + // render's. + var action = update.action; + + { + isInHookUserCodeInDev = true; } - } // Suspend. - // - // Throwing here is an implementation detail that allows us to unwind the - // call stack. But we shouldn't allow it to leak into userspace. Throw an - // opaque placeholder value instead of the actual thenable. If it doesn't - // get captured by the work loop, log a warning, because that means - // something in userspace must have caught it. + newState = reducer(newState, action); - suspendedThenable = thenable; - throw SuspenseException; - } - } -} // This is used to track the actual thenable that suspended so it can be -// passed to the rest of the Suspense implementation — which, for historical -// reasons, expects to receive a thenable. + { + isInHookUserCodeInDev = false; + } // $FlowFixMe[incompatible-type] we bail out when we get a null -var suspendedThenable = null; -function getSuspendedThenable() { - // This is called right after `use` suspends by throwing an exception. `use` - // throws an opaque value instead of the thenable itself so that it can't be - // caught in userspace. Then the work loop accesses the actual thenable using - // this function. - if (suspendedThenable === null) { - throw new Error('Expected a suspended thenable. This is a bug in React. Please file ' + 'an issue.'); - } - var thenable = suspendedThenable; - suspendedThenable = null; - return thenable; -} + update = update.next; + } while (update !== null); // $FlowFixMe[incompatible-use] found when upgrading Flow -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ -function is(x, y) { - return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare - ; -} -var objectIs = // $FlowFixMe[method-unbinding] -typeof Object.is === 'function' ? Object.is : is; + workInProgressHook.memoizedState = newState; + return [newState, dispatch]; + } + } // $FlowFixMe[incompatible-use] found when upgrading Flow -var currentlyRenderingComponent = null; -var currentlyRenderingTask = null; -var currentlyRenderingRequest = null; -var currentlyRenderingKeyPath = null; -var firstWorkInProgressHook = null; -var workInProgressHook = null; // Whether the work-in-progress hook is a re-rendered hook -var isReRender = false; // Whether an update was scheduled during the currently executing render pass. + return [workInProgressHook.memoizedState, dispatch]; + } else { + { + isInHookUserCodeInDev = true; + } -var didScheduleRenderPhaseUpdate = false; // Counts the number of useId hooks in this component + var initialState; -var localIdCounter = 0; // Chunks that should be pushed to the stream once the component -// finishes rendering. -// Counts the number of useFormState calls in this component + if (reducer === basicStateReducer) { + // Special case for `useState`. + initialState = typeof initialArg === 'function' ? initialArg() : initialArg; + } else { + initialState = init !== undefined ? init(initialArg) : initialArg; + } -var formStateCounter = 0; // The index of the useFormState hook that matches the one passed in at the -// root during an MPA navigation, if any. + { + isInHookUserCodeInDev = false; + } // $FlowFixMe[incompatible-use] found when upgrading Flow -var formStateMatchingIndex = -1; // Counts the number of use(thenable) calls in this component -var thenableIndexCounter = 0; -var thenableState = null; // Lazily created map of render-phase updates + workInProgressHook.memoizedState = initialState; // $FlowFixMe[incompatible-use] found when upgrading Flow -var renderPhaseUpdates = null; // Counter to prevent infinite loops. + var _queue = workInProgressHook.queue = { + last: null, + dispatch: null + }; -var numberOfReRenders = 0; -var RE_RENDER_LIMIT = 25; -var isInHookUserCodeInDev = false; // In DEV, this is the name of the currently executing primitive hook + var _dispatch = _queue.dispatch = dispatchAction.bind(null, currentlyRenderingComponent, _queue); // $FlowFixMe[incompatible-use] found when upgrading Flow -var currentHookNameInDev; -function resolveCurrentlyRenderingComponent() { - if (currentlyRenderingComponent === null) { - throw new Error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.'); + return [workInProgressHook.memoizedState, _dispatch]; } +} - { - if (isInHookUserCodeInDev) { - 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://reactjs.org/link/rules-of-hooks'); - } - } +function useMemo(nextCreate, deps) { + currentlyRenderingComponent = resolveCurrentlyRenderingComponent(); + workInProgressHook = createWorkInProgressHook(); + var nextDeps = deps === undefined ? null : deps; - return currentlyRenderingComponent; -} + if (workInProgressHook !== null) { + var prevState = workInProgressHook.memoizedState; -function areHookInputsEqual(nextDeps, prevDeps) { - if (prevDeps === null) { - { - error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev); + if (prevState !== null) { + if (nextDeps !== null) { + var prevDeps = prevState[1]; + + if (areHookInputsEqual(nextDeps, prevDeps)) { + return prevState[0]; + } + } } + } - return false; + { + isInHookUserCodeInDev = true; } + var nextValue = nextCreate(); + { - // Don't bother comparing lengths in prod because these arrays should be - // passed inline. - if (nextDeps.length !== prevDeps.length) { - error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + nextDeps.join(', ') + "]", "[" + prevDeps.join(', ') + "]"); - } + isInHookUserCodeInDev = false; } // $FlowFixMe[incompatible-use] found when upgrading Flow - for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - if (objectIs(nextDeps[i], prevDeps[i])) { - continue; - } + workInProgressHook.memoizedState = [nextValue, nextDeps]; + return nextValue; +} - return false; - } +function useRef(initialValue) { + currentlyRenderingComponent = resolveCurrentlyRenderingComponent(); + workInProgressHook = createWorkInProgressHook(); + var previousRef = workInProgressHook.memoizedState; - return true; -} + if (previousRef === null) { + var ref = { + current: initialValue + }; -function createHook() { - if (numberOfReRenders > 0) { - throw new Error('Rendered more hooks than during the previous render'); - } + { + Object.seal(ref); + } // $FlowFixMe[incompatible-use] found when upgrading Flow - return { - memoizedState: null, - queue: null, - next: null - }; -} -function createWorkInProgressHook() { - if (workInProgressHook === null) { - // This is the first hook in the list - if (firstWorkInProgressHook === null) { - isReRender = false; - firstWorkInProgressHook = workInProgressHook = createHook(); - } else { - // There's already a work-in-progress. Reuse it. - isReRender = true; - workInProgressHook = firstWorkInProgressHook; - } + workInProgressHook.memoizedState = ref; + return ref; } else { - if (workInProgressHook.next === null) { - isReRender = false; // Append to the end of the list - - workInProgressHook = workInProgressHook.next = createHook(); - } else { - // There's already a work-in-progress. Reuse it. - isReRender = true; - workInProgressHook = workInProgressHook.next; - } + return previousRef; } - - return workInProgressHook; } -function prepareToUseHooks(request, task, keyPath, componentIdentity, prevThenableState) { - currentlyRenderingComponent = componentIdentity; - currentlyRenderingTask = task; - currentlyRenderingRequest = request; - currentlyRenderingKeyPath = keyPath; +function dispatchAction(componentIdentity, queue, action) { + if (numberOfReRenders >= RE_RENDER_LIMIT) { + throw new Error('Too many re-renders. React limits the number of renders to prevent ' + 'an infinite loop.'); + } - { - isInHookUserCodeInDev = false; - } // The following should have already been reset - // didScheduleRenderPhaseUpdate = false; - // firstWorkInProgressHook = null; - // numberOfReRenders = 0; - // renderPhaseUpdates = null; - // workInProgressHook = null; + if (componentIdentity === currentlyRenderingComponent) { + // This is a render phase update. Stash it in a lazily-created map of + // queue -> linked list of updates. After this render pass, we'll restart + // and apply the stashed updates on top of the work-in-progress hook. + didScheduleRenderPhaseUpdate = true; + var update = { + action: action, + next: null + }; + if (renderPhaseUpdates === null) { + renderPhaseUpdates = new Map(); + } - localIdCounter = 0; - formStateCounter = 0; - formStateMatchingIndex = -1; - thenableIndexCounter = 0; - thenableState = prevThenableState; -} -function finishHooks(Component, props, children, refOrContext) { - // This must be called after every function component to prevent hooks from - // being used in classes. - while (didScheduleRenderPhaseUpdate) { - // Updates were scheduled during the render phase. They are stored in - // the `renderPhaseUpdates` map. Call the component again, reusing the - // work-in-progress hooks and applying the additional updates on top. Keep - // restarting until no more updates are scheduled. - didScheduleRenderPhaseUpdate = false; - localIdCounter = 0; - formStateCounter = 0; - formStateMatchingIndex = -1; - thenableIndexCounter = 0; - numberOfReRenders += 1; // Start over from the beginning of the list + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); - workInProgressHook = null; - children = Component(props, refOrContext); - } + if (firstRenderPhaseUpdate === undefined) { + // $FlowFixMe[incompatible-use] found when upgrading Flow + renderPhaseUpdates.set(queue, update); + } else { + // Append the update to the end of the list. + var lastRenderPhaseUpdate = firstRenderPhaseUpdate; - resetHooksState(); - return children; + while (lastRenderPhaseUpdate.next !== null) { + lastRenderPhaseUpdate = lastRenderPhaseUpdate.next; + } + + lastRenderPhaseUpdate.next = update; + } + } } -function getThenableStateAfterSuspending() { - var state = thenableState; - thenableState = null; - return state; + +function useCallback(callback, deps) { + return useMemo(function () { + return callback; + }, deps); } -function checkDidRenderIdHook() { - // This should be called immediately after every finishHooks call. - // Conceptually, it's part of the return value of finishHooks; it's only a - // separate function to avoid using an array tuple. - var didRenderIdHook = localIdCounter !== 0; - return didRenderIdHook; + +function throwOnUseEffectEventCall() { + throw new Error("A function wrapped in useEffectEvent can't be called during rendering."); } -function getFormStateCount() { - // This should be called immediately after every finishHooks call. - // Conceptually, it's part of the return value of finishHooks; it's only a - // separate function to avoid using an array tuple. - return formStateCounter; + +function useEffectEvent(callback) { + // $FlowIgnore[incompatible-return] + return throwOnUseEffectEventCall; } -function getFormStateMatchingIndex() { - // This should be called immediately after every finishHooks call. - // Conceptually, it's part of the return value of finishHooks; it's only a - // separate function to avoid using an array tuple. - return formStateMatchingIndex; -} // Reset the internal hooks state if an error occurs while rendering a component -function resetHooksState() { - { - isInHookUserCodeInDev = false; +function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { + if (getServerSnapshot === undefined) { + throw new Error('Missing getServerSnapshot, which is required for ' + 'server-rendered content. Will revert to client rendering.'); } - currentlyRenderingComponent = null; - currentlyRenderingTask = null; - currentlyRenderingRequest = null; - currentlyRenderingKeyPath = null; - didScheduleRenderPhaseUpdate = false; - firstWorkInProgressHook = null; - numberOfReRenders = 0; - renderPhaseUpdates = null; - workInProgressHook = null; + return getServerSnapshot(); } -function readContext(context) { +function useDeferredValue(value, initialValue) { + resolveCurrentlyRenderingComponent(); + { - if (isInHookUserCodeInDev) { - 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().'); - } + return initialValue !== undefined ? initialValue : value; } - - return readContext$1(context); } -function useContext(context) { - { - currentHookNameInDev = 'useContext'; - } +function unsupportedStartTransition() { + throw new Error('startTransition cannot be called during server rendering.'); +} +function useTransition() { resolveCurrentlyRenderingComponent(); - return readContext$1(context); + return [false, unsupportedStartTransition]; } -function basicStateReducer(state, action) { - // $FlowFixMe[incompatible-use]: Flow doesn't like mixed types - return typeof action === 'function' ? action(state) : action; +function useHostTransitionStatus() { + resolveCurrentlyRenderingComponent(); + return NotPendingTransition; } -function useState(initialState) { - { - currentHookNameInDev = 'useState'; - } +function unsupportedSetOptimisticState() { + throw new Error('Cannot update optimistic state while rendering.'); +} - return useReducer(basicStateReducer, // useReducer has a special case to support lazy useState initializers - initialState); +function useOptimistic(passthrough, reducer) { + resolveCurrentlyRenderingComponent(); + return [passthrough, unsupportedSetOptimisticState]; } -function useReducer(reducer, initialArg, init) { - { - if (reducer !== basicStateReducer) { - currentHookNameInDev = 'useReducer'; - } + +function createPostbackFormStateKey(permalink, componentKeyPath, hookIndex) { + if (permalink !== undefined) { + // Don't bother to hash a permalink-based key since it's already short. + return 'p' + permalink; + } else { + // Append a node to the key path that represents the form state hook. + var keyPath = [componentKeyPath, null, hookIndex]; // Key paths are hashed to reduce the size. It does not need to be secure, + // and it's more important that it's fast than that it's completely + // collision-free. + + var keyPathHash = createFastHashJS(JSON.stringify(keyPath)); + return 'k' + keyPathHash; } +} - currentlyRenderingComponent = resolveCurrentlyRenderingComponent(); - workInProgressHook = createWorkInProgressHook(); +function useFormState(action, initialState, permalink) { + resolveCurrentlyRenderingComponent(); // Count the number of useFormState hooks per component. We also use this to + // track the position of this useFormState hook relative to the other ones in + // this component, so we can generate a unique key for each one. - if (isReRender) { - // This is a re-render. Apply the new render phase updates to the previous - // current hook. - var queue = workInProgressHook.queue; - var dispatch = queue.dispatch; + var formStateHookIndex = formStateCounter++; + var request = currentlyRenderingRequest; // $FlowIgnore[prop-missing] - if (renderPhaseUpdates !== null) { - // Render phase updates are stored in a map of queue -> linked list - var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); + var formAction = action.$$FORM_ACTION; - if (firstRenderPhaseUpdate !== undefined) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - renderPhaseUpdates.delete(queue); // $FlowFixMe[incompatible-use] found when upgrading Flow + if (typeof formAction === 'function') { + // This is a server action. These have additional features to enable + // MPA-style form submissions with progressive enhancement. + // TODO: If the same permalink is passed to multiple useFormStates, and + // they all have the same action signature, Fizz will pass the postback + // state to all of them. We should probably only pass it to the first one, + // and/or warn. + // The key is lazily generated and deduped so the that the keypath doesn't + // get JSON.stringify-ed unnecessarily, and at most once. + var nextPostbackStateKey = null; // Determine the current form state. If we received state during an MPA form + // submission, then we will reuse that, if the action identity matches. + // Otherwise we'll use the initial state argument. We will emit a comment + // marker into the stream that indicates whether the state was reused. - var newState = workInProgressHook.memoizedState; - var update = firstRenderPhaseUpdate; + var state = initialState; + var componentKeyPath = currentlyRenderingKeyPath; + var postbackFormState = getFormState(request); // $FlowIgnore[prop-missing] - do { - // Process this render phase update. We don't have to check the - // priority because it will always be the same as the current - // render's. - var action = update.action; + var isSignatureEqual = action.$$IS_SIGNATURE_EQUAL; - { - isInHookUserCodeInDev = true; - } + if (postbackFormState !== null && typeof isSignatureEqual === 'function') { + var postbackKey = postbackFormState[1]; + var postbackReferenceId = postbackFormState[2]; + var postbackBoundArity = postbackFormState[3]; - newState = reducer(newState, action); + if (isSignatureEqual.call(action, postbackReferenceId, postbackBoundArity)) { + nextPostbackStateKey = createPostbackFormStateKey(permalink, componentKeyPath, formStateHookIndex); - { - isInHookUserCodeInDev = false; - } // $FlowFixMe[incompatible-type] we bail out when we get a null + if (postbackKey === nextPostbackStateKey) { + // This was a match + formStateMatchingIndex = formStateHookIndex; // Reuse the state that was submitted by the form. + + state = postbackFormState[0]; + } + } + } // Bind the state to the first argument of the action. - update = update.next; - } while (update !== null); // $FlowFixMe[incompatible-use] found when upgrading Flow + var boundAction = action.bind(null, state); // Wrap the action so the return value is void. + + var dispatch = function (payload) { + boundAction(payload); + }; // $FlowIgnore[prop-missing] - workInProgressHook.memoizedState = newState; - return [newState, dispatch]; - } - } // $FlowFixMe[incompatible-use] found when upgrading Flow + if (typeof boundAction.$$FORM_ACTION === 'function') { + // $FlowIgnore[prop-missing] + dispatch.$$FORM_ACTION = function (prefix) { + var metadata = boundAction.$$FORM_ACTION(prefix); // Override the action URL + + if (permalink !== undefined) { + { + checkAttributeStringCoercion(permalink, 'target'); + } + + permalink += ''; + metadata.action = permalink; + } + var formData = metadata.data; - return [workInProgressHook.memoizedState, dispatch]; - } else { - { - isInHookUserCodeInDev = true; - } + if (formData) { + if (nextPostbackStateKey === null) { + nextPostbackStateKey = createPostbackFormStateKey(permalink, componentKeyPath, formStateHookIndex); + } - var initialState; + formData.append('$ACTION_KEY', nextPostbackStateKey); + } - if (reducer === basicStateReducer) { - // Special case for `useState`. - initialState = typeof initialArg === 'function' ? initialArg() : initialArg; - } else { - initialState = init !== undefined ? init(initialArg) : initialArg; + return metadata; + }; } - { - isInHookUserCodeInDev = false; - } // $FlowFixMe[incompatible-use] found when upgrading Flow - + return [state, dispatch]; + } else { + // This is not a server action, so the implementation is much simpler. + // Bind the state to the first argument of the action. + var _boundAction = action.bind(null, initialState); // Wrap the action so the return value is void. - workInProgressHook.memoizedState = initialState; // $FlowFixMe[incompatible-use] found when upgrading Flow - var _queue = workInProgressHook.queue = { - last: null, - dispatch: null + var _dispatch2 = function (payload) { + _boundAction(payload); }; - var _dispatch = _queue.dispatch = dispatchAction.bind(null, currentlyRenderingComponent, _queue); // $FlowFixMe[incompatible-use] found when upgrading Flow - - - return [workInProgressHook.memoizedState, _dispatch]; + return [initialState, _dispatch2]; } } -function useMemo(nextCreate, deps) { - currentlyRenderingComponent = resolveCurrentlyRenderingComponent(); - workInProgressHook = createWorkInProgressHook(); - var nextDeps = deps === undefined ? null : deps; +function useId() { + var task = currentlyRenderingTask; + var treeId = getTreeId(task.treeContext); + var resumableState = currentResumableState; - if (workInProgressHook !== null) { - var prevState = workInProgressHook.memoizedState; + if (resumableState === null) { + throw new Error('Invalid hook call. Hooks can only be called inside of the body of a function component.'); + } - if (prevState !== null) { - if (nextDeps !== null) { - var prevDeps = prevState[1]; + var localId = localIdCounter++; + return makeId(resumableState, treeId, localId); +} - if (areHookInputsEqual(nextDeps, prevDeps)) { - return prevState[0]; - } - } +function use(usable) { + if (usable !== null && typeof usable === 'object') { + // $FlowFixMe[method-unbinding] + if (typeof usable.then === 'function') { + // This is a thenable. + var thenable = usable; + return unwrapThenable(thenable); + } else if (usable.$$typeof === REACT_CONTEXT_TYPE) { + var context = usable; + return readContext(context); } - } + } // eslint-disable-next-line react-internal/safe-string-coercion - { - isInHookUserCodeInDev = true; - } - var nextValue = nextCreate(); + throw new Error('An unsupported type was passed to use(): ' + String(usable)); +} - { - isInHookUserCodeInDev = false; - } // $FlowFixMe[incompatible-use] found when upgrading Flow +function unwrapThenable(thenable) { + var index = thenableIndexCounter; + thenableIndexCounter += 1; + if (thenableState === null) { + thenableState = createThenableState(); + } - workInProgressHook.memoizedState = [nextValue, nextDeps]; - return nextValue; + return trackUsedThenable(thenableState, thenable, index); } -function useRef(initialValue) { - currentlyRenderingComponent = resolveCurrentlyRenderingComponent(); - workInProgressHook = createWorkInProgressHook(); - var previousRef = workInProgressHook.memoizedState; - - if (previousRef === null) { - var ref = { - current: initialValue - }; +function unsupportedRefresh() { + throw new Error('Cache cannot be refreshed during server rendering.'); +} - { - Object.seal(ref); - } // $FlowFixMe[incompatible-use] found when upgrading Flow +function useCacheRefresh() { + return unsupportedRefresh; +} +function useMemoCache(size) { + var data = new Array(size); - workInProgressHook.memoizedState = ref; - return ref; - } else { - return previousRef; + for (var i = 0; i < size; i++) { + data[i] = REACT_MEMO_CACHE_SENTINEL; } + + return data; } -function dispatchAction(componentIdentity, queue, action) { - if (numberOfReRenders >= RE_RENDER_LIMIT) { - throw new Error('Too many re-renders. React limits the number of renders to prevent ' + 'an infinite loop.'); - } +function noop$1() {} - if (componentIdentity === currentlyRenderingComponent) { - // This is a render phase update. Stash it in a lazily-created map of - // queue -> linked list of updates. After this render pass, we'll restart - // and apply the stashed updates on top of the work-in-progress hook. - didScheduleRenderPhaseUpdate = true; - var update = { - action: action, - next: null - }; +var HooksDispatcher = { + readContext: readContext, + use: use, + useContext: useContext, + useMemo: useMemo, + useReducer: useReducer, + useRef: useRef, + useState: useState, + useInsertionEffect: noop$1, + useLayoutEffect: noop$1, + useCallback: useCallback, + // useImperativeHandle is not run in the server environment + useImperativeHandle: noop$1, + // Effects are not run in the server environment. + useEffect: noop$1, + // Debugging effect + useDebugValue: noop$1, + useDeferredValue: useDeferredValue, + useTransition: useTransition, + useId: useId, + // Subscriptions are not setup in a server environment. + useSyncExternalStore: useSyncExternalStore +}; - if (renderPhaseUpdates === null) { - renderPhaseUpdates = new Map(); - } +{ + HooksDispatcher.useCacheRefresh = useCacheRefresh; +} - var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); +{ + HooksDispatcher.useEffectEvent = useEffectEvent; +} - if (firstRenderPhaseUpdate === undefined) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - renderPhaseUpdates.set(queue, update); - } else { - // Append the update to the end of the list. - var lastRenderPhaseUpdate = firstRenderPhaseUpdate; +{ + HooksDispatcher.useMemoCache = useMemoCache; +} - while (lastRenderPhaseUpdate.next !== null) { - lastRenderPhaseUpdate = lastRenderPhaseUpdate.next; - } +{ + HooksDispatcher.useHostTransitionStatus = useHostTransitionStatus; +} - lastRenderPhaseUpdate.next = update; - } - } +{ + HooksDispatcher.useOptimistic = useOptimistic; + HooksDispatcher.useFormState = useFormState; } -function useCallback(callback, deps) { - return useMemo(function () { - return callback; - }, deps); +var currentResumableState = null; +function setCurrentResumableState(resumableState) { + currentResumableState = resumableState; } -function throwOnUseEffectEventCall() { - throw new Error("A function wrapped in useEffectEvent can't be called during rendering."); +function getCacheSignal() { + throw new Error('Not implemented.'); } -function useEffectEvent(callback) { - // $FlowIgnore[incompatible-return] - return throwOnUseEffectEventCall; +function getCacheForType(resourceType) { + throw new Error('Not implemented.'); } -function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { - if (getServerSnapshot === undefined) { - throw new Error('Missing getServerSnapshot, which is required for ' + 'server-rendered content. Will revert to client rendering.'); +var DefaultCacheDispatcher = { + getCacheSignal: getCacheSignal, + getCacheForType: getCacheForType +}; + +// 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 */ + } + + disabledDepth++; } - - return getServerSnapshot(); } +function reenableLogs() { + { + disabledDepth--; -function useDeferredValue(value, initialValue) { - resolveCurrentlyRenderingComponent(); + 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. - { - return initialValue !== undefined ? initialValue : value; - } -} + 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 unsupportedStartTransition() { - throw new Error('startTransition cannot be called during server rendering.'); + if (disabledDepth < 0) { + error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); + } + } } -function useTransition() { - resolveCurrentlyRenderingComponent(); - return [false, unsupportedStartTransition]; -} +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher; +var prefix; +function describeBuiltInComponentFrame(name, ownerFn) { + { + if (prefix === undefined) { + // Extract the VM specific prefix used by each line. + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = match && match[1] || ''; + } + } // We use the prefix to ensure our stacks line up with native stack frames. -function useHostTransitionStatus() { - resolveCurrentlyRenderingComponent(); - return NotPendingTransition; -} -function unsupportedSetOptimisticState() { - throw new Error('Cannot update optimistic state while rendering.'); + return '\n' + prefix + name; + } } +var reentry = false; +var componentFrameCache; -function useOptimistic(passthrough, reducer) { - resolveCurrentlyRenderingComponent(); - return [passthrough, unsupportedSetOptimisticState]; +{ + var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap(); } +/** + * 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 createPostbackFormStateKey(permalink, componentKeyPath, hookIndex) { - if (permalink !== undefined) { - // Don't bother to hash a permalink-based key since it's already short. - return 'p' + permalink; - } else { - // Append a node to the key path that represents the form state hook. - var keyPath = [componentKeyPath, null, hookIndex]; // Key paths are hashed to reduce the size. It does not need to be secure, - // and it's more important that it's fast than that it's completely - // collision-free. - var keyPathHash = createFastHashJS(JSON.stringify(keyPath)); - return 'k' + keyPathHash; +function describeNativeComponentFrame(fn, construct) { + // If something asked for a stack inside a fake render, it should get ignored. + if (!fn || reentry) { + return ''; } -} - -function useFormState(action, initialState, permalink) { - resolveCurrentlyRenderingComponent(); // Count the number of useFormState hooks per component. We also use this to - // track the position of this useFormState hook relative to the other ones in - // this component, so we can generate a unique key for each one. - var formStateHookIndex = formStateCounter++; - var request = currentlyRenderingRequest; // $FlowIgnore[prop-missing] + { + var frame = componentFrameCache.get(fn); - var formAction = action.$$FORM_ACTION; + if (frame !== undefined) { + return frame; + } + } - if (typeof formAction === 'function') { - // This is a server action. These have additional features to enable - // MPA-style form submissions with progressive enhancement. - // TODO: If the same permalink is passed to multiple useFormStates, and - // they all have the same action signature, Fizz will pass the postback - // state to all of them. We should probably only pass it to the first one, - // and/or warn. - // The key is lazily generated and deduped so the that the keypath doesn't - // get JSON.stringify-ed unnecessarily, and at most once. - var nextPostbackStateKey = null; // Determine the current form state. If we received state during an MPA form - // submission, then we will reuse that, if the action identity matches. - // Otherwise we'll use the initial state argument. We will emit a comment - // marker into the stream that indicates whether the state was reused. + reentry = true; + var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. - var state = initialState; - var componentKeyPath = currentlyRenderingKeyPath; - var postbackFormState = getFormState(request); // $FlowIgnore[prop-missing] + Error.prepareStackTrace = undefined; + var previousDispatcher; - var isSignatureEqual = action.$$IS_SIGNATURE_EQUAL; + { + previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function + // for warnings. - if (postbackFormState !== null && typeof isSignatureEqual === 'function') { - var postbackKey = postbackFormState[1]; - var postbackReferenceId = postbackFormState[2]; - var postbackBoundArity = postbackFormState[3]; + ReactCurrentDispatcher$1.current = 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. + */ - if (isSignatureEqual.call(action, postbackReferenceId, postbackBoundArity)) { - nextPostbackStateKey = createPostbackFormStateKey(permalink, componentKeyPath, formStateHookIndex); - if (postbackKey === nextPostbackStateKey) { - // This was a match - formStateMatchingIndex = formStateHookIndex; // Reuse the state that was submitted by the form. + var RunInRootFrame = { + DetermineComponentFrameRoot: function () { + var control; - state = postbackFormState[0]; - } - } - } // Bind the state to the first argument of the action. + try { + // This should throw. + if (construct) { + // Something should be setting the props in the constructor. + var Fake = function () { + throw Error(); + }; // $FlowFixMe[prop-missing] - var boundAction = action.bind(null, state); // Wrap the action so the return value is void. + 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(); + } + }); - var dispatch = function (payload) { - boundAction(payload); - }; // $FlowIgnore[prop-missing] + 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 - if (typeof boundAction.$$FORM_ACTION === 'function') { - // $FlowIgnore[prop-missing] - dispatch.$$FORM_ACTION = function (prefix) { - var metadata = boundAction.$$FORM_ACTION(prefix); // Override the action URL - if (permalink !== undefined) { - { - checkAttributeStringCoercion(permalink, 'target'); + 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 - permalink += ''; - metadata.action = permalink; - } - var formData = metadata.data; + 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 (formData) { - if (nextPostbackStateKey === null) { - nextPostbackStateKey = createPostbackFormStateKey(permalink, componentKeyPath, formStateHookIndex); + if (maybePromise && typeof maybePromise.catch === 'function') { + maybePromise.catch(function () {}); } - - formData.append('$ACTION_KEY', nextPostbackStateKey); } + } 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]; + } + } - return metadata; - }; + return [null, null]; } + }; // $FlowFixMe[prop-missing] - return [state, dispatch]; - } else { - // This is not a server action, so the implementation is much simpler. - // Bind the state to the first argument of the action. - var _boundAction = action.bind(null, initialState); // Wrap the action so the return value is void. - - - var _dispatch2 = function (payload) { - _boundAction(payload); - }; + RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; + var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable. - return [initialState, _dispatch2]; + 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' + }); } -} - -function useId() { - var task = currentlyRenderingTask; - var treeId = getTreeId(task.treeContext); - var resumableState = currentResumableState; - if (resumableState === null) { - throw new Error('Invalid hook call. Hooks can only be called inside of the body of a function component.'); - } + try { + var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(), + sampleStack = _RunInRootFrame$Deter[0], + controlStack = _RunInRootFrame$Deter[1]; - var localId = localIdCounter++; - return makeId(resumableState, treeId, localId); -} + 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; -function use(usable) { - if (usable !== null && typeof usable === 'object') { - // $FlowFixMe[method-unbinding] - if (typeof usable.then === 'function') { - // This is a thenable. - var thenable = usable; - return unwrapThenable(thenable); - } else if (usable.$$typeof === REACT_CONTEXT_TYPE) { - var context = usable; - return readContext(context); - } - } // eslint-disable-next-line react-internal/safe-string-coercion + while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { + s++; + } + 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... - throw new Error('An unsupported type was passed to use(): ' + String(usable)); -} -function unwrapThenable(thenable) { - var index = thenableIndexCounter; - thenableIndexCounter += 1; + if (s === sampleLines.length || c === controlLines.length) { + s = sampleLines.length - 1; + c = controlLines.length - 1; - if (thenableState === null) { - thenableState = createThenableState(); - } + 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--; + } + } - return trackUsedThenable(thenableState, thenable, index); -} + 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. -function unsupportedRefresh() { - throw new Error('Cache cannot be refreshed during server rendering.'); -} + 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. -function useCacheRefresh() { - return unsupportedRefresh; -} -function useMemoCache(size) { - var data = new Array(size); + if (fn.displayName && _frame.includes('')) { + _frame = _frame.replace('', fn.displayName); + } - for (var i = 0; i < size; i++) { - data[i] = REACT_MEMO_CACHE_SENTINEL; - } + if (true) { + if (typeof fn === 'function') { + componentFrameCache.set(fn, _frame); + } + } // Return the line we found. - return data; -} -function noop$1() {} + return _frame; + } + } while (s >= 1 && c >= 0); + } -var HooksDispatcher = { - readContext: readContext, - use: use, - useContext: useContext, - useMemo: useMemo, - useReducer: useReducer, - useRef: useRef, - useState: useState, - useInsertionEffect: noop$1, - useLayoutEffect: noop$1, - useCallback: useCallback, - // useImperativeHandle is not run in the server environment - useImperativeHandle: noop$1, - // Effects are not run in the server environment. - useEffect: noop$1, - // Debugging effect - useDebugValue: noop$1, - useDeferredValue: useDeferredValue, - useTransition: useTransition, - useId: useId, - // Subscriptions are not setup in a server environment. - useSyncExternalStore: useSyncExternalStore -}; + break; + } + } + } + } finally { + reentry = false; -{ - HooksDispatcher.useCacheRefresh = useCacheRefresh; -} + { + ReactCurrentDispatcher$1.current = previousDispatcher; + reenableLogs(); + } -{ - HooksDispatcher.useEffectEvent = useEffectEvent; -} + Error.prepareStackTrace = previousPrepareStackTrace; + } // Fallback to just using the name if we couldn't make it throw. -{ - HooksDispatcher.useMemoCache = useMemoCache; -} -{ - HooksDispatcher.useHostTransitionStatus = useHostTransitionStatus; -} + var name = fn ? fn.displayName || fn.name : ''; + var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; -{ - HooksDispatcher.useOptimistic = useOptimistic; - HooksDispatcher.useFormState = useFormState; -} + { + if (typeof fn === 'function') { + componentFrameCache.set(fn, syntheticFrame); + } + } -var currentResumableState = null; -function setCurrentResumableState(resumableState) { - currentResumableState = resumableState; + return syntheticFrame; } -function getCacheSignal() { - throw new Error('Not implemented.'); +function describeClassComponentFrame(ctor, ownerFn) { + { + return describeNativeComponentFrame(ctor, true); + } } - -function getCacheForType(resourceType) { - throw new Error('Not implemented.'); +function describeFunctionComponentFrame(fn, ownerFn) { + { + return describeNativeComponentFrame(fn, false); + } } -var DefaultCacheDispatcher = { - getCacheSignal: getCacheSignal, - getCacheForType: getCacheForType -}; - function getStackByComponentStackNode(componentStack) { try { var info = ''; @@ -9305,19 +9458,19 @@ function encodeErrorForBoundary(boundary, digest, error, thrownInfo) { boundary.errorDigest = digest; { - // In dev we additionally encode the error message and component stack on the boundary - var errorMessage; + var message; // In dev we additionally encode the error message and component stack on the boundary - if (typeof error === 'string') { - errorMessage = error; - } else if (error && typeof error.message === 'string') { - errorMessage = error.message; + if (error instanceof Error) { + // eslint-disable-next-line react-internal/safe-string-coercion + message = String(error.message); + } else if (typeof error === 'object' && error !== null) { + message = describeObjectForErrorMessage(error); } else { // eslint-disable-next-line react-internal/safe-string-coercion - errorMessage = String(error); + message = String(error); } - boundary.errorMessage = errorMessage; + boundary.errorMessage = message; boundary.errorComponentStack = thrownInfo.componentStack; } } @@ -9702,8 +9855,7 @@ var didWarnAboutGetDerivedStateOnFunctionComponent = {}; var didWarnAboutReassigningProps = false; var didWarnAboutDefaultPropsOnFunctionComponent = {}; var didWarnAboutGenerators = false; -var didWarnAboutMaps = false; -var hasWarnedAboutUsingContextAsConsumer = false; // This would typically be a function component but we still support module pattern +var didWarnAboutMaps = false; // This would typically be a function component but we still support module pattern // components for some reason. function renderIndeterminateComponent(request, task, keyPath, Component, props) { @@ -9904,30 +10056,6 @@ function renderMemo(request, task, keyPath, type, props, ref) { } function renderContextConsumer(request, task, keyPath, context, props) { - // The logic below for Context differs depending on PROD or DEV mode. In - // DEV mode, we create a separate object for Context.Consumer that acts - // like a proxy to Context. This proxy object adds unnecessary code in PROD - // so we use the old behaviour (Context.Consumer references Context) to - // reduce size and overhead. The separate object references context via - // a property called "_context", which also gives us the ability to check - // in DEV mode if this property exists or not and warn if it does not. - { - if (context._context === undefined) { - // This may be because it's a Context (rather than a Consumer). - // Or it may be because it's older React where they're the same thing. - // We only want to warn if we're sure it's a new React. - if (context !== context.Consumer) { - if (!hasWarnedAboutUsingContextAsConsumer) { - hasWarnedAboutUsingContextAsConsumer = true; - - error('Rendering directly is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?'); - } - } - } else { - context = context._context; - } - } - var render = props.children; { @@ -9944,8 +10072,7 @@ function renderContextConsumer(request, task, keyPath, context, props) { task.keyPath = prevKeyPath; } -function renderContextProvider(request, task, keyPath, type, props) { - var context = type._context; +function renderContextProvider(request, task, keyPath, context, props) { var value = props.value; var children = props.children; var prevSnapshot; @@ -10082,16 +10209,32 @@ function renderElement(request, task, keyPath, type, props, ref) { case REACT_PROVIDER_TYPE: { - renderContextProvider(request, task, keyPath, type, props); - return; + { + var context = type._context; + renderContextProvider(request, task, keyPath, context, props); + return; + } // Fall through + } case REACT_CONTEXT_TYPE: { - renderContextConsumer(request, task, keyPath, type, props); - return; + { + var _context2 = type; + + { + if (_context2._context !== undefined) { + _context2 = _context2._context; + } + } + + renderContextConsumer(request, task, keyPath, _context2, props); + return; + } } + case REACT_CONSUMER_TYPE: + case REACT_LAZY_TYPE: { renderLazyComponent(request, task, keyPath, type, props); @@ -10243,6 +10386,23 @@ function validateIterable(iterable, iteratorFn) { didWarnAboutMaps = true; } } +} + +function warnOnFunctionType(invalidChild) { + { + var name = invalidChild.displayName || invalidChild.name || 'Component'; + + error('Functions are not valid as a React child. This may happen if ' + 'you return %s instead of <%s /> from render. ' + 'Or maybe you meant to call this function rather than return it.', name, name); + } +} + +function warnOnSymbolType(invalidChild) { + { + // eslint-disable-next-line react-internal/safe-string-coercion + var name = String(invalidChild); + + error('Symbols are not valid as a React child.\n' + ' %s', name); + } } // This function by it self renders a node and consumes the task by mutating it // to update the current execution state. @@ -10397,7 +10557,11 @@ function renderNodeDestructive(request, task, node, childIndex) { { if (typeof node === 'function') { - error('Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of from render. ' + 'Or maybe you meant to call this function rather than return it.'); + warnOnFunctionType(node); + } + + if (typeof node === 'symbol') { + warnOnSymbolType(node); } } } diff --git a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.production.js b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.production.js index c95631b5ad4d8..81b032aee2746 100644 --- a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.production.js +++ b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.production.js @@ -30,7 +30,57 @@ function formatProdErrorMessage(code) { return "Minified React error #" + code + "; visit " + url + " for the full message or " + 'use the non-minified dev environment for full errors and additional ' + 'helpful warnings.'; } -var ReactVersion = '18.3.0-experimental-ba5e6a832-20240208'; +var ReactVersion = '18.3.0-experimental-a515d753b-20240220'; + +// ----------------------------------------------------------------------------- +const enableFloat = true; // Enables unstable_useMemoCache hook, intended as a compilation target for + +// ATTENTION +// 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. +const REACT_ELEMENT_TYPE = Symbol.for('react.element'); +const REACT_PORTAL_TYPE = Symbol.for('react.portal'); +const REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); +const REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); +const REACT_PROFILER_TYPE = Symbol.for('react.profiler'); +const REACT_PROVIDER_TYPE = Symbol.for('react.provider'); // TODO: Delete with enableRenderableContext + +const REACT_CONSUMER_TYPE = Symbol.for('react.consumer'); +const REACT_CONTEXT_TYPE = Symbol.for('react.context'); +const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); +const REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); +const REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); +const REACT_MEMO_TYPE = Symbol.for('react.memo'); +const REACT_LAZY_TYPE = Symbol.for('react.lazy'); +const REACT_SCOPE_TYPE = Symbol.for('react.scope'); +const REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for('react.debug_trace_mode'); +const REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); +const REACT_LEGACY_HIDDEN_TYPE = Symbol.for('react.legacy_hidden'); +const REACT_CACHE_TYPE = Symbol.for('react.cache'); +const REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel'); +const REACT_POSTPONE_TYPE = Symbol.for('react.postpone'); +const MAYBE_ITERATOR_SYMBOL = Symbol.iterator; +const FAUX_ITERATOR_SYMBOL = '@@iterator'; +function getIteratorFn(maybeIterable) { + if (maybeIterable === null || typeof maybeIterable !== 'object') { + return null; + } + + const maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; + + if (typeof maybeIterator === 'function') { + return maybeIterator; + } + + return null; +} + +const isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare + +function isArray(a) { + return isArrayImpl(a); +} // A pure JS implementation of a string hashing function. We do not use it for // security or obfuscation purposes, only to create compact hashes. So we @@ -154,9 +204,6 @@ function closeWithError(destination, error) { const assign = Object.assign; -// ----------------------------------------------------------------------------- -const enableFloat = true; // Enables unstable_useMemoCache hook, intended as a compilation target for - // $FlowFixMe[method-unbinding] const hasOwnProperty = Object.prototype.hasOwnProperty; @@ -326,12 +373,6 @@ function sanitizeURL(url) { return url; } -const isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare - -function isArray(a) { - return isArrayImpl(a); -} - // The build script is at scripts/rollup/generate-inline-fizz-runtime.js. // Run `yarn generate-inline-fizz-runtime` to generate. const clientRenderBoundary = '$RX=function(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};'; @@ -4995,45 +5036,6 @@ function writeEndClientRenderedSuspenseBoundary(destination, renderState) { } const NotPendingTransition = NotPending; -// ATTENTION -// 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. -const REACT_ELEMENT_TYPE = Symbol.for('react.element'); -const REACT_PORTAL_TYPE = Symbol.for('react.portal'); -const REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); -const REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); -const REACT_PROFILER_TYPE = Symbol.for('react.profiler'); -const REACT_PROVIDER_TYPE = Symbol.for('react.provider'); -const REACT_CONTEXT_TYPE = Symbol.for('react.context'); -const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); -const REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); -const REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); -const REACT_MEMO_TYPE = Symbol.for('react.memo'); -const REACT_LAZY_TYPE = Symbol.for('react.lazy'); -const REACT_SCOPE_TYPE = Symbol.for('react.scope'); -const REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for('react.debug_trace_mode'); -const REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); -const REACT_LEGACY_HIDDEN_TYPE = Symbol.for('react.legacy_hidden'); -const REACT_CACHE_TYPE = Symbol.for('react.cache'); -const REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel'); -const REACT_POSTPONE_TYPE = Symbol.for('react.postpone'); -const MAYBE_ITERATOR_SYMBOL = Symbol.iterator; -const FAUX_ITERATOR_SYMBOL = '@@iterator'; -function getIteratorFn(maybeIterable) { - if (maybeIterable === null || typeof maybeIterable !== 'object') { - return null; - } - - const maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; - - if (typeof maybeIterator === 'function') { - return maybeIterator; - } - - return null; -} - function getWrappedName(outerType, innerType, wrapperName) { const displayName = outerType.displayName; @@ -5100,13 +5102,23 @@ function getComponentNameFromType(type) { if (typeof type === 'object') { switch (type.$$typeof) { + case REACT_PROVIDER_TYPE: + { + const provider = type; + return getContextName(provider._context) + '.Provider'; + } + case REACT_CONTEXT_TYPE: const context = type; - return getContextName(context) + '.Consumer'; - case REACT_PROVIDER_TYPE: - const provider = type; - return getContextName(provider._context) + '.Provider'; + { + return getContextName(context) + '.Consumer'; + } + + case REACT_CONSUMER_TYPE: + { + return null; + } case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, 'ForwardRef'); @@ -5138,326 +5150,86 @@ function getComponentNameFromType(type) { return null; } -let prefix; -function describeBuiltInComponentFrame(name, ownerFn) { +const emptyContextObject = {}; + +function getMaskedContext(type, unmaskedContext) { { - if (prefix === undefined) { - // Extract the VM specific prefix used by each line. - try { - throw Error(); - } catch (x) { - const match = x.stack.trim().match(/\n( *(at )?)/); - prefix = match && match[1] || ''; - } - } // We use the prefix to ensure our stacks line up with native stack frames. + const contextTypes = type.contextTypes; + if (!contextTypes) { + return emptyContextObject; + } - return '\n' + prefix + name; + const context = {}; + + for (const key in contextTypes) { + context[key] = unmaskedContext[key]; + } + + return context; } } -let reentry = false; -let componentFrameCache; -/** - * 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 processChildContext(instance, type, parentContext, childContextTypes) { + { + // TODO (bvaughn) Replace this behavior with an invariant() in the future. + // It has only been added in Fiber to match the (unintentional) behavior in Stack. + if (typeof instance.getChildContext !== 'function') { + return parentContext; + } -function describeNativeComponentFrame(fn, construct) { - // If something asked for a stack inside a fake render, it should get ignored. - if (!fn || reentry) { - return ''; - } + const childContext = instance.getChildContext(); - reentry = true; - const previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. + for (const contextKey in childContext) { + if (!(contextKey in childContextTypes)) { + throw Error(formatProdErrorMessage(108, getComponentNameFromType(type) || 'Unknown', contextKey)); + } + } - Error.prepareStackTrace = undefined; - /** - * 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. - */ + return assign({}, parentContext, childContext); + } +} +// Forming a reverse tree. +// The structure of a context snapshot is an implementation of this file. +// Currently, it's implemented as tracking the current active node. - const RunInRootFrame = { - DetermineComponentFrameRoot() { - let control; - try { - // This should throw. - if (construct) { - // Something should be setting the props in the constructor. - const Fake = function () { - throw Error(); - }; // $FlowFixMe[prop-missing] +const rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances. +// This global (actually thread local) state represents what state all those "current", +// fields are currently in. +let currentActiveSnapshot = null; - 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(); - } - }); +function popNode(prev) { + { + prev.context._currentValue2 = prev.parentValue; + } +} - 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; - } +function pushNode(next) { + { + next.context._currentValue2 = next.value; + } +} - Reflect.construct(fn, [], Fake); - } else { - try { - Fake.call(); - } catch (x) { - control = x; - } // $FlowFixMe[prop-missing] found when upgrading Flow +function popToNearestCommonAncestor(prev, next) { + if (prev === next) ; else { + popNode(prev); + const parentPrev = prev.parent; + const parentNext = next.parent; + if (parentPrev === null) { + if (parentNext !== null) { + throw Error(formatProdErrorMessage(401)); + } + } else { + if (parentNext === null) { + throw Error(formatProdErrorMessage(401)); + } - 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 - - - const 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(() => {}); - } - } - } 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]; - } - } - - return [null, null]; - } - - }; // $FlowFixMe[prop-missing] - - RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; - const 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 { - const _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. - const sampleLines = sampleStack.split('\n'); - const controlLines = controlStack.split('\n'); - let s = 0; - let c = 0; - - while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { - s++; - } - - 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--; - } - } - - 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. - let 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 (false) ; // Return the line we found. - - - return frame; - } - } while (s >= 1 && c >= 0); - } - - break; - } - } - } - } finally { - reentry = false; - - Error.prepareStackTrace = previousPrepareStackTrace; - } // Fallback to just using the name if we couldn't make it throw. - - - const name = fn ? fn.displayName || fn.name : ''; - const syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; - - return syntheticFrame; -} - -function describeClassComponentFrame(ctor, ownerFn) { - { - return describeNativeComponentFrame(ctor, true); - } -} -function describeFunctionComponentFrame(fn, ownerFn) { - { - return describeNativeComponentFrame(fn, false); - } -} - -const emptyContextObject = {}; - -function getMaskedContext(type, unmaskedContext) { - { - const contextTypes = type.contextTypes; - - if (!contextTypes) { - return emptyContextObject; - } - - const context = {}; - - for (const key in contextTypes) { - context[key] = unmaskedContext[key]; - } - - return context; - } -} -function processChildContext(instance, type, parentContext, childContextTypes) { - { - // TODO (bvaughn) Replace this behavior with an invariant() in the future. - // It has only been added in Fiber to match the (unintentional) behavior in Stack. - if (typeof instance.getChildContext !== 'function') { - - return parentContext; - } - - const childContext = instance.getChildContext(); - - for (const contextKey in childContext) { - if (!(contextKey in childContextTypes)) { - throw Error(formatProdErrorMessage(108, getComponentNameFromType(type) || 'Unknown', contextKey)); - } - } - - return assign({}, parentContext, childContext); - } -} - -// Forming a reverse tree. -// The structure of a context snapshot is an implementation of this file. -// Currently, it's implemented as tracking the current active node. - - -const rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances. -// This global (actually thread local) state represents what state all those "current", -// fields are currently in. - -let currentActiveSnapshot = null; - -function popNode(prev) { - { - prev.context._currentValue2 = prev.parentValue; - } -} - -function pushNode(next) { - { - next.context._currentValue2 = next.value; - } -} - -function popToNearestCommonAncestor(prev, next) { - if (prev === next) ; else { - popNode(prev); - const parentPrev = prev.parent; - const parentNext = next.parent; - - if (parentPrev === null) { - if (parentNext !== null) { - throw Error(formatProdErrorMessage(401)); - } - } else { - if (parentNext === null) { - throw Error(formatProdErrorMessage(401)); - } - - popToNearestCommonAncestor(parentPrev, parentNext); - } // On the way back, we push the new ones that weren't common. + popToNearestCommonAncestor(parentPrev, parentNext); + } // On the way back, we push the new ones that weren't common. pushNode(next); @@ -6639,6 +6411,246 @@ const DefaultCacheDispatcher = { getCacheForType }; +let prefix; +function describeBuiltInComponentFrame(name, ownerFn) { + { + if (prefix === undefined) { + // Extract the VM specific prefix used by each line. + try { + throw Error(); + } catch (x) { + const match = x.stack.trim().match(/\n( *(at )?)/); + prefix = match && match[1] || ''; + } + } // We use the prefix to ensure our stacks line up with native stack frames. + + + return '\n' + prefix + name; + } +} +let reentry = false; +let componentFrameCache; +/** + * 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 ''; + } + + reentry = true; + const previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined. + + Error.prepareStackTrace = undefined; + /** + * 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. + */ + + + const RunInRootFrame = { + DetermineComponentFrameRoot() { + let control; + + try { + // This should throw. + if (construct) { + // Something should be setting the props in the constructor. + const 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 (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 + + + const 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(() => {}); + } + } + } 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]; + } + } + + return [null, null]; + } + + }; // $FlowFixMe[prop-missing] + + RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot'; + const 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 { + const _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. + const sampleLines = sampleStack.split('\n'); + const controlLines = controlStack.split('\n'); + let s = 0; + let c = 0; + + while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) { + s++; + } + + 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--; + } + } + + 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. + let 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 (false) ; // Return the line we found. + + + return frame; + } + } while (s >= 1 && c >= 0); + } + + break; + } + } + } + } finally { + reentry = false; + + Error.prepareStackTrace = previousPrepareStackTrace; + } // Fallback to just using the name if we couldn't make it throw. + + + const name = fn ? fn.displayName || fn.name : ''; + const syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; + + return syntheticFrame; +} + +function describeClassComponentFrame(ctor, ownerFn) { + { + return describeNativeComponentFrame(ctor, true); + } +} +function describeFunctionComponentFrame(fn, ownerFn) { + { + return describeNativeComponentFrame(fn, false); + } +} + function getStackByComponentStackNode(componentStack) { try { let info = ''; @@ -7389,7 +7401,6 @@ function renderMemo(request, task, keyPath, type, props, ref) { } function renderContextConsumer(request, task, keyPath, context, props) { - const render = props.children; const newValue = readContext$1(context); @@ -7400,8 +7411,7 @@ function renderContextConsumer(request, task, keyPath, context, props) { task.keyPath = prevKeyPath; } -function renderContextProvider(request, task, keyPath, type, props) { - const context = type._context; +function renderContextProvider(request, task, keyPath, context, props) { const value = props.value; const children = props.children; @@ -7527,16 +7537,26 @@ function renderElement(request, task, keyPath, type, props, ref) { case REACT_PROVIDER_TYPE: { - renderContextProvider(request, task, keyPath, type, props); - return; + { + const context = type._context; + renderContextProvider(request, task, keyPath, context, props); + return; + } // Fall through + } case REACT_CONTEXT_TYPE: { - renderContextConsumer(request, task, keyPath, type, props); - return; + { + let context = type; + + renderContextConsumer(request, task, keyPath, context, props); + return; + } } + case REACT_CONSUMER_TYPE: + case REACT_LAZY_TYPE: { renderLazyComponent(request, task, keyPath, type, props); diff --git a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.production.min.js b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.production.min.js index f51cfebed3c4a..b3fb6ae4d0641 100644 --- a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.production.min.js +++ b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server-legacy.browser.production.min.js @@ -29,186 +29,187 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -'use strict';var ba=require("next/dist/compiled/react-experimental"),ea=require("react-dom");function q(a){var b="https://react.dev/errors/"+a;if(1>>16)&65535)<<16)&4294967295;f=f<<15|f>>>17;f=461845907*(f&65535)+((461845907*(f>>>16)&65535)<<16)&4294967295;e^=f;e=e<<13|e>>>19;e=5*(e&65535)+((5*(e>>>16)&65535)<<16)&4294967295;e=(e&65535)+27492+(((e>>>16)+58964&65535)<<16)}f=0;switch(c){case 3:f^=(a.charCodeAt(b+2)&255)<< +'use strict';var ba=require("next/dist/compiled/react-experimental"),ca=require("react-dom");function q(a){var b="https://react.dev/errors/"+a;if(1>>16)&65535)<<16)&4294967295;f=f<<15|f>>>17;f=461845907*(f&65535)+((461845907*(f>>>16)&65535)<<16)&4294967295;e^=f;e=e<<13|e>>>19;e=5*(e&65535)+((5*(e>>>16)&65535)<<16)&4294967295;e=(e&65535)+27492+(((e>>>16)+58964&65535)<<16)}f=0;switch(c){case 3:f^=(a.charCodeAt(b+2)&255)<< 16;case 2:f^=(a.charCodeAt(b+1)&255)<<8;case 1:f^=a.charCodeAt(b)&255,f=3432918353*(f&65535)+((3432918353*(f>>>16)&65535)<<16)&4294967295,f=f<<15|f>>>17,e^=461845907*(f&65535)+((461845907*(f>>>16)&65535)<<16)&4294967295}e^=a.length;e^=e>>>16;e=2246822507*(e&65535)+((2246822507*(e>>>16)&65535)<<16)&4294967295;e^=e>>>13;e=3266489909*(e&65535)+((3266489909*(e>>>16)&65535)<<16)&4294967295;return(e^e>>>16)>>>0} -var v=Object.assign,A=Object.prototype.hasOwnProperty,ha=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ia={},pa={}; -function qa(a){if(A.call(pa,a))return!0;if(A.call(ia,a))return!1;if(ha.test(a))return pa[a]=!0;ia[a]=!0;return!1} -var ra=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" ")),Aa= +var v=Object.assign,A=Object.prototype.hasOwnProperty,kb=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),lb={},mb={}; +function nb(a){if(A.call(mb,a))return!0;if(A.call(lb,a))return!1;if(kb.test(a))return mb[a]=!0;lb[a]=!0;return!1} +var ob=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" ")),pb= new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"], ["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical", "glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering", "shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"], ["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"], -["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Ba=/["'&<>]/; -function C(a){if("boolean"===typeof a||"number"===typeof a)return""+a;a=""+a;var b=Ba.exec(a);if(b){var c="",d,e=0;for(d=b.index;d")} -function Kb(a,b,c,d,e,f,g,h){var k=null;"function"===typeof d&&("function"===typeof d.$$FORM_ACTION?(e=qb(b),b=d.$$FORM_ACTION(e),h=b.name,d=b.action||"",e=b.encType,f=b.method,g=b.target,k=b.data):(a.push(" ","formAction",'="',Ib,'"'),g=f=e=d=h=null,Lb(b,c)));null!=h&&L(a,"name",h);null!=d&&L(a,"formAction",d);null!=e&&L(a,"formEncType",e);null!=f&&L(a,"formMethod",f);null!=g&&L(a,"formTarget",g);return k} -function L(a,b,c){switch(b){case "className":K(a,"class",c);break;case "tabIndex":K(a,"tabindex",c);break;case "dir":case "role":case "viewBox":case "width":case "height":K(a,b,c);break;case "style":ob(a,c);break;case "src":case "href":if(""===c)break;case "action":case "formAction":if(null==c||"function"===typeof c||"symbol"===typeof c||"boolean"===typeof c)break;a.push(" ",b,'="',C(""+c),'"');break;case "defaultValue":case "defaultChecked":case "innerHTML":case "suppressContentEditableWarning":case "suppressHydrationWarning":break; -case "autoFocus":case "multiple":case "muted":pb(a,b.toLowerCase(),c);break;case "xlinkHref":if("function"===typeof c||"symbol"===typeof c||"boolean"===typeof c)break;a.push(" ","xlink:href",'="',C(""+c),'"');break;case "contentEditable":case "spellCheck":case "draggable":case "value":case "autoReverse":case "externalResourcesRequired":case "focusable":case "preserveAlpha":"function"!==typeof c&&"symbol"!==typeof c&&a.push(" ",b,'="',C(c),'"');break;case "allowFullScreen":case "async":case "autoPlay":case "controls":case "default":case "defer":case "disabled":case "disablePictureInPicture":case "disableRemotePlayback":case "formNoValidate":case "hidden":case "loop":case "noModule":case "noValidate":case "open":case "playsInline":case "readOnly":case "required":case "reversed":case "scoped":case "seamless":case "itemScope":c&& +["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),qb=/["'&<>]/; +function C(a){if("boolean"===typeof a||"number"===typeof a)return""+a;a=""+a;var b=qb.exec(a);if(b){var c="",d,e=0;for(d=b.index;d")} +function ec(a,b,c,d,e,f,g,h){var k=null;"function"===typeof d&&("function"===typeof d.$$FORM_ACTION?(e=bc(b),b=d.$$FORM_ACTION(e),h=b.name,d=b.action||"",e=b.encType,f=b.method,g=b.target,k=b.data):(a.push(" ","formAction",'="',cc,'"'),g=f=e=d=h=null,qc(b,c)));null!=h&&L(a,"name",h);null!=d&&L(a,"formAction",d);null!=e&&L(a,"formEncType",e);null!=f&&L(a,"formMethod",f);null!=g&&L(a,"formTarget",g);return k} +function L(a,b,c){switch(b){case "className":K(a,"class",c);break;case "tabIndex":K(a,"tabindex",c);break;case "dir":case "role":case "viewBox":case "width":case "height":K(a,b,c);break;case "style":$b(a,c);break;case "src":case "href":if(""===c)break;case "action":case "formAction":if(null==c||"function"===typeof c||"symbol"===typeof c||"boolean"===typeof c)break;a.push(" ",b,'="',C(""+c),'"');break;case "defaultValue":case "defaultChecked":case "innerHTML":case "suppressContentEditableWarning":case "suppressHydrationWarning":break; +case "autoFocus":case "multiple":case "muted":ac(a,b.toLowerCase(),c);break;case "xlinkHref":if("function"===typeof c||"symbol"===typeof c||"boolean"===typeof c)break;a.push(" ","xlink:href",'="',C(""+c),'"');break;case "contentEditable":case "spellCheck":case "draggable":case "value":case "autoReverse":case "externalResourcesRequired":case "focusable":case "preserveAlpha":"function"!==typeof c&&"symbol"!==typeof c&&a.push(" ",b,'="',C(c),'"');break;case "allowFullScreen":case "async":case "autoPlay":case "controls":case "default":case "defer":case "disabled":case "disablePictureInPicture":case "disableRemotePlayback":case "formNoValidate":case "hidden":case "loop":case "noModule":case "noValidate":case "open":case "playsInline":case "readOnly":case "required":case "reversed":case "scoped":case "seamless":case "itemScope":c&& "function"!==typeof c&&"symbol"!==typeof c&&a.push(" ",b,'=""');break;case "capture":case "download":!0===c?a.push(" ",b,'=""'):!1!==c&&"function"!==typeof c&&"symbol"!==typeof c&&a.push(" ",b,'="',C(c),'"');break;case "cols":case "rows":case "size":case "span":"function"!==typeof c&&"symbol"!==typeof c&&!isNaN(c)&&1<=c&&a.push(" ",b,'="',C(c),'"');break;case "rowSpan":case "start":"function"===typeof c||"symbol"===typeof c||isNaN(c)||a.push(" ",b,'="',C(c),'"');break;case "xlinkActuate":K(a,"xlink:actuate", -c);break;case "xlinkArcrole":K(a,"xlink:arcrole",c);break;case "xlinkRole":K(a,"xlink:role",c);break;case "xlinkShow":K(a,"xlink:show",c);break;case "xlinkTitle":K(a,"xlink:title",c);break;case "xlinkType":K(a,"xlink:type",c);break;case "xmlBase":K(a,"xml:base",c);break;case "xmlLang":K(a,"xml:lang",c);break;case "xmlSpace":K(a,"xml:space",c);break;default:if(!(2"))} -function P(a,b){a.push(Q("link"));for(var c in b)if(A.call(b,c)){var d=b[c];if(null!=d)switch(c){case "children":case "dangerouslySetInnerHTML":throw Error(q(399,"link"));default:L(a,c,d)}}a.push("/>");return null}function Nb(a,b,c){a.push(Q(c));for(var d in b)if(A.call(b,d)){var e=b[d];if(null!=e)switch(d){case "children":case "dangerouslySetInnerHTML":throw Error(q(399,c));default:L(a,d,e)}}a.push("/>");return null} -function Ob(a,b){a.push(Q("title"));var c=null,d=null,e;for(e in b)if(A.call(b,e)){var f=b[e];if(null!=f)switch(e){case "children":c=f;break;case "dangerouslySetInnerHTML":d=f;break;default:L(a,e,f)}}a.push(">");b=Array.isArray(c)?2>c.length?c[0]:null:c;"function"!==typeof b&&"symbol"!==typeof b&&null!==b&&void 0!==b&&a.push(C(""+b));M(a,d,c);a.push(Pb("title"));return null} -function Qb(a,b){a.push(Q("script"));var c=null,d=null,e;for(e in b)if(A.call(b,e)){var f=b[e];if(null!=f)switch(e){case "children":c=f;break;case "dangerouslySetInnerHTML":d=f;break;default:L(a,e,f)}}a.push(">");M(a,d,c);"string"===typeof c&&a.push(C(c));a.push(Pb("script"));return null} -function Rb(a,b,c){a.push(Q(c));var d=c=null,e;for(e in b)if(A.call(b,e)){var f=b[e];if(null!=f)switch(e){case "children":c=f;break;case "dangerouslySetInnerHTML":d=f;break;default:L(a,e,f)}}a.push(">");M(a,d,c);return"string"===typeof c?(a.push(C(c)),null):c}var Sb=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Tb=new Map;function Q(a){var b=Tb.get(a);if(void 0===b){if(!Sb.test(a))throw Error(q(65,a));b="<"+a;Tb.set(a,b)}return b} -function Ub(a,b,c,d,e,f,g,h,k){switch(b){case "div":case "span":case "svg":case "path":break;case "a":a.push(Q("a"));var m=null,n=null,l;for(l in c)if(A.call(c,l)){var t=c[l];if(null!=t)switch(l){case "children":m=t;break;case "dangerouslySetInnerHTML":n=t;break;case "href":""===t?K(a,"href",""):L(a,l,t);break;default:L(a,l,t)}}a.push(">");M(a,n,m);if("string"===typeof m){a.push(C(m));var r=null}else r=m;return r;case "g":case "p":case "li":break;case "select":a.push(Q("select"));var D=null,w=null, +c);break;case "xlinkArcrole":K(a,"xlink:arcrole",c);break;case "xlinkRole":K(a,"xlink:role",c);break;case "xlinkShow":K(a,"xlink:show",c);break;case "xlinkTitle":K(a,"xlink:title",c);break;case "xlinkType":K(a,"xlink:type",c);break;case "xmlBase":K(a,"xml:base",c);break;case "xmlLang":K(a,"xml:lang",c);break;case "xmlSpace":K(a,"xml:space",c);break;default:if(!(2"))} +function P(a,b){a.push(Q("link"));for(var c in b)if(A.call(b,c)){var d=b[c];if(null!=d)switch(c){case "children":case "dangerouslySetInnerHTML":throw Error(q(399,"link"));default:L(a,c,d)}}a.push("/>");return null}function sc(a,b,c){a.push(Q(c));for(var d in b)if(A.call(b,d)){var e=b[d];if(null!=e)switch(d){case "children":case "dangerouslySetInnerHTML":throw Error(q(399,c));default:L(a,d,e)}}a.push("/>");return null} +function tc(a,b){a.push(Q("title"));var c=null,d=null,e;for(e in b)if(A.call(b,e)){var f=b[e];if(null!=f)switch(e){case "children":c=f;break;case "dangerouslySetInnerHTML":d=f;break;default:L(a,e,f)}}a.push(">");b=Array.isArray(c)?2>c.length?c[0]:null:c;"function"!==typeof b&&"symbol"!==typeof b&&null!==b&&void 0!==b&&a.push(C(""+b));M(a,d,c);a.push(uc("title"));return null} +function vc(a,b){a.push(Q("script"));var c=null,d=null,e;for(e in b)if(A.call(b,e)){var f=b[e];if(null!=f)switch(e){case "children":c=f;break;case "dangerouslySetInnerHTML":d=f;break;default:L(a,e,f)}}a.push(">");M(a,d,c);"string"===typeof c&&a.push(C(c));a.push(uc("script"));return null} +function wc(a,b,c){a.push(Q(c));var d=c=null,e;for(e in b)if(A.call(b,e)){var f=b[e];if(null!=f)switch(e){case "children":c=f;break;case "dangerouslySetInnerHTML":d=f;break;default:L(a,e,f)}}a.push(">");M(a,d,c);return"string"===typeof c?(a.push(C(c)),null):c}var xc=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,yc=new Map;function Q(a){var b=yc.get(a);if(void 0===b){if(!xc.test(a))throw Error(q(65,a));b="<"+a;yc.set(a,b)}return b} +function zc(a,b,c,d,e,f,g,h,k){switch(b){case "div":case "span":case "svg":case "path":break;case "a":a.push(Q("a"));var m=null,n=null,l;for(l in c)if(A.call(c,l)){var t=c[l];if(null!=t)switch(l){case "children":m=t;break;case "dangerouslySetInnerHTML":n=t;break;case "href":""===t?K(a,"href",""):L(a,l,t);break;default:L(a,l,t)}}a.push(">");M(a,n,m);if("string"===typeof m){a.push(C(m));var r=null}else r=m;return r;case "g":case "p":case "li":break;case "select":a.push(Q("select"));var D=null,w=null, y;for(y in c)if(A.call(c,y)){var x=c[y];if(null!=x)switch(y){case "children":D=x;break;case "dangerouslySetInnerHTML":w=x;break;case "defaultValue":case "value":break;default:L(a,y,x)}}a.push(">");M(a,w,D);return D;case "option":var p=g.selectedValue;a.push(Q("option"));var G=null,F=null,u=null,z=null,B;for(B in c)if(A.call(c,B)){var H=c[B];if(null!=H)switch(B){case "children":G=H;break;case "selected":u=H;break;case "dangerouslySetInnerHTML":z=H;break;case "value":F=H;default:L(a,B,H)}}if(null!= -p){var rb=null!==F?""+F:Mb(G);if(Ea(p))for(var sa=0;sa");M(a,z,G);return G;case "textarea":a.push(Q("textarea"));var R=null,ca=null,T=null,ta;for(ta in c)if(A.call(c,ta)){var ua=c[ta];if(null!=ua)switch(ta){case "children":T=ua;break;case "value":R=ua;break;case "defaultValue":ca=ua;break;case "dangerouslySetInnerHTML":throw Error(q(91));default:L(a,ta,ua)}}null=== -R&&null!==ca&&(R=ca);a.push(">");if(null!=T){if(null!=R)throw Error(q(92));if(Ea(T)){if(1");null!==bd&&bd.forEach(Jb,a);return null;case "button":a.push(Q("button"));var Ra=null,cd=null,dd=null,ed=null,fd=null, -gd=null,hd=null,Sa;for(Sa in c)if(A.call(c,Sa)){var da=c[Sa];if(null!=da)switch(Sa){case "children":Ra=da;break;case "dangerouslySetInnerHTML":cd=da;break;case "name":dd=da;break;case "formAction":ed=da;break;case "formEncType":fd=da;break;case "formMethod":gd=da;break;case "formTarget":hd=da;break;default:L(a,Sa,da)}}var id=Kb(a,d,e,ed,fd,gd,hd,dd);a.push(">");null!==id&&id.forEach(Jb,a);M(a,cd,Ra);if("string"===typeof Ra){a.push(C(Ra));var jd=null}else jd=Ra;return jd;case "form":a.push(Q("form")); -var Ta=null,kd=null,ma=null,Ua=null,Va=null,Wa=null,Xa;for(Xa in c)if(A.call(c,Xa)){var na=c[Xa];if(null!=na)switch(Xa){case "children":Ta=na;break;case "dangerouslySetInnerHTML":kd=na;break;case "action":ma=na;break;case "encType":Ua=na;break;case "method":Va=na;break;case "target":Wa=na;break;default:L(a,Xa,na)}}var dc=null,ec=null;if("function"===typeof ma)if("function"===typeof ma.$$FORM_ACTION){var Ue=qb(d),Fa=ma.$$FORM_ACTION(Ue);ma=Fa.action||"";Ua=Fa.encType;Va=Fa.method;Wa=Fa.target;dc=Fa.data; -ec=Fa.name}else a.push(" ","action",'="',Ib,'"'),Wa=Va=Ua=ma=null,Lb(d,e);null!=ma&&L(a,"action",ma);null!=Ua&&L(a,"encType",Ua);null!=Va&&L(a,"method",Va);null!=Wa&&L(a,"target",Wa);a.push(">");null!==ec&&(a.push('"),null!==dc&&dc.forEach(Jb,a));M(a,kd,Ta);if("string"===typeof Ta){a.push(C(Ta));var ld=null}else ld=Ta;return ld;case "menuitem":a.push(Q("menuitem"));for(var xb in c)if(A.call(c,xb)){var md=c[xb];if(null!=md)switch(xb){case "children":case "dangerouslySetInnerHTML":throw Error(q(400)); -default:L(a,xb,md)}}a.push(">");return null;case "title":if(3===g.insertionMode||g.tagScope&1||null!=c.itemProp)var fc=Ob(a,c);else k?fc=null:(Ob(e.hoistableChunks,c),fc=void 0);return fc;case "link":var Ve=c.rel,oa=c.href,yb=c.precedence;if(3===g.insertionMode||g.tagScope&1||null!=c.itemProp||"string"!==typeof Ve||"string"!==typeof oa||""===oa){P(a,c);var Ya=null}else if("stylesheet"===c.rel)if("string"!==typeof yb||null!=c.disabled||c.onLoad||c.onError)Ya=P(a,c);else{var Ga=e.styles.get(yb),zb= -d.styleResources.hasOwnProperty(oa)?d.styleResources[oa]:void 0;if(null!==zb){d.styleResources[oa]=null;Ga||(Ga={precedence:C(yb),rules:[],hrefs:[],sheets:new Map},e.styles.set(yb,Ga));var Ab={state:0,props:v({},c,{"data-precedence":c.precedence,precedence:null})};if(zb){2===zb.length&&Vb(Ab.props,zb);var gc=e.preloads.stylesheets.get(oa);gc&&0");var ab=Array.isArray(Ha)?2>Ha.length?Ha[0]:null:Ha;"function"!==typeof ab&&"symbol"!==typeof ab&&null!==ab&&void 0!==ab&&a.push(C(""+ab));M(a,sd,Ha);a.push(Pb("style"));var td=null}else{var xa=e.styles.get(Eb);if(null!==(d.styleResources.hasOwnProperty(wa)?d.styleResources[wa]:void 0)){d.styleResources[wa]=null;xa?xa.hrefs.push(C(wa)):(xa={precedence:C(Eb),rules:[],hrefs:[C(wa)],sheets:new Map},e.styles.set(Eb,xa));var ud=xa.rules,Ia=null,vd=null,Gb;for(Gb in c)if(A.call(c, -Gb)){var jc=c[Gb];if(null!=jc)switch(Gb){case "children":Ia=jc;break;case "dangerouslySetInnerHTML":vd=jc}}var bb=Array.isArray(Ia)?2>Ia.length?Ia[0]:null:Ia;"function"!==typeof bb&&"symbol"!==typeof bb&&null!==bb&&void 0!==bb&&ud.push(C(""+bb));M(ud,vd,Ia)}xa&&f&&f.styles.add(xa);h&&a.push("\x3c!-- --\x3e");td=void 0}return td;case "meta":if(3===g.insertionMode||g.tagScope&1||null!=c.itemProp)var wd=Nb(a,c,"meta");else h&&a.push("\x3c!-- --\x3e"),wd=k?null:"string"===typeof c.charSet?Nb(e.charsetChunks, -c,"meta"):"viewport"===c.name?Nb(e.viewportChunks,c,"meta"):Nb(e.hoistableChunks,c,"meta");return wd;case "listing":case "pre":a.push(Q(b));var cb=null,db=null,eb;for(eb in c)if(A.call(c,eb)){var Hb=c[eb];if(null!=Hb)switch(eb){case "children":cb=Hb;break;case "dangerouslySetInnerHTML":db=Hb;break;default:L(a,eb,Hb)}}a.push(">");if(null!=db){if(null!=cb)throw Error(q(60));if("object"!==typeof db||!("__html"in db))throw Error(q(61));var ya=db.__html;null!==ya&&void 0!==ya&&("string"===typeof ya&&0< +p){var sb=null!==F?""+F:rc(G);if(ib(p))for(var sa=0;sa");M(a,z,G);return G;case "textarea":a.push(Q("textarea"));var R=null,da=null,T=null,ta;for(ta in c)if(A.call(c,ta)){var ua=c[ta];if(null!=ua)switch(ta){case "children":T=ua;break;case "value":R=ua;break;case "defaultValue":da=ua;break;case "dangerouslySetInnerHTML":throw Error(q(91));default:L(a,ta,ua)}}null=== +R&&null!==da&&(R=da);a.push(">");if(null!=T){if(null!=R)throw Error(q(92));if(ib(T)){if(1");null!==kd&&kd.forEach(dc,a);return null;case "button":a.push(Q("button"));var Ra=null,ld=null,md=null,nd=null,od=null, +pd=null,qd=null,Sa;for(Sa in c)if(A.call(c,Sa)){var ea=c[Sa];if(null!=ea)switch(Sa){case "children":Ra=ea;break;case "dangerouslySetInnerHTML":ld=ea;break;case "name":md=ea;break;case "formAction":nd=ea;break;case "formEncType":od=ea;break;case "formMethod":pd=ea;break;case "formTarget":qd=ea;break;default:L(a,Sa,ea)}}var rd=ec(a,d,e,nd,od,pd,qd,md);a.push(">");null!==rd&&rd.forEach(dc,a);M(a,ld,Ra);if("string"===typeof Ra){a.push(C(Ra));var sd=null}else sd=Ra;return sd;case "form":a.push(Q("form")); +var Ta=null,td=null,ma=null,Ua=null,Va=null,Wa=null,Xa;for(Xa in c)if(A.call(c,Xa)){var na=c[Xa];if(null!=na)switch(Xa){case "children":Ta=na;break;case "dangerouslySetInnerHTML":td=na;break;case "action":ma=na;break;case "encType":Ua=na;break;case "method":Va=na;break;case "target":Wa=na;break;default:L(a,Xa,na)}}var fc=null,gc=null;if("function"===typeof ma)if("function"===typeof ma.$$FORM_ACTION){var bf=bc(d),Fa=ma.$$FORM_ACTION(bf);ma=Fa.action||"";Ua=Fa.encType;Va=Fa.method;Wa=Fa.target;fc=Fa.data; +gc=Fa.name}else a.push(" ","action",'="',cc,'"'),Wa=Va=Ua=ma=null,qc(d,e);null!=ma&&L(a,"action",ma);null!=Ua&&L(a,"encType",Ua);null!=Va&&L(a,"method",Va);null!=Wa&&L(a,"target",Wa);a.push(">");null!==gc&&(a.push('"),null!==fc&&fc.forEach(dc,a));M(a,td,Ta);if("string"===typeof Ta){a.push(C(Ta));var ud=null}else ud=Ta;return ud;case "menuitem":a.push(Q("menuitem"));for(var yb in c)if(A.call(c,yb)){var vd=c[yb];if(null!=vd)switch(yb){case "children":case "dangerouslySetInnerHTML":throw Error(q(400)); +default:L(a,yb,vd)}}a.push(">");return null;case "title":if(3===g.insertionMode||g.tagScope&1||null!=c.itemProp)var hc=tc(a,c);else k?hc=null:(tc(e.hoistableChunks,c),hc=void 0);return hc;case "link":var cf=c.rel,oa=c.href,zb=c.precedence;if(3===g.insertionMode||g.tagScope&1||null!=c.itemProp||"string"!==typeof cf||"string"!==typeof oa||""===oa){P(a,c);var Ya=null}else if("stylesheet"===c.rel)if("string"!==typeof zb||null!=c.disabled||c.onLoad||c.onError)Ya=P(a,c);else{var Ga=e.styles.get(zb),Ab= +d.styleResources.hasOwnProperty(oa)?d.styleResources[oa]:void 0;if(null!==Ab){d.styleResources[oa]=null;Ga||(Ga={precedence:C(zb),rules:[],hrefs:[],sheets:new Map},e.styles.set(zb,Ga));var Bb={state:0,props:v({},c,{"data-precedence":c.precedence,precedence:null})};if(Ab){2===Ab.length&&Ac(Bb.props,Ab);var ic=e.preloads.stylesheets.get(oa);ic&&0");var ab=Array.isArray(Ha)?2>Ha.length?Ha[0]:null:Ha;"function"!==typeof ab&&"symbol"!==typeof ab&&null!==ab&&void 0!==ab&&a.push(C(""+ab));M(a,Bd,Ha);a.push(uc("style"));var Cd=null}else{var xa=e.styles.get(Fb);if(null!==(d.styleResources.hasOwnProperty(wa)?d.styleResources[wa]:void 0)){d.styleResources[wa]=null;xa?xa.hrefs.push(C(wa)):(xa={precedence:C(Fb),rules:[],hrefs:[C(wa)],sheets:new Map},e.styles.set(Fb,xa));var Dd=xa.rules,Ia=null,Ed=null,Hb;for(Hb in c)if(A.call(c, +Hb)){var lc=c[Hb];if(null!=lc)switch(Hb){case "children":Ia=lc;break;case "dangerouslySetInnerHTML":Ed=lc}}var bb=Array.isArray(Ia)?2>Ia.length?Ia[0]:null:Ia;"function"!==typeof bb&&"symbol"!==typeof bb&&null!==bb&&void 0!==bb&&Dd.push(C(""+bb));M(Dd,Ed,Ia)}xa&&f&&f.styles.add(xa);h&&a.push("\x3c!-- --\x3e");Cd=void 0}return Cd;case "meta":if(3===g.insertionMode||g.tagScope&1||null!=c.itemProp)var Fd=sc(a,c,"meta");else h&&a.push("\x3c!-- --\x3e"),Fd=k?null:"string"===typeof c.charSet?sc(e.charsetChunks, +c,"meta"):"viewport"===c.name?sc(e.viewportChunks,c,"meta"):sc(e.hoistableChunks,c,"meta");return Fd;case "listing":case "pre":a.push(Q(b));var cb=null,db=null,eb;for(eb in c)if(A.call(c,eb)){var Ib=c[eb];if(null!=Ib)switch(eb){case "children":cb=Ib;break;case "dangerouslySetInnerHTML":db=Ib;break;default:L(a,eb,Ib)}}a.push(">");if(null!=db){if(null!=cb)throw Error(q(60));if("object"!==typeof db||!("__html"in db))throw Error(q(61));var ya=db.__html;null!==ya&&void 0!==ya&&("string"===typeof ya&&0< ya.length&&"\n"===ya[0]?a.push("\n",ya):a.push(""+ya))}"string"===typeof cb&&"\n"===cb[0]&&a.push("\n");return cb;case "img":var O=c.src,J=c.srcSet;if(!("lazy"===c.loading||!O&&!J||"string"!==typeof O&&null!=O||"string"!==typeof J&&null!=J)&&"low"!==c.fetchPriority&&!1===!!(g.tagScope&2)&&("string"!==typeof O||":"!==O[4]||"d"!==O[0]&&"D"!==O[0]||"a"!==O[1]&&"A"!==O[1]||"t"!==O[2]&&"T"!==O[2]||"a"!==O[3]&&"A"!==O[3])&&("string"!==typeof J||":"!==J[4]||"d"!==J[0]&&"D"!==J[0]||"a"!==J[1]&&"A"!==J[1]|| -"t"!==J[2]&&"T"!==J[2]||"a"!==J[3]&&"A"!==J[3])){var xd="string"===typeof c.sizes?c.sizes:void 0,Ja=J?J+"\n"+(xd||""):O,kc=e.preloads.images,za=kc.get(Ja);if(za){if("high"===c.fetchPriority||10>e.highImagePreloads.size)kc.delete(Ja),e.highImagePreloads.add(za)}else if(!d.imageResources.hasOwnProperty(Ja)){d.imageResources[Ja]=E;var lc=c.crossOrigin;var yd="string"===typeof lc?"use-credentials"===lc?lc:"":void 0;var aa=e.headers,mc;aa&&0aa.highImagePreloads.length)&& -(mc=Wb(O,"image",{imageSrcSet:c.srcSet,imageSizes:c.sizes,crossOrigin:yd,integrity:c.integrity,nonce:c.nonce,type:c.type,fetchPriority:c.fetchPriority,referrerPolicy:c.refererPolicy}),2<=(aa.remainingCapacity-=mc.length))?(e.resets.image[Ja]=E,aa.highImagePreloads&&(aa.highImagePreloads+=", "),aa.highImagePreloads+=mc):(za=[],P(za,{rel:"preload",as:"image",href:J?void 0:O,imageSrcSet:J,imageSizes:xd,crossOrigin:yd,integrity:c.integrity,type:c.type,fetchPriority:c.fetchPriority,referrerPolicy:c.referrerPolicy}), -"high"===c.fetchPriority||10>e.highImagePreloads.size?e.highImagePreloads.add(za):(e.bulkPreloads.add(za),kc.set(Ja,za)))}}return Nb(a,c,"img");case "base":case "area":case "br":case "col":case "embed":case "hr":case "keygen":case "param":case "source":case "track":case "wbr":return Nb(a,c,b);case "annotation-xml":case "color-profile":case "font-face":case "font-face-src":case "font-face-uri":case "font-face-format":case "font-face-name":case "missing-glyph":break;case "head":if(2>g.insertionMode&& -null===e.headChunks){e.headChunks=[];var zd=Rb(e.headChunks,c,"head")}else zd=Rb(a,c,"head");return zd;case "html":if(0===g.insertionMode&&null===e.htmlChunks){e.htmlChunks=[""];var Ad=Rb(e.htmlChunks,c,"html")}else Ad=Rb(a,c,"html");return Ad;default:if(-1!==b.indexOf("-")){a.push(Q(b));var nc=null,Bd=null,Ka;for(Ka in c)if(A.call(c,Ka)){var X=c[Ka];if(null!=X){var Cd=Ka;switch(Ka){case "children":nc=X;break;case "dangerouslySetInnerHTML":Bd=X;break;case "style":ob(a,X);break;case "suppressContentEditableWarning":case "suppressHydrationWarning":break; -case "className":Cd="class";default:if(qa(Ka)&&"function"!==typeof X&&"symbol"!==typeof X&&!1!==X){if(!0===X)X="";else if("object"===typeof X)continue;a.push(" ",Cd,'="',C(X),'"')}}}}a.push(">");M(a,Bd,nc);return nc}}return Rb(a,c,b)}var Xb=new Map;function Pb(a){var b=Xb.get(a);void 0===b&&(b="",Xb.set(a,b));return b}function Yb(a,b){b=b.bootstrapChunks;for(var c=0;c')} -function $b(a,b,c,d){switch(c.insertionMode){case 0:case 1:case 2:return a.push('