From 48290c6a0513ab512bb293b72eb5f06ffdd0bb6a Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 2 Dec 2022 05:15:54 +0100 Subject: [PATCH] Update react next tag (#43617) Fixes #43033 Also remove the unsued react-dom files: bundles for bun, and react-dom-test-utils x-ref: https://github.com/facebook/react/pull/25713 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) --- package.json | 6 +- ...t-dom-server-legacy.browser.development.js | 245 +- ...om-server-legacy.browser.production.min.js | 13 +- ...eact-dom-server-legacy.node.development.js | 245 +- ...t-dom-server-legacy.node.production.min.js | 14 +- ...t-dom-server-rendering-stub.development.js | 2 +- ...om-server-rendering-stub.production.min.js | 2 +- .../react-dom-server.browser.development.js | 245 +- ...react-dom-server.browser.production.min.js | 27 +- .../cjs/react-dom-server.bun.development.js | 9084 ----------------- .../react-dom-server.bun.production.min.js | 137 - .../cjs/react-dom-server.node.development.js | 245 +- .../react-dom-server.node.production.min.js | 31 +- .../cjs/react-dom-test-utils.development.js | 1759 ---- .../react-dom-test-utils.production.min.js | 40 - .../react-dom/cjs/react-dom.development.js | 134 +- .../react-dom/cjs/react-dom.production.min.js | 89 +- .../react-dom/cjs/react-dom.profiling.min.js | 97 +- packages/next/compiled/react-dom/package.json | 6 +- .../next/compiled/react-dom/server.bun.js | 18 - .../server.browser.js | 34 +- .../compiled/react/cjs/react.development.js | 2 +- .../react/cjs/react.production.min.js | 2 +- .../cjs/react.shared-subset.development.js | 2 +- .../cjs/react.shared-subset.production.min.js | 2 +- packages/next/compiled/react/package.json | 2 +- packages/next/taskfile.js | 14 + pnpm-lock.yaml | 36 +- 28 files changed, 919 insertions(+), 11614 deletions(-) delete mode 100644 packages/next/compiled/react-dom/cjs/react-dom-server.bun.development.js delete mode 100644 packages/next/compiled/react-dom/cjs/react-dom-server.bun.production.min.js delete mode 100644 packages/next/compiled/react-dom/cjs/react-dom-test-utils.development.js delete mode 100644 packages/next/compiled/react-dom/cjs/react-dom-test-utils.production.min.js delete mode 100644 packages/next/compiled/react-dom/server.bun.js diff --git a/package.json b/package.json index a693a9ff2d71240..10f3ca903bc148b 100644 --- a/package.json +++ b/package.json @@ -180,11 +180,11 @@ "random-seed": "0.3.0", "react": "18.2.0", "react-17": "npm:react@17.0.2", - "react-builtin": "npm:react@18.3.0-next-2655c9354-20221121", + "react-builtin": "npm:react@18.3.0-next-3ba7add60-20221201", "react-dom": "18.2.0", "react-dom-17": "npm:react-dom@17.0.2", - "react-dom-builtin": "npm:react-dom@18.3.0-next-2655c9354-20221121", - "react-server-dom-webpack": "18.3.0-next-2655c9354-20221121", + "react-dom-builtin": "npm:react-dom@18.3.0-next-3ba7add60-20221201", + "react-server-dom-webpack": "18.3.0-next-3ba7add60-20221201", "react-ssr-prepass": "1.0.8", "react-virtualized": "9.22.3", "relay-compiler": "13.0.2", diff --git a/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.development.js b/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.development.js index d5354a3cd0ab9b9..6876273988b38aa 100644 --- a/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.development.js +++ b/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.development.js @@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") { var React = require('react'); var ReactDOM = require('react-dom'); -var ReactVersion = '18.3.0-next-2655c9354-20221121'; +var ReactVersion = '18.3.0-next-3ba7add60-20221201'; var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; @@ -2191,8 +2191,13 @@ function preinit(href, options) { return; } - var resources = currentResources; + 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. + +function preinitImpl(resources, href, options) { { validatePreinitArguments(href, options); } @@ -2839,7 +2844,7 @@ function cleanupAfterRender(previousDispatcher) { finishRenderingResources(); ReactDOMCurrentDispatcher.current = previousDispatcher; } // Used to distinguish these contexts from ones used in other renderers. - +var ScriptStreamingFormat = 0; var startInlineScript = stringToPrecomputedChunk(''); var startScriptSrc = stringToPrecomputedChunk(''); +var completeSegmentScriptEnd = stringToPrecomputedChunk('")'); function writeCompletedSegmentInstruction(destination, responseState, contentSegmentID) { - writeChunk(destination, responseState.startInlineScript); - if (!responseState.sentCompleteSegmentFunction) { - // The first time we write this, we'll need to include the full implementation. - responseState.sentCompleteSegmentFunction = true; - writeChunk(destination, completeSegmentScript1Full); - } else { - // Future calls can just reuse the same function. - writeChunk(destination, completeSegmentScript1Partial); - } + { + writeChunk(destination, responseState.startInlineScript); + + if (!responseState.sentCompleteSegmentFunction) { + // The first time we write this, we'll need to include the full implementation. + responseState.sentCompleteSegmentFunction = true; + writeChunk(destination, completeSegmentScript1Full); + } else { + // Future calls can just reuse the same function. + writeChunk(destination, completeSegmentScript1Partial); + } + } // Write function arguments, which are string literals + writeChunk(destination, responseState.segmentPrefix); var formattedID = stringToChunk(contentSegmentID.toString(16)); writeChunk(destination, formattedID); - writeChunk(destination, completeSegmentScript2); + + { + writeChunk(destination, completeSegmentScript2); + } + writeChunk(destination, responseState.placeholderPrefix); writeChunk(destination, formattedID); - return writeChunkAndReturn(destination, completeSegmentScript3); + + { + return writeChunkAndReturn(destination, completeSegmentScriptEnd); + } } var completeBoundaryScript1Full = stringToPrecomputedChunk(completeBoundary + ';$RC("'); var completeBoundaryScript1Partial = stringToPrecomputedChunk('$RC("'); @@ -4559,9 +4578,9 @@ var completeBoundaryWithStylesScript1FullBoth = stringToPrecomputedChunk(complet var completeBoundaryWithStylesScript1FullPartial = stringToPrecomputedChunk(completeBoundaryWithStyles + ';$RR("'); var completeBoundaryWithStylesScript1Partial = stringToPrecomputedChunk('$RR("'); var completeBoundaryScript2 = stringToPrecomputedChunk('","'); -var completeBoundaryScript2a = stringToPrecomputedChunk('",'); -var completeBoundaryScript3 = stringToPrecomputedChunk('"'); -var completeBoundaryScript4 = stringToPrecomputedChunk(')'); +var completeBoundaryScript3a = stringToPrecomputedChunk('",'); +var completeBoundaryScript3b = stringToPrecomputedChunk('"'); +var completeBoundaryScriptEnd = stringToPrecomputedChunk(')'); function writeCompletedBoundaryInstruction(destination, responseState, boundaryID, contentSegmentID, boundaryResources) { var hasStyleDependencies; @@ -4569,62 +4588,84 @@ function writeCompletedBoundaryInstruction(destination, responseState, boundaryI hasStyleDependencies = hasStyleResourceDependencies(boundaryResources); } - writeChunk(destination, responseState.startInlineScript); - - if ( hasStyleDependencies) { - if (!responseState.sentCompleteBoundaryFunction) { - responseState.sentCompleteBoundaryFunction = true; - responseState.sentStyleInsertionFunction = true; - writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth)); - } else if (!responseState.sentStyleInsertionFunction) { - responseState.sentStyleInsertionFunction = true; - writeChunk(destination, completeBoundaryWithStylesScript1FullPartial); - } else { - writeChunk(destination, completeBoundaryWithStylesScript1Partial); - } - } else { - if (!responseState.sentCompleteBoundaryFunction) { - responseState.sentCompleteBoundaryFunction = true; - writeChunk(destination, completeBoundaryScript1Full); + { + writeChunk(destination, responseState.startInlineScript); + + if ( hasStyleDependencies) { + if (!responseState.sentCompleteBoundaryFunction) { + responseState.sentCompleteBoundaryFunction = true; + responseState.sentStyleInsertionFunction = true; + writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth)); + } else if (!responseState.sentStyleInsertionFunction) { + responseState.sentStyleInsertionFunction = true; + writeChunk(destination, completeBoundaryWithStylesScript1FullPartial); + } else { + writeChunk(destination, completeBoundaryWithStylesScript1Partial); + } } else { - writeChunk(destination, completeBoundaryScript1Partial); + if (!responseState.sentCompleteBoundaryFunction) { + responseState.sentCompleteBoundaryFunction = true; + writeChunk(destination, completeBoundaryScript1Full); + } else { + writeChunk(destination, completeBoundaryScript1Partial); + } } } if (boundaryID === null) { throw new Error('An ID must have been assigned before we can complete the boundary.'); - } + } // Write function arguments, which are string and array literals + var formattedContentID = stringToChunk(contentSegmentID.toString(16)); writeChunk(destination, boundaryID); - writeChunk(destination, completeBoundaryScript2); + + { + writeChunk(destination, completeBoundaryScript2); + } + writeChunk(destination, responseState.segmentPrefix); writeChunk(destination, formattedContentID); if ( hasStyleDependencies) { - writeChunk(destination, completeBoundaryScript2a); - writeStyleResourceDependencies(destination, boundaryResources); + // Script and data writers must format this differently: + // - script writer emits an array literal, whose string elements are + // escaped for javascript e.g. ["A", "B"] + // - data writer emits a string literal, which is escaped as html + // e.g. ["A", "B"] + { + writeChunk(destination, completeBoundaryScript3a); // boundaryResources encodes an array literal + + writeStyleResourceDependenciesInJS(destination, boundaryResources); + } } else { - writeChunk(destination, completeBoundaryScript3); + { + writeChunk(destination, completeBoundaryScript3b); + } } - return writeChunkAndReturn(destination, completeBoundaryScript4); + { + return writeChunkAndReturn(destination, completeBoundaryScriptEnd); + } } var clientRenderScript1Full = stringToPrecomputedChunk(clientRenderBoundary + ';$RX("'); var clientRenderScript1Partial = stringToPrecomputedChunk('$RX("'); var clientRenderScript1A = stringToPrecomputedChunk('"'); -var clientRenderScript2 = stringToPrecomputedChunk(')'); var clientRenderErrorScriptArgInterstitial = stringToPrecomputedChunk(','); +var clientRenderScriptEnd = stringToPrecomputedChunk(')'); function writeClientRenderBoundaryInstruction(destination, responseState, boundaryID, errorDigest, errorMessage, errorComponentStack) { - writeChunk(destination, responseState.startInlineScript); - if (!responseState.sentClientRenderFunction) { - // The first time we write this, we'll need to include the full implementation. - responseState.sentClientRenderFunction = true; - writeChunk(destination, clientRenderScript1Full); - } else { - // Future calls can just reuse the same function. - writeChunk(destination, clientRenderScript1Partial); + { + writeChunk(destination, responseState.startInlineScript); + + if (!responseState.sentClientRenderFunction) { + // The first time we write this, we'll need to include the full implementation. + responseState.sentClientRenderFunction = true; + writeChunk(destination, clientRenderScript1Full); + } else { + // Future calls can just reuse the same function. + writeChunk(destination, clientRenderScript1Partial); + } } if (boundaryID === null) { @@ -4632,24 +4673,41 @@ function writeClientRenderBoundaryInstruction(destination, responseState, bounda } writeChunk(destination, boundaryID); - writeChunk(destination, clientRenderScript1A); + + { + // " needs to be inserted for scripts, since ArgInterstitual does not contain + // leading or trailing quotes + writeChunk(destination, clientRenderScript1A); + } if (errorDigest || errorMessage || errorComponentStack) { - writeChunk(destination, clientRenderErrorScriptArgInterstitial); - writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorDigest || ''))); + { + // ,"JSONString" + writeChunk(destination, clientRenderErrorScriptArgInterstitial); + writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorDigest || ''))); + } } if (errorMessage || errorComponentStack) { - writeChunk(destination, clientRenderErrorScriptArgInterstitial); - writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorMessage || ''))); + { + // ,"JSONString" + writeChunk(destination, clientRenderErrorScriptArgInterstitial); + writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorMessage || ''))); + } } if (errorComponentStack) { - writeChunk(destination, clientRenderErrorScriptArgInterstitial); - writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorComponentStack))); + // ,"JSONString" + { + writeChunk(destination, clientRenderErrorScriptArgInterstitial); + writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorComponentStack))); + } } - return writeChunkAndReturn(destination, clientRenderScript2); + { + // > + return writeChunkAndReturn(destination, clientRenderScriptEnd); + } } var regexForJSStringsInInstructionScripts = /[<\u2028\u2029]/g; @@ -4709,7 +4767,8 @@ function escapeJSObjectForInstructionScripts(input) { var precedencePlaceholderStart = stringToPrecomputedChunk(''); -function writeInitialResources(destination, resources, responseState) { +function writeInitialResources(destination, resources, responseState, willFlushAllSegments) { + function flushLinkResource(resource) { if (!resource.flushed) { pushLinkImpl(target, resource.props, responseState); @@ -4933,20 +4992,22 @@ function hasStyleResourceDependencies(boundaryResources) { var arrayFirstOpenBracket = stringToPrecomputedChunk('['); var arraySubsequentOpenBracket = stringToPrecomputedChunk(',['); var arrayInterstitial = stringToPrecomputedChunk(','); -var arrayCloseBracket = stringToPrecomputedChunk(']'); +var arrayCloseBracket = stringToPrecomputedChunk(']'); // This function writes a 2D array of strings to be embedded in javascript. +// E.g. +// [["JS_escaped_string1", "JS_escaped_string2"]] -function writeStyleResourceDependencies(destination, boundaryResources) { +function writeStyleResourceDependenciesInJS(destination, boundaryResources) { writeChunk(destination, arrayFirstOpenBracket); var nextArrayOpenBrackChunk = arrayFirstOpenBracket; boundaryResources.forEach(function (resource) { if (resource.inShell) ; else if (resource.flushed) { writeChunk(destination, nextArrayOpenBrackChunk); - writeStyleResourceDependencyHrefOnly(destination, resource.href); + writeStyleResourceDependencyHrefOnlyInJS(destination, resource.href); writeChunk(destination, arrayCloseBracket); nextArrayOpenBrackChunk = arraySubsequentOpenBracket; } else { writeChunk(destination, nextArrayOpenBrackChunk); - writeStyleResourceDependency(destination, resource.href, resource.precedence, resource.props); + writeStyleResourceDependencyInJS(destination, resource.href, resource.precedence, resource.props); writeChunk(destination, arrayCloseBracket); nextArrayOpenBrackChunk = arraySubsequentOpenBracket; resource.flushed = true; @@ -4955,8 +5016,10 @@ function writeStyleResourceDependencies(destination, boundaryResources) { }); writeChunk(destination, arrayCloseBracket); } +/* Helper functions */ -function writeStyleResourceDependencyHrefOnly(destination, href) { + +function writeStyleResourceDependencyHrefOnlyInJS(destination, href) { // We should actually enforce this earlier when the resource is created but for // now we make sure we are actually dealing with a string here. { @@ -4967,7 +5030,7 @@ function writeStyleResourceDependencyHrefOnly(destination, href) { writeChunk(destination, stringToChunk(escapeJSObjectForInstructionScripts(coercedHref))); } -function writeStyleResourceDependency(destination, href, precedence, props) { +function writeStyleResourceDependencyInJS(destination, href, precedence, props) { { checkAttributeStringCoercion(href, 'href'); } @@ -5007,7 +5070,7 @@ function writeStyleResourceDependency(destination, href, precedence, props) { // eslint-disable-next-line-no-fallthrough default: - writeStyleResourceAttribute(destination, propKey, propValue); + writeStyleResourceAttributeInJS(destination, propKey, propValue); break; } } @@ -5016,7 +5079,7 @@ function writeStyleResourceDependency(destination, href, precedence, props) { return null; } -function writeStyleResourceAttribute(destination, name, value) { +function writeStyleResourceAttributeInJS(destination, name, value) { var attributeName = name.toLowerCase(); var attributeValue; @@ -5086,23 +5149,25 @@ function writeStyleResourceAttribute(destination, name, value) { writeChunk(destination, stringToChunk(escapeJSObjectForInstructionScripts(attributeName))); writeChunk(destination, arrayInterstitial); writeChunk(destination, stringToChunk(escapeJSObjectForInstructionScripts(attributeValue))); -} +} // This function writes a 2D array of strings to be embedded in an attribute -function createResponseState$1(generateStaticMarkup, identifierPrefix) { - var responseState = createResponseState(identifierPrefix, undefined); +function createResponseState$1(generateStaticMarkup, identifierPrefix, externalRuntimeConfig) { + var responseState = createResponseState(identifierPrefix, undefined, undefined, undefined, undefined); return { // Keep this in sync with ReactDOMServerFormatConfig bootstrapChunks: responseState.bootstrapChunks, - startInlineScript: responseState.startInlineScript, placeholderPrefix: responseState.placeholderPrefix, segmentPrefix: responseState.segmentPrefix, boundaryPrefix: responseState.boundaryPrefix, idPrefix: responseState.idPrefix, nextSuspenseID: responseState.nextSuspenseID, + streamingFormat: responseState.streamingFormat, + startInlineScript: responseState.startInlineScript, sentCompleteSegmentFunction: responseState.sentCompleteSegmentFunction, sentCompleteBoundaryFunction: responseState.sentCompleteBoundaryFunction, sentClientRenderFunction: responseState.sentClientRenderFunction, sentStyleInsertionFunction: responseState.sentStyleInsertionFunction, + externalRuntimeConfig: responseState.externalRuntimeConfig, // This is an extra field for the legacy renderer generateStaticMarkup: generateStaticMarkup }; @@ -8807,7 +8872,7 @@ function flushSegment(request, destination, segment) { } } -function flushInitialResources(destination, resources, responseState) { +function flushInitialResources(destination, resources, responseState, willFlushAllSegments) { writeInitialResources(destination, resources, responseState); } @@ -8910,7 +8975,7 @@ function flushCompletedQueues(request, destination) { writeChunk(destination, preamble[i]); } - flushInitialResources(destination, request.resources, request.responseState); + flushInitialResources(destination, request.resources, request.responseState, request.allPendingTasks === 0); } flushSegment(request, destination, completedRootSegment); @@ -9076,7 +9141,7 @@ function abort(request, reason) { function onError() {// Non-fatal errors are ignored. } -function renderToStringImpl(children, options, generateStaticMarkup, abortReason) { +function renderToStringImpl(children, options, generateStaticMarkup, abortReason, unstable_externalRuntimeSrc) { var didFatal = false; var fatalError = null; var result = ''; diff --git a/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.production.min.js b/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.production.min.js index 894fd2cc613aba3..b110a7000169643 100644 --- a/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +++ b/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.production.min.js @@ -20,7 +20,7 @@ var ja={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderIma zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ka=["Webkit","ms","Moz","O"];Object.keys(ja).forEach(function(a){ka.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);ja[b]=ja[a]})});var la=/["'&<>]/; function w(a){if("boolean"===typeof a||"number"===typeof a)return""+a;a=""+a;var b=la.exec(a);if(b){var c="",d,e=0;for(d=b.index;d",placeholderPrefix:b+"P:",segmentPrefix:b+"S:",boundaryPrefix:b+"B:",idPrefix:b,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1,sentStyleInsertionFunction:!1,generateStaticMarkup:a}}function Xa(a,b,c,d){if(c.generateStaticMarkup)return a.push(w(b)),!1;""===b?a=d:(d&&a.push("\x3c!-- --\x3e"),a.push(w(b)),a=!0);return a} +function Wa(a,b){b=void 0===b?"":b;return{bootstrapChunks:[],placeholderPrefix:b+"P:",segmentPrefix:b+"S:",boundaryPrefix:b+"B:",idPrefix:b,nextSuspenseID:0,streamingFormat:0,startInlineScript:"'); var startScriptSrc = stringToPrecomputedChunk(''); +var completeSegmentScriptEnd = stringToPrecomputedChunk('")'); function writeCompletedSegmentInstruction(destination, responseState, contentSegmentID) { - writeChunk(destination, responseState.startInlineScript); - if (!responseState.sentCompleteSegmentFunction) { - // The first time we write this, we'll need to include the full implementation. - responseState.sentCompleteSegmentFunction = true; - writeChunk(destination, completeSegmentScript1Full); - } else { - // Future calls can just reuse the same function. - writeChunk(destination, completeSegmentScript1Partial); - } + { + writeChunk(destination, responseState.startInlineScript); + + if (!responseState.sentCompleteSegmentFunction) { + // The first time we write this, we'll need to include the full implementation. + responseState.sentCompleteSegmentFunction = true; + writeChunk(destination, completeSegmentScript1Full); + } else { + // Future calls can just reuse the same function. + writeChunk(destination, completeSegmentScript1Partial); + } + } // Write function arguments, which are string literals + writeChunk(destination, responseState.segmentPrefix); var formattedID = stringToChunk(contentSegmentID.toString(16)); writeChunk(destination, formattedID); - writeChunk(destination, completeSegmentScript2); + + { + writeChunk(destination, completeSegmentScript2); + } + writeChunk(destination, responseState.placeholderPrefix); writeChunk(destination, formattedID); - return writeChunkAndReturn(destination, completeSegmentScript3); + + { + return writeChunkAndReturn(destination, completeSegmentScriptEnd); + } } var completeBoundaryScript1Full = stringToPrecomputedChunk(completeBoundary + ';$RC("'); var completeBoundaryScript1Partial = stringToPrecomputedChunk('$RC("'); @@ -4560,9 +4579,9 @@ var completeBoundaryWithStylesScript1FullBoth = stringToPrecomputedChunk(complet var completeBoundaryWithStylesScript1FullPartial = stringToPrecomputedChunk(completeBoundaryWithStyles + ';$RR("'); var completeBoundaryWithStylesScript1Partial = stringToPrecomputedChunk('$RR("'); var completeBoundaryScript2 = stringToPrecomputedChunk('","'); -var completeBoundaryScript2a = stringToPrecomputedChunk('",'); -var completeBoundaryScript3 = stringToPrecomputedChunk('"'); -var completeBoundaryScript4 = stringToPrecomputedChunk(')'); +var completeBoundaryScript3a = stringToPrecomputedChunk('",'); +var completeBoundaryScript3b = stringToPrecomputedChunk('"'); +var completeBoundaryScriptEnd = stringToPrecomputedChunk(')'); function writeCompletedBoundaryInstruction(destination, responseState, boundaryID, contentSegmentID, boundaryResources) { var hasStyleDependencies; @@ -4570,62 +4589,84 @@ function writeCompletedBoundaryInstruction(destination, responseState, boundaryI hasStyleDependencies = hasStyleResourceDependencies(boundaryResources); } - writeChunk(destination, responseState.startInlineScript); - - if ( hasStyleDependencies) { - if (!responseState.sentCompleteBoundaryFunction) { - responseState.sentCompleteBoundaryFunction = true; - responseState.sentStyleInsertionFunction = true; - writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth)); - } else if (!responseState.sentStyleInsertionFunction) { - responseState.sentStyleInsertionFunction = true; - writeChunk(destination, completeBoundaryWithStylesScript1FullPartial); - } else { - writeChunk(destination, completeBoundaryWithStylesScript1Partial); - } - } else { - if (!responseState.sentCompleteBoundaryFunction) { - responseState.sentCompleteBoundaryFunction = true; - writeChunk(destination, completeBoundaryScript1Full); + { + writeChunk(destination, responseState.startInlineScript); + + if ( hasStyleDependencies) { + if (!responseState.sentCompleteBoundaryFunction) { + responseState.sentCompleteBoundaryFunction = true; + responseState.sentStyleInsertionFunction = true; + writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth)); + } else if (!responseState.sentStyleInsertionFunction) { + responseState.sentStyleInsertionFunction = true; + writeChunk(destination, completeBoundaryWithStylesScript1FullPartial); + } else { + writeChunk(destination, completeBoundaryWithStylesScript1Partial); + } } else { - writeChunk(destination, completeBoundaryScript1Partial); + if (!responseState.sentCompleteBoundaryFunction) { + responseState.sentCompleteBoundaryFunction = true; + writeChunk(destination, completeBoundaryScript1Full); + } else { + writeChunk(destination, completeBoundaryScript1Partial); + } } } if (boundaryID === null) { throw new Error('An ID must have been assigned before we can complete the boundary.'); - } + } // Write function arguments, which are string and array literals + var formattedContentID = stringToChunk(contentSegmentID.toString(16)); writeChunk(destination, boundaryID); - writeChunk(destination, completeBoundaryScript2); + + { + writeChunk(destination, completeBoundaryScript2); + } + writeChunk(destination, responseState.segmentPrefix); writeChunk(destination, formattedContentID); if ( hasStyleDependencies) { - writeChunk(destination, completeBoundaryScript2a); - writeStyleResourceDependencies(destination, boundaryResources); + // Script and data writers must format this differently: + // - script writer emits an array literal, whose string elements are + // escaped for javascript e.g. ["A", "B"] + // - data writer emits a string literal, which is escaped as html + // e.g. ["A", "B"] + { + writeChunk(destination, completeBoundaryScript3a); // boundaryResources encodes an array literal + + writeStyleResourceDependenciesInJS(destination, boundaryResources); + } } else { - writeChunk(destination, completeBoundaryScript3); + { + writeChunk(destination, completeBoundaryScript3b); + } } - return writeChunkAndReturn(destination, completeBoundaryScript4); + { + return writeChunkAndReturn(destination, completeBoundaryScriptEnd); + } } var clientRenderScript1Full = stringToPrecomputedChunk(clientRenderBoundary + ';$RX("'); var clientRenderScript1Partial = stringToPrecomputedChunk('$RX("'); var clientRenderScript1A = stringToPrecomputedChunk('"'); -var clientRenderScript2 = stringToPrecomputedChunk(')'); var clientRenderErrorScriptArgInterstitial = stringToPrecomputedChunk(','); +var clientRenderScriptEnd = stringToPrecomputedChunk(')'); function writeClientRenderBoundaryInstruction(destination, responseState, boundaryID, errorDigest, errorMessage, errorComponentStack) { - writeChunk(destination, responseState.startInlineScript); - if (!responseState.sentClientRenderFunction) { - // The first time we write this, we'll need to include the full implementation. - responseState.sentClientRenderFunction = true; - writeChunk(destination, clientRenderScript1Full); - } else { - // Future calls can just reuse the same function. - writeChunk(destination, clientRenderScript1Partial); + { + writeChunk(destination, responseState.startInlineScript); + + if (!responseState.sentClientRenderFunction) { + // The first time we write this, we'll need to include the full implementation. + responseState.sentClientRenderFunction = true; + writeChunk(destination, clientRenderScript1Full); + } else { + // Future calls can just reuse the same function. + writeChunk(destination, clientRenderScript1Partial); + } } if (boundaryID === null) { @@ -4633,24 +4674,41 @@ function writeClientRenderBoundaryInstruction(destination, responseState, bounda } writeChunk(destination, boundaryID); - writeChunk(destination, clientRenderScript1A); + + { + // " needs to be inserted for scripts, since ArgInterstitual does not contain + // leading or trailing quotes + writeChunk(destination, clientRenderScript1A); + } if (errorDigest || errorMessage || errorComponentStack) { - writeChunk(destination, clientRenderErrorScriptArgInterstitial); - writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorDigest || ''))); + { + // ,"JSONString" + writeChunk(destination, clientRenderErrorScriptArgInterstitial); + writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorDigest || ''))); + } } if (errorMessage || errorComponentStack) { - writeChunk(destination, clientRenderErrorScriptArgInterstitial); - writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorMessage || ''))); + { + // ,"JSONString" + writeChunk(destination, clientRenderErrorScriptArgInterstitial); + writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorMessage || ''))); + } } if (errorComponentStack) { - writeChunk(destination, clientRenderErrorScriptArgInterstitial); - writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorComponentStack))); + // ,"JSONString" + { + writeChunk(destination, clientRenderErrorScriptArgInterstitial); + writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorComponentStack))); + } } - return writeChunkAndReturn(destination, clientRenderScript2); + { + // > + return writeChunkAndReturn(destination, clientRenderScriptEnd); + } } var regexForJSStringsInInstructionScripts = /[<\u2028\u2029]/g; @@ -4710,7 +4768,8 @@ function escapeJSObjectForInstructionScripts(input) { var precedencePlaceholderStart = stringToPrecomputedChunk(''); -function writeInitialResources(destination, resources, responseState) { +function writeInitialResources(destination, resources, responseState, willFlushAllSegments) { + function flushLinkResource(resource) { if (!resource.flushed) { pushLinkImpl(target, resource.props, responseState); @@ -4934,20 +4993,22 @@ function hasStyleResourceDependencies(boundaryResources) { var arrayFirstOpenBracket = stringToPrecomputedChunk('['); var arraySubsequentOpenBracket = stringToPrecomputedChunk(',['); var arrayInterstitial = stringToPrecomputedChunk(','); -var arrayCloseBracket = stringToPrecomputedChunk(']'); +var arrayCloseBracket = stringToPrecomputedChunk(']'); // This function writes a 2D array of strings to be embedded in javascript. +// E.g. +// [["JS_escaped_string1", "JS_escaped_string2"]] -function writeStyleResourceDependencies(destination, boundaryResources) { +function writeStyleResourceDependenciesInJS(destination, boundaryResources) { writeChunk(destination, arrayFirstOpenBracket); var nextArrayOpenBrackChunk = arrayFirstOpenBracket; boundaryResources.forEach(function (resource) { if (resource.inShell) ; else if (resource.flushed) { writeChunk(destination, nextArrayOpenBrackChunk); - writeStyleResourceDependencyHrefOnly(destination, resource.href); + writeStyleResourceDependencyHrefOnlyInJS(destination, resource.href); writeChunk(destination, arrayCloseBracket); nextArrayOpenBrackChunk = arraySubsequentOpenBracket; } else { writeChunk(destination, nextArrayOpenBrackChunk); - writeStyleResourceDependency(destination, resource.href, resource.precedence, resource.props); + writeStyleResourceDependencyInJS(destination, resource.href, resource.precedence, resource.props); writeChunk(destination, arrayCloseBracket); nextArrayOpenBrackChunk = arraySubsequentOpenBracket; resource.flushed = true; @@ -4956,8 +5017,10 @@ function writeStyleResourceDependencies(destination, boundaryResources) { }); writeChunk(destination, arrayCloseBracket); } +/* Helper functions */ -function writeStyleResourceDependencyHrefOnly(destination, href) { + +function writeStyleResourceDependencyHrefOnlyInJS(destination, href) { // We should actually enforce this earlier when the resource is created but for // now we make sure we are actually dealing with a string here. { @@ -4968,7 +5031,7 @@ function writeStyleResourceDependencyHrefOnly(destination, href) { writeChunk(destination, stringToChunk(escapeJSObjectForInstructionScripts(coercedHref))); } -function writeStyleResourceDependency(destination, href, precedence, props) { +function writeStyleResourceDependencyInJS(destination, href, precedence, props) { { checkAttributeStringCoercion(href, 'href'); } @@ -5008,7 +5071,7 @@ function writeStyleResourceDependency(destination, href, precedence, props) { // eslint-disable-next-line-no-fallthrough default: - writeStyleResourceAttribute(destination, propKey, propValue); + writeStyleResourceAttributeInJS(destination, propKey, propValue); break; } } @@ -5017,7 +5080,7 @@ function writeStyleResourceDependency(destination, href, precedence, props) { return null; } -function writeStyleResourceAttribute(destination, name, value) { +function writeStyleResourceAttributeInJS(destination, name, value) { var attributeName = name.toLowerCase(); var attributeValue; @@ -5087,23 +5150,25 @@ function writeStyleResourceAttribute(destination, name, value) { writeChunk(destination, stringToChunk(escapeJSObjectForInstructionScripts(attributeName))); writeChunk(destination, arrayInterstitial); writeChunk(destination, stringToChunk(escapeJSObjectForInstructionScripts(attributeValue))); -} +} // This function writes a 2D array of strings to be embedded in an attribute -function createResponseState$1(generateStaticMarkup, identifierPrefix) { - var responseState = createResponseState(identifierPrefix, undefined); +function createResponseState$1(generateStaticMarkup, identifierPrefix, externalRuntimeConfig) { + var responseState = createResponseState(identifierPrefix, undefined, undefined, undefined, undefined); return { // Keep this in sync with ReactDOMServerFormatConfig bootstrapChunks: responseState.bootstrapChunks, - startInlineScript: responseState.startInlineScript, placeholderPrefix: responseState.placeholderPrefix, segmentPrefix: responseState.segmentPrefix, boundaryPrefix: responseState.boundaryPrefix, idPrefix: responseState.idPrefix, nextSuspenseID: responseState.nextSuspenseID, + streamingFormat: responseState.streamingFormat, + startInlineScript: responseState.startInlineScript, sentCompleteSegmentFunction: responseState.sentCompleteSegmentFunction, sentCompleteBoundaryFunction: responseState.sentCompleteBoundaryFunction, sentClientRenderFunction: responseState.sentClientRenderFunction, sentStyleInsertionFunction: responseState.sentStyleInsertionFunction, + externalRuntimeConfig: responseState.externalRuntimeConfig, // This is an extra field for the legacy renderer generateStaticMarkup: generateStaticMarkup }; @@ -8808,7 +8873,7 @@ function flushSegment(request, destination, segment) { } } -function flushInitialResources(destination, resources, responseState) { +function flushInitialResources(destination, resources, responseState, willFlushAllSegments) { writeInitialResources(destination, resources, responseState); } @@ -8911,7 +8976,7 @@ function flushCompletedQueues(request, destination) { writeChunk(destination, preamble[i]); } - flushInitialResources(destination, request.resources, request.responseState); + flushInitialResources(destination, request.resources, request.responseState, request.allPendingTasks === 0); } flushSegment(request, destination, completedRootSegment); @@ -9077,7 +9142,7 @@ function abort(request, reason) { function onError() {// Non-fatal errors are ignored. } -function renderToStringImpl(children, options, generateStaticMarkup, abortReason) { +function renderToStringImpl(children, options, generateStaticMarkup, abortReason, unstable_externalRuntimeSrc) { var didFatal = false; var fatalError = null; var result = ''; diff --git a/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.node.production.min.js b/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.node.production.min.js index 0ed31409502a891..dc06fa715e846a1 100644 --- a/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.node.production.min.js +++ b/packages/next/compiled/react-dom/cjs/react-dom-server-legacy.node.production.min.js @@ -19,7 +19,7 @@ var ka={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderIma zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},la=["Webkit","ms","Moz","O"];Object.keys(ka).forEach(function(a){la.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);ka[b]=ka[a]})});var ma=/["'&<>]/; function v(a){if("boolean"===typeof a||"number"===typeof a)return""+a;a=""+a;var b=ma.exec(a);if(b){var c="",d,e=0;for(d=b.index;d",placeholderPrefix:b+"P:",segmentPrefix:b+"S:",boundaryPrefix:b+"B:",idPrefix:b,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1,sentStyleInsertionFunction:!1,generateStaticMarkup:a}}function Ya(){return{insertionMode:1,selectedValue:null,noscriptTagInScope:!1}} -function Za(a,b,c,d){if(c.generateStaticMarkup)return a.push(v(b)),!1;""===b?a=d:(d&&a.push("\x3c!-- --\x3e"),a.push(v(b)),a=!0);return a} +c=",[";b.flushed=!0;b.hint.flushed=!0}});a.push("]")}function Xa(a,b){b=void 0===b?"":b;return{bootstrapChunks:[],placeholderPrefix:b+"P:",segmentPrefix:b+"S:",boundaryPrefix:b+"B:",idPrefix:b,nextSuspenseID:0,streamingFormat:0,startInlineScript:"'); var startScriptSrc = stringToPrecomputedChunk(''); +var completeSegmentScriptEnd = stringToPrecomputedChunk('")'); +var completeSegmentData1 = stringToPrecomputedChunk('