mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[Fizz] Encode external fizz runtime into chunks eagerly (#26752)
in https://github.com/facebook/react/pull/26738 we added nonce to the
ResponseState. Initially it was used in a variety of places but the
version that got merged only included it with the external fizz runtime.
This PR updates the config for the external fizz runtime so that the
nonce is encoded into the script chunks at request creation time.
The rationale is that for live-requests, streaming is more likely than
not so doing the encoding work at the start is better than during flush.
For cases such as SSG where the runtime is not required the extra
encoding is tolerable (not a live request). Bots are an interesting case
because if you want fastest TTFB you will end up requiring the runtime
but if you are withholding until the stream is done you have already
sacrificed fastest TTFB and the marginal slowdown of the extraneous
encoding is hopefully neglibible
I'm writing this so later if we learn that this tradeoff isn't worth it
we at least understand why I made the change in the first place.
DiffTrain build for [8ea96ef84d](https://github.com/facebook/react/commit/8ea96ef84d8f08ed1846dec9e8ed20d2225db0d3)
This commit is contained in:
@@ -1 +1 @@
|
||||
491aec5d6113ce5bae7c10966bc38a4a8fc091a8
|
||||
8ea96ef84d8f08ed1846dec9e8ed20d2225db0d3
|
||||
|
||||
@@ -19,7 +19,7 @@ if (__DEV__) {
|
||||
var React = require("react");
|
||||
var ReactDOM = require("react-dom");
|
||||
|
||||
var ReactVersion = "18.3.0-www-classic-cc24eed6";
|
||||
var ReactVersion = "18.3.0-www-classic-fcee71d2";
|
||||
|
||||
// This refers to a WWW module.
|
||||
var warningWWW = require("warning");
|
||||
@@ -2415,7 +2415,7 @@ function createResponseState$1(
|
||||
'<script nonce="' + escapeTextForBrowser(nonce) + '">'
|
||||
);
|
||||
var bootstrapChunks = [];
|
||||
var externalRuntimeDesc = null;
|
||||
var externalRuntimeScript = null;
|
||||
var streamingFormat = ScriptStreamingFormat;
|
||||
|
||||
if (bootstrapScriptContent !== undefined) {
|
||||
@@ -2431,12 +2431,27 @@ function createResponseState$1(
|
||||
streamingFormat = DataStreamingFormat;
|
||||
|
||||
if (typeof externalRuntimeConfig === "string") {
|
||||
externalRuntimeDesc = {
|
||||
externalRuntimeScript = {
|
||||
src: externalRuntimeConfig,
|
||||
integrity: undefined
|
||||
chunks: []
|
||||
};
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig,
|
||||
async: true,
|
||||
integrity: undefined,
|
||||
nonce: nonce
|
||||
});
|
||||
} else {
|
||||
externalRuntimeDesc = externalRuntimeConfig;
|
||||
externalRuntimeScript = {
|
||||
src: externalRuntimeConfig.src,
|
||||
chunks: []
|
||||
};
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig.src,
|
||||
async: true,
|
||||
integrity: externalRuntimeConfig.integrity,
|
||||
nonce: nonce
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2514,7 +2529,7 @@ function createResponseState$1(
|
||||
streamingFormat: streamingFormat,
|
||||
startInlineScript: inlineScriptWithNonce,
|
||||
instructions: NothingSent,
|
||||
externalRuntimeConfig: externalRuntimeDesc,
|
||||
externalRuntimeScript: externalRuntimeScript,
|
||||
htmlChunks: null,
|
||||
headChunks: null,
|
||||
hasBody: false,
|
||||
@@ -6194,16 +6209,16 @@ function writePreamble(
|
||||
willFlushAllSegments
|
||||
) {
|
||||
// This function must be called exactly once on every request
|
||||
if (!willFlushAllSegments && responseState.externalRuntimeConfig) {
|
||||
if (!willFlushAllSegments && responseState.externalRuntimeScript) {
|
||||
// If the root segment is incomplete due to suspended tasks
|
||||
// (e.g. willFlushAllSegments = false) and we are using data
|
||||
// streaming format, ensure the external runtime is sent.
|
||||
// (User code could choose to send this even earlier by calling
|
||||
// preinit(...), if they know they will suspend).
|
||||
var _responseState$extern = responseState.externalRuntimeConfig,
|
||||
var _responseState$extern = responseState.externalRuntimeScript,
|
||||
src = _responseState$extern.src,
|
||||
integrity = _responseState$extern.integrity;
|
||||
internalPreinitScript(resources, src, integrity, responseState.nonce);
|
||||
chunks = _responseState$extern.chunks;
|
||||
internalPreinitScript(resources, src, chunks);
|
||||
}
|
||||
|
||||
var htmlChunks = responseState.htmlChunks;
|
||||
@@ -6258,10 +6273,10 @@ function writePreamble(
|
||||
|
||||
if (resources.stylesMap.has(key));
|
||||
else {
|
||||
var chunks = resource.chunks;
|
||||
var _chunks = resource.chunks;
|
||||
|
||||
for (i = 0; i < chunks.length; i++) {
|
||||
writeChunk(destination, chunks[i]);
|
||||
for (i = 0; i < _chunks.length; i++) {
|
||||
writeChunk(destination, _chunks[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -7425,29 +7440,21 @@ function preinit(href, options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} // 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, nonce) {
|
||||
function internalPreinitScript(resources, src, chunks) {
|
||||
var key = getResourceKey("script", src);
|
||||
var resource = resources.scriptsMap.get(key);
|
||||
|
||||
if (!resource) {
|
||||
resource = {
|
||||
type: "script",
|
||||
chunks: [],
|
||||
chunks: chunks,
|
||||
state: NoState,
|
||||
props: null
|
||||
};
|
||||
resources.scriptsMap.set(key, resource);
|
||||
resources.scripts.add(resource);
|
||||
pushScriptImpl(resource.chunks, {
|
||||
async: true,
|
||||
src: src,
|
||||
integrity: integrity,
|
||||
nonce: nonce
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -7627,7 +7634,7 @@ function createResponseState(
|
||||
streamingFormat: responseState.streamingFormat,
|
||||
startInlineScript: responseState.startInlineScript,
|
||||
instructions: responseState.instructions,
|
||||
externalRuntimeConfig: responseState.externalRuntimeConfig,
|
||||
externalRuntimeScript: responseState.externalRuntimeScript,
|
||||
htmlChunks: responseState.htmlChunks,
|
||||
headChunks: responseState.headChunks,
|
||||
hasBody: responseState.hasBody,
|
||||
@@ -7636,7 +7643,6 @@ function createResponseState(
|
||||
preloadChunks: responseState.preloadChunks,
|
||||
hoistableChunks: responseState.hoistableChunks,
|
||||
stylesToHoist: responseState.stylesToHoist,
|
||||
nonce: responseState.nonce,
|
||||
// This is an extra field for the legacy renderer
|
||||
generateStaticMarkup: generateStaticMarkup
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ if (__DEV__) {
|
||||
var React = require("react");
|
||||
var ReactDOM = require("react-dom");
|
||||
|
||||
var ReactVersion = "18.3.0-www-modern-10c90c32";
|
||||
var ReactVersion = "18.3.0-www-modern-938c86f0";
|
||||
|
||||
// This refers to a WWW module.
|
||||
var warningWWW = require("warning");
|
||||
@@ -2415,7 +2415,7 @@ function createResponseState$1(
|
||||
'<script nonce="' + escapeTextForBrowser(nonce) + '">'
|
||||
);
|
||||
var bootstrapChunks = [];
|
||||
var externalRuntimeDesc = null;
|
||||
var externalRuntimeScript = null;
|
||||
var streamingFormat = ScriptStreamingFormat;
|
||||
|
||||
if (bootstrapScriptContent !== undefined) {
|
||||
@@ -2431,12 +2431,27 @@ function createResponseState$1(
|
||||
streamingFormat = DataStreamingFormat;
|
||||
|
||||
if (typeof externalRuntimeConfig === "string") {
|
||||
externalRuntimeDesc = {
|
||||
externalRuntimeScript = {
|
||||
src: externalRuntimeConfig,
|
||||
integrity: undefined
|
||||
chunks: []
|
||||
};
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig,
|
||||
async: true,
|
||||
integrity: undefined,
|
||||
nonce: nonce
|
||||
});
|
||||
} else {
|
||||
externalRuntimeDesc = externalRuntimeConfig;
|
||||
externalRuntimeScript = {
|
||||
src: externalRuntimeConfig.src,
|
||||
chunks: []
|
||||
};
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig.src,
|
||||
async: true,
|
||||
integrity: externalRuntimeConfig.integrity,
|
||||
nonce: nonce
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2514,7 +2529,7 @@ function createResponseState$1(
|
||||
streamingFormat: streamingFormat,
|
||||
startInlineScript: inlineScriptWithNonce,
|
||||
instructions: NothingSent,
|
||||
externalRuntimeConfig: externalRuntimeDesc,
|
||||
externalRuntimeScript: externalRuntimeScript,
|
||||
htmlChunks: null,
|
||||
headChunks: null,
|
||||
hasBody: false,
|
||||
@@ -6194,16 +6209,16 @@ function writePreamble(
|
||||
willFlushAllSegments
|
||||
) {
|
||||
// This function must be called exactly once on every request
|
||||
if (!willFlushAllSegments && responseState.externalRuntimeConfig) {
|
||||
if (!willFlushAllSegments && responseState.externalRuntimeScript) {
|
||||
// If the root segment is incomplete due to suspended tasks
|
||||
// (e.g. willFlushAllSegments = false) and we are using data
|
||||
// streaming format, ensure the external runtime is sent.
|
||||
// (User code could choose to send this even earlier by calling
|
||||
// preinit(...), if they know they will suspend).
|
||||
var _responseState$extern = responseState.externalRuntimeConfig,
|
||||
var _responseState$extern = responseState.externalRuntimeScript,
|
||||
src = _responseState$extern.src,
|
||||
integrity = _responseState$extern.integrity;
|
||||
internalPreinitScript(resources, src, integrity, responseState.nonce);
|
||||
chunks = _responseState$extern.chunks;
|
||||
internalPreinitScript(resources, src, chunks);
|
||||
}
|
||||
|
||||
var htmlChunks = responseState.htmlChunks;
|
||||
@@ -6258,10 +6273,10 @@ function writePreamble(
|
||||
|
||||
if (resources.stylesMap.has(key));
|
||||
else {
|
||||
var chunks = resource.chunks;
|
||||
var _chunks = resource.chunks;
|
||||
|
||||
for (i = 0; i < chunks.length; i++) {
|
||||
writeChunk(destination, chunks[i]);
|
||||
for (i = 0; i < _chunks.length; i++) {
|
||||
writeChunk(destination, _chunks[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -7425,29 +7440,21 @@ function preinit(href, options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} // 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, nonce) {
|
||||
function internalPreinitScript(resources, src, chunks) {
|
||||
var key = getResourceKey("script", src);
|
||||
var resource = resources.scriptsMap.get(key);
|
||||
|
||||
if (!resource) {
|
||||
resource = {
|
||||
type: "script",
|
||||
chunks: [],
|
||||
chunks: chunks,
|
||||
state: NoState,
|
||||
props: null
|
||||
};
|
||||
resources.scriptsMap.set(key, resource);
|
||||
resources.scripts.add(resource);
|
||||
pushScriptImpl(resource.chunks, {
|
||||
async: true,
|
||||
src: src,
|
||||
integrity: integrity,
|
||||
nonce: nonce
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -7627,7 +7634,7 @@ function createResponseState(
|
||||
streamingFormat: responseState.streamingFormat,
|
||||
startInlineScript: responseState.startInlineScript,
|
||||
instructions: responseState.instructions,
|
||||
externalRuntimeConfig: responseState.externalRuntimeConfig,
|
||||
externalRuntimeScript: responseState.externalRuntimeScript,
|
||||
htmlChunks: responseState.htmlChunks,
|
||||
headChunks: responseState.headChunks,
|
||||
hasBody: responseState.hasBody,
|
||||
@@ -7636,7 +7643,6 @@ function createResponseState(
|
||||
preloadChunks: responseState.preloadChunks,
|
||||
hoistableChunks: responseState.hoistableChunks,
|
||||
stylesToHoist: responseState.stylesToHoist,
|
||||
nonce: responseState.nonce,
|
||||
// This is an extra field for the legacy renderer
|
||||
generateStaticMarkup: generateStaticMarkup
|
||||
};
|
||||
|
||||
@@ -1623,13 +1623,12 @@ function writePreamble(
|
||||
willFlushAllSegments
|
||||
) {
|
||||
!willFlushAllSegments &&
|
||||
responseState.externalRuntimeConfig &&
|
||||
((willFlushAllSegments = responseState.externalRuntimeConfig),
|
||||
responseState.externalRuntimeScript &&
|
||||
((willFlushAllSegments = responseState.externalRuntimeScript),
|
||||
internalPreinitScript(
|
||||
resources,
|
||||
willFlushAllSegments.src,
|
||||
willFlushAllSegments.integrity,
|
||||
responseState.nonce
|
||||
willFlushAllSegments.chunks
|
||||
));
|
||||
willFlushAllSegments = responseState.htmlChunks;
|
||||
var headChunks = responseState.headChunks,
|
||||
@@ -2080,19 +2079,13 @@ function preinit(href, options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function internalPreinitScript(resources, src, integrity, nonce) {
|
||||
var key = "[script]" + src,
|
||||
resource = resources.scriptsMap.get(key);
|
||||
function internalPreinitScript(resources, src, chunks) {
|
||||
src = "[script]" + src;
|
||||
var resource = resources.scriptsMap.get(src);
|
||||
resource ||
|
||||
((resource = { type: "script", chunks: [], state: 0, props: null }),
|
||||
resources.scriptsMap.set(key, resource),
|
||||
resources.scripts.add(resource),
|
||||
pushScriptImpl(resource.chunks, {
|
||||
async: !0,
|
||||
src: src,
|
||||
integrity: integrity,
|
||||
nonce: nonce
|
||||
}));
|
||||
((resource = { type: "script", chunks: chunks, state: 0, props: null }),
|
||||
resources.scriptsMap.set(src, resource),
|
||||
resources.scripts.add(resource));
|
||||
}
|
||||
function preloadAsStylePropsFromProps(href, props) {
|
||||
return {
|
||||
@@ -2115,14 +2108,28 @@ function createResponseState(
|
||||
externalRuntimeConfig
|
||||
) {
|
||||
identifierPrefix = void 0 === identifierPrefix ? "" : identifierPrefix;
|
||||
var externalRuntimeDesc = null,
|
||||
var externalRuntimeScript = null,
|
||||
streamingFormat = 0;
|
||||
void 0 !== externalRuntimeConfig &&
|
||||
((streamingFormat = 1),
|
||||
(externalRuntimeDesc =
|
||||
"string" === typeof externalRuntimeConfig
|
||||
? { src: externalRuntimeConfig, integrity: void 0 }
|
||||
: externalRuntimeConfig));
|
||||
"string" === typeof externalRuntimeConfig
|
||||
? ((externalRuntimeScript = { src: externalRuntimeConfig, chunks: [] }),
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig,
|
||||
async: !0,
|
||||
integrity: void 0,
|
||||
nonce: void 0
|
||||
}))
|
||||
: ((externalRuntimeScript = {
|
||||
src: externalRuntimeConfig.src,
|
||||
chunks: []
|
||||
}),
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig.src,
|
||||
async: !0,
|
||||
integrity: externalRuntimeConfig.integrity,
|
||||
nonce: void 0
|
||||
})));
|
||||
return {
|
||||
bootstrapChunks: [],
|
||||
placeholderPrefix: identifierPrefix + "P:",
|
||||
@@ -2133,7 +2140,7 @@ function createResponseState(
|
||||
streamingFormat: streamingFormat,
|
||||
startInlineScript: "<script>",
|
||||
instructions: 0,
|
||||
externalRuntimeConfig: externalRuntimeDesc,
|
||||
externalRuntimeScript: externalRuntimeScript,
|
||||
htmlChunks: null,
|
||||
headChunks: null,
|
||||
hasBody: !1,
|
||||
@@ -2142,7 +2149,6 @@ function createResponseState(
|
||||
preloadChunks: [],
|
||||
hoistableChunks: [],
|
||||
stylesToHoist: !1,
|
||||
nonce: void 0,
|
||||
generateStaticMarkup: generateStaticMarkup
|
||||
};
|
||||
}
|
||||
@@ -3297,7 +3303,7 @@ function renderNode(request, task, node) {
|
||||
null !== node &&
|
||||
"function" === typeof node.then)
|
||||
) {
|
||||
var thenableState$14 = getThenableStateAfterSuspending(),
|
||||
var thenableState$15 = getThenableStateAfterSuspending(),
|
||||
segment = task.blockedSegment,
|
||||
newSegment = createPendingSegment(
|
||||
request,
|
||||
@@ -3311,7 +3317,7 @@ function renderNode(request, task, node) {
|
||||
segment.lastPushedText = !1;
|
||||
request = createTask(
|
||||
request,
|
||||
thenableState$14,
|
||||
thenableState$15,
|
||||
task.node,
|
||||
task.blockedBoundary,
|
||||
newSegment,
|
||||
@@ -3811,13 +3817,13 @@ function flushCompletedQueues(request, destination) {
|
||||
completedBoundaries.splice(0, i);
|
||||
var partialBoundaries = request.partialBoundaries;
|
||||
for (i = 0; i < partialBoundaries.length; i++) {
|
||||
var boundary$16 = partialBoundaries[i];
|
||||
var boundary$17 = partialBoundaries[i];
|
||||
a: {
|
||||
clientRenderedBoundaries = request;
|
||||
boundary = destination;
|
||||
clientRenderedBoundaries.resources.boundaryResources =
|
||||
boundary$16.resources;
|
||||
var completedSegments = boundary$16.completedSegments;
|
||||
boundary$17.resources;
|
||||
var completedSegments = boundary$17.completedSegments;
|
||||
for (
|
||||
responseState = 0;
|
||||
responseState < completedSegments.length;
|
||||
@@ -3827,7 +3833,7 @@ function flushCompletedQueues(request, destination) {
|
||||
!flushPartiallyCompletedSegment(
|
||||
clientRenderedBoundaries,
|
||||
boundary,
|
||||
boundary$16,
|
||||
boundary$17,
|
||||
completedSegments[responseState]
|
||||
)
|
||||
) {
|
||||
@@ -3839,7 +3845,7 @@ function flushCompletedQueues(request, destination) {
|
||||
completedSegments.splice(0, responseState);
|
||||
JSCompiler_inline_result = writeResourcesForBoundary(
|
||||
boundary,
|
||||
boundary$16.resources,
|
||||
boundary$17.resources,
|
||||
clientRenderedBoundaries.responseState
|
||||
);
|
||||
}
|
||||
@@ -3902,8 +3908,8 @@ function abort(request, reason) {
|
||||
}
|
||||
null !== request.destination &&
|
||||
flushCompletedQueues(request, request.destination);
|
||||
} catch (error$18) {
|
||||
logRecoverableError(request, error$18), fatalError(request, error$18);
|
||||
} catch (error$19) {
|
||||
logRecoverableError(request, error$19), fatalError(request, error$19);
|
||||
}
|
||||
}
|
||||
function onError() {}
|
||||
@@ -3985,4 +3991,4 @@ exports.renderToString = function (children, options) {
|
||||
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
|
||||
);
|
||||
};
|
||||
exports.version = "18.3.0-www-classic-e4dd9d30";
|
||||
exports.version = "18.3.0-www-classic-ad0d70c8";
|
||||
|
||||
@@ -1622,13 +1622,12 @@ function writePreamble(
|
||||
willFlushAllSegments
|
||||
) {
|
||||
!willFlushAllSegments &&
|
||||
responseState.externalRuntimeConfig &&
|
||||
((willFlushAllSegments = responseState.externalRuntimeConfig),
|
||||
responseState.externalRuntimeScript &&
|
||||
((willFlushAllSegments = responseState.externalRuntimeScript),
|
||||
internalPreinitScript(
|
||||
resources,
|
||||
willFlushAllSegments.src,
|
||||
willFlushAllSegments.integrity,
|
||||
responseState.nonce
|
||||
willFlushAllSegments.chunks
|
||||
));
|
||||
willFlushAllSegments = responseState.htmlChunks;
|
||||
var headChunks = responseState.headChunks,
|
||||
@@ -2079,19 +2078,13 @@ function preinit(href, options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function internalPreinitScript(resources, src, integrity, nonce) {
|
||||
var key = "[script]" + src,
|
||||
resource = resources.scriptsMap.get(key);
|
||||
function internalPreinitScript(resources, src, chunks) {
|
||||
src = "[script]" + src;
|
||||
var resource = resources.scriptsMap.get(src);
|
||||
resource ||
|
||||
((resource = { type: "script", chunks: [], state: 0, props: null }),
|
||||
resources.scriptsMap.set(key, resource),
|
||||
resources.scripts.add(resource),
|
||||
pushScriptImpl(resource.chunks, {
|
||||
async: !0,
|
||||
src: src,
|
||||
integrity: integrity,
|
||||
nonce: nonce
|
||||
}));
|
||||
((resource = { type: "script", chunks: chunks, state: 0, props: null }),
|
||||
resources.scriptsMap.set(src, resource),
|
||||
resources.scripts.add(resource));
|
||||
}
|
||||
function preloadAsStylePropsFromProps(href, props) {
|
||||
return {
|
||||
@@ -2114,14 +2107,28 @@ function createResponseState(
|
||||
externalRuntimeConfig
|
||||
) {
|
||||
identifierPrefix = void 0 === identifierPrefix ? "" : identifierPrefix;
|
||||
var externalRuntimeDesc = null,
|
||||
var externalRuntimeScript = null,
|
||||
streamingFormat = 0;
|
||||
void 0 !== externalRuntimeConfig &&
|
||||
((streamingFormat = 1),
|
||||
(externalRuntimeDesc =
|
||||
"string" === typeof externalRuntimeConfig
|
||||
? { src: externalRuntimeConfig, integrity: void 0 }
|
||||
: externalRuntimeConfig));
|
||||
"string" === typeof externalRuntimeConfig
|
||||
? ((externalRuntimeScript = { src: externalRuntimeConfig, chunks: [] }),
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig,
|
||||
async: !0,
|
||||
integrity: void 0,
|
||||
nonce: void 0
|
||||
}))
|
||||
: ((externalRuntimeScript = {
|
||||
src: externalRuntimeConfig.src,
|
||||
chunks: []
|
||||
}),
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig.src,
|
||||
async: !0,
|
||||
integrity: externalRuntimeConfig.integrity,
|
||||
nonce: void 0
|
||||
})));
|
||||
return {
|
||||
bootstrapChunks: [],
|
||||
placeholderPrefix: identifierPrefix + "P:",
|
||||
@@ -2132,7 +2139,7 @@ function createResponseState(
|
||||
streamingFormat: streamingFormat,
|
||||
startInlineScript: "<script>",
|
||||
instructions: 0,
|
||||
externalRuntimeConfig: externalRuntimeDesc,
|
||||
externalRuntimeScript: externalRuntimeScript,
|
||||
htmlChunks: null,
|
||||
headChunks: null,
|
||||
hasBody: !1,
|
||||
@@ -2141,7 +2148,6 @@ function createResponseState(
|
||||
preloadChunks: [],
|
||||
hoistableChunks: [],
|
||||
stylesToHoist: !1,
|
||||
nonce: void 0,
|
||||
generateStaticMarkup: generateStaticMarkup
|
||||
};
|
||||
}
|
||||
@@ -3195,7 +3201,7 @@ function renderNode(request, task, node) {
|
||||
null !== node &&
|
||||
"function" === typeof node.then)
|
||||
) {
|
||||
var thenableState$14 = getThenableStateAfterSuspending(),
|
||||
var thenableState$15 = getThenableStateAfterSuspending(),
|
||||
segment = task.blockedSegment,
|
||||
newSegment = createPendingSegment(
|
||||
request,
|
||||
@@ -3209,7 +3215,7 @@ function renderNode(request, task, node) {
|
||||
segment.lastPushedText = !1;
|
||||
request = createTask(
|
||||
request,
|
||||
thenableState$14,
|
||||
thenableState$15,
|
||||
task.node,
|
||||
task.blockedBoundary,
|
||||
newSegment,
|
||||
@@ -3709,13 +3715,13 @@ function flushCompletedQueues(request, destination) {
|
||||
completedBoundaries.splice(0, i);
|
||||
var partialBoundaries = request.partialBoundaries;
|
||||
for (i = 0; i < partialBoundaries.length; i++) {
|
||||
var boundary$16 = partialBoundaries[i];
|
||||
var boundary$17 = partialBoundaries[i];
|
||||
a: {
|
||||
clientRenderedBoundaries = request;
|
||||
boundary = destination;
|
||||
clientRenderedBoundaries.resources.boundaryResources =
|
||||
boundary$16.resources;
|
||||
var completedSegments = boundary$16.completedSegments;
|
||||
boundary$17.resources;
|
||||
var completedSegments = boundary$17.completedSegments;
|
||||
for (
|
||||
responseState = 0;
|
||||
responseState < completedSegments.length;
|
||||
@@ -3725,7 +3731,7 @@ function flushCompletedQueues(request, destination) {
|
||||
!flushPartiallyCompletedSegment(
|
||||
clientRenderedBoundaries,
|
||||
boundary,
|
||||
boundary$16,
|
||||
boundary$17,
|
||||
completedSegments[responseState]
|
||||
)
|
||||
) {
|
||||
@@ -3737,7 +3743,7 @@ function flushCompletedQueues(request, destination) {
|
||||
completedSegments.splice(0, responseState);
|
||||
JSCompiler_inline_result = writeResourcesForBoundary(
|
||||
boundary,
|
||||
boundary$16.resources,
|
||||
boundary$17.resources,
|
||||
clientRenderedBoundaries.responseState
|
||||
);
|
||||
}
|
||||
@@ -3800,8 +3806,8 @@ function abort(request, reason) {
|
||||
}
|
||||
null !== request.destination &&
|
||||
flushCompletedQueues(request, request.destination);
|
||||
} catch (error$18) {
|
||||
logRecoverableError(request, error$18), fatalError(request, error$18);
|
||||
} catch (error$19) {
|
||||
logRecoverableError(request, error$19), fatalError(request, error$19);
|
||||
}
|
||||
}
|
||||
function onError() {}
|
||||
@@ -3883,4 +3889,4 @@ exports.renderToString = function (children, options) {
|
||||
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
|
||||
);
|
||||
};
|
||||
exports.version = "18.3.0-www-modern-83586ccd";
|
||||
exports.version = "18.3.0-www-modern-07269b39";
|
||||
|
||||
@@ -2412,7 +2412,7 @@ function createResponseState(
|
||||
'<script nonce="' + escapeTextForBrowser(nonce) + '">'
|
||||
);
|
||||
var bootstrapChunks = [];
|
||||
var externalRuntimeDesc = null;
|
||||
var externalRuntimeScript = null;
|
||||
var streamingFormat = ScriptStreamingFormat;
|
||||
|
||||
if (bootstrapScriptContent !== undefined) {
|
||||
@@ -2428,12 +2428,27 @@ function createResponseState(
|
||||
streamingFormat = DataStreamingFormat;
|
||||
|
||||
if (typeof externalRuntimeConfig === "string") {
|
||||
externalRuntimeDesc = {
|
||||
externalRuntimeScript = {
|
||||
src: externalRuntimeConfig,
|
||||
integrity: undefined
|
||||
chunks: []
|
||||
};
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig,
|
||||
async: true,
|
||||
integrity: undefined,
|
||||
nonce: nonce
|
||||
});
|
||||
} else {
|
||||
externalRuntimeDesc = externalRuntimeConfig;
|
||||
externalRuntimeScript = {
|
||||
src: externalRuntimeConfig.src,
|
||||
chunks: []
|
||||
};
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig.src,
|
||||
async: true,
|
||||
integrity: externalRuntimeConfig.integrity,
|
||||
nonce: nonce
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2511,7 +2526,7 @@ function createResponseState(
|
||||
streamingFormat: streamingFormat,
|
||||
startInlineScript: inlineScriptWithNonce,
|
||||
instructions: NothingSent,
|
||||
externalRuntimeConfig: externalRuntimeDesc,
|
||||
externalRuntimeScript: externalRuntimeScript,
|
||||
htmlChunks: null,
|
||||
headChunks: null,
|
||||
hasBody: false,
|
||||
@@ -6201,16 +6216,16 @@ function writePreamble(
|
||||
willFlushAllSegments
|
||||
) {
|
||||
// This function must be called exactly once on every request
|
||||
if (!willFlushAllSegments && responseState.externalRuntimeConfig) {
|
||||
if (!willFlushAllSegments && responseState.externalRuntimeScript) {
|
||||
// If the root segment is incomplete due to suspended tasks
|
||||
// (e.g. willFlushAllSegments = false) and we are using data
|
||||
// streaming format, ensure the external runtime is sent.
|
||||
// (User code could choose to send this even earlier by calling
|
||||
// preinit(...), if they know they will suspend).
|
||||
var _responseState$extern = responseState.externalRuntimeConfig,
|
||||
var _responseState$extern = responseState.externalRuntimeScript,
|
||||
src = _responseState$extern.src,
|
||||
integrity = _responseState$extern.integrity;
|
||||
internalPreinitScript(resources, src, integrity, responseState.nonce);
|
||||
chunks = _responseState$extern.chunks;
|
||||
internalPreinitScript(resources, src, chunks);
|
||||
}
|
||||
|
||||
var htmlChunks = responseState.htmlChunks;
|
||||
@@ -6265,10 +6280,10 @@ function writePreamble(
|
||||
|
||||
if (resources.stylesMap.has(key));
|
||||
else {
|
||||
var chunks = resource.chunks;
|
||||
var _chunks = resource.chunks;
|
||||
|
||||
for (i = 0; i < chunks.length; i++) {
|
||||
writeChunk(destination, chunks[i]);
|
||||
for (i = 0; i < _chunks.length; i++) {
|
||||
writeChunk(destination, _chunks[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -7432,29 +7447,21 @@ function preinit(href, options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} // 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, nonce) {
|
||||
function internalPreinitScript(resources, src, chunks) {
|
||||
var key = getResourceKey("script", src);
|
||||
var resource = resources.scriptsMap.get(key);
|
||||
|
||||
if (!resource) {
|
||||
resource = {
|
||||
type: "script",
|
||||
chunks: [],
|
||||
chunks: chunks,
|
||||
state: NoState,
|
||||
props: null
|
||||
};
|
||||
resources.scriptsMap.set(key, resource);
|
||||
resources.scripts.add(resource);
|
||||
pushScriptImpl(resource.chunks, {
|
||||
async: true,
|
||||
src: src,
|
||||
integrity: integrity,
|
||||
nonce: nonce
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -1653,13 +1653,12 @@ function writePreamble(
|
||||
willFlushAllSegments
|
||||
) {
|
||||
!willFlushAllSegments &&
|
||||
responseState.externalRuntimeConfig &&
|
||||
((willFlushAllSegments = responseState.externalRuntimeConfig),
|
||||
responseState.externalRuntimeScript &&
|
||||
((willFlushAllSegments = responseState.externalRuntimeScript),
|
||||
internalPreinitScript(
|
||||
resources,
|
||||
willFlushAllSegments.src,
|
||||
willFlushAllSegments.integrity,
|
||||
responseState.nonce
|
||||
willFlushAllSegments.chunks
|
||||
));
|
||||
willFlushAllSegments = responseState.htmlChunks;
|
||||
var headChunks = responseState.headChunks,
|
||||
@@ -2131,19 +2130,13 @@ function preinit(href, options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function internalPreinitScript(resources, src, integrity, nonce) {
|
||||
var key = "[script]" + src,
|
||||
resource = resources.scriptsMap.get(key);
|
||||
function internalPreinitScript(resources, src, chunks) {
|
||||
src = "[script]" + src;
|
||||
var resource = resources.scriptsMap.get(src);
|
||||
resource ||
|
||||
((resource = { type: "script", chunks: [], state: 0, props: null }),
|
||||
resources.scriptsMap.set(key, resource),
|
||||
resources.scripts.add(resource),
|
||||
pushScriptImpl(resource.chunks, {
|
||||
async: !0,
|
||||
src: src,
|
||||
integrity: integrity,
|
||||
nonce: nonce
|
||||
}));
|
||||
((resource = { type: "script", chunks: chunks, state: 0, props: null }),
|
||||
resources.scriptsMap.set(src, resource),
|
||||
resources.scripts.add(resource));
|
||||
}
|
||||
function preloadAsStylePropsFromProps(href, props) {
|
||||
return {
|
||||
@@ -3155,7 +3148,7 @@ function renderNode(request, task, node) {
|
||||
null !== node &&
|
||||
"function" === typeof node.then)
|
||||
) {
|
||||
var thenableState$14 = getThenableStateAfterSuspending(),
|
||||
var thenableState$15 = getThenableStateAfterSuspending(),
|
||||
segment = task.blockedSegment,
|
||||
newSegment = createPendingSegment(
|
||||
request,
|
||||
@@ -3169,7 +3162,7 @@ function renderNode(request, task, node) {
|
||||
segment.lastPushedText = !1;
|
||||
request = createTask(
|
||||
request,
|
||||
thenableState$14,
|
||||
thenableState$15,
|
||||
task.node,
|
||||
task.blockedBoundary,
|
||||
newSegment,
|
||||
@@ -3576,13 +3569,13 @@ function flushCompletedQueues(request, destination) {
|
||||
completedBoundaries.splice(0, i);
|
||||
var partialBoundaries = request.partialBoundaries;
|
||||
for (i = 0; i < partialBoundaries.length; i++) {
|
||||
var boundary$16 = partialBoundaries[i];
|
||||
var boundary$17 = partialBoundaries[i];
|
||||
a: {
|
||||
clientRenderedBoundaries = request;
|
||||
boundary = destination;
|
||||
clientRenderedBoundaries.resources.boundaryResources =
|
||||
boundary$16.resources;
|
||||
var completedSegments = boundary$16.completedSegments;
|
||||
boundary$17.resources;
|
||||
var completedSegments = boundary$17.completedSegments;
|
||||
for (
|
||||
responseState = 0;
|
||||
responseState < completedSegments.length;
|
||||
@@ -3592,7 +3585,7 @@ function flushCompletedQueues(request, destination) {
|
||||
!flushPartiallyCompletedSegment(
|
||||
clientRenderedBoundaries,
|
||||
boundary,
|
||||
boundary$16,
|
||||
boundary$17,
|
||||
completedSegments[responseState]
|
||||
)
|
||||
) {
|
||||
@@ -3604,7 +3597,7 @@ function flushCompletedQueues(request, destination) {
|
||||
completedSegments.splice(0, responseState);
|
||||
JSCompiler_inline_result = writeResourcesForBoundary(
|
||||
boundary,
|
||||
boundary$16.resources,
|
||||
boundary$17.resources,
|
||||
clientRenderedBoundaries.responseState
|
||||
);
|
||||
}
|
||||
@@ -3664,8 +3657,8 @@ function abort(request, reason) {
|
||||
}
|
||||
null !== request.destination &&
|
||||
flushCompletedQueues(request, request.destination);
|
||||
} catch (error$18) {
|
||||
logRecoverableError(request, error$18), fatalError(request, error$18);
|
||||
} catch (error$19) {
|
||||
logRecoverableError(request, error$19), fatalError(request, error$19);
|
||||
}
|
||||
}
|
||||
exports.abortStream = function (stream) {
|
||||
@@ -3807,7 +3800,7 @@ exports.renderToStream = function (children, options) {
|
||||
: void 0;
|
||||
identifierPrefix = void 0 === identifierPrefix ? "" : identifierPrefix;
|
||||
var JSCompiler_inline_result = [];
|
||||
var externalRuntimeDesc = null,
|
||||
var externalRuntimeScript = null,
|
||||
streamingFormat = 0;
|
||||
void 0 !== bootstrapScriptContent &&
|
||||
JSCompiler_inline_result.push(
|
||||
@@ -3817,10 +3810,24 @@ exports.renderToStream = function (children, options) {
|
||||
);
|
||||
void 0 !== externalRuntimeConfig &&
|
||||
((streamingFormat = 1),
|
||||
(externalRuntimeDesc =
|
||||
"string" === typeof externalRuntimeConfig
|
||||
? { src: externalRuntimeConfig, integrity: void 0 }
|
||||
: externalRuntimeConfig));
|
||||
"string" === typeof externalRuntimeConfig
|
||||
? ((externalRuntimeScript = { src: externalRuntimeConfig, chunks: [] }),
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig,
|
||||
async: !0,
|
||||
integrity: void 0,
|
||||
nonce: void 0
|
||||
}))
|
||||
: ((externalRuntimeScript = {
|
||||
src: externalRuntimeConfig.src,
|
||||
chunks: []
|
||||
}),
|
||||
pushScriptImpl(externalRuntimeScript.chunks, {
|
||||
src: externalRuntimeConfig.src,
|
||||
async: !0,
|
||||
integrity: externalRuntimeConfig.integrity,
|
||||
nonce: void 0
|
||||
})));
|
||||
if (void 0 !== bootstrapScripts)
|
||||
for (
|
||||
bootstrapScriptContent = 0;
|
||||
@@ -3882,7 +3889,7 @@ exports.renderToStream = function (children, options) {
|
||||
streamingFormat: streamingFormat,
|
||||
startInlineScript: "<script>",
|
||||
instructions: 0,
|
||||
externalRuntimeConfig: externalRuntimeDesc,
|
||||
externalRuntimeScript: externalRuntimeScript,
|
||||
htmlChunks: null,
|
||||
headChunks: null,
|
||||
hasBody: !1,
|
||||
@@ -3894,7 +3901,7 @@ exports.renderToStream = function (children, options) {
|
||||
nonce: void 0
|
||||
};
|
||||
bootstrapModules = createFormatContext(0, null, !1);
|
||||
externalRuntimeDesc = options ? options.progressiveChunkSize : void 0;
|
||||
externalRuntimeScript = options ? options.progressiveChunkSize : void 0;
|
||||
streamingFormat = options.onError;
|
||||
ReactDOMCurrentDispatcher.current = ReactDOMServerDispatcher;
|
||||
options = [];
|
||||
@@ -3921,7 +3928,7 @@ exports.renderToStream = function (children, options) {
|
||||
flushScheduled: !1,
|
||||
responseState: JSCompiler_inline_result,
|
||||
progressiveChunkSize:
|
||||
void 0 === externalRuntimeDesc ? 12800 : externalRuntimeDesc,
|
||||
void 0 === externalRuntimeScript ? 12800 : externalRuntimeScript,
|
||||
status: 0,
|
||||
fatalError: null,
|
||||
nextSegmentId: 0,
|
||||
|
||||
Reference in New Issue
Block a user