remote-components 0.0.7 → 0.0.9
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 +12 -9
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +12 -9
- package/dist/html/host.js.map +1 -1
- package/dist/next/config.cjs +25 -16
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +18 -9
- package/dist/next/config.js.map +1 -1
- package/dist/next/{server/app-client.cjs → host/app-router-client.cjs} +5 -5
- package/dist/next/host/app-router-client.cjs.map +1 -0
- package/dist/next/{server/app-client.js → host/app-router-client.js} +2 -2
- package/dist/next/host/app-router-client.js.map +1 -0
- package/dist/next/{server/app-server.cjs → host/app-router-server.cjs} +6 -6
- package/dist/next/host/app-router-server.cjs.map +1 -0
- package/dist/next/{server/app-server.js → host/app-router-server.js} +2 -2
- package/dist/next/host/app-router-server.js.map +1 -0
- package/dist/next/{server/pages-client.cjs → host/pages-router-client.cjs} +7 -10
- package/dist/next/host/pages-router-client.cjs.map +1 -0
- package/dist/next/{server/pages-client.d.ts → host/pages-router-client.d.ts} +3 -1
- package/dist/next/{server/pages-client.js → host/pages-router-client.js} +4 -7
- package/dist/next/host/pages-router-client.js.map +1 -0
- package/dist/next/{server/pages-server.cjs → host/pages-router-server.cjs} +6 -6
- package/dist/next/host/pages-router-server.cjs.map +1 -0
- package/dist/next/{server/pages-server.d.ts → host/pages-router-server.d.ts} +2 -1
- package/dist/next/{server/pages-server.js → host/pages-router-server.js} +3 -3
- package/dist/next/host/pages-router-server.js.map +1 -0
- package/dist/next/remote/{pages.cjs → pages-router.cjs} +4 -4
- package/dist/next/remote/pages-router.cjs.map +1 -0
- package/dist/next/remote/{pages.js → pages-router.js} +1 -1
- package/dist/next/remote/pages-router.js.map +1 -0
- package/dist/next/remote/render-client.cjs +1 -1
- package/dist/next/remote/render-client.cjs.map +1 -1
- package/dist/next/remote/render-client.js +1 -1
- package/dist/next/remote/render-client.js.map +1 -1
- package/dist/shared/client/remote-component.cjs +23 -4
- package/dist/shared/client/remote-component.cjs.map +1 -1
- package/dist/shared/client/remote-component.js +23 -4
- package/dist/shared/client/remote-component.js.map +1 -1
- package/dist/shared/webpack/shared-modules.cjs +4 -1
- package/dist/shared/webpack/shared-modules.cjs.map +1 -1
- package/dist/shared/webpack/shared-modules.js +4 -1
- package/dist/shared/webpack/shared-modules.js.map +1 -1
- package/package.json +44 -72
- package/dist/next/client.cjs +0 -757
- package/dist/next/client.cjs.map +0 -1
- package/dist/next/client.d.ts +0 -11
- package/dist/next/client.js +0 -723
- package/dist/next/client.js.map +0 -1
- package/dist/next/remote/pages.cjs.map +0 -1
- package/dist/next/remote/pages.js.map +0 -1
- package/dist/next/server/app-client.cjs.map +0 -1
- package/dist/next/server/app-client.js.map +0 -1
- package/dist/next/server/app-server.cjs.map +0 -1
- package/dist/next/server/app-server.js.map +0 -1
- package/dist/next/server/pages-client.cjs.map +0 -1
- package/dist/next/server/pages-client.js.map +0 -1
- package/dist/next/server/pages-server.cjs.map +0 -1
- package/dist/next/server/pages-server.js.map +0 -1
- /package/dist/next/{server/app-client.d.ts → host/app-router-client.d.ts} +0 -0
- /package/dist/next/{server/app-server.d.ts → host/app-router-server.d.ts} +0 -0
- /package/dist/next/remote/{pages.d.ts → pages-router.d.ts} +0 -0
package/dist/html/host.cjs
CHANGED
|
@@ -37,7 +37,10 @@ function applySharedModules(bundle, resolve) {
|
|
|
37
37
|
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
38
38
|
);
|
|
39
39
|
for (const [key, value] of Object.entries(resolve)) {
|
|
40
|
-
|
|
40
|
+
let ids = modulePaths.filter((p) => p === key);
|
|
41
|
+
if (ids.length === 0) {
|
|
42
|
+
ids = modulePaths.filter((p) => p.includes(key));
|
|
43
|
+
}
|
|
41
44
|
for (let id of ids) {
|
|
42
45
|
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
43
46
|
if (webpackBundle.m) {
|
|
@@ -148,7 +151,7 @@ var init_next_client_pages_loader = __esm({
|
|
|
148
151
|
}
|
|
149
152
|
});
|
|
150
153
|
|
|
151
|
-
// src/html/runtime/webpack.ts
|
|
154
|
+
// src/html/host/runtime/webpack.ts
|
|
152
155
|
var webpack_exports = {};
|
|
153
156
|
__export(webpack_exports, {
|
|
154
157
|
webpackRuntime: () => webpackRuntime
|
|
@@ -223,7 +226,7 @@ async function webpackRuntime() {
|
|
|
223
226
|
};
|
|
224
227
|
}
|
|
225
228
|
var init_webpack = __esm({
|
|
226
|
-
"src/html/runtime/webpack.ts"() {
|
|
229
|
+
"src/html/host/runtime/webpack.ts"() {
|
|
227
230
|
"use strict";
|
|
228
231
|
init_shared_modules();
|
|
229
232
|
init_next_client_pages_loader();
|
|
@@ -448,7 +451,7 @@ function getSharedModule(bundle, id) {
|
|
|
448
451
|
for (const [key, value] of Object.entries(
|
|
449
452
|
self.__remote_shared_modules__?.[bundle] ?? {}
|
|
450
453
|
)) {
|
|
451
|
-
if (id.includes(key)) {
|
|
454
|
+
if (typeof id === "string" && id.includes(key) || id === key) {
|
|
452
455
|
return value;
|
|
453
456
|
}
|
|
454
457
|
}
|
|
@@ -518,7 +521,7 @@ var init_webpack_adapter = __esm({
|
|
|
518
521
|
}
|
|
519
522
|
});
|
|
520
523
|
|
|
521
|
-
// src/html/runtime/turbopack.ts
|
|
524
|
+
// src/html/host/runtime/turbopack.ts
|
|
522
525
|
var turbopack_exports = {};
|
|
523
526
|
__export(turbopack_exports, {
|
|
524
527
|
turbopackRuntime: () => turbopackRuntime
|
|
@@ -557,7 +560,7 @@ async function turbopackRuntime(url, bundle, shared, remoteShared) {
|
|
|
557
560
|
};
|
|
558
561
|
}
|
|
559
562
|
var init_turbopack = __esm({
|
|
560
|
-
"src/html/runtime/turbopack.ts"() {
|
|
563
|
+
"src/html/host/runtime/turbopack.ts"() {
|
|
561
564
|
"use strict";
|
|
562
565
|
init_shared_modules();
|
|
563
566
|
init_next_client_pages_loader();
|
|
@@ -565,7 +568,7 @@ var init_turbopack = __esm({
|
|
|
565
568
|
}
|
|
566
569
|
});
|
|
567
570
|
|
|
568
|
-
// src/html/host.tsx
|
|
571
|
+
// src/html/host/index.tsx
|
|
569
572
|
var import_client = require("react-dom/client");
|
|
570
573
|
|
|
571
574
|
// src/shared/client/rsc.ts
|
|
@@ -632,7 +635,7 @@ function createRSCStream(name, data) {
|
|
|
632
635
|
});
|
|
633
636
|
}
|
|
634
637
|
|
|
635
|
-
// src/html/runtime/index.ts
|
|
638
|
+
// src/html/host/runtime/index.ts
|
|
636
639
|
async function getRuntime(type, url, bundle, shared, remoteShared) {
|
|
637
640
|
if (typeof globalThis.process === "undefined") {
|
|
638
641
|
globalThis.process = {
|
|
@@ -649,7 +652,7 @@ async function getRuntime(type, url, bundle, shared, remoteShared) {
|
|
|
649
652
|
throw new Error(`Runtime ${type} is not supported`);
|
|
650
653
|
}
|
|
651
654
|
|
|
652
|
-
// src/html/host.tsx
|
|
655
|
+
// src/html/host/index.tsx
|
|
653
656
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
654
657
|
if (typeof HTMLElement !== "undefined") {
|
|
655
658
|
class RemoteComponent extends HTMLElement {
|
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/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\n if (!self.__remote_components_turbopack_chunk_loader_promise__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_chunk_loader_promise__ = {};\n }\n if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {\n return self.__remote_components_turbopack_chunk_loader_promise__[url];\n }\n\n self.__remote_components_turbopack_chunk_loader_promise__[url] =\n 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 return self.__remote_components_turbopack_chunk_loader_promise__[url];\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 const exports = {} as Record<string, unknown>;\n const moduleExports = { exports };\n const exportNames = new Set<string>();\n\n if (!self.__remote_components_turbopack_modules__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_modules__ = {};\n }\n if (!self.__remote_components_turbopack_modules__[bundle]) {\n self.__remote_components_turbopack_modules__[bundle] = {};\n }\n if (self.__remote_components_turbopack_modules__[bundle][moduleId]) {\n return self.__remote_components_turbopack_modules__[bundle][moduleId];\n }\n\n if (typeof moduleInit !== 'function') {\n throw new Error(\n `Module ${id} not found in bundle ${bundle} with id ${moduleId}`,\n );\n }\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 exportNames.add(key);\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: moduleExports,\n e: exports,\n });\n\n for (const name of exportNames) {\n if (typeof exports[name] === 'function') {\n exports[name] = exports[name]();\n }\n }\n\n self.__remote_components_turbopack_modules__[bundle][moduleId] =\n moduleExports.exports;\n return moduleExports.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,OA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
1
|
+
{"version":3,"sources":["../../src/shared/webpack/shared-modules.ts","../../src/shared/webpack/next-client-pages-loader.ts","../../src/html/host/runtime/webpack.ts","../../src/shared/client/const.ts","../../src/shared/client/webpack-adapter.ts","../../src/html/host/runtime/turbopack.ts","../../src/html/host/index.tsx","../../src/shared/client/rsc.ts","../../src/html/host/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 let ids = modulePaths.filter((p) => p === key);\n if (ids.length === 0) {\n ids = modulePaths.filter((p) => p.includes(key));\n }\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\n if (!self.__remote_components_turbopack_chunk_loader_promise__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_chunk_loader_promise__ = {};\n }\n if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {\n return self.__remote_components_turbopack_chunk_loader_promise__[url];\n }\n\n self.__remote_components_turbopack_chunk_loader_promise__[url] =\n 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 return self.__remote_components_turbopack_chunk_loader_promise__[url];\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 | number): 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 ((typeof id === 'string' && id.includes(key)) || id === 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 const exports = {} as Record<string, unknown>;\n const moduleExports = { exports };\n const exportNames = new Set<string>();\n\n if (!self.__remote_components_turbopack_modules__) {\n // eslint-disable-next-line camelcase\n self.__remote_components_turbopack_modules__ = {};\n }\n if (!self.__remote_components_turbopack_modules__[bundle]) {\n self.__remote_components_turbopack_modules__[bundle] = {};\n }\n if (self.__remote_components_turbopack_modules__[bundle][moduleId]) {\n return self.__remote_components_turbopack_modules__[bundle][moduleId];\n }\n\n if (typeof moduleInit !== 'function') {\n throw new Error(\n `Module ${id} not found in bundle ${bundle} with id ${moduleId}`,\n );\n }\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 exportNames.add(key);\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: moduleExports,\n e: exports,\n });\n\n for (const name of exportNames) {\n if (typeof exports[name] === 'function') {\n exports[name] = exports[name]();\n }\n }\n\n self.__remote_components_turbopack_modules__[bundle][moduleId] =\n moduleExports.exports;\n return moduleExports.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,UAAI,MAAM,YAAY,OAAO,CAAC,MAAM,MAAM,GAAG;AAC7C,UAAI,IAAI,WAAW,GAAG;AACpB,cAAM,YAAY,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC;AAAA,MACjD;AACA,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;AAnDA;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,YAAY,YAAY,eAAe;AAAA,EACzD;AAGA,QAAM,UAAU,SAAS,cAAc,UAAU;AACjD,UAAQ,KAA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C,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"]}
|
package/dist/html/host.js
CHANGED
|
@@ -16,7 +16,10 @@ function applySharedModules(bundle, resolve) {
|
|
|
16
16
|
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
17
17
|
);
|
|
18
18
|
for (const [key, value] of Object.entries(resolve)) {
|
|
19
|
-
|
|
19
|
+
let ids = modulePaths.filter((p) => p === key);
|
|
20
|
+
if (ids.length === 0) {
|
|
21
|
+
ids = modulePaths.filter((p) => p.includes(key));
|
|
22
|
+
}
|
|
20
23
|
for (let id of ids) {
|
|
21
24
|
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
22
25
|
if (webpackBundle.m) {
|
|
@@ -127,7 +130,7 @@ var init_next_client_pages_loader = __esm({
|
|
|
127
130
|
}
|
|
128
131
|
});
|
|
129
132
|
|
|
130
|
-
// src/html/runtime/webpack.ts
|
|
133
|
+
// src/html/host/runtime/webpack.ts
|
|
131
134
|
var webpack_exports = {};
|
|
132
135
|
__export(webpack_exports, {
|
|
133
136
|
webpackRuntime: () => webpackRuntime
|
|
@@ -202,7 +205,7 @@ async function webpackRuntime() {
|
|
|
202
205
|
};
|
|
203
206
|
}
|
|
204
207
|
var init_webpack = __esm({
|
|
205
|
-
"src/html/runtime/webpack.ts"() {
|
|
208
|
+
"src/html/host/runtime/webpack.ts"() {
|
|
206
209
|
"use strict";
|
|
207
210
|
init_shared_modules();
|
|
208
211
|
init_next_client_pages_loader();
|
|
@@ -427,7 +430,7 @@ function getSharedModule(bundle, id) {
|
|
|
427
430
|
for (const [key, value] of Object.entries(
|
|
428
431
|
self.__remote_shared_modules__?.[bundle] ?? {}
|
|
429
432
|
)) {
|
|
430
|
-
if (id.includes(key)) {
|
|
433
|
+
if (typeof id === "string" && id.includes(key) || id === key) {
|
|
431
434
|
return value;
|
|
432
435
|
}
|
|
433
436
|
}
|
|
@@ -497,7 +500,7 @@ var init_webpack_adapter = __esm({
|
|
|
497
500
|
}
|
|
498
501
|
});
|
|
499
502
|
|
|
500
|
-
// src/html/runtime/turbopack.ts
|
|
503
|
+
// src/html/host/runtime/turbopack.ts
|
|
501
504
|
var turbopack_exports = {};
|
|
502
505
|
__export(turbopack_exports, {
|
|
503
506
|
turbopackRuntime: () => turbopackRuntime
|
|
@@ -536,7 +539,7 @@ async function turbopackRuntime(url, bundle, shared, remoteShared) {
|
|
|
536
539
|
};
|
|
537
540
|
}
|
|
538
541
|
var init_turbopack = __esm({
|
|
539
|
-
"src/html/runtime/turbopack.ts"() {
|
|
542
|
+
"src/html/host/runtime/turbopack.ts"() {
|
|
540
543
|
"use strict";
|
|
541
544
|
init_shared_modules();
|
|
542
545
|
init_next_client_pages_loader();
|
|
@@ -544,7 +547,7 @@ var init_turbopack = __esm({
|
|
|
544
547
|
}
|
|
545
548
|
});
|
|
546
549
|
|
|
547
|
-
// src/html/host.tsx
|
|
550
|
+
// src/html/host/index.tsx
|
|
548
551
|
import { hydrateRoot } from "react-dom/client";
|
|
549
552
|
|
|
550
553
|
// src/shared/client/rsc.ts
|
|
@@ -611,7 +614,7 @@ function createRSCStream(name, data) {
|
|
|
611
614
|
});
|
|
612
615
|
}
|
|
613
616
|
|
|
614
|
-
// src/html/runtime/index.ts
|
|
617
|
+
// src/html/host/runtime/index.ts
|
|
615
618
|
async function getRuntime(type, url, bundle, shared, remoteShared) {
|
|
616
619
|
if (typeof globalThis.process === "undefined") {
|
|
617
620
|
globalThis.process = {
|
|
@@ -628,7 +631,7 @@ async function getRuntime(type, url, bundle, shared, remoteShared) {
|
|
|
628
631
|
throw new Error(`Runtime ${type} is not supported`);
|
|
629
632
|
}
|
|
630
633
|
|
|
631
|
-
// src/html/host.tsx
|
|
634
|
+
// src/html/host/index.tsx
|
|
632
635
|
import { jsx } from "react/jsx-runtime";
|
|
633
636
|
if (typeof HTMLElement !== "undefined") {
|
|
634
637
|
class RemoteComponent extends HTMLElement {
|