Unverified Commit 5bc1e65e authored by Shu Ding's avatar Shu Ding Committed by GitHub

Add flag to switch to the experimental channel (#48896)

This PR does three things:
- Vendors the package `react-server-dom-webpack@experimental` as
`react-server-dom-webpack-experimental` similar to React and React DOM
- Upgrades all vendored React packages
- Re-lands the `experimentalReact` flag to switch between `@next` and
`@experimental` channels of React for app dir.

Fix NEXT-926.
parent d3c59a11
......@@ -204,6 +204,7 @@
"react-dom-builtin": "npm:react-dom@18.3.0-next-6eadbe0c4-20230425",
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-6eadbe0c4-20230425",
"react-server-dom-webpack": "18.3.0-next-6eadbe0c4-20230425",
"react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-6eadbe0c4-20230425",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
......
......@@ -97,6 +97,10 @@ pub async fn get_next_client_import_map(
"react-dom/",
request_to_import_mapping(app_dir, "next/dist/compiled/react-dom/*"),
);
import_map.insert_wildcard_alias(
"react-server-dom-webpack/",
request_to_import_mapping(app_dir, "next/dist/compiled/react-server-dom-webpack/*"),
);
}
ClientContextType::Fallback => {}
ClientContextType::Other => {}
......@@ -210,6 +214,7 @@ pub async fn get_next_server_import_map(
import_map.insert_wildcard_alias("react-dom/", external);
import_map.insert_exact_alias("styled-jsx", external);
import_map.insert_wildcard_alias("styled-jsx/", external);
import_map.insert_exact_alias("react-server-dom-webpack/", external);
}
ServerContextType::AppSSR { .. }
| ServerContextType::AppRSC { .. }
......@@ -382,6 +387,10 @@ pub async fn insert_next_server_special_aliases(
"react-dom/",
request_to_import_mapping(app_dir, "next/dist/compiled/react-dom/*"),
);
import_map.insert_wildcard_alias(
"react-server-dom-webpack/",
request_to_import_mapping(app_dir, "next/dist/compiled/react-server-dom-webpack/*"),
);
}
ServerContextType::Middleware => {}
}
......
......@@ -1141,8 +1141,12 @@ export default async function build(
forkOptions: {
env: {
...process.env,
NEXT_PREBUNDLED_REACT_WORKER: type === 'app' ? '1' : '',
__NEXT_PRIVATE_PREBUNDLED_REACT: type === 'app' ? '1' : '',
__NEXT_PRIVATE_PREBUNDLED_REACT:
type === 'app'
? config.experimental.experimentalReact
? 'experimental'
: 'next'
: '',
},
},
enableWorkerThreads: config.experimental.workerThreads,
......
......@@ -1955,7 +1955,7 @@ ${
// to ensure the correctness of the version for app.
`\
if (nextConfig && nextConfig.experimental && nextConfig.experimental.appDir) {
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = '1'
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = nextConfig.experimental.experimentalReact ? 'experimental' : 'next'
}
`
}
......
......@@ -86,7 +86,7 @@ const babelIncludeRegexes: RegExp[] = [
/[\\/](strip-ansi|ansi-regex|styled-jsx)[\\/]/,
]
const reactPackagesRegex = /^(react(?:$|\/)|react-dom(?:$|\/))/
const reactPackagesRegex = /^(react|react-dom|react-server-dom-webpack)($|\/)/
const staticGenerationAsyncStorageRegex =
/next[\\/]dist[\\/]client[\\/]components[\\/]static-generation-async-storage/
......@@ -704,6 +704,8 @@ export default async function getBaseWebpackConfig(
const hasServerComponents = hasAppDir
const disableOptimizedLoading = true
const enableTypedRoutes = !!config.experimental.typedRoutes && hasAppDir
const experimentalReact = !!config.experimental.experimentalReact && hasAppDir
const bundledReactChannel = experimentalReact ? '-experimental' : ''
if (isClient) {
if (
......@@ -1228,7 +1230,10 @@ export default async function getBaseWebpackConfig(
request === 'react/jsx-runtime'
) {
if (isAppLayer) {
return `commonjs next/dist/compiled/${request}`
return `commonjs next/dist/compiled/${request.replace(
'react',
'react' + bundledReactChannel
)}`
}
return
}
......@@ -1237,10 +1242,7 @@ export default async function getBaseWebpackConfig(
if (layer === WEBPACK_LAYERS.server) {
// React needs to be bundled for Server Components so the special
// `react-server` export condition can be used.
if (
reactPackagesRegex.test(request) ||
request === 'next/dist/compiled/react-server-dom-webpack/server.edge'
) {
if (reactPackagesRegex.test(request)) {
return
}
}
......@@ -1254,7 +1256,7 @@ export default async function getBaseWebpackConfig(
return `commonjs ${request}`
}
if (/^(react(?:$|\/)|react-dom(?:$|\/))/.test(request)) {
if (reactPackagesRegex.test(request)) {
// override react-dom to server-rendering-stub for server
if (
request === 'react-dom' &&
......@@ -1262,9 +1264,18 @@ export default async function getBaseWebpackConfig(
layer === WEBPACK_LAYERS.server ||
layer === WEBPACK_LAYERS.action)
) {
request = 'react-dom/server-rendering-stub'
request = `next/dist/compiled/react-dom${bundledReactChannel}/server-rendering-stub`
} else if (isAppLayer) {
request =
'next/dist/compiled/' +
request.replace(
/^(react-server-dom-webpack|react-dom|react)/,
(name) => {
return name + bundledReactChannel
}
)
}
return `commonjs ${isAppLayer ? 'next/dist/compiled/' : ''}${request}`
return `commonjs ${request}`
}
const notExternalModules =
......@@ -1441,7 +1452,12 @@ export default async function getBaseWebpackConfig(
// also map react to builtin ones with require-hook.
if (layer === WEBPACK_LAYERS.client) {
if (reactPackagesRegex.test(request)) {
return `commonjs next/dist/compiled/${request}`
return `commonjs next/dist/compiled/${request.replace(
/^(react-server-dom-webpack|react-dom|react)/,
(name) => {
return name + bundledReactChannel
}
)}`
}
return
}
......@@ -1781,7 +1797,7 @@ export default async function getBaseWebpackConfig(
...(hasAppDir
? [
{
test: codeCondition.test,
// All app dir layers need to use this configured resolution logic
issuerLayer: {
or: [
WEBPACK_LAYERS.server,
......@@ -1801,10 +1817,13 @@ export default async function getBaseWebpackConfig(
[require.resolve('next/dynamic')]: require.resolve(
'next/dist/shared/lib/app-dynamic'
),
'react/jsx-runtime$':
'next/dist/compiled/react/jsx-runtime',
'react/jsx-dev-runtime$':
'next/dist/compiled/react/jsx-dev-runtime',
'react/jsx-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-runtime`,
'react/jsx-dev-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime`,
'react-dom/server.edge$': `next/dist/compiled/react-dom${bundledReactChannel}/server.edge`,
'react-server-dom-webpack/client$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/client`,
'react-server-dom-webpack/client.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/client.edge`,
'react-server-dom-webpack/server.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/server.edge`,
'react-server-dom-webpack/server.node$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/server.node`,
},
},
},
......@@ -1835,9 +1854,8 @@ export default async function getBaseWebpackConfig(
// If missing the alias override here, the default alias will be used which aliases
// react to the direct file path, not the package name. In that case the condition
// will be ignored completely.
react: 'next/dist/compiled/react/react.shared-subset',
'react-dom$':
'next/dist/compiled/react-dom/server-rendering-stub',
react: `next/dist/compiled/react${bundledReactChannel}/react.shared-subset`,
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/server-rendering-stub`,
},
},
use: {
......@@ -1900,11 +1918,10 @@ export default async function getBaseWebpackConfig(
// It needs `conditionNames` here to require the proper asset,
// when react is acting as dependency of compiled/react-dom.
alias: {
react: 'next/dist/compiled/react/react.shared-subset',
react: `next/dist/compiled/react${bundledReactChannel}/react.shared-subset`,
// Use server rendering stub for RSC
// x-ref: https://github.com/facebook/react/pull/25436
'react-dom$':
'next/dist/compiled/react-dom/server-rendering-stub',
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/server-rendering-stub`,
},
},
},
......@@ -1913,9 +1930,8 @@ export default async function getBaseWebpackConfig(
test: codeCondition.test,
resolve: {
alias: {
react: 'next/dist/compiled/react',
'react-dom$':
'next/dist/compiled/react-dom/server-rendering-stub',
react: `next/dist/compiled/react${bundledReactChannel}`,
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/server-rendering-stub`,
},
},
},
......@@ -1923,12 +1939,11 @@ export default async function getBaseWebpackConfig(
test: codeCondition.test,
resolve: {
alias: {
react: 'next/dist/compiled/react',
react: `next/dist/compiled/react${bundledReactChannel}`,
'react-dom$': reactProductionProfiling
? 'next/dist/compiled/react-dom/cjs/react-dom.profiling.min'
: 'next/dist/compiled/react-dom',
'react-dom/client$':
'next/dist/compiled/react-dom/client',
? `next/dist/compiled/react-dom${bundledReactChannel}/cjs/react-dom.profiling.min`
: `next/dist/compiled/react-dom${bundledReactChannel}`,
'react-dom/client$': `next/dist/compiled/react-dom${bundledReactChannel}/client`,
},
},
},
......@@ -2292,7 +2307,7 @@ export default async function getBaseWebpackConfig(
appDir,
dev,
isEdgeServer,
useExperimentalReact: false,
useExperimentalReact: experimentalReact,
})),
hasAppDir &&
!isClient &&
......
......@@ -592,7 +592,7 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
export * as serverHooks from 'next/dist/client/components/hooks-server-context'
export { renderToReadableStream, decodeReply } from 'next/dist/compiled/react-server-dom-webpack/server.edge'
export { renderToReadableStream, decodeReply } from 'react-server-dom-webpack/server.edge'
export const __next_app_webpack_require__ = __webpack_require__
export { preloadStyle, preloadFont, preconnect } from 'next/dist/server/app-render/rsc/preloads'
`
......
// This file must be bundled in the app's client layer.
// This file must be bundled in the app's client layer, it shouldn't be directly
// imported by the server.
import { createServerReference } from 'next/dist/compiled/react-server-dom-webpack/client'
// eslint-disable-next-line import/no-extraneous-dependencies
import { createServerReference } from 'react-server-dom-webpack/client'
import { callServer } from 'next/dist/client/app-call-server'
// A noop wrapper to let the Flight client create the server reference.
......
......@@ -12,6 +12,9 @@ const originModules = [
require.resolve('../../../server/load-components'),
require.resolve('../../../server/next-server'),
require.resolve('../../../compiled/react-server-dom-webpack/client.edge'),
require.resolve(
'../../../compiled/react-server-dom-webpack-experimental/client.edge'
),
]
const RUNTIME_NAMES = ['webpack-runtime', 'webpack-api-runtime']
......@@ -23,7 +26,7 @@ export function deleteAppClientCache() {
// ensure we reset the cache for sc_server components
// loaded via react-server-dom-webpack
const reactServerDomModId = require.resolve(
'next/dist/compiled/react-server-dom-webpack/client.edge'
'react-server-dom-webpack/client.edge'
)
const reactServerDomMod = require.cache[reactServerDomModId]
......
import { encodeReply } from 'next/dist/compiled/react-server-dom-webpack/client'
// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
import { encodeReply } from 'react-server-dom-webpack/client'
export async function callServer(id: string, args: any[]) {
const actionId = id
......
......@@ -3,7 +3,9 @@ import '../build/polyfills/polyfill-module'
// @ts-ignore react-dom/client exists when using React 18
import ReactDOMClient from 'react-dom/client'
import React, { use } from 'react'
import { createFromReadableStream } from 'next/dist/compiled/react-server-dom-webpack/client'
// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
import { createFromReadableStream } from 'react-server-dom-webpack/client'
import { HeadManagerContext } from '../shared/lib/head-manager-context'
import { GlobalLayoutRouterContext } from '../shared/lib/app-router-context'
......
'use client'
import { createFromFetch } from 'next/dist/compiled/react-server-dom-webpack/client'
// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
import { createFromFetch } from 'react-server-dom-webpack/client'
import type {
FlightRouterState,
FlightData,
......
MIT License
Copyright (c) Meta Platforms, Inc. and affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
/**
* @license React
* react-server-dom-webpack-client.browser.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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 m=require("react-dom"),n=require("react"),p={stream:!0};function r(a,b){if(a){var c=a[b.id];if(a=c[b.name])c=a.name;else{a=c["*"];if(!a)throw Error('Could not find the module "'+b.id+'" in the React SSR Manifest. This is probably a bug in the React Server Components bundler.');c=b.name}return{id:a.id,chunks:a.chunks,name:c,async:!!b.async}}return b}var t=new Map,u=new Map;function v(){}
function w(a){for(var b=a.chunks,c=[],d=0;d<b.length;d++){var e=b[d],g=t.get(e);if(void 0===g){g=globalThis.__next_chunk_load__(e);c.push(g);var k=t.set.bind(t,e,null);g.then(k,v);t.set(e,g)}else null!==g&&c.push(g)}if(a.async){if(b=u.get(a.id))return"fulfilled"===b.status?null:b;var h=Promise.all(c).then(function(){return globalThis.__next_require__(a.id)});h.then(function(l){h.status="fulfilled";h.value=l},function(l){h.status="rejected";h.reason=l});u.set(a.id,h);return h}return 0<c.length?Promise.all(c):null}
var x=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher,y=new WeakMap,A=Symbol.for("react.element"),B=Symbol.for("react.lazy"),C=Symbol.for("react.default_value"),D=Symbol.iterator;function E(a){if(null===a||"object"!==typeof a)return null;a=D&&a[D]||a["@@iterator"];return"function"===typeof a?a:null}var F=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function G(a,b,c,d){this.status=a;this.value=b;this.reason=c;this._response=d}G.prototype=Object.create(Promise.prototype);
G.prototype.then=function(a,b){switch(this.status){case "resolved_model":H(this);break;case "resolved_module":I(this)}switch(this.status){case "fulfilled":a(this.value);break;case "pending":case "blocked":a&&(null===this.value&&(this.value=[]),this.value.push(a));b&&(null===this.reason&&(this.reason=[]),this.reason.push(b));break;default:b(this.reason)}};
function J(a){switch(a.status){case "resolved_model":H(a);break;case "resolved_module":I(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":throw a;default:throw a.reason;}}function K(a,b){for(var c=0;c<a.length;c++)(0,a[c])(b)}function M(a,b,c){switch(a.status){case "fulfilled":K(b,a.value);break;case "pending":case "blocked":a.value=b;a.reason=c;break;case "rejected":c&&K(c,a.reason)}}
function N(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.reason;a.status="rejected";a.reason=b;null!==c&&K(c,b)}}function O(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.value,d=a.reason;a.status="resolved_module";a.value=b;null!==c&&(I(a),M(a,c,d))}}var P=null,Q=null;
function H(a){var b=P,c=Q;P=a;Q=null;try{var d=JSON.parse(a.value,a._response._fromJSON);null!==Q&&0<Q.deps?(Q.value=d,a.status="blocked",a.value=null,a.reason=null):(a.status="fulfilled",a.value=d)}catch(e){a.status="rejected",a.reason=e}finally{P=b,Q=c}}
function I(a){try{var b=a.value;if(b.async){var c=u.get(b.id);if("fulfilled"===c.status)var d=c.value;else throw c.reason;}else d=globalThis.__next_require__(b.id);var e="*"===b.name?d:""===b.name?d.__esModule?d.default:d:d[b.name];a.status="fulfilled";a.value=e}catch(g){a.status="rejected",a.reason=g}}function R(a,b){a._chunks.forEach(function(c){"pending"===c.status&&N(c,b)})}function S(a,b){var c=a._chunks,d=c.get(b);d||(d=new G("pending",null,null,a),c.set(b,d));return d}
function T(a,b,c){if(Q){var d=Q;d.deps++}else d=Q={deps:1,value:null};return function(e){b[c]=e;d.deps--;0===d.deps&&"blocked"===a.status&&(e=a.value,a.status="fulfilled",a.value=d.value,null!==e&&K(e,d.value))}}function U(a){return function(b){return N(a,b)}}
function V(a,b){function c(){var e=Array.prototype.slice.call(arguments),g=b.bound;return g?"fulfilled"===g.status?d(b.id,g.value.concat(e)):Promise.resolve(g).then(function(k){return d(b.id,k.concat(e))}):d(b.id,e)}var d=a._callServer;y.set(c,b);return c}
function aa(a,b,c,d){if("$"===d[0]){if("$"===d)return A;switch(d[1]){case "$":return d.slice(1);case "L":return b=parseInt(d.slice(2),16),a=S(a,b),{$$typeof:B,_payload:a,_init:J};case "@":return b=parseInt(d.slice(2),16),S(a,b);case "S":return Symbol.for(d.slice(2));case "P":return a=d.slice(2),F[a]||(F[a]=n.createServerContext(a,C)),F[a].Provider;case "F":b=parseInt(d.slice(2),16);b=S(a,b);switch(b.status){case "resolved_model":H(b)}switch(b.status){case "fulfilled":return V(a,b.value);default:throw b.reason;
}case "I":return Infinity;case "-":return"$-0"===d?-0:-Infinity;case "N":return NaN;case "u":return;case "D":return new Date(Date.parse(d.slice(2)));case "n":return BigInt(d.slice(2));default:d=parseInt(d.slice(1),16);a=S(a,d);switch(a.status){case "resolved_model":H(a);break;case "resolved_module":I(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":return d=P,a.then(T(d,b,c),U(d)),null;default:throw a.reason;}}}return d}
function ba(){throw Error('Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.');}function ca(a,b,c){var d=a._chunks,e=d.get(b);c=JSON.parse(c,a._fromJSON);var g=r(a._bundlerConfig,c);if(c=w(g)){if(e){var k=e;k.status="blocked"}else k=new G("blocked",null,null,a),d.set(b,k);c.then(function(){return O(k,g)},function(h){return N(k,h)})}else e?O(e,g):d.set(b,new G("resolved_module",g,null,a))}
function W(a){R(a,Error("Connection closed."))}
function X(a,b){if(""!==b){var c=b.indexOf(":",0),d=parseInt(b.slice(0,c),16);switch(b[c+1]){case "I":ca(a,d,b.slice(c+2));break;case "H":d=b[c+2];b=b.slice(c+3);a=JSON.parse(b,a._fromJSON);if(b=x.current){if("string"===typeof a)c=a;else{c=a[0];var e=a[1]}switch(d){case "D":b.prefetchDNS(c,e);break;case "C":b.preconnect(c,e);break;case "L":b.preload(c,e);break;case "I":b.preinit(c,e)}}break;case "E":b=JSON.parse(b.slice(c+2)).digest;e=Error("An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.");e.stack=
"Error: "+e.message;e.digest=b;b=a._chunks;(c=b.get(d))?N(c,e):b.set(d,new G("rejected",null,e,a));break;default:e=b.slice(c+1),c=a._chunks,(b=c.get(d))?"pending"===b.status&&(a=b.value,d=b.reason,b.status="resolved_model",b.value=e,null!==a&&(H(b),M(b,a,d))):c.set(d,new G("resolved_model",e,null,a))}}}function da(a){return function(b,c){return"string"===typeof c?aa(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===A?{$$typeof:A,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}
var ea=Array.isArray;function fa(a){return Number.isFinite(a)?0===a&&-Infinity===1/a?"$-0":a:Infinity===a?"$Infinity":-Infinity===a?"$-Infinity":"$NaN"}
function ha(a,b,c,d){function e(l,f){if(null===f)return null;if("object"===typeof f){if("function"===typeof f.then){null===h&&(h=new FormData);k++;var L=g++;f.then(function(q){q=JSON.stringify(q,e);var z=h;z.append(b+L,q);k--;0===k&&c(z)},function(q){d(q)});return"$@"+L.toString(16)}if(f instanceof FormData){null===h&&(h=new FormData);var ia=h;l=g++;var ja=b+l+"_";f.forEach(function(q,z){ia.append(ja+z,q)});return"$K"+l.toString(16)}return!ea(f)&&E(f)?Array.from(f):f}if("string"===typeof f){if("Z"===
f[f.length-1]&&this[l]instanceof Date)return"$D"+f;f="$"===f[0]?"$"+f:f;return f}if("boolean"===typeof f)return f;if("number"===typeof f)return fa(f);if("undefined"===typeof f)return"$undefined";if("function"===typeof f){f=y.get(f);if(void 0!==f)return f=JSON.stringify(f,e),null===h&&(h=new FormData),l=g++,h.set(b+l,f),"$F"+l.toString(16);throw Error("Client Functions cannot be passed directly to Server Functions. Only Functions passed from the Server can be passed back again.");}if("symbol"===typeof f){l=
f.description;if(Symbol.for(l)!==f)throw Error("Only global symbols received from Symbol.for(...) can be passed to Server Functions. The symbol Symbol.for("+(f.description+") cannot be found among global symbols."));return"$S"+l}if("bigint"===typeof f)return"$n"+f.toString(10);throw Error("Type "+typeof f+" is not supported as an argument to a Server Function.");}var g=1,k=0,h=null;a=JSON.stringify(a,e);null===h?c(a):(h.set(b+"0",a),0===k&&c(h))}
function Y(a){a=a&&a.callServer?a.callServer:void 0;var b=new TextDecoder,c=new Map;a={_bundlerConfig:null,_callServer:void 0!==a?a:ba,_chunks:c,_partialRow:"",_stringDecoder:b};a._fromJSON=da(a);return a}
function Z(a,b){function c(g){var k=g.value;if(g.done)W(a);else{g=k;k=a._stringDecoder;for(var h=g.indexOf(10);-1<h;){var l=a._partialRow;var f=g.subarray(0,h);f=k.decode(f);X(a,l+f);a._partialRow="";g=g.subarray(h+1);h=g.indexOf(10)}a._partialRow+=k.decode(g,p);return e.read().then(c).catch(d)}}function d(g){R(a,g)}var e=b.getReader();e.read().then(c).catch(d)}exports.createFromFetch=function(a,b){var c=Y(b);a.then(function(d){Z(c,d.body)},function(d){R(c,d)});return S(c,0)};
exports.createFromReadableStream=function(a,b){b=Y(b);Z(b,a);return S(b,0)};
exports.createFromXHR=function(a,b){function c(){for(var k=a.responseText,h=g,l=k.indexOf("\n",h);-1<l;)h=e._partialRow+k.slice(h,l),X(e,h),e._partialRow="",h=l+1,l=k.indexOf("\n",h);e._partialRow+=k.slice(h);g=k.length}function d(){R(e,new TypeError("Network error"))}var e=Y(b),g=0;a.addEventListener("progress",c);a.addEventListener("load",function(){c();W(e)});a.addEventListener("error",d);a.addEventListener("abort",d);a.addEventListener("timeout",d);return S(e,0)};
exports.createServerReference=function(a,b){function c(){var d=Array.prototype.slice.call(arguments);return b(a,d)}y.set(c,{id:a,bound:null});return c};exports.encodeReply=function(a){return new Promise(function(b,c){ha(a,"",b,c)})};
/**
* @license React
* react-server-dom-webpack-client.edge.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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 p=require("react-dom"),r=require("react"),t={stream:!0};function u(a,b){if(a){var c=a[b.id];if(a=c[b.name])c=a.name;else{a=c["*"];if(!a)throw Error('Could not find the module "'+b.id+'" in the React SSR Manifest. This is probably a bug in the React Server Components bundler.');c=b.name}return{id:a.id,chunks:a.chunks,name:c,async:!!b.async}}return b}var v=new Map,w=new Map;function x(){}
function y(a){for(var b=a.chunks,c=[],d=0;d<b.length;d++){var g=b[d],e=v.get(g);if(void 0===e){e=globalThis.__next_chunk_load__(g);c.push(e);var l=v.set.bind(v,g,null);e.then(l,x);v.set(g,e)}else null!==e&&c.push(e)}if(a.async){if(b=w.get(a.id))return"fulfilled"===b.status?null:b;var m=Promise.all(c).then(function(){return globalThis.__next_require__(a.id)});m.then(function(h){m.status="fulfilled";m.value=h},function(h){m.status="rejected";m.reason=h});w.set(a.id,m);return m}return 0<c.length?Promise.all(c):null}
var z=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher,A=new WeakMap,B=Symbol.for("react.element"),C=Symbol.for("react.lazy"),D=Symbol.for("react.default_value"),E=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function F(a,b,c,d){this.status=a;this.value=b;this.reason=c;this._response=d}F.prototype=Object.create(Promise.prototype);
F.prototype.then=function(a,b){switch(this.status){case "resolved_model":G(this);break;case "resolved_module":H(this)}switch(this.status){case "fulfilled":a(this.value);break;case "pending":case "blocked":a&&(null===this.value&&(this.value=[]),this.value.push(a));b&&(null===this.reason&&(this.reason=[]),this.reason.push(b));break;default:b(this.reason)}};
function I(a){switch(a.status){case "resolved_model":G(a);break;case "resolved_module":H(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":throw a;default:throw a.reason;}}function J(a,b){for(var c=0;c<a.length;c++)(0,a[c])(b)}function K(a,b,c){switch(a.status){case "fulfilled":J(b,a.value);break;case "pending":case "blocked":a.value=b;a.reason=c;break;case "rejected":c&&J(c,a.reason)}}
function L(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.reason;a.status="rejected";a.reason=b;null!==c&&J(c,b)}}function M(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.value,d=a.reason;a.status="resolved_module";a.value=b;null!==c&&(H(a),K(a,c,d))}}var N=null,O=null;
function G(a){var b=N,c=O;N=a;O=null;try{var d=JSON.parse(a.value,a._response._fromJSON);null!==O&&0<O.deps?(O.value=d,a.status="blocked",a.value=null,a.reason=null):(a.status="fulfilled",a.value=d)}catch(g){a.status="rejected",a.reason=g}finally{N=b,O=c}}
function H(a){try{var b=a.value;if(b.async){var c=w.get(b.id);if("fulfilled"===c.status)var d=c.value;else throw c.reason;}else d=globalThis.__next_require__(b.id);var g="*"===b.name?d:""===b.name?d.__esModule?d.default:d:d[b.name];a.status="fulfilled";a.value=g}catch(e){a.status="rejected",a.reason=e}}function P(a,b){a._chunks.forEach(function(c){"pending"===c.status&&L(c,b)})}function Q(a,b){var c=a._chunks,d=c.get(b);d||(d=new F("pending",null,null,a),c.set(b,d));return d}
function R(a,b,c){if(O){var d=O;d.deps++}else d=O={deps:1,value:null};return function(g){b[c]=g;d.deps--;0===d.deps&&"blocked"===a.status&&(g=a.value,a.status="fulfilled",a.value=d.value,null!==g&&J(g,d.value))}}function S(a){return function(b){return L(a,b)}}
function T(a,b){function c(){var g=Array.prototype.slice.call(arguments),e=b.bound;return e?"fulfilled"===e.status?d(b.id,e.value.concat(g)):Promise.resolve(e).then(function(l){return d(b.id,l.concat(g))}):d(b.id,g)}var d=a._callServer;A.set(c,b);return c}
function U(a,b,c,d){if("$"===d[0]){if("$"===d)return B;switch(d[1]){case "$":return d.slice(1);case "L":return b=parseInt(d.slice(2),16),a=Q(a,b),{$$typeof:C,_payload:a,_init:I};case "@":return b=parseInt(d.slice(2),16),Q(a,b);case "S":return Symbol.for(d.slice(2));case "P":return a=d.slice(2),E[a]||(E[a]=r.createServerContext(a,D)),E[a].Provider;case "F":b=parseInt(d.slice(2),16);b=Q(a,b);switch(b.status){case "resolved_model":G(b)}switch(b.status){case "fulfilled":return T(a,b.value);default:throw b.reason;
}case "I":return Infinity;case "-":return"$-0"===d?-0:-Infinity;case "N":return NaN;case "u":return;case "D":return new Date(Date.parse(d.slice(2)));case "n":return BigInt(d.slice(2));default:d=parseInt(d.slice(1),16);a=Q(a,d);switch(a.status){case "resolved_model":G(a);break;case "resolved_module":H(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":return d=N,a.then(R(d,b,c),S(d)),null;default:throw a.reason;}}}return d}
function V(){throw Error('Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.');}function W(a,b,c){var d=a._chunks,g=d.get(b);c=JSON.parse(c,a._fromJSON);var e=u(a._bundlerConfig,c);if(c=y(e)){if(g){var l=g;l.status="blocked"}else l=new F("blocked",null,null,a),d.set(b,l);c.then(function(){return M(l,e)},function(m){return L(l,m)})}else g?M(g,e):d.set(b,new F("resolved_module",e,null,a))}
function aa(a){return function(b,c){return"string"===typeof c?U(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===B?{$$typeof:B,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}function X(a,b){var c=new TextDecoder,d=new Map;a={_bundlerConfig:a,_callServer:void 0!==b?b:V,_chunks:d,_partialRow:"",_stringDecoder:c};a._fromJSON=aa(a);return a}
function Y(){throw Error("Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.");}
function Z(a,b){function c(e){var l=e.value;if(e.done)P(a,Error("Connection closed."));else{e=l;l=a._stringDecoder;for(var m=e.indexOf(10);-1<m;){var h=a._partialRow;var n=e.subarray(0,m);n=l.decode(n);var f=h+n;h=a;if(""!==f){var k=f.indexOf(":",0);n=parseInt(f.slice(0,k),16);switch(f[k+1]){case "I":W(h,n,f.slice(k+2));break;case "H":n=f[k+2];f=f.slice(k+3);h=JSON.parse(f,h._fromJSON);f=void 0;var q=z.current;if(q)switch("string"===typeof h?k=h:(k=h[0],f=h[1]),n){case "D":q.prefetchDNS(k,f);break;
case "C":q.preconnect(k,f);break;case "L":q.preload(k,f);break;case "I":q.preinit(k,f)}break;case "E":k=JSON.parse(f.slice(k+2)).digest;f=Error("An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.");f.stack="Error: "+f.message;f.digest=k;k=h._chunks;(q=k.get(n))?L(q,f):k.set(n,new F("rejected",
null,f,h));break;default:f=f.slice(k+1),k=h._chunks,(q=k.get(n))?(h=q,n=f,"pending"===h.status&&(f=h.value,k=h.reason,h.status="resolved_model",h.value=n,null!==f&&(G(h),K(h,f,k)))):k.set(n,new F("resolved_model",f,null,h))}}a._partialRow="";e=e.subarray(m+1);m=e.indexOf(10)}a._partialRow+=l.decode(e,t);return g.read().then(c).catch(d)}}function d(e){P(a,e)}var g=b.getReader();g.read().then(c).catch(d)}
exports.createFromFetch=function(a,b){var c=X(b&&b.moduleMap?b.moduleMap:null,Y);a.then(function(d){Z(c,d.body)},function(d){P(c,d)});return Q(c,0)};exports.createFromReadableStream=function(a,b){b=X(b&&b.moduleMap?b.moduleMap:null,Y);Z(b,a);return Q(b,0)};exports.createServerReference=function(){return Y};
/**
* @license React
* react-server-dom-webpack-client.node.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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 k=require("util"),l=require("react-dom"),m=require("react"),n={stream:!0};function p(a,b){if(a){var c=a[b.id];if(a=c[b.name])c=a.name;else{a=c["*"];if(!a)throw Error('Could not find the module "'+b.id+'" in the React SSR Manifest. This is probably a bug in the React Server Components bundler.');c=b.name}return{id:a.id,chunks:a.chunks,name:c,async:!!b.async}}return b}var q=new Map,r=new Map;function t(){}
function u(a){for(var b=a.chunks,c=[],d=0;d<b.length;d++){var e=b[d],f=q.get(e);if(void 0===f){f=globalThis.__next_chunk_load__(e);c.push(f);var h=q.set.bind(q,e,null);f.then(h,t);q.set(e,f)}else null!==f&&c.push(f)}if(a.async){if(b=r.get(a.id))return"fulfilled"===b.status?null:b;var g=Promise.all(c).then(function(){return globalThis.__next_require__(a.id)});g.then(function(w){g.status="fulfilled";g.value=w},function(w){g.status="rejected";g.reason=w});r.set(a.id,g);return g}return 0<c.length?Promise.all(c):null}
var v=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher,x=new WeakMap,y=Symbol.for("react.element"),z=Symbol.for("react.lazy"),A=Symbol.for("react.default_value"),B=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function C(a,b,c,d){this.status=a;this.value=b;this.reason=c;this._response=d}C.prototype=Object.create(Promise.prototype);
C.prototype.then=function(a,b){switch(this.status){case "resolved_model":D(this);break;case "resolved_module":E(this)}switch(this.status){case "fulfilled":a(this.value);break;case "pending":case "blocked":a&&(null===this.value&&(this.value=[]),this.value.push(a));b&&(null===this.reason&&(this.reason=[]),this.reason.push(b));break;default:b(this.reason)}};
function F(a){switch(a.status){case "resolved_model":D(a);break;case "resolved_module":E(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":throw a;default:throw a.reason;}}function G(a,b){for(var c=0;c<a.length;c++)(0,a[c])(b)}function H(a,b,c){switch(a.status){case "fulfilled":G(b,a.value);break;case "pending":case "blocked":a.value=b;a.reason=c;break;case "rejected":c&&G(c,a.reason)}}
function I(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.reason;a.status="rejected";a.reason=b;null!==c&&G(c,b)}}function J(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.value,d=a.reason;a.status="resolved_module";a.value=b;null!==c&&(E(a),H(a,c,d))}}var K=null,L=null;
function D(a){var b=K,c=L;K=a;L=null;try{var d=JSON.parse(a.value,a._response._fromJSON);null!==L&&0<L.deps?(L.value=d,a.status="blocked",a.value=null,a.reason=null):(a.status="fulfilled",a.value=d)}catch(e){a.status="rejected",a.reason=e}finally{K=b,L=c}}
function E(a){try{var b=a.value;if(b.async){var c=r.get(b.id);if("fulfilled"===c.status)var d=c.value;else throw c.reason;}else d=globalThis.__next_require__(b.id);var e="*"===b.name?d:""===b.name?d.__esModule?d.default:d:d[b.name];a.status="fulfilled";a.value=e}catch(f){a.status="rejected",a.reason=f}}function M(a,b){a._chunks.forEach(function(c){"pending"===c.status&&I(c,b)})}function N(a,b){var c=a._chunks,d=c.get(b);d||(d=new C("pending",null,null,a),c.set(b,d));return d}
function O(a,b,c){if(L){var d=L;d.deps++}else d=L={deps:1,value:null};return function(e){b[c]=e;d.deps--;0===d.deps&&"blocked"===a.status&&(e=a.value,a.status="fulfilled",a.value=d.value,null!==e&&G(e,d.value))}}function P(a){return function(b){return I(a,b)}}
function Q(a,b){function c(){var e=Array.prototype.slice.call(arguments),f=b.bound;return f?"fulfilled"===f.status?d(b.id,f.value.concat(e)):Promise.resolve(f).then(function(h){return d(b.id,h.concat(e))}):d(b.id,e)}var d=a._callServer;x.set(c,b);return c}
function R(a,b,c,d){if("$"===d[0]){if("$"===d)return y;switch(d[1]){case "$":return d.slice(1);case "L":return b=parseInt(d.slice(2),16),a=N(a,b),{$$typeof:z,_payload:a,_init:F};case "@":return b=parseInt(d.slice(2),16),N(a,b);case "S":return Symbol.for(d.slice(2));case "P":return a=d.slice(2),B[a]||(B[a]=m.createServerContext(a,A)),B[a].Provider;case "F":b=parseInt(d.slice(2),16);b=N(a,b);switch(b.status){case "resolved_model":D(b)}switch(b.status){case "fulfilled":return Q(a,b.value);default:throw b.reason;
}case "I":return Infinity;case "-":return"$-0"===d?-0:-Infinity;case "N":return NaN;case "u":return;case "D":return new Date(Date.parse(d.slice(2)));case "n":return BigInt(d.slice(2));default:d=parseInt(d.slice(1),16);a=N(a,d);switch(a.status){case "resolved_model":D(a);break;case "resolved_module":E(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":return d=K,a.then(O(d,b,c),P(d)),null;default:throw a.reason;}}}return d}
function S(){throw Error('Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.');}function T(a,b,c){var d=a._chunks,e=d.get(b);c=JSON.parse(c,a._fromJSON);var f=p(a._bundlerConfig,c);if(c=u(f)){if(e){var h=e;h.status="blocked"}else h=new C("blocked",null,null,a),d.set(b,h);c.then(function(){return J(h,f)},function(g){return I(h,g)})}else e?J(e,f):d.set(b,new C("resolved_module",f,null,a))}
function U(a,b){if(""!==b){var c=b.indexOf(":",0),d=parseInt(b.slice(0,c),16);switch(b[c+1]){case "I":T(a,d,b.slice(c+2));break;case "H":d=b[c+2];b=b.slice(c+3);a=JSON.parse(b,a._fromJSON);if(b=v.current){if("string"===typeof a)c=a;else{c=a[0];var e=a[1]}switch(d){case "D":b.prefetchDNS(c,e);break;case "C":b.preconnect(c,e);break;case "L":b.preload(c,e);break;case "I":b.preinit(c,e)}}break;case "E":b=JSON.parse(b.slice(c+2)).digest;e=Error("An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.");
e.stack="Error: "+e.message;e.digest=b;b=a._chunks;(c=b.get(d))?I(c,e):b.set(d,new C("rejected",null,e,a));break;default:e=b.slice(c+1),c=a._chunks,(b=c.get(d))?"pending"===b.status&&(a=b.value,d=b.reason,b.status="resolved_model",b.value=e,null!==a&&(D(b),H(b,a,d))):c.set(d,new C("resolved_model",e,null,a))}}}
function V(a){return function(b,c){return"string"===typeof c?R(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===y?{$$typeof:y,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}function W(a,b){var c=new k.TextDecoder,d=new Map;a={_bundlerConfig:a,_callServer:void 0!==b?b:S,_chunks:d,_partialRow:"",_stringDecoder:c};a._fromJSON=V(a);return a}
function X(){throw Error("Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.");}
exports.createFromNodeStream=function(a,b){var c=W(b,X);a.on("data",function(d){if("string"===typeof d){for(var e=0,f=d.indexOf("\n",e);-1<f;)e=c._partialRow+d.slice(e,f),U(c,e),c._partialRow="",e=f+1,f=d.indexOf("\n",e);c._partialRow+=d.slice(e)}else{f=c._stringDecoder;for(e=d.indexOf(10);-1<e;){var h=c._partialRow;var g=d.subarray(0,e);g=f.decode(g);U(c,h+g);c._partialRow="";d=d.subarray(e+1);e=d.indexOf(10)}c._partialRow+=f.decode(d,n)}});a.on("error",function(d){M(c,d)});a.on("end",function(){M(c,
Error("Connection closed."))});return N(c,0)};exports.createServerReference=function(){return X};
/**
* @license React
* react-server-dom-webpack-client.node.unbundled.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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 g=require("util"),k=require("react-dom"),l=require("react"),m={stream:!0};function p(a,b){var c=a[b.id];if(a=c[b.name])b=a.name;else{a=c["*"];if(!a)throw Error('Could not find the module "'+b.id+'" in the React SSR Manifest. This is probably a bug in the React Server Components bundler.');b=b.name}return{specifier:a.specifier,name:b}}var q=new Map;
function r(a){var b=q.get(a.specifier);if(b)return"fulfilled"===b.status?null:b;var c=import(a.specifier);c.then(function(d){c.status="fulfilled";c.value=d},function(d){c.status="rejected";c.reason=d});q.set(a.specifier,c);return c}var t=k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher,u=new WeakMap,v=Symbol.for("react.element"),w=Symbol.for("react.lazy"),x=Symbol.for("react.default_value"),y=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;
function z(a,b,c,d){this.status=a;this.value=b;this.reason=c;this._response=d}z.prototype=Object.create(Promise.prototype);z.prototype.then=function(a,b){switch(this.status){case "resolved_model":A(this);break;case "resolved_module":B(this)}switch(this.status){case "fulfilled":a(this.value);break;case "pending":case "blocked":a&&(null===this.value&&(this.value=[]),this.value.push(a));b&&(null===this.reason&&(this.reason=[]),this.reason.push(b));break;default:b(this.reason)}};
function C(a){switch(a.status){case "resolved_model":A(a);break;case "resolved_module":B(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":throw a;default:throw a.reason;}}function D(a,b){for(var c=0;c<a.length;c++)(0,a[c])(b)}function E(a,b,c){switch(a.status){case "fulfilled":D(b,a.value);break;case "pending":case "blocked":a.value=b;a.reason=c;break;case "rejected":c&&D(c,a.reason)}}
function F(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.reason;a.status="rejected";a.reason=b;null!==c&&D(c,b)}}function G(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.value,d=a.reason;a.status="resolved_module";a.value=b;null!==c&&(B(a),E(a,c,d))}}var H=null,I=null;
function A(a){var b=H,c=I;H=a;I=null;try{var d=JSON.parse(a.value,a._response._fromJSON);null!==I&&0<I.deps?(I.value=d,a.status="blocked",a.value=null,a.reason=null):(a.status="fulfilled",a.value=d)}catch(e){a.status="rejected",a.reason=e}finally{H=b,I=c}}function B(a){try{var b=a.value,c=q.get(b.specifier);if("fulfilled"===c.status)var d=c.value;else throw c.reason;var e="*"===b.name?d:""===b.name?d.default:d[b.name];a.status="fulfilled";a.value=e}catch(f){a.status="rejected",a.reason=f}}
function J(a,b){a._chunks.forEach(function(c){"pending"===c.status&&F(c,b)})}function K(a,b){var c=a._chunks,d=c.get(b);d||(d=new z("pending",null,null,a),c.set(b,d));return d}function L(a,b,c){if(I){var d=I;d.deps++}else d=I={deps:1,value:null};return function(e){b[c]=e;d.deps--;0===d.deps&&"blocked"===a.status&&(e=a.value,a.status="fulfilled",a.value=d.value,null!==e&&D(e,d.value))}}function M(a){return function(b){return F(a,b)}}
function N(a,b){function c(){var e=Array.prototype.slice.call(arguments),f=b.bound;return f?"fulfilled"===f.status?d(b.id,f.value.concat(e)):Promise.resolve(f).then(function(h){return d(b.id,h.concat(e))}):d(b.id,e)}var d=a._callServer;u.set(c,b);return c}
function O(a,b,c,d){if("$"===d[0]){if("$"===d)return v;switch(d[1]){case "$":return d.slice(1);case "L":return b=parseInt(d.slice(2),16),a=K(a,b),{$$typeof:w,_payload:a,_init:C};case "@":return b=parseInt(d.slice(2),16),K(a,b);case "S":return Symbol.for(d.slice(2));case "P":return a=d.slice(2),y[a]||(y[a]=l.createServerContext(a,x)),y[a].Provider;case "F":b=parseInt(d.slice(2),16);b=K(a,b);switch(b.status){case "resolved_model":A(b)}switch(b.status){case "fulfilled":return N(a,b.value);default:throw b.reason;
}case "I":return Infinity;case "-":return"$-0"===d?-0:-Infinity;case "N":return NaN;case "u":return;case "D":return new Date(Date.parse(d.slice(2)));case "n":return BigInt(d.slice(2));default:d=parseInt(d.slice(1),16);a=K(a,d);switch(a.status){case "resolved_model":A(a);break;case "resolved_module":B(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":return d=H,a.then(L(d,b,c),M(d)),null;default:throw a.reason;}}}return d}
function P(){throw Error('Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.');}function Q(a,b,c){var d=a._chunks,e=d.get(b);c=JSON.parse(c,a._fromJSON);var f=p(a._bundlerConfig,c);if(c=r(f)){if(e){var h=e;h.status="blocked"}else h=new z("blocked",null,null,a),d.set(b,h);c.then(function(){return G(h,f)},function(n){return F(h,n)})}else e?G(e,f):d.set(b,new z("resolved_module",f,null,a))}
function R(a,b){if(""!==b){var c=b.indexOf(":",0),d=parseInt(b.slice(0,c),16);switch(b[c+1]){case "I":Q(a,d,b.slice(c+2));break;case "H":d=b[c+2];b=b.slice(c+3);a=JSON.parse(b,a._fromJSON);if(b=t.current){if("string"===typeof a)c=a;else{c=a[0];var e=a[1]}switch(d){case "D":b.prefetchDNS(c,e);break;case "C":b.preconnect(c,e);break;case "L":b.preload(c,e);break;case "I":b.preinit(c,e)}}break;case "E":b=JSON.parse(b.slice(c+2)).digest;e=Error("An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.");
e.stack="Error: "+e.message;e.digest=b;b=a._chunks;(c=b.get(d))?F(c,e):b.set(d,new z("rejected",null,e,a));break;default:e=b.slice(c+1),c=a._chunks,(b=c.get(d))?"pending"===b.status&&(a=b.value,d=b.reason,b.status="resolved_model",b.value=e,null!==a&&(A(b),E(b,a,d))):c.set(d,new z("resolved_model",e,null,a))}}}
function S(a){return function(b,c){return"string"===typeof c?O(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===v?{$$typeof:v,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}function T(a,b){var c=new g.TextDecoder,d=new Map;a={_bundlerConfig:a,_callServer:void 0!==b?b:P,_chunks:d,_partialRow:"",_stringDecoder:c};a._fromJSON=S(a);return a}
function U(){throw Error("Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.");}
exports.createFromNodeStream=function(a,b){var c=T(b,U);a.on("data",function(d){if("string"===typeof d){for(var e=0,f=d.indexOf("\n",e);-1<f;)e=c._partialRow+d.slice(e,f),R(c,e),c._partialRow="",e=f+1,f=d.indexOf("\n",e);c._partialRow+=d.slice(e)}else{f=c._stringDecoder;for(e=d.indexOf(10);-1<e;){var h=c._partialRow;var n=d.subarray(0,e);n=f.decode(n);R(c,h+n);c._partialRow="";d=d.subarray(e+1);e=d.indexOf(10)}c._partialRow+=f.decode(d,m)}});a.on("error",function(d){J(c,d)});a.on("end",function(){J(c,
Error("Connection closed."))});return K(c,0)};exports.createServerReference=function(){return U};
/**
* @license React
* react-server-dom-webpack-node-register.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
'use strict';const n=require("acorn-loose"),p=require("url"),r=require("module");
module.exports=function(){const h=Symbol.for("react.client.reference"),k=Symbol.for("react.server.reference"),t=Promise.prototype,u=Function.prototype.bind;Function.prototype.bind=function(a){const c=u.apply(this,arguments);if(this.$$typeof===k){const b=Array.prototype.slice.call(arguments,1);c.$$typeof=k;c.$$id=this.$$id;c.$$bound=this.$$bound?this.$$bound.concat(b):b}return c};const v={get:function(a,c){switch(c){case "$$typeof":return a.$$typeof;case "$$id":return a.$$id;case "$$async":return a.$$async;
case "name":return a.name;case "displayName":return;case "defaultProps":return;case "toJSON":return;case Symbol.toPrimitive:return Object.prototype[Symbol.toPrimitive];case "Provider":throw Error("Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider.");}throw Error("Cannot access "+(String(a.name)+"."+String(c))+" on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.");
},set:function(){throw Error("Cannot assign to a client module from a server module.");}},q={get:function(a,c){switch(c){case "$$typeof":return a.$$typeof;case "$$id":return a.$$id;case "$$async":return a.$$async;case "name":return a.name;case "defaultProps":return;case "toJSON":return;case Symbol.toPrimitive:return Object.prototype[Symbol.toPrimitive];case "__esModule":const d=a.$$id;a.default=Object.defineProperties(function(){throw Error("Attempted to call the default export of "+d+" from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");
},{$$typeof:{value:h},$$id:{value:a.$$id+"#"},$$async:{value:a.$$async}});return!0;case "then":if(a.then)return a.then;if(a.$$async)return;var b=Object.defineProperties({},{$$typeof:{value:h},$$id:{value:a.$$id},$$async:{value:!0}});const e=new Proxy(b,q);a.status="fulfilled";a.value=e;return a.then=Object.defineProperties(function(f){return Promise.resolve(f(e))},{$$typeof:{value:h},$$id:{value:a.$$id+"#then"},$$async:{value:!1}})}b=a[c];b||(b=Object.defineProperties(function(){throw Error("Attempted to call "+
String(c)+"() from the server but "+String(c)+" is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");},{name:{value:c},$$typeof:{value:h},$$id:{value:a.$$id+"#"+c},$$async:{value:a.$$async}}),b=a[c]=new Proxy(b,v));return b},getPrototypeOf(){return t},set:function(){throw Error("Cannot assign to a client module from a server module.");}},l=r.prototype._compile;r.prototype._compile=function(a,
c){if(-1===a.indexOf("use client")&&-1===a.indexOf("use server"))return l.apply(this,arguments);try{var b=n.parse(a,{ecmaVersion:"2024",sourceType:"source"}).body}catch(m){return console.error("Error parsing %s %s",p,m.message),l.apply(this,arguments)}var d=!1,e=!1;for(var f=0;f<b.length;f++){var g=b[f];if("ExpressionStatement"!==g.type||!g.directive)break;"use client"===g.directive&&(d=!0);"use server"===g.directive&&(e=!0)}if(!d&&!e)return l.apply(this,arguments);if(d&&e)throw Error('Cannot have both "use client" and "use server" directives in the same file.');
d&&(b=p.pathToFileURL(c).href,b=Object.defineProperties({},{$$typeof:{value:h},$$id:{value:b},$$async:{value:!1}}),this.exports=new Proxy(b,q));if(e)if(l.apply(this,arguments),e=p.pathToFileURL(c).href,b=this.exports,"function"===typeof b)Object.defineProperties(b,{$$typeof:{value:k},$$id:{value:e},$$bound:{value:null}});else for(d=Object.keys(b),f=0;f<d.length;f++){g=d[f];const m=b[d[f]];"function"===typeof m&&Object.defineProperties(m,{$$typeof:{value:k},$$id:{value:e+"#"+g},$$bound:{value:null}})}}};
/**
* @license React
* react-server-dom-webpack-plugin.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
'use strict';var r=require("path"),u=require("url"),x=require("neo-async"),A=require("acorn-loose"),B=require("webpack/lib/dependencies/ModuleDependency"),C=require("webpack/lib/dependencies/NullDependency"),D=require("webpack/lib/Template"),E=require("webpack");const F=Array.isArray;class G extends B{constructor(b){super(b)}get type(){return"client-reference"}}const H=require.resolve("../client.browser.js");
class I{constructor(b){this.ssrManifestFilename=this.clientManifestFilename=this.chunkName=this.clientReferences=void 0;if(!b||"boolean"!==typeof b.isServer)throw Error("React Server Plugin: You must specify the isServer option as a boolean.");if(b.isServer)throw Error("TODO: Implement the server compiler.");b.clientReferences?"string"!==typeof b.clientReferences&&F(b.clientReferences)?this.clientReferences=b.clientReferences:this.clientReferences=[b.clientReferences]:this.clientReferences=[{directory:".",
recursive:!0,include:/\.(js|ts|jsx|tsx)$/}];"string"===typeof b.chunkName?(this.chunkName=b.chunkName,/\[(index|request)\]/.test(this.chunkName)||(this.chunkName+="[index]")):this.chunkName="client[index]";this.clientManifestFilename=b.clientManifestFilename||"react-client-manifest.json";this.ssrManifestFilename=b.ssrManifestFilename||"react-ssr-manifest.json"}apply(b){const n=this;let p,t=!1;b.hooks.beforeCompile.tapAsync("React Server Plugin",(e,g)=>{e=e.contextModuleFactory;const l=b.resolverFactory.get("context",
{}),a=b.resolverFactory.get("normal");n.resolveAllClientFiles(b.context,l,a,b.inputFileSystem,e,function(c,d){c?g(c):(p=d,g())})});b.hooks.thisCompilation.tap("React Server Plugin",(e,g)=>{g=g.normalModuleFactory;e.dependencyFactories.set(G,g);e.dependencyTemplates.set(G,new C.Template);e=l=>{l.hooks.program.tap("React Server Plugin",()=>{const a=l.state.module;if(a.resource===H&&(t=!0,p))for(let d=0;d<p.length;d++){const m=p[d];var c=n.chunkName.replace(/\[index\]/g,""+d).replace(/\[request\]/g,
D.toPath(m.userRequest));c=new E.AsyncDependenciesBlock({name:c},null,m.request);c.addDependency(m);a.addBlock(c)}})};g.hooks.parser.for("javascript/auto").tap("HarmonyModulesPlugin",e);g.hooks.parser.for("javascript/esm").tap("HarmonyModulesPlugin",e);g.hooks.parser.for("javascript/dynamic").tap("HarmonyModulesPlugin",e)});b.hooks.make.tap("React Server Plugin",e=>{e.hooks.processAssets.tap({name:"React Server Plugin",stage:E.Compilation.PROCESS_ASSETS_STAGE_REPORT},function(){if(!1===t)e.warnings.push(new E.WebpackError("Client runtime at react-server-dom-webpack/client was not found. React Server Components module map file "+
n.clientManifestFilename+" was not created."));else{var g=new Set((p||[]).map(d=>d.request)),l={},a={};e.chunkGroups.forEach(function(d){function m(k,f){if(g.has(f.resource)&&(f=u.pathToFileURL(f.resource).href,void 0!==f)){const h={};l[f]={id:k,chunks:q,name:"*"};h["*"]={specifier:f,name:"*"};a[k]=h}}const q=d.chunks.map(function(k){return k.id});d.chunks.forEach(function(k){k=e.chunkGraph.getChunkModulesIterable(k);Array.from(k).forEach(function(f){const h=e.chunkGraph.getModuleId(f);m(h,f);f.modules&&
f.modules.forEach(v=>{m(h,v)})})})});var c=JSON.stringify(l,null,2);e.emitAsset(n.clientManifestFilename,new E.sources.RawSource(c,!1));c=JSON.stringify(a,null,2);e.emitAsset(n.ssrManifestFilename,new E.sources.RawSource(c,!1))}})})}resolveAllClientFiles(b,n,p,t,e,g){function l(a){if(-1===a.indexOf("use client"))return!1;let c;try{c=A.parse(a,{ecmaVersion:"2024",sourceType:"module"}).body}catch(d){return!1}for(a=0;a<c.length;a++){const d=c[a];if("ExpressionStatement"!==d.type||!d.directive)break;
if("use client"===d.directive)return!0}return!1}x.map(this.clientReferences,(a,c)=>{"string"===typeof a?c(null,[new G(a)]):n.resolve({},b,a.directory,{},(d,m)=>{if(d)return c(d);e.resolveDependencies(t,{resource:m,resourceQuery:"",recursive:void 0===a.recursive?!0:a.recursive,regExp:a.include,include:void 0,exclude:a.exclude},(q,k)=>{if(q)return c(q);q=k.map(f=>{var h=r.join(m,f.userRequest);h=new G(h);h.userRequest=f.userRequest;return h});x.filter(q,(f,h)=>{p.resolve({},b,f.request,{},(v,y)=>{if(v||
"string"!==typeof y)return h(null,!1);t.readFile(y,"utf-8",(w,z)=>{if(w||"string"!==typeof z)return h(null,!1);w=l(z);h(null,w)})})},c)})})},(a,c)=>{if(a)return g(a);a=[];for(let d=0;d<c.length;d++)a.push.apply(a,c[d]);g(null,a)})}}module.exports=I;
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack-client.browser.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-client.browser.development.js');
}
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack-client.edge.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-client.edge.development.js');
}
'use strict';
module.exports = require('./client.browser');
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack-client.node.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-client.node.development.js');
}
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack-client.node.unbundled.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-client.node.unbundled.development.js');
}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
'use strict';
throw new Error('Use react-server-dom-webpack/client instead.');
'use strict';
module.exports = require('./cjs/react-server-dom-webpack-node-register.js');
{
"name": "react-server-dom-webpack-experimental-builtin",
"main": "index.js",
"exports": {
".": "./index.js",
"./plugin": "./plugin.js",
"./client": {
"workerd": "./client.edge.js",
"edge-light": "./client.edge.js",
"deno": "./client.edge.js",
"worker": "./client.edge.js",
"node": {
"webpack": "./client.node.js",
"default": "./client.node.unbundled.js"
},
"browser": "./client.browser.js",
"default": "./client.browser.js"
},
"./client.browser": "./client.browser.js",
"./client.edge": "./client.edge.js",
"./client.node": "./client.node.js",
"./client.node.unbundled": "./client.node.unbundled.js",
"./server": {
"react-server": {
"workerd": "./server.edge.js",
"edge-light": "./server.edge.js",
"deno": "./server.browser.js",
"node": {
"webpack": "./server.node.js",
"default": "./server.node.unbundled.js"
},
"browser": "./server.browser.js"
},
"default": "./server.js"
},
"./server.browser": "./server.browser.js",
"./server.edge": "./server.edge.js",
"./server.node": "./server.node.js",
"./server.node.unbundled": "./server.node.unbundled.js",
"./node-loader": "./esm/react-server-dom-webpack-node-loader.production.min.js",
"./node-register": "./node-register.js",
"./package.json": "./package.json"
},
"dependencies": {
"acorn-loose": "^8.3.0",
"neo-async": "^2.6.1",
"loose-envify": "^1.1.0"
},
"peerDependencies": {
"react": "0.0.0-experimental-6eadbe0c4-20230425",
"react-dom": "0.0.0-experimental-6eadbe0c4-20230425",
"webpack": "^5.59.0"
}
}
\ No newline at end of file
'use strict';
module.exports = require('./cjs/react-server-dom-webpack-plugin.js');
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack-server.browser.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-server.browser.development.js');
}
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack-server.edge.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-server.edge.development.js');
}
'use strict';
throw new Error(
'The React Server Writer cannot be used outside a react-server environment. ' +
'You must configure Node.js using the `--conditions react-server` flag.'
);
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack-server.node.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-server.node.development.js');
}
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack-server.node.unbundled.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-server.node.unbundled.development.js');
}
{
"name": "react-server-dom-webpack",
"description": "React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.",
"version": "18.3.0-next-6eadbe0c4-20230425",
"keywords": [
"react"
],
"homepage": "https://reactjs.org/",
"bugs": "https://github.com/facebook/react/issues",
"license": "MIT",
"files": [
"LICENSE",
"README.md",
"index.js",
"plugin.js",
"client.js",
"client.browser.js",
"client.edge.js",
"client.node.js",
"client.node.unbundled.js",
"server.js",
"server.browser.js",
"server.edge.js",
"server.node.js",
"server.node.unbundled.js",
"node-register.js",
"cjs/",
"umd/",
"esm/"
],
"name": "react-server-dom-webpack-builtin",
"main": "index.js",
"exports": {
".": "./index.js",
"./plugin": "./plugin.js",
......@@ -68,28 +41,14 @@
"./node-register": "./node-register.js",
"./package.json": "./package.json"
},
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
"directory": "packages/react-server-dom-webpack"
},
"engines": {
"node": ">=0.10.0"
},
"peerDependencies": {
"react": "18.3.0-next-6eadbe0c4-20230425",
"react-dom": "18.3.0-next-6eadbe0c4-20230425",
"webpack": "^5.59.0"
},
"dependencies": {
"acorn-loose": "^8.3.0",
"neo-async": "^2.6.1",
"loose-envify": "^1.1.0"
},
"browserify": {
"transform": [
"loose-envify"
]
"peerDependencies": {
"react": "18.3.0-next-6eadbe0c4-20230425",
"react-dom": "18.3.0-next-6eadbe0c4-20230425",
"webpack": "^5.59.0"
}
}
\ No newline at end of file
import type { GetDynamicParamFromSegment } from '../../server/app-render/app-render'
import type { LoaderTree } from '../../server/lib/app-dir-module'
import React from 'react'
import {
AppleWebAppMeta,
......@@ -14,8 +17,6 @@ import {
} from './generate/opengraph'
import { IconsMetadata } from './generate/icons'
import { accumulateMetadata, resolveMetadata } from './resolve-metadata'
import { LoaderTree } from '../../server/lib/app-dir-module'
import type { GetDynamicParamFromSegment } from '../../server/app-render/app-render'
// Generate the actual React elements from the resolved metadata.
export async function MetadataTree({
......
......@@ -108,7 +108,7 @@ export async function handleAction({
const {
decodeReply,
decodeReplyFromBusboy,
} = require('next/dist/compiled/react-server-dom-webpack/server.node')
} = require(`react-server-dom-webpack/server.node`)
if (isMultipartAction) {
const busboy = require('busboy')
......
......@@ -13,10 +13,11 @@ import type {
import type { StaticGenerationAsyncStorage } from '../../client/components/static-generation-async-storage'
import type { StaticGenerationBailout } from '../../client/components/static-generation-bailout'
import type { RequestAsyncStorage } from '../../client/components/request-async-storage'
// Import builtin react directly to avoid require cache conflicts
import React from 'next/dist/compiled/react'
import ReactDOMServer from 'next/dist/compiled/react-dom/server.edge'
import React from 'react'
import ReactDOMServer from 'react-dom/server.edge'
import { NotFound as DefaultNotFound } from '../../client/components/error'
import { createServerComponentRenderer } from './create-server-components-renderer'
import { ParsedUrlQuery } from 'querystring'
import { NextParsedUrlQuery } from '../request-meta'
......@@ -26,14 +27,13 @@ import {
createBufferedTransformStream,
continueFromInitialStream,
streamToBufferedResult,
} from '../node-web-streams-helper'
} from '../stream-utils/node-web-streams-helper'
import {
canSegmentBeOverridden,
matchSegment,
} from '../../client/components/match-segments'
import { ServerInsertedHTMLContext } from '../../shared/lib/server-inserted-html'
import { stripInternalQueries } from '../internal-utils'
import { HeadManagerContext } from '../../shared/lib/head-manager-context'
import {
NEXT_ROUTER_PREFETCH,
NEXT_ROUTER_STATE_TREE,
......@@ -56,7 +56,6 @@ import { interopDefault } from './interop-default'
import { preloadComponent } from './preload-component'
import { FlightRenderResult } from './flight-render-result'
import { createErrorHandler } from './create-error-handler'
import { createServerComponentRenderer } from './create-server-components-renderer'
import { getShortDynamicParamType } from './get-short-dynamic-param-type'
import { getSegmentParam } from './get-segment-param'
import { getCssInlinedLinkTags } from './get-css-inlined-link-tags'
......@@ -1332,10 +1331,11 @@ export async function renderToHTMLOrFlight(
nonce
)
const { HeadManagerContext } =
require('../../shared/lib/head-manager-context') as typeof import('../../shared/lib/head-manager-context')
const serverInsertedHTMLCallbacks: Set<() => React.ReactNode> = new Set()
function InsertedHTML({ children }: { children: JSX.Element }) {
// Reset addInsertedHtmlCallback on each render
serverInsertedHTMLCallbacks.clear()
const addInsertedHtml = React.useCallback(
(handler: () => React.ReactNode) => {
serverInsertedHTMLCallbacks.add(handler)
......@@ -1422,27 +1422,30 @@ export async function renderToHTMLOrFlight(
}
}
const flushed = renderToString(
<>
{Array.from(serverInsertedHTMLCallbacks).map((callback) =>
callback()
)}
{polyfillsFlushed
? null
: polyfills?.map((polyfill) => {
return (
<script
key={polyfill.src}
src={polyfill.src}
integrity={polyfill.integrity}
noModule={true}
nonce={nonce}
/>
)
})}
{errorMetaTags}
</>
)
const flushed = renderToString({
ReactDOMServer: require('react-dom/server.edge'),
element: (
<>
{Array.from(serverInsertedHTMLCallbacks).map((callback) =>
callback()
)}
{polyfillsFlushed
? null
: polyfills?.map((polyfill) => {
return (
<script
key={polyfill.src}
src={polyfill.src}
integrity={polyfill.integrity}
noModule={true}
nonce={nonce}
/>
)
})}
{errorMetaTags}
</>
),
})
polyfillsFlushed = true
return flushed
}
......@@ -1503,7 +1506,7 @@ export async function renderToHTMLOrFlight(
}
const renderStream = await renderToInitialStream({
ReactDOMServer,
ReactDOMServer: require('react-dom/server.edge'),
element: (
<html id="__next_error__">
<head>
......
import { LoaderTree } from '../lib/app-dir-module'
import { FlightRouterState, Segment } from './types'
import { GetDynamicParamFromSegment } from './app-render'
import type { LoaderTree } from '../lib/app-dir-module'
import type { FlightRouterState, Segment } from './types'
import type { GetDynamicParamFromSegment } from './app-render'
import { PAGE_SEGMENT_KEY } from '../../shared/lib/constants'
export function addSearchParamsIfPageSegment(
......
import { RenderOpts } from './types'
import React, { use } from 'next/dist/compiled/react'
import type { RenderOpts } from './types'
import type { FlightResponseRef } from './flight-response-ref'
import React, { use } from 'react'
import { createErrorHandler } from './create-error-handler'
import { useFlightResponse } from './use-flight-response'
import { FlightResponseRef } from './flight-response-ref'
/**
* Create a component that renders the Flight stream.
......
import React from 'next/dist/compiled/react'
import ReactDOMServer from 'next/dist/compiled/react-dom/server.edge'
import { streamToString } from '../node-web-streams-helper'
import { streamToString } from '../stream-utils/node-web-streams-helper'
import { AppRenderSpan } from '../lib/trace/constants'
import { getTracer } from '../lib/trace/tracer'
export async function renderToString(element: React.ReactElement) {
export async function renderToString({
ReactDOMServer,
element,
}: {
ReactDOMServer: typeof import('react-dom/server.edge')
element: React.ReactElement
}) {
return getTracer().trace(AppRenderSpan.renderToString, async () => {
const renderStream = await ReactDOMServer.renderToReadableStream(element)
await renderStream.allReady
......
import { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin'
import {
readableStreamTee,
encodeText,
decodeText,
} from '../node-web-streams-helper'
import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin'
import type { FlightResponseRef } from './flight-response-ref'
import { readableStreamTee } from '../stream-utils/node-web-streams-helper'
import { encodeText, decodeText } from '../stream-utils/encode-decode'
import { htmlEscapeJsonString } from '../htmlescape'
import { isEdgeRuntime } from './app-render'
import { FlightResponseRef } from './flight-response-ref'
/**
* Render Flight stream.
......@@ -25,7 +22,7 @@ export function useFlightResponse(
}
const {
createFromReadableStream,
} = require('next/dist/compiled/react-server-dom-webpack/client.edge')
} = require(`react-server-dom-webpack/client.edge`)
const [renderStream, forwardStream] = readableStreamTee(req)
const res = createFromReadableStream(renderStream, {
......
......@@ -286,6 +286,9 @@ const configSchema = {
appDir: {
type: 'boolean',
},
experimentalReact: {
type: 'boolean',
},
extensionAlias: {
type: 'object',
},
......
......@@ -271,6 +271,11 @@ export interface ExperimentalConfig {
*
*/
instrumentationHook?: boolean
/**
* Enable `react@experimental` channel for the `app` directory.
*/
experimentalReact?: boolean
}
export type ExportPathMap = {
......
......@@ -9,7 +9,7 @@ import {
IncrementalCacheEntry,
} from '../../response-cache'
import { encode } from '../../../shared/lib/bloom-filter/base64-arraybuffer'
import { encodeText } from '../../node-web-streams-helper'
import { encodeText } from '../../stream-utils/encode-decode'
function toRoute(pathname: string): string {
return pathname.replace(/\/$/, '').replace(/\/index$/, '') || '/'
......
......@@ -68,7 +68,8 @@ export const createWorker = (
serverPort: number,
ipcPort: number,
isNodeDebugging: boolean | 'brk' | undefined,
type: 'pages' | 'app'
type: 'pages' | 'app',
useExperimentalReact?: boolean
) => {
const { initialEnv } = require('@next/env') as typeof import('@next/env')
const { Worker } = require('next/dist/compiled/jest-worker')
......@@ -90,8 +91,9 @@ export const createWorker = (
NODE_ENV: process.env.NODE_ENV,
...(type === 'app'
? {
NEXT_PREBUNDLED_REACT_WORKER: '1',
__NEXT_PRIVATE_PREBUNDLED_REACT: '1',
__NEXT_PRIVATE_PREBUNDLED_REACT: useExperimentalReact
? 'experimental'
: 'next',
}
: {}),
},
......
......@@ -273,7 +273,8 @@ export default class NextNodeServer extends BaseServer {
this.port || 0,
ipcPort,
options.isNodeDebugging,
'app'
'app',
this.nextConfig.experimental.experimentalReact
)
}
this.renderWorkers.pages = createWorker(
......
......@@ -25,7 +25,7 @@ import type {
ServerRuntime,
} from 'next/types'
import type { UnwrapPromise } from '../lib/coalesced-function'
import type { ReactReadableStream } from './node-web-streams-helper'
import type { ReactReadableStream } from './stream-utils/node-web-streams-helper'
import type { ClientReferenceManifest } from '../build/webpack/plugins/flight-manifest-plugin'
import type { NextFontManifest } from '../build/webpack/plugins/next-font-manifest-plugin'
......@@ -78,7 +78,7 @@ import {
createBufferedTransformStream,
renderToInitialStream,
continueFromInitialStream,
} from './node-web-streams-helper'
} from './stream-utils/node-web-streams-helper'
import { ImageConfigContext } from '../shared/lib/image-config-context'
import stripAnsi from 'next/dist/compiled/strip-ansi'
import { stripInternalQueries } from './internal-utils'
......
This diff is collapsed.
export function encodeText(input: string) {
return new TextEncoder().encode(input)
}
export function decodeText(
input: Uint8Array | undefined,
textDecoder: TextDecoder
) {
return textDecoder.decode(input, { stream: true })
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment