Use the new moduleMap option in the flight client during SSR (#37406)

Adopt the new `moduleMap` option added in https://github.com/facebook/react/pull/24629, which helps us getting rid of our hacky implementation injected to `globalThis.__next_require__`. The map will be attached to the flight manifest as `__ssr_module_mapping__`.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
This commit is contained in:
Shu Ding 2022-06-02 17:43:25 +02:00 committed by GitHub
parent b0783e9932
commit a3e067e6e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 490 additions and 430 deletions

View file

@ -82,15 +82,15 @@ export class FlightManifestPlugin {
}
const moduleExports: any = manifest[resource] || {}
const moduleIdMapping: any = manifest.__ssr_module_id__ || {}
const moduleIdMapping: any = manifest.__ssr_module_mapping__ || {}
moduleIdMapping[id] = moduleIdMapping[id] || {}
// Note that this isn't that reliable as webpack is still possible to assign
// additional queries to make sure there's no conflict even using the `named`
// module ID strategy.
const ssrNamedModuleId = relative(context, mod.resourceResolveData.path)
moduleIdMapping[id] = ssrNamedModuleId.startsWith('.')
? ssrNamedModuleId
: `./${ssrNamedModuleId}`
let ssrNamedModuleId = relative(context, mod.resourceResolveData.path)
if (!ssrNamedModuleId.startsWith('.'))
ssrNamedModuleId = `./${ssrNamedModuleId}`
const exportsInfo = compilation.moduleGraph.getExportsInfo(mod)
const cjsExports = [
@ -143,10 +143,16 @@ export class FlightManifestPlugin {
: [],
}
}
if (!moduleIdMapping[id][name]) {
moduleIdMapping[id][name] = {
...moduleExports[name],
id: ssrNamedModuleId,
}
}
})
manifest[resource] = moduleExports
manifest.__ssr_module_id__ = moduleIdMapping
manifest.__ssr_module_mapping__ = moduleIdMapping
}
chunkGroup.chunks.forEach((chunk: any) => {

View file

@ -502,7 +502,7 @@ var startInlineScript = stringToPrecomputedChunk('<script>');
var endInlineScript = stringToPrecomputedChunk('</script>');
var startScriptSrc = stringToPrecomputedChunk('<script src="');
var startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
var endAsyncScript = stringToPrecomputedChunk('" async=""></script>'); // Allows us to keep track of what we've already written so we can refer back to it.
var endAsyncScript = stringToPrecomputedChunk('" async=""></script>');
var textSeparator = stringToPrecomputedChunk('<!-- -->');
@ -537,6 +537,10 @@ var startPendingSuspenseBoundary1 = stringToPrecomputedChunk('<!--$?--><template
var startPendingSuspenseBoundary2 = stringToPrecomputedChunk('"></template>');
var startClientRenderedSuspenseBoundary = stringToPrecomputedChunk('<!--$!-->');
var endSuspenseBoundary = stringToPrecomputedChunk('<!--/$-->');
var clientRenderedSuspenseBoundaryError1 = stringToPrecomputedChunk('<template data-hash="');
var clientRenderedSuspenseBoundaryError1A = stringToPrecomputedChunk('" data-msg="');
var clientRenderedSuspenseBoundaryError1B = stringToPrecomputedChunk('" data-stack="');
var clientRenderedSuspenseBoundaryError2 = stringToPrecomputedChunk('"></template>');
var startSegmentHTML = stringToPrecomputedChunk('<div hidden id="');
var startSegmentHTML2 = stringToPrecomputedChunk('">');
var endSegmentHTML = stringToPrecomputedChunk('</div>');
@ -566,7 +570,7 @@ var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
// const SUSPENSE_PENDING_START_DATA = '$?';
// const SUSPENSE_FALLBACK_START_DATA = '$!';
//
// function clientRenderBoundary(suspenseBoundaryID) {
// function clientRenderBoundary(suspenseBoundaryID, errorHash, errorMsg, errorComponentStack) {
// // Find the fallback's first element.
// const suspenseIdNode = document.getElementById(suspenseBoundaryID);
// if (!suspenseIdNode) {
@ -578,6 +582,11 @@ var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
// const suspenseNode = suspenseIdNode.previousSibling;
// // Tag it to be client rendered.
// suspenseNode.data = SUSPENSE_FALLBACK_START_DATA;
// // assign error metadata to first sibling
// let dataset = suspenseIdNode.dataset;
// if (errorHash) dataset.hash = errorHash;
// if (errorMsg) dataset.msg = errorMsg;
// if (errorComponentStack) dataset.stack = errorComponentStack;
// // Tell React to retry it if the parent already hydrated.
// if (suspenseNode._reactRetry) {
// suspenseNode._reactRetry();
@ -661,7 +670,7 @@ var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
var completeSegmentFunction = 'function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)}';
var completeBoundaryFunction = 'function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}}';
var clientRenderFunction = 'function $RX(a){if(a=document.getElementById(a))a=a.previousSibling,a.data="$!",a._reactRetry&&a._reactRetry()}';
var clientRenderFunction = 'function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.hash=c),d&&(a.msg=d),e&&(a.stack=e),b._reactRetry&&b._reactRetry())}';
var completeSegmentScript1Full = stringToPrecomputedChunk(completeSegmentFunction + ';$RS("');
var completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("');
var completeSegmentScript2 = stringToPrecomputedChunk('","');
@ -672,7 +681,9 @@ var completeBoundaryScript2 = stringToPrecomputedChunk('","');
var completeBoundaryScript3 = stringToPrecomputedChunk('")</script>');
var clientRenderScript1Full = stringToPrecomputedChunk(clientRenderFunction + ';$RX("');
var clientRenderScript1Partial = stringToPrecomputedChunk('$RX("');
var clientRenderScript2 = stringToPrecomputedChunk('")</script>');
var clientRenderScript1A = stringToPrecomputedChunk('"');
var clientRenderScript2 = stringToPrecomputedChunk(')</script>');
var clientRenderErrorScriptArgInterstitial = stringToPrecomputedChunk(',');
var rendererSigil;
@ -864,6 +875,14 @@ function readContext(context) {
return value;
}
var currentRequest = null;
function prepareToUseHooksForRequest(request) {
currentRequest = request;
}
function resetHooksForRequest() {
currentRequest = null;
}
function readContext$1(context) {
{
if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
@ -912,7 +931,7 @@ var Dispatcher = {
useLayoutEffect: unsupportedHook,
useImperativeHandle: unsupportedHook,
useEffect: unsupportedHook,
useId: unsupportedHook,
useId: useId,
useMutableSource: unsupportedHook,
useSyncExternalStore: unsupportedHook,
useCacheRefresh: function () {
@ -939,6 +958,16 @@ function getCurrentCache() {
return currentCache;
}
function useId() {
if (currentRequest === 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
return ':' + currentRequest.identifierPrefix + 'S' + id.toString(32) + ':';
}
var ContextRegistry = ReactSharedInternals.ContextRegistry;
function getOrCreateServerContext(globalName) {
if (!ContextRegistry[globalName]) {
@ -957,7 +986,7 @@ function defaultErrorHandler(error) {
var OPEN = 0;
var CLOSING = 1;
var CLOSED = 2;
function createRequest(model, bundlerConfig, onError, context) {
function createRequest(model, bundlerConfig, onError, context, identifierPrefix) {
var pingedSegments = [];
var request = {
status: OPEN,
@ -974,6 +1003,8 @@ function createRequest(model, bundlerConfig, onError, context) {
writtenSymbols: new Map(),
writtenModules: new Map(),
writtenProviders: new Map(),
identifierPrefix: identifierPrefix || '',
identifierCount: 1,
onError: onError === undefined ? defaultErrorHandler : onError,
toJSON: function (key, value) {
return resolveModelToJSON(request, this, key, value);
@ -1581,6 +1612,7 @@ function performWork(request) {
var prevCache = getCurrentCache();
ReactCurrentDispatcher.current = Dispatcher;
setCurrentCache(request.cache);
prepareToUseHooksForRequest(request);
try {
var pingedSegments = request.pingedSegments;
@ -1600,6 +1632,7 @@ function performWork(request) {
} finally {
ReactCurrentDispatcher.current = prevDispatcher;
setCurrentCache(prevCache);
resetHooksForRequest();
}
}
@ -1725,8 +1758,8 @@ function importServerContexts(contexts) {
return rootContextSnapshot;
}
function renderToReadableStream(model, webpackMap, options, context) {
var request = createRequest(model, webpackMap, options ? options.onError : undefined, context);
function renderToReadableStream(model, webpackMap, options) {
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined);
var stream = new ReadableStream({
type: 'bytes',
start: function (controller) {
@ -1736,6 +1769,9 @@ function renderToReadableStream(model, webpackMap, options, context) {
startFlowing(request, controller);
},
cancel: function (reason) {}
}, // $FlowFixMe size() methods are not allowed on byte streams.
{
highWaterMark: 0
});
return stream;
}

View file

@ -7,7 +7,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var e=require("react"),k=null,m=0;function n(a,b){if(0!==b.length)if(512<b.length)0<m&&(a.enqueue(new Uint8Array(k.buffer,0,m)),k=new Uint8Array(512),m=0),a.enqueue(b);else{var d=k.length-m;d<b.length&&(0===d?a.enqueue(k):(k.set(b.subarray(0,d),m),a.enqueue(k),b=b.subarray(d)),k=new Uint8Array(512),m=0);k.set(b,m);m+=b.length}return!0}var p=new TextEncoder;function r(a){return p.encode(a)}function u(a,b){"function"===typeof a.error?a.error(b):a.close()}
'use strict';var e=require("react"),k=null,m=0;function n(a,b){if(0!==b.length)if(512<b.length)0<m&&(a.enqueue(new Uint8Array(k.buffer,0,m)),k=new Uint8Array(512),m=0),a.enqueue(b);else{var d=k.length-m;d<b.length&&(0===d?a.enqueue(k):(k.set(b.subarray(0,d),m),a.enqueue(k),b=b.subarray(d)),k=new Uint8Array(512),m=0);k.set(b,m);m+=b.length}return!0}var q=new TextEncoder;function r(a){return q.encode(a)}function u(a,b){"function"===typeof a.error?a.error(b):a.close()}
var w=JSON.stringify,x=Symbol.for("react.module.reference"),y=Symbol.for("react.element"),aa=Symbol.for("react.fragment"),z=Symbol.for("react.provider"),ba=Symbol.for("react.forward_ref"),ca=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),B=Symbol.for("react.default_value");function C(a,b,d,c,f,g,h){this.acceptsBooleans=2===b||3===b||4===b;this.attributeName=c;this.attributeNamespace=f;this.mustUseProperty=d;this.propertyName=a;this.type=b;this.sanitizeURL=g;this.removeEmptyString=h}var D="children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ");
D.push("innerText","textContent");D.forEach(function(a){new C(a,0,!1,a,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){new C(a[0],1,!1,a[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(a){new C(a,2,!1,a.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){new C(a,2,!1,a,null,!1,!1)});
"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){new C(a,3,!1,a.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(a){new C(a,3,!0,a,null,!1,!1)});["capture","download"].forEach(function(a){new C(a,4,!1,a,null,!1,!1)});
@ -17,29 +17,29 @@ F);new C(b,1,!1,a,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:sh
new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(a){new C(a,1,!1,a.toLowerCase(),null,!0,!0)});
var G={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,
fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},da=["Webkit","ms","Moz","O"];Object.keys(G).forEach(function(a){da.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);G[b]=G[a]})});var H=Array.isArray;r("<script>");r("\x3c/script>");r('<script src="');r('<script type="module" src="');r('" async="">\x3c/script>');r("\x3c!-- --\x3e");r(' style="');r(":");r(";");r(" ");r('="');r('"');r('=""');r(">");
r("/>");r(' selected=""');r("\n");r("<!DOCTYPE html>");r("</");r(">");r('<template id="');r('"></template>');r("\x3c!--$--\x3e");r('\x3c!--$?--\x3e<template id="');r('"></template>');r("\x3c!--$!--\x3e");r("\x3c!--/$--\x3e");r('<div hidden id="');r('">');r("</div>");r('<svg aria-hidden="true" style="display:none" id="');r('">');r("</svg>");r('<math aria-hidden="true" style="display:none" id="');r('">');r("</math>");r('<table hidden id="');r('">');r("</table>");r('<table hidden><tbody id="');r('">');
r("</tbody></table>");r('<table hidden><tr id="');r('">');r("</tr></table>");r('<table hidden><colgroup id="');r('">');r("</colgroup></table>");r('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("');r('$RS("');r('","');r('")\x3c/script>');r('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("');
r('$RC("');r('","');r('")\x3c/script>');r('function $RX(a){if(a=document.getElementById(a))a=a.previousSibling,a.data="$!",a._reactRetry&&a._reactRetry()};$RX("');r('$RX("');r('")\x3c/script>');var I=null;
r("/>");r(' selected=""');r("\n");r("<!DOCTYPE html>");r("</");r(">");r('<template id="');r('"></template>');r("\x3c!--$--\x3e");r('\x3c!--$?--\x3e<template id="');r('"></template>');r("\x3c!--$!--\x3e");r("\x3c!--/$--\x3e");r('<template data-hash="');r('" data-msg="');r('" data-stack="');r('"></template>');r('<div hidden id="');r('">');r("</div>");r('<svg aria-hidden="true" style="display:none" id="');r('">');r("</svg>");r('<math aria-hidden="true" style="display:none" id="');r('">');r("</math>");
r('<table hidden id="');r('">');r("</table>");r('<table hidden><tbody id="');r('">');r("</tbody></table>");r('<table hidden><tr id="');r('">');r("</tr></table>");r('<table hidden><colgroup id="');r('">');r("</colgroup></table>");r('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("');r('$RS("');r('","');r('")\x3c/script>');r('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("');
r('$RC("');r('","');r('")\x3c/script>');r('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.hash=c),d&&(a.msg=d),e&&(a.stack=e),b._reactRetry&&b._reactRetry())};$RX("');r('$RX("');r('"');r(")\x3c/script>");r(",");var I=null;
function J(a,b){if(a!==b){a.context._currentValue=a.parentValue;a=a.parent;var d=b.parent;if(null===a){if(null!==d)throw Error("The stacks must reach the root at the same time. This is a bug in React.");}else{if(null===d)throw Error("The stacks must reach the root at the same time. This is a bug in React.");J(a,d);b.context._currentValue=b.value}}}function K(a){a.context._currentValue=a.parentValue;a=a.parent;null!==a&&K(a)}
function L(a){var b=a.parent;null!==b&&L(b);a.context._currentValue=a.value}function ea(a,b){a.context._currentValue=a.parentValue;a=a.parent;if(null===a)throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");a.depth===b.depth?J(a,b):ea(a,b)}
function fa(a,b){var d=b.parent;if(null===d)throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");a.depth===d.depth?J(a,d):fa(a,d);b.context._currentValue=b.value}function M(a){var b=I;b!==a&&(null===b?L(a):null===a?K(b):b.depth===a.depth?J(b,a):b.depth>a.depth?ea(b,a):fa(b,a),I=a)}function ha(a,b){var d=a._currentValue;a._currentValue=b;var c=I;return I=a={parent:c,depth:null===c?0:c.depth+1,context:a,parentValue:d,value:b}}
function ia(a){return a._currentValue}
var la={useMemo:function(a){return a()},useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:N,useTransition:N,getCacheForType:function(a){if(!R)throw Error("Reading the cache is only supported while rendering.");var b=R.get(a);void 0===b&&(b=a(),R.set(a,b));return b},readContext:ia,useContext:ia,useReducer:N,useRef:N,useState:N,useInsertionEffect:N,useLayoutEffect:N,useImperativeHandle:N,useEffect:N,useId:N,useMutableSource:N,useSyncExternalStore:N,useCacheRefresh:function(){return ja}};
function N(){throw Error("This Hook is not supported in Server Components.");}function ja(){if(!R)throw Error("Refreshing the cache is not supported in Server Components.");}var R=null,ma=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=ma.ContextRegistry,T=ma.ReactCurrentDispatcher;function na(a){console.error(a)}
function oa(a,b,d,c){var f=[],g={status:0,fatalError:null,destination:null,bundlerConfig:b,cache:new Map,nextChunkId:0,pendingChunks:0,pingedSegments:f,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,writtenProviders:new Map,onError:void 0===d?na:d,toJSON:function(a,b){return pa(g,this,a,b)}};g.pendingChunks++;b=qa(c);a=ra(g,a,b);f.push(a);return g}var sa={};
function U(a,b,d,c){if(null!==d&&void 0!==d)throw Error("Refs cannot be used in server components, nor passed to client components.");if("function"===typeof a)return a(c);if("string"===typeof a)return[y,a,b,c];if("symbol"===typeof a)return a===aa?c.children:[y,a,b,c];if(null!=a&&"object"===typeof a){if(a.$$typeof===x)return[y,a,b,c];switch(a.$$typeof){case A:var f=a._init;a=f(a._payload);return U(a,b,d,c);case ba:return b=a.render,b(c,void 0);case ca:return U(a.type,b,d,c);case z:return ha(a._context,
c.value),[y,a,b,{value:c.value,children:c.children,__pop:sa}]}}throw Error("Unsupported server component type: "+V(a));}function ra(a,b,d){var c={id:a.nextChunkId++,model:b,context:d,ping:function(){var b=a.pingedSegments;b.push(c);1===b.length&&ta(a)}};return c}function ua(a){return Object.prototype.toString.call(a).replace(/^\[object (.*)\]$/,function(a,d){return d})}function W(a){var b=JSON.stringify(a);return'"'+a+'"'===b?a:b}
function V(a){switch(typeof a){case "string":return JSON.stringify(10>=a.length?a:a.substr(0,10)+"...");case "object":if(H(a))return"[...]";a=ua(a);return"Object"===a?"{...}":a;case "function":return"function";default:return String(a)}}
function ea(a){var b=a.parent;null!==b&&ea(b);a.context._currentValue=a.value}function fa(a,b){a.context._currentValue=a.parentValue;a=a.parent;if(null===a)throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");a.depth===b.depth?J(a,b):fa(a,b)}
function ha(a,b){var d=b.parent;if(null===d)throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");a.depth===d.depth?J(a,d):ha(a,d);b.context._currentValue=b.value}function L(a){var b=I;b!==a&&(null===b?ea(a):null===a?K(b):b.depth===a.depth?J(b,a):b.depth>a.depth?fa(b,a):ha(b,a),I=a)}function ia(a,b){var d=a._currentValue;a._currentValue=b;var c=I;return I=a={parent:c,depth:null===c?0:c.depth+1,context:a,parentValue:d,value:b}}var M=null;
function ja(a){return a._currentValue}
var na={useMemo:function(a){return a()},useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:N,useTransition:N,getCacheForType:function(a){if(!O)throw Error("Reading the cache is only supported while rendering.");var b=O.get(a);void 0===b&&(b=a(),O.set(a,b));return b},readContext:ja,useContext:ja,useReducer:N,useRef:N,useState:N,useInsertionEffect:N,useLayoutEffect:N,useImperativeHandle:N,useEffect:N,useId:ka,useMutableSource:N,useSyncExternalStore:N,useCacheRefresh:function(){return ma}};
function N(){throw Error("This Hook is not supported in Server Components.");}function ma(){if(!O)throw Error("Refreshing the cache is not supported in Server Components.");}var O=null;function ka(){if(null===M)throw Error("useId can only be used while React is rendering");var a=M.identifierCount++;return":"+M.identifierPrefix+"S"+a.toString(32)+":"}var oa=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=oa.ContextRegistry,T=oa.ReactCurrentDispatcher;function pa(a){console.error(a)}
function qa(a,b,d,c,f){var g=[],h={status:0,fatalError:null,destination:null,bundlerConfig:b,cache:new Map,nextChunkId:0,pendingChunks:0,pingedSegments:g,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,writtenProviders:new Map,identifierPrefix:f||"",identifierCount:1,onError:void 0===d?pa:d,toJSON:function(a,b){return ra(h,this,a,b)}};h.pendingChunks++;b=sa(c);a=ta(h,a,b);g.push(a);return h}var ua={};
function U(a,b,d,c){if(null!==d&&void 0!==d)throw Error("Refs cannot be used in server components, nor passed to client components.");if("function"===typeof a)return a(c);if("string"===typeof a)return[y,a,b,c];if("symbol"===typeof a)return a===aa?c.children:[y,a,b,c];if(null!=a&&"object"===typeof a){if(a.$$typeof===x)return[y,a,b,c];switch(a.$$typeof){case A:var f=a._init;a=f(a._payload);return U(a,b,d,c);case ba:return b=a.render,b(c,void 0);case ca:return U(a.type,b,d,c);case z:return ia(a._context,
c.value),[y,a,b,{value:c.value,children:c.children,__pop:ua}]}}throw Error("Unsupported server component type: "+V(a));}function ta(a,b,d){var c={id:a.nextChunkId++,model:b,context:d,ping:function(){var b=a.pingedSegments;b.push(c);1===b.length&&va(a)}};return c}function wa(a){return Object.prototype.toString.call(a).replace(/^\[object (.*)\]$/,function(a,d){return d})}function W(a){var b=JSON.stringify(a);return'"'+a+'"'===b?a:b}
function V(a){switch(typeof a){case "string":return JSON.stringify(10>=a.length?a:a.substr(0,10)+"...");case "object":if(H(a))return"[...]";a=wa(a);return"Object"===a?"{...}":a;case "function":return"function";default:return String(a)}}
function X(a,b){if(H(a)){for(var d="[",c=0;c<a.length;c++){0<c&&(d+=", ");if(6<c){d+="...";break}var f=a[c];d=""+c===b&&"object"===typeof f&&null!==f?d+X(f):d+V(f)}return d+"]"}d="{";c=Object.keys(a);for(f=0;f<c.length;f++){0<f&&(d+=", ");if(6<f){d+="...";break}var g=c[f];d+=W(g)+": ";var h=a[g];d=g===b&&"object"===typeof h&&null!==h?d+X(h):d+V(h)}return d+"}"}
function pa(a,b,d,c){switch(c){case y:return"$"}for(;"object"===typeof c&&null!==c&&(c.$$typeof===y||c.$$typeof===A);)try{switch(c.$$typeof){case y:var f=c;c=U(f.type,f.key,f.ref,f.props);break;case A:var g=c._init;c=g(c._payload)}}catch(t){if("object"===typeof t&&null!==t&&"function"===typeof t.then)return a.pendingChunks++,a=ra(a,c,I),d=a.ping,t.then(d,d),"@"+a.id.toString(16);Y(a,t);a.pendingChunks++;d=a.nextChunkId++;Z(a,d,t);return"@"+d.toString(16)}if(null===c)return null;if("object"===typeof c){if(c.$$typeof===
x){f=c.filepath+"#"+c.name;g=a.writtenModules;var h=g.get(f);if(void 0!==h)return b[0]===y&&"1"===d?"@"+h.toString(16):"$"+h.toString(16);try{var q=a.bundlerConfig[c.filepath][c.name];a.pendingChunks++;var l=a.nextChunkId++,O=w(q),P="M"+l.toString(16)+":"+O+"\n";var Q=p.encode(P);a.completedModuleChunks.push(Q);g.set(f,l);return b[0]===y&&"1"===d?"@"+l.toString(16):"$"+l.toString(16)}catch(t){return a.pendingChunks++,d=a.nextChunkId++,Z(a,d,t),"$"+d.toString(16)}}else{if(c.$$typeof===z)return b=c._context._globalName,
c=a.writtenProviders,d=c.get(d),void 0===d&&(a.pendingChunks++,d=a.nextChunkId++,c.set(b,d),b="P"+d.toString(16)+":"+b+"\n",b=p.encode(b),a.completedJSONChunks.push(b)),"$"+d.toString(16);if(c===sa){a=I;if(null===a)throw Error("Tried to pop a Context at the root of the app. This is a bug in React.");d=a.parentValue;a.context._currentValue=d===B?a.context._defaultValue:d;I=a.parent;return}}return c}if("string"===typeof c)return a="$"===c[0]||"@"===c[0]?"$"+c:c,a;if("boolean"===typeof c||"number"===
function ra(a,b,d,c){switch(c){case y:return"$"}for(;"object"===typeof c&&null!==c&&(c.$$typeof===y||c.$$typeof===A);)try{switch(c.$$typeof){case y:var f=c;c=U(f.type,f.key,f.ref,f.props);break;case A:var g=c._init;c=g(c._payload)}}catch(t){if("object"===typeof t&&null!==t&&"function"===typeof t.then)return a.pendingChunks++,a=ta(a,c,I),d=a.ping,t.then(d,d),"@"+a.id.toString(16);Y(a,t);a.pendingChunks++;d=a.nextChunkId++;Z(a,d,t);return"@"+d.toString(16)}if(null===c)return null;if("object"===typeof c){if(c.$$typeof===
x){f=c.filepath+"#"+c.name;g=a.writtenModules;var h=g.get(f);if(void 0!==h)return b[0]===y&&"1"===d?"@"+h.toString(16):"$"+h.toString(16);try{var p=a.bundlerConfig[c.filepath][c.name];a.pendingChunks++;var l=a.nextChunkId++,P=w(p),Q="M"+l.toString(16)+":"+P+"\n";var R=q.encode(Q);a.completedModuleChunks.push(R);g.set(f,l);return b[0]===y&&"1"===d?"@"+l.toString(16):"$"+l.toString(16)}catch(t){return a.pendingChunks++,d=a.nextChunkId++,Z(a,d,t),"$"+d.toString(16)}}else{if(c.$$typeof===z)return b=c._context._globalName,
c=a.writtenProviders,d=c.get(d),void 0===d&&(a.pendingChunks++,d=a.nextChunkId++,c.set(b,d),b="P"+d.toString(16)+":"+b+"\n",b=q.encode(b),a.completedJSONChunks.push(b)),"$"+d.toString(16);if(c===ua){a=I;if(null===a)throw Error("Tried to pop a Context at the root of the app. This is a bug in React.");d=a.parentValue;a.context._currentValue=d===B?a.context._defaultValue:d;I=a.parent;return}}return c}if("string"===typeof c)return a="$"===c[0]||"@"===c[0]?"$"+c:c,a;if("boolean"===typeof c||"number"===
typeof c||"undefined"===typeof c)return c;if("function"===typeof c){if(/^on[A-Z]/.test(d))throw Error("Event handlers cannot be passed to client component props. Remove "+(W(d)+" from these props if possible: "+X(b)+"\nIf you need interactivity, consider converting part of this to a client component."));throw Error("Functions cannot be passed directly to client components because they're not serializable. Remove "+(W(d)+" ("+(c.displayName||c.name||"function")+") from this object, or avoid the entire object: "+
X(b)));}if("symbol"===typeof c){q=a.writtenSymbols;l=q.get(c);if(void 0!==l)return"$"+l.toString(16);l=c.description;if(Symbol.for(l)!==c)throw Error("Only global symbols received from Symbol.for(...) can be passed to client components. The symbol Symbol.for("+(c.description+") cannot be found among global symbols. Remove ")+(W(d)+" from this object, or avoid the entire object: "+X(b)));a.pendingChunks++;d=a.nextChunkId++;b=w(l);b="S"+d.toString(16)+":"+b+"\n";b=p.encode(b);a.completedModuleChunks.push(b);
q.set(c,d);return"$"+d.toString(16)}if("bigint"===typeof c)throw Error("BigInt ("+c+") is not yet supported in client component props. Remove "+(W(d)+" from this object or use a plain number instead: "+X(b)));throw Error("Type "+typeof c+" is not supported in client component props. Remove "+(W(d)+" from this object, or avoid the entire object: "+X(b)));}function Y(a,b){a=a.onError;a(b)}function va(a,b){null!==a.destination?(a.status=2,u(a.destination,b)):(a.status=1,a.fatalError=b)}
function Z(a,b,d){var c="";try{if(d instanceof Error){var f=String(d.message);c=String(d.stack)}else f="Error: "+d}catch(g){f="An error occurred but serializing the error message failed."}d={message:f,stack:c};b="E"+b.toString(16)+":"+w(d)+"\n";b=p.encode(b);a.completedErrorChunks.push(b)}
function ta(a){var b=T.current,d=R;T.current=la;R=a.cache;try{var c=a.pingedSegments;a.pingedSegments=[];for(var f=0;f<c.length;f++){var g=c[f];var h=a;M(g.context);try{for(var q=g.model;"object"===typeof q&&null!==q&&q.$$typeof===y;){var l=q;g.model=q;q=U(l.type,l.key,l.ref,l.props)}var O=g.id,P=w(q,h.toJSON),Q="J"+O.toString(16)+":"+P+"\n";var t=p.encode(Q);h.completedJSONChunks.push(t)}catch(v){if("object"===typeof v&&null!==v&&"function"===typeof v.then){var ka=g.ping;v.then(ka,ka)}else Y(h,v),
Z(h,g.id,v)}}null!==a.destination&&wa(a,a.destination)}catch(v){Y(a,v),va(a,v)}finally{T.current=b,R=d}}
function wa(a,b){k=new Uint8Array(512);m=0;try{for(var d=a.completedModuleChunks,c=0;c<d.length;c++)if(a.pendingChunks--,!n(b,d[c])){a.destination=null;c++;break}d.splice(0,c);var f=a.completedJSONChunks;for(c=0;c<f.length;c++)if(a.pendingChunks--,!n(b,f[c])){a.destination=null;c++;break}f.splice(0,c);var g=a.completedErrorChunks;for(c=0;c<g.length;c++)if(a.pendingChunks--,!n(b,g[c])){a.destination=null;c++;break}g.splice(0,c)}finally{k&&0<m&&(b.enqueue(new Uint8Array(k.buffer,0,m)),k=null,m=0)}0===
a.pendingChunks&&b.close()}function qa(a){if(a){var b=I;M(null);for(var d=0;d<a.length;d++){var c=a[d],f=c[0];c=c[1];S[f]||(S[f]=e.createServerContext(f,B));ha(S[f],c)}a=I;M(b);return a}return null}
exports.renderToReadableStream=function(a,b,d,c){var f=oa(a,b,d?d.onError:void 0,c);return new ReadableStream({type:"bytes",start:function(){ta(f)},pull:function(a){if(1===f.status)f.status=2,u(a,f.fatalError);else if(2!==f.status&&null===f.destination){f.destination=a;try{wa(f,a)}catch(h){Y(f,h),va(f,h)}}},cancel:function(){}})};
X(b)));}if("symbol"===typeof c){p=a.writtenSymbols;l=p.get(c);if(void 0!==l)return"$"+l.toString(16);l=c.description;if(Symbol.for(l)!==c)throw Error("Only global symbols received from Symbol.for(...) can be passed to client components. The symbol Symbol.for("+(c.description+") cannot be found among global symbols. Remove ")+(W(d)+" from this object, or avoid the entire object: "+X(b)));a.pendingChunks++;d=a.nextChunkId++;b=w(l);b="S"+d.toString(16)+":"+b+"\n";b=q.encode(b);a.completedModuleChunks.push(b);
p.set(c,d);return"$"+d.toString(16)}if("bigint"===typeof c)throw Error("BigInt ("+c+") is not yet supported in client component props. Remove "+(W(d)+" from this object or use a plain number instead: "+X(b)));throw Error("Type "+typeof c+" is not supported in client component props. Remove "+(W(d)+" from this object, or avoid the entire object: "+X(b)));}function Y(a,b){a=a.onError;a(b)}function xa(a,b){null!==a.destination?(a.status=2,u(a.destination,b)):(a.status=1,a.fatalError=b)}
function Z(a,b,d){var c="";try{if(d instanceof Error){var f=String(d.message);c=String(d.stack)}else f="Error: "+d}catch(g){f="An error occurred but serializing the error message failed."}d={message:f,stack:c};b="E"+b.toString(16)+":"+w(d)+"\n";b=q.encode(b);a.completedErrorChunks.push(b)}
function va(a){var b=T.current,d=O;T.current=na;O=a.cache;M=a;try{var c=a.pingedSegments;a.pingedSegments=[];for(var f=0;f<c.length;f++){var g=c[f];var h=a;L(g.context);try{for(var p=g.model;"object"===typeof p&&null!==p&&p.$$typeof===y;){var l=p;g.model=p;p=U(l.type,l.key,l.ref,l.props)}var P=g.id,Q=w(p,h.toJSON),R="J"+P.toString(16)+":"+Q+"\n";var t=q.encode(R);h.completedJSONChunks.push(t)}catch(v){if("object"===typeof v&&null!==v&&"function"===typeof v.then){var la=g.ping;v.then(la,la)}else Y(h,
v),Z(h,g.id,v)}}null!==a.destination&&ya(a,a.destination)}catch(v){Y(a,v),xa(a,v)}finally{T.current=b,O=d,M=null}}
function ya(a,b){k=new Uint8Array(512);m=0;try{for(var d=a.completedModuleChunks,c=0;c<d.length;c++)if(a.pendingChunks--,!n(b,d[c])){a.destination=null;c++;break}d.splice(0,c);var f=a.completedJSONChunks;for(c=0;c<f.length;c++)if(a.pendingChunks--,!n(b,f[c])){a.destination=null;c++;break}f.splice(0,c);var g=a.completedErrorChunks;for(c=0;c<g.length;c++)if(a.pendingChunks--,!n(b,g[c])){a.destination=null;c++;break}g.splice(0,c)}finally{k&&0<m&&(b.enqueue(new Uint8Array(k.buffer,0,m)),k=null,m=0)}0===
a.pendingChunks&&b.close()}function sa(a){if(a){var b=I;L(null);for(var d=0;d<a.length;d++){var c=a[d],f=c[0];c=c[1];S[f]||(S[f]=e.createServerContext(f,B));ia(S[f],c)}a=I;L(b);return a}return null}
exports.renderToReadableStream=function(a,b,d){var c=qa(a,b,d?d.onError:void 0,d?d.context:void 0,d?d.identifierPrefix:void 0);return new ReadableStream({type:"bytes",start:function(){va(c)},pull:function(a){if(1===c.status)c.status=2,u(a,c.fatalError);else if(2!==c.status&&null===c.destination){c.destination=a;try{ya(c,a)}catch(g){Y(c,g),xa(c,g)}}},cancel:function(){}},{highWaterMark:0})};

View file

@ -34,7 +34,11 @@ function parseModel(response, json) {
}
// eslint-disable-next-line no-unused-vars
function resolveModuleReference(moduleData) {
function resolveModuleReference(bundlerConfig, moduleData) {
if (bundlerConfig) {
return bundlerConfig[moduleData.id][moduleData.name];
}
return moduleData;
} // The chunk cache contains all the chunks we've preloaded so far.
// If they're still pending they're a thenable. This map also exists
@ -365,9 +369,10 @@ function parseModelTuple(response, value) {
return value;
}
function createResponse() {
function createResponse(bundlerConfig) {
var chunks = new Map();
var response = {
_bundlerConfig: bundlerConfig,
_chunks: chunks,
readRoot: readRoot
};
@ -391,7 +396,7 @@ function resolveModule(response, id, model) {
var chunks = response._chunks;
var chunk = chunks.get(id);
var moduleMetaData = parseModel(response, model);
var moduleReference = resolveModuleReference(moduleMetaData); // TODO: Add an option to encode modules that are lazy loaded.
var moduleReference = resolveModuleReference(response._bundlerConfig, moduleMetaData); // TODO: Add an option to encode modules that are lazy loaded.
// For now we preload all modules as early as possible since it's likely
// that we'll need them.
@ -527,11 +532,11 @@ function createFromJSONCallback(response) {
};
}
function createResponse$1() {
function createResponse$1(bundlerConfig) {
// NOTE: CHECK THE COMPILER OUTPUT EACH TIME YOU CHANGE THIS.
// It should be inlined to one object literal but minor changes can break it.
var stringDecoder = createStringDecoder() ;
var response = createResponse();
var response = createResponse(bundlerConfig);
response._partialRow = '';
{
@ -567,14 +572,14 @@ function startReadingFromStream(response, stream) {
reader.read().then(progress, error);
}
function createFromReadableStream(stream) {
var response = createResponse$1();
function createFromReadableStream(stream, options) {
var response = createResponse$1(options && options.moduleMap ? options.moduleMap : null);
startReadingFromStream(response, stream);
return response;
}
function createFromFetch(promiseForResponse) {
var response = createResponse$1();
function createFromFetch(promiseForResponse, options) {
var response = createResponse$1(options && options.moduleMap ? options.moduleMap : null);
promiseForResponse.then(function (r) {
startReadingFromStream(response, r.body);
}, function (e) {
@ -583,8 +588,8 @@ function createFromFetch(promiseForResponse) {
return response;
}
function createFromXHR(request) {
var response = createResponse$1();
function createFromXHR(request, options) {
var response = createResponse$1(options && options.moduleMap ? options.moduleMap : null);
var processedLength = 0;
function progress(e) {

View file

@ -7,13 +7,13 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var h=require("react"),k={stream:!0},m=new Map,p=Symbol.for("react.element"),q=Symbol.for("react.lazy"),r=Symbol.for("react.default_value"),t=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function u(a){t[a]||(t[a]=h.createServerContext(a,r));return t[a]}function v(a,b,c){this._status=a;this._value=b;this._response=c}v.prototype.then=function(a){0===this._status?(null===this._value&&(this._value=[]),this._value.push(a)):a()};
function w(a){switch(a._status){case 3:return a._value;case 1:var b=JSON.parse(a._value,a._response._fromJSON);a._status=3;return a._value=b;case 2:b=a._value;for(var c=b.chunks,d=0;d<c.length;d++){var e=m.get(c[d]);if(null!==e)throw e;}c=globalThis.__next_require__(b.id);b="*"===b.name?c:""===b.name?c.__esModule?c.default:c:c[b.name];a._status=3;return a._value=b;case 0:throw a;default:throw a._value;}}function x(){var a=y(this,0);return w(a)}function z(a,b){return new v(3,b,a)}
'use strict';var k=require("react"),l={stream:!0},n=new Map,p=Symbol.for("react.element"),q=Symbol.for("react.lazy"),r=Symbol.for("react.default_value"),t=k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function u(a){t[a]||(t[a]=k.createServerContext(a,r));return t[a]}function v(a,b,c){this._status=a;this._value=b;this._response=c}v.prototype.then=function(a){0===this._status?(null===this._value&&(this._value=[]),this._value.push(a)):a()};
function w(a){switch(a._status){case 3:return a._value;case 1:var b=JSON.parse(a._value,a._response._fromJSON);a._status=3;return a._value=b;case 2:b=a._value;for(var c=b.chunks,d=0;d<c.length;d++){var e=n.get(c[d]);if(null!==e)throw e;}c=globalThis.__next_require__(b.id);b="*"===b.name?c:""===b.name?c.__esModule?c.default:c:c[b.name];a._status=3;return a._value=b;case 0:throw a;default:throw a._value;}}function x(){var a=y(this,0);return w(a)}function z(a,b){return new v(3,b,a)}
function A(a){if(null!==a)for(var b=0;b<a.length;b++)(0,a[b])()}function C(a,b){if(0===a._status){var c=a._value;a._status=4;a._value=b;A(c)}}function D(a,b){a._chunks.forEach(function(a){C(a,b)})}function y(a,b){var c=a._chunks,d=c.get(b);d||(d=new v(0,null,a),c.set(b,d));return d}
function E(a,b,c){switch(c[0]){case "$":if("$"===c)return p;if("$"===c[1]||"@"===c[1])return c.substring(1);b=parseInt(c.substring(1),16);a=y(a,b);return w(a);case "@":return b=parseInt(c.substring(1),16),a=y(a,b),{$$typeof:q,_payload:a,_init:w}}return c}function F(a){D(a,Error("Connection closed."))}
function G(a,b){if(""!==b){var c=b[0],d=b.indexOf(":",1),e=parseInt(b.substring(1,d),16);d=b.substring(d+1);switch(c){case "J":b=a._chunks;(c=b.get(e))?0===c._status&&(a=c._value,c._status=1,c._value=d,A(a)):b.set(e,new v(1,d,a));break;case "M":b=a._chunks;c=b.get(e);d=JSON.parse(d,a._fromJSON);for(var n=d.chunks,g=0;g<n.length;g++){var f=n[g];if(void 0===m.get(f)){var B=globalThis.__next_chunk_load__(f),l=m.set.bind(m,f,null),J=m.set.bind(m,f);B.then(l,J);m.set(f,B)}}c?0===c._status&&(a=c._value,c._status=
2,c._value=d,A(a)):b.set(e,new v(2,d,a));break;case "P":a._chunks.set(e,z(a,u(d).Provider));break;case "S":c=JSON.parse(d);a._chunks.set(e,z(a,Symbol.for(c)));break;case "E":b=JSON.parse(d);c=Error(b.message);c.stack=b.stack;b=a._chunks;(d=b.get(e))?C(d,c):b.set(e,new v(4,c,a));break;default:throw Error("Error parsing the data. It's probably an error code or network corruption.");}}}
function H(a){return function(b,c){return"string"===typeof c?E(a,this,c):"object"===typeof c&&null!==c?(b=c[0]===p?{$$typeof:p,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}function I(){var a=new TextDecoder;a={_chunks:new Map,readRoot:x,_partialRow:"",_stringDecoder:a};a._fromJSON=H(a);return a}
function K(a,b){function c(b){var g=b.value;if(b.done)F(a);else{b=g;g=a._stringDecoder;for(var f=b.indexOf(10);-1<f;){var n=a._partialRow;var l=b.subarray(0,f);l=g.decode(l);G(a,n+l);a._partialRow="";b=b.subarray(f+1);f=b.indexOf(10)}a._partialRow+=g.decode(b,k);return e.read().then(c,d)}}function d(b){D(a,b)}var e=b.getReader();e.read().then(c,d)}exports.createFromFetch=function(a){var b=I();a.then(function(a){K(b,a.body)},function(a){D(b,a)});return b};
exports.createFromReadableStream=function(a){var b=I();K(b,a);return b};
exports.createFromXHR=function(a){function b(){for(var b=a.responseText,c=e,f=b.indexOf("\n",c);-1<f;)c=d._partialRow+b.substring(c,f),G(d,c),d._partialRow="",c=f+1,f=b.indexOf("\n",c);d._partialRow+=b.substring(c);e=b.length}function c(){D(d,new TypeError("Network error"))}var d=I(),e=0;a.addEventListener("progress",b);a.addEventListener("load",function(){b();F(d)});a.addEventListener("error",c);a.addEventListener("abort",c);a.addEventListener("timeout",c);return d};
function G(a,b){if(""!==b){var c=b[0],d=b.indexOf(":",1),e=parseInt(b.substring(1,d),16);d=b.substring(d+1);switch(c){case "J":b=a._chunks;(c=b.get(e))?0===c._status&&(a=c._value,c._status=1,c._value=d,A(a)):b.set(e,new v(1,d,a));break;case "M":b=a._chunks;c=b.get(e);d=JSON.parse(d,a._fromJSON);var f=a._bundlerConfig;d=f?f[d.id][d.name]:d;f=d.chunks;for(var h=0;h<f.length;h++){var g=f[h];if(void 0===n.get(g)){var B=globalThis.__next_chunk_load__(g),m=n.set.bind(n,g,null),J=n.set.bind(n,g);B.then(m,J);n.set(g,
B)}}c?0===c._status&&(a=c._value,c._status=2,c._value=d,A(a)):b.set(e,new v(2,d,a));break;case "P":a._chunks.set(e,z(a,u(d).Provider));break;case "S":c=JSON.parse(d);a._chunks.set(e,z(a,Symbol.for(c)));break;case "E":b=JSON.parse(d);c=Error(b.message);c.stack=b.stack;b=a._chunks;(d=b.get(e))?C(d,c):b.set(e,new v(4,c,a));break;default:throw Error("Error parsing the data. It's probably an error code or network corruption.");}}}
function H(a){return function(b,c){return"string"===typeof c?E(a,this,c):"object"===typeof c&&null!==c?(b=c[0]===p?{$$typeof:p,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}function I(a){var b=new TextDecoder,c=new Map;a={_bundlerConfig:a,_chunks:c,readRoot:x,_partialRow:"",_stringDecoder:b};a._fromJSON=H(a);return a}
function K(a,b){function c(b){var h=b.value;if(b.done)F(a);else{b=h;h=a._stringDecoder;for(var g=b.indexOf(10);-1<g;){var f=a._partialRow;var m=b.subarray(0,g);m=h.decode(m);G(a,f+m);a._partialRow="";b=b.subarray(g+1);g=b.indexOf(10)}a._partialRow+=h.decode(b,l);return e.read().then(c,d)}}function d(b){D(a,b)}var e=b.getReader();e.read().then(c,d)}exports.createFromFetch=function(a,b){var c=I(b&&b.moduleMap?b.moduleMap:null);a.then(function(a){K(c,a.body)},function(a){D(c,a)});return c};
exports.createFromReadableStream=function(a,b){b=I(b&&b.moduleMap?b.moduleMap:null);K(b,a);return b};
exports.createFromXHR=function(a,b){function c(){for(var b=a.responseText,c=f,d=b.indexOf("\n",c);-1<d;)c=e._partialRow+b.substring(c,d),G(e,c),e._partialRow="",c=d+1,d=b.indexOf("\n",c);e._partialRow+=b.substring(c);f=b.length}function d(){D(e,new TypeError("Network error"))}var e=I(b&&b.moduleMap?b.moduleMap:null),f=0;a.addEventListener("progress",c);a.addEventListener("load",function(){c();F(e)});a.addEventListener("error",d);a.addEventListener("abort",d);a.addEventListener("timeout",d);return e};

View file

@ -243,7 +243,7 @@
"raw-body": "2.4.1",
"react-is": "17.0.2",
"react-refresh": "0.12.0",
"react-server-dom-webpack": "0.0.0-experimental-577f2de46-20220320",
"react-server-dom-webpack": "0.0.0-experimental-d2c9e834a-20220601",
"regenerator-runtime": "0.13.4",
"sass-loader": "12.4.0",
"schema-utils2": "npm:schema-utils@2.7.1",

View file

@ -106,12 +106,15 @@ function preloadDataFetchingRecord(
function useFlightResponse(
writable: WritableStream<Uint8Array>,
id: string,
req: ReadableStream<Uint8Array>
req: ReadableStream<Uint8Array>,
serverComponentManifest: any
) {
let entry = rscCache.get(id)
if (!entry) {
const [renderStream, forwardStream] = readableStreamTee(req)
entry = createFromReadableStream(renderStream)
entry = createFromReadableStream(renderStream, {
moduleMap: serverComponentManifest.__ssr_module_mapping__,
})
rscCache.set(id, entry)
let bootstrapped = false
@ -167,14 +170,9 @@ function createServerComponentRenderer(
// react-server-dom-webpack. This is a hack until we find a better way.
if (ComponentMod.__next_app_webpack_require__ || ComponentMod.__next_rsc__) {
// @ts-ignore
globalThis.__next_require__ = (clientModuleId) => {
const ssrModuleId =
serverComponentManifest.__ssr_module_id__[clientModuleId]
return (
ComponentMod.__next_app_webpack_require__ ||
ComponentMod.__next_rsc__.__webpack_require__
)(ssrModuleId)
}
globalThis.__next_require__ =
ComponentMod.__next_app_webpack_require__ ||
ComponentMod.__next_rsc__.__webpack_require__
// @ts-ignore
globalThis.__next_chunk_load__ = () => Promise.resolve()
@ -191,7 +189,8 @@ function createServerComponentRenderer(
const response = useFlightResponse(
writable,
cachePrefix + ',' + id,
reqStream
reqStream,
serverComponentManifest
)
const root = response.readRoot()
rscCache.delete(id)

View file

@ -317,16 +317,21 @@ function useFlightResponse({
req,
pageData,
inlinedDataWritable,
serverComponentManifest,
}: {
id: string
req: ReadableStream<Uint8Array>
pageData: { current: string } | null
inlinedDataWritable: WritableStream<Uint8Array>
serverComponentManifest: any
}) {
let entry = rscCache.get(id)
if (!entry) {
const [renderStream, forwardStream] = readableStreamTee(req)
entry = createFromReadableStream(renderStream)
entry = createFromReadableStream(renderStream, {
moduleMap: serverComponentManifest.__ssr_module_mapping__,
})
rscCache.set(id, entry)
let bootstrapped = false
@ -398,6 +403,7 @@ function createServerComponentRenderer(
req: reqStream,
pageData,
inlinedDataWritable: inlinedTransformStream.writable,
serverComponentManifest,
})
const root = response.readRoot()
@ -484,11 +490,7 @@ export async function renderToHTML(
const search = urlQueryToSearchParams(query).toString()
// @ts-ignore
globalThis.__next_require__ = (clientModuleId) => {
const ssrModuleId =
serverComponentManifest.__ssr_module_id__[clientModuleId]
return ComponentMod.__next_rsc__.__webpack_require__(ssrModuleId)
}
globalThis.__next_require__ = ComponentMod.__next_rsc__.__webpack_require__
// @ts-ignore
globalThis.__next_chunk_load__ = () => Promise.resolve()

File diff suppressed because it is too large Load diff