remote-components 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html/host.cjs +84 -28
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +84 -28
- package/dist/html/host.js.map +1 -1
- package/dist/next/client.cjs +738 -0
- package/dist/next/client.cjs.map +1 -0
- package/dist/next/client.d.ts +11 -0
- package/dist/next/client.js +704 -0
- package/dist/next/client.js.map +1 -0
- package/dist/next/remote/render-client.cjs +19 -2
- package/dist/next/remote/render-client.cjs.map +1 -1
- package/dist/next/remote/render-client.js +10 -3
- package/dist/next/remote/render-client.js.map +1 -1
- package/dist/next/remote/render-server.cjs +1 -2
- package/dist/next/remote/render-server.cjs.map +1 -1
- package/dist/next/remote/render-server.js +1 -2
- package/dist/next/remote/render-server.js.map +1 -1
- package/dist/next/{host → server}/app-client.cjs +19 -3
- package/dist/next/server/app-client.cjs.map +1 -0
- package/dist/next/{host → server}/app-client.d.ts +1 -1
- package/dist/next/{host → server}/app-client.js +9 -3
- package/dist/next/server/app-client.js.map +1 -0
- package/dist/next/server/app-server.cjs.map +1 -0
- package/dist/next/server/app-server.js.map +1 -0
- package/dist/next/server/pages-client.cjs.map +1 -0
- package/dist/next/server/pages-client.js.map +1 -0
- package/dist/next/server/pages-server.cjs.map +1 -0
- package/dist/next/server/pages-server.js.map +1 -0
- package/dist/shared/client/remote-component.cjs +27 -19
- package/dist/shared/client/remote-component.cjs.map +1 -1
- package/dist/shared/client/remote-component.d.ts +2 -2
- package/dist/shared/client/remote-component.js +27 -19
- package/dist/shared/client/remote-component.js.map +1 -1
- package/dist/shared/ssr/fetch-remote-component.cjs +3 -1
- package/dist/shared/ssr/fetch-remote-component.cjs.map +1 -1
- package/dist/shared/ssr/fetch-remote-component.js +3 -1
- package/dist/shared/ssr/fetch-remote-component.js.map +1 -1
- package/package.json +37 -9
- package/dist/next/host/app-client.cjs.map +0 -1
- package/dist/next/host/app-client.js.map +0 -1
- package/dist/next/host/app-server.cjs.map +0 -1
- package/dist/next/host/app-server.js.map +0 -1
- package/dist/next/host/pages-client.cjs.map +0 -1
- package/dist/next/host/pages-client.js.map +0 -1
- package/dist/next/host/pages-server.cjs.map +0 -1
- package/dist/next/host/pages-server.js.map +0 -1
- /package/dist/next/{host → server}/app-server.cjs +0 -0
- /package/dist/next/{host → server}/app-server.d.ts +0 -0
- /package/dist/next/{host → server}/app-server.js +0 -0
- /package/dist/next/{host → server}/pages-client.cjs +0 -0
- /package/dist/next/{host → server}/pages-client.d.ts +0 -0
- /package/dist/next/{host → server}/pages-client.js +0 -0
- /package/dist/next/{host → server}/pages-server.cjs +0 -0
- /package/dist/next/{host → server}/pages-server.d.ts +0 -0
- /package/dist/next/{host → server}/pages-server.js +0 -0
package/dist/html/host.cjs
CHANGED
|
@@ -247,7 +247,6 @@ var init_const = __esm({
|
|
|
247
247
|
// src/shared/client/webpack-adapter.ts
|
|
248
248
|
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}) {
|
|
249
249
|
const self = globalThis;
|
|
250
|
-
self.__DISABLE_WEBPACK_EXEC__ = true;
|
|
251
250
|
if (!self.__remote_bundle_url__) {
|
|
252
251
|
self.__remote_bundle_url__ = {};
|
|
253
252
|
}
|
|
@@ -267,20 +266,20 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
267
266
|
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
268
267
|
}
|
|
269
268
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
269
|
+
if (runtime === RUNTIME_TURBOPACK) {
|
|
270
|
+
await Promise.all(
|
|
271
|
+
scripts.map((script) => {
|
|
272
|
+
if (script.src) {
|
|
273
|
+
return self.__webpack_chunk_load__?.(script.src, bundle);
|
|
274
|
+
}
|
|
275
|
+
return Promise.resolve(void 0);
|
|
276
|
+
})
|
|
277
|
+
);
|
|
278
|
+
}
|
|
278
279
|
}
|
|
279
280
|
function createChunkLoader(runtime) {
|
|
280
281
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
281
|
-
|
|
282
|
-
return Promise.resolve(void 0);
|
|
283
|
-
}
|
|
282
|
+
const self = globalThis;
|
|
284
283
|
const {
|
|
285
284
|
bundle,
|
|
286
285
|
id: path,
|
|
@@ -289,7 +288,10 @@ function createChunkLoader(runtime) {
|
|
|
289
288
|
bundle: scriptBundle ?? "",
|
|
290
289
|
id: chunkId
|
|
291
290
|
};
|
|
292
|
-
const
|
|
291
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
292
|
+
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
293
|
+
return Promise.resolve(void 0);
|
|
294
|
+
}
|
|
293
295
|
const url = new URL(
|
|
294
296
|
path ? `${prefix ?? ""}${path}`.replace(
|
|
295
297
|
/(?<char>[^:])(?<double>\/\/)/g,
|
|
@@ -383,8 +385,9 @@ function createModuleRequire(runtime) {
|
|
|
383
385
|
return (id) => {
|
|
384
386
|
const self = globalThis;
|
|
385
387
|
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? { bundle: "default", id };
|
|
388
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
386
389
|
try {
|
|
387
|
-
if (
|
|
390
|
+
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
388
391
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
389
392
|
}
|
|
390
393
|
const sharedModule = getSharedModule(bundle ?? "default", moduleId ?? id);
|
|
@@ -546,6 +549,70 @@ var init_turbopack = __esm({
|
|
|
546
549
|
// src/html/host.tsx
|
|
547
550
|
var import_client = require("react-dom/client");
|
|
548
551
|
|
|
552
|
+
// src/shared/client/rsc.ts
|
|
553
|
+
function fixPayload(payload) {
|
|
554
|
+
if (Array.isArray(payload)) {
|
|
555
|
+
if (payload[0] === "$") {
|
|
556
|
+
fixPayload(payload[3]);
|
|
557
|
+
if (payload.length === 4) {
|
|
558
|
+
payload.push(null, null, 1);
|
|
559
|
+
}
|
|
560
|
+
} else {
|
|
561
|
+
for (const item of payload) {
|
|
562
|
+
fixPayload(item);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
} else if (typeof payload === "object" && payload !== null) {
|
|
566
|
+
for (const key in payload) {
|
|
567
|
+
fixPayload(payload[key]);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
function createRSCStream(name, data) {
|
|
572
|
+
return new ReadableStream({
|
|
573
|
+
type: "bytes",
|
|
574
|
+
start(controller) {
|
|
575
|
+
const encoder = new TextEncoder();
|
|
576
|
+
const self = globalThis;
|
|
577
|
+
if (!self[name] && data.length > 0) {
|
|
578
|
+
data.forEach((chunk) => {
|
|
579
|
+
const lines = chunk.split("\n");
|
|
580
|
+
for (const line of lines) {
|
|
581
|
+
const match = /\.push\("(?<rsc>.*)"\);$/.exec(line);
|
|
582
|
+
if (match?.groups?.rsc) {
|
|
583
|
+
self[name] = self[name] ?? [];
|
|
584
|
+
self[name].push(JSON.parse(`"${match.groups.rsc}"`));
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
const allChunks = (self[name] ?? [`0:[null]
|
|
590
|
+
`]).join("");
|
|
591
|
+
allChunks.split("\n").forEach((chunk) => {
|
|
592
|
+
if (chunk.length > 0) {
|
|
593
|
+
const { id, prefix, payload } = /(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\[.*\])/.exec(
|
|
594
|
+
chunk
|
|
595
|
+
)?.groups ?? {};
|
|
596
|
+
if (payload) {
|
|
597
|
+
const jsonPayload = JSON.parse(payload);
|
|
598
|
+
fixPayload(jsonPayload);
|
|
599
|
+
const reconstruct = `${id}:${prefix ?? ""}${JSON.stringify(jsonPayload)}`;
|
|
600
|
+
controller.enqueue(encoder.encode(`${reconstruct}
|
|
601
|
+
`));
|
|
602
|
+
} else {
|
|
603
|
+
controller.enqueue(encoder.encode(`${chunk}
|
|
604
|
+
`));
|
|
605
|
+
}
|
|
606
|
+
} else {
|
|
607
|
+
controller.enqueue(encoder.encode(`${chunk}
|
|
608
|
+
`));
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
controller.close();
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
|
|
549
616
|
// src/html/runtime/index.ts
|
|
550
617
|
async function getRuntime(type, url, bundle, shared, remoteShared) {
|
|
551
618
|
if (typeof globalThis.process === "undefined") {
|
|
@@ -736,21 +803,10 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
736
803
|
const RemoteComponentFromReadableStream = ({
|
|
737
804
|
name
|
|
738
805
|
}) => {
|
|
806
|
+
const stream = createRSCStream(name, self[name] ?? [`0:[null]
|
|
807
|
+
`]);
|
|
739
808
|
const Component = cache ?? // cache the component to avoid reloading the RSC flight data
|
|
740
|
-
(cache = createFromReadableStream(
|
|
741
|
-
// convert the RSC flight data array into a ReadableStream
|
|
742
|
-
new ReadableStream({
|
|
743
|
-
type: "bytes",
|
|
744
|
-
start(controller) {
|
|
745
|
-
const encoder = new TextEncoder();
|
|
746
|
-
(self[name] ?? [`0:[null]
|
|
747
|
-
`]).forEach((chunk) => {
|
|
748
|
-
controller.enqueue(encoder.encode(chunk));
|
|
749
|
-
});
|
|
750
|
-
controller.close();
|
|
751
|
-
}
|
|
752
|
-
})
|
|
753
|
-
));
|
|
809
|
+
(cache = createFromReadableStream(stream));
|
|
754
810
|
return Component;
|
|
755
811
|
};
|
|
756
812
|
(0, import_client.hydrateRoot)(
|
package/dist/html/host.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shared/webpack/shared-modules.ts","../../src/shared/webpack/next-client-pages-loader.ts","../../src/html/runtime/webpack.ts","../../src/shared/client/const.ts","../../src/shared/client/webpack-adapter.ts","../../src/html/runtime/turbopack.ts","../../src/html/host.tsx","../../src/html/runtime/index.ts"],"sourcesContent":["// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\nexport function applySharedModules(\n bundle: string,\n resolve: Record<string, unknown>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // if we have the bundle\n if (self.__remote_webpack_require__?.[bundle]) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ??\n self.__remote_webpack_require__[bundle].m ??\n {},\n );\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n const ids = modulePaths.filter((p) => p.includes(key));\n for (let id of ids) {\n const webpackBundle = self.__remote_webpack_require__[bundle];\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {\n id = `${self.__remote_webpack_module_map__[bundle][id]}`;\n }\n // create a mock module which exports the shared module\n webpackBundle.m[id] = (module) => {\n module.exports = value;\n };\n }\n }\n }\n }\n}\n","// module loader for Next.js Pages Router\nexport function nextClientPagesLoader(\n bundle: string,\n route: string,\n styleContainer: HTMLHeadElement | ShadowRoot | null = document.head,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string | number) => unknown) & {\n c?: Record<\n string | number,\n { id: string; parents: string[]; children: string[] }\n >;\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n type?: 'turbopack' | 'webpack';\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // Next.js client pages loader reference storage\n __NEXT_P?: [\n (\n | [\n string,\n () => { default?: React.ComponentType<Record<string, unknown>> },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n ];\n };\n\n // temporarily remove the original Next.js CSS loader\n const nextCssOriginal = document.getElementById('__next_css__DO_NOT_USE__');\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.removeChild(nextCssOriginal);\n }\n\n // create a new Next.js CSS loader element\n const nextCss = document.createElement('noscript');\n nextCss.id = '__next_css__DO_NOT_USE__';\n const lastNode =\n document.head.childNodes[document.head.childNodes.length - 1];\n document.head.appendChild(nextCss);\n\n // find the page component loader chunk\n const componentLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // find the app loader chunk\n const appLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // if we didn't find the component loader or app loader, throw an error\n if (!(componentLoaderChunk && appLoaderChunk)) {\n throw new Error(\n `Next.js client pages loader not found in bundle \"${bundle}\"`,\n );\n }\n\n // temporarily store the original __NEXT_P reference\n // this is required to avoid conflicts with the Next.js client pages loader\n // which uses the same global variable to store the page components\n const __NEXT_P_ORIGINAL = self.__NEXT_P;\n const selfOriginal = self;\n delete selfOriginal.__NEXT_P;\n\n // load the component and app loader chunks\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? componentLoaderChunk\n : `[${bundle}] ${componentLoaderChunk}`,\n );\n if (\n typeof appLoaderChunk === 'string' ||\n (typeof appLoaderChunk === 'number' && appLoaderChunk !== -1)\n ) {\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? appLoaderChunk\n : `[${bundle}] ${appLoaderChunk}`,\n );\n }\n\n // if we have the __NEXT_P global variable, we can extract the component and app\n if (self.__NEXT_P) {\n const [, componentLoader] = self.__NEXT_P[0] ?? [\n undefined,\n () => ({ default: null }),\n ];\n const [, appLoader] = self.__NEXT_P[2] ?? [\n undefined,\n () => ({\n default: null,\n }),\n ];\n const { default: Component } = componentLoader();\n const { default: App } = appLoader();\n\n // load the CSS files from the remote bundle\n const cssRE = /\\.s?css$/;\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {})\n .filter((id) => cssRE.test(id))\n .forEach((id) => {\n self.__remote_webpack_require__?.[bundle]?.(id);\n });\n\n Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {})\n .filter((path) => cssRE.test(path))\n .forEach((path) => {\n const id = self.__remote_webpack_module_map__?.[bundle]?.[path];\n if (id) {\n self.__remote_webpack_require__?.[bundle]?.(id);\n }\n });\n\n // if the styleContainer is provided, we need to move the styles to it\n if (styleContainer) {\n let node = nextCss.previousSibling;\n while (node && node !== lastNode) {\n styleContainer.appendChild(node);\n node = nextCss.previousSibling;\n }\n }\n\n // restore the original __NEXT_P reference\n delete self.__NEXT_P;\n self.__NEXT_P = __NEXT_P_ORIGINAL;\n\n // restore the original Next.js CSS loader\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.appendChild(nextCssOriginal);\n }\n\n return { Component, App };\n }\n\n return { Component: null, App: null };\n}\n","import { applySharedModules } from '../../shared/webpack/shared-modules';\nimport { nextClientPagesLoader } from '../../shared/webpack/next-client-pages-loader';\n\n// initializer for the webpack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function webpackRuntime() {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__: boolean;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __webpack_require_type__: 'webpack' | 'turbopack';\n } & Record<string, string[]>;\n\n // disable webpack exec to prevent automatically executing the entry module\n self.__DISABLE_WEBPACK_EXEC__ = true;\n // add a custom webpack require function to load remote components from multiple bundles / zones\n if (\n typeof self.__webpack_require__ !== 'function' &&\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n self.__webpack_require__ = (remoteId: string) => {\n const re = /\\[(?<bundle>[a-zA-Z0-9-_]+)\\] (?<id>.*)/;\n const match = re.exec(remoteId);\n const bundle = match?.groups?.bundle;\n const id = match?.groups?.id;\n if (!(id && bundle)) {\n throw new Error(`Module not found: \"${remoteId}\"`);\n }\n if (typeof self.__remote_webpack_require__?.[bundle] !== 'function') {\n throw new Error(`Remote component loading error \"${bundle}\"`);\n }\n return self.__remote_webpack_require__[bundle](id);\n };\n // not used but required by react-server-dom-webpack\n self.__webpack_chunk_load__ = () => {\n return Promise.resolve([]);\n };\n }\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n async function preloadScripts(\n scripts: HTMLScriptElement[],\n url: URL,\n bundle: string,\n _: string,\n ) {\n // we need to properly attach script elements to the document to load the remote component bundles\n // we need to wait for all scripts to load before we can hydrate the remote component\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newScript = document.createElement('script');\n newScript.onload = () => {\n resolve();\n };\n newScript.onerror = () => {\n reject(\n new Error(\n `Failed to load script ${script.src} for remote component`,\n ),\n );\n };\n const scriptSrc =\n script.getAttribute('src') || script.getAttribute('data-src');\n if (scriptSrc) {\n newScript.src = new URL(\n scriptSrc.replace(/\\/_next\\/\\[(?:.+)\\](?:%20| )/, '/_next/'),\n url,\n ).href;\n }\n newScript.async = true;\n document.body.appendChild(newScript);\n // safe to remove the original script element\n script.parentElement?.removeChild(script);\n });\n }),\n );\n\n // module resolution map for the shared modules\n const resolve = {\n '/react/index.js': (await import('react')).default,\n '/react/jsx-dev-runtime.js': (await import('react/jsx-dev-runtime'))\n .default,\n '/react/jsx-runtime.js': (await import('react/jsx-runtime')).default,\n '/react-dom/index.js': (await import('react-dom')).default,\n '/react-dom/client.js': (await import('react-dom/client')).default,\n };\n\n // apply shared modules to the bundle\n applySharedModules(bundle, resolve);\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","export const DEFAULT_ROUTE = '/';\n\nexport const RUNTIME_WEBPACK = 'webpack';\nexport const RUNTIME_TURBOPACK = 'turbopack';\n\nexport const REMOTE_COMPONENT_REGEX =\n /(?<prefix>.*?)\\[(?<bundle>[^\\]]+)\\](?:%20| )(?<id>.+)/;\n\nexport function getBundleKey(bundle: string): string {\n return bundle.replace(/-/g, '_');\n}\n\nexport type Runtime = typeof RUNTIME_WEBPACK | typeof RUNTIME_TURBOPACK;\n","import type { GlobalScope } from './types';\nimport {\n type Runtime,\n RUNTIME_TURBOPACK,\n RUNTIME_WEBPACK,\n REMOTE_COMPONENT_REGEX,\n getBundleKey,\n} from './const';\n\n/**\n * Sets up webpack runtime environment for remote components\n */\nexport async function setupWebpackRuntime(\n runtime: Runtime,\n scripts: { src: string | null }[] = [],\n url: URL = new URL(location.href),\n bundle?: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n): Promise<void> {\n const self = globalThis as GlobalScope;\n self.__DISABLE_WEBPACK_EXEC__ = true;\n\n if (!self.__remote_bundle_url__) {\n // eslint-disable-next-line camelcase\n self.__remote_bundle_url__ = {};\n }\n self.__remote_bundle_url__[bundle ?? 'default'] = url;\n\n await initializeSharedModules(bundle ?? 'default', shared, remoteShared);\n if (\n typeof self.__webpack_require__ !== 'function' ||\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n if (\n !self.__original_webpack_require__ &&\n !self.__original_webpack_chunk_load__\n ) {\n // eslint-disable-next-line camelcase\n self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;\n // eslint-disable-next-line camelcase\n self.__original_webpack_require__ = self.__webpack_require__;\n }\n\n self.__webpack_chunk_load__ = createChunkLoader(runtime);\n self.__webpack_require__ = createModuleRequire(runtime);\n // eslint-disable-next-line camelcase\n self.__webpack_require_type__ = runtime;\n\n if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {\n const remoteBundle = bundle ?? 'default';\n self.__remote_webpack_require__[remoteBundle] =\n self.__webpack_require__ as (remoteId: string | number) => unknown;\n self.__remote_webpack_require__[remoteBundle].type = 'turbopack';\n }\n }\n await Promise.all(\n scripts.map((script) => {\n if (script.src) {\n return self.__webpack_chunk_load__?.(script.src, bundle);\n }\n return Promise.resolve(undefined);\n }),\n );\n}\n\n/**\n * Creates chunk loader function for webpack runtime\n */\nfunction createChunkLoader(\n runtime: Runtime,\n): (chunkId: string) => Promise<unknown> | undefined {\n // eslint-disable-next-line camelcase\n return function __turbopack_chunk_load__(\n chunkId: string,\n scriptBundle?: string,\n ) {\n if (runtime === RUNTIME_WEBPACK) {\n // all scripts are already loaded for this remote\n return Promise.resolve(undefined);\n }\n const {\n bundle,\n id: path,\n prefix,\n } = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {\n bundle: scriptBundle ?? '',\n id: chunkId,\n };\n const self = globalThis as GlobalScope;\n const url = new URL(\n path\n ? `${prefix ?? ''}${path}`.replace(\n /(?<char>[^:])(?<double>\\/\\/)/g,\n '$1/',\n )\n : '/',\n self.__remote_bundle_url__?.[bundle ?? 'default'] ??\n new URL(location.origin),\n ).href;\n if (url.endsWith('.css')) {\n return;\n }\n return new Promise((resolve, reject) => {\n fetch(url)\n .then((res) => res.text())\n .then((code) => {\n if (code.includes('globalThis.TURBOPACK')) {\n return handleTurbopackChunk(code, bundle ?? '', url);\n }\n })\n .then(resolve)\n .catch(reject);\n });\n };\n}\n\n/**\n * Handles Turbopack chunk loading\n */\nasync function handleTurbopackChunk(\n code: string,\n bundle: string,\n url: string,\n): Promise<void> {\n // skip this chunk as it is not needed for remote components\n if (\n code.includes('/next/dist/client/app-next-turbopack.js') &&\n code.includes('importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS')\n ) {\n // remove preload links for this chunk\n const preloadLinks = document.querySelectorAll(\n `link[rel=\"preload\"][href=\"${new URL(url).pathname}\"]`,\n );\n preloadLinks.forEach((preloadLink) => preloadLink.remove());\n return;\n }\n\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n\n // replace global variables with bundle-specific ones\n const transformedCode = code\n .replace(/globalThis\\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`)\n .replace(\n /TURBOPACK_WORKER_LOCATION/g,\n `TURBOPACK_WORKER_LOCATION_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_NEXT_CHUNK_URLS/g,\n `TURBOPACK_NEXT_CHUNK_URLS_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,\n `TURBOPACK_CHUNK_UPDATE_LISTENERS_${bundleKey}`,\n )\n .replace(/__next_require__/g, `__${bundleKey}_next_require__`)\n .replace(\n /\\/\\/# sourceMappingURL=(?<name>.+)(?<optional>\\._)?\\.js\\.map/g,\n `//# sourceMappingURL=${\n new URL(\n '.',\n new URL(\n url,\n self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin),\n ),\n ).href\n }$1$2.js.map`,\n );\n\n // load the script dynamically using a Blob URL\n await new Promise<void>((scriptResolve, scriptReject) => {\n const blob = new Blob([transformedCode], {\n type: 'application/javascript; charset=UTF-8',\n });\n const scriptUrl = URL.createObjectURL(blob);\n const script = document.createElement('script');\n script.src = scriptUrl;\n script.async = true;\n script.onload = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptResolve(undefined);\n };\n script.onerror = (error) => {\n URL.revokeObjectURL(scriptUrl);\n scriptReject(\n new Error(\n `Failed to load script: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n };\n document.head.appendChild(script);\n });\n const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`] as\n | { chunks: string[] }[]\n | undefined;\n const loadChunkLists = [] as (Promise<unknown> | undefined)[];\n while (chunkLists?.length) {\n const { chunks } = chunkLists.shift() ?? { chunks: [] };\n if (chunks.length > 0) {\n chunks.forEach((id: string) => {\n const chunkLoadResult = self.__webpack_chunk_load__?.(\n `[${bundle}] ${url.slice(0, url.indexOf('/_next'))}/_next/${id}`,\n );\n if (chunkLoadResult) {\n loadChunkLists.push(chunkLoadResult);\n }\n });\n }\n }\n if (loadChunkLists.length > 0) {\n await Promise.all(loadChunkLists);\n }\n}\n\n/**\n * Creates module require function for webpack runtime\n */\nfunction createModuleRequire(runtime: Runtime): (id: string) => unknown {\n return (id: string) => {\n const self = globalThis as GlobalScope;\n const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)\n ?.groups ?? { bundle: 'default', id };\n try {\n if (runtime === RUNTIME_WEBPACK && bundle && moduleId) {\n return self.__remote_webpack_require__?.[bundle]?.(moduleId);\n }\n const sharedModule = getSharedModule(bundle ?? 'default', moduleId ?? id);\n if (sharedModule) {\n return sharedModule;\n }\n if (bundle && moduleId) {\n return handleTurbopackModule(bundle, moduleId, id);\n }\n throw new Error(`Module ${id} not found`);\n } catch {\n try {\n return self.__original_webpack_require__?.(id);\n } catch {\n throw new Error(\n `Module ${id} not found in remote component bundle ${bundle}`,\n );\n }\n }\n };\n}\n\nfunction initializeSharedModules(\n bundle: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n) {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, Record<string, unknown>>;\n __next_f?: unknown[];\n };\n // eslint-disable-next-line camelcase\n self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};\n\n if (!self.__remote_shared_modules__[bundle]) {\n self.__remote_shared_modules__[bundle] = {};\n }\n\n // ensure that the shared modules are initialized\n return Promise.all(\n Object.entries(remoteShared).map(async ([id, module]) => {\n if (self.__remote_shared_modules__?.[bundle]) {\n self.__remote_shared_modules__[bundle][\n id.replace('[app-ssr]', '[app-client]')\n ] = await (\n shared[module] ??\n (() =>\n Promise.resolve(\n new Proxy(\n {},\n {\n get(_, prop: string) {\n if (prop !== 'then') {\n // eslint-disable-next-line no-console\n console.warn(\n `Shared dependency \"${module}\" not found for \"${bundle}\" when trying to import \"${prop}\".`,\n );\n }\n },\n },\n ),\n ))\n )();\n }\n }),\n );\n}\n\n/**\n * Returns shared modules for common dependencies\n */\nfunction getSharedModule(bundle: string, id: string): unknown {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, unknown>;\n };\n\n for (const [key, value] of Object.entries(\n self.__remote_shared_modules__?.[bundle] ?? {},\n )) {\n if (id.includes(key)) {\n return value;\n }\n }\n return null;\n}\n\n/**\n * Handles Turbopack module resolution\n */\nfunction handleTurbopackModule(\n bundle: string,\n moduleId: string,\n id: string,\n): unknown {\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n const modules = (\n self[`TURBOPACK_${bundleKey}`] as\n | [unknown, Record<string, unknown>][]\n | undefined\n )?.find((mod: [unknown, Record<string, unknown>]) => moduleId in mod[1])?.[1];\n const moduleInit = modules?.[moduleId];\n if (typeof moduleInit !== 'function') {\n throw new Error(\n `Module ${id} not found in bundle ${bundle} with id ${moduleId}`,\n );\n }\n const exports = {} as Record<string, unknown>;\n moduleInit({\n // HMR not implemented for Remote Components\n k: {\n register() {\n // omit\n },\n registerExports() {\n // omit\n },\n signature() {\n return () => {\n // omit\n };\n },\n },\n s(m: Record<string, () => unknown>) {\n for (const [key, value] of Object.entries(m)) {\n exports[key] = value;\n }\n },\n i(iid: string) {\n return self.__webpack_require__?.(`[${bundle}] ${iid}`);\n },\n r(rid: string) {\n return self.__webpack_require__?.(`[${bundle}] ${rid}`);\n },\n m: {\n exports,\n },\n });\n for (const [key, value] of Object.entries(exports)) {\n if (typeof value === 'function') {\n exports[key] = value();\n }\n }\n return exports;\n}\n","import { applySharedModules } from '../../shared/webpack/shared-modules';\nimport { nextClientPagesLoader } from '../../shared/webpack/next-client-pages-loader';\nimport { setupWebpackRuntime } from '../../shared/client/webpack-adapter';\n\n// initializer for the turbopack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function turbopackRuntime(\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__: boolean;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __remote_component_shared__?: Record<string, () => Promise<unknown>>;\n } & Record<string, string[]>;\n\n await setupWebpackRuntime(\n 'turbopack',\n [],\n url,\n bundle,\n self.__remote_component_shared__ ?? shared,\n remoteShared,\n );\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n function preloadScripts(scripts: HTMLScriptElement[], __: URL) {\n return setupWebpackRuntime(\n 'turbopack',\n scripts.map((script) => ({\n src:\n script.getAttribute('src') ||\n script.getAttribute('data-src') ||\n script.src,\n })),\n url,\n bundle,\n self.__remote_component_shared__ ?? shared,\n remoteShared,\n );\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","import { hydrateRoot } from 'react-dom/client';\nimport { getRuntime, type Runtime } from './runtime';\n\nif (typeof HTMLElement !== 'undefined') {\n class RemoteComponent extends HTMLElement {\n name: string;\n bundle: string;\n fallbackSlot: HTMLSlotElement;\n __next: HTMLDivElement | null = null;\n fouc: HTMLStyleElement | null = null;\n isLoading = false;\n\n constructor() {\n super();\n // use the shadow DOM to encapsulate the component\n this.attachShadow({ mode: 'open' });\n\n // create a slot element to allow the remote component to use the default slot\n this.fallbackSlot = document.createElement('slot');\n this.shadowRoot?.appendChild(this.fallbackSlot);\n\n this.name = this.getAttribute('name') || '__vercel_remote_component';\n this.bundle = 'default';\n\n // load when the custom element has an src, data-ssr attribute or contains an SSR remote component div\n if (\n this.hasAttribute('src') ||\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.hasAttribute('data-ssr')\n ) {\n // start loading and hydration\n this.load().catch((e) => {\n throw new Error(`Failed to load remote component: ${e}`);\n });\n }\n }\n\n static get observedAttributes() {\n return ['src'];\n }\n\n // watch for src attribute changes\n // this is required to reload the remote component when the src attribute is added later\n // this is for rendering the custom element using React\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (name === 'src' && oldValue !== newValue) {\n this.load().catch((e) => {\n throw new Error(`Failed to load remote component: ${e}`);\n });\n }\n }\n\n async load() {\n // prevent multiple loads\n if (this.isLoading) {\n return;\n }\n\n this.isLoading = true;\n const src = this.getAttribute('src');\n const remoteComponentChild = this.querySelector(\n 'div#__REMOTE_COMPONENT__',\n );\n\n if (!src && !remoteComponentChild) {\n throw new Error('src attribute is required');\n }\n\n let url: URL | null = null;\n let html = this.innerHTML;\n\n if (!remoteComponentChild && src) {\n url = new URL(src, window.location.href);\n\n // fetch the remote component\n const fetchInit = {\n method: 'GET',\n headers: {\n Accept: 'text/html',\n // pass the public address of the remote component to the server used for module map mutation\n 'Vercel-Remote-Component-Url': url.href,\n },\n credentials: this.getAttribute('credentials') || 'same-origin',\n } as RequestInit;\n\n const res = await fetch(url, fetchInit);\n\n if (!res.ok) {\n throw new Error(\n `Failed to fetch remote component \"${this.name}\": ${res.status}`,\n );\n }\n\n // get the full HTML content as a string\n html = await res.text();\n }\n // create a virtual element which will be used to parse the HTML and extract the component and RSC flight data\n const doc = document.createElement('div');\n doc.innerHTML = html;\n\n // reference to the remote component content\n const component =\n doc.querySelector(`div[data-bundle][data-route][id^=\"${this.name}\"]`) ??\n // fallback to the first element with the data-bundle and data-route attributes when not using a named remote component\n doc.querySelector('div[data-bundle][data-route]') ??\n // fallback to Next.js Pages Router\n doc.querySelector('div#__next');\n const nextData = JSON.parse(\n (\n doc.querySelector('#__NEXT_DATA__') ??\n doc.querySelector('#__REMOTE_NEXT_DATA__')\n )?.textContent ?? 'null',\n ) as {\n props: {\n pageProps: Record<string, unknown>;\n __REMOTE_COMPONENT__?: {\n bundle: string;\n runtime: 'turbopack' | 'webpack';\n };\n };\n page: string;\n buildId: string;\n } | null;\n\n // when using a Next.js Pages Router remote application in development mode\n // we hide the remote component to prevent flickering\n // until the CSS is loaded for the remote component\n if (nextData && nextData.buildId === 'development') {\n this.fouc = document.createElement('style');\n this.fouc.textContent = `:host { display: none; }`;\n this.shadowRoot?.appendChild(this.fouc);\n }\n\n this.name =\n component?.getAttribute('id')?.replace(/_ssr$/, '') ||\n (nextData ? '__next' : this.name);\n // reference to the RSC flight data\n const rsc = doc.querySelector(`#${this.name}_rsc`);\n\n // reference to the bundle containing the client components\n this.bundle =\n component?.getAttribute('data-bundle') ||\n nextData?.props.__REMOTE_COMPONENT__?.bundle ||\n this.bundle;\n\n // add remote component metadata information at the custom element\n const metadata = document.createElement('script');\n metadata.type = 'application/json';\n metadata.setAttribute('data-remote-component', '');\n metadata.textContent = JSON.stringify({\n name: this.name,\n bundle: this.bundle,\n route: component?.getAttribute('data-route') ?? nextData?.page ?? '/',\n runtime:\n component?.getAttribute('data-runtime') ??\n nextData?.props.__REMOTE_COMPONENT__?.runtime,\n });\n this.parentNode?.insertBefore(metadata, this);\n\n const remoteSharedEl = doc.querySelector(`#${this.name}_shared`);\n const remoteShared = (JSON.parse(remoteSharedEl?.textContent ?? '{}') ??\n {}) as Record<string, string>;\n remoteSharedEl?.parentElement?.removeChild(remoteSharedEl);\n\n if (!component || !(rsc || nextData)) {\n throw new Error(`Failed to find component with id \"${this.name}\"`);\n }\n\n // store the original loading content of the custom element\n // this is required to remove the loading content after the remote component is loaded\n const removable = Array.from(this.childNodes);\n\n // reference to all link elements in the remote component\n const links = doc.querySelectorAll<HTMLLinkElement>('link[href]');\n\n // attach each link element to the shadow DOM to load the styles\n await Promise.all(\n Array.from(links).map((link) => {\n return new Promise<void>((resolve, reject) => {\n const newLink = document.createElement('link');\n newLink.onload = () => {\n resolve();\n };\n newLink.onerror = () => {\n reject(\n new Error(\n `Failed to load link ${link.href} for remote component`,\n ),\n );\n };\n for (const attr of link.attributes) {\n if (attr.name === 'href') {\n newLink.setAttribute(\n attr.name,\n new URL(attr.value, url ?? location.origin).href,\n );\n } else {\n newLink.setAttribute(attr.name, attr.value);\n }\n }\n this.shadowRoot?.appendChild(newLink);\n });\n }),\n );\n\n // attach the remote component content to the shadow DOM\n Array.from(component.children).forEach((el) => {\n this.shadowRoot?.appendChild(el);\n });\n\n // clear the loading content of the shadow DOM root\n for (const el of removable) {\n el.parentElement?.removeChild(el);\n }\n this.shadowRoot?.removeChild(this.fallbackSlot);\n\n const {\n self,\n createFromReadableStream,\n nextClientPagesLoader,\n preloadScripts,\n } = await getRuntime(\n (component.getAttribute('data-runtime') ?? 'webpack') as Runtime,\n url ?? new URL(location.href),\n this.bundle,\n {\n react: async () => (await import('react')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react-dom/client': async () =>\n (await import('react-dom/client')).default,\n },\n remoteShared,\n );\n\n const scripts = doc.querySelectorAll<HTMLScriptElement>(\n 'script[src],script[data-src]',\n );\n if (!url) {\n url = new URL(\n component.getAttribute('data-route') ?? '/',\n window.location.href,\n );\n }\n\n await preloadScripts(Array.from(scripts), url, this.bundle, this.name);\n\n // using RSC hydration if the RSC flight data is available\n if (rsc) {\n // remove the RSC flight data script element\n rsc.parentElement?.removeChild(rsc);\n\n // reload the RSC flight data script to eval it's content\n const rscClone = document.createElement('script');\n rscClone.id = `${this.name}_rsc`;\n rscClone.textContent = rsc.textContent;\n document.body.appendChild(rscClone);\n\n let cache: React.ReactNode;\n // React component to convert the RSC flight data into a React component\n const RemoteComponentFromReadableStream = ({\n name,\n }: {\n name: string;\n }) => {\n const Component =\n cache ??\n // cache the component to avoid reloading the RSC flight data\n (cache = createFromReadableStream(\n // convert the RSC flight data array into a ReadableStream\n new ReadableStream({\n type: 'bytes',\n start(controller) {\n const encoder = new TextEncoder();\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n (self[name] ?? [`0:[null]\\n`]).forEach((chunk) => {\n // encode the chunk to a byte buffer\n controller.enqueue(encoder.encode(chunk));\n });\n // close the stream when all chunks are enqueued\n controller.close();\n },\n }),\n ) as React.ReactNode);\n\n // React can handle the component reference and will wait for the component to be ready\n return Component;\n };\n\n // hydrate the remote component using the RSC flight data\n hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.shadowRoot,\n <RemoteComponentFromReadableStream name={this.name} />,\n );\n } else if (nextData) {\n // using Next.js client pages loader if the Next.js hydration data is available\n const { Component, App } = nextClientPagesLoader(\n this.bundle,\n nextData.page,\n this.shadowRoot,\n );\n\n // if we have the component, we can hydrate it\n if (Component) {\n hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.shadowRoot,\n App ? (\n <App Component={Component} {...nextData.props} />\n ) : (\n <Component {...nextData.props} />\n ),\n );\n }\n\n // remove the FOUC workaround style element to show the remote component\n // this is only for development mode\n if (this.fouc) {\n this.shadowRoot?.removeChild(this.fouc);\n }\n }\n\n this.isLoading = false;\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n","export type Runtime = 'webpack' | 'turbopack' | 'esm';\n\nexport async function getRuntime(\n type: Runtime,\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // minimally mock process.env for browser environments\n if (typeof globalThis.process === 'undefined') {\n globalThis.process = {\n env: {},\n } as NodeJS.Process;\n }\n\n if (type === 'webpack') {\n const { webpackRuntime } = await import(`./webpack`);\n return webpackRuntime();\n } else if (type === 'turbopack') {\n const { turbopackRuntime } = await import(`./turbopack`);\n return turbopackRuntime(url, bundle, shared, remoteShared);\n }\n throw new Error(`Runtime ${type} is not supported`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,SAAS,mBACd,QACA,SACA;AAEA,QAAM,OAAO;AAab,MAAI,KAAK,6BAA6B,MAAM,GAAG;AAC7C,UAAM,cAAc,OAAO;AAAA,MACzB,KAAK,gCAAgC,MAAM,KACzC,KAAK,2BAA2B,MAAM,EAAE,KACxC,CAAC;AAAA,IACL;AAEA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,YAAM,MAAM,YAAY,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC;AACrD,eAAS,MAAM,KAAK;AAClB,cAAM,gBAAgB,KAAK,2BAA2B,MAAM;AAC5D,YAAI,cAAc,GAAG;AAGnB,cAAI,KAAK,gCAAgC,MAAM,IAAI,EAAE,GAAG;AACtD,iBAAK,GAAG,KAAK,8BAA8B,MAAM,EAAE,EAAE;AAAA,UACvD;AAEA,wBAAc,EAAE,EAAE,IAAI,CAACA,YAAW;AAChC,YAAAA,QAAO,UAAU;AAAA,UACnB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAhDA;AAAA;AAAA;AAAA;AAAA;;;ACCO,SAAS,sBACd,QACA,OACA,iBAAsD,SAAS,MAC/D;AAEA,QAAM,OAAO;AAsDb,QAAM,kBAAkB,SAAS,eAAe,0BAA0B;AAC1E,MAAI,iBAAi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IAAI,YAAY;AAIhC,iBAAC,KAAK,IAAI,KAAK,CAAC;AAAA,CAAY,GAAG,QAAQ,CAAC,UAAU;AAEhD,6BAAW,QAAQ,QAAQ,OAAO,KAAK,CAAC;AAAA,gBAC1C,CAAC;AAED,2BAAW,MAAM;AAAA,cACnB;AAAA,YACF,CAAC;AAAA,UACH;AAGF,iBAAO;AAAA,QACT;AAGA;AAAA;AAAA;AAAA,UAGE,KAAK;AAAA,UACL,4CAAC,qCAAkC,MAAM,KAAK,MAAM;AAAA,QACtD;AAAA,MACF,WAAW,UAAU;AAEnB,cAAM,EAAE,WAAW,IAAI,IAAIA;AAAA,UACzB,KAAK;AAAA,UACL,SAAS;AAAA,UACT,KAAK;AAAA,QACP;AAGA,YAAI,WAAW;AACb;AAAA;AAAA;AAAA,YAGE,KAAK;AAAA,YACL,MACE,4CAAC,OAAI,WAAuB,GAAG,SAAS,OAAO,IAE/C,4CAAC,aAAW,GAAG,SAAS,OAAO;AAAA,UAEnC;AAAA,QACF;AAIA,YAAI,KAAK,MAAM;AACb,eAAK,YAAY,YAAY,KAAK,IAAI;AAAA,QACxC;AAAA,MACF;AAEA,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAGA,iBAAe,OAAO,oBAAoB,eAAe;AAC3D;","names":["module","resolve","module","webpackRuntime","turbopackRuntime","nextClientPagesLoader"]}
|
|
1
|
+
{"version":3,"sources":["../../src/shared/webpack/shared-modules.ts","../../src/shared/webpack/next-client-pages-loader.ts","../../src/html/runtime/webpack.ts","../../src/shared/client/const.ts","../../src/shared/client/webpack-adapter.ts","../../src/html/runtime/turbopack.ts","../../src/html/host.tsx","../../src/shared/client/rsc.ts","../../src/html/runtime/index.ts"],"sourcesContent":["// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\nexport function applySharedModules(\n bundle: string,\n resolve: Record<string, unknown>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // if we have the bundle\n if (self.__remote_webpack_require__?.[bundle]) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ??\n self.__remote_webpack_require__[bundle].m ??\n {},\n );\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n const ids = modulePaths.filter((p) => p.includes(key));\n for (let id of ids) {\n const webpackBundle = self.__remote_webpack_require__[bundle];\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {\n id = `${self.__remote_webpack_module_map__[bundle][id]}`;\n }\n // create a mock module which exports the shared module\n webpackBundle.m[id] = (module) => {\n module.exports = value;\n };\n }\n }\n }\n }\n}\n","// module loader for Next.js Pages Router\nexport function nextClientPagesLoader(\n bundle: string,\n route: string,\n styleContainer: HTMLHeadElement | ShadowRoot | null = document.head,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string | number) => unknown) & {\n c?: Record<\n string | number,\n { id: string; parents: string[]; children: string[] }\n >;\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n type?: 'turbopack' | 'webpack';\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // Next.js client pages loader reference storage\n __NEXT_P?: [\n (\n | [\n string,\n () => { default?: React.ComponentType<Record<string, unknown>> },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n ];\n };\n\n // temporarily remove the original Next.js CSS loader\n const nextCssOriginal = document.getElementById('__next_css__DO_NOT_USE__');\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.removeChild(nextCssOriginal);\n }\n\n // create a new Next.js CSS loader element\n const nextCss = document.createElement('noscript');\n nextCss.id = '__next_css__DO_NOT_USE__';\n const lastNode =\n document.head.childNodes[document.head.childNodes.length - 1];\n document.head.appendChild(nextCss);\n\n // find the page component loader chunk\n const componentLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // find the app loader chunk\n const appLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // if we didn't find the component loader or app loader, throw an error\n if (!(componentLoaderChunk && appLoaderChunk)) {\n throw new Error(\n `Next.js client pages loader not found in bundle \"${bundle}\"`,\n );\n }\n\n // temporarily store the original __NEXT_P reference\n // this is required to avoid conflicts with the Next.js client pages loader\n // which uses the same global variable to store the page components\n const __NEXT_P_ORIGINAL = self.__NEXT_P;\n const selfOriginal = self;\n delete selfOriginal.__NEXT_P;\n\n // load the component and app loader chunks\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? componentLoaderChunk\n : `[${bundle}] ${componentLoaderChunk}`,\n );\n if (\n typeof appLoaderChunk === 'string' ||\n (typeof appLoaderChunk === 'number' && appLoaderChunk !== -1)\n ) {\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? appLoaderChunk\n : `[${bundle}] ${appLoaderChunk}`,\n );\n }\n\n // if we have the __NEXT_P global variable, we can extract the component and app\n if (self.__NEXT_P) {\n const [, componentLoader] = self.__NEXT_P[0] ?? [\n undefined,\n () => ({ default: null }),\n ];\n const [, appLoader] = self.__NEXT_P[2] ?? [\n undefined,\n () => ({\n default: null,\n }),\n ];\n const { default: Component } = componentLoader();\n const { default: App } = appLoader();\n\n // load the CSS files from the remote bundle\n const cssRE = /\\.s?css$/;\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {})\n .filter((id) => cssRE.test(id))\n .forEach((id) => {\n self.__remote_webpack_require__?.[bundle]?.(id);\n });\n\n Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {})\n .filter((path) => cssRE.test(path))\n .forEach((path) => {\n const id = self.__remote_webpack_module_map__?.[bundle]?.[path];\n if (id) {\n self.__remote_webpack_require__?.[bundle]?.(id);\n }\n });\n\n // if the styleContainer is provided, we need to move the styles to it\n if (styleContainer) {\n let node = nextCss.previousSibling;\n while (node && node !== lastNode) {\n styleContainer.appendChild(node);\n node = nextCss.previousSibling;\n }\n }\n\n // restore the original __NEXT_P reference\n delete self.__NEXT_P;\n self.__NEXT_P = __NEXT_P_ORIGINAL;\n\n // restore the original Next.js CSS loader\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.appendChild(nextCssOriginal);\n }\n\n return { Component, App };\n }\n\n return { Component: null, App: null };\n}\n","import { applySharedModules } from '../../shared/webpack/shared-modules';\nimport { nextClientPagesLoader } from '../../shared/webpack/next-client-pages-loader';\n\n// initializer for the webpack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function webpackRuntime() {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__: boolean;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __webpack_require_type__: 'webpack' | 'turbopack';\n } & Record<string, string[]>;\n\n // disable webpack exec to prevent automatically executing the entry module\n self.__DISABLE_WEBPACK_EXEC__ = true;\n // add a custom webpack require function to load remote components from multiple bundles / zones\n if (\n typeof self.__webpack_require__ !== 'function' &&\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n self.__webpack_require__ = (remoteId: string) => {\n const re = /\\[(?<bundle>[a-zA-Z0-9-_]+)\\] (?<id>.*)/;\n const match = re.exec(remoteId);\n const bundle = match?.groups?.bundle;\n const id = match?.groups?.id;\n if (!(id && bundle)) {\n throw new Error(`Module not found: \"${remoteId}\"`);\n }\n if (typeof self.__remote_webpack_require__?.[bundle] !== 'function') {\n throw new Error(`Remote component loading error \"${bundle}\"`);\n }\n return self.__remote_webpack_require__[bundle](id);\n };\n // not used but required by react-server-dom-webpack\n self.__webpack_chunk_load__ = () => {\n return Promise.resolve([]);\n };\n }\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n async function preloadScripts(\n scripts: HTMLScriptElement[],\n url: URL,\n bundle: string,\n _: string,\n ) {\n // we need to properly attach script elements to the document to load the remote component bundles\n // we need to wait for all scripts to load before we can hydrate the remote component\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newScript = document.createElement('script');\n newScript.onload = () => {\n resolve();\n };\n newScript.onerror = () => {\n reject(\n new Error(\n `Failed to load script ${script.src} for remote component`,\n ),\n );\n };\n const scriptSrc =\n script.getAttribute('src') || script.getAttribute('data-src');\n if (scriptSrc) {\n newScript.src = new URL(\n scriptSrc.replace(/\\/_next\\/\\[(?:.+)\\](?:%20| )/, '/_next/'),\n url,\n ).href;\n }\n newScript.async = true;\n document.body.appendChild(newScript);\n // safe to remove the original script element\n script.parentElement?.removeChild(script);\n });\n }),\n );\n\n // module resolution map for the shared modules\n const resolve = {\n '/react/index.js': (await import('react')).default,\n '/react/jsx-dev-runtime.js': (await import('react/jsx-dev-runtime'))\n .default,\n '/react/jsx-runtime.js': (await import('react/jsx-runtime')).default,\n '/react-dom/index.js': (await import('react-dom')).default,\n '/react-dom/client.js': (await import('react-dom/client')).default,\n };\n\n // apply shared modules to the bundle\n applySharedModules(bundle, resolve);\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","export const DEFAULT_ROUTE = '/';\n\nexport const RUNTIME_WEBPACK = 'webpack';\nexport const RUNTIME_TURBOPACK = 'turbopack';\n\nexport const REMOTE_COMPONENT_REGEX =\n /(?<prefix>.*?)\\[(?<bundle>[^\\]]+)\\](?:%20| )(?<id>.+)/;\n\nexport function getBundleKey(bundle: string): string {\n return bundle.replace(/-/g, '_');\n}\n\nexport type Runtime = typeof RUNTIME_WEBPACK | typeof RUNTIME_TURBOPACK;\n","import type { GlobalScope } from './types';\nimport {\n type Runtime,\n RUNTIME_TURBOPACK,\n RUNTIME_WEBPACK,\n REMOTE_COMPONENT_REGEX,\n getBundleKey,\n} from './const';\n\n/**\n * Sets up webpack runtime environment for remote components\n */\nexport async function setupWebpackRuntime(\n runtime: Runtime,\n scripts: { src: string | null }[] = [],\n url: URL = new URL(location.href),\n bundle?: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n): Promise<void> {\n const self = globalThis as GlobalScope;\n\n if (!self.__remote_bundle_url__) {\n // eslint-disable-next-line camelcase\n self.__remote_bundle_url__ = {};\n }\n self.__remote_bundle_url__[bundle ?? 'default'] = url;\n\n await initializeSharedModules(bundle ?? 'default', shared, remoteShared);\n if (\n typeof self.__webpack_require__ !== 'function' ||\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n if (\n !self.__original_webpack_require__ &&\n !self.__original_webpack_chunk_load__\n ) {\n // eslint-disable-next-line camelcase\n self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;\n // eslint-disable-next-line camelcase\n self.__original_webpack_require__ = self.__webpack_require__;\n }\n\n self.__webpack_chunk_load__ = createChunkLoader(runtime);\n self.__webpack_require__ = createModuleRequire(runtime);\n // eslint-disable-next-line camelcase\n self.__webpack_require_type__ = runtime;\n\n if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {\n const remoteBundle = bundle ?? 'default';\n self.__remote_webpack_require__[remoteBundle] =\n self.__webpack_require__ as (remoteId: string | number) => unknown;\n self.__remote_webpack_require__[remoteBundle].type = 'turbopack';\n }\n }\n if (runtime === RUNTIME_TURBOPACK) {\n await Promise.all(\n scripts.map((script) => {\n if (script.src) {\n return self.__webpack_chunk_load__?.(script.src, bundle);\n }\n return Promise.resolve(undefined);\n }),\n );\n }\n}\n\n/**\n * Creates chunk loader function for webpack runtime\n */\nfunction createChunkLoader(\n runtime: Runtime,\n): (chunkId: string) => Promise<unknown> | undefined {\n // eslint-disable-next-line camelcase\n return function __turbopack_chunk_load__(\n chunkId: string,\n scriptBundle?: string,\n ) {\n const self = globalThis as GlobalScope;\n const {\n bundle,\n id: path,\n prefix,\n } = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {\n bundle: scriptBundle ?? '',\n id: chunkId,\n };\n const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? 'default']\n ? self.__remote_webpack_require__[bundle ?? 'default']?.type || 'webpack'\n : runtime;\n if (remoteRuntime === RUNTIME_WEBPACK) {\n // all scripts are already loaded for this remote\n return Promise.resolve(undefined);\n }\n\n const url = new URL(\n path\n ? `${prefix ?? ''}${path}`.replace(\n /(?<char>[^:])(?<double>\\/\\/)/g,\n '$1/',\n )\n : '/',\n self.__remote_bundle_url__?.[bundle ?? 'default'] ??\n new URL(location.origin),\n ).href;\n if (url.endsWith('.css')) {\n return;\n }\n return new Promise((resolve, reject) => {\n fetch(url)\n .then((res) => res.text())\n .then((code) => {\n if (code.includes('globalThis.TURBOPACK')) {\n return handleTurbopackChunk(code, bundle ?? '', url);\n }\n })\n .then(resolve)\n .catch(reject);\n });\n };\n}\n\n/**\n * Handles Turbopack chunk loading\n */\nasync function handleTurbopackChunk(\n code: string,\n bundle: string,\n url: string,\n): Promise<void> {\n // skip this chunk as it is not needed for remote components\n if (\n code.includes('/next/dist/client/app-next-turbopack.js') &&\n code.includes('importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS')\n ) {\n // remove preload links for this chunk\n const preloadLinks = document.querySelectorAll(\n `link[rel=\"preload\"][href=\"${new URL(url).pathname}\"]`,\n );\n preloadLinks.forEach((preloadLink) => preloadLink.remove());\n return;\n }\n\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n\n // replace global variables with bundle-specific ones\n const transformedCode = code\n .replace(/globalThis\\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`)\n .replace(\n /TURBOPACK_WORKER_LOCATION/g,\n `TURBOPACK_WORKER_LOCATION_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_NEXT_CHUNK_URLS/g,\n `TURBOPACK_NEXT_CHUNK_URLS_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,\n `TURBOPACK_CHUNK_UPDATE_LISTENERS_${bundleKey}`,\n )\n .replace(/__next_require__/g, `__${bundleKey}_next_require__`)\n .replace(\n /\\/\\/# sourceMappingURL=(?<name>.+)(?<optional>\\._)?\\.js\\.map/g,\n `//# sourceMappingURL=${\n new URL(\n '.',\n new URL(\n url,\n self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin),\n ),\n ).href\n }$1$2.js.map`,\n );\n\n // load the script dynamically using a Blob URL\n await new Promise<void>((scriptResolve, scriptReject) => {\n const blob = new Blob([transformedCode], {\n type: 'application/javascript; charset=UTF-8',\n });\n const scriptUrl = URL.createObjectURL(blob);\n const script = document.createElement('script');\n script.src = scriptUrl;\n script.async = true;\n script.onload = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptResolve(undefined);\n };\n script.onerror = (error) => {\n URL.revokeObjectURL(scriptUrl);\n scriptReject(\n new Error(\n `Failed to load script: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n };\n document.head.appendChild(script);\n });\n const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`] as\n | { chunks: string[] }[]\n | undefined;\n const loadChunkLists = [] as (Promise<unknown> | undefined)[];\n while (chunkLists?.length) {\n const { chunks } = chunkLists.shift() ?? { chunks: [] };\n if (chunks.length > 0) {\n chunks.forEach((id: string) => {\n const chunkLoadResult = self.__webpack_chunk_load__?.(\n `[${bundle}] ${url.slice(0, url.indexOf('/_next'))}/_next/${id}`,\n );\n if (chunkLoadResult) {\n loadChunkLists.push(chunkLoadResult);\n }\n });\n }\n }\n if (loadChunkLists.length > 0) {\n await Promise.all(loadChunkLists);\n }\n}\n\n/**\n * Creates module require function for webpack runtime\n */\nfunction createModuleRequire(runtime: Runtime): (id: string) => unknown {\n return (id: string) => {\n const self = globalThis as GlobalScope;\n const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)\n ?.groups ?? { bundle: 'default', id };\n const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? 'default']\n ? self.__remote_webpack_require__[bundle ?? 'default']?.type || 'webpack'\n : runtime;\n try {\n if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {\n return self.__remote_webpack_require__?.[bundle]?.(moduleId);\n }\n const sharedModule = getSharedModule(bundle ?? 'default', moduleId ?? id);\n if (sharedModule) {\n return sharedModule;\n }\n if (bundle && moduleId) {\n return handleTurbopackModule(bundle, moduleId, id);\n }\n throw new Error(`Module ${id} not found`);\n } catch {\n try {\n return self.__original_webpack_require__?.(id);\n } catch {\n throw new Error(\n `Module ${id} not found in remote component bundle ${bundle}`,\n );\n }\n }\n };\n}\n\nfunction initializeSharedModules(\n bundle: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n) {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, Record<string, unknown>>;\n __next_f?: unknown[];\n };\n // eslint-disable-next-line camelcase\n self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};\n\n if (!self.__remote_shared_modules__[bundle]) {\n self.__remote_shared_modules__[bundle] = {};\n }\n\n // ensure that the shared modules are initialized\n return Promise.all(\n Object.entries(remoteShared).map(async ([id, module]) => {\n if (self.__remote_shared_modules__?.[bundle]) {\n self.__remote_shared_modules__[bundle][\n id.replace('[app-ssr]', '[app-client]')\n ] = await (\n shared[module] ??\n (() =>\n Promise.resolve(\n new Proxy(\n {},\n {\n get(_, prop: string) {\n if (prop !== 'then') {\n // eslint-disable-next-line no-console\n console.warn(\n `Shared dependency \"${module}\" not found for \"${bundle}\" when trying to import \"${prop}\".`,\n );\n }\n },\n },\n ),\n ))\n )();\n }\n }),\n );\n}\n\n/**\n * Returns shared modules for common dependencies\n */\nfunction getSharedModule(bundle: string, id: string): unknown {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, unknown>;\n };\n\n for (const [key, value] of Object.entries(\n self.__remote_shared_modules__?.[bundle] ?? {},\n )) {\n if (id.includes(key)) {\n return value;\n }\n }\n return null;\n}\n\n/**\n * Handles Turbopack module resolution\n */\nfunction handleTurbopackModule(\n bundle: string,\n moduleId: string,\n id: string,\n): unknown {\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n const modules = (\n self[`TURBOPACK_${bundleKey}`] as\n | [unknown, Record<string, unknown>][]\n | undefined\n )?.find((mod: [unknown, Record<string, unknown>]) => moduleId in mod[1])?.[1];\n const moduleInit = modules?.[moduleId];\n if (typeof moduleInit !== 'function') {\n throw new Error(\n `Module ${id} not found in bundle ${bundle} with id ${moduleId}`,\n );\n }\n const exports = {} as Record<string, unknown>;\n moduleInit({\n // HMR not implemented for Remote Components\n k: {\n register() {\n // omit\n },\n registerExports() {\n // omit\n },\n signature() {\n return () => {\n // omit\n };\n },\n },\n s(m: Record<string, () => unknown>) {\n for (const [key, value] of Object.entries(m)) {\n exports[key] = value;\n }\n },\n i(iid: string) {\n return self.__webpack_require__?.(`[${bundle}] ${iid}`);\n },\n r(rid: string) {\n return self.__webpack_require__?.(`[${bundle}] ${rid}`);\n },\n m: {\n exports,\n },\n });\n for (const [key, value] of Object.entries(exports)) {\n if (typeof value === 'function') {\n exports[key] = value();\n }\n }\n return exports;\n}\n","import { applySharedModules } from '../../shared/webpack/shared-modules';\nimport { nextClientPagesLoader } from '../../shared/webpack/next-client-pages-loader';\nimport { setupWebpackRuntime } from '../../shared/client/webpack-adapter';\n\n// initializer for the turbopack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function turbopackRuntime(\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__: boolean;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __remote_component_shared__?: Record<string, () => Promise<unknown>>;\n } & Record<string, string[]>;\n\n await setupWebpackRuntime(\n 'turbopack',\n [],\n url,\n bundle,\n self.__remote_component_shared__ ?? shared,\n remoteShared,\n );\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n function preloadScripts(scripts: HTMLScriptElement[], __: URL) {\n return setupWebpackRuntime(\n 'turbopack',\n scripts.map((script) => ({\n src:\n script.getAttribute('src') ||\n script.getAttribute('data-src') ||\n script.src,\n })),\n url,\n bundle,\n self.__remote_component_shared__ ?? shared,\n remoteShared,\n );\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","import { hydrateRoot } from 'react-dom/client';\nimport { createRSCStream } from '../shared/client/rsc';\nimport { getRuntime, type Runtime } from './runtime';\n\nif (typeof HTMLElement !== 'undefined') {\n class RemoteComponent extends HTMLElement {\n name: string;\n bundle: string;\n fallbackSlot: HTMLSlotElement;\n __next: HTMLDivElement | null = null;\n fouc: HTMLStyleElement | null = null;\n isLoading = false;\n\n constructor() {\n super();\n // use the shadow DOM to encapsulate the component\n this.attachShadow({ mode: 'open' });\n\n // create a slot element to allow the remote component to use the default slot\n this.fallbackSlot = document.createElement('slot');\n this.shadowRoot?.appendChild(this.fallbackSlot);\n\n this.name = this.getAttribute('name') || '__vercel_remote_component';\n this.bundle = 'default';\n\n // load when the custom element has an src, data-ssr attribute or contains an SSR remote component div\n if (\n this.hasAttribute('src') ||\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.hasAttribute('data-ssr')\n ) {\n // start loading and hydration\n this.load().catch((e) => {\n throw new Error(`Failed to load remote component: ${e}`);\n });\n }\n }\n\n static get observedAttributes() {\n return ['src'];\n }\n\n // watch for src attribute changes\n // this is required to reload the remote component when the src attribute is added later\n // this is for rendering the custom element using React\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (name === 'src' && oldValue !== newValue) {\n this.load().catch((e) => {\n throw new Error(`Failed to load remote component: ${e}`);\n });\n }\n }\n\n async load() {\n // prevent multiple loads\n if (this.isLoading) {\n return;\n }\n\n this.isLoading = true;\n const src = this.getAttribute('src');\n const remoteComponentChild = this.querySelector(\n 'div#__REMOTE_COMPONENT__',\n );\n\n if (!src && !remoteComponentChild) {\n throw new Error('src attribute is required');\n }\n\n let url: URL | null = null;\n let html = this.innerHTML;\n\n if (!remoteComponentChild && src) {\n url = new URL(src, window.location.href);\n\n // fetch the remote component\n const fetchInit = {\n method: 'GET',\n headers: {\n Accept: 'text/html',\n // pass the public address of the remote component to the server used for module map mutation\n 'Vercel-Remote-Component-Url': url.href,\n },\n credentials: this.getAttribute('credentials') || 'same-origin',\n } as RequestInit;\n\n const res = await fetch(url, fetchInit);\n\n if (!res.ok) {\n throw new Error(\n `Failed to fetch remote component \"${this.name}\": ${res.status}`,\n );\n }\n\n // get the full HTML content as a string\n html = await res.text();\n }\n // create a virtual element which will be used to parse the HTML and extract the component and RSC flight data\n const doc = document.createElement('div');\n doc.innerHTML = html;\n\n // reference to the remote component content\n const component =\n doc.querySelector(`div[data-bundle][data-route][id^=\"${this.name}\"]`) ??\n // fallback to the first element with the data-bundle and data-route attributes when not using a named remote component\n doc.querySelector('div[data-bundle][data-route]') ??\n // fallback to Next.js Pages Router\n doc.querySelector('div#__next');\n const nextData = JSON.parse(\n (\n doc.querySelector('#__NEXT_DATA__') ??\n doc.querySelector('#__REMOTE_NEXT_DATA__')\n )?.textContent ?? 'null',\n ) as {\n props: {\n pageProps: Record<string, unknown>;\n __REMOTE_COMPONENT__?: {\n bundle: string;\n runtime: 'turbopack' | 'webpack';\n };\n };\n page: string;\n buildId: string;\n } | null;\n\n // when using a Next.js Pages Router remote application in development mode\n // we hide the remote component to prevent flickering\n // until the CSS is loaded for the remote component\n if (nextData && nextData.buildId === 'development') {\n this.fouc = document.createElement('style');\n this.fouc.textContent = `:host { display: none; }`;\n this.shadowRoot?.appendChild(this.fouc);\n }\n\n this.name =\n component?.getAttribute('id')?.replace(/_ssr$/, '') ||\n (nextData ? '__next' : this.name);\n // reference to the RSC flight data\n const rsc = doc.querySelector(`#${this.name}_rsc`);\n\n // reference to the bundle containing the client components\n this.bundle =\n component?.getAttribute('data-bundle') ||\n nextData?.props.__REMOTE_COMPONENT__?.bundle ||\n this.bundle;\n\n // add remote component metadata information at the custom element\n const metadata = document.createElement('script');\n metadata.type = 'application/json';\n metadata.setAttribute('data-remote-component', '');\n metadata.textContent = JSON.stringify({\n name: this.name,\n bundle: this.bundle,\n route: component?.getAttribute('data-route') ?? nextData?.page ?? '/',\n runtime:\n component?.getAttribute('data-runtime') ??\n nextData?.props.__REMOTE_COMPONENT__?.runtime,\n });\n this.parentNode?.insertBefore(metadata, this);\n\n const remoteSharedEl = doc.querySelector(`#${this.name}_shared`);\n const remoteShared = (JSON.parse(remoteSharedEl?.textContent ?? '{}') ??\n {}) as Record<string, string>;\n remoteSharedEl?.parentElement?.removeChild(remoteSharedEl);\n\n if (!component || !(rsc || nextData)) {\n throw new Error(`Failed to find component with id \"${this.name}\"`);\n }\n\n // store the original loading content of the custom element\n // this is required to remove the loading content after the remote component is loaded\n const removable = Array.from(this.childNodes);\n\n // reference to all link elements in the remote component\n const links = doc.querySelectorAll<HTMLLinkElement>('link[href]');\n\n // attach each link element to the shadow DOM to load the styles\n await Promise.all(\n Array.from(links).map((link) => {\n return new Promise<void>((resolve, reject) => {\n const newLink = document.createElement('link');\n newLink.onload = () => {\n resolve();\n };\n newLink.onerror = () => {\n reject(\n new Error(\n `Failed to load link ${link.href} for remote component`,\n ),\n );\n };\n for (const attr of link.attributes) {\n if (attr.name === 'href') {\n newLink.setAttribute(\n attr.name,\n new URL(attr.value, url ?? location.origin).href,\n );\n } else {\n newLink.setAttribute(attr.name, attr.value);\n }\n }\n this.shadowRoot?.appendChild(newLink);\n });\n }),\n );\n\n // attach the remote component content to the shadow DOM\n Array.from(component.children).forEach((el) => {\n this.shadowRoot?.appendChild(el);\n });\n\n // clear the loading content of the shadow DOM root\n for (const el of removable) {\n el.parentElement?.removeChild(el);\n }\n this.shadowRoot?.removeChild(this.fallbackSlot);\n\n const {\n self,\n createFromReadableStream,\n nextClientPagesLoader,\n preloadScripts,\n } = await getRuntime(\n (component.getAttribute('data-runtime') ?? 'webpack') as Runtime,\n url ?? new URL(location.href),\n this.bundle,\n {\n react: async () => (await import('react')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react-dom/client': async () =>\n (await import('react-dom/client')).default,\n },\n remoteShared,\n );\n\n const scripts = doc.querySelectorAll<HTMLScriptElement>(\n 'script[src],script[data-src]',\n );\n if (!url) {\n url = new URL(\n component.getAttribute('data-route') ?? '/',\n window.location.href,\n );\n }\n\n await preloadScripts(Array.from(scripts), url, this.bundle, this.name);\n\n // using RSC hydration if the RSC flight data is available\n if (rsc) {\n // remove the RSC flight data script element\n rsc.parentElement?.removeChild(rsc);\n\n // reload the RSC flight data script to eval it's content\n const rscClone = document.createElement('script');\n rscClone.id = `${this.name}_rsc`;\n rscClone.textContent = rsc.textContent;\n document.body.appendChild(rscClone);\n\n let cache: React.ReactNode;\n // React component to convert the RSC flight data into a React component\n const RemoteComponentFromReadableStream = ({\n name,\n }: {\n name: string;\n }) => {\n // convert the RSC flight data array into a ReadableStream\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n const stream = createRSCStream(name, self[name] ?? [`0:[null]\\n`]);\n const Component =\n cache ??\n // cache the component to avoid reloading the RSC flight data\n (cache = createFromReadableStream(stream) as React.ReactNode);\n\n // React can handle the component reference and will wait for the component to be ready\n return Component;\n };\n\n // hydrate the remote component using the RSC flight data\n hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.shadowRoot,\n <RemoteComponentFromReadableStream name={this.name} />,\n );\n } else if (nextData) {\n // using Next.js client pages loader if the Next.js hydration data is available\n const { Component, App } = nextClientPagesLoader(\n this.bundle,\n nextData.page,\n this.shadowRoot,\n );\n\n // if we have the component, we can hydrate it\n if (Component) {\n hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.shadowRoot,\n App ? (\n <App Component={Component} {...nextData.props} />\n ) : (\n <Component {...nextData.props} />\n ),\n );\n }\n\n // remove the FOUC workaround style element to show the remote component\n // this is only for development mode\n if (this.fouc) {\n this.shadowRoot?.removeChild(this.fouc);\n }\n }\n\n this.isLoading = false;\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n","/**\n * Fixes RSC payload to make it compatible with React JSX development runtime\n */\nexport function fixPayload(payload: unknown): void {\n if (Array.isArray(payload)) {\n // if the current node is a React element, we need to fix the payload\n if (payload[0] === '$') {\n // fix the props (children or other React elements)\n fixPayload(payload[3]);\n if (payload.length === 4) {\n // add placeholder for the missing debug info\n payload.push(null, null, 1);\n }\n } else {\n // we are in an array, continue with visiting each item\n for (const item of payload) {\n fixPayload(item);\n }\n }\n } else if (typeof payload === 'object' && payload !== null) {\n // we are in an object, continue with visiting each property\n for (const key in payload) {\n fixPayload((payload as Record<string, unknown>)[key]);\n }\n }\n}\n\n/**\n * Processes RSC flight data and creates a ReadableStream\n */\nexport function createRSCStream(\n name: string,\n data: string[],\n): ReadableStream<Uint8Array> {\n return new ReadableStream({\n type: 'bytes',\n start(controller) {\n const encoder = new TextEncoder();\n const self = globalThis as typeof globalThis & Record<string, string[]>;\n\n // when the remote component RSC scripts are not found or loaded\n // we need to load the RSC flight data parsing the chunks\n if (!self[name] && data.length > 0) {\n data.forEach((chunk) => {\n const lines = chunk.split('\\n');\n for (const line of lines) {\n const match = /\\.push\\(\"(?<rsc>.*)\"\\);$/.exec(line);\n if (match?.groups?.rsc) {\n self[name] = self[name] ?? [];\n self[name].push(JSON.parse(`\"${match.groups.rsc}\"`) as string);\n }\n }\n });\n }\n\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n const allChunks = (self[name] ?? [`0:[null]\\n`]).join('');\n\n // process each line in the RSC flight data\n allChunks.split('\\n').forEach((chunk) => {\n if (chunk.length > 0) {\n // parse the chunk to get the id, prefix and payload\n const { id, prefix, payload } =\n /(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\\[.*\\])/.exec(\n chunk,\n )?.groups ?? {};\n\n if (payload) {\n // parse the payload to a JSON object\n const jsonPayload = JSON.parse(payload) as unknown[];\n // fix the payload to make it compatible with React JSX development runtime\n fixPayload(jsonPayload);\n // reconstruct the chunk to a string\n const reconstruct = `${id}:${prefix ?? ''}${JSON.stringify(jsonPayload)}`;\n // encode the chunk to a byte buffer\n controller.enqueue(encoder.encode(`${reconstruct}\\n`));\n } else {\n // add empty line before closing the stream\n controller.enqueue(encoder.encode(`${chunk}\\n`));\n }\n } else {\n // add empty line before closing the stream\n controller.enqueue(encoder.encode(`${chunk}\\n`));\n }\n });\n // close the stream when all chunks are enqueued\n controller.close();\n },\n });\n}\n","export type Runtime = 'webpack' | 'turbopack' | 'esm';\n\nexport async function getRuntime(\n type: Runtime,\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // minimally mock process.env for browser environments\n if (typeof globalThis.process === 'undefined') {\n globalThis.process = {\n env: {},\n } as NodeJS.Process;\n }\n\n if (type === 'webpack') {\n const { webpackRuntime } = await import(`./webpack`);\n return webpackRuntime();\n } else if (type === 'turbopack') {\n const { turbopackRuntime } = await import(`./turbopack`);\n return turbopackRuntime(url, bundle, shared, remoteShared);\n }\n throw new Error(`Runtime ${type} is not supported`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,SAAS,mBACd,QACA,SACA;AAEA,QAAM,OAAO;AAab,MAAI,KAAK,6BAA6B,MAAM,GAAG;AAC7C,UAAM,cAAc,OAAO;AAAA,MACzB,KAAK,gCAAgC,MAAM,KACzC,KAAK,2BAA2B,MAAM,EAAE,KACxC,CAAC;AAAA,IACL;AAEA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,YAAM,MAAM,YAAY,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC;AACrD,eAAS,MAAM,KAAK;AAClB,cAAM,gBAAgB,KAAK,2BAA2B,MAAM;AAC5D,YAAI,cAAc,GAAG;AAGnB,cAAI,KAAK,gCAAgC,MAAM,IAAI,EAAE,GAAG;AACtD,iBAAK,GAAG,KAAK,8BAA8B,MAAM,EAAE,EAAE;AAAA,UACvD;AAEA,wBAAc,EAAE,EAAE,IAAI,CAACA,YAAW;AAChC,YAAAA,QAAO,UAAU;AAAA,UACnB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAhDA;AAAA;AAAA;AAAA;AAAA;;;ACCO,SAAS,sBACd,QACA,OACA,iBAAsD,SAAS,MAC/D;AAEA,QAAM,OAAO;AAsDb,QAAM,kBAAkB,SAAS,eAAe,0BAA0B;AAC1E,MAAI,iBAAiB;AACnB,oBAAgB,Y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["module","resolve","module","webpackRuntime","turbopackRuntime","nextClientPagesLoader"]}
|
package/dist/html/host.js
CHANGED
|
@@ -226,7 +226,6 @@ var init_const = __esm({
|
|
|
226
226
|
// src/shared/client/webpack-adapter.ts
|
|
227
227
|
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}) {
|
|
228
228
|
const self = globalThis;
|
|
229
|
-
self.__DISABLE_WEBPACK_EXEC__ = true;
|
|
230
229
|
if (!self.__remote_bundle_url__) {
|
|
231
230
|
self.__remote_bundle_url__ = {};
|
|
232
231
|
}
|
|
@@ -246,20 +245,20 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
246
245
|
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
247
246
|
}
|
|
248
247
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
248
|
+
if (runtime === RUNTIME_TURBOPACK) {
|
|
249
|
+
await Promise.all(
|
|
250
|
+
scripts.map((script) => {
|
|
251
|
+
if (script.src) {
|
|
252
|
+
return self.__webpack_chunk_load__?.(script.src, bundle);
|
|
253
|
+
}
|
|
254
|
+
return Promise.resolve(void 0);
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
}
|
|
257
258
|
}
|
|
258
259
|
function createChunkLoader(runtime) {
|
|
259
260
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
260
|
-
|
|
261
|
-
return Promise.resolve(void 0);
|
|
262
|
-
}
|
|
261
|
+
const self = globalThis;
|
|
263
262
|
const {
|
|
264
263
|
bundle,
|
|
265
264
|
id: path,
|
|
@@ -268,7 +267,10 @@ function createChunkLoader(runtime) {
|
|
|
268
267
|
bundle: scriptBundle ?? "",
|
|
269
268
|
id: chunkId
|
|
270
269
|
};
|
|
271
|
-
const
|
|
270
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
271
|
+
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
272
|
+
return Promise.resolve(void 0);
|
|
273
|
+
}
|
|
272
274
|
const url = new URL(
|
|
273
275
|
path ? `${prefix ?? ""}${path}`.replace(
|
|
274
276
|
/(?<char>[^:])(?<double>\/\/)/g,
|
|
@@ -362,8 +364,9 @@ function createModuleRequire(runtime) {
|
|
|
362
364
|
return (id) => {
|
|
363
365
|
const self = globalThis;
|
|
364
366
|
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? { bundle: "default", id };
|
|
367
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
365
368
|
try {
|
|
366
|
-
if (
|
|
369
|
+
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
367
370
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
368
371
|
}
|
|
369
372
|
const sharedModule = getSharedModule(bundle ?? "default", moduleId ?? id);
|
|
@@ -525,6 +528,70 @@ var init_turbopack = __esm({
|
|
|
525
528
|
// src/html/host.tsx
|
|
526
529
|
import { hydrateRoot } from "react-dom/client";
|
|
527
530
|
|
|
531
|
+
// src/shared/client/rsc.ts
|
|
532
|
+
function fixPayload(payload) {
|
|
533
|
+
if (Array.isArray(payload)) {
|
|
534
|
+
if (payload[0] === "$") {
|
|
535
|
+
fixPayload(payload[3]);
|
|
536
|
+
if (payload.length === 4) {
|
|
537
|
+
payload.push(null, null, 1);
|
|
538
|
+
}
|
|
539
|
+
} else {
|
|
540
|
+
for (const item of payload) {
|
|
541
|
+
fixPayload(item);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
} else if (typeof payload === "object" && payload !== null) {
|
|
545
|
+
for (const key in payload) {
|
|
546
|
+
fixPayload(payload[key]);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function createRSCStream(name, data) {
|
|
551
|
+
return new ReadableStream({
|
|
552
|
+
type: "bytes",
|
|
553
|
+
start(controller) {
|
|
554
|
+
const encoder = new TextEncoder();
|
|
555
|
+
const self = globalThis;
|
|
556
|
+
if (!self[name] && data.length > 0) {
|
|
557
|
+
data.forEach((chunk) => {
|
|
558
|
+
const lines = chunk.split("\n");
|
|
559
|
+
for (const line of lines) {
|
|
560
|
+
const match = /\.push\("(?<rsc>.*)"\);$/.exec(line);
|
|
561
|
+
if (match?.groups?.rsc) {
|
|
562
|
+
self[name] = self[name] ?? [];
|
|
563
|
+
self[name].push(JSON.parse(`"${match.groups.rsc}"`));
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
const allChunks = (self[name] ?? [`0:[null]
|
|
569
|
+
`]).join("");
|
|
570
|
+
allChunks.split("\n").forEach((chunk) => {
|
|
571
|
+
if (chunk.length > 0) {
|
|
572
|
+
const { id, prefix, payload } = /(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\[.*\])/.exec(
|
|
573
|
+
chunk
|
|
574
|
+
)?.groups ?? {};
|
|
575
|
+
if (payload) {
|
|
576
|
+
const jsonPayload = JSON.parse(payload);
|
|
577
|
+
fixPayload(jsonPayload);
|
|
578
|
+
const reconstruct = `${id}:${prefix ?? ""}${JSON.stringify(jsonPayload)}`;
|
|
579
|
+
controller.enqueue(encoder.encode(`${reconstruct}
|
|
580
|
+
`));
|
|
581
|
+
} else {
|
|
582
|
+
controller.enqueue(encoder.encode(`${chunk}
|
|
583
|
+
`));
|
|
584
|
+
}
|
|
585
|
+
} else {
|
|
586
|
+
controller.enqueue(encoder.encode(`${chunk}
|
|
587
|
+
`));
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
controller.close();
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
|
|
528
595
|
// src/html/runtime/index.ts
|
|
529
596
|
async function getRuntime(type, url, bundle, shared, remoteShared) {
|
|
530
597
|
if (typeof globalThis.process === "undefined") {
|
|
@@ -715,21 +782,10 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
715
782
|
const RemoteComponentFromReadableStream = ({
|
|
716
783
|
name
|
|
717
784
|
}) => {
|
|
785
|
+
const stream = createRSCStream(name, self[name] ?? [`0:[null]
|
|
786
|
+
`]);
|
|
718
787
|
const Component = cache ?? // cache the component to avoid reloading the RSC flight data
|
|
719
|
-
(cache = createFromReadableStream(
|
|
720
|
-
// convert the RSC flight data array into a ReadableStream
|
|
721
|
-
new ReadableStream({
|
|
722
|
-
type: "bytes",
|
|
723
|
-
start(controller) {
|
|
724
|
-
const encoder = new TextEncoder();
|
|
725
|
-
(self[name] ?? [`0:[null]
|
|
726
|
-
`]).forEach((chunk) => {
|
|
727
|
-
controller.enqueue(encoder.encode(chunk));
|
|
728
|
-
});
|
|
729
|
-
controller.close();
|
|
730
|
-
}
|
|
731
|
-
})
|
|
732
|
-
));
|
|
788
|
+
(cache = createFromReadableStream(stream));
|
|
733
789
|
return Component;
|
|
734
790
|
};
|
|
735
791
|
hydrateRoot(
|