diff --git a/package.json b/package.json
index 7348d1e07c10bb..8a0fd4f57ede5c 100644
--- a/package.json
+++ b/package.json
@@ -197,16 +197,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-60a927d04-20240113",
+ "react-builtin": "npm:react@18.3.0-canary-14898b6a9-20240318",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
- "react-dom-builtin": "npm:react-dom@18.3.0-canary-60a927d04-20240113",
- "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-60a927d04-20240113",
- "react-experimental-builtin": "npm:react@0.0.0-experimental-60a927d04-20240113",
- "react-server-dom-turbopack": "18.3.0-canary-60a927d04-20240113",
- "react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-60a927d04-20240113",
- "react-server-dom-webpack": "18.3.0-canary-60a927d04-20240113",
- "react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-60a927d04-20240113",
+ "react-dom-builtin": "npm:react-dom@18.3.0-canary-14898b6a9-20240318",
+ "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-14898b6a9-20240318",
+ "react-experimental-builtin": "npm:react@0.0.0-experimental-14898b6a9-20240318",
+ "react-server-dom-turbopack": "18.3.0-canary-14898b6a9-20240318",
+ "react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-14898b6a9-20240318",
+ "react-server-dom-webpack": "18.3.0-canary-14898b6a9-20240318",
+ "react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-14898b6a9-20240318",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
@@ -216,8 +216,8 @@
"resolve-from": "5.0.0",
"sass": "1.54.0",
"satori": "0.10.9",
- "scheduler-builtin": "npm:scheduler@0.24.0-canary-60a927d04-20240113",
- "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-60a927d04-20240113",
+ "scheduler-builtin": "npm:scheduler@0.24.0-canary-14898b6a9-20240318",
+ "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-14898b6a9-20240318",
"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 f37efea75879fc..bd07a7b8066b73 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-60a927d04-20240113';
+var ReactVersion = '18.3.0-experimental-14898b6a9-20240318';
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
@@ -74,6 +74,326 @@ function printWarning(level, format, args) {
}
}
+// 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 += '' + describeElementType(type) + '>';
+ } 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
@@ -186,9 +506,6 @@ function stringToChunk(content) {
function stringToPrecomputedChunk(content) {
return content;
}
-function clonePrecomputedChunk(chunk) {
- return chunk;
-}
function closeWithError(destination, error) {
// $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types.
destination.destroy(error);
@@ -1190,6 +1507,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
case 'defaultChecked':
case 'innerHTML':
+ case 'ref':
{
return true;
}
@@ -1607,19 +1925,13 @@ 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())};';
var completeBoundary = '$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};';
var completeBoundaryWithStyles = '$RM=new Map;\n$RR=function(r,t,w){for(var u=$RC,n=$RM,p=new Map,q=document,g,b,h=q.querySelectorAll("link[data-precedence],style[data-precedence]"),v=[],k=0;b=h[k++];)"not all"===b.getAttribute("media")?v.push(b):("LINK"===b.tagName&&n.set(b.getAttribute("href"),b),p.set(b.dataset.precedence,g=b));b=0;h=[];var l,a;for(k=!0;;){if(k){var f=w[b++];if(!f){k=!1;b=0;continue}var c=!1,m=0;var d=f[m++];if(a=n.get(d)){var e=a._p;c=!0}else{a=q.createElement("link");a.href=d;a.rel="stylesheet";for(a.dataset.precedence=\nl=f[m++];e=f[m++];)a.setAttribute(e,f[m++]);e=a._p=new Promise(function(x,y){a.onload=x;a.onerror=y});n.set(d,a)}d=a.getAttribute("media");!e||"l"===e.s||d&&!matchMedia(d).matches||h.push(e);if(c)continue}else{a=v[b++];if(!a)break;l=a.getAttribute("data-precedence");a.removeAttribute("media")}c=p.get(l)||g;c===g&&(g=a);p.set(l,a);c?c.parentNode.insertBefore(a,c.nextSibling):(c=q.head,c.insertBefore(a,c.firstChild))}Promise.all(h).then(u.bind(null,r,t,""),u.bind(null,r,t,"Resource failed to load"))};';
var completeSegment = '$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};';
-var formReplaying = 'addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error(\'A React form was unexpectedly submitted.\')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.getRootNode(),(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,\nd,b))}});';
+var formReplaying = 'addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error(\'React form unexpectedly submitted.\')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});';
function getValueDescriptorExpectingObjectForWarning(thing) {
return thing === null ? '`null`' : thing === undefined ? '`undefined`' : thing === '' ? 'an empty string' : "something with type \"" + typeof thing + "\"";
@@ -1814,6 +2126,7 @@ function createRenderState$1(resumableState, nonce, externalRuntimeConfig, impor
headChunks: null,
externalRuntimeScript: externalRuntimeScript,
bootstrapChunks: bootstrapChunks,
+ importMapChunks: importMapChunks,
onHeaders: onHeaders,
headers: headers,
resets: {
@@ -1828,9 +2141,7 @@ function createRenderState$1(resumableState, nonce, externalRuntimeConfig, impor
style: {}
},
charsetChunks: [],
- preconnectChunks: [],
- importMapChunks: importMapChunks,
- preloadChunks: [],
+ viewportChunks: [],
hoistableChunks: [],
// cleared on flush
preconnects: new Set(),
@@ -1849,7 +2160,7 @@ function createRenderState$1(resumableState, nonce, externalRuntimeConfig, impor
},
nonce: nonce,
// like a module global for currently rendering boundary
- boundaryResources: null,
+ hoistableState: null,
stylesToHoist: false
};
@@ -2227,7 +2538,7 @@ function makeFormFieldPrefix(resumableState) {
var actionJavaScriptURL = stringToPrecomputedChunk(escapeTextForBrowser( // eslint-disable-next-line no-script-url
-"javascript:throw new Error('A React form was unexpectedly submitted.')"));
+"javascript:throw new Error('React form unexpectedly submitted.')"));
var startHiddenInputChunk = stringToPrecomputedChunk('= 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.
- var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled ""
- // but we have a user-provided "displayName"
- // splice it in to make the stack more readable.
-
-
- if (fn.displayName && _frame.includes('')) {
- _frame = _frame.replace('', fn.displayName);
- }
-
- if (true) {
- if (typeof fn === 'function') {
- componentFrameCache.set(fn, _frame);
- }
- } // Return the line we found.
-
-
- return _frame;
- }
- } while (s >= 1 && c >= 0);
- }
-
- break;
- }
- }
- }
- } 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) : '';
-
- {
- if (typeof fn === 'function') {
- componentFrameCache.set(fn, syntheticFrame);
- }
- }
-
- return syntheticFrame;
-}
-
-function describeClassComponentFrame(ctor, source, ownerFn) {
- {
- return describeNativeComponentFrame(ctor, true);
- }
-}
-function describeFunctionComponentFrame(fn, source, ownerFn) {
- {
- return describeNativeComponentFrame(fn, false);
- }
-}
-
-function shouldConstruct$1(Component) {
- var prototype = Component.prototype;
- return !!(prototype && prototype.isReactComponent);
-}
-
-function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
-
- if (type == null) {
- return '';
- }
-
- if (typeof type === 'function') {
- {
- return describeNativeComponentFrame(type, shouldConstruct$1(type));
- }
- }
-
- if (typeof type === 'string') {
- return describeBuiltInComponentFrame(type);
- }
-
- switch (type) {
- case REACT_SUSPENSE_TYPE:
- return describeBuiltInComponentFrame('Suspense');
-
- case REACT_SUSPENSE_LIST_TYPE:
- return describeBuiltInComponentFrame('SuspenseList');
- }
-
- 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, source, ownerFn);
-
- 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 describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
- } catch (x) {}
- }
- }
- }
-
- return '';
-}
-
-var loggedTypeFailures = {};
-var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
-
-function setCurrentlyValidatingElement(element) {
- {
- if (element) {
- var owner = element._owner;
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
- } else {
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
- }
- }
-}
-
-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;
- }
-
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
- } catch (ex) {
- error$1 = ex;
- }
-
- 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);
-
- setCurrentlyValidatingElement(null);
- }
-
- 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);
-
- error('Failed %s type: %s', location, error$1.message);
-
- setCurrentlyValidatingElement(null);
- }
- }
- }
- }
-}
-
-var warnedAboutMissingGetChildContext;
-
-{
- warnedAboutMissingGetChildContext = {};
-}
-
-var emptyContextObject = {};
-
-{
- Object.freeze(emptyContextObject);
-}
-
-function getMaskedContext(type, unmaskedContext) {
- {
- var contextTypes = type.contextTypes;
-
- if (!contextTypes) {
- return emptyContextObject;
- }
-
- var context = {};
-
- for (var key in contextTypes) {
- context[key] = unmaskedContext[key];
- }
-
- {
- var name = getComponentNameFromType(type) || 'Unknown';
- checkPropTypes(contextTypes, context, 'context', 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 (!warnedAboutMissingGetChildContext[componentName]) {
- warnedAboutMissingGetChildContext[componentName] = true;
-
- 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;
- }
-
- 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.");
- }
- }
-
- {
- var name = getComponentNameFromType(type) || 'Unknown';
- checkPropTypes(childContextTypes, childContext, 'child context', name);
- }
-
- return assign({}, parentContext, childContext);
- }
-}
-
-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.
-
-
-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;
- }
-}
-
-function pushNode(next) {
- {
- next.context._currentValue2 = next.value;
- }
-}
-
-function popToNearestCommonAncestor(prev, next) {
- if (prev === next) ; else {
- popNode(prev);
- var parentPrev = prev.parent;
- var parentNext = next.parent;
-
- 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.');
- }
+ 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.');
+ }
popToNearestCommonAncestor(parentPrev, parentNext);
} // On the way back, we push the new ones that weren't common.
@@ -7516,12 +7345,7 @@ function popProvider(context) {
{
var _value = prevSnapshot.parentValue;
-
- if (_value === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED) {
- prevSnapshot.context._currentValue2 = prevSnapshot.context._defaultValue;
- } else {
- prevSnapshot.context._currentValue2 = _value;
- }
+ prevSnapshot.context._currentValue2 = _value;
{
if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) {
@@ -7580,18 +7404,19 @@ var didWarnOnInvalidCallback;
didWarnOnInvalidCallback = new Set();
}
-function warnOnInvalidCallback(callback, callerName) {
+function warnOnInvalidCallback(callback) {
{
if (callback === null || typeof callback === 'function') {
return;
- }
+ } // eslint-disable-next-line react-internal/safe-string-coercion
+
- var key = callerName + '_' + callback;
+ var key = String(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);
+ error('Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback);
}
}
}
@@ -7620,7 +7445,7 @@ function warnNoop(publicInstance, callerName) {
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);
+ error('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, componentName);
didWarnAboutNoopUpdateForComponent[warningKey] = true;
}
@@ -7641,7 +7466,7 @@ var classComponentUpdater = {
{
if (callback !== undefined && callback !== null) {
- warnOnInvalidCallback(callback, 'setState');
+ warnOnInvalidCallback(callback);
}
}
}
@@ -7653,7 +7478,7 @@ var classComponentUpdater = {
{
if (callback !== undefined && callback !== null) {
- warnOnInvalidCallback(callback, 'setState');
+ warnOnInvalidCallback(callback);
}
}
},
@@ -7666,7 +7491,7 @@ var classComponentUpdater = {
} else {
{
if (callback !== undefined && callback !== null) {
- warnOnInvalidCallback(callback, 'setState');
+ warnOnInvalidCallback(callback);
}
}
}
@@ -7692,7 +7517,7 @@ function constructClassInstance(ctor, props, maskedLegacyContext) {
{
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
+ contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE;
if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
didWarnAboutInvalidateContextType.add(ctor);
@@ -7702,10 +7527,7 @@ function constructClassInstance(ctor, props, maskedLegacyContext) {
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) {
- //
+ } 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(', ') + '}.';
@@ -7785,9 +7607,9 @@ function checkClassInstance(instance, ctor, newProps) {
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);
+ error('No `render` method found on the %s ' + '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);
+ error('No `render` method found on the %s ' + 'instance: you may have forgotten to define `render`.', name);
}
}
@@ -7846,7 +7668,7 @@ function checkClassInstance(instance, ctor, newProps) {
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);
+ error('When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name);
}
if (instance.defaultProps) {
@@ -8603,377 +8425,749 @@ function useMemo(nextCreate, deps) {
if (nextDeps !== null) {
var prevDeps = prevState[1];
- if (areHookInputsEqual(nextDeps, prevDeps)) {
- return prevState[0];
- }
- }
- }
+ if (areHookInputsEqual(nextDeps, prevDeps)) {
+ return prevState[0];
+ }
+ }
+ }
+ }
+
+ {
+ isInHookUserCodeInDev = true;
+ }
+
+ var nextValue = nextCreate();
+
+ {
+ isInHookUserCodeInDev = false;
+ } // $FlowFixMe[incompatible-use] found when upgrading Flow
+
+
+ workInProgressHook.memoizedState = [nextValue, nextDeps];
+ return nextValue;
+}
+
+function useRef(initialValue) {
+ currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
+ workInProgressHook = createWorkInProgressHook();
+ var previousRef = workInProgressHook.memoizedState;
+
+ if (previousRef === null) {
+ var ref = {
+ current: initialValue
+ };
+
+ {
+ Object.seal(ref);
+ } // $FlowFixMe[incompatible-use] found when upgrading Flow
+
+
+ workInProgressHook.memoizedState = ref;
+ return ref;
+ } else {
+ return previousRef;
+ }
+}
+
+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.');
+ }
+
+ 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();
+ }
+
+ var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
+
+ 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;
+
+ while (lastRenderPhaseUpdate.next !== null) {
+ lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
+ }
+
+ lastRenderPhaseUpdate.next = update;
+ }
+ }
+}
+
+function useCallback(callback, deps) {
+ return useMemo(function () {
+ return callback;
+ }, deps);
+}
+
+function throwOnUseEffectEventCall() {
+ throw new Error("A function wrapped in useEffectEvent can't be called during rendering.");
+}
+
+function useEffectEvent(callback) {
+ // $FlowIgnore[incompatible-return]
+ return throwOnUseEffectEventCall;
+}
+
+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.');
+ }
+
+ return getServerSnapshot();
+}
+
+function useDeferredValue(value, initialValue) {
+ resolveCurrentlyRenderingComponent();
+
+ {
+ return initialValue !== undefined ? initialValue : value;
+ }
+}
+
+function unsupportedStartTransition() {
+ throw new Error('startTransition cannot be called during server rendering.');
+}
+
+function useTransition() {
+ resolveCurrentlyRenderingComponent();
+ return [false, unsupportedStartTransition];
+}
+
+function useHostTransitionStatus() {
+ resolveCurrentlyRenderingComponent();
+ return NotPendingTransition;
+}
+
+function unsupportedSetOptimisticState() {
+ throw new Error('Cannot update optimistic state while rendering.');
+}
+
+function useOptimistic(passthrough, reducer) {
+ resolveCurrentlyRenderingComponent();
+ return [passthrough, unsupportedSetOptimisticState];
+}
+
+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 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 formAction = action.$$FORM_ACTION;
+
+ 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 state = initialState;
+ var componentKeyPath = currentlyRenderingKeyPath;
+ var postbackFormState = getFormState(request); // $FlowIgnore[prop-missing]
+
+ var isSignatureEqual = action.$$IS_SIGNATURE_EQUAL;
+
+ if (postbackFormState !== null && typeof isSignatureEqual === 'function') {
+ var postbackKey = postbackFormState[1];
+ var postbackReferenceId = postbackFormState[2];
+ var postbackBoundArity = postbackFormState[3];
+
+ 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.
+
+ state = postbackFormState[0];
+ }
+ }
+ } // Bind the state to the first argument of the action.
+
+
+ var boundAction = action.bind(null, state); // Wrap the action so the return value is void.
+
+ var dispatch = function (payload) {
+ boundAction(payload);
+ }; // $FlowIgnore[prop-missing]
+
+
+ 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;
+
+ if (formData) {
+ if (nextPostbackStateKey === null) {
+ nextPostbackStateKey = createPostbackFormStateKey(permalink, componentKeyPath, formStateHookIndex);
+ }
+
+ formData.append('$ACTION_KEY', nextPostbackStateKey);
+ }
+
+ return metadata;
+ };
+ }
+
+ 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);
+ };
+
+ return [initialState, _dispatch2];
}
+}
- {
- isInHookUserCodeInDev = true;
+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.');
}
- var nextValue = nextCreate();
+ var localId = localIdCounter++;
+ return makeId(resumableState, treeId, localId);
+}
- {
- isInHookUserCodeInDev = false;
- } // $FlowFixMe[incompatible-use] found when upgrading Flow
+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
- workInProgressHook.memoizedState = [nextValue, nextDeps];
- return nextValue;
+ throw new Error('An unsupported type was passed to use(): ' + String(usable));
}
-function useRef(initialValue) {
- currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
- workInProgressHook = createWorkInProgressHook();
- var previousRef = workInProgressHook.memoizedState;
+function unwrapThenable(thenable) {
+ var index = thenableIndexCounter;
+ thenableIndexCounter += 1;
- if (previousRef === null) {
- var ref = {
- current: initialValue
- };
+ if (thenableState === null) {
+ thenableState = createThenableState();
+ }
- {
- Object.seal(ref);
- } // $FlowFixMe[incompatible-use] found when upgrading Flow
+ return trackUsedThenable(thenableState, thenable, index);
+}
+function unsupportedRefresh() {
+ throw new Error('Cache cannot be refreshed during server rendering.');
+}
- workInProgressHook.memoizedState = ref;
- return ref;
- } else {
- return previousRef;
- }
+function useCacheRefresh() {
+ return unsupportedRefresh;
}
-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 useMemoCache(size) {
+ var data = new Array(size);
+
+ for (var i = 0; i < size; i++) {
+ data[i] = REACT_MEMO_CACHE_SENTINEL;
}
- 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
- };
+ return data;
+}
- if (renderPhaseUpdates === null) {
- renderPhaseUpdates = new Map();
- }
+function noop$1() {}
- var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
+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 (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.useCacheRefresh = useCacheRefresh;
+}
- while (lastRenderPhaseUpdate.next !== null) {
- lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
- }
+{
+ HooksDispatcher.useEffectEvent = useEffectEvent;
+}
- lastRenderPhaseUpdate.next = update;
- }
- }
+{
+ HooksDispatcher.useMemoCache = useMemoCache;
}
-function useCallback(callback, deps) {
- return useMemo(function () {
- return callback;
- }, deps);
+{
+ HooksDispatcher.useHostTransitionStatus = useHostTransitionStatus;
}
-function throwOnUseEffectEventCall() {
- throw new Error("A function wrapped in useEffectEvent can't be called during rendering.");
+{
+ HooksDispatcher.useOptimistic = useOptimistic;
+ HooksDispatcher.useFormState = useFormState;
}
-function useEffectEvent(callback) {
- // $FlowIgnore[incompatible-return]
- return throwOnUseEffectEventCall;
+var currentResumableState = null;
+function setCurrentResumableState(resumableState) {
+ currentResumableState = resumableState;
}
-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.');
- }
+function getCacheSignal() {
+ throw new Error('Not implemented.');
+}
- return getServerSnapshot();
+function getCacheForType(resourceType) {
+ throw new Error('Not implemented.');
}
-function useDeferredValue(value, initialValue) {
- resolveCurrentlyRenderingComponent();
+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() {
{
- return initialValue !== undefined ? initialValue : value;
+ 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++;
}
}
+function reenableLogs() {
+ {
+ disabledDepth--;
-function unsupportedStartTransition() {
- throw new Error('startTransition cannot be called during server rendering.');
+ if (disabledDepth === 0) {
+ /* eslint-disable react-internal/no-production-logging */
+ var props = {
+ configurable: true,
+ enumerable: true,
+ writable: true
+ }; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
+
+ Object.defineProperties(console, {
+ log: assign({}, props, {
+ value: prevLog
+ }),
+ info: assign({}, props, {
+ value: prevInfo
+ }),
+ warn: assign({}, props, {
+ value: prevWarn
+ }),
+ error: assign({}, props, {
+ value: prevError
+ }),
+ group: assign({}, props, {
+ value: prevGroup
+ }),
+ groupCollapsed: assign({}, props, {
+ value: prevGroupCollapsed
+ }),
+ groupEnd: assign({}, props, {
+ value: prevGroupEnd
+ })
+ });
+ /* eslint-enable react-internal/no-production-logging */
+ }
+
+ 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);
- };
-
- return [initialState, _dispatch2];
- }
-}
-
-function useId() {
- var task = currentlyRenderingTask;
- var treeId = getTreeId(task.treeContext);
- var resumableState = currentResumableState;
+ RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot';
+ var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable.
- if (resumableState === null) {
- throw new Error('Invalid hook call. Hooks can only be called inside of the body of a function component.');
+ 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'
+ });
}
- var localId = localIdCounter++;
- return makeId(resumableState, treeId, localId);
-}
+ try {
+ var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(),
+ sampleStack = _RunInRootFrame$Deter[0],
+ controlStack = _RunInRootFrame$Deter[1];
-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 || usable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
- var context = usable;
- return readContext(context);
- }
- } // eslint-disable-next-line react-internal/safe-string-coercion
+ if (sampleStack && controlStack) {
+ // This extracts the first frame from the sample that isn't also in the control.
+ // Skipping one frame that we assume is the frame that calls the two.
+ var sampleLines = sampleStack.split('\n');
+ var controlLines = controlStack.split('\n');
+ var s = 0;
+ var c = 0;
+ while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) {
+ s++;
+ }
- throw new Error('An unsupported type was passed to use(): ' + String(usable));
-}
+ 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...
-function unwrapThenable(thenable) {
- var index = thenableIndexCounter;
- thenableIndexCounter += 1;
- if (thenableState === null) {
- thenableState = createThenableState();
- }
+ if (s === sampleLines.length || c === controlLines.length) {
+ s = sampleLines.length - 1;
+ c = controlLines.length - 1;
- return trackUsedThenable(thenableState, thenable, index);
-}
+ 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--;
+ }
+ }
-function unsupportedRefresh() {
- throw new Error('Cache cannot be refreshed during server rendering.');
-}
+ 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 useCacheRefresh() {
- return unsupportedRefresh;
-}
+ 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 useMemoCache(size) {
- var data = new Array(size);
- for (var i = 0; i < size; i++) {
- data[i] = REACT_MEMO_CACHE_SENTINEL;
- }
+ if (fn.displayName && _frame.includes('')) {
+ _frame = _frame.replace('', fn.displayName);
+ }
- return data;
-}
+ if (true) {
+ if (typeof fn === 'function') {
+ componentFrameCache.set(fn, _frame);
+ }
+ } // Return the line we found.
-function noop$1() {}
-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
-};
+ return _frame;
+ }
+ } while (s >= 1 && c >= 0);
+ }
-{
- HooksDispatcher.useCacheRefresh = useCacheRefresh;
-}
+ break;
+ }
+ }
+ }
+ } finally {
+ reentry = false;
-{
- HooksDispatcher.useEffectEvent = useEffectEvent;
-}
+ {
+ ReactCurrentDispatcher$1.current = previousDispatcher;
+ reenableLogs();
+ }
-{
- HooksDispatcher.useMemoCache = useMemoCache;
-}
+ Error.prepareStackTrace = previousPrepareStackTrace;
+ } // Fallback to just using the name if we couldn't make it throw.
-{
- HooksDispatcher.useHostTransitionStatus = useHostTransitionStatus;
-}
-{
- HooksDispatcher.useOptimistic = useOptimistic;
- HooksDispatcher.useFormState = useFormState;
-}
+ var name = fn ? fn.displayName || fn.name : '';
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
-var currentResumableState = null;
-function setCurrentResumableState(resumableState) {
- currentResumableState = resumableState;
-}
+ {
+ if (typeof fn === 'function') {
+ componentFrameCache.set(fn, syntheticFrame);
+ }
+ }
-function getCacheSignal() {
- throw new Error('Not implemented.');
+ return syntheticFrame;
}
-function getCacheForType(resourceType) {
- throw new Error('Not implemented.');
+function describeClassComponentFrame(ctor, ownerFn) {
+ {
+ return describeNativeComponentFrame(ctor, true);
+ }
+}
+function describeFunctionComponentFrame(fn, ownerFn) {
+ {
+ return describeNativeComponentFrame(fn, false);
+ }
}
-
-var DefaultCacheDispatcher = {
- getCacheSignal: getCacheSignal,
- getCacheForType: getCacheForType
-};
function getStackByComponentStackNode(componentStack) {
try {
@@ -8983,15 +9177,15 @@ function getStackByComponentStackNode(componentStack) {
do {
switch (node.tag) {
case 0:
- info += describeBuiltInComponentFrame(node.type, null, null);
+ info += describeBuiltInComponentFrame(node.type, null);
break;
case 1:
- info += describeFunctionComponentFrame(node.type, null, null);
+ info += describeFunctionComponentFrame(node.type, null);
break;
case 2:
- info += describeClassComponentFrame(node.type, null, null);
+ info += describeClassComponentFrame(node.type, null);
break;
} // $FlowFixMe[incompatible-type] we bail out when we get a null
@@ -9084,7 +9278,7 @@ function createRequest(children, resumableState, renderState, rootFormatContext,
false, false); // There is no parent so conceptually, we're unblocked to flush this segment.
rootSegment.parentFlushed = true;
- var rootTask = createRenderTask(request, null, children, -1, null, rootSegment, abortSet, null, rootFormatContext, emptyContextObject, rootContextSnapshot, emptyTreeContext, null);
+ var rootTask = createRenderTask(request, null, children, -1, null, rootSegment, null, abortSet, null, rootFormatContext, emptyContextObject, rootContextSnapshot, emptyTreeContext, null, false);
pingedTasks.push(rootTask);
return request;
}
@@ -9117,13 +9311,14 @@ function createSuspenseBoundary(request, fallbackAbortableTasks) {
byteSize: 0,
fallbackAbortableTasks: fallbackAbortableTasks,
errorDigest: null,
- resources: createBoundaryResources(),
+ contentState: createHoistableState(),
+ fallbackState: createHoistableState(),
trackedContentKeyPath: null,
trackedFallbackNode: null
};
}
-function createRenderTask(request, thenableState, node, childIndex, blockedBoundary, blockedSegment, abortSet, keyPath, formatContext, legacyContext, context, treeContext, componentStack) {
+function createRenderTask(request, thenableState, node, childIndex, blockedBoundary, blockedSegment, hoistableState, abortSet, keyPath, formatContext, legacyContext, context, treeContext, componentStack, isFallback) {
request.allPendingTasks++;
if (blockedBoundary === null) {
@@ -9141,6 +9336,7 @@ function createRenderTask(request, thenableState, node, childIndex, blockedBound
},
blockedBoundary: blockedBoundary,
blockedSegment: blockedSegment,
+ hoistableState: hoistableState,
abortSet: abortSet,
keyPath: keyPath,
formatContext: formatContext,
@@ -9148,13 +9344,14 @@ function createRenderTask(request, thenableState, node, childIndex, blockedBound
context: context,
treeContext: treeContext,
componentStack: componentStack,
- thenableState: thenableState
+ thenableState: thenableState,
+ isFallback: isFallback
};
abortSet.add(task);
return task;
}
-function createReplayTask(request, thenableState, replay, node, childIndex, blockedBoundary, abortSet, keyPath, formatContext, legacyContext, context, treeContext, componentStack) {
+function createReplayTask(request, thenableState, replay, node, childIndex, blockedBoundary, hoistableState, abortSet, keyPath, formatContext, legacyContext, context, treeContext, componentStack, isFallback) {
request.allPendingTasks++;
if (blockedBoundary === null) {
@@ -9173,6 +9370,7 @@ function createReplayTask(request, thenableState, replay, node, childIndex, bloc
},
blockedBoundary: blockedBoundary,
blockedSegment: null,
+ hoistableState: hoistableState,
abortSet: abortSet,
keyPath: keyPath,
formatContext: formatContext,
@@ -9180,7 +9378,8 @@ function createReplayTask(request, thenableState, replay, node, childIndex, bloc
context: context,
treeContext: treeContext,
componentStack: componentStack,
- thenableState: thenableState
+ thenableState: thenableState,
+ isFallback: isFallback
};
abortSet.add(task);
return task;
@@ -9262,19 +9461,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;
}
}
@@ -9347,6 +9546,7 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
var suspenseComponentStack = task.componentStack = createBuiltInComponentStack(task, 'Suspense');
var prevKeyPath = task.keyPath;
var parentBoundary = task.blockedBoundary;
+ var parentHoistableState = task.hoistableState;
var parentSegment = task.blockedSegment; // Each time we enter a suspense boundary, we split out into a new segment for
// the fallback so that we can later replace that segment with the content.
// This also lets us split out the main content even if it doesn't suspend,
@@ -9382,12 +9582,8 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
// we're writing to. If something suspends, it'll spawn new suspended task with that context.
task.blockedBoundary = newBoundary;
+ task.hoistableState = newBoundary.contentState;
task.blockedSegment = contentRootSegment;
-
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, newBoundary.resources);
- }
-
task.keyPath = keyPath;
try {
@@ -9426,11 +9622,8 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
// We don't need to schedule any task because we know the parent has written yet.
// We do need to fallthrough to create the fallback though.
} finally {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, parentBoundary ? parentBoundary.resources : null);
- }
-
task.blockedBoundary = parentBoundary;
+ task.hoistableState = parentHoistableState;
task.blockedSegment = parentSegment;
task.keyPath = prevKeyPath;
task.componentStack = previousComponentStack;
@@ -9457,9 +9650,9 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
// on it yet in case we finish the main content, so we queue for later.
- var suspendedFallbackTask = createRenderTask(request, null, fallback, -1, parentBoundary, boundarySegment, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // This stack should be the Suspense boundary stack because while the fallback is actually a child segment
+ var suspendedFallbackTask = createRenderTask(request, null, fallback, -1, parentBoundary, boundarySegment, newBoundary.fallbackState, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // This stack should be the Suspense boundary stack because while the fallback is actually a child segment
// of the parent boundary from a component standpoint the fallback is a child of the Suspense boundary itself
- suspenseComponentStack); // TODO: This should be queued at a separate lower priority queue so that we only work
+ suspenseComponentStack, true); // TODO: This should be queued at a separate lower priority queue so that we only work
// on preparing fallbacks if we don't have any more main content to task on.
request.pingedTasks.push(suspendedFallbackTask);
@@ -9473,6 +9666,7 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c
var prevKeyPath = task.keyPath;
var previousReplaySet = task.replay;
var parentBoundary = task.blockedBoundary;
+ var parentHoistableState = task.hoistableState;
var content = props.children;
var fallback = props.fallback;
var fallbackAbortSet = new Set();
@@ -9484,16 +9678,13 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c
// we're writing to. If something suspends, it'll spawn new suspended task with that context.
task.blockedBoundary = resumedBoundary;
+ task.hoistableState = resumedBoundary.contentState;
task.replay = {
nodes: childNodes,
slots: childSlots,
pendingTasks: 1
};
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, resumedBoundary.resources);
- }
-
try {
// We use the safe form because we don't handle suspending here. Only error handling.
renderNode(request, task, content, -1);
@@ -9536,11 +9727,8 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c
// We don't need to schedule any task because we know the parent has written yet.
// We do need to fallthrough to create the fallback though.
} finally {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, parentBoundary ? parentBoundary.resources : null);
- }
-
task.blockedBoundary = parentBoundary;
+ task.hoistableState = parentHoistableState;
task.replay = previousReplaySet;
task.keyPath = prevKeyPath;
task.componentStack = previousComponentStack;
@@ -9554,9 +9742,9 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c
slots: fallbackSlots,
pendingTasks: 0
};
- var suspendedFallbackTask = createReplayTask(request, null, fallbackReplay, fallback, -1, parentBoundary, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // This stack should be the Suspense boundary stack because while the fallback is actually a child segment
+ var suspendedFallbackTask = createReplayTask(request, null, fallbackReplay, fallback, -1, parentBoundary, resumedBoundary.fallbackState, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // This stack should be the Suspense boundary stack because while the fallback is actually a child segment
// of the parent boundary from a component standpoint the fallback is a child of the Suspense boundary itself
- suspenseComponentStack); // TODO: This should be queued at a separate lower priority queue so that we only work
+ suspenseComponentStack, true); // TODO: This should be queued at a separate lower priority queue so that we only work
// on preparing fallbacks if we don't have any more main content to task on.
request.pingedTasks.push(suspendedFallbackTask);
@@ -9584,7 +9772,7 @@ function renderHostElement(request, task, keyPath, type, props) {
task.keyPath = prevKeyPath;
} else {
// Render
- var _children = pushStartInstance(segment.chunks, type, props, request.resumableState, request.renderState, task.formatContext, segment.lastPushedText);
+ var _children = pushStartInstance(segment.chunks, type, props, request.resumableState, request.renderState, task.hoistableState, task.formatContext, segment.lastPushedText, task.isFallback);
segment.lastPushedText = false;
var _prevContext = task.formatContext;
@@ -9609,7 +9797,12 @@ function shouldConstruct(Component) {
return Component.prototype && Component.prototype.isReactComponent;
}
-function renderWithHooks(request, task, keyPath, prevThenableState, Component, props, secondArg) {
+function renderWithHooks(request, task, keyPath, Component, props, secondArg) {
+ // Reset the task's thenable state before continuing, so that if a later
+ // component suspends we can reuse the same task object. If the same
+ // component suspends again, the thenable state will be restored.
+ var prevThenableState = task.thenableState;
+ task.thenableState = null;
var componentIdentity = {};
prepareToUseHooks(request, task, keyPath, componentIdentity, prevThenableState);
var result = Component(props, secondArg);
@@ -9636,7 +9829,7 @@ function finishClassComponent(request, task, keyPath, instance, Component, props
var previousContext = task.legacyContext;
var mergedContext = processChildContext(instance, Component, previousContext, childContextTypes);
task.legacyContext = mergedContext;
- renderNodeDestructive(request, task, null, nextChildren, -1);
+ renderNodeDestructive(request, task, nextChildren, -1);
task.legacyContext = previousContext;
return;
}
@@ -9644,7 +9837,7 @@ function finishClassComponent(request, task, keyPath, instance, Component, props
var prevKeyPath = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, nextChildren, -1);
+ renderNodeDestructive(request, task, nextChildren, -1);
task.keyPath = prevKeyPath;
}
@@ -9665,11 +9858,10 @@ 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, prevThenableState, Component, props) {
+function renderIndeterminateComponent(request, task, keyPath, Component, props) {
var legacyContext;
{
@@ -9691,7 +9883,7 @@ function renderIndeterminateComponent(request, task, keyPath, prevThenableState,
}
}
- var value = renderWithHooks(request, task, keyPath, prevThenableState, Component, props, legacyContext);
+ var value = renderWithHooks(request, task, keyPath, Component, props, legacyContext);
var hasId = checkDidRenderIdHook();
var formStateCount = getFormStateCount();
var formStateMatchingIndex = getFormStateMatchingIndex();
@@ -9785,7 +9977,7 @@ function finishFunctionComponent(request, task, keyPath, children, hasId, formSt
// We're now successfully past this task, and we haven't modified the
// context stack. We don't have to pop back to the previous task every
// again, so we can use the destructive recursive form.
- renderNodeDestructive(request, task, null, children, -1);
+ renderNodeDestructive(request, task, children, -1);
}
task.keyPath = prevKeyPath;
@@ -9795,7 +9987,7 @@ function validateFunctionComponentInDev(Component) {
{
if (Component) {
if (Component.childContextTypes) {
- error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component');
+ error('childContextTypes cannot be defined on a function component.\n' + ' %s.childContextTypes = ...', Component.displayName || Component.name || 'Component');
}
}
@@ -9849,10 +10041,30 @@ function resolveDefaultProps(Component, baseProps) {
return baseProps;
}
-function renderForwardRef(request, task, keyPath, prevThenableState, type, props, ref) {
+function renderForwardRef(request, task, keyPath, type, props, ref) {
var previousComponentStack = task.componentStack;
task.componentStack = createFunctionComponentStack(task, type.render);
- var children = renderWithHooks(request, task, keyPath, prevThenableState, type.render, props, ref);
+ var propsWithoutRef;
+
+ if ('ref' in props) {
+ // `ref` is just a prop now, but `forwardRef` expects it to not appear in
+ // the props object. This used to happen in the JSX runtime, but now we do
+ // it here.
+ propsWithoutRef = {};
+
+ for (var key in props) {
+ // Since `ref` should only appear in props via the JSX transform, we can
+ // assume that this is a plain object. So we don't need a
+ // hasOwnProperty check.
+ if (key !== 'ref') {
+ propsWithoutRef[key] = props[key];
+ }
+ }
+ } else {
+ propsWithoutRef = props;
+ }
+
+ var children = renderWithHooks(request, task, keyPath, type.render, propsWithoutRef, ref);
var hasId = checkDidRenderIdHook();
var formStateCount = getFormStateCount();
var formStateMatchingIndex = getFormStateMatchingIndex();
@@ -9860,37 +10072,13 @@ function renderForwardRef(request, task, keyPath, prevThenableState, type, props
task.componentStack = previousComponentStack;
}
-function renderMemo(request, task, keyPath, prevThenableState, type, props, ref) {
+function renderMemo(request, task, keyPath, type, props, ref) {
var innerType = type.type;
var resolvedProps = resolveDefaultProps(innerType, props);
- renderElement(request, task, keyPath, prevThenableState, innerType, resolvedProps, ref);
+ renderElement(request, task, keyPath, innerType, resolvedProps, 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;
{
@@ -9903,12 +10091,11 @@ function renderContextConsumer(request, task, keyPath, context, props) {
var newChildren = render(newValue);
var prevKeyPath = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, newChildren, -1);
+ renderNodeDestructive(request, task, newChildren, -1);
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;
@@ -9920,7 +10107,7 @@ function renderContextProvider(request, task, keyPath, type, props) {
var prevKeyPath = task.keyPath;
task.context = pushProvider(context, value);
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, children, -1);
+ renderNodeDestructive(request, task, children, -1);
task.context = popProvider(context);
task.keyPath = prevKeyPath;
@@ -9931,14 +10118,14 @@ function renderContextProvider(request, task, keyPath, type, props) {
}
}
-function renderLazyComponent(request, task, keyPath, prevThenableState, lazyComponent, props, ref) {
+function renderLazyComponent(request, task, keyPath, lazyComponent, props, ref) {
var previousComponentStack = task.componentStack;
task.componentStack = createBuiltInComponentStack(task, 'Lazy');
var payload = lazyComponent._payload;
var init = lazyComponent._init;
var Component = init(payload);
var resolvedProps = resolveDefaultProps(Component, props);
- renderElement(request, task, keyPath, prevThenableState, Component, resolvedProps, ref);
+ renderElement(request, task, keyPath, Component, resolvedProps, ref);
task.componentStack = previousComponentStack;
}
@@ -9950,18 +10137,18 @@ function renderOffscreen(request, task, keyPath, props) {
// pure indirection.
var prevKeyPath = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, props.children, -1);
+ renderNodeDestructive(request, task, props.children, -1);
task.keyPath = prevKeyPath;
}
}
-function renderElement(request, task, keyPath, prevThenableState, type, props, ref) {
+function renderElement(request, task, keyPath, type, props, ref) {
if (typeof type === 'function') {
if (shouldConstruct(type)) {
renderClassComponent(request, task, keyPath, type, props);
return;
} else {
- renderIndeterminateComponent(request, task, keyPath, prevThenableState, type, props);
+ renderIndeterminateComponent(request, task, keyPath, type, props);
return;
}
}
@@ -9989,7 +10176,7 @@ function renderElement(request, task, keyPath, prevThenableState, type, props, r
{
var prevKeyPath = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, props.children, -1);
+ renderNodeDestructive(request, task, props.children, -1);
task.keyPath = prevKeyPath;
return;
}
@@ -10007,7 +10194,7 @@ function renderElement(request, task, keyPath, prevThenableState, type, props, r
var _prevKeyPath3 = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, props.children, -1);
+ renderNodeDestructive(request, task, props.children, -1);
task.keyPath = _prevKeyPath3;
task.componentStack = preiousComponentStack;
return;
@@ -10033,31 +10220,47 @@ function renderElement(request, task, keyPath, prevThenableState, type, props, r
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
{
- renderForwardRef(request, task, keyPath, prevThenableState, type, props, ref);
+ renderForwardRef(request, task, keyPath, type, props, ref);
return;
}
case REACT_MEMO_TYPE:
{
- renderMemo(request, task, keyPath, prevThenableState, type, props, ref);
+ renderMemo(request, task, keyPath, type, props, ref);
return;
}
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, prevThenableState, type, props);
+ renderLazyComponent(request, task, keyPath, type, props);
return;
}
}
@@ -10105,7 +10308,7 @@ function resumeNode(request, task, segmentId, node, childIndex) {
}
}
-function replayElement(request, task, keyPath, prevThenableState, name, keyOrIndex, childIndex, type, props, ref, replay) {
+function replayElement(request, task, keyPath, name, keyOrIndex, childIndex, type, props, ref, replay) {
// We're replaying. Find the path to follow.
var replayNodes = replay.nodes;
@@ -10134,7 +10337,7 @@ function replayElement(request, task, keyPath, prevThenableState, name, keyOrInd
};
try {
- renderElement(request, task, keyPath, prevThenableState, type, props, ref);
+ renderElement(request, task, keyPath, type, props, ref);
if (task.replay.pendingTasks === 1 && task.replay.nodes.length > 0 // TODO check remaining slots
) {
@@ -10206,13 +10409,28 @@ 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.
-function renderNodeDestructive(request, task, // The thenable state reused from the previous attempt, if any. This is almost
-// always null, except when called by retryTask.
-prevThenableState, node, childIndex) {
+function renderNodeDestructive(request, task, node, childIndex) {
if (task.replay !== null && typeof task.replay.slots === 'number') {
// TODO: Figure out a cheaper place than this hot path to do this check.
var resumeSegmentID = task.replay.slots;
@@ -10223,9 +10441,14 @@ prevThenableState, node, childIndex) {
task.node = node;
- task.childIndex = childIndex; // Handle object types
+ task.childIndex = childIndex;
+
+ if (node === null) {
+ return;
+ } // Handle object types
+
- if (typeof node === 'object' && node !== null) {
+ if (typeof node === 'object') {
switch (node.$$typeof) {
case REACT_ELEMENT_TYPE:
{
@@ -10233,17 +10456,26 @@ prevThenableState, node, childIndex) {
var type = element.type;
var key = element.key;
var props = element.props;
- var ref = element.ref;
+ var ref;
+
+ {
+ // TODO: This is a temporary, intermediate step. Once the feature
+ // flag is removed, we should get the ref off the props object right
+ // before using it.
+ var refProp = props.ref;
+ ref = refProp !== undefined ? refProp : null;
+ }
+
var name = getComponentNameFromType(type);
var keyOrIndex = key == null ? childIndex === -1 ? 0 : childIndex : key;
var keyPath = [task.keyPath, name, keyOrIndex];
if (task.replay !== null) {
- replayElement(request, task, keyPath, prevThenableState, name, keyOrIndex, childIndex, type, props, ref, task.replay); // No matches found for this node. We assume it's already emitted in the
+ replayElement(request, task, keyPath, name, keyOrIndex, childIndex, type, props, ref, task.replay); // No matches found for this node. We assume it's already emitted in the
// prelude and skip it during the replay.
} else {
// We're doing a plain render.
- renderElement(request, task, keyPath, prevThenableState, type, props, ref);
+ renderElement(request, task, keyPath, type, props, ref);
}
return;
@@ -10264,7 +10496,7 @@ prevThenableState, node, childIndex) {
task.componentStack = previousComponentStack; // Now we render the resolved node
- renderNodeDestructive(request, task, null, resolvedNode, childIndex);
+ renderNodeDestructive(request, task, resolvedNode, childIndex);
return;
}
}
@@ -10319,13 +10551,15 @@ prevThenableState, node, childIndex) {
var maybeUsable = node;
if (typeof maybeUsable.then === 'function') {
+ // Clear any previous thenable state that was created by the unwrapping.
+ task.thenableState = null;
var thenable = maybeUsable;
- return renderNodeDestructive(request, task, null, unwrapThenable(thenable), childIndex);
+ return renderNodeDestructive(request, task, unwrapThenable(thenable), childIndex);
}
- if (maybeUsable.$$typeof === REACT_CONTEXT_TYPE || maybeUsable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
+ if (maybeUsable.$$typeof === REACT_CONTEXT_TYPE) {
var context = maybeUsable;
- return renderNodeDestructive(request, task, null, readContext$1(context), childIndex);
+ return renderNodeDestructive(request, task, readContext$1(context), childIndex);
} // $FlowFixMe[method-unbinding]
@@ -10355,7 +10589,11 @@ prevThenableState, 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);
}
}
}
@@ -10650,9 +10888,9 @@ function injectPostponedHole(request, task, reason, thrownInfo) {
}
function spawnNewSuspendedReplayTask(request, task, thenableState, x) {
- var newTask = createReplayTask(request, thenableState, task.replay, task.node, task.childIndex, task.blockedBoundary, task.abortSet, task.keyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // We pop one task off the stack because the node that suspended will be tried again,
+ var newTask = createReplayTask(request, thenableState, task.replay, task.node, task.childIndex, task.blockedBoundary, task.hoistableState, task.abortSet, task.keyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // We pop one task off the stack because the node that suspended will be tried again,
// which will add it back onto the stack.
- task.componentStack !== null ? task.componentStack.parent : null);
+ task.componentStack !== null ? task.componentStack.parent : null, task.isFallback);
var ping = newTask.ping;
x.then(ping, ping);
}
@@ -10667,9 +10905,9 @@ function spawnNewSuspendedRenderTask(request, task, thenableState, x) {
segment.children.push(newSegment); // Reset lastPushedText for current Segment since the new Segment "consumed" it
segment.lastPushedText = false;
- var newTask = createRenderTask(request, thenableState, task.node, task.childIndex, task.blockedBoundary, newSegment, task.abortSet, task.keyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // We pop one task off the stack because the node that suspended will be tried again,
+ var newTask = createRenderTask(request, thenableState, task.node, task.childIndex, task.blockedBoundary, newSegment, task.hoistableState, task.abortSet, task.keyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // We pop one task off the stack because the node that suspended will be tried again,
// which will add it back onto the stack.
- task.componentStack !== null ? task.componentStack.parent : null);
+ task.componentStack !== null ? task.componentStack.parent : null, task.isFallback);
var ping = newTask.ping;
x.then(ping, ping);
} // This is a non-destructive form of rendering a node. If it suspends it spawns
@@ -10693,7 +10931,7 @@ function renderNode(request, task, node, childIndex) {
if (segment === null) {
// Replay
try {
- return renderNodeDestructive(request, task, null, node, childIndex);
+ return renderNodeDestructive(request, task, node, childIndex);
} catch (thrownValue) {
resetHooksState();
x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
@@ -10731,7 +10969,7 @@ function renderNode(request, task, node, childIndex) {
var chunkLength = segment.chunks.length;
try {
- return renderNodeDestructive(request, task, null, node, childIndex);
+ return renderNodeDestructive(request, task, node, childIndex);
} catch (thrownValue) {
resetHooksState(); // Reset the write pointers to where we started.
@@ -10970,8 +11208,16 @@ function abortTask(task, request, error) {
if (replay === null) {
// We didn't complete the root so we have nothing to show. We can close
// the request;
- logRecoverableError(request, error, errorInfo);
- fatalError(request, error);
+ if (typeof error === 'object' && error !== null && error.$$typeof === REACT_POSTPONE_TYPE) {
+ var postponeInstance = error;
+ var fatal = new Error('The render was aborted with postpone when the shell is incomplete. Reason: ' + postponeInstance.message);
+ logRecoverableError(request, fatal, errorInfo);
+ fatalError(request, fatal);
+ } else {
+ logRecoverableError(request, error, errorInfo);
+ fatalError(request, error);
+ }
+
return;
} else {
// If the shell aborts during a replay, that's not a fatal error. Instead
@@ -10980,7 +11226,17 @@ function abortTask(task, request, error) {
replay.pendingTasks--;
if (replay.pendingTasks === 0 && replay.nodes.length > 0) {
- var errorDigest = logRecoverableError(request, error, errorInfo);
+ var errorDigest;
+
+ if (typeof error === 'object' && error !== null && error.$$typeof === REACT_POSTPONE_TYPE) {
+ var _postponeInstance = error;
+ logPostpone(request, _postponeInstance.message, errorInfo); // TODO: Figure out a better signal than a magic digest value.
+
+ errorDigest = 'POSTPONE';
+ } else {
+ errorDigest = logRecoverableError(request, error, errorInfo);
+ }
+
abortRemainingReplayNodes(request, null, replay.nodes, replay.slots, error, errorDigest, errorInfo);
}
@@ -11000,7 +11256,16 @@ function abortTask(task, request, error) {
var _errorInfo = getThrownInfo(request, task.componentStack);
- var _errorDigest = logRecoverableError(request, error, _errorInfo);
+ var _errorDigest;
+
+ if (typeof error === 'object' && error !== null && error.$$typeof === REACT_POSTPONE_TYPE) {
+ var _postponeInstance2 = error;
+ logPostpone(request, _postponeInstance2.message, _errorInfo); // TODO: Figure out a better signal than a magic digest value.
+
+ _errorDigest = 'POSTPONE';
+ } else {
+ _errorDigest = logRecoverableError(request, error, _errorInfo);
+ }
var errorMessage = error;
@@ -11178,11 +11443,6 @@ function finishedTask(request, boundary, segment) {
}
function retryTask(request, task) {
- {
- var blockedBoundary = task.blockedBoundary;
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, blockedBoundary ? blockedBoundary.resources : null);
- }
-
var segment = task.blockedSegment;
if (segment === null) {
@@ -11217,12 +11477,7 @@ function retryRenderTask(request, task, segment) {
try {
// We call the destructive form that mutates this task. That way if something
// suspends again, we can reuse the same task instead of spawning a new one.
- // Reset the task's thenable state before continuing, so that if a later
- // component suspends we can reuse the same task object. If the same
- // component suspends again, the thenable state will be restored.
- var prevThenableState = task.thenableState;
- task.thenableState = null;
- renderNodeDestructive(request, task, prevThenableState, task.node, task.childIndex);
+ renderNodeDestructive(request, task, task.node, task.childIndex);
pushSegmentFinale(segment.chunks, request.renderState, segment.lastPushedText, segment.textEmbedded);
task.abortSet.delete(task);
segment.status = COMPLETED;
@@ -11268,10 +11523,6 @@ function retryRenderTask(request, task, segment) {
erroredTask(request, task.blockedBoundary, x, errorInfo);
return;
} finally {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, null);
- }
-
{
currentTaskInDEV = prevTaskInDEV;
}
@@ -11298,12 +11549,7 @@ function retryReplayTask(request, task) {
try {
// We call the destructive form that mutates this task. That way if something
// suspends again, we can reuse the same task instead of spawning a new one.
- // Reset the task's thenable state before continuing, so that if a later
- // component suspends we can reuse the same task object. If the same
- // component suspends again, the thenable state will be restored.
- var prevThenableState = task.thenableState;
- task.thenableState = null;
- renderNodeDestructive(request, task, prevThenableState, task.node, task.childIndex);
+ renderNodeDestructive(request, task, task.node, task.childIndex);
if (task.replay.pendingTasks === 1 && task.replay.nodes.length > 0) {
throw new Error("Couldn't find all resumable slots by key/index during replaying. " + "The tree doesn't match so React will fallback to client rendering.");
@@ -11350,10 +11596,6 @@ function retryReplayTask(request, task) {
return;
} finally {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, null);
- }
-
{
currentTaskInDEV = prevTaskInDEV;
}
@@ -11432,7 +11674,12 @@ function performWork(request) {
}
}
-function flushSubtree(request, destination, segment) {
+function flushPreamble(request, destination, rootSegment) {
+ var willFlushAllSegments = request.allPendingTasks === 0 && request.trackedPostpones === null;
+ writePreamble(destination, request.resumableState, request.renderState, willFlushAllSegments);
+}
+
+function flushSubtree(request, destination, segment, hoistableState) {
segment.parentFlushed = true;
switch (segment.status) {
@@ -11467,7 +11714,7 @@ function flushSubtree(request, destination, segment) {
writeChunk(destination, chunks[chunkIdx]);
}
- r = flushSegment(request, destination, nextChild);
+ r = flushSegment(request, destination, nextChild, hoistableState);
} // Finally just write all the remaining chunks
@@ -11489,12 +11736,12 @@ function flushSubtree(request, destination, segment) {
}
}
-function flushSegment(request, destination, segment) {
+function flushSegment(request, destination, segment, hoistableState) {
var boundary = segment.boundary;
if (boundary === null) {
// Not a suspense boundary.
- return flushSubtree(request, destination, segment);
+ return flushSubtree(request, destination, segment, hoistableState);
}
boundary.parentFlushed = true; // This segment is a Suspense boundary. We need to decide whether to
@@ -11505,7 +11752,7 @@ function flushSegment(request, destination, segment) {
// We never queue the inner boundary so we'll never emit its content or partial segments.
writeStartClientRenderedSuspenseBoundary(destination, request.renderState, boundary.errorDigest, boundary.errorMessage, boundary.errorComponentStack); // Flush the fallback.
- flushSubtree(request, destination, segment);
+ flushSubtree(request, destination, segment, hoistableState);
return writeEndClientRenderedSuspenseBoundary(destination, request.renderState);
} else if (boundary.status !== COMPLETED) {
if (boundary.status === PENDING) {
@@ -11521,9 +11768,17 @@ function flushSegment(request, destination, segment) {
var id = boundary.rootSegmentID;
- writeStartPendingSuspenseBoundary(destination, request.renderState, id); // Flush the fallback.
+ writeStartPendingSuspenseBoundary(destination, request.renderState, id); // We are going to flush the fallback so we need to hoist the fallback
+ // state to the parent boundary
+
+ {
+ if (hoistableState) {
+ hoistHoistables(hoistableState, boundary.fallbackState);
+ }
+ } // Flush the fallback.
- flushSubtree(request, destination, segment);
+
+ flushSubtree(request, destination, segment, hoistableState);
return writeEndPendingSuspenseBoundary(destination);
} else if (boundary.byteSize > request.progressiveChunkSize) {
// This boundary is large and will be emitted separately so that we can progressively show
@@ -11535,13 +11790,19 @@ function flushSegment(request, destination, segment) {
boundary.rootSegmentID = request.nextSegmentId++;
request.completedBoundaries.push(boundary); // Emit a pending rendered suspense boundary wrapper.
- writeStartPendingSuspenseBoundary(destination, request.renderState, boundary.rootSegmentID); // Flush the fallback.
+ writeStartPendingSuspenseBoundary(destination, request.renderState, boundary.rootSegmentID); // While we are going to flush the fallback we are going to follow it up with
+ // the completed boundary immediately so we make the choice to omit fallback
+ // boundary state from the parent since it will be replaced when the boundary
+ // flushes later in this pass or in a future flush
+ // Flush the fallback.
- flushSubtree(request, destination, segment);
+ flushSubtree(request, destination, segment, hoistableState);
return writeEndPendingSuspenseBoundary(destination);
} else {
{
- hoistResources(request.renderState, boundary.resources);
+ if (hoistableState) {
+ hoistHoistables(hoistableState, boundary.contentState);
+ }
} // We can inline this boundary's content as a complete boundary.
@@ -11553,7 +11814,7 @@ function flushSegment(request, destination, segment) {
}
var contentSegment = completedSegments[0];
- flushSegment(request, destination, contentSegment);
+ flushSegment(request, destination, contentSegment, hoistableState);
return writeEndCompletedSuspenseBoundary(destination, request.renderState);
}
}
@@ -11562,17 +11823,13 @@ function flushClientRenderedBoundary(request, destination, boundary) {
return writeClientRenderBoundaryInstruction(destination, request.resumableState, request.renderState, boundary.rootSegmentID, boundary.errorDigest, boundary.errorMessage, boundary.errorComponentStack);
}
-function flushSegmentContainer(request, destination, segment) {
+function flushSegmentContainer(request, destination, segment, hoistableState) {
writeStartSegment(destination, request.renderState, segment.parentFormatContext, segment.id);
- flushSegment(request, destination, segment);
+ flushSegment(request, destination, segment, hoistableState);
return writeEndSegment(destination, segment.parentFormatContext);
}
function flushCompletedBoundary(request, destination, boundary) {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, boundary.resources);
- }
-
var completedSegments = boundary.completedSegments;
var i = 0;
@@ -11584,17 +11841,13 @@ function flushCompletedBoundary(request, destination, boundary) {
completedSegments.length = 0;
{
- writeResourcesForBoundary(destination, boundary.resources, request.renderState);
+ writeHoistablesForBoundary(destination, boundary.contentState, request.renderState);
}
- return writeCompletedBoundaryInstruction(destination, request.resumableState, request.renderState, boundary.rootSegmentID, boundary.resources);
+ return writeCompletedBoundaryInstruction(destination, request.resumableState, request.renderState, boundary.rootSegmentID, boundary.contentState);
}
function flushPartialBoundary(request, destination, boundary) {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, boundary.resources);
- }
-
var completedSegments = boundary.completedSegments;
var i = 0;
@@ -11613,11 +11866,7 @@ function flushPartialBoundary(request, destination, boundary) {
completedSegments.splice(0, i);
{
- // The way this is structured we only write resources for partial boundaries
- // if there is no backpressure. Later before we complete the boundary we
- // will write resources regardless of backpressure before we emit the
- // completion instruction
- return writeResourcesForBoundary(destination, boundary.resources, request.renderState);
+ return writeHoistablesForBoundary(destination, boundary.contentState, request.renderState);
}
}
@@ -11627,6 +11876,7 @@ function flushPartiallyCompletedSegment(request, destination, boundary, segment)
return true;
}
+ var hoistableState = boundary.contentState;
var segmentID = segment.id;
if (segmentID === -1) {
@@ -11638,13 +11888,13 @@ function flushPartiallyCompletedSegment(request, destination, boundary, segment)
throw new Error('A root segment ID must have been assigned by now. This is a bug in React.');
}
- return flushSegmentContainer(request, destination, segment);
+ return flushSegmentContainer(request, destination, segment, hoistableState);
} else if (segmentID === boundary.rootSegmentID) {
// When we emit postponed boundaries, we might have assigned the ID already
// but it's still the root segment so we can't inject it into the parent yet.
- return flushSegmentContainer(request, destination, segment);
+ return flushSegmentContainer(request, destination, segment, hoistableState);
} else {
- flushSegmentContainer(request, destination, segment);
+ flushSegmentContainer(request, destination, segment, hoistableState);
return writeCompletedSegmentInstruction(destination, request.resumableState, request.renderState, segmentID);
}
}
@@ -11665,10 +11915,10 @@ function flushCompletedQueues(request, destination) {
return;
} else if (request.pendingRootTasks === 0) {
if (enableFloat) {
- writePreamble(destination, request.resumableState, request.renderState, request.allPendingTasks === 0 && request.trackedPostpones === null);
+ flushPreamble(request, destination, completedRootSegment);
}
- flushSegment(request, destination, completedRootSegment);
+ flushSegment(request, destination, completedRootSegment, null);
request.completedRootSegment = null;
writeCompletedRoot(destination, request.renderState);
} else {
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 a5b433744222b9..29bb83f9278a56 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
@@ -17,16 +17,67 @@ var ReactDOM = require('react-dom');
// template literal strings. The messages will be replaced with error codes
// during build.
function formatProdErrorMessage(code) {
- let url = 'https://reactjs.org/docs/error-decoder.html?invariant=' + code;
+ let url = 'https://react.dev/errors/' + code;
- for (let i = 1; i < arguments.length; i++) {
- url += '&args[]=' + encodeURIComponent(arguments[i]);
+ if (arguments.length > 1) {
+ url += '?args[]=' + encodeURIComponent(arguments[1]);
+
+ for (let i = 2; i < arguments.length; i++) {
+ url += '&args[]=' + encodeURIComponent(arguments[i]);
+ }
}
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-60a927d04-20240113';
+var ReactVersion = '18.3.0-experimental-14898b6a9-20240318';
+
+// 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
@@ -140,9 +191,6 @@ function stringToChunk(content) {
function stringToPrecomputedChunk(content) {
return content;
}
-function clonePrecomputedChunk(chunk) {
- return chunk;
-}
function closeWithError(destination, error) {
// $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types.
destination.destroy(error);
@@ -322,19 +370,13 @@ 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())};';
const completeBoundary = '$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};';
const completeBoundaryWithStyles = '$RM=new Map;\n$RR=function(r,t,w){for(var u=$RC,n=$RM,p=new Map,q=document,g,b,h=q.querySelectorAll("link[data-precedence],style[data-precedence]"),v=[],k=0;b=h[k++];)"not all"===b.getAttribute("media")?v.push(b):("LINK"===b.tagName&&n.set(b.getAttribute("href"),b),p.set(b.dataset.precedence,g=b));b=0;h=[];var l,a;for(k=!0;;){if(k){var f=w[b++];if(!f){k=!1;b=0;continue}var c=!1,m=0;var d=f[m++];if(a=n.get(d)){var e=a._p;c=!0}else{a=q.createElement("link");a.href=d;a.rel="stylesheet";for(a.dataset.precedence=\nl=f[m++];e=f[m++];)a.setAttribute(e,f[m++]);e=a._p=new Promise(function(x,y){a.onload=x;a.onerror=y});n.set(d,a)}d=a.getAttribute("media");!e||"l"===e.s||d&&!matchMedia(d).matches||h.push(e);if(c)continue}else{a=v[b++];if(!a)break;l=a.getAttribute("data-precedence");a.removeAttribute("media")}c=p.get(l)||g;c===g&&(g=a);p.set(l,a);c?c.parentNode.insertBefore(a,c.nextSibling):(c=q.head,c.insertBefore(a,c.firstChild))}Promise.all(h).then(u.bind(null,r,t,""),u.bind(null,r,t,"Resource failed to load"))};';
const completeSegment = '$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};';
-const formReplaying = 'addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error(\'A React form was unexpectedly submitted.\')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.getRootNode(),(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,\nd,b))}});';
+const formReplaying = 'addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error(\'React form unexpectedly submitted.\')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});';
const ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
@@ -510,6 +552,7 @@ function createRenderState$1(resumableState, nonce, externalRuntimeConfig, impor
headChunks: null,
externalRuntimeScript: externalRuntimeScript,
bootstrapChunks: bootstrapChunks,
+ importMapChunks,
onHeaders,
headers,
resets: {
@@ -524,9 +567,7 @@ function createRenderState$1(resumableState, nonce, externalRuntimeConfig, impor
style: {}
},
charsetChunks: [],
- preconnectChunks: [],
- importMapChunks,
- preloadChunks: [],
+ viewportChunks: [],
hoistableChunks: [],
// cleared on flush
preconnects: new Set(),
@@ -545,7 +586,7 @@ function createRenderState$1(resumableState, nonce, externalRuntimeConfig, impor
},
nonce,
// like a module global for currently rendering boundary
- boundaryResources: null,
+ hoistableState: null,
stylesToHoist: false
};
@@ -907,7 +948,7 @@ function makeFormFieldPrefix(resumableState) {
const actionJavaScriptURL = stringToPrecomputedChunk(escapeTextForBrowser( // eslint-disable-next-line no-script-url
-"javascript:throw new Error('A React form was unexpectedly submitted.')"));
+"javascript:throw new Error('React form unexpectedly submitted.')"));
const startHiddenInputChunk = stringToPrecomputedChunk(' {
+ hoistableState.stylesheets.forEach(resource => {
if (resource.state === PREAMBLE) ; else if (resource.state === LATE) {
// We only need to emit the href because this resource flushed in an earlier
// boundary already which encoded the attributes necessary to construct
@@ -3746,6 +3851,7 @@ function writeStyleResourceAttributeInJS(destination, name, value) // not null o
case 'suppressContentEditableWarning':
case 'suppressHydrationWarning':
case 'style':
+ case 'ref':
// Ignored
return;
// Attribute renames
@@ -3805,10 +3911,10 @@ function writeStyleResourceAttributeInJS(destination, name, value) // not null o
// [["JSON_escaped_string1", "JSON_escaped_string2"]]
-function writeStyleResourceDependenciesInAttr(destination, boundaryResources) {
+function writeStyleResourceDependenciesInAttr(destination, hoistableState) {
writeChunk(destination, arrayFirstOpenBracket);
let nextArrayOpenBrackChunk = arrayFirstOpenBracket;
- boundaryResources.stylesheets.forEach(resource => {
+ hoistableState.stylesheets.forEach(resource => {
if (resource.state === PREAMBLE) ; else if (resource.state === LATE) {
// We only need to emit the href because this resource flushed in an earlier
// boundary already which encoded the attributes necessary to construct
@@ -3895,6 +4001,7 @@ function writeStyleResourceAttributeInAttr(destination, name, value) // not null
case 'suppressContentEditableWarning':
case 'suppressHydrationWarning':
case 'style':
+ case 'ref':
// Ignored
return;
// Attribute renames
@@ -3958,15 +4065,12 @@ const PENDING$1 = 0;
const PRELOADED = 1;
const PREAMBLE = 2;
const LATE = 3;
-function createBoundaryResources() {
+function createHoistableState() {
return {
styles: new Set(),
stylesheets: new Set()
};
}
-function setCurrentlyRenderingBoundaryResourcesTarget(renderState, boundaryResources) {
- renderState.boundaryResources = boundaryResources;
-}
function getResourceKey(href) {
return href;
@@ -4751,13 +4855,9 @@ function hoistStylesheetDependency(stylesheet) {
this.stylesheets.add(stylesheet);
}
-function hoistResources(renderState, source) {
- const currentBoundaryResources = renderState.boundaryResources;
-
- if (currentBoundaryResources) {
- source.styles.forEach(hoistStyleQueueDependency, currentBoundaryResources);
- source.stylesheets.forEach(hoistStylesheetDependency, currentBoundaryResources);
- }
+function hoistHoistables(parentState, childState) {
+ childState.styles.forEach(hoistStyleQueueDependency, parentState);
+ childState.stylesheets.forEach(hoistStylesheetDependency, parentState);
} // This function is called at various times depending on whether we are rendering
// or prerendering. In this implementation we only actually emit headers once and
// subsequent calls are ignored. We track whether the request has a completed shell
@@ -4864,13 +4964,12 @@ function createRenderState(resumableState, generateStaticMarkup) {
headChunks: renderState.headChunks,
externalRuntimeScript: renderState.externalRuntimeScript,
bootstrapChunks: renderState.bootstrapChunks,
+ importMapChunks: renderState.importMapChunks,
onHeaders: renderState.onHeaders,
headers: renderState.headers,
resets: renderState.resets,
charsetChunks: renderState.charsetChunks,
- preconnectChunks: renderState.preconnectChunks,
- importMapChunks: renderState.importMapChunks,
- preloadChunks: renderState.preloadChunks,
+ viewportChunks: renderState.viewportChunks,
hoistableChunks: renderState.hoistableChunks,
preconnects: renderState.preconnects,
fontPreloads: renderState.fontPreloads,
@@ -4881,7 +4980,6 @@ function createRenderState(resumableState, generateStaticMarkup) {
scripts: renderState.scripts,
bulkPreloads: renderState.bulkPreloads,
preloads: renderState.preloads,
- boundaryResources: renderState.boundaryResources,
stylesToHoist: renderState.stylesToHoist,
// This is an extra field for the legacy renderer
generateStaticMarkup
@@ -4939,47 +5037,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_SERVER_CONTEXT_TYPE = Symbol.for('react.server_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_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
-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;
@@ -5046,13 +5103,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');
@@ -5078,302 +5145,55 @@ function getComponentNameFromType(type) {
return null;
}
}
-
- case REACT_SERVER_CONTEXT_TYPE:
- {
- const context2 = type;
- return (context2.displayName || context2._globalName) + '.Provider';
- }
-
}
}
return null;
}
-let prefix;
-function describeBuiltInComponentFrame(name, source, 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();
+
+ for (const contextKey in childContext) {
+ if (!(contextKey in childContextTypes)) {
+ throw Error(formatProdErrorMessage(108, getComponentNameFromType(type) || 'Unknown', contextKey));
+ }
+ }
+
+ return assign({}, parentContext, childContext);
}
+}
- 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, source, ownerFn) {
- {
- return describeNativeComponentFrame(ctor, true);
- }
-}
-function describeFunctionComponentFrame(fn, source, 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.
+// 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.
@@ -5532,12 +5352,7 @@ function popProvider(context) {
{
const value = prevSnapshot.parentValue;
-
- if (value === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED) {
- prevSnapshot.context._currentValue2 = prevSnapshot.context._defaultValue;
- } else {
- prevSnapshot.context._currentValue2 = value;
- }
+ prevSnapshot.context._currentValue2 = value;
}
return currentActiveSnapshot = prevSnapshot.parent;
@@ -6478,124 +6293,364 @@ function useId() {
const treeId = getTreeId(task.treeContext);
const resumableState = currentResumableState;
- if (resumableState === null) {
- throw Error(formatProdErrorMessage(404));
- }
+ if (resumableState === null) {
+ throw Error(formatProdErrorMessage(404));
+ }
+
+ const localId = localIdCounter++;
+ return makeId(resumableState, treeId, localId);
+}
+
+function use(usable) {
+ if (usable !== null && typeof usable === 'object') {
+ // $FlowFixMe[method-unbinding]
+ if (typeof usable.then === 'function') {
+ // This is a thenable.
+ const thenable = usable;
+ return unwrapThenable(thenable);
+ } else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
+ const context = usable;
+ return readContext(context);
+ }
+ } // eslint-disable-next-line react-internal/safe-string-coercion
+
+
+ throw Error(formatProdErrorMessage(438, String(usable)));
+}
+
+function unwrapThenable(thenable) {
+ const index = thenableIndexCounter;
+ thenableIndexCounter += 1;
+
+ if (thenableState === null) {
+ thenableState = createThenableState();
+ }
+
+ return trackUsedThenable(thenableState, thenable, index);
+}
+
+function unsupportedRefresh() {
+ throw Error(formatProdErrorMessage(393));
+}
+
+function useCacheRefresh() {
+ return unsupportedRefresh;
+}
+
+function useMemoCache(size) {
+ const data = new Array(size);
+
+ for (let i = 0; i < size; i++) {
+ data[i] = REACT_MEMO_CACHE_SENTINEL;
+ }
+
+ return data;
+}
+
+function noop$1() {}
+
+const HooksDispatcher = {
+ readContext,
+ use,
+ useContext,
+ useMemo,
+ useReducer,
+ useRef,
+ useState,
+ useInsertionEffect: noop$1,
+ useLayoutEffect: noop$1,
+ 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,
+ useTransition,
+ useId,
+ // Subscriptions are not setup in a server environment.
+ useSyncExternalStore
+};
+
+{
+ HooksDispatcher.useCacheRefresh = useCacheRefresh;
+}
+
+{
+ HooksDispatcher.useEffectEvent = useEffectEvent;
+}
+
+{
+ HooksDispatcher.useMemoCache = useMemoCache;
+}
+
+{
+ HooksDispatcher.useHostTransitionStatus = useHostTransitionStatus;
+}
+
+{
+ HooksDispatcher.useOptimistic = useOptimistic;
+ HooksDispatcher.useFormState = useFormState;
+}
+
+let currentResumableState = null;
+function setCurrentResumableState(resumableState) {
+ currentResumableState = resumableState;
+}
+
+function getCacheSignal() {
+ throw Error(formatProdErrorMessage(248));
+}
+
+function getCacheForType(resourceType) {
+ throw Error(formatProdErrorMessage(248));
+}
+
+const DefaultCacheDispatcher = {
+ getCacheSignal,
+ 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];
+ }
- const localId = localIdCounter++;
- return makeId(resumableState, treeId, localId);
-}
+ }; // $FlowFixMe[prop-missing]
-function use(usable) {
- if (usable !== null && typeof usable === 'object') {
- // $FlowFixMe[method-unbinding]
- if (typeof usable.then === 'function') {
- // This is a thenable.
- const thenable = usable;
- return unwrapThenable(thenable);
- } else if (usable.$$typeof === REACT_CONTEXT_TYPE || usable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
- const context = usable;
- return readContext(context);
- }
- } // eslint-disable-next-line react-internal/safe-string-coercion
+ 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'
+ });
+ }
- throw Error(formatProdErrorMessage(438, String(usable)));
-}
+ try {
+ const _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(),
+ sampleStack = _RunInRootFrame$Deter[0],
+ controlStack = _RunInRootFrame$Deter[1];
-function unwrapThenable(thenable) {
- const index = thenableIndexCounter;
- thenableIndexCounter += 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;
- if (thenableState === null) {
- thenableState = createThenableState();
- }
+ while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) {
+ s++;
+ }
- return trackUsedThenable(thenableState, thenable, index);
-}
+ 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...
-function unsupportedRefresh() {
- throw Error(formatProdErrorMessage(393));
-}
-function useCacheRefresh() {
- return unsupportedRefresh;
-}
+ if (s === sampleLines.length || c === controlLines.length) {
+ s = sampleLines.length - 1;
+ c = controlLines.length - 1;
-function useMemoCache(size) {
- const data = new Array(size);
+ 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 (let i = 0; i < size; i++) {
- data[i] = REACT_MEMO_CACHE_SENTINEL;
- }
+ 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.
- return data;
-}
+ 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.
-function noop$1() {}
+ if (fn.displayName && frame.includes('')) {
+ frame = frame.replace('', fn.displayName);
+ }
-const HooksDispatcher = {
- readContext,
- use,
- useContext,
- useMemo,
- useReducer,
- useRef,
- useState,
- useInsertionEffect: noop$1,
- useLayoutEffect: noop$1,
- 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,
- useTransition,
- useId,
- // Subscriptions are not setup in a server environment.
- useSyncExternalStore
-};
+ if (false) ; // Return the line we found.
-{
- HooksDispatcher.useCacheRefresh = useCacheRefresh;
-}
-{
- HooksDispatcher.useEffectEvent = useEffectEvent;
-}
+ return frame;
+ }
+ } while (s >= 1 && c >= 0);
+ }
-{
- HooksDispatcher.useMemoCache = useMemoCache;
-}
+ break;
+ }
+ }
+ }
+ } finally {
+ reentry = false;
-{
- HooksDispatcher.useHostTransitionStatus = useHostTransitionStatus;
-}
+ Error.prepareStackTrace = previousPrepareStackTrace;
+ } // Fallback to just using the name if we couldn't make it throw.
-{
- HooksDispatcher.useOptimistic = useOptimistic;
- HooksDispatcher.useFormState = useFormState;
-}
-let currentResumableState = null;
-function setCurrentResumableState(resumableState) {
- currentResumableState = resumableState;
-}
+ const name = fn ? fn.displayName || fn.name : '';
+ const syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
-function getCacheSignal() {
- throw Error(formatProdErrorMessage(248));
+ return syntheticFrame;
}
-function getCacheForType(resourceType) {
- throw Error(formatProdErrorMessage(248));
+function describeClassComponentFrame(ctor, ownerFn) {
+ {
+ return describeNativeComponentFrame(ctor, true);
+ }
+}
+function describeFunctionComponentFrame(fn, ownerFn) {
+ {
+ return describeNativeComponentFrame(fn, false);
+ }
}
-
-const DefaultCacheDispatcher = {
- getCacheSignal,
- getCacheForType
-};
function getStackByComponentStackNode(componentStack) {
try {
@@ -6605,15 +6660,15 @@ function getStackByComponentStackNode(componentStack) {
do {
switch (node.tag) {
case 0:
- info += describeBuiltInComponentFrame(node.type, null, null);
+ info += describeBuiltInComponentFrame(node.type, null);
break;
case 1:
- info += describeFunctionComponentFrame(node.type, null, null);
+ info += describeFunctionComponentFrame(node.type, null);
break;
case 2:
- info += describeClassComponentFrame(node.type, null, null);
+ info += describeClassComponentFrame(node.type, null);
break;
} // $FlowFixMe[incompatible-type] we bail out when we get a null
@@ -6705,7 +6760,7 @@ function createRequest(children, resumableState, renderState, rootFormatContext,
false, false); // There is no parent so conceptually, we're unblocked to flush this segment.
rootSegment.parentFlushed = true;
- const rootTask = createRenderTask(request, null, children, -1, null, rootSegment, abortSet, null, rootFormatContext, emptyContextObject, rootContextSnapshot, emptyTreeContext, null);
+ const rootTask = createRenderTask(request, null, children, -1, null, rootSegment, null, abortSet, null, rootFormatContext, emptyContextObject, rootContextSnapshot, emptyTreeContext, null, false);
pingedTasks.push(rootTask);
return request;
}
@@ -6736,13 +6791,14 @@ function createSuspenseBoundary(request, fallbackAbortableTasks) {
byteSize: 0,
fallbackAbortableTasks,
errorDigest: null,
- resources: createBoundaryResources(),
+ contentState: createHoistableState(),
+ fallbackState: createHoistableState(),
trackedContentKeyPath: null,
trackedFallbackNode: null
};
}
-function createRenderTask(request, thenableState, node, childIndex, blockedBoundary, blockedSegment, abortSet, keyPath, formatContext, legacyContext, context, treeContext, componentStack) {
+function createRenderTask(request, thenableState, node, childIndex, blockedBoundary, blockedSegment, hoistableState, abortSet, keyPath, formatContext, legacyContext, context, treeContext, componentStack, isFallback) {
request.allPendingTasks++;
if (blockedBoundary === null) {
@@ -6758,6 +6814,7 @@ function createRenderTask(request, thenableState, node, childIndex, blockedBound
ping: () => pingTask(request, task),
blockedBoundary,
blockedSegment,
+ hoistableState,
abortSet,
keyPath,
formatContext,
@@ -6765,13 +6822,14 @@ function createRenderTask(request, thenableState, node, childIndex, blockedBound
context,
treeContext,
componentStack,
- thenableState
+ thenableState,
+ isFallback
};
abortSet.add(task);
return task;
}
-function createReplayTask(request, thenableState, replay, node, childIndex, blockedBoundary, abortSet, keyPath, formatContext, legacyContext, context, treeContext, componentStack) {
+function createReplayTask(request, thenableState, replay, node, childIndex, blockedBoundary, hoistableState, abortSet, keyPath, formatContext, legacyContext, context, treeContext, componentStack, isFallback) {
request.allPendingTasks++;
if (blockedBoundary === null) {
@@ -6788,6 +6846,7 @@ function createReplayTask(request, thenableState, replay, node, childIndex, bloc
ping: () => pingTask(request, task),
blockedBoundary,
blockedSegment: null,
+ hoistableState,
abortSet,
keyPath,
formatContext,
@@ -6795,7 +6854,8 @@ function createReplayTask(request, thenableState, replay, node, childIndex, bloc
context,
treeContext,
componentStack,
- thenableState
+ thenableState,
+ isFallback
};
abortSet.add(task);
return task;
@@ -6928,6 +6988,7 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
const suspenseComponentStack = task.componentStack = createBuiltInComponentStack(task, 'Suspense');
const prevKeyPath = task.keyPath;
const parentBoundary = task.blockedBoundary;
+ const parentHoistableState = task.hoistableState;
const parentSegment = task.blockedSegment; // Each time we enter a suspense boundary, we split out into a new segment for
// the fallback so that we can later replace that segment with the content.
// This also lets us split out the main content even if it doesn't suspend,
@@ -6963,12 +7024,8 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
// we're writing to. If something suspends, it'll spawn new suspended task with that context.
task.blockedBoundary = newBoundary;
+ task.hoistableState = newBoundary.contentState;
task.blockedSegment = contentRootSegment;
-
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, newBoundary.resources);
- }
-
task.keyPath = keyPath;
try {
@@ -7007,11 +7064,8 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
// We don't need to schedule any task because we know the parent has written yet.
// We do need to fallthrough to create the fallback though.
} finally {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, parentBoundary ? parentBoundary.resources : null);
- }
-
task.blockedBoundary = parentBoundary;
+ task.hoistableState = parentHoistableState;
task.blockedSegment = parentSegment;
task.keyPath = prevKeyPath;
task.componentStack = previousComponentStack;
@@ -7038,9 +7092,9 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
// on it yet in case we finish the main content, so we queue for later.
- const suspendedFallbackTask = createRenderTask(request, null, fallback, -1, parentBoundary, boundarySegment, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // This stack should be the Suspense boundary stack because while the fallback is actually a child segment
+ const suspendedFallbackTask = createRenderTask(request, null, fallback, -1, parentBoundary, boundarySegment, newBoundary.fallbackState, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // This stack should be the Suspense boundary stack because while the fallback is actually a child segment
// of the parent boundary from a component standpoint the fallback is a child of the Suspense boundary itself
- suspenseComponentStack); // TODO: This should be queued at a separate lower priority queue so that we only work
+ suspenseComponentStack, true); // TODO: This should be queued at a separate lower priority queue so that we only work
// on preparing fallbacks if we don't have any more main content to task on.
request.pingedTasks.push(suspendedFallbackTask);
@@ -7054,6 +7108,7 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c
const prevKeyPath = task.keyPath;
const previousReplaySet = task.replay;
const parentBoundary = task.blockedBoundary;
+ const parentHoistableState = task.hoistableState;
const content = props.children;
const fallback = props.fallback;
const fallbackAbortSet = new Set();
@@ -7065,16 +7120,13 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c
// we're writing to. If something suspends, it'll spawn new suspended task with that context.
task.blockedBoundary = resumedBoundary;
+ task.hoistableState = resumedBoundary.contentState;
task.replay = {
nodes: childNodes,
slots: childSlots,
pendingTasks: 1
};
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, resumedBoundary.resources);
- }
-
try {
// We use the safe form because we don't handle suspending here. Only error handling.
renderNode(request, task, content, -1);
@@ -7117,11 +7169,8 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c
// We don't need to schedule any task because we know the parent has written yet.
// We do need to fallthrough to create the fallback though.
} finally {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, parentBoundary ? parentBoundary.resources : null);
- }
-
task.blockedBoundary = parentBoundary;
+ task.hoistableState = parentHoistableState;
task.replay = previousReplaySet;
task.keyPath = prevKeyPath;
task.componentStack = previousComponentStack;
@@ -7135,9 +7184,9 @@ function replaySuspenseBoundary(request, task, keyPath, props, id, childNodes, c
slots: fallbackSlots,
pendingTasks: 0
};
- const suspendedFallbackTask = createReplayTask(request, null, fallbackReplay, fallback, -1, parentBoundary, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // This stack should be the Suspense boundary stack because while the fallback is actually a child segment
+ const suspendedFallbackTask = createReplayTask(request, null, fallbackReplay, fallback, -1, parentBoundary, resumedBoundary.fallbackState, fallbackAbortSet, fallbackKeyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // This stack should be the Suspense boundary stack because while the fallback is actually a child segment
// of the parent boundary from a component standpoint the fallback is a child of the Suspense boundary itself
- suspenseComponentStack); // TODO: This should be queued at a separate lower priority queue so that we only work
+ suspenseComponentStack, true); // TODO: This should be queued at a separate lower priority queue so that we only work
// on preparing fallbacks if we don't have any more main content to task on.
request.pingedTasks.push(suspendedFallbackTask);
@@ -7165,7 +7214,7 @@ function renderHostElement(request, task, keyPath, type, props) {
task.keyPath = prevKeyPath;
} else {
// Render
- const children = pushStartInstance(segment.chunks, type, props, request.resumableState, request.renderState, task.formatContext, segment.lastPushedText);
+ const children = pushStartInstance(segment.chunks, type, props, request.resumableState, request.renderState, task.hoistableState, task.formatContext, segment.lastPushedText, task.isFallback);
segment.lastPushedText = false;
const prevContext = task.formatContext;
const prevKeyPath = task.keyPath;
@@ -7189,7 +7238,12 @@ function shouldConstruct(Component) {
return Component.prototype && Component.prototype.isReactComponent;
}
-function renderWithHooks(request, task, keyPath, prevThenableState, Component, props, secondArg) {
+function renderWithHooks(request, task, keyPath, Component, props, secondArg) {
+ // Reset the task's thenable state before continuing, so that if a later
+ // component suspends we can reuse the same task object. If the same
+ // component suspends again, the thenable state will be restored.
+ const prevThenableState = task.thenableState;
+ task.thenableState = null;
const componentIdentity = {};
prepareToUseHooks(request, task, keyPath, componentIdentity, prevThenableState);
const result = Component(props, secondArg);
@@ -7206,7 +7260,7 @@ function finishClassComponent(request, task, keyPath, instance, Component, props
const previousContext = task.legacyContext;
const mergedContext = processChildContext(instance, Component, previousContext, childContextTypes);
task.legacyContext = mergedContext;
- renderNodeDestructive(request, task, null, nextChildren, -1);
+ renderNodeDestructive(request, task, nextChildren, -1);
task.legacyContext = previousContext;
return;
}
@@ -7214,7 +7268,7 @@ function finishClassComponent(request, task, keyPath, instance, Component, props
const prevKeyPath = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, nextChildren, -1);
+ renderNodeDestructive(request, task, nextChildren, -1);
task.keyPath = prevKeyPath;
}
@@ -7229,7 +7283,7 @@ function renderClassComponent(request, task, keyPath, Component, props) {
}
// components for some reason.
-function renderIndeterminateComponent(request, task, keyPath, prevThenableState, Component, props) {
+function renderIndeterminateComponent(request, task, keyPath, Component, props) {
let legacyContext;
{
@@ -7239,7 +7293,7 @@ function renderIndeterminateComponent(request, task, keyPath, prevThenableState,
const previousComponentStack = task.componentStack;
task.componentStack = createFunctionComponentStack(task, Component);
- const value = renderWithHooks(request, task, keyPath, prevThenableState, Component, props, legacyContext);
+ const value = renderWithHooks(request, task, keyPath, Component, props, legacyContext);
const hasId = checkDidRenderIdHook();
const formStateCount = getFormStateCount();
const formStateMatchingIndex = getFormStateMatchingIndex();
@@ -7306,7 +7360,7 @@ function finishFunctionComponent(request, task, keyPath, children, hasId, formSt
// We're now successfully past this task, and we haven't modified the
// context stack. We don't have to pop back to the previous task every
// again, so we can use the destructive recursive form.
- renderNodeDestructive(request, task, null, children, -1);
+ renderNodeDestructive(request, task, children, -1);
}
task.keyPath = prevKeyPath;
@@ -7330,10 +7384,30 @@ function resolveDefaultProps(Component, baseProps) {
return baseProps;
}
-function renderForwardRef(request, task, keyPath, prevThenableState, type, props, ref) {
+function renderForwardRef(request, task, keyPath, type, props, ref) {
const previousComponentStack = task.componentStack;
task.componentStack = createFunctionComponentStack(task, type.render);
- const children = renderWithHooks(request, task, keyPath, prevThenableState, type.render, props, ref);
+ let propsWithoutRef;
+
+ if ('ref' in props) {
+ // `ref` is just a prop now, but `forwardRef` expects it to not appear in
+ // the props object. This used to happen in the JSX runtime, but now we do
+ // it here.
+ propsWithoutRef = {};
+
+ for (const key in props) {
+ // Since `ref` should only appear in props via the JSX transform, we can
+ // assume that this is a plain object. So we don't need a
+ // hasOwnProperty check.
+ if (key !== 'ref') {
+ propsWithoutRef[key] = props[key];
+ }
+ }
+ } else {
+ propsWithoutRef = props;
+ }
+
+ const children = renderWithHooks(request, task, keyPath, type.render, propsWithoutRef, ref);
const hasId = checkDidRenderIdHook();
const formStateCount = getFormStateCount();
const formStateMatchingIndex = getFormStateMatchingIndex();
@@ -7341,45 +7415,43 @@ function renderForwardRef(request, task, keyPath, prevThenableState, type, props
task.componentStack = previousComponentStack;
}
-function renderMemo(request, task, keyPath, prevThenableState, type, props, ref) {
+function renderMemo(request, task, keyPath, type, props, ref) {
const innerType = type.type;
const resolvedProps = resolveDefaultProps(innerType, props);
- renderElement(request, task, keyPath, prevThenableState, innerType, resolvedProps, ref);
+ renderElement(request, task, keyPath, innerType, resolvedProps, ref);
}
function renderContextConsumer(request, task, keyPath, context, props) {
-
const render = props.children;
const newValue = readContext$1(context);
const newChildren = render(newValue);
const prevKeyPath = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, newChildren, -1);
+ renderNodeDestructive(request, task, newChildren, -1);
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;
const prevKeyPath = task.keyPath;
task.context = pushProvider(context, value);
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, children, -1);
+ renderNodeDestructive(request, task, children, -1);
task.context = popProvider();
task.keyPath = prevKeyPath;
}
-function renderLazyComponent(request, task, keyPath, prevThenableState, lazyComponent, props, ref) {
+function renderLazyComponent(request, task, keyPath, lazyComponent, props, ref) {
const previousComponentStack = task.componentStack;
task.componentStack = createBuiltInComponentStack(task, 'Lazy');
const payload = lazyComponent._payload;
const init = lazyComponent._init;
const Component = init(payload);
const resolvedProps = resolveDefaultProps(Component, props);
- renderElement(request, task, keyPath, prevThenableState, Component, resolvedProps, ref);
+ renderElement(request, task, keyPath, Component, resolvedProps, ref);
task.componentStack = previousComponentStack;
}
@@ -7391,18 +7463,18 @@ function renderOffscreen(request, task, keyPath, props) {
// pure indirection.
const prevKeyPath = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, props.children, -1);
+ renderNodeDestructive(request, task, props.children, -1);
task.keyPath = prevKeyPath;
}
}
-function renderElement(request, task, keyPath, prevThenableState, type, props, ref) {
+function renderElement(request, task, keyPath, type, props, ref) {
if (typeof type === 'function') {
if (shouldConstruct(type)) {
renderClassComponent(request, task, keyPath, type, props);
return;
} else {
- renderIndeterminateComponent(request, task, keyPath, prevThenableState, type, props);
+ renderIndeterminateComponent(request, task, keyPath, type, props);
return;
}
}
@@ -7430,7 +7502,7 @@ function renderElement(request, task, keyPath, prevThenableState, type, props, r
{
const prevKeyPath = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, props.children, -1);
+ renderNodeDestructive(request, task, props.children, -1);
task.keyPath = prevKeyPath;
return;
}
@@ -7448,7 +7520,7 @@ function renderElement(request, task, keyPath, prevThenableState, type, props, r
const prevKeyPath = task.keyPath;
task.keyPath = keyPath;
- renderNodeDestructive(request, task, null, props.children, -1);
+ renderNodeDestructive(request, task, props.children, -1);
task.keyPath = prevKeyPath;
task.componentStack = preiousComponentStack;
return;
@@ -7474,31 +7546,41 @@ function renderElement(request, task, keyPath, prevThenableState, type, props, r
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
{
- renderForwardRef(request, task, keyPath, prevThenableState, type, props, ref);
+ renderForwardRef(request, task, keyPath, type, props, ref);
return;
}
case REACT_MEMO_TYPE:
{
- renderMemo(request, task, keyPath, prevThenableState, type, props, ref);
+ renderMemo(request, task, keyPath, type, props, ref);
return;
}
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, prevThenableState, type, props);
+ renderLazyComponent(request, task, keyPath, type, props);
return;
}
}
@@ -7540,7 +7622,7 @@ function resumeNode(request, task, segmentId, node, childIndex) {
}
}
-function replayElement(request, task, keyPath, prevThenableState, name, keyOrIndex, childIndex, type, props, ref, replay) {
+function replayElement(request, task, keyPath, name, keyOrIndex, childIndex, type, props, ref, replay) {
// We're replaying. Find the path to follow.
const replayNodes = replay.nodes;
@@ -7569,7 +7651,7 @@ function replayElement(request, task, keyPath, prevThenableState, name, keyOrInd
};
try {
- renderElement(request, task, keyPath, prevThenableState, type, props, ref);
+ renderElement(request, task, keyPath, type, props, ref);
if (task.replay.pendingTasks === 1 && task.replay.nodes.length > 0 // TODO check remaining slots
) {
@@ -7621,9 +7703,7 @@ function replayElement(request, task, keyPath, prevThenableState, name, keyOrInd
// to update the current execution state.
-function renderNodeDestructive(request, task, // The thenable state reused from the previous attempt, if any. This is almost
-// always null, except when called by retryTask.
-prevThenableState, node, childIndex) {
+function renderNodeDestructive(request, task, node, childIndex) {
if (task.replay !== null && typeof task.replay.slots === 'number') {
// TODO: Figure out a cheaper place than this hot path to do this check.
const resumeSegmentID = task.replay.slots;
@@ -7634,9 +7714,14 @@ prevThenableState, node, childIndex) {
task.node = node;
- task.childIndex = childIndex; // Handle object types
+ task.childIndex = childIndex;
+
+ if (node === null) {
+ return;
+ } // Handle object types
+
- if (typeof node === 'object' && node !== null) {
+ if (typeof node === 'object') {
switch (node.$$typeof) {
case REACT_ELEMENT_TYPE:
{
@@ -7644,17 +7729,26 @@ prevThenableState, node, childIndex) {
const type = element.type;
const key = element.key;
const props = element.props;
- const ref = element.ref;
+ let ref;
+
+ {
+ // TODO: This is a temporary, intermediate step. Once the feature
+ // flag is removed, we should get the ref off the props object right
+ // before using it.
+ const refProp = props.ref;
+ ref = refProp !== undefined ? refProp : null;
+ }
+
const name = getComponentNameFromType(type);
const keyOrIndex = key == null ? childIndex === -1 ? 0 : childIndex : key;
const keyPath = [task.keyPath, name, keyOrIndex];
if (task.replay !== null) {
- replayElement(request, task, keyPath, prevThenableState, name, keyOrIndex, childIndex, type, props, ref, task.replay); // No matches found for this node. We assume it's already emitted in the
+ replayElement(request, task, keyPath, name, keyOrIndex, childIndex, type, props, ref, task.replay); // No matches found for this node. We assume it's already emitted in the
// prelude and skip it during the replay.
} else {
// We're doing a plain render.
- renderElement(request, task, keyPath, prevThenableState, type, props, ref);
+ renderElement(request, task, keyPath, type, props, ref);
}
return;
@@ -7675,7 +7769,7 @@ prevThenableState, node, childIndex) {
task.componentStack = previousComponentStack; // Now we render the resolved node
- renderNodeDestructive(request, task, null, resolvedNode, childIndex);
+ renderNodeDestructive(request, task, resolvedNode, childIndex);
return;
}
}
@@ -7727,13 +7821,15 @@ prevThenableState, node, childIndex) {
const maybeUsable = node;
if (typeof maybeUsable.then === 'function') {
+ // Clear any previous thenable state that was created by the unwrapping.
+ task.thenableState = null;
const thenable = maybeUsable;
- return renderNodeDestructive(request, task, null, unwrapThenable(thenable), childIndex);
+ return renderNodeDestructive(request, task, unwrapThenable(thenable), childIndex);
}
- if (maybeUsable.$$typeof === REACT_CONTEXT_TYPE || maybeUsable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
+ if (maybeUsable.$$typeof === REACT_CONTEXT_TYPE) {
const context = maybeUsable;
- return renderNodeDestructive(request, task, null, readContext$1(context), childIndex);
+ return renderNodeDestructive(request, task, readContext$1(context), childIndex);
} // $FlowFixMe[method-unbinding]
@@ -8049,9 +8145,9 @@ function injectPostponedHole(request, task, reason, thrownInfo) {
}
function spawnNewSuspendedReplayTask(request, task, thenableState, x) {
- const newTask = createReplayTask(request, thenableState, task.replay, task.node, task.childIndex, task.blockedBoundary, task.abortSet, task.keyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // We pop one task off the stack because the node that suspended will be tried again,
+ const newTask = createReplayTask(request, thenableState, task.replay, task.node, task.childIndex, task.blockedBoundary, task.hoistableState, task.abortSet, task.keyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // We pop one task off the stack because the node that suspended will be tried again,
// which will add it back onto the stack.
- task.componentStack !== null ? task.componentStack.parent : null);
+ task.componentStack !== null ? task.componentStack.parent : null, task.isFallback);
const ping = newTask.ping;
x.then(ping, ping);
}
@@ -8066,9 +8162,9 @@ function spawnNewSuspendedRenderTask(request, task, thenableState, x) {
segment.children.push(newSegment); // Reset lastPushedText for current Segment since the new Segment "consumed" it
segment.lastPushedText = false;
- const newTask = createRenderTask(request, thenableState, task.node, task.childIndex, task.blockedBoundary, newSegment, task.abortSet, task.keyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // We pop one task off the stack because the node that suspended will be tried again,
+ const newTask = createRenderTask(request, thenableState, task.node, task.childIndex, task.blockedBoundary, newSegment, task.hoistableState, task.abortSet, task.keyPath, task.formatContext, task.legacyContext, task.context, task.treeContext, // We pop one task off the stack because the node that suspended will be tried again,
// which will add it back onto the stack.
- task.componentStack !== null ? task.componentStack.parent : null);
+ task.componentStack !== null ? task.componentStack.parent : null, task.isFallback);
const ping = newTask.ping;
x.then(ping, ping);
} // This is a non-destructive form of rendering a node. If it suspends it spawns
@@ -8092,7 +8188,7 @@ function renderNode(request, task, node, childIndex) {
if (segment === null) {
// Replay
try {
- return renderNodeDestructive(request, task, null, node, childIndex);
+ return renderNodeDestructive(request, task, node, childIndex);
} catch (thrownValue) {
resetHooksState();
x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
@@ -8130,7 +8226,7 @@ function renderNode(request, task, node, childIndex) {
const chunkLength = segment.chunks.length;
try {
- return renderNodeDestructive(request, task, null, node, childIndex);
+ return renderNodeDestructive(request, task, node, childIndex);
} catch (thrownValue) {
resetHooksState(); // Reset the write pointers to where we started.
@@ -8355,8 +8451,16 @@ function abortTask(task, request, error) {
if (replay === null) {
// We didn't complete the root so we have nothing to show. We can close
// the request;
- logRecoverableError(request, error, errorInfo);
- fatalError(request, error);
+ if (typeof error === 'object' && error !== null && error.$$typeof === REACT_POSTPONE_TYPE) {
+ const postponeInstance = error;
+ const fatal = Error(formatProdErrorMessage(501, postponeInstance.message));
+ logRecoverableError(request, fatal, errorInfo);
+ fatalError(request, fatal);
+ } else {
+ logRecoverableError(request, error, errorInfo);
+ fatalError(request, error);
+ }
+
return;
} else {
// If the shell aborts during a replay, that's not a fatal error. Instead
@@ -8365,7 +8469,17 @@ function abortTask(task, request, error) {
replay.pendingTasks--;
if (replay.pendingTasks === 0 && replay.nodes.length > 0) {
- const errorDigest = logRecoverableError(request, error, errorInfo);
+ let errorDigest;
+
+ if (typeof error === 'object' && error !== null && error.$$typeof === REACT_POSTPONE_TYPE) {
+ const postponeInstance = error;
+ logPostpone(request, postponeInstance.message, errorInfo); // TODO: Figure out a better signal than a magic digest value.
+
+ errorDigest = 'POSTPONE';
+ } else {
+ errorDigest = logRecoverableError(request, error, errorInfo);
+ }
+
abortRemainingReplayNodes(request, null, replay.nodes, replay.slots, error, errorDigest);
}
@@ -8384,7 +8498,16 @@ function abortTask(task, request, error) {
// boundary the message is referring to
const errorInfo = getThrownInfo(request, task.componentStack);
- const errorDigest = logRecoverableError(request, error, errorInfo);
+ let errorDigest;
+
+ if (typeof error === 'object' && error !== null && error.$$typeof === REACT_POSTPONE_TYPE) {
+ const postponeInstance = error;
+ logPostpone(request, postponeInstance.message, errorInfo); // TODO: Figure out a better signal than a magic digest value.
+
+ errorDigest = 'POSTPONE';
+ } else {
+ errorDigest = logRecoverableError(request, error, errorInfo);
+ }
encodeErrorForBoundary(boundary, errorDigest);
untrackBoundary(request, boundary);
@@ -8547,11 +8670,6 @@ function finishedTask(request, boundary, segment) {
}
function retryTask(request, task) {
- {
- const blockedBoundary = task.blockedBoundary;
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, blockedBoundary ? blockedBoundary.resources : null);
- }
-
const segment = task.blockedSegment;
if (segment === null) {
@@ -8580,12 +8698,7 @@ function retryRenderTask(request, task, segment) {
try {
// We call the destructive form that mutates this task. That way if something
// suspends again, we can reuse the same task instead of spawning a new one.
- // Reset the task's thenable state before continuing, so that if a later
- // component suspends we can reuse the same task object. If the same
- // component suspends again, the thenable state will be restored.
- const prevThenableState = task.thenableState;
- task.thenableState = null;
- renderNodeDestructive(request, task, prevThenableState, task.node, task.childIndex);
+ renderNodeDestructive(request, task, task.node, task.childIndex);
pushSegmentFinale(segment.chunks, request.renderState, segment.lastPushedText, segment.textEmbedded);
task.abortSet.delete(task);
segment.status = COMPLETED;
@@ -8631,9 +8744,6 @@ function retryRenderTask(request, task, segment) {
erroredTask(request, task.blockedBoundary, x, errorInfo);
return;
} finally {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, null);
- }
}
}
@@ -8651,12 +8761,7 @@ function retryReplayTask(request, task) {
try {
// We call the destructive form that mutates this task. That way if something
// suspends again, we can reuse the same task instead of spawning a new one.
- // Reset the task's thenable state before continuing, so that if a later
- // component suspends we can reuse the same task object. If the same
- // component suspends again, the thenable state will be restored.
- const prevThenableState = task.thenableState;
- task.thenableState = null;
- renderNodeDestructive(request, task, prevThenableState, task.node, task.childIndex);
+ renderNodeDestructive(request, task, task.node, task.childIndex);
if (task.replay.pendingTasks === 1 && task.replay.nodes.length > 0) {
throw Error(formatProdErrorMessage(488));
@@ -8703,9 +8808,6 @@ function retryReplayTask(request, task) {
return;
} finally {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, null);
- }
}
}
@@ -8771,7 +8873,12 @@ function performWork(request) {
}
}
-function flushSubtree(request, destination, segment) {
+function flushPreamble(request, destination, rootSegment) {
+ const willFlushAllSegments = request.allPendingTasks === 0 && request.trackedPostpones === null;
+ writePreamble(destination, request.resumableState, request.renderState, willFlushAllSegments);
+}
+
+function flushSubtree(request, destination, segment, hoistableState) {
segment.parentFlushed = true;
switch (segment.status) {
@@ -8806,7 +8913,7 @@ function flushSubtree(request, destination, segment) {
writeChunk(destination, chunks[chunkIdx]);
}
- r = flushSegment(request, destination, nextChild);
+ r = flushSegment(request, destination, nextChild, hoistableState);
} // Finally just write all the remaining chunks
@@ -8828,12 +8935,12 @@ function flushSubtree(request, destination, segment) {
}
}
-function flushSegment(request, destination, segment) {
+function flushSegment(request, destination, segment, hoistableState) {
const boundary = segment.boundary;
if (boundary === null) {
// Not a suspense boundary.
- return flushSubtree(request, destination, segment);
+ return flushSubtree(request, destination, segment, hoistableState);
}
boundary.parentFlushed = true; // This segment is a Suspense boundary. We need to decide whether to
@@ -8844,7 +8951,7 @@ function flushSegment(request, destination, segment) {
// We never queue the inner boundary so we'll never emit its content or partial segments.
writeStartClientRenderedSuspenseBoundary(destination, request.renderState, boundary.errorDigest); // Flush the fallback.
- flushSubtree(request, destination, segment);
+ flushSubtree(request, destination, segment, hoistableState);
return writeEndClientRenderedSuspenseBoundary(destination, request.renderState);
} else if (boundary.status !== COMPLETED) {
if (boundary.status === PENDING) {
@@ -8860,9 +8967,17 @@ function flushSegment(request, destination, segment) {
const id = boundary.rootSegmentID;
- writeStartPendingSuspenseBoundary(destination, request.renderState, id); // Flush the fallback.
+ writeStartPendingSuspenseBoundary(destination, request.renderState, id); // We are going to flush the fallback so we need to hoist the fallback
+ // state to the parent boundary
+
+ {
+ if (hoistableState) {
+ hoistHoistables(hoistableState, boundary.fallbackState);
+ }
+ } // Flush the fallback.
- flushSubtree(request, destination, segment);
+
+ flushSubtree(request, destination, segment, hoistableState);
return writeEndPendingSuspenseBoundary(destination);
} else if (boundary.byteSize > request.progressiveChunkSize) {
// This boundary is large and will be emitted separately so that we can progressively show
@@ -8874,13 +8989,19 @@ function flushSegment(request, destination, segment) {
boundary.rootSegmentID = request.nextSegmentId++;
request.completedBoundaries.push(boundary); // Emit a pending rendered suspense boundary wrapper.
- writeStartPendingSuspenseBoundary(destination, request.renderState, boundary.rootSegmentID); // Flush the fallback.
+ writeStartPendingSuspenseBoundary(destination, request.renderState, boundary.rootSegmentID); // While we are going to flush the fallback we are going to follow it up with
+ // the completed boundary immediately so we make the choice to omit fallback
+ // boundary state from the parent since it will be replaced when the boundary
+ // flushes later in this pass or in a future flush
+ // Flush the fallback.
- flushSubtree(request, destination, segment);
+ flushSubtree(request, destination, segment, hoistableState);
return writeEndPendingSuspenseBoundary(destination);
} else {
{
- hoistResources(request.renderState, boundary.resources);
+ if (hoistableState) {
+ hoistHoistables(hoistableState, boundary.contentState);
+ }
} // We can inline this boundary's content as a complete boundary.
@@ -8892,7 +9013,7 @@ function flushSegment(request, destination, segment) {
}
const contentSegment = completedSegments[0];
- flushSegment(request, destination, contentSegment);
+ flushSegment(request, destination, contentSegment, hoistableState);
return writeEndCompletedSuspenseBoundary(destination, request.renderState);
}
}
@@ -8901,17 +9022,13 @@ function flushClientRenderedBoundary(request, destination, boundary) {
return writeClientRenderBoundaryInstruction(destination, request.resumableState, request.renderState, boundary.rootSegmentID, boundary.errorDigest, boundary.errorMessage, boundary.errorComponentStack);
}
-function flushSegmentContainer(request, destination, segment) {
+function flushSegmentContainer(request, destination, segment, hoistableState) {
writeStartSegment(destination, request.renderState, segment.parentFormatContext, segment.id);
- flushSegment(request, destination, segment);
+ flushSegment(request, destination, segment, hoistableState);
return writeEndSegment(destination, segment.parentFormatContext);
}
function flushCompletedBoundary(request, destination, boundary) {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, boundary.resources);
- }
-
const completedSegments = boundary.completedSegments;
let i = 0;
@@ -8923,17 +9040,13 @@ function flushCompletedBoundary(request, destination, boundary) {
completedSegments.length = 0;
{
- writeResourcesForBoundary(destination, boundary.resources, request.renderState);
+ writeHoistablesForBoundary(destination, boundary.contentState, request.renderState);
}
- return writeCompletedBoundaryInstruction(destination, request.resumableState, request.renderState, boundary.rootSegmentID, boundary.resources);
+ return writeCompletedBoundaryInstruction(destination, request.resumableState, request.renderState, boundary.rootSegmentID, boundary.contentState);
}
function flushPartialBoundary(request, destination, boundary) {
- {
- setCurrentlyRenderingBoundaryResourcesTarget(request.renderState, boundary.resources);
- }
-
const completedSegments = boundary.completedSegments;
let i = 0;
@@ -8952,11 +9065,7 @@ function flushPartialBoundary(request, destination, boundary) {
completedSegments.splice(0, i);
{
- // The way this is structured we only write resources for partial boundaries
- // if there is no backpressure. Later before we complete the boundary we
- // will write resources regardless of backpressure before we emit the
- // completion instruction
- return writeResourcesForBoundary(destination, boundary.resources, request.renderState);
+ return writeHoistablesForBoundary(destination, boundary.contentState, request.renderState);
}
}
@@ -8966,6 +9075,7 @@ function flushPartiallyCompletedSegment(request, destination, boundary, segment)
return true;
}
+ const hoistableState = boundary.contentState;
const segmentID = segment.id;
if (segmentID === -1) {
@@ -8977,13 +9087,13 @@ function flushPartiallyCompletedSegment(request, destination, boundary, segment)
throw Error(formatProdErrorMessage(392));
}
- return flushSegmentContainer(request, destination, segment);
+ return flushSegmentContainer(request, destination, segment, hoistableState);
} else if (segmentID === boundary.rootSegmentID) {
// When we emit postponed boundaries, we might have assigned the ID already
// but it's still the root segment so we can't inject it into the parent yet.
- return flushSegmentContainer(request, destination, segment);
+ return flushSegmentContainer(request, destination, segment, hoistableState);
} else {
- flushSegmentContainer(request, destination, segment);
+ flushSegmentContainer(request, destination, segment, hoistableState);
return writeCompletedSegmentInstruction(destination, request.resumableState, request.renderState, segmentID);
}
}
@@ -9004,10 +9114,10 @@ function flushCompletedQueues(request, destination) {
return;
} else if (request.pendingRootTasks === 0) {
if (enableFloat) {
- writePreamble(destination, request.resumableState, request.renderState, request.allPendingTasks === 0 && request.trackedPostpones === null);
+ flushPreamble(request, destination, completedRootSegment);
}
- flushSegment(request, destination, completedRootSegment);
+ flushSegment(request, destination, completedRootSegment, null);
request.completedRootSegment = null;
writeCompletedRoot(destination, request.renderState);
} else {
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 2e0d284577a705..4934a8bf842678 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,188 +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"),ca=require("react-dom");function q(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c>>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 w=Object.assign,z=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]*$"),ma={},na={};
-function oa(a){if(z.call(na,a))return!0;if(z.call(ma,a))return!1;if(ha.test(a))return na[a]=!0;ma[a]=!0;return!1}
-var Aa=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(" ")),Ba=
+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"]]),Ca=/["'&<>]/;
-function A(a){if("boolean"===typeof a||"number"===typeof a)return""+a;a=""+a;var b=Ca.exec(a);if(b){var c="",d,e=0;for(d=b.index;d")}
-function Eb(a,b,c,d,e,f,g,h){var k=null;"function"===typeof d&&("function"===typeof d.$$FORM_ACTION?(e=sb(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",'="',tb,'"'),g=f=e=d=h=null,Fb(b,c)));null!=h&&K(a,"name",h);null!=d&&K(a,"formAction",d);null!=e&&K(a,"formEncType",e);null!=f&&K(a,"formMethod",f);null!=g&&K(a,"formTarget",g);return k}
-function K(a,b,c){switch(b){case "className":J(a,"class",c);break;case "tabIndex":J(a,"tabindex",c);break;case "dir":case "role":case "viewBox":case "width":case "height":J(a,b,c);break;case "style":qb(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,'="',A(""+c),'"');break;case "defaultValue":case "defaultChecked":case "innerHTML":case "suppressContentEditableWarning":case "suppressHydrationWarning":break;
-case "autoFocus":case "multiple":case "muted":rb(a,b.toLowerCase(),c);break;case "xlinkHref":if("function"===typeof c||"symbol"===typeof c||"boolean"===typeof c)break;a.push(" ","xlink:href",'="',A(""+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,'="',A(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,'="',A(c),'"');break;case "cols":case "rows":case "size":case "span":"function"!==typeof c&&"symbol"!==typeof c&&!isNaN(c)&&1<=c&&a.push(" ",b,'="',A(c),'"');break;case "rowSpan":case "start":"function"===typeof c||"symbol"===typeof c||isNaN(c)||a.push(" ",b,'="',A(c),'"');break;case "xlinkActuate":J(a,"xlink:actuate",
-c);break;case "xlinkArcrole":J(a,"xlink:arcrole",c);break;case "xlinkRole":J(a,"xlink:role",c);break;case "xlinkShow":J(a,"xlink:show",c);break;case "xlinkTitle":J(a,"xlink:title",c);break;case "xlinkType":J(a,"xlink:type",c);break;case "xmlBase":J(a,"xml:base",c);break;case "xmlLang":J(a,"xml:lang",c);break;case "xmlSpace":J(a,"xml:space",c);break;default:if(!(2"))}
-function Hb(a,b,c,d,e,f,g){var h=b.rel,k=b.href,l=b.precedence;if(3===f||g||null!=b.itemProp||"string"!==typeof h||"string"!==typeof k||""===k)return N(a,b),null;if("stylesheet"===b.rel){if("string"!==typeof l||null!=b.disabled||b.onLoad||b.onError)return N(a,b);f=d.styles.get(l);g=c.styleResources.hasOwnProperty(k)?c.styleResources[k]:void 0;null!==g?(c.styleResources[k]=null,f||(f={precedence:A(l),rules:[],hrefs:[],sheets:new Map},d.styles.set(l,f)),b={state:0,props:w({},b,{"data-precedence":b.precedence,
-precedence:null})},g&&(2===g.length&&Ib(b.props,g),(c=d.preloads.stylesheets.get(k))&&0");return null}function Jb(a,b,c){a.push(O(c));for(var d in b)if(z.call(b,d)){var e=b[d];if(null!=e)switch(d){case "children":case "dangerouslySetInnerHTML":throw Error(q(399,c));default:K(a,d,e)}}a.push("/>");return null}
-function Kb(a,b){a.push(O("title"));var c=null,d=null,e;for(e in b)if(z.call(b,e)){var f=b[e];if(null!=f)switch(e){case "children":c=f;break;case "dangerouslySetInnerHTML":d=f;break;default:K(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(A(""+b));M(a,d,c);a.push(Lb("title"));return null}
-function Mb(a,b){a.push(O("script"));var c=null,d=null,e;for(e in b)if(z.call(b,e)){var f=b[e];if(null!=f)switch(e){case "children":c=f;break;case "dangerouslySetInnerHTML":d=f;break;default:K(a,e,f)}}a.push(">");M(a,d,c);"string"===typeof c&&a.push(A(c));a.push(Lb("script"));return null}
-function Nb(a,b,c){a.push(O(c));var d=c=null,e;for(e in b)if(z.call(b,e)){var f=b[e];if(null!=f)switch(e){case "children":c=f;break;case "dangerouslySetInnerHTML":d=f;break;default:K(a,e,f)}}a.push(">");M(a,d,c);return"string"===typeof c?(a.push(A(c)),null):c}var Ob=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Pb=new Map;function O(a){var b=Pb.get(a);if(void 0===b){if(!Ob.test(a))throw Error(q(65,a));b="<"+a;Pb.set(a,b)}return b}
-function Qb(a,b,c,d,e,f,g){switch(b){case "div":case "span":case "svg":case "path":case "a":case "g":case "p":case "li":break;case "select":a.push(O("select"));var h=null,k=null,l;for(l in c)if(z.call(c,l)){var m=c[l];if(null!=m)switch(l){case "children":h=m;break;case "dangerouslySetInnerHTML":k=m;break;case "defaultValue":case "value":break;default:K(a,l,m)}}a.push(">");M(a,k,h);return h;case "option":var p=f.selectedValue;a.push(O("option"));var n=null,r=null,D=null,B=null,y;for(y in c)if(z.call(c,
-y)){var v=c[y];if(null!=v)switch(y){case "children":n=v;break;case "selected":D=v;break;case "dangerouslySetInnerHTML":B=v;break;case "value":r=v;default:K(a,y,v)}}if(null!=p){var u=null!==r?""+r:Gb(n);if(Fa(p))for(var F=0;F");M(a,B,n);return n;case "textarea":a.push(O("textarea"));var x=null,t=null,E=null,P;for(P in c)if(z.call(c,P)){var G=c[P];if(null!=G)switch(P){case "children":E=
-G;break;case "value":x=G;break;case "defaultValue":t=G;break;case "dangerouslySetInnerHTML":throw Error(q(91));default:K(a,P,G)}}null===x&&null!==t&&(x=t);a.push(">");if(null!=E){if(null!=x)throw Error(q(92));if(Fa(E)){if(1");null!==ub&&ub.forEach(Db,a);return null;case "button":a.push(O("button"));var ra=null,sa=null,da=null,ta=null,ua=null,Xa=null,va=null,Ya;for(Ya in c)if(z.call(c,Ya)){var ea=c[Ya];if(null!=ea)switch(Ya){case "children":ra=ea;break;case "dangerouslySetInnerHTML":sa=ea;break;case "name":da=ea;break;case "formAction":ta=ea;break;case "formEncType":ua=ea;break;case "formMethod":Xa=ea;break;case "formTarget":va=ea;break;default:K(a,Ya,ea)}}var Vc=Eb(a,d,e,ta,ua,Xa,va,da);a.push(">");null!==
-Vc&&Vc.forEach(Db,a);M(a,sa,ra);if("string"===typeof ra){a.push(A(ra));var Wc=null}else Wc=ra;return Wc;case "form":a.push(O("form"));var Za=null,Xc=null,ka=null,$a=null,ab=null,bb=null,cb;for(cb in c)if(z.call(c,cb)){var la=c[cb];if(null!=la)switch(cb){case "children":Za=la;break;case "dangerouslySetInnerHTML":Xc=la;break;case "action":ka=la;break;case "encType":$a=la;break;case "method":ab=la;break;case "target":bb=la;break;default:K(a,cb,la)}}var ac=null,bc=null;if("function"===typeof ka)if("function"===
-typeof ka.$$FORM_ACTION){var Ee=sb(d),Ga=ka.$$FORM_ACTION(Ee);ka=Ga.action||"";$a=Ga.encType;ab=Ga.method;bb=Ga.target;ac=Ga.data;bc=Ga.name}else a.push(" ","action",'="',tb,'"'),bb=ab=$a=ka=null,Fb(d,e);null!=ka&&K(a,"action",ka);null!=$a&&K(a,"encType",$a);null!=ab&&K(a,"method",ab);null!=bb&&K(a,"target",bb);a.push(">");null!==bc&&(a.push('"),null!==ac&&ac.forEach(Db,a));M(a,Xc,Za);if("string"===typeof Za){a.push(A(Za));var Yc=null}else Yc=Za;return Yc;
-case "menuitem":a.push(O("menuitem"));for(var vb in c)if(z.call(c,vb)){var Zc=c[vb];if(null!=Zc)switch(vb){case "children":case "dangerouslySetInnerHTML":throw Error(q(400));default:K(a,vb,Zc)}}a.push(">");return null;case "title":if(3===f.insertionMode||f.tagScope&1||null!=c.itemProp)var $c=Kb(a,c);else Kb(e.hoistableChunks,c),$c=null;return $c;case "link":return Hb(a,c,d,e,g,f.insertionMode,!!(f.tagScope&1));case "script":var cc=c.async;if("string"!==typeof c.src||!c.src||!cc||"function"===typeof cc||
-"symbol"===typeof cc||c.onLoad||c.onError||3===f.insertionMode||f.tagScope&1||null!=c.itemProp)var ad=Mb(a,c);else{var wb=c.src;if("module"===c.type){var xb=d.moduleScriptResources;var bd=e.preloads.moduleScripts}else xb=d.scriptResources,bd=e.preloads.scripts;var yb=xb.hasOwnProperty(wb)?xb[wb]:void 0;if(null!==yb){xb[wb]=null;var dc=c;if(yb){2===yb.length&&(dc=w({},c),Ib(dc,yb));var cd=bd.get(wb);cd&&(cd.length=0)}var dd=[];e.scripts.add(dd);Mb(dd,dc)}g&&a.push("\x3c!-- --\x3e");ad=null}return ad;
-case "style":var zb=c.precedence,wa=c.href;if(3===f.insertionMode||f.tagScope&1||null!=c.itemProp||"string"!==typeof zb||"string"!==typeof wa||""===wa){a.push(O("style"));var Ha=null,ed=null,db;for(db in c)if(z.call(c,db)){var Ab=c[db];if(null!=Ab)switch(db){case "children":Ha=Ab;break;case "dangerouslySetInnerHTML":ed=Ab;break;default:K(a,db,Ab)}}a.push(">");var eb=Array.isArray(Ha)?2>Ha.length?Ha[0]:null:Ha;"function"!==typeof eb&&"symbol"!==typeof eb&&null!==eb&&void 0!==eb&&a.push(A(""+eb));M(a,
-ed,Ha);a.push(Lb("style"));var fd=null}else{var xa=e.styles.get(zb);if(null!==(d.styleResources.hasOwnProperty(wa)?d.styleResources[wa]:void 0)){d.styleResources[wa]=null;xa?xa.hrefs.push(A(wa)):(xa={precedence:A(zb),rules:[],hrefs:[A(wa)],sheets:new Map},e.styles.set(zb,xa));var gd=xa.rules,Ia=null,hd=null,Bb;for(Bb in c)if(z.call(c,Bb)){var ec=c[Bb];if(null!=ec)switch(Bb){case "children":Ia=ec;break;case "dangerouslySetInnerHTML":hd=ec}}var fb=Array.isArray(Ia)?2>Ia.length?Ia[0]:null:Ia;"function"!==
-typeof fb&&"symbol"!==typeof fb&&null!==fb&&void 0!==fb&&gd.push(A(""+fb));M(gd,hd,Ia)}xa&&e.boundaryResources&&e.boundaryResources.styles.add(xa);g&&a.push("\x3c!-- --\x3e");fd=void 0}return fd;case "meta":if(3===f.insertionMode||f.tagScope&1||null!=c.itemProp)var id=Jb(a,c,"meta");else g&&a.push("\x3c!-- --\x3e"),id="string"===typeof c.charSet?Jb(e.charsetChunks,c,"meta"):"viewport"===c.name?Jb(e.preconnectChunks,c,"meta"):Jb(e.hoistableChunks,c,"meta");return id;case "listing":case "pre":a.push(O(b));
-var gb=null,hb=null,ib;for(ib in c)if(z.call(c,ib)){var Cb=c[ib];if(null!=Cb)switch(ib){case "children":gb=Cb;break;case "dangerouslySetInnerHTML":hb=Cb;break;default:K(a,ib,Cb)}}a.push(">");if(null!=hb){if(null!=gb)throw Error(q(60));if("object"!==typeof hb||!("__html"in hb))throw Error(q(61));var ya=hb.__html;null!==ya&&void 0!==ya&&("string"===typeof ya&&0e.highImagePreloads.size)fc.delete(Ja),e.highImagePreloads.add(za)}else if(!d.imageResources.hasOwnProperty(Ja)){d.imageResources[Ja]=C;var gc=c.crossOrigin;var kd="string"===typeof gc?"use-credentials"===gc?gc:"":void 0;var aa=e.headers,hc;aa&&0aa.highImagePreloads.length)&&(hc=Rb(L,"image",{imageSrcSet:c.srcSet,imageSizes:c.sizes,crossOrigin:kd,integrity:c.integrity,nonce:c.nonce,type:c.type,
-fetchPriority:c.fetchPriority,referrerPolicy:c.refererPolicy}),2<=(aa.remainingCapacity-=hc.length))?(e.resets.image[Ja]=C,aa.highImagePreloads&&(aa.highImagePreloads+=", "),aa.highImagePreloads+=hc):(za=[],N(za,{rel:"preload",as:"image",href:I?void 0:L,imageSrcSet:I,imageSizes:jd,crossOrigin:kd,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),
-fc.set(Ja,za)))}}return Jb(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 Jb(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>f.insertionMode&&null===e.headChunks){e.headChunks=[];var ld=Nb(e.headChunks,c,"head")}else ld=Nb(a,c,"head");return ld;case "html":if(0===
-f.insertionMode&&null===e.htmlChunks){e.htmlChunks=[""];var md=Nb(e.htmlChunks,c,"html")}else md=Nb(a,c,"html");return md;default:if(-1!==b.indexOf("-")){a.push(O(b));var ic=null,nd=null,Ka;for(Ka in c)if(z.call(c,Ka)){var V=c[Ka];if(null!=V){var od=Ka;switch(Ka){case "children":ic=V;break;case "dangerouslySetInnerHTML":nd=V;break;case "style":qb(a,V);break;case "suppressContentEditableWarning":case "suppressHydrationWarning":break;case "className":od="class";default:if(oa(Ka)&&"function"!==typeof V&&
-"symbol"!==typeof V&&!1!==V){if(!0===V)V="";else if("object"===typeof V)continue;a.push(" ",od,'="',A(V),'"')}}}}a.push(">");M(a,nd,ic);return ic}}return Nb(a,c,b)}var Sb=new Map;function Lb(a){var b=Sb.get(a);void 0===b&&(b=""+a+">",Sb.set(a,b));return b}function Tb(a,b){b=b.bootstrapChunks;for(var c=0;c')}
-function Vb(a,b,c,d){switch(c.insertionMode){case 0:case 1:case 2:return a.push('