Handle line endings correctly on Windows in build script for RN (#26727)

## Summary

We added some post-processing in the build for RN in #26616 that broke
for users on Windows due to how line endings were handled to the regular
expression to insert some directives in the docblock. This fixes that
problem, reported in #26697 as well.

## How did you test this change?

Verified files are still built correctly on Mac/Linux. Will ask for help
to test on Windows.

DiffTrain build for [f87e97a0a6](https://github.com/facebook/react/commit/f87e97a0a67fa7cfd7e6f2ec985621c0e825cb23)
This commit is contained in:
josephsavona
2023-04-25 22:05:15 +00:00
parent 6c615dc833
commit db78d9be34
34 changed files with 28522 additions and 26186 deletions
+1 -1
View File
@@ -1 +1 @@
ded4a785b875d384f78efa28279550d86d93f54f
f87e97a0a67fa7cfd7e6f2ec985621c0e825cb23
+1 -1
View File
@@ -27,7 +27,7 @@ if (
}
"use strict";
var ReactVersion = "18.3.0-www-modern-95e6ae95";
var ReactVersion = "18.3.0-www-modern-bcc00dd5";
// ATTENTION
// When adding new symbols to this file,
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");
var ReactVersion = "18.3.0-www-classic-0673a8a9";
var ReactVersion = "18.3.0-www-classic-86d152c3";
// This refers to a WWW module.
var warningWWW = require("warning");
@@ -1228,7 +1228,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
warnedProperties[name] = true;
return true;
} // We can't rely on the event system being injected on the server.
}
if (eventRegistry != null) {
var registrationNameDependencies =
@@ -1755,14 +1755,14 @@ function escapeHtml(string) {
}
if (lastIndex !== index) {
html += str.substring(lastIndex, index);
html += str.slice(lastIndex, index);
}
lastIndex = index + 1;
html += escape;
}
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
} // end code copied and modified from escape-html
/**
@@ -2339,18 +2339,8 @@ var ReactDOMServerDispatcher = {
preload: preload,
preinit: preinit
};
var currentResources = null;
var currentResourcesStack = [];
function prepareToRender(resources) {
currentResourcesStack.push(currentResources);
currentResources = resources;
var previousHostDispatcher = ReactDOMCurrentDispatcher.current;
function prepareHostDispatcher() {
ReactDOMCurrentDispatcher.current = ReactDOMServerDispatcher;
return previousHostDispatcher;
}
function cleanupAfterRender(previousDispatcher) {
currentResources = currentResourcesStack.pop();
ReactDOMCurrentDispatcher.current = previousDispatcher;
} // Used to distinguish these contexts from ones used in other renderers.
var ScriptStreamingFormat = 0;
var DataStreamingFormat = 1;
@@ -2368,7 +2358,7 @@ var SentClientRenderFunction =
4;
var SentStyleInsertionFunction =
/* */
8; // Per response, global state that is not contextual to the rendering subtree.
8;
var dataElementQuotedEnd = stringToPrecomputedChunk('"></template>');
var startInlineScript = stringToPrecomputedChunk("<script>");
@@ -2815,6 +2805,47 @@ function pushStringAttribute(target, name, value) {
attributeEnd
);
}
} // Since this will likely be repeated a lot in the HTML, we use a more concise message
// than on the client and hopefully it's googleable.
stringToPrecomputedChunk(
escapeTextForBrowser(
// eslint-disable-next-line no-script-url
"javascript:throw new Error('A React form was unexpectedly submitted.')"
)
);
function pushFormActionAttribute(
target,
responseState,
formAction,
formEncType,
formMethod,
formTarget,
name
) {
{
// Plain form actions support all the properties, so we have to emit them.
if (name !== null) {
pushAttribute(target, "name", name);
}
if (formAction !== null) {
pushAttribute(target, "formAction", formAction);
}
if (formEncType !== null) {
pushAttribute(target, "formEncType", formEncType);
}
if (formMethod !== null) {
pushAttribute(target, "formMethod", formMethod);
}
if (formTarget !== null) {
pushAttribute(target, "formTarget", formTarget);
}
}
}
function pushAttribute(target, name, value) {
@@ -2848,37 +2879,39 @@ function pushAttribute(target, name, value) {
}
case "src":
case "href":
case "action": {
if (value === "") {
{
if (name === "src") {
error(
'An empty string ("") was passed to the %s attribute. ' +
"This may cause the browser to download the whole page again over the network. " +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
} else {
error(
'An empty string ("") was passed to the %s attribute. ' +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
case "href": {
{
if (value === "") {
{
if (name === "src") {
error(
'An empty string ("") was passed to the %s attribute. ' +
"This may cause the browser to download the whole page again over the network. " +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
} else {
error(
'An empty string ("") was passed to the %s attribute. ' +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
}
}
}
return;
return;
}
}
}
// Fall through to the last case which shouldn't remove empty strings.
case "action":
case "formAction": {
// TODO: Consider only special casing these for each tag.
if (
value == null ||
typeof value === "function" ||
@@ -3186,6 +3219,7 @@ var didWarnDefaultTextareaValue = false;
var didWarnInvalidOptionChildren = false;
var didWarnInvalidOptionInnerHTML = false;
var didWarnSelectedSetOnOption = false;
var didWarnFormActionType = false;
function checkSelectProp(props, propName) {
{
@@ -3417,50 +3451,98 @@ function pushStartOption(target, props, formatContext) {
return children;
}
function pushInput(target, props) {
{
checkControlledValueProps("input", props);
function pushStartForm(target, props, responseState) {
target.push(startChunkForTag("form"));
var children = null;
var innerHTML = null;
var formAction = null;
var formEncType = null;
var formMethod = null;
var formTarget = null;
if (
props.checked !== undefined &&
props.defaultChecked !== undefined &&
!didWarnDefaultChecked
) {
error(
"%s contains an input of type %s with both checked and defaultChecked props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the checked prop, or the defaultChecked prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
for (var propKey in props) {
if (hasOwnProperty.call(props, propKey)) {
var propValue = props[propKey];
didWarnDefaultChecked = true;
}
if (propValue == null) {
continue;
}
if (
props.value !== undefined &&
props.defaultValue !== undefined &&
!didWarnDefaultInputValue
) {
error(
"%s contains an input of type %s with both value and defaultValue props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the value prop, or the defaultValue prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
switch (propKey) {
case "children":
children = propValue;
break;
didWarnDefaultInputValue = true;
case "dangerouslySetInnerHTML":
innerHTML = propValue;
break;
case "action":
formAction = propValue;
break;
case "encType":
formEncType = propValue;
break;
case "method":
formMethod = propValue;
break;
case "target":
formTarget = propValue;
break;
default:
pushAttribute(target, propKey, propValue);
break;
}
}
}
{
// Plain form actions support all the properties, so we have to emit them.
if (formAction !== null) {
pushAttribute(target, "action", formAction);
}
if (formEncType !== null) {
pushAttribute(target, "encType", formEncType);
}
if (formMethod !== null) {
pushAttribute(target, "method", formMethod);
}
if (formTarget !== null) {
pushAttribute(target, "target", formTarget);
}
}
target.push(endOfStartTag);
pushInnerHTML(target, innerHTML, children);
if (typeof children === "string") {
// Special case children as a string to avoid the unnecessary comment.
// TODO: Remove this special case after the general optimization is in place.
target.push(stringToChunk(encodeHTMLTextNode(children)));
return null;
}
return children;
}
function pushInput(target, props, responseState) {
{
checkControlledValueProps("input", props);
}
target.push(startChunkForTag("input"));
var name = null;
var formAction = null;
var formEncType = null;
var formMethod = null;
var formTarget = null;
var value = null;
var defaultValue = null;
var checked = null;
@@ -3483,6 +3565,26 @@ function pushInput(target, props) {
"use `dangerouslySetInnerHTML`."
);
case "name":
name = propValue;
break;
case "formAction":
formAction = propValue;
break;
case "formEncType":
formEncType = propValue;
break;
case "formMethod":
formMethod = propValue;
break;
case "formTarget":
formTarget = propValue;
break;
case "defaultChecked":
defaultChecked = propValue;
break;
@@ -3506,6 +3608,63 @@ function pushInput(target, props) {
}
}
{
if (
formAction !== null &&
props.type !== "image" &&
props.type !== "submit" &&
!didWarnFormActionType
) {
didWarnFormActionType = true;
error(
'An input can only specify a formAction along with type="submit" or type="image".'
);
}
}
pushFormActionAttribute(
target,
responseState,
formAction,
formEncType,
formMethod,
formTarget,
name
);
{
if (checked !== null && defaultChecked !== null && !didWarnDefaultChecked) {
error(
"%s contains an input of type %s with both checked and defaultChecked props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the checked prop, or the defaultChecked prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
didWarnDefaultChecked = true;
}
if (value !== null && defaultValue !== null && !didWarnDefaultInputValue) {
error(
"%s contains an input of type %s with both value and defaultValue props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the value prop, or the defaultValue prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
didWarnDefaultInputValue = true;
}
}
if (checked !== null) {
pushBooleanAttribute(target, "checked", checked);
} else if (defaultChecked !== null) {
@@ -3522,6 +3681,97 @@ function pushInput(target, props) {
return null;
}
function pushStartButton(target, props, responseState) {
target.push(startChunkForTag("button"));
var children = null;
var innerHTML = null;
var name = null;
var formAction = null;
var formEncType = null;
var formMethod = null;
var formTarget = null;
for (var propKey in props) {
if (hasOwnProperty.call(props, propKey)) {
var propValue = props[propKey];
if (propValue == null) {
continue;
}
switch (propKey) {
case "children":
children = propValue;
break;
case "dangerouslySetInnerHTML":
innerHTML = propValue;
break;
case "name":
name = propValue;
break;
case "formAction":
formAction = propValue;
break;
case "formEncType":
formEncType = propValue;
break;
case "formMethod":
formMethod = propValue;
break;
case "formTarget":
formTarget = propValue;
break;
default:
pushAttribute(target, propKey, propValue);
break;
}
}
}
{
if (
formAction !== null &&
props.type != null &&
props.type !== "submit" &&
!didWarnFormActionType
) {
didWarnFormActionType = true;
error(
'A button can only specify a formAction along with type="submit" or no type.'
);
}
}
pushFormActionAttribute(
target,
responseState,
formAction,
formEncType,
formMethod,
formTarget,
name
);
target.push(endOfStartTag);
pushInnerHTML(target, innerHTML, children);
if (typeof children === "string") {
// Special case children as a string to avoid the unnecessary comment.
// TODO: Remove this special case after the general optimization is in place.
target.push(stringToChunk(encodeHTMLTextNode(children)));
return null;
}
return children;
}
function pushStartTextArea(target, props) {
{
checkControlledValueProps("textarea", props);
@@ -4879,7 +5129,13 @@ function pushStartInstance(
return pushStartTextArea(target, props);
case "input":
return pushInput(target, props);
return pushInput(target, props, responseState);
case "button":
return pushStartButton(target, props, responseState);
case "form":
return pushStartForm(target, props);
case "menuitem":
return pushStartMenuItem(target, props);
@@ -4966,7 +5222,7 @@ function pushStartInstance(
case "font-face-format":
case "font-face-name":
case "missing-glyph": {
return pushStartGenericElement(target, props, type);
break;
}
// Preamble start tags
@@ -5054,7 +5310,8 @@ function pushEndInstance(target, type, props, responseState, formatContext) {
target.push(endTag1, stringToChunk(type), endTag2);
}
function writeCompletedRoot(destination, responseState) {
function writeBootstrap(destination, responseState) {
var bootstrapChunks = responseState.bootstrapChunks;
var i = 0;
@@ -5063,10 +5320,16 @@ function writeCompletedRoot(destination, responseState) {
}
if (i < bootstrapChunks.length) {
return writeChunkAndReturn(destination, bootstrapChunks[i]);
var lastChunk = bootstrapChunks[i];
bootstrapChunks.length = 0;
return writeChunkAndReturn(destination, lastChunk);
}
return true;
}
function writeCompletedRoot(destination, responseState) {
return writeBootstrap(destination, responseState);
} // Structural Nodes
// A placeholder is a node inside a hidden partial tree that can be filled in later, but before
// display. It's never visible to users. We use the template tag because it can be used in every
@@ -5488,11 +5751,15 @@ function writeCompletedBoundaryInstruction(
}
}
var writeMore;
if (scriptFormat) {
return writeChunkAndReturn(destination, completeBoundaryScriptEnd);
writeMore = writeChunkAndReturn(destination, completeBoundaryScriptEnd);
} else {
return writeChunkAndReturn(destination, completeBoundaryDataEnd);
writeMore = writeChunkAndReturn(destination, completeBoundaryDataEnd);
}
return writeBootstrap(destination, responseState) && writeMore;
}
var clientRenderScript1Full = stringToPrecomputedChunk(
clientRenderBoundary + ';$RX("'
@@ -5914,10 +6181,7 @@ function writePreamble(
var _responseState$extern = responseState.externalRuntimeConfig,
src = _responseState$extern.src,
integrity = _responseState$extern.integrity;
preinitImpl(resources, src, {
as: "script",
integrity: integrity
});
internalPreinitScript(resources, src, integrity);
}
var htmlChunks = responseState.htmlChunks;
@@ -6577,17 +6841,18 @@ function getResourceKey(as, href) {
}
function prefetchDNS(href, options) {
if (!currentResources) {
// While we expect that preconnect calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
var resources = currentResources;
var resources = getResources(request);
{
if (typeof href !== "string" || !href) {
@@ -6632,20 +6897,22 @@ function prefetchDNS(href, options) {
}
resources.preconnects.add(resource);
flushResources(request);
}
}
function preconnect(href, options) {
if (!currentResources) {
// While we expect that preconnect calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
var resources = currentResources;
var resources = getResources(request);
{
if (typeof href !== "string" || !href) {
@@ -6696,20 +6963,22 @@ function preconnect(href, options) {
}
resources.preconnects.add(resource);
flushResources(request);
}
}
function preload(href, options) {
if (!currentResources) {
// While we expect that preload calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
var resources = currentResources;
var resources = getResources(request);
{
if (typeof href !== "string" || !href) {
@@ -6846,25 +7115,25 @@ function preload(href, options) {
resources.explicitOtherPreloads.add(resource);
}
}
flushResources(request);
}
}
function preinit(href, options) {
if (!currentResources) {
// While we expect that preinit calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
preinitImpl(currentResources, href, options);
} // On the server, preinit may be called outside of render when sending an
// external SSR runtime as part of the initial resources payload. Since this
// is an internal React call, we do not need to use the resources stack.
var resources = getResources(request);
function preinitImpl(resources, href, options) {
{
if (typeof href !== "string" || !href) {
error(
@@ -7029,6 +7298,7 @@ function preinitImpl(resources, href, options) {
}
precedenceSet.add(resource);
flushResources(request);
}
return;
@@ -7119,12 +7389,38 @@ function preinitImpl(resources, href, options) {
resources.scripts.add(_resource3);
pushScriptImpl(_resource3.chunks, _resourceProps);
flushResources(request);
}
return;
}
}
}
} // This method is trusted. It must only be called from within this codebase and it assumes the arguments
// conform to the types because no user input is being passed in. It also assumes that it is being called as
// part of a work or flush loop and therefore does not need to request Fizz to flush Resources.
function internalPreinitScript(resources, src, integrity) {
var key = getResourceKey("script", src);
var resource = resources.scriptsMap.get(key);
if (!resource) {
resource = {
type: "script",
chunks: [],
state: NoState,
props: null
};
resources.scriptsMap.set(key, resource);
resources.scripts.add(resource);
pushScriptImpl(resource.chunks, {
async: true,
src: src,
integrity: integrity
});
}
return;
}
function preloadPropsFromPreloadOptions(href, as, options) {
@@ -9819,6 +10115,7 @@ function noop$1() {}
var HooksDispatcher = {
readContext: readContext,
use: use,
useContext: useContext,
useMemo: useMemo,
useReducer: useReducer,
@@ -9853,10 +10150,6 @@ var HooksDispatcher = {
HooksDispatcher.useMemoCache = useMemoCache;
}
{
HooksDispatcher.use = use;
}
var currentResponseState = null;
function setCurrentResponseState(responseState) {
currentResponseState = responseState;
@@ -9951,11 +10244,13 @@ function createRequest(
onShellError,
onFatalError
) {
prepareHostDispatcher();
var pingedTasks = [];
var abortSet = new Set();
var resources = createResources();
var request = {
destination: null,
flushScheduled: false,
responseState: responseState,
progressiveChunkSize:
progressiveChunkSize === undefined
@@ -10004,12 +10299,19 @@ function createRequest(
pingedTasks.push(rootTask);
return request;
}
var currentRequest = null;
function resolveRequest() {
if (currentRequest) return currentRequest;
return null;
}
function pingTask(request, task) {
var pingedTasks = request.pingedTasks;
pingedTasks.push(task);
if (pingedTasks.length === 1) {
if (request.pingedTasks.length === 1) {
request.flushScheduled = request.destination !== null;
scheduleWork(function () {
return performWork(request);
});
@@ -11527,7 +11829,8 @@ function performWork(request) {
ReactCurrentCache.current = DefaultCacheDispatcher;
}
var previousHostDispatcher = prepareToRender(request.resources);
var prevRequest = currentRequest;
currentRequest = request;
var prevGetCurrentStackImpl;
{
@@ -11563,8 +11866,6 @@ function performWork(request) {
ReactCurrentCache.current = prevCacheDispatcher;
}
cleanupAfterRender(previousHostDispatcher);
{
ReactDebugCurrentFrame.getCurrentStack = prevGetCurrentStackImpl;
}
@@ -11579,6 +11880,8 @@ function performWork(request) {
// we'll to restore the context to what it was before returning.
switchContext(prevContext);
}
currentRequest = prevRequest;
}
}
@@ -11957,6 +12260,8 @@ function flushCompletedQueues(request, destination) {
request.completedBoundaries.length === 0 // We don't need to check any partially completed segments because
// either they have pending task or they're complete.
) {
request.flushScheduled = false;
{
writePostamble(destination, request.responseState);
}
@@ -11975,10 +12280,30 @@ function flushCompletedQueues(request, destination) {
}
function startWork(request) {
scheduleWork(function () {
return performWork(request);
});
request.flushScheduled = request.destination !== null;
{
scheduleWork(function () {
return performWork(request);
});
}
}
function enqueueFlush(request) {
if (
request.flushScheduled === false && // If there are pinged tasks we are going to flush anyway after work completes
request.pingedTasks.length === 0 && // If there is no destination there is nothing we can flush to. A flush will
// happen when we start flowing again
request.destination !== null
) {
var destination = request.destination;
request.flushScheduled = true;
scheduleWork(function () {
return flushCompletedQueues(request, destination);
});
}
}
function startFlowing(request, destination) {
if (request.status === CLOSING) {
request.status = CLOSED;
@@ -12028,6 +12353,12 @@ function abort(request, reason) {
fatalError(request, error);
}
}
function flushResources(request) {
enqueueFlush(request);
}
function getResources(request) {
return request.resources;
}
function onError() {
// Non-fatal errors are ignored.
+464 -133
View File
@@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");
var ReactVersion = "18.3.0-www-modern-8e893346";
var ReactVersion = "18.3.0-www-modern-a23c15ee";
// This refers to a WWW module.
var warningWWW = require("warning");
@@ -1228,7 +1228,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
warnedProperties[name] = true;
return true;
} // We can't rely on the event system being injected on the server.
}
if (eventRegistry != null) {
var registrationNameDependencies =
@@ -1755,14 +1755,14 @@ function escapeHtml(string) {
}
if (lastIndex !== index) {
html += str.substring(lastIndex, index);
html += str.slice(lastIndex, index);
}
lastIndex = index + 1;
html += escape;
}
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
} // end code copied and modified from escape-html
/**
@@ -2339,18 +2339,8 @@ var ReactDOMServerDispatcher = {
preload: preload,
preinit: preinit
};
var currentResources = null;
var currentResourcesStack = [];
function prepareToRender(resources) {
currentResourcesStack.push(currentResources);
currentResources = resources;
var previousHostDispatcher = ReactDOMCurrentDispatcher.current;
function prepareHostDispatcher() {
ReactDOMCurrentDispatcher.current = ReactDOMServerDispatcher;
return previousHostDispatcher;
}
function cleanupAfterRender(previousDispatcher) {
currentResources = currentResourcesStack.pop();
ReactDOMCurrentDispatcher.current = previousDispatcher;
} // Used to distinguish these contexts from ones used in other renderers.
var ScriptStreamingFormat = 0;
var DataStreamingFormat = 1;
@@ -2368,7 +2358,7 @@ var SentClientRenderFunction =
4;
var SentStyleInsertionFunction =
/* */
8; // Per response, global state that is not contextual to the rendering subtree.
8;
var dataElementQuotedEnd = stringToPrecomputedChunk('"></template>');
var startInlineScript = stringToPrecomputedChunk("<script>");
@@ -2815,6 +2805,47 @@ function pushStringAttribute(target, name, value) {
attributeEnd
);
}
} // Since this will likely be repeated a lot in the HTML, we use a more concise message
// than on the client and hopefully it's googleable.
stringToPrecomputedChunk(
escapeTextForBrowser(
// eslint-disable-next-line no-script-url
"javascript:throw new Error('A React form was unexpectedly submitted.')"
)
);
function pushFormActionAttribute(
target,
responseState,
formAction,
formEncType,
formMethod,
formTarget,
name
) {
{
// Plain form actions support all the properties, so we have to emit them.
if (name !== null) {
pushAttribute(target, "name", name);
}
if (formAction !== null) {
pushAttribute(target, "formAction", formAction);
}
if (formEncType !== null) {
pushAttribute(target, "formEncType", formEncType);
}
if (formMethod !== null) {
pushAttribute(target, "formMethod", formMethod);
}
if (formTarget !== null) {
pushAttribute(target, "formTarget", formTarget);
}
}
}
function pushAttribute(target, name, value) {
@@ -2848,37 +2879,39 @@ function pushAttribute(target, name, value) {
}
case "src":
case "href":
case "action": {
if (value === "") {
{
if (name === "src") {
error(
'An empty string ("") was passed to the %s attribute. ' +
"This may cause the browser to download the whole page again over the network. " +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
} else {
error(
'An empty string ("") was passed to the %s attribute. ' +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
case "href": {
{
if (value === "") {
{
if (name === "src") {
error(
'An empty string ("") was passed to the %s attribute. ' +
"This may cause the browser to download the whole page again over the network. " +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
} else {
error(
'An empty string ("") was passed to the %s attribute. ' +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
}
}
}
return;
return;
}
}
}
// Fall through to the last case which shouldn't remove empty strings.
case "action":
case "formAction": {
// TODO: Consider only special casing these for each tag.
if (
value == null ||
typeof value === "function" ||
@@ -3186,6 +3219,7 @@ var didWarnDefaultTextareaValue = false;
var didWarnInvalidOptionChildren = false;
var didWarnInvalidOptionInnerHTML = false;
var didWarnSelectedSetOnOption = false;
var didWarnFormActionType = false;
function checkSelectProp(props, propName) {
{
@@ -3417,50 +3451,98 @@ function pushStartOption(target, props, formatContext) {
return children;
}
function pushInput(target, props) {
{
checkControlledValueProps("input", props);
function pushStartForm(target, props, responseState) {
target.push(startChunkForTag("form"));
var children = null;
var innerHTML = null;
var formAction = null;
var formEncType = null;
var formMethod = null;
var formTarget = null;
if (
props.checked !== undefined &&
props.defaultChecked !== undefined &&
!didWarnDefaultChecked
) {
error(
"%s contains an input of type %s with both checked and defaultChecked props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the checked prop, or the defaultChecked prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
for (var propKey in props) {
if (hasOwnProperty.call(props, propKey)) {
var propValue = props[propKey];
didWarnDefaultChecked = true;
}
if (propValue == null) {
continue;
}
if (
props.value !== undefined &&
props.defaultValue !== undefined &&
!didWarnDefaultInputValue
) {
error(
"%s contains an input of type %s with both value and defaultValue props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the value prop, or the defaultValue prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
switch (propKey) {
case "children":
children = propValue;
break;
didWarnDefaultInputValue = true;
case "dangerouslySetInnerHTML":
innerHTML = propValue;
break;
case "action":
formAction = propValue;
break;
case "encType":
formEncType = propValue;
break;
case "method":
formMethod = propValue;
break;
case "target":
formTarget = propValue;
break;
default:
pushAttribute(target, propKey, propValue);
break;
}
}
}
{
// Plain form actions support all the properties, so we have to emit them.
if (formAction !== null) {
pushAttribute(target, "action", formAction);
}
if (formEncType !== null) {
pushAttribute(target, "encType", formEncType);
}
if (formMethod !== null) {
pushAttribute(target, "method", formMethod);
}
if (formTarget !== null) {
pushAttribute(target, "target", formTarget);
}
}
target.push(endOfStartTag);
pushInnerHTML(target, innerHTML, children);
if (typeof children === "string") {
// Special case children as a string to avoid the unnecessary comment.
// TODO: Remove this special case after the general optimization is in place.
target.push(stringToChunk(encodeHTMLTextNode(children)));
return null;
}
return children;
}
function pushInput(target, props, responseState) {
{
checkControlledValueProps("input", props);
}
target.push(startChunkForTag("input"));
var name = null;
var formAction = null;
var formEncType = null;
var formMethod = null;
var formTarget = null;
var value = null;
var defaultValue = null;
var checked = null;
@@ -3483,6 +3565,26 @@ function pushInput(target, props) {
"use `dangerouslySetInnerHTML`."
);
case "name":
name = propValue;
break;
case "formAction":
formAction = propValue;
break;
case "formEncType":
formEncType = propValue;
break;
case "formMethod":
formMethod = propValue;
break;
case "formTarget":
formTarget = propValue;
break;
case "defaultChecked":
defaultChecked = propValue;
break;
@@ -3506,6 +3608,63 @@ function pushInput(target, props) {
}
}
{
if (
formAction !== null &&
props.type !== "image" &&
props.type !== "submit" &&
!didWarnFormActionType
) {
didWarnFormActionType = true;
error(
'An input can only specify a formAction along with type="submit" or type="image".'
);
}
}
pushFormActionAttribute(
target,
responseState,
formAction,
formEncType,
formMethod,
formTarget,
name
);
{
if (checked !== null && defaultChecked !== null && !didWarnDefaultChecked) {
error(
"%s contains an input of type %s with both checked and defaultChecked props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the checked prop, or the defaultChecked prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
didWarnDefaultChecked = true;
}
if (value !== null && defaultValue !== null && !didWarnDefaultInputValue) {
error(
"%s contains an input of type %s with both value and defaultValue props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the value prop, or the defaultValue prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
didWarnDefaultInputValue = true;
}
}
if (checked !== null) {
pushBooleanAttribute(target, "checked", checked);
} else if (defaultChecked !== null) {
@@ -3522,6 +3681,97 @@ function pushInput(target, props) {
return null;
}
function pushStartButton(target, props, responseState) {
target.push(startChunkForTag("button"));
var children = null;
var innerHTML = null;
var name = null;
var formAction = null;
var formEncType = null;
var formMethod = null;
var formTarget = null;
for (var propKey in props) {
if (hasOwnProperty.call(props, propKey)) {
var propValue = props[propKey];
if (propValue == null) {
continue;
}
switch (propKey) {
case "children":
children = propValue;
break;
case "dangerouslySetInnerHTML":
innerHTML = propValue;
break;
case "name":
name = propValue;
break;
case "formAction":
formAction = propValue;
break;
case "formEncType":
formEncType = propValue;
break;
case "formMethod":
formMethod = propValue;
break;
case "formTarget":
formTarget = propValue;
break;
default:
pushAttribute(target, propKey, propValue);
break;
}
}
}
{
if (
formAction !== null &&
props.type != null &&
props.type !== "submit" &&
!didWarnFormActionType
) {
didWarnFormActionType = true;
error(
'A button can only specify a formAction along with type="submit" or no type.'
);
}
}
pushFormActionAttribute(
target,
responseState,
formAction,
formEncType,
formMethod,
formTarget,
name
);
target.push(endOfStartTag);
pushInnerHTML(target, innerHTML, children);
if (typeof children === "string") {
// Special case children as a string to avoid the unnecessary comment.
// TODO: Remove this special case after the general optimization is in place.
target.push(stringToChunk(encodeHTMLTextNode(children)));
return null;
}
return children;
}
function pushStartTextArea(target, props) {
{
checkControlledValueProps("textarea", props);
@@ -4879,7 +5129,13 @@ function pushStartInstance(
return pushStartTextArea(target, props);
case "input":
return pushInput(target, props);
return pushInput(target, props, responseState);
case "button":
return pushStartButton(target, props, responseState);
case "form":
return pushStartForm(target, props);
case "menuitem":
return pushStartMenuItem(target, props);
@@ -4966,7 +5222,7 @@ function pushStartInstance(
case "font-face-format":
case "font-face-name":
case "missing-glyph": {
return pushStartGenericElement(target, props, type);
break;
}
// Preamble start tags
@@ -5054,7 +5310,8 @@ function pushEndInstance(target, type, props, responseState, formatContext) {
target.push(endTag1, stringToChunk(type), endTag2);
}
function writeCompletedRoot(destination, responseState) {
function writeBootstrap(destination, responseState) {
var bootstrapChunks = responseState.bootstrapChunks;
var i = 0;
@@ -5063,10 +5320,16 @@ function writeCompletedRoot(destination, responseState) {
}
if (i < bootstrapChunks.length) {
return writeChunkAndReturn(destination, bootstrapChunks[i]);
var lastChunk = bootstrapChunks[i];
bootstrapChunks.length = 0;
return writeChunkAndReturn(destination, lastChunk);
}
return true;
}
function writeCompletedRoot(destination, responseState) {
return writeBootstrap(destination, responseState);
} // Structural Nodes
// A placeholder is a node inside a hidden partial tree that can be filled in later, but before
// display. It's never visible to users. We use the template tag because it can be used in every
@@ -5488,11 +5751,15 @@ function writeCompletedBoundaryInstruction(
}
}
var writeMore;
if (scriptFormat) {
return writeChunkAndReturn(destination, completeBoundaryScriptEnd);
writeMore = writeChunkAndReturn(destination, completeBoundaryScriptEnd);
} else {
return writeChunkAndReturn(destination, completeBoundaryDataEnd);
writeMore = writeChunkAndReturn(destination, completeBoundaryDataEnd);
}
return writeBootstrap(destination, responseState) && writeMore;
}
var clientRenderScript1Full = stringToPrecomputedChunk(
clientRenderBoundary + ';$RX("'
@@ -5914,10 +6181,7 @@ function writePreamble(
var _responseState$extern = responseState.externalRuntimeConfig,
src = _responseState$extern.src,
integrity = _responseState$extern.integrity;
preinitImpl(resources, src, {
as: "script",
integrity: integrity
});
internalPreinitScript(resources, src, integrity);
}
var htmlChunks = responseState.htmlChunks;
@@ -6577,17 +6841,18 @@ function getResourceKey(as, href) {
}
function prefetchDNS(href, options) {
if (!currentResources) {
// While we expect that preconnect calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
var resources = currentResources;
var resources = getResources(request);
{
if (typeof href !== "string" || !href) {
@@ -6632,20 +6897,22 @@ function prefetchDNS(href, options) {
}
resources.preconnects.add(resource);
flushResources(request);
}
}
function preconnect(href, options) {
if (!currentResources) {
// While we expect that preconnect calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
var resources = currentResources;
var resources = getResources(request);
{
if (typeof href !== "string" || !href) {
@@ -6696,20 +6963,22 @@ function preconnect(href, options) {
}
resources.preconnects.add(resource);
flushResources(request);
}
}
function preload(href, options) {
if (!currentResources) {
// While we expect that preload calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
var resources = currentResources;
var resources = getResources(request);
{
if (typeof href !== "string" || !href) {
@@ -6846,25 +7115,25 @@ function preload(href, options) {
resources.explicitOtherPreloads.add(resource);
}
}
flushResources(request);
}
}
function preinit(href, options) {
if (!currentResources) {
// While we expect that preinit calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
preinitImpl(currentResources, href, options);
} // On the server, preinit may be called outside of render when sending an
// external SSR runtime as part of the initial resources payload. Since this
// is an internal React call, we do not need to use the resources stack.
var resources = getResources(request);
function preinitImpl(resources, href, options) {
{
if (typeof href !== "string" || !href) {
error(
@@ -7029,6 +7298,7 @@ function preinitImpl(resources, href, options) {
}
precedenceSet.add(resource);
flushResources(request);
}
return;
@@ -7119,12 +7389,38 @@ function preinitImpl(resources, href, options) {
resources.scripts.add(_resource3);
pushScriptImpl(_resource3.chunks, _resourceProps);
flushResources(request);
}
return;
}
}
}
} // This method is trusted. It must only be called from within this codebase and it assumes the arguments
// conform to the types because no user input is being passed in. It also assumes that it is being called as
// part of a work or flush loop and therefore does not need to request Fizz to flush Resources.
function internalPreinitScript(resources, src, integrity) {
var key = getResourceKey("script", src);
var resource = resources.scriptsMap.get(key);
if (!resource) {
resource = {
type: "script",
chunks: [],
state: NoState,
props: null
};
resources.scriptsMap.set(key, resource);
resources.scripts.add(resource);
pushScriptImpl(resource.chunks, {
async: true,
src: src,
integrity: integrity
});
}
return;
}
function preloadPropsFromPreloadOptions(href, as, options) {
@@ -9578,6 +9874,7 @@ function noop$1() {}
var HooksDispatcher = {
readContext: readContext,
use: use,
useContext: useContext,
useMemo: useMemo,
useReducer: useReducer,
@@ -9612,10 +9909,6 @@ var HooksDispatcher = {
HooksDispatcher.useMemoCache = useMemoCache;
}
{
HooksDispatcher.use = use;
}
var currentResponseState = null;
function setCurrentResponseState(responseState) {
currentResponseState = responseState;
@@ -9710,11 +10003,13 @@ function createRequest(
onShellError,
onFatalError
) {
prepareHostDispatcher();
var pingedTasks = [];
var abortSet = new Set();
var resources = createResources();
var request = {
destination: null,
flushScheduled: false,
responseState: responseState,
progressiveChunkSize:
progressiveChunkSize === undefined
@@ -9763,12 +10058,19 @@ function createRequest(
pingedTasks.push(rootTask);
return request;
}
var currentRequest = null;
function resolveRequest() {
if (currentRequest) return currentRequest;
return null;
}
function pingTask(request, task) {
var pingedTasks = request.pingedTasks;
pingedTasks.push(task);
if (pingedTasks.length === 1) {
if (request.pingedTasks.length === 1) {
request.flushScheduled = request.destination !== null;
scheduleWork(function () {
return performWork(request);
});
@@ -11275,7 +11577,8 @@ function performWork(request) {
ReactCurrentCache.current = DefaultCacheDispatcher;
}
var previousHostDispatcher = prepareToRender(request.resources);
var prevRequest = currentRequest;
currentRequest = request;
var prevGetCurrentStackImpl;
{
@@ -11311,8 +11614,6 @@ function performWork(request) {
ReactCurrentCache.current = prevCacheDispatcher;
}
cleanupAfterRender(previousHostDispatcher);
{
ReactDebugCurrentFrame.getCurrentStack = prevGetCurrentStackImpl;
}
@@ -11327,6 +11628,8 @@ function performWork(request) {
// we'll to restore the context to what it was before returning.
switchContext(prevContext);
}
currentRequest = prevRequest;
}
}
@@ -11705,6 +12008,8 @@ function flushCompletedQueues(request, destination) {
request.completedBoundaries.length === 0 // We don't need to check any partially completed segments because
// either they have pending task or they're complete.
) {
request.flushScheduled = false;
{
writePostamble(destination, request.responseState);
}
@@ -11723,10 +12028,30 @@ function flushCompletedQueues(request, destination) {
}
function startWork(request) {
scheduleWork(function () {
return performWork(request);
});
request.flushScheduled = request.destination !== null;
{
scheduleWork(function () {
return performWork(request);
});
}
}
function enqueueFlush(request) {
if (
request.flushScheduled === false && // If there are pinged tasks we are going to flush anyway after work completes
request.pingedTasks.length === 0 && // If there is no destination there is nothing we can flush to. A flush will
// happen when we start flowing again
request.destination !== null
) {
var destination = request.destination;
request.flushScheduled = true;
scheduleWork(function () {
return flushCompletedQueues(request, destination);
});
}
}
function startFlowing(request, destination) {
if (request.status === CLOSING) {
request.status = CLOSED;
@@ -11776,6 +12101,12 @@ function abort(request, reason) {
fatalError(request, error);
}
}
function flushResources(request) {
enqueueFlush(request);
}
function getResources(request) {
return request.resources;
}
function onError() {
// Non-fatal errors are ignored.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1225,7 +1225,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
warnedProperties[name] = true;
return true;
} // We can't rely on the event system being injected on the server.
}
if (eventRegistry != null) {
var registrationNameDependencies =
@@ -1752,14 +1752,14 @@ function escapeHtml(string) {
}
if (lastIndex !== index) {
html += str.substring(lastIndex, index);
html += str.slice(lastIndex, index);
}
lastIndex = index + 1;
html += escape;
}
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
} // end code copied and modified from escape-html
/**
@@ -2336,18 +2336,8 @@ var ReactDOMServerDispatcher = {
preload: preload,
preinit: preinit
};
var currentResources = null;
var currentResourcesStack = [];
function prepareToRender(resources) {
currentResourcesStack.push(currentResources);
currentResources = resources;
var previousHostDispatcher = ReactDOMCurrentDispatcher.current;
function prepareHostDispatcher() {
ReactDOMCurrentDispatcher.current = ReactDOMServerDispatcher;
return previousHostDispatcher;
}
function cleanupAfterRender(previousDispatcher) {
currentResources = currentResourcesStack.pop();
ReactDOMCurrentDispatcher.current = previousDispatcher;
} // Used to distinguish these contexts from ones used in other renderers.
var ScriptStreamingFormat = 0;
var DataStreamingFormat = 1;
@@ -2365,7 +2355,7 @@ var SentClientRenderFunction =
4;
var SentStyleInsertionFunction =
/* */
8; // Per response, global state that is not contextual to the rendering subtree.
8;
var dataElementQuotedEnd = stringToPrecomputedChunk('"></template>');
var startInlineScript = stringToPrecomputedChunk("<script>");
@@ -2822,6 +2812,47 @@ function pushStringAttribute(target, name, value) {
attributeEnd
);
}
} // Since this will likely be repeated a lot in the HTML, we use a more concise message
// than on the client and hopefully it's googleable.
stringToPrecomputedChunk(
escapeTextForBrowser(
// eslint-disable-next-line no-script-url
"javascript:throw new Error('A React form was unexpectedly submitted.')"
)
);
function pushFormActionAttribute(
target,
responseState,
formAction,
formEncType,
formMethod,
formTarget,
name
) {
{
// Plain form actions support all the properties, so we have to emit them.
if (name !== null) {
pushAttribute(target, "name", name);
}
if (formAction !== null) {
pushAttribute(target, "formAction", formAction);
}
if (formEncType !== null) {
pushAttribute(target, "formEncType", formEncType);
}
if (formMethod !== null) {
pushAttribute(target, "formMethod", formMethod);
}
if (formTarget !== null) {
pushAttribute(target, "formTarget", formTarget);
}
}
}
function pushAttribute(target, name, value) {
@@ -2855,37 +2886,39 @@ function pushAttribute(target, name, value) {
}
case "src":
case "href":
case "action": {
if (value === "") {
{
if (name === "src") {
error(
'An empty string ("") was passed to the %s attribute. ' +
"This may cause the browser to download the whole page again over the network. " +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
} else {
error(
'An empty string ("") was passed to the %s attribute. ' +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
case "href": {
{
if (value === "") {
{
if (name === "src") {
error(
'An empty string ("") was passed to the %s attribute. ' +
"This may cause the browser to download the whole page again over the network. " +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
} else {
error(
'An empty string ("") was passed to the %s attribute. ' +
"To fix this, either do not render the element at all " +
"or pass null to %s instead of an empty string.",
name,
name
);
}
}
}
return;
return;
}
}
}
// Fall through to the last case which shouldn't remove empty strings.
case "action":
case "formAction": {
// TODO: Consider only special casing these for each tag.
if (
value == null ||
typeof value === "function" ||
@@ -3193,6 +3226,7 @@ var didWarnDefaultTextareaValue = false;
var didWarnInvalidOptionChildren = false;
var didWarnInvalidOptionInnerHTML = false;
var didWarnSelectedSetOnOption = false;
var didWarnFormActionType = false;
function checkSelectProp(props, propName) {
{
@@ -3424,50 +3458,98 @@ function pushStartOption(target, props, formatContext) {
return children;
}
function pushInput(target, props) {
{
checkControlledValueProps("input", props);
function pushStartForm(target, props, responseState) {
target.push(startChunkForTag("form"));
var children = null;
var innerHTML = null;
var formAction = null;
var formEncType = null;
var formMethod = null;
var formTarget = null;
if (
props.checked !== undefined &&
props.defaultChecked !== undefined &&
!didWarnDefaultChecked
) {
error(
"%s contains an input of type %s with both checked and defaultChecked props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the checked prop, or the defaultChecked prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
for (var propKey in props) {
if (hasOwnProperty.call(props, propKey)) {
var propValue = props[propKey];
didWarnDefaultChecked = true;
}
if (propValue == null) {
continue;
}
if (
props.value !== undefined &&
props.defaultValue !== undefined &&
!didWarnDefaultInputValue
) {
error(
"%s contains an input of type %s with both value and defaultValue props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the value prop, or the defaultValue prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
switch (propKey) {
case "children":
children = propValue;
break;
didWarnDefaultInputValue = true;
case "dangerouslySetInnerHTML":
innerHTML = propValue;
break;
case "action":
formAction = propValue;
break;
case "encType":
formEncType = propValue;
break;
case "method":
formMethod = propValue;
break;
case "target":
formTarget = propValue;
break;
default:
pushAttribute(target, propKey, propValue);
break;
}
}
}
{
// Plain form actions support all the properties, so we have to emit them.
if (formAction !== null) {
pushAttribute(target, "action", formAction);
}
if (formEncType !== null) {
pushAttribute(target, "encType", formEncType);
}
if (formMethod !== null) {
pushAttribute(target, "method", formMethod);
}
if (formTarget !== null) {
pushAttribute(target, "target", formTarget);
}
}
target.push(endOfStartTag);
pushInnerHTML(target, innerHTML, children);
if (typeof children === "string") {
// Special case children as a string to avoid the unnecessary comment.
// TODO: Remove this special case after the general optimization is in place.
target.push(stringToChunk(encodeHTMLTextNode(children)));
return null;
}
return children;
}
function pushInput(target, props, responseState) {
{
checkControlledValueProps("input", props);
}
target.push(startChunkForTag("input"));
var name = null;
var formAction = null;
var formEncType = null;
var formMethod = null;
var formTarget = null;
var value = null;
var defaultValue = null;
var checked = null;
@@ -3490,6 +3572,26 @@ function pushInput(target, props) {
"use `dangerouslySetInnerHTML`."
);
case "name":
name = propValue;
break;
case "formAction":
formAction = propValue;
break;
case "formEncType":
formEncType = propValue;
break;
case "formMethod":
formMethod = propValue;
break;
case "formTarget":
formTarget = propValue;
break;
case "defaultChecked":
defaultChecked = propValue;
break;
@@ -3513,6 +3615,63 @@ function pushInput(target, props) {
}
}
{
if (
formAction !== null &&
props.type !== "image" &&
props.type !== "submit" &&
!didWarnFormActionType
) {
didWarnFormActionType = true;
error(
'An input can only specify a formAction along with type="submit" or type="image".'
);
}
}
pushFormActionAttribute(
target,
responseState,
formAction,
formEncType,
formMethod,
formTarget,
name
);
{
if (checked !== null && defaultChecked !== null && !didWarnDefaultChecked) {
error(
"%s contains an input of type %s with both checked and defaultChecked props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the checked prop, or the defaultChecked prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
didWarnDefaultChecked = true;
}
if (value !== null && defaultValue !== null && !didWarnDefaultInputValue) {
error(
"%s contains an input of type %s with both value and defaultValue props. " +
"Input elements must be either controlled or uncontrolled " +
"(specify either the value prop, or the defaultValue prop, but not " +
"both). Decide between using a controlled or uncontrolled input " +
"element and remove one of these props. More info: " +
"https://reactjs.org/link/controlled-components",
"A component",
props.type
);
didWarnDefaultInputValue = true;
}
}
if (checked !== null) {
pushBooleanAttribute(target, "checked", checked);
} else if (defaultChecked !== null) {
@@ -3529,6 +3688,97 @@ function pushInput(target, props) {
return null;
}
function pushStartButton(target, props, responseState) {
target.push(startChunkForTag("button"));
var children = null;
var innerHTML = null;
var name = null;
var formAction = null;
var formEncType = null;
var formMethod = null;
var formTarget = null;
for (var propKey in props) {
if (hasOwnProperty.call(props, propKey)) {
var propValue = props[propKey];
if (propValue == null) {
continue;
}
switch (propKey) {
case "children":
children = propValue;
break;
case "dangerouslySetInnerHTML":
innerHTML = propValue;
break;
case "name":
name = propValue;
break;
case "formAction":
formAction = propValue;
break;
case "formEncType":
formEncType = propValue;
break;
case "formMethod":
formMethod = propValue;
break;
case "formTarget":
formTarget = propValue;
break;
default:
pushAttribute(target, propKey, propValue);
break;
}
}
}
{
if (
formAction !== null &&
props.type != null &&
props.type !== "submit" &&
!didWarnFormActionType
) {
didWarnFormActionType = true;
error(
'A button can only specify a formAction along with type="submit" or no type.'
);
}
}
pushFormActionAttribute(
target,
responseState,
formAction,
formEncType,
formMethod,
formTarget,
name
);
target.push(endOfStartTag);
pushInnerHTML(target, innerHTML, children);
if (typeof children === "string") {
// Special case children as a string to avoid the unnecessary comment.
// TODO: Remove this special case after the general optimization is in place.
target.push(stringToChunk(encodeHTMLTextNode(children)));
return null;
}
return children;
}
function pushStartTextArea(target, props) {
{
checkControlledValueProps("textarea", props);
@@ -4886,7 +5136,13 @@ function pushStartInstance(
return pushStartTextArea(target, props);
case "input":
return pushInput(target, props);
return pushInput(target, props, responseState);
case "button":
return pushStartButton(target, props, responseState);
case "form":
return pushStartForm(target, props);
case "menuitem":
return pushStartMenuItem(target, props);
@@ -4973,7 +5229,7 @@ function pushStartInstance(
case "font-face-format":
case "font-face-name":
case "missing-glyph": {
return pushStartGenericElement(target, props, type);
break;
}
// Preamble start tags
@@ -5061,7 +5317,8 @@ function pushEndInstance(target, type, props, responseState, formatContext) {
target.push(endTag1, stringToChunk(type), endTag2);
}
function writeCompletedRoot(destination, responseState) {
function writeBootstrap(destination, responseState) {
var bootstrapChunks = responseState.bootstrapChunks;
var i = 0;
@@ -5070,10 +5327,16 @@ function writeCompletedRoot(destination, responseState) {
}
if (i < bootstrapChunks.length) {
return writeChunkAndReturn(destination, bootstrapChunks[i]);
var lastChunk = bootstrapChunks[i];
bootstrapChunks.length = 0;
return writeChunkAndReturn(destination, lastChunk);
}
return true;
}
function writeCompletedRoot(destination, responseState) {
return writeBootstrap(destination, responseState);
} // Structural Nodes
// A placeholder is a node inside a hidden partial tree that can be filled in later, but before
// display. It's never visible to users. We use the template tag because it can be used in every
@@ -5495,11 +5758,15 @@ function writeCompletedBoundaryInstruction(
}
}
var writeMore;
if (scriptFormat) {
return writeChunkAndReturn(destination, completeBoundaryScriptEnd);
writeMore = writeChunkAndReturn(destination, completeBoundaryScriptEnd);
} else {
return writeChunkAndReturn(destination, completeBoundaryDataEnd);
writeMore = writeChunkAndReturn(destination, completeBoundaryDataEnd);
}
return writeBootstrap(destination, responseState) && writeMore;
}
var clientRenderScript1Full = stringToPrecomputedChunk(
clientRenderBoundary + ';$RX("'
@@ -5921,10 +6188,7 @@ function writePreamble(
var _responseState$extern = responseState.externalRuntimeConfig,
src = _responseState$extern.src,
integrity = _responseState$extern.integrity;
preinitImpl(resources, src, {
as: "script",
integrity: integrity
});
internalPreinitScript(resources, src, integrity);
}
var htmlChunks = responseState.htmlChunks;
@@ -6584,17 +6848,18 @@ function getResourceKey(as, href) {
}
function prefetchDNS(href, options) {
if (!currentResources) {
// While we expect that preconnect calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
var resources = currentResources;
var resources = getResources(request);
{
if (typeof href !== "string" || !href) {
@@ -6639,20 +6904,22 @@ function prefetchDNS(href, options) {
}
resources.preconnects.add(resource);
flushResources(request);
}
}
function preconnect(href, options) {
if (!currentResources) {
// While we expect that preconnect calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
var resources = currentResources;
var resources = getResources(request);
{
if (typeof href !== "string" || !href) {
@@ -6703,20 +6970,22 @@ function preconnect(href, options) {
}
resources.preconnects.add(resource);
flushResources(request);
}
}
function preload(href, options) {
if (!currentResources) {
// While we expect that preload calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
var resources = currentResources;
var resources = getResources(request);
{
if (typeof href !== "string" || !href) {
@@ -6853,25 +7122,25 @@ function preload(href, options) {
resources.explicitOtherPreloads.add(resource);
}
}
flushResources(request);
}
}
function preinit(href, options) {
if (!currentResources) {
// While we expect that preinit calls are primarily going to be observed
// during render because effects and events don't run on the server it is
// still possible that these get called in module scope. This is valid on
// the client since there is still a document to interact with but on the
// server we need a request to associate the call to. Because of this we
// simply return and do not warn.
var request = resolveRequest();
if (!request) {
// In async contexts we can sometimes resolve resources from AsyncLocalStorage. If we can't we can also
// possibly get them from the stack if we are not in an async context. Since we were not able to resolve
// the resources for this call in either case we opt to do nothing. We can consider making this a warning
// but there may be times where calling a function outside of render is intentional (i.e. to warm up data
// fetching) and we don't want to warn in those cases.
return;
}
preinitImpl(currentResources, href, options);
} // On the server, preinit may be called outside of render when sending an
// external SSR runtime as part of the initial resources payload. Since this
// is an internal React call, we do not need to use the resources stack.
var resources = getResources(request);
function preinitImpl(resources, href, options) {
{
if (typeof href !== "string" || !href) {
error(
@@ -7036,6 +7305,7 @@ function preinitImpl(resources, href, options) {
}
precedenceSet.add(resource);
flushResources(request);
}
return;
@@ -7126,12 +7396,38 @@ function preinitImpl(resources, href, options) {
resources.scripts.add(_resource3);
pushScriptImpl(_resource3.chunks, _resourceProps);
flushResources(request);
}
return;
}
}
}
} // This method is trusted. It must only be called from within this codebase and it assumes the arguments
// conform to the types because no user input is being passed in. It also assumes that it is being called as
// part of a work or flush loop and therefore does not need to request Fizz to flush Resources.
function internalPreinitScript(resources, src, integrity) {
var key = getResourceKey("script", src);
var resource = resources.scriptsMap.get(key);
if (!resource) {
resource = {
type: "script",
chunks: [],
state: NoState,
props: null
};
resources.scriptsMap.set(key, resource);
resources.scripts.add(resource);
pushScriptImpl(resource.chunks, {
async: true,
src: src,
integrity: integrity
});
}
return;
}
function preloadPropsFromPreloadOptions(href, as, options) {
@@ -9470,6 +9766,7 @@ function noop$1() {}
var HooksDispatcher = {
readContext: readContext,
use: use,
useContext: useContext,
useMemo: useMemo,
useReducer: useReducer,
@@ -9504,10 +9801,6 @@ var HooksDispatcher = {
HooksDispatcher.useMemoCache = useMemoCache;
}
{
HooksDispatcher.use = use;
}
var currentResponseState = null;
function setCurrentResponseState(responseState) {
currentResponseState = responseState;
@@ -9602,11 +9895,13 @@ function createRequest(
onShellError,
onFatalError
) {
prepareHostDispatcher();
var pingedTasks = [];
var abortSet = new Set();
var resources = createResources();
var request = {
destination: null,
flushScheduled: false,
responseState: responseState,
progressiveChunkSize:
progressiveChunkSize === undefined
@@ -9655,10 +9950,20 @@ function createRequest(
pingedTasks.push(rootTask);
return request;
}
var currentRequest = null;
function resolveRequest() {
if (currentRequest) return currentRequest;
return null;
}
function pingTask(request, task) {
var pingedTasks = request.pingedTasks;
pingedTasks.push(task);
if (request.pingedTasks.length === 1) {
request.flushScheduled = request.destination !== null;
}
}
function createSuspenseBoundary(request, fallbackAbortableTasks) {
@@ -11161,7 +11466,8 @@ function performWork(request) {
ReactCurrentCache.current = DefaultCacheDispatcher;
}
var previousHostDispatcher = prepareToRender(request.resources);
var prevRequest = currentRequest;
currentRequest = request;
var prevGetCurrentStackImpl;
{
@@ -11197,8 +11503,6 @@ function performWork(request) {
ReactCurrentCache.current = prevCacheDispatcher;
}
cleanupAfterRender(previousHostDispatcher);
{
ReactDebugCurrentFrame.getCurrentStack = prevGetCurrentStackImpl;
}
@@ -11213,6 +11517,8 @@ function performWork(request) {
// we'll to restore the context to what it was before returning.
switchContext(prevContext);
}
currentRequest = prevRequest;
}
}
@@ -11585,6 +11891,8 @@ function flushCompletedQueues(request, destination) {
request.completedBoundaries.length === 0 // We don't need to check any partially completed segments because
// either they have pending task or they're complete.
) {
request.flushScheduled = false;
{
writePostamble(destination, request.responseState);
}
@@ -11601,6 +11909,22 @@ function flushCompletedQueues(request, destination) {
}
}
}
function startWork(request) {
request.flushScheduled = request.destination !== null;
}
function enqueueFlush(request) {
if (
request.flushScheduled === false && // If there are pinged tasks we are going to flush anyway after work completes
request.pingedTasks.length === 0 && // If there is no destination there is nothing we can flush to. A flush will
// happen when we start flowing again
request.destination !== null
) {
request.flushScheduled = true;
}
}
function startFlowing(request, destination) {
if (request.status === CLOSING) {
request.status = CLOSED;
@@ -11650,6 +11974,12 @@ function abort(request, reason) {
fatalError(request, error);
}
}
function flushResources(request) {
enqueueFlush(request);
}
function getResources(request) {
return request.resources;
}
function renderToStream(children, options) {
var destination = {
@@ -11674,6 +12004,7 @@ function renderToStream(children, options) {
undefined,
undefined
);
startWork(request);
if (destination.fatal) {
throw destination.error;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -17,6 +17,7 @@ if (__DEV__) {
"use strict";
var ReactFlightDOMRelayClientIntegration = require("ReactFlightDOMRelayClientIntegration");
var ReactDOM = require("react-dom");
var React = require("react");
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
@@ -72,6 +73,54 @@ function parseModel(response, json) {
return parseModelRecursively(response, dummy, "", json);
}
var ReactDOMSharedInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
// This client file is in the shared folder because it applies to both SSR and browser contexts.
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
function dispatchHint(code, model) {
var dispatcher = ReactDOMCurrentDispatcher.current;
if (dispatcher) {
var href, options;
if (typeof model === "string") {
href = model;
} else {
href = model[0];
options = model[1];
}
switch (code) {
case "D": {
// $FlowFixMe[prop-missing] options are not refined to their types by code
dispatcher.prefetchDNS(href, options);
return;
}
case "C": {
// $FlowFixMe[prop-missing] options are not refined to their types by code
dispatcher.preconnect(href, options);
return;
}
case "L": {
// $FlowFixMe[prop-missing] options are not refined to their types by code
// $FlowFixMe[incompatible-call] options are not refined to their types by code
dispatcher.preload(href, options);
return;
}
case "I": {
// $FlowFixMe[prop-missing] options are not refined to their types by code
// $FlowFixMe[incompatible-call] options are not refined to their types by code
dispatcher.preinit(href, options);
return;
}
}
}
}
var knownServerReferences = new WeakMap();
// ATTENTION
@@ -503,12 +552,12 @@ function parseModelString(response, parentObject, key, value) {
switch (value[1]) {
case "$": {
// This was an escaped string value.
return value.substring(1);
return value.slice(1);
}
case "L": {
// Lazy node
var id = parseInt(value.substring(2), 16);
var id = parseInt(value.slice(2), 16);
var chunk = getChunk(response, id); // We create a React.lazy wrapper around any lazy values.
// When passed into React, we'll know how to suspend on this.
@@ -517,7 +566,7 @@ function parseModelString(response, parentObject, key, value) {
case "@": {
// Promise
var _id = parseInt(value.substring(2), 16);
var _id = parseInt(value.slice(2), 16);
var _chunk = getChunk(response, _id);
@@ -526,17 +575,17 @@ function parseModelString(response, parentObject, key, value) {
case "S": {
// Symbol
return Symbol.for(value.substring(2));
return Symbol.for(value.slice(2));
}
case "P": {
// Server Context Provider
return getOrCreateServerContext(value.substring(2)).Provider;
return getOrCreateServerContext(value.slice(2)).Provider;
}
case "F": {
// Server Reference
var _id2 = parseInt(value.substring(2), 16);
var _id2 = parseInt(value.slice(2), 16);
var _chunk2 = getChunk(response, _id2);
@@ -558,20 +607,44 @@ function parseModelString(response, parentObject, key, value) {
}
}
case "I": {
// $Infinity
return Infinity;
}
case "-": {
// $-0 or $-Infinity
if (value === "$-0") {
return -0;
} else {
return -Infinity;
}
}
case "N": {
// $NaN
return NaN;
}
case "u": {
// matches "$undefined"
// Special encoding for `undefined` which can't be serialized as JSON otherwise.
return undefined;
}
case "D": {
// Date
return new Date(Date.parse(value.slice(2)));
}
case "n": {
// BigInt
return BigInt(value.substring(2));
return BigInt(value.slice(2));
}
default: {
// We assume that anything else is a reference ID.
var _id3 = parseInt(value.substring(1), 16);
var _id3 = parseInt(value.slice(1), 16);
var _chunk3 = getChunk(response, _id3);
@@ -711,6 +784,10 @@ function resolveErrorDev(response, id, digest, message, stack) {
triggerErrorOnChunk(chunk, errorWithDigest);
}
}
function resolveHint(response, code, model) {
var hintModel = parseModel(response, model);
dispatchHint(code, hintModel);
}
function close(response) {
// In case there are any remaining unresolved chunks, they won't
// be resolved now. So we need to issue an error to those.
@@ -726,10 +803,13 @@ function resolveRow(response, chunk) {
} else if (chunk[0] === "I") {
// $FlowFixMe[incompatible-call] unable to refine on array indices
resolveModule(response, chunk[1], chunk[2]);
} else if (chunk[0] === "H") {
// $FlowFixMe[incompatible-call] unable to refine on array indices
resolveHint(response, chunk[1], chunk[2]);
} else {
{
resolveErrorDev(
response,
response, // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples.
chunk[1], // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples.
// $FlowFixMe[prop-missing]
// $FlowFixMe[incompatible-use]
@@ -17,6 +17,7 @@ if (__DEV__) {
"use strict";
var ReactFlightDOMRelayClientIntegration = require("ReactFlightDOMRelayClientIntegration");
var ReactDOM = require("react-dom");
var React = require("react");
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
@@ -72,6 +73,54 @@ function parseModel(response, json) {
return parseModelRecursively(response, dummy, "", json);
}
var ReactDOMSharedInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
// This client file is in the shared folder because it applies to both SSR and browser contexts.
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
function dispatchHint(code, model) {
var dispatcher = ReactDOMCurrentDispatcher.current;
if (dispatcher) {
var href, options;
if (typeof model === "string") {
href = model;
} else {
href = model[0];
options = model[1];
}
switch (code) {
case "D": {
// $FlowFixMe[prop-missing] options are not refined to their types by code
dispatcher.prefetchDNS(href, options);
return;
}
case "C": {
// $FlowFixMe[prop-missing] options are not refined to their types by code
dispatcher.preconnect(href, options);
return;
}
case "L": {
// $FlowFixMe[prop-missing] options are not refined to their types by code
// $FlowFixMe[incompatible-call] options are not refined to their types by code
dispatcher.preload(href, options);
return;
}
case "I": {
// $FlowFixMe[prop-missing] options are not refined to their types by code
// $FlowFixMe[incompatible-call] options are not refined to their types by code
dispatcher.preinit(href, options);
return;
}
}
}
}
var knownServerReferences = new WeakMap();
// ATTENTION
@@ -503,12 +552,12 @@ function parseModelString(response, parentObject, key, value) {
switch (value[1]) {
case "$": {
// This was an escaped string value.
return value.substring(1);
return value.slice(1);
}
case "L": {
// Lazy node
var id = parseInt(value.substring(2), 16);
var id = parseInt(value.slice(2), 16);
var chunk = getChunk(response, id); // We create a React.lazy wrapper around any lazy values.
// When passed into React, we'll know how to suspend on this.
@@ -517,7 +566,7 @@ function parseModelString(response, parentObject, key, value) {
case "@": {
// Promise
var _id = parseInt(value.substring(2), 16);
var _id = parseInt(value.slice(2), 16);
var _chunk = getChunk(response, _id);
@@ -526,17 +575,17 @@ function parseModelString(response, parentObject, key, value) {
case "S": {
// Symbol
return Symbol.for(value.substring(2));
return Symbol.for(value.slice(2));
}
case "P": {
// Server Context Provider
return getOrCreateServerContext(value.substring(2)).Provider;
return getOrCreateServerContext(value.slice(2)).Provider;
}
case "F": {
// Server Reference
var _id2 = parseInt(value.substring(2), 16);
var _id2 = parseInt(value.slice(2), 16);
var _chunk2 = getChunk(response, _id2);
@@ -558,20 +607,44 @@ function parseModelString(response, parentObject, key, value) {
}
}
case "I": {
// $Infinity
return Infinity;
}
case "-": {
// $-0 or $-Infinity
if (value === "$-0") {
return -0;
} else {
return -Infinity;
}
}
case "N": {
// $NaN
return NaN;
}
case "u": {
// matches "$undefined"
// Special encoding for `undefined` which can't be serialized as JSON otherwise.
return undefined;
}
case "D": {
// Date
return new Date(Date.parse(value.slice(2)));
}
case "n": {
// BigInt
return BigInt(value.substring(2));
return BigInt(value.slice(2));
}
default: {
// We assume that anything else is a reference ID.
var _id3 = parseInt(value.substring(1), 16);
var _id3 = parseInt(value.slice(1), 16);
var _chunk3 = getChunk(response, _id3);
@@ -711,6 +784,10 @@ function resolveErrorDev(response, id, digest, message, stack) {
triggerErrorOnChunk(chunk, errorWithDigest);
}
}
function resolveHint(response, code, model) {
var hintModel = parseModel(response, model);
dispatchHint(code, hintModel);
}
function close(response) {
// In case there are any remaining unresolved chunks, they won't
// be resolved now. So we need to issue an error to those.
@@ -726,10 +803,13 @@ function resolveRow(response, chunk) {
} else if (chunk[0] === "I") {
// $FlowFixMe[incompatible-call] unable to refine on array indices
resolveModule(response, chunk[1], chunk[2]);
} else if (chunk[0] === "H") {
// $FlowFixMe[incompatible-call] unable to refine on array indices
resolveHint(response, chunk[1], chunk[2]);
} else {
{
resolveErrorDev(
response,
response, // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples.
chunk[1], // $FlowFixMe[incompatible-call]: Flow doesn't support disjoint unions on tuples.
// $FlowFixMe[prop-missing]
// $FlowFixMe[incompatible-use]
@@ -12,6 +12,7 @@
"use strict";
var ReactFlightDOMRelayClientIntegration = require("ReactFlightDOMRelayClientIntegration"),
ReactDOM = require("react-dom"),
React = require("react");
function formatProdErrorMessage(code) {
for (
@@ -69,6 +70,8 @@ function parseModelRecursively(response, parentObj, key, value) {
return value;
}
var dummy = {},
ReactDOMCurrentDispatcher =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher,
knownServerReferences = new WeakMap(),
REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
@@ -248,23 +251,23 @@ function parseModelString(response, parentObject, key, value) {
if ("$" === value) return REACT_ELEMENT_TYPE;
switch (value[1]) {
case "$":
return value.substring(1);
return value.slice(1);
case "L":
return (
(parentObject = parseInt(value.substring(2), 16)),
(parentObject = parseInt(value.slice(2), 16)),
(response = getChunk(response, parentObject)),
{ $$typeof: REACT_LAZY_TYPE, _payload: response, _init: readChunk }
);
case "@":
return (
(parentObject = parseInt(value.substring(2), 16)),
(parentObject = parseInt(value.slice(2), 16)),
getChunk(response, parentObject)
);
case "S":
return Symbol.for(value.substring(2));
return Symbol.for(value.slice(2));
case "P":
return (
(response = value.substring(2)),
(response = value.slice(2)),
ContextRegistry[response] ||
(ContextRegistry[response] = React.createServerContext(
response,
@@ -273,7 +276,7 @@ function parseModelString(response, parentObject, key, value) {
ContextRegistry[response].Provider
);
case "F":
parentObject = parseInt(value.substring(2), 16);
parentObject = parseInt(value.slice(2), 16);
parentObject = getChunk(response, parentObject);
switch (parentObject.status) {
case "resolved_model":
@@ -285,12 +288,20 @@ function parseModelString(response, parentObject, key, value) {
default:
throw parentObject.reason;
}
case "I":
return Infinity;
case "-":
return "$-0" === value ? -0 : -Infinity;
case "N":
return NaN;
case "u":
return;
case "D":
return new Date(Date.parse(value.slice(2)));
case "n":
return BigInt(value.substring(2));
return BigInt(value.slice(2));
default:
value = parseInt(value.substring(1), 16);
value = parseInt(value.slice(1), 16);
response = getChunk(response, value);
switch (response.status) {
case "resolved_model":
@@ -368,31 +379,67 @@ exports.createResponse = function (bundlerConfig, callServer) {
exports.getRoot = function (response) {
return getChunk(response, 0);
};
exports.resolveRow = function (response, chunk) {
if ("O" === chunk[0]) {
var id = chunk[1],
model = chunk[2],
chunks = response._chunks;
(chunk = chunks.get(id))
exports.resolveRow = function (response, chunk$jscomp$0) {
if ("O" === chunk$jscomp$0[0]) {
var id = chunk$jscomp$0[1],
model = chunk$jscomp$0[2];
chunk$jscomp$0 = response._chunks;
var chunk = chunk$jscomp$0.get(id);
chunk
? "pending" === chunk.status &&
((response = chunk.value),
(id = chunk.reason),
(chunk$jscomp$0 = chunk.reason),
(chunk.status = "resolved_model"),
(chunk.value = model),
null !== response &&
(initializeModelChunk(chunk),
wakeChunkIfInitialized(chunk, response, id)))
: chunks.set(id, new Chunk("resolved_model", model, null, response));
wakeChunkIfInitialized(chunk, response, chunk$jscomp$0)))
: chunk$jscomp$0.set(
id,
new Chunk("resolved_model", model, null, response)
);
} else if ("I" === chunk$jscomp$0[0])
resolveModule(response, chunk$jscomp$0[1], chunk$jscomp$0[2]);
else if ("H" === chunk$jscomp$0[0]) {
if (
((model = chunk$jscomp$0[1]),
(response = parseModelRecursively(
response,
dummy,
"",
chunk$jscomp$0[2]
)),
(chunk$jscomp$0 = ReactDOMCurrentDispatcher.current))
)
switch (
("string" === typeof response
? (id = response)
: ((id = response[0]), (chunk = response[1])),
model)
) {
case "D":
chunk$jscomp$0.prefetchDNS(id, chunk);
break;
case "C":
chunk$jscomp$0.preconnect(id, chunk);
break;
case "L":
chunk$jscomp$0.preload(id, chunk);
break;
case "I":
chunk$jscomp$0.preinit(id, chunk);
}
} else
"I" === chunk[0]
? resolveModule(response, chunk[1], chunk[2])
: ((model = chunk[1]),
(id = chunk[2].digest),
(chunk = Error(formatProdErrorMessage(441))),
(chunk.stack = "Error: " + chunk.message),
(chunk.digest = id),
(id = response._chunks),
(chunks = id.get(model))
? triggerErrorOnChunk(chunks, chunk)
: id.set(model, new Chunk("rejected", null, chunk, response)));
(model = chunk$jscomp$0[1]),
(chunk$jscomp$0 = chunk$jscomp$0[2].digest),
(chunk = Error(formatProdErrorMessage(441))),
(chunk.stack = "Error: " + chunk.message),
(chunk.digest = chunk$jscomp$0),
(chunk$jscomp$0 = response._chunks),
(id = chunk$jscomp$0.get(model))
? triggerErrorOnChunk(id, chunk)
: chunk$jscomp$0.set(
model,
new Chunk("rejected", null, chunk, response)
);
};
@@ -12,6 +12,7 @@
"use strict";
var ReactFlightDOMRelayClientIntegration = require("ReactFlightDOMRelayClientIntegration"),
ReactDOM = require("react-dom"),
React = require("react");
function formatProdErrorMessage(code) {
for (
@@ -69,6 +70,8 @@ function parseModelRecursively(response, parentObj, key, value) {
return value;
}
var dummy = {},
ReactDOMCurrentDispatcher =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher,
knownServerReferences = new WeakMap(),
REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
@@ -248,23 +251,23 @@ function parseModelString(response, parentObject, key, value) {
if ("$" === value) return REACT_ELEMENT_TYPE;
switch (value[1]) {
case "$":
return value.substring(1);
return value.slice(1);
case "L":
return (
(parentObject = parseInt(value.substring(2), 16)),
(parentObject = parseInt(value.slice(2), 16)),
(response = getChunk(response, parentObject)),
{ $$typeof: REACT_LAZY_TYPE, _payload: response, _init: readChunk }
);
case "@":
return (
(parentObject = parseInt(value.substring(2), 16)),
(parentObject = parseInt(value.slice(2), 16)),
getChunk(response, parentObject)
);
case "S":
return Symbol.for(value.substring(2));
return Symbol.for(value.slice(2));
case "P":
return (
(response = value.substring(2)),
(response = value.slice(2)),
ContextRegistry[response] ||
(ContextRegistry[response] = React.createServerContext(
response,
@@ -273,7 +276,7 @@ function parseModelString(response, parentObject, key, value) {
ContextRegistry[response].Provider
);
case "F":
parentObject = parseInt(value.substring(2), 16);
parentObject = parseInt(value.slice(2), 16);
parentObject = getChunk(response, parentObject);
switch (parentObject.status) {
case "resolved_model":
@@ -285,12 +288,20 @@ function parseModelString(response, parentObject, key, value) {
default:
throw parentObject.reason;
}
case "I":
return Infinity;
case "-":
return "$-0" === value ? -0 : -Infinity;
case "N":
return NaN;
case "u":
return;
case "D":
return new Date(Date.parse(value.slice(2)));
case "n":
return BigInt(value.substring(2));
return BigInt(value.slice(2));
default:
value = parseInt(value.substring(1), 16);
value = parseInt(value.slice(1), 16);
response = getChunk(response, value);
switch (response.status) {
case "resolved_model":
@@ -368,31 +379,67 @@ exports.createResponse = function (bundlerConfig, callServer) {
exports.getRoot = function (response) {
return getChunk(response, 0);
};
exports.resolveRow = function (response, chunk) {
if ("O" === chunk[0]) {
var id = chunk[1],
model = chunk[2],
chunks = response._chunks;
(chunk = chunks.get(id))
exports.resolveRow = function (response, chunk$jscomp$0) {
if ("O" === chunk$jscomp$0[0]) {
var id = chunk$jscomp$0[1],
model = chunk$jscomp$0[2];
chunk$jscomp$0 = response._chunks;
var chunk = chunk$jscomp$0.get(id);
chunk
? "pending" === chunk.status &&
((response = chunk.value),
(id = chunk.reason),
(chunk$jscomp$0 = chunk.reason),
(chunk.status = "resolved_model"),
(chunk.value = model),
null !== response &&
(initializeModelChunk(chunk),
wakeChunkIfInitialized(chunk, response, id)))
: chunks.set(id, new Chunk("resolved_model", model, null, response));
wakeChunkIfInitialized(chunk, response, chunk$jscomp$0)))
: chunk$jscomp$0.set(
id,
new Chunk("resolved_model", model, null, response)
);
} else if ("I" === chunk$jscomp$0[0])
resolveModule(response, chunk$jscomp$0[1], chunk$jscomp$0[2]);
else if ("H" === chunk$jscomp$0[0]) {
if (
((model = chunk$jscomp$0[1]),
(response = parseModelRecursively(
response,
dummy,
"",
chunk$jscomp$0[2]
)),
(chunk$jscomp$0 = ReactDOMCurrentDispatcher.current))
)
switch (
("string" === typeof response
? (id = response)
: ((id = response[0]), (chunk = response[1])),
model)
) {
case "D":
chunk$jscomp$0.prefetchDNS(id, chunk);
break;
case "C":
chunk$jscomp$0.preconnect(id, chunk);
break;
case "L":
chunk$jscomp$0.preload(id, chunk);
break;
case "I":
chunk$jscomp$0.preinit(id, chunk);
}
} else
"I" === chunk[0]
? resolveModule(response, chunk[1], chunk[2])
: ((model = chunk[1]),
(id = chunk[2].digest),
(chunk = Error(formatProdErrorMessage(441))),
(chunk.stack = "Error: " + chunk.message),
(chunk.digest = id),
(id = response._chunks),
(chunks = id.get(model))
? triggerErrorOnChunk(chunks, chunk)
: id.set(model, new Chunk("rejected", null, chunk, response)));
(model = chunk$jscomp$0[1]),
(chunk$jscomp$0 = chunk$jscomp$0[2].digest),
(chunk = Error(formatProdErrorMessage(441))),
(chunk.stack = "Error: " + chunk.message),
(chunk.digest = chunk$jscomp$0),
(chunk$jscomp$0 = response._chunks),
(id = chunk$jscomp$0.get(model))
? triggerErrorOnChunk(id, chunk)
: chunk$jscomp$0.set(
model,
new Chunk("rejected", null, chunk, response)
);
};
@@ -18,6 +18,7 @@ if (__DEV__) {
var JSResourceReferenceImpl = require("JSResourceReferenceImpl");
var ReactFlightDOMRelayServerIntegration = require("ReactFlightDOMRelayServerIntegration");
var ReactDOM = require("react-dom");
var React = require("react");
// This refers to a WWW module.
@@ -142,6 +143,10 @@ function processImportChunk(request, id, clientReferenceMetadata) {
// The clientReferenceMetadata is already a JSON serializable value.
return ["I", id, clientReferenceMetadata];
}
function processHintChunk(request, id, code, model) {
// The hint is already a JSON serializable value.
return ["H", code, model];
}
function scheduleWork(callback) {
callback();
}
@@ -154,6 +159,128 @@ function closeWithError(destination, error) {
ReactFlightDOMRelayServerIntegration.close(destination);
}
var ReactDOMSharedInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
// Re-export dynamic flags from the www version.
require("ReactFeatureFlags");
var ReactDOMFlightServerDispatcher = {
prefetchDNS: prefetchDNS,
preconnect: preconnect,
preload: preload,
preinit: preinit
};
function prefetchDNS(href, options) {
{
if (typeof href === "string") {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = "D" + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
if (options) {
emitHint(request, "D", [href, options]);
} else {
emitHint(request, "D", href);
}
}
}
}
}
function preconnect(href, options) {
{
if (typeof href === "string") {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var crossOrigin =
options == null || typeof options.crossOrigin !== "string"
? null
: options.crossOrigin === "use-credentials"
? "use-credentials"
: "";
var key =
"C" + (crossOrigin === null ? "null" : crossOrigin) + "|" + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
if (options) {
emitHint(request, "C", [href, options]);
} else {
emitHint(request, "C", href);
}
}
}
}
}
function preload(href, options) {
{
if (typeof href === "string") {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = "L" + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
emitHint(request, "L", [href, options]);
}
}
}
}
function preinit(href, options) {
{
if (typeof href === "string") {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = "I" + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
emitHint(request, "I", [href, options]);
}
}
}
}
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
function prepareHostDispatcher() {
ReactDOMCurrentDispatcher.current = ReactDOMFlightServerDispatcher;
} // Used to distinguish these contexts from ones used in other renderers.
function createHints() {
return new Set();
}
// ATTENTION
// When adding new symbols to this file,
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
@@ -397,9 +524,6 @@ function readContext$1(context) {
return value;
}
// Re-export dynamic flags from the www version.
require("ReactFeatureFlags");
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
// changes to one module should be reflected in the others.
// TODO: Rename this module and the corresponding Fiber one to "Thenable"
@@ -522,14 +646,14 @@ function getSuspendedThenable() {
return thenable;
}
var currentRequest = null;
var currentRequest$1 = null;
var thenableIndexCounter = 0;
var thenableState = null;
function prepareToUseHooksForRequest(request) {
currentRequest = request;
currentRequest$1 = request;
}
function resetHooksForRequest() {
currentRequest = null;
currentRequest$1 = null;
}
function prepareToUseHooksForComponent(prevThenableState) {
thenableIndexCounter = 0;
@@ -551,7 +675,7 @@ function readContext(context) {
}
}
if (currentRequest === null) {
if (currentRequest$1 === null) {
error(
"Context can only be read while React is rendering. " +
"In classes, you can read it in the render method or getDerivedStateFromProps. " +
@@ -612,13 +736,13 @@ function unsupportedRefresh() {
}
function useId() {
if (currentRequest === null) {
if (currentRequest$1 === null) {
throw new Error("useId can only be used while React is rendering");
}
var id = currentRequest.identifierCount++; // use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client
var id = currentRequest$1.identifierCount++; // use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client
return ":" + currentRequest.identifierPrefix + "S" + id.toString(32) + ":";
return ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":";
}
function use(usable) {
@@ -659,9 +783,11 @@ function createSignal() {
}
function resolveCache() {
if (currentCache) return currentCache;
// active and so to support cache() and fetch() outside of render, we yield
// an empty Map.
var request = resolveRequest();
if (request) {
return getCache(request);
}
return new Map();
}
@@ -691,14 +817,6 @@ var DefaultCacheDispatcher = {
return entry;
}
};
var currentCache = null;
function setCurrentCache(cache) {
currentCache = cache;
return currentCache;
}
function getCurrentCache() {
return currentCache;
}
// in case they error.
@@ -780,7 +898,7 @@ function describeValueForErrorMessage(value) {
switch (typeof value) {
case "string": {
return JSON.stringify(
value.length <= 10 ? value : value.substr(0, 10) + "..."
value.length <= 10 ? value : value.slice(0, 10) + "..."
);
}
@@ -1065,20 +1183,25 @@ function createRequest(
);
}
prepareHostDispatcher();
ReactCurrentCache.current = DefaultCacheDispatcher;
var abortSet = new Set();
var pingedTasks = [];
var hints = createHints();
var request = {
status: OPEN,
flushScheduled: false,
fatalError: null,
destination: null,
bundlerConfig: bundlerConfig,
cache: new Map(),
nextChunkId: 0,
pendingChunks: 0,
hints: hints,
abortableTasks: abortSet,
pingedTasks: pingedTasks,
completedImportChunks: [],
completedHintChunks: [],
completedJSONChunks: [],
completedErrorChunks: [],
writtenSymbols: new Map(),
@@ -1099,6 +1222,12 @@ function createRequest(
pingedTasks.push(rootTask);
return request;
}
var currentRequest = null;
function resolveRequest() {
if (currentRequest) return currentRequest;
return null;
}
function createRootContext(reqContext) {
return importServerContexts(reqContext);
@@ -1194,6 +1323,17 @@ function serializeThenable(request, thenable) {
return newTask.id;
}
function emitHint(request, code, model) {
emitHintChunk(request, code, model);
enqueueFlush(request);
}
function getHints(request) {
return request.hints;
}
function getCache(request) {
return request.cache;
}
function readThenable(thenable) {
if (thenable.status === "fulfilled") {
return thenable.value;
@@ -1400,6 +1540,7 @@ function pingTask(request, task) {
pingedTasks.push(task);
if (pingedTasks.length === 1) {
request.flushScheduled = request.destination !== null;
scheduleWork(function () {
return performWork(request);
});
@@ -1442,10 +1583,34 @@ function serializeProviderReference(name) {
return "$P" + name;
}
function serializeNumber(number) {
if (Number.isFinite(number)) {
if (number === 0 && 1 / number === -Infinity) {
return "$-0";
} else {
return number;
}
} else {
if (number === Infinity) {
return "$Infinity";
} else if (number === -Infinity) {
return "$-Infinity";
} else {
return "$NaN";
}
}
}
function serializeUndefined() {
return "$undefined";
}
function serializeDateFromDateJSON(dateJSON) {
// JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString.
// We need only tack on a $D prefix.
return "$D" + dateJSON;
}
function serializeBigInt(n) {
return "$n" + n.toString(10);
}
@@ -1518,11 +1683,16 @@ function escapeStringValue(value) {
var insideContextProps = null;
var isInsideContextValue = false;
function resolveModelToJSON(request, parent, key, value) {
// Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
{
// $FlowFixMe[incompatible-use]
var originalValue = parent[key];
if (typeof originalValue === "object" && originalValue !== value) {
if (
typeof originalValue === "object" &&
originalValue !== value &&
!(originalValue instanceof Date)
) {
if (objectName(originalValue) !== "Object") {
var jsxParentType = jsxChildrenParents.get(parent);
@@ -1730,13 +1900,28 @@ function resolveModelToJSON(request, parent, key, value) {
}
if (typeof value === "string") {
// TODO: Maybe too clever. If we support URL there's no similar trick.
if (value[value.length - 1] === "Z") {
// Possibly a Date, whose toJSON automatically calls toISOString
// $FlowFixMe[incompatible-use]
var _originalValue = parent[key]; // $FlowFixMe[method-unbinding]
if (_originalValue instanceof Date) {
return serializeDateFromDateJSON(value);
}
}
return escapeStringValue(value);
}
if (typeof value === "boolean" || typeof value === "number") {
if (typeof value === "boolean") {
return value;
}
if (typeof value === "number") {
return serializeNumber(value);
}
if (typeof value === "undefined") {
return serializeUndefined();
}
@@ -1868,6 +2053,16 @@ function emitImportChunk(request, id, clientReferenceMetadata) {
request.completedImportChunks.push(processedChunk);
}
function emitHintChunk(request, code, model) {
var processedChunk = processHintChunk(
request,
request.nextChunkId++,
code,
model
);
request.completedHintChunks.push(processedChunk);
}
function emitSymbolChunk(request, id, name) {
var symbolReference = serializeSymbolReference(name);
var processedChunk = processReferenceChunk(request, id, symbolReference);
@@ -1976,9 +2171,9 @@ function retryTask(request, task) {
function performWork(request) {
var prevDispatcher = ReactCurrentDispatcher.current;
var prevCache = getCurrentCache();
ReactCurrentDispatcher.current = HooksDispatcher;
setCurrentCache(request.cache);
var prevRequest = currentRequest;
currentRequest = request;
prepareToUseHooksForRequest(request);
try {
@@ -1998,8 +2193,8 @@ function performWork(request) {
fatalError(request, error);
} finally {
ReactCurrentDispatcher.current = prevDispatcher;
setCurrentCache(prevCache);
resetHooksForRequest();
currentRequest = prevRequest;
}
}
@@ -2022,18 +2217,35 @@ function flushCompletedChunks(request, destination) {
}
}
importsChunks.splice(0, i); // Next comes model data.
importsChunks.splice(0, i); // Next comes hints.
var hintChunks = request.completedHintChunks;
i = 0;
for (; i < hintChunks.length; i++) {
var _chunk = hintChunks[i];
var _keepWriting = writeChunkAndReturn(destination, _chunk);
if (!_keepWriting) {
request.destination = null;
i++;
break;
}
}
hintChunks.splice(0, i); // Next comes model data.
var jsonChunks = request.completedJSONChunks;
i = 0;
for (; i < jsonChunks.length; i++) {
request.pendingChunks--;
var _chunk = jsonChunks[i];
var _chunk2 = jsonChunks[i];
var _keepWriting = writeChunkAndReturn(destination, _chunk);
var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
if (!_keepWriting) {
if (!_keepWriting2) {
request.destination = null;
i++;
break;
@@ -2049,11 +2261,11 @@ function flushCompletedChunks(request, destination) {
for (; i < errorChunks.length; i++) {
request.pendingChunks--;
var _chunk2 = errorChunks[i];
var _chunk3 = errorChunks[i];
var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
var _keepWriting3 = writeChunkAndReturn(destination, _chunk3);
if (!_keepWriting2) {
if (!_keepWriting3) {
request.destination = null;
i++;
break;
@@ -2062,6 +2274,7 @@ function flushCompletedChunks(request, destination) {
errorChunks.splice(0, i);
} finally {
request.flushScheduled = false;
}
if (request.pendingChunks === 0) {
@@ -2071,12 +2284,30 @@ function flushCompletedChunks(request, destination) {
}
function startWork(request) {
request.flushScheduled = request.destination !== null;
{
scheduleWork(function () {
return performWork(request);
});
}
}
function enqueueFlush(request) {
if (
request.flushScheduled === false && // If there are pinged tasks we are going to flush anyway after work completes
request.pingedTasks.length === 0 && // If there is no destination there is nothing we can flush to. A flush will
// happen when we start flowing again
request.destination !== null
) {
var destination = request.destination;
request.flushScheduled = true;
scheduleWork(function () {
return flushCompletedChunks(request, destination);
});
}
}
function startFlowing(request, destination) {
if (request.status === CLOSING) {
request.status = CLOSED;
@@ -18,6 +18,7 @@ if (__DEV__) {
var JSResourceReferenceImpl = require("JSResourceReferenceImpl");
var ReactFlightDOMRelayServerIntegration = require("ReactFlightDOMRelayServerIntegration");
var ReactDOM = require("react-dom");
var React = require("react");
// This refers to a WWW module.
@@ -142,6 +143,10 @@ function processImportChunk(request, id, clientReferenceMetadata) {
// The clientReferenceMetadata is already a JSON serializable value.
return ["I", id, clientReferenceMetadata];
}
function processHintChunk(request, id, code, model) {
// The hint is already a JSON serializable value.
return ["H", code, model];
}
function scheduleWork(callback) {
callback();
}
@@ -154,6 +159,128 @@ function closeWithError(destination, error) {
ReactFlightDOMRelayServerIntegration.close(destination);
}
var ReactDOMSharedInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
// Re-export dynamic flags from the www version.
require("ReactFeatureFlags");
var ReactDOMFlightServerDispatcher = {
prefetchDNS: prefetchDNS,
preconnect: preconnect,
preload: preload,
preinit: preinit
};
function prefetchDNS(href, options) {
{
if (typeof href === "string") {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = "D" + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
if (options) {
emitHint(request, "D", [href, options]);
} else {
emitHint(request, "D", href);
}
}
}
}
}
function preconnect(href, options) {
{
if (typeof href === "string") {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var crossOrigin =
options == null || typeof options.crossOrigin !== "string"
? null
: options.crossOrigin === "use-credentials"
? "use-credentials"
: "";
var key =
"C" + (crossOrigin === null ? "null" : crossOrigin) + "|" + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
if (options) {
emitHint(request, "C", [href, options]);
} else {
emitHint(request, "C", href);
}
}
}
}
}
function preload(href, options) {
{
if (typeof href === "string") {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = "L" + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
emitHint(request, "L", [href, options]);
}
}
}
}
function preinit(href, options) {
{
if (typeof href === "string") {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = "I" + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
emitHint(request, "I", [href, options]);
}
}
}
}
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
function prepareHostDispatcher() {
ReactDOMCurrentDispatcher.current = ReactDOMFlightServerDispatcher;
} // Used to distinguish these contexts from ones used in other renderers.
function createHints() {
return new Set();
}
// ATTENTION
// When adding new symbols to this file,
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
@@ -397,9 +524,6 @@ function readContext$1(context) {
return value;
}
// Re-export dynamic flags from the www version.
require("ReactFeatureFlags");
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
// changes to one module should be reflected in the others.
// TODO: Rename this module and the corresponding Fiber one to "Thenable"
@@ -522,14 +646,14 @@ function getSuspendedThenable() {
return thenable;
}
var currentRequest = null;
var currentRequest$1 = null;
var thenableIndexCounter = 0;
var thenableState = null;
function prepareToUseHooksForRequest(request) {
currentRequest = request;
currentRequest$1 = request;
}
function resetHooksForRequest() {
currentRequest = null;
currentRequest$1 = null;
}
function prepareToUseHooksForComponent(prevThenableState) {
thenableIndexCounter = 0;
@@ -551,7 +675,7 @@ function readContext(context) {
}
}
if (currentRequest === null) {
if (currentRequest$1 === null) {
error(
"Context can only be read while React is rendering. " +
"In classes, you can read it in the render method or getDerivedStateFromProps. " +
@@ -612,13 +736,13 @@ function unsupportedRefresh() {
}
function useId() {
if (currentRequest === null) {
if (currentRequest$1 === null) {
throw new Error("useId can only be used while React is rendering");
}
var id = currentRequest.identifierCount++; // use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client
var id = currentRequest$1.identifierCount++; // use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client
return ":" + currentRequest.identifierPrefix + "S" + id.toString(32) + ":";
return ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":";
}
function use(usable) {
@@ -659,9 +783,11 @@ function createSignal() {
}
function resolveCache() {
if (currentCache) return currentCache;
// active and so to support cache() and fetch() outside of render, we yield
// an empty Map.
var request = resolveRequest();
if (request) {
return getCache(request);
}
return new Map();
}
@@ -691,14 +817,6 @@ var DefaultCacheDispatcher = {
return entry;
}
};
var currentCache = null;
function setCurrentCache(cache) {
currentCache = cache;
return currentCache;
}
function getCurrentCache() {
return currentCache;
}
// in case they error.
@@ -780,7 +898,7 @@ function describeValueForErrorMessage(value) {
switch (typeof value) {
case "string": {
return JSON.stringify(
value.length <= 10 ? value : value.substr(0, 10) + "..."
value.length <= 10 ? value : value.slice(0, 10) + "..."
);
}
@@ -1065,20 +1183,25 @@ function createRequest(
);
}
prepareHostDispatcher();
ReactCurrentCache.current = DefaultCacheDispatcher;
var abortSet = new Set();
var pingedTasks = [];
var hints = createHints();
var request = {
status: OPEN,
flushScheduled: false,
fatalError: null,
destination: null,
bundlerConfig: bundlerConfig,
cache: new Map(),
nextChunkId: 0,
pendingChunks: 0,
hints: hints,
abortableTasks: abortSet,
pingedTasks: pingedTasks,
completedImportChunks: [],
completedHintChunks: [],
completedJSONChunks: [],
completedErrorChunks: [],
writtenSymbols: new Map(),
@@ -1099,6 +1222,12 @@ function createRequest(
pingedTasks.push(rootTask);
return request;
}
var currentRequest = null;
function resolveRequest() {
if (currentRequest) return currentRequest;
return null;
}
function createRootContext(reqContext) {
return importServerContexts(reqContext);
@@ -1194,6 +1323,17 @@ function serializeThenable(request, thenable) {
return newTask.id;
}
function emitHint(request, code, model) {
emitHintChunk(request, code, model);
enqueueFlush(request);
}
function getHints(request) {
return request.hints;
}
function getCache(request) {
return request.cache;
}
function readThenable(thenable) {
if (thenable.status === "fulfilled") {
return thenable.value;
@@ -1400,6 +1540,7 @@ function pingTask(request, task) {
pingedTasks.push(task);
if (pingedTasks.length === 1) {
request.flushScheduled = request.destination !== null;
scheduleWork(function () {
return performWork(request);
});
@@ -1442,10 +1583,34 @@ function serializeProviderReference(name) {
return "$P" + name;
}
function serializeNumber(number) {
if (Number.isFinite(number)) {
if (number === 0 && 1 / number === -Infinity) {
return "$-0";
} else {
return number;
}
} else {
if (number === Infinity) {
return "$Infinity";
} else if (number === -Infinity) {
return "$-Infinity";
} else {
return "$NaN";
}
}
}
function serializeUndefined() {
return "$undefined";
}
function serializeDateFromDateJSON(dateJSON) {
// JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString.
// We need only tack on a $D prefix.
return "$D" + dateJSON;
}
function serializeBigInt(n) {
return "$n" + n.toString(10);
}
@@ -1518,11 +1683,16 @@ function escapeStringValue(value) {
var insideContextProps = null;
var isInsideContextValue = false;
function resolveModelToJSON(request, parent, key, value) {
// Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
{
// $FlowFixMe[incompatible-use]
var originalValue = parent[key];
if (typeof originalValue === "object" && originalValue !== value) {
if (
typeof originalValue === "object" &&
originalValue !== value &&
!(originalValue instanceof Date)
) {
if (objectName(originalValue) !== "Object") {
var jsxParentType = jsxChildrenParents.get(parent);
@@ -1730,13 +1900,28 @@ function resolveModelToJSON(request, parent, key, value) {
}
if (typeof value === "string") {
// TODO: Maybe too clever. If we support URL there's no similar trick.
if (value[value.length - 1] === "Z") {
// Possibly a Date, whose toJSON automatically calls toISOString
// $FlowFixMe[incompatible-use]
var _originalValue = parent[key]; // $FlowFixMe[method-unbinding]
if (_originalValue instanceof Date) {
return serializeDateFromDateJSON(value);
}
}
return escapeStringValue(value);
}
if (typeof value === "boolean" || typeof value === "number") {
if (typeof value === "boolean") {
return value;
}
if (typeof value === "number") {
return serializeNumber(value);
}
if (typeof value === "undefined") {
return serializeUndefined();
}
@@ -1868,6 +2053,16 @@ function emitImportChunk(request, id, clientReferenceMetadata) {
request.completedImportChunks.push(processedChunk);
}
function emitHintChunk(request, code, model) {
var processedChunk = processHintChunk(
request,
request.nextChunkId++,
code,
model
);
request.completedHintChunks.push(processedChunk);
}
function emitSymbolChunk(request, id, name) {
var symbolReference = serializeSymbolReference(name);
var processedChunk = processReferenceChunk(request, id, symbolReference);
@@ -1976,9 +2171,9 @@ function retryTask(request, task) {
function performWork(request) {
var prevDispatcher = ReactCurrentDispatcher.current;
var prevCache = getCurrentCache();
ReactCurrentDispatcher.current = HooksDispatcher;
setCurrentCache(request.cache);
var prevRequest = currentRequest;
currentRequest = request;
prepareToUseHooksForRequest(request);
try {
@@ -1998,8 +2193,8 @@ function performWork(request) {
fatalError(request, error);
} finally {
ReactCurrentDispatcher.current = prevDispatcher;
setCurrentCache(prevCache);
resetHooksForRequest();
currentRequest = prevRequest;
}
}
@@ -2022,18 +2217,35 @@ function flushCompletedChunks(request, destination) {
}
}
importsChunks.splice(0, i); // Next comes model data.
importsChunks.splice(0, i); // Next comes hints.
var hintChunks = request.completedHintChunks;
i = 0;
for (; i < hintChunks.length; i++) {
var _chunk = hintChunks[i];
var _keepWriting = writeChunkAndReturn(destination, _chunk);
if (!_keepWriting) {
request.destination = null;
i++;
break;
}
}
hintChunks.splice(0, i); // Next comes model data.
var jsonChunks = request.completedJSONChunks;
i = 0;
for (; i < jsonChunks.length; i++) {
request.pendingChunks--;
var _chunk = jsonChunks[i];
var _chunk2 = jsonChunks[i];
var _keepWriting = writeChunkAndReturn(destination, _chunk);
var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
if (!_keepWriting) {
if (!_keepWriting2) {
request.destination = null;
i++;
break;
@@ -2049,11 +2261,11 @@ function flushCompletedChunks(request, destination) {
for (; i < errorChunks.length; i++) {
request.pendingChunks--;
var _chunk2 = errorChunks[i];
var _chunk3 = errorChunks[i];
var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
var _keepWriting3 = writeChunkAndReturn(destination, _chunk3);
if (!_keepWriting2) {
if (!_keepWriting3) {
request.destination = null;
i++;
break;
@@ -2062,6 +2274,7 @@ function flushCompletedChunks(request, destination) {
errorChunks.splice(0, i);
} finally {
request.flushScheduled = false;
}
if (request.pendingChunks === 0) {
@@ -2071,12 +2284,30 @@ function flushCompletedChunks(request, destination) {
}
function startWork(request) {
request.flushScheduled = request.destination !== null;
{
scheduleWork(function () {
return performWork(request);
});
}
}
function enqueueFlush(request) {
if (
request.flushScheduled === false && // If there are pinged tasks we are going to flush anyway after work completes
request.pingedTasks.length === 0 && // If there is no destination there is nothing we can flush to. A flush will
// happen when we start flowing again
request.destination !== null
) {
var destination = request.destination;
request.flushScheduled = true;
scheduleWork(function () {
return flushCompletedChunks(request, destination);
});
}
}
function startFlowing(request, destination) {
if (request.status === CLOSING) {
request.status = CLOSED;
@@ -13,6 +13,7 @@
"use strict";
var JSResourceReferenceImpl = require("JSResourceReferenceImpl"),
ReactFlightDOMRelayServerIntegration = require("ReactFlightDOMRelayServerIntegration"),
ReactDOM = require("react-dom"),
React = require("react"),
hasOwnProperty = Object.prototype.hasOwnProperty,
isArrayImpl = Array.isArray;
@@ -47,7 +48,80 @@ function writeChunkAndReturn(destination, chunk) {
ReactFlightDOMRelayServerIntegration.emitRow(destination, chunk);
return !0;
}
var REACT_ELEMENT_TYPE = Symbol.for("react.element"),
var ReactDOMSharedInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
require("ReactFeatureFlags");
var ReactDOMFlightServerDispatcher = {
prefetchDNS: prefetchDNS,
preconnect: preconnect,
preload: preload,
preinit: preinit
};
function prefetchDNS(href, options) {
if ("string" === typeof href) {
var request = currentRequest ? currentRequest : null;
if (request) {
var hints = request.hints,
key = "D" + href;
hints.has(key) ||
(hints.add(key),
options
? emitHintChunk(request, "D", [href, options])
: emitHintChunk(request, "D", href),
enqueueFlush(request));
}
}
}
function preconnect(href, options) {
if ("string" === typeof href) {
var request = currentRequest ? currentRequest : null;
if (request) {
var hints = request.hints,
crossOrigin =
null == options || "string" !== typeof options.crossOrigin
? null
: "use-credentials" === options.crossOrigin
? "use-credentials"
: "";
crossOrigin =
"C" + (null === crossOrigin ? "null" : crossOrigin) + "|" + href;
hints.has(crossOrigin) ||
(hints.add(crossOrigin),
options
? emitHintChunk(request, "C", [href, options])
: emitHintChunk(request, "C", href),
enqueueFlush(request));
}
}
}
function preload(href, options) {
if ("string" === typeof href) {
var request = currentRequest ? currentRequest : null;
if (request) {
var hints = request.hints,
key = "L" + href;
hints.has(key) ||
(hints.add(key),
emitHintChunk(request, "L", [href, options]),
enqueueFlush(request));
}
}
}
function preinit(href, options) {
if ("string" === typeof href) {
var request = currentRequest ? currentRequest : null;
if (request) {
var hints = request.hints,
key = "I" + href;
hints.has(key) ||
(hints.add(key),
emitHintChunk(request, "I", [href, options]),
enqueueFlush(request));
}
}
}
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher,
REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context"),
@@ -141,7 +215,6 @@ function pushProvider(context, nextValue) {
value: nextValue
});
}
require("ReactFeatureFlags");
var SuspenseException = Error(
"Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`"
);
@@ -198,7 +271,7 @@ function getSuspendedThenable() {
suspendedThenable = null;
return thenable;
}
var currentRequest = null,
var currentRequest$1 = null,
thenableIndexCounter = 0,
thenableState = null;
function getThenableStateAfterSuspending() {
@@ -248,10 +321,10 @@ function unsupportedRefresh() {
throw Error("Refreshing the cache is not supported in Server Components.");
}
function useId() {
if (null === currentRequest)
if (null === currentRequest$1)
throw Error("useId can only be used while React is rendering");
var id = currentRequest.identifierCount++;
return ":" + currentRequest.identifierPrefix + "S" + id.toString(32) + ":";
var id = currentRequest$1.identifierCount++;
return ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":";
}
function use(usable) {
if (
@@ -272,23 +345,26 @@ function use(usable) {
function createSignal() {
return new AbortController().signal;
}
function resolveCache() {
var request = currentRequest ? currentRequest : null;
return request ? request.cache : new Map();
}
var DefaultCacheDispatcher = {
getCacheSignal: function () {
var cache = currentCache ? currentCache : new Map(),
entry = cache.get(createSignal);
void 0 === entry &&
((entry = createSignal()), cache.set(createSignal, entry));
return entry;
},
getCacheForType: function (resourceType) {
var cache = currentCache ? currentCache : new Map(),
entry = cache.get(resourceType);
void 0 === entry &&
((entry = resourceType()), cache.set(resourceType, entry));
return entry;
}
getCacheSignal: function () {
var cache = resolveCache(),
entry = cache.get(createSignal);
void 0 === entry &&
((entry = createSignal()), cache.set(createSignal, entry));
return entry;
},
currentCache = null;
getCacheForType: function (resourceType) {
var cache = resolveCache(),
entry = cache.get(resourceType);
void 0 === entry &&
((entry = resourceType()), cache.set(resourceType, entry));
return entry;
}
};
function objectName(object) {
return Object.prototype.toString
.call(object)
@@ -300,7 +376,7 @@ function describeValueForErrorMessage(value) {
switch (typeof value) {
case "string":
return JSON.stringify(
10 >= value.length ? value : value.substr(0, 10) + "..."
10 >= value.length ? value : value.slice(0, 10) + "..."
);
case "object":
if (isArrayImpl(value)) return "[...]";
@@ -410,20 +486,25 @@ function createRequest(
ReactCurrentCache.current !== DefaultCacheDispatcher
)
throw Error("Currently React only supports one RSC renderer at a time.");
ReactDOMCurrentDispatcher.current = ReactDOMFlightServerDispatcher;
ReactCurrentCache.current = DefaultCacheDispatcher;
var abortSet = new Set(),
pingedTasks = [],
hints = new Set(),
request = {
status: 0,
flushScheduled: !1,
fatalError: null,
destination: null,
bundlerConfig: bundlerConfig,
cache: new Map(),
nextChunkId: 0,
pendingChunks: 0,
hints: hints,
abortableTasks: abortSet,
pingedTasks: pingedTasks,
completedImportChunks: [],
completedHintChunks: [],
completedJSONChunks: [],
completedErrorChunks: [],
writtenSymbols: new Map(),
@@ -443,7 +524,8 @@ function createRequest(
pingedTasks.push(model);
return request;
}
var POP = {};
var currentRequest = null,
POP = {};
function serializeThenable(request, thenable) {
request.pendingChunks++;
var newTask = createTask(
@@ -599,7 +681,9 @@ function attemptResolveElement(
function pingTask(request, task) {
var pingedTasks = request.pingedTasks;
pingedTasks.push(task);
1 === pingedTasks.length && performWork(request);
1 === pingedTasks.length &&
((request.flushScheduled = null !== request.destination),
performWork(request));
}
function createTask(request, model, context, abortSet) {
var task = {
@@ -751,9 +835,26 @@ function resolveModelToJSON(request, parent, key, value) {
? Array.from(value)
: value;
}
if ("string" === typeof value)
return (request = "$" === value[0] ? "$" + value : value), request;
if ("boolean" === typeof value || "number" === typeof value) return value;
if ("string" === typeof value) {
if ("Z" === value[value.length - 1] && parent[key] instanceof Date)
return "$D" + value;
request = "$" === value[0] ? "$" + value : value;
return request;
}
if ("boolean" === typeof value) return value;
if ("number" === typeof value)
return (
(request = value),
Number.isFinite(request)
? 0 === request && -Infinity === 1 / request
? "$-0"
: request
: Infinity === request
? "$Infinity"
: -Infinity === request
? "$-Infinity"
: "$NaN"
);
if ("undefined" === typeof value) return "$undefined";
if ("function" === typeof value) {
if (value instanceof JSResourceReferenceImpl)
@@ -814,12 +915,15 @@ function fatalError(request, error) {
function emitErrorChunkProd(request, id, digest) {
request.completedErrorChunks.push(["E", id, { digest: digest }]);
}
function emitHintChunk(request, code, model) {
request.nextChunkId++;
request.completedHintChunks.push(["H", code, model]);
}
function performWork(request$jscomp$0) {
var prevDispatcher = ReactCurrentDispatcher.current,
prevCache = currentCache;
var prevDispatcher = ReactCurrentDispatcher.current;
ReactCurrentDispatcher.current = HooksDispatcher;
currentCache = request$jscomp$0.cache;
currentRequest = request$jscomp$0;
var prevRequest = currentRequest;
currentRequest$1 = currentRequest = request$jscomp$0;
try {
var pingedTasks = request$jscomp$0.pingedTasks;
request$jscomp$0.pingedTasks = [];
@@ -898,29 +1002,49 @@ function performWork(request$jscomp$0) {
fatalError(request$jscomp$0, error);
} finally {
(ReactCurrentDispatcher.current = prevDispatcher),
(currentCache = prevCache),
(currentRequest = null);
(currentRequest$1 = null),
(currentRequest = prevRequest);
}
}
function flushCompletedChunks(request, destination) {
for (
var importsChunks = request.completedImportChunks, i = 0;
i < importsChunks.length;
i++
)
request.pendingChunks--, writeChunkAndReturn(destination, importsChunks[i]);
importsChunks.splice(0, i);
importsChunks = request.completedJSONChunks;
for (i = 0; i < importsChunks.length; i++)
request.pendingChunks--, writeChunkAndReturn(destination, importsChunks[i]);
importsChunks.splice(0, i);
importsChunks = request.completedErrorChunks;
for (i = 0; i < importsChunks.length; i++)
request.pendingChunks--, writeChunkAndReturn(destination, importsChunks[i]);
importsChunks.splice(0, i);
try {
for (
var importsChunks = request.completedImportChunks, i = 0;
i < importsChunks.length;
i++
)
request.pendingChunks--,
writeChunkAndReturn(destination, importsChunks[i]);
importsChunks.splice(0, i);
var hintChunks = request.completedHintChunks;
for (i = 0; i < hintChunks.length; i++)
writeChunkAndReturn(destination, hintChunks[i]);
hintChunks.splice(0, i);
var jsonChunks = request.completedJSONChunks;
for (i = 0; i < jsonChunks.length; i++)
request.pendingChunks--, writeChunkAndReturn(destination, jsonChunks[i]);
jsonChunks.splice(0, i);
var errorChunks = request.completedErrorChunks;
for (i = 0; i < errorChunks.length; i++)
request.pendingChunks--, writeChunkAndReturn(destination, errorChunks[i]);
errorChunks.splice(0, i);
} finally {
request.flushScheduled = !1;
}
0 === request.pendingChunks &&
ReactFlightDOMRelayServerIntegration.close(destination);
}
function enqueueFlush(request) {
if (
!1 === request.flushScheduled &&
0 === request.pingedTasks.length &&
null !== request.destination
) {
var destination = request.destination;
request.flushScheduled = !0;
flushCompletedChunks(request, destination);
}
}
function importServerContexts(contexts) {
if (contexts) {
var prevContext = currentActiveSnapshot;
@@ -950,6 +1074,7 @@ exports.render = function (model, destination, config, options) {
void 0,
options ? options.identifierPrefix : void 0
);
model.flushScheduled = null !== model.destination;
performWork(model);
if (1 === model.status)
(model.status = 2), ReactFlightDOMRelayServerIntegration.close(destination);
@@ -13,6 +13,7 @@
"use strict";
var JSResourceReferenceImpl = require("JSResourceReferenceImpl"),
ReactFlightDOMRelayServerIntegration = require("ReactFlightDOMRelayServerIntegration"),
ReactDOM = require("react-dom"),
React = require("react"),
hasOwnProperty = Object.prototype.hasOwnProperty,
isArrayImpl = Array.isArray;
@@ -47,7 +48,80 @@ function writeChunkAndReturn(destination, chunk) {
ReactFlightDOMRelayServerIntegration.emitRow(destination, chunk);
return !0;
}
var REACT_ELEMENT_TYPE = Symbol.for("react.element"),
var ReactDOMSharedInternals =
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
require("ReactFeatureFlags");
var ReactDOMFlightServerDispatcher = {
prefetchDNS: prefetchDNS,
preconnect: preconnect,
preload: preload,
preinit: preinit
};
function prefetchDNS(href, options) {
if ("string" === typeof href) {
var request = currentRequest ? currentRequest : null;
if (request) {
var hints = request.hints,
key = "D" + href;
hints.has(key) ||
(hints.add(key),
options
? emitHintChunk(request, "D", [href, options])
: emitHintChunk(request, "D", href),
enqueueFlush(request));
}
}
}
function preconnect(href, options) {
if ("string" === typeof href) {
var request = currentRequest ? currentRequest : null;
if (request) {
var hints = request.hints,
crossOrigin =
null == options || "string" !== typeof options.crossOrigin
? null
: "use-credentials" === options.crossOrigin
? "use-credentials"
: "";
crossOrigin =
"C" + (null === crossOrigin ? "null" : crossOrigin) + "|" + href;
hints.has(crossOrigin) ||
(hints.add(crossOrigin),
options
? emitHintChunk(request, "C", [href, options])
: emitHintChunk(request, "C", href),
enqueueFlush(request));
}
}
}
function preload(href, options) {
if ("string" === typeof href) {
var request = currentRequest ? currentRequest : null;
if (request) {
var hints = request.hints,
key = "L" + href;
hints.has(key) ||
(hints.add(key),
emitHintChunk(request, "L", [href, options]),
enqueueFlush(request));
}
}
}
function preinit(href, options) {
if ("string" === typeof href) {
var request = currentRequest ? currentRequest : null;
if (request) {
var hints = request.hints,
key = "I" + href;
hints.has(key) ||
(hints.add(key),
emitHintChunk(request, "I", [href, options]),
enqueueFlush(request));
}
}
}
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher,
REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context"),
@@ -141,7 +215,6 @@ function pushProvider(context, nextValue) {
value: nextValue
});
}
require("ReactFeatureFlags");
var SuspenseException = Error(
"Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`"
);
@@ -198,7 +271,7 @@ function getSuspendedThenable() {
suspendedThenable = null;
return thenable;
}
var currentRequest = null,
var currentRequest$1 = null,
thenableIndexCounter = 0,
thenableState = null;
function getThenableStateAfterSuspending() {
@@ -248,10 +321,10 @@ function unsupportedRefresh() {
throw Error("Refreshing the cache is not supported in Server Components.");
}
function useId() {
if (null === currentRequest)
if (null === currentRequest$1)
throw Error("useId can only be used while React is rendering");
var id = currentRequest.identifierCount++;
return ":" + currentRequest.identifierPrefix + "S" + id.toString(32) + ":";
var id = currentRequest$1.identifierCount++;
return ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":";
}
function use(usable) {
if (
@@ -272,23 +345,26 @@ function use(usable) {
function createSignal() {
return new AbortController().signal;
}
function resolveCache() {
var request = currentRequest ? currentRequest : null;
return request ? request.cache : new Map();
}
var DefaultCacheDispatcher = {
getCacheSignal: function () {
var cache = currentCache ? currentCache : new Map(),
entry = cache.get(createSignal);
void 0 === entry &&
((entry = createSignal()), cache.set(createSignal, entry));
return entry;
},
getCacheForType: function (resourceType) {
var cache = currentCache ? currentCache : new Map(),
entry = cache.get(resourceType);
void 0 === entry &&
((entry = resourceType()), cache.set(resourceType, entry));
return entry;
}
getCacheSignal: function () {
var cache = resolveCache(),
entry = cache.get(createSignal);
void 0 === entry &&
((entry = createSignal()), cache.set(createSignal, entry));
return entry;
},
currentCache = null;
getCacheForType: function (resourceType) {
var cache = resolveCache(),
entry = cache.get(resourceType);
void 0 === entry &&
((entry = resourceType()), cache.set(resourceType, entry));
return entry;
}
};
function objectName(object) {
return Object.prototype.toString
.call(object)
@@ -300,7 +376,7 @@ function describeValueForErrorMessage(value) {
switch (typeof value) {
case "string":
return JSON.stringify(
10 >= value.length ? value : value.substr(0, 10) + "..."
10 >= value.length ? value : value.slice(0, 10) + "..."
);
case "object":
if (isArrayImpl(value)) return "[...]";
@@ -410,20 +486,25 @@ function createRequest(
ReactCurrentCache.current !== DefaultCacheDispatcher
)
throw Error("Currently React only supports one RSC renderer at a time.");
ReactDOMCurrentDispatcher.current = ReactDOMFlightServerDispatcher;
ReactCurrentCache.current = DefaultCacheDispatcher;
var abortSet = new Set(),
pingedTasks = [],
hints = new Set(),
request = {
status: 0,
flushScheduled: !1,
fatalError: null,
destination: null,
bundlerConfig: bundlerConfig,
cache: new Map(),
nextChunkId: 0,
pendingChunks: 0,
hints: hints,
abortableTasks: abortSet,
pingedTasks: pingedTasks,
completedImportChunks: [],
completedHintChunks: [],
completedJSONChunks: [],
completedErrorChunks: [],
writtenSymbols: new Map(),
@@ -443,7 +524,8 @@ function createRequest(
pingedTasks.push(model);
return request;
}
var POP = {};
var currentRequest = null,
POP = {};
function serializeThenable(request, thenable) {
request.pendingChunks++;
var newTask = createTask(
@@ -599,7 +681,9 @@ function attemptResolveElement(
function pingTask(request, task) {
var pingedTasks = request.pingedTasks;
pingedTasks.push(task);
1 === pingedTasks.length && performWork(request);
1 === pingedTasks.length &&
((request.flushScheduled = null !== request.destination),
performWork(request));
}
function createTask(request, model, context, abortSet) {
var task = {
@@ -751,9 +835,26 @@ function resolveModelToJSON(request, parent, key, value) {
? Array.from(value)
: value;
}
if ("string" === typeof value)
return (request = "$" === value[0] ? "$" + value : value), request;
if ("boolean" === typeof value || "number" === typeof value) return value;
if ("string" === typeof value) {
if ("Z" === value[value.length - 1] && parent[key] instanceof Date)
return "$D" + value;
request = "$" === value[0] ? "$" + value : value;
return request;
}
if ("boolean" === typeof value) return value;
if ("number" === typeof value)
return (
(request = value),
Number.isFinite(request)
? 0 === request && -Infinity === 1 / request
? "$-0"
: request
: Infinity === request
? "$Infinity"
: -Infinity === request
? "$-Infinity"
: "$NaN"
);
if ("undefined" === typeof value) return "$undefined";
if ("function" === typeof value) {
if (value instanceof JSResourceReferenceImpl)
@@ -814,12 +915,15 @@ function fatalError(request, error) {
function emitErrorChunkProd(request, id, digest) {
request.completedErrorChunks.push(["E", id, { digest: digest }]);
}
function emitHintChunk(request, code, model) {
request.nextChunkId++;
request.completedHintChunks.push(["H", code, model]);
}
function performWork(request$jscomp$0) {
var prevDispatcher = ReactCurrentDispatcher.current,
prevCache = currentCache;
var prevDispatcher = ReactCurrentDispatcher.current;
ReactCurrentDispatcher.current = HooksDispatcher;
currentCache = request$jscomp$0.cache;
currentRequest = request$jscomp$0;
var prevRequest = currentRequest;
currentRequest$1 = currentRequest = request$jscomp$0;
try {
var pingedTasks = request$jscomp$0.pingedTasks;
request$jscomp$0.pingedTasks = [];
@@ -898,29 +1002,49 @@ function performWork(request$jscomp$0) {
fatalError(request$jscomp$0, error);
} finally {
(ReactCurrentDispatcher.current = prevDispatcher),
(currentCache = prevCache),
(currentRequest = null);
(currentRequest$1 = null),
(currentRequest = prevRequest);
}
}
function flushCompletedChunks(request, destination) {
for (
var importsChunks = request.completedImportChunks, i = 0;
i < importsChunks.length;
i++
)
request.pendingChunks--, writeChunkAndReturn(destination, importsChunks[i]);
importsChunks.splice(0, i);
importsChunks = request.completedJSONChunks;
for (i = 0; i < importsChunks.length; i++)
request.pendingChunks--, writeChunkAndReturn(destination, importsChunks[i]);
importsChunks.splice(0, i);
importsChunks = request.completedErrorChunks;
for (i = 0; i < importsChunks.length; i++)
request.pendingChunks--, writeChunkAndReturn(destination, importsChunks[i]);
importsChunks.splice(0, i);
try {
for (
var importsChunks = request.completedImportChunks, i = 0;
i < importsChunks.length;
i++
)
request.pendingChunks--,
writeChunkAndReturn(destination, importsChunks[i]);
importsChunks.splice(0, i);
var hintChunks = request.completedHintChunks;
for (i = 0; i < hintChunks.length; i++)
writeChunkAndReturn(destination, hintChunks[i]);
hintChunks.splice(0, i);
var jsonChunks = request.completedJSONChunks;
for (i = 0; i < jsonChunks.length; i++)
request.pendingChunks--, writeChunkAndReturn(destination, jsonChunks[i]);
jsonChunks.splice(0, i);
var errorChunks = request.completedErrorChunks;
for (i = 0; i < errorChunks.length; i++)
request.pendingChunks--, writeChunkAndReturn(destination, errorChunks[i]);
errorChunks.splice(0, i);
} finally {
request.flushScheduled = !1;
}
0 === request.pendingChunks &&
ReactFlightDOMRelayServerIntegration.close(destination);
}
function enqueueFlush(request) {
if (
!1 === request.flushScheduled &&
0 === request.pingedTasks.length &&
null !== request.destination
) {
var destination = request.destination;
request.flushScheduled = !0;
flushCompletedChunks(request, destination);
}
}
function importServerContexts(contexts) {
if (contexts) {
var prevContext = currentActiveSnapshot;
@@ -950,6 +1074,7 @@ exports.render = function (model, destination, config, options) {
void 0,
options ? options.identifierPrefix : void 0
);
model.flushScheduled = null !== model.destination;
performWork(model);
if (1 === model.status)
(model.status = 2), ReactFlightDOMRelayServerIntegration.close(destination);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+11
View File
@@ -55,6 +55,7 @@
"%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)."
"<%s /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements."
"<SuspenseList tail=\"%s\" /> is only valid if revealOrder is \"forwards\" or \"backwards\". Did you mean to specify revealOrder=\"forwards\"?"
"A button can only specify a formAction along with type=\"submit\" or no type."
"A cache instance was released after it was already freed. This likely indicates a bug in React."
"A cache instance was retained after it was already freed. This likely indicates a bug in React."
"A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional."
@@ -77,6 +78,7 @@
"An empty string (\"\") was passed to the %s attribute. This may cause the browser to download the whole page again over the network. To fix this, either do not render the element at all or pass null to %s instead of an empty string."
"An empty string (\"\") was passed to the %s attribute. To fix this, either do not render the element at all or pass null to %s instead of an empty string."
"An error occurred during hydration. The server HTML was replaced with client content in <%s>."
"An input can only specify a formAction along with type=\"submit\" or type=\"image\"."
"An invalid container has been provided. This may indicate that another renderer is being used in addition to the test renderer. (For example, ReactDOM.createPortal inside of a ReactTestRenderer tree.) This is not supported."
"An update (setState, replaceState, or forceUpdate) was scheduled from inside an update function. Update functions should be pure, with zero side-effects. Consider using componentDidUpdate or a callback.\n\nPlease update the following component: %s"
"An update to %s inside a test was not wrapped in act(...).\n\nWhen testing, code that causes React state updates should be wrapped into act(...):\n\nact(() => {\n /* fire events that update state */\n});\n/* assert on the output */\n\nThis ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act"
@@ -101,6 +103,11 @@
"Cannot render a <script> with onLoad or onError listeners outside the main document. Try removing onLoad={...} and onError={...} or moving it into the root <head> tag or somewhere in the <body>."
"Cannot render a <style> outside the main document without knowing its precedence and a unique href key. React can hoist and deduplicate <style> tags if you provide a `precedence` prop along with an `href` prop that does not conflic with the `href` values used in any other hoisted <style> or <link rel=\"stylesheet\" ...> tags. Note that hoisting <style> tags is considered an advanced feature that most will not use directly. Consider moving the <style> tag to the <head> or consider adding a `precedence=\"default\"` and `href=\"some unique resource identifier\"`, or move the <style> to the <style> tag."
"Cannot render a sync or defer <script> outside the main document without knowing its order. Try adding async=\"\" or moving it into the root <head> tag."
"Cannot specify a \"name\" prop for a button that specifies a function as a formAction. React needs it to encode which action should be invoked. It will get overridden."
"Cannot specify a encType or method for a form that specifies a function as the action. React provides those automatically. They will get overridden."
"Cannot specify a formEncType or formMethod for a button that specifies a function as a formAction. React provides those automatically. They will get overridden."
"Cannot specify a formTarget for a button that specifies a function as a formAction. The function will always be executed in the same window."
"Cannot specify a target for a form that specifies a function as the action. The function will always be executed in the same window."
"Cannot update a component (`%s`) while rendering a different component (`%s`). To locate the bad setState() call inside `%s`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render"
"Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state."
"Cannot update the \"is\" prop after it has been initialized."
@@ -341,6 +348,10 @@
"You are setting the style `{ %s: ... }` as a prop. You should nest it in a style object. E.g. `{ style: { %s: ... } }`"
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
"You can only pass the action prop to <form>. Use the formAction prop on <input> or <button>."
"You can only pass the action prop to <form>."
"You can only pass the formAction prop to <input> or <button>. Use the action prop on <form>."
"You can only pass the formAction prop to <input> or <button>."
"You did not run Node.js with the `--conditions react-server` flag. Any \"react-server\" override will only work with ESM imports."
"You passed a JSX element to createRoot. You probably meant to call root.render instead. Example usage:\n\n let root = createRoot(domContainer);\n root.render(<App />);"
"You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root."
@@ -1812,7 +1812,7 @@ var ExhaustiveDeps = {
break;
case 'updater':
extraWarning = " You can also do a functional update '" + setStateRecommendation.setter + "(" + setStateRecommendation.missingDep.substring(0, 1) + " => ...)' if you only need '" + setStateRecommendation.missingDep + "'" + (" in the '" + setStateRecommendation.setter + "' call.");
extraWarning = " You can also do a functional update '" + setStateRecommendation.setter + "(" + setStateRecommendation.missingDep.slice(0, 1) + " => ...)' if you only need '" + setStateRecommendation.missingDep + "'" + (" in the '" + setStateRecommendation.setter + "' call.");
break;
default: