remote-components 0.0.2 → 0.0.4

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.js CHANGED
@@ -153,7 +153,9 @@ async function webpackRuntime() {
153
153
  return Promise.resolve([]);
154
154
  };
155
155
  }
156
- const { createFromReadableStream } = await import("react-server-dom-webpack/client.browser");
156
+ const {
157
+ default: { createFromReadableStream }
158
+ } = await import("react-server-dom-webpack/client.browser");
157
159
  async function preloadScripts(scripts, url, bundle, _) {
158
160
  await Promise.all(
159
161
  scripts.map((script) => {
@@ -169,13 +171,10 @@ async function webpackRuntime() {
169
171
  )
170
172
  );
171
173
  };
172
- const scriptSrc = script.src || script.getAttribute("data-src");
174
+ const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
173
175
  if (scriptSrc) {
174
176
  newScript.src = new URL(
175
- scriptSrc.replace(
176
- /\/_next\/\[remote-component-(?:.+)\](?:%20| )/,
177
- "/_next/"
178
- ),
177
+ scriptSrc.replace(/\/_next\/\[(?:.+)\](?:%20| )/, "/_next/"),
179
178
  url
180
179
  ).href;
181
180
  }
@@ -186,10 +185,11 @@ async function webpackRuntime() {
186
185
  })
187
186
  );
188
187
  const resolve = {
189
- "/react/index.js": await import("react"),
190
- "/react/jsx-dev-runtime.js": await import("react/jsx-dev-runtime"),
191
- "/react/jsx-runtime.js": await import("react/jsx-runtime"),
192
- "/react-dom/index.js": await import("react-dom")
188
+ "/react/index.js": (await import("react")).default,
189
+ "/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
190
+ "/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
191
+ "/react-dom/index.js": (await import("react-dom")).default,
192
+ "/react-dom/client.js": (await import("react-dom/client")).default
193
193
  };
194
194
  applySharedModules(bundle, resolve);
195
195
  }
@@ -209,19 +209,6 @@ var init_webpack = __esm({
209
209
  }
210
210
  });
211
211
 
212
- // src/shared/client/script-loader.ts
213
- function loadCSS(url) {
214
- const link = document.createElement("link");
215
- link.rel = "stylesheet";
216
- link.href = url;
217
- document.head.appendChild(link);
218
- }
219
- var init_script_loader = __esm({
220
- "src/shared/client/script-loader.ts"() {
221
- "use strict";
222
- }
223
- });
224
-
225
212
  // src/shared/client/const.ts
226
213
  function getBundleKey(bundle) {
227
214
  return bundle.replace(/-/g, "_");
@@ -232,14 +219,18 @@ var init_const = __esm({
232
219
  "use strict";
233
220
  RUNTIME_WEBPACK = "webpack";
234
221
  RUNTIME_TURBOPACK = "turbopack";
235
- REMOTE_COMPONENT_REGEX = /(?<prefix>.*)?\[(?<bundle>remote-component-(?:[^\]]+))\](?:%20| )(?<id>.+)/;
222
+ REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
236
223
  }
237
224
  });
238
225
 
239
226
  // src/shared/client/webpack-adapter.ts
240
- async function setupWebpackRuntime(runtime, scripts = [], bundle, shared = {}, remoteShared = {}) {
227
+ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}) {
241
228
  const self = globalThis;
242
229
  self.__DISABLE_WEBPACK_EXEC__ = true;
230
+ if (!self.__remote_bundle_url__) {
231
+ self.__remote_bundle_url__ = {};
232
+ }
233
+ self.__remote_bundle_url__[bundle ?? "default"] = url;
243
234
  await initializeSharedModules(bundle ?? "default", shared, remoteShared);
244
235
  if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
245
236
  if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
@@ -277,15 +268,15 @@ function createChunkLoader(runtime) {
277
268
  bundle: scriptBundle ?? "",
278
269
  id: chunkId
279
270
  };
271
+ const self = globalThis;
280
272
  const url = new URL(
281
273
  path ? `${prefix ?? ""}${path}`.replace(
282
274
  /(?<char>[^:])(?<double>\/\/)/g,
283
275
  "$1/"
284
276
  ) : "/",
285
- location.origin
277
+ self.__remote_bundle_url__?.[bundle ?? "default"] ?? new URL(location.origin)
286
278
  ).href;
287
279
  if (url.endsWith(".css")) {
288
- loadCSS(url);
289
280
  return;
290
281
  }
291
282
  return new Promise((resolve, reject) => {
@@ -317,12 +308,18 @@ async function handleTurbopackChunk(code, bundle, url) {
317
308
  /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,
318
309
  `TURBOPACK_CHUNK_UPDATE_LISTENERS_${bundleKey}`
319
310
  ).replace(/__next_require__/g, `__${bundleKey}_next_require__`).replace(
320
- /\/\/# sourceMappingURL=(?<name>.+)\._\.js\.map/g,
321
- `//# sourceMappingURL=${new URL(".", new URL(url)).pathname}$1._.js.map`
311
+ /\/\/# sourceMappingURL=(?<name>.+)(?<optional>\._)?\.js\.map/g,
312
+ `//# sourceMappingURL=${new URL(
313
+ ".",
314
+ new URL(
315
+ url,
316
+ self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin)
317
+ )
318
+ ).href}$1$2.js.map`
322
319
  );
323
320
  await new Promise((scriptResolve, scriptReject) => {
324
321
  const blob = new Blob([transformedCode], {
325
- type: "application/javascript"
322
+ type: "application/javascript; charset=UTF-8"
326
323
  });
327
324
  const scriptUrl = URL.createObjectURL(blob);
328
325
  const script = document.createElement("script");
@@ -397,12 +394,20 @@ function initializeSharedModules(bundle, shared = {}, remoteShared = {}) {
397
394
  return Promise.all(
398
395
  Object.entries(remoteShared).map(async ([id, module]) => {
399
396
  if (self.__remote_shared_modules__?.[bundle]) {
400
- self.__remote_shared_modules__[bundle][id.replace("[app-ssr]", "[app-client]")] = await (shared[module] ?? (() => {
401
- console.warn(
402
- `Shared dependency not found for "${bundle}": ${module}`
403
- );
404
- return Promise.resolve({});
405
- }))();
397
+ self.__remote_shared_modules__[bundle][id.replace("[app-ssr]", "[app-client]")] = await (shared[module] ?? (() => Promise.resolve(
398
+ new Proxy(
399
+ {},
400
+ {
401
+ get(_, prop) {
402
+ if (prop !== "then") {
403
+ console.warn(
404
+ `Shared dependency "${module}" not found for "${bundle}" when trying to import "${prop}".`
405
+ );
406
+ }
407
+ }
408
+ }
409
+ )
410
+ )))();
406
411
  }
407
412
  })
408
413
  );
@@ -466,7 +471,6 @@ function handleTurbopackModule(bundle, moduleId, id) {
466
471
  var init_webpack_adapter = __esm({
467
472
  "src/shared/client/webpack-adapter.ts"() {
468
473
  "use strict";
469
- init_script_loader();
470
474
  init_const();
471
475
  }
472
476
  });
@@ -476,22 +480,26 @@ var turbopack_exports = {};
476
480
  __export(turbopack_exports, {
477
481
  turbopackRuntime: () => turbopackRuntime
478
482
  });
479
- async function turbopackRuntime(bundle, shared, remoteShared) {
483
+ async function turbopackRuntime(url, bundle, shared, remoteShared) {
480
484
  const self = globalThis;
481
485
  await setupWebpackRuntime(
482
486
  "turbopack",
483
487
  [],
488
+ url,
484
489
  bundle,
485
490
  self.__remote_component_shared__ ?? shared,
486
491
  remoteShared
487
492
  );
488
- const { createFromReadableStream } = await import("react-server-dom-webpack/client.browser");
493
+ const {
494
+ default: { createFromReadableStream }
495
+ } = await import("react-server-dom-webpack/client.browser");
489
496
  function preloadScripts(scripts, __) {
490
497
  return setupWebpackRuntime(
491
498
  "turbopack",
492
499
  scripts.map((script) => ({
493
- src: script.src || script.getAttribute("data-src")
500
+ src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
494
501
  })),
502
+ url,
495
503
  bundle,
496
504
  self.__remote_component_shared__ ?? shared,
497
505
  remoteShared
@@ -518,7 +526,7 @@ var init_turbopack = __esm({
518
526
  import { hydrateRoot } from "react-dom/client";
519
527
 
520
528
  // src/html/runtime/index.ts
521
- async function getRuntime(type, bundle, shared, remoteShared) {
529
+ async function getRuntime(type, url, bundle, shared, remoteShared) {
522
530
  if (typeof globalThis.process === "undefined") {
523
531
  globalThis.process = {
524
532
  env: {}
@@ -529,7 +537,7 @@ async function getRuntime(type, bundle, shared, remoteShared) {
529
537
  return webpackRuntime2();
530
538
  } else if (type === "turbopack") {
531
539
  const { turbopackRuntime: turbopackRuntime2 } = await Promise.resolve().then(() => (init_turbopack(), turbopack_exports));
532
- return turbopackRuntime2(bundle, shared, remoteShared);
540
+ return turbopackRuntime2(url, bundle, shared, remoteShared);
533
541
  }
534
542
  throw new Error(`Runtime ${type} is not supported`);
535
543
  }
@@ -590,7 +598,7 @@ if (typeof HTMLElement !== "undefined") {
590
598
  // pass the public address of the remote component to the server used for module map mutation
591
599
  "Vercel-Remote-Component-Url": url.href
592
600
  },
593
- credentials: "include"
601
+ credentials: this.getAttribute("credentials") || "same-origin"
594
602
  };
595
603
  const res = await fetch(url, fetchInit);
596
604
  if (!res.ok) {
@@ -632,7 +640,7 @@ if (typeof HTMLElement !== "undefined") {
632
640
  if (!component || !(rsc || nextData)) {
633
641
  throw new Error(`Failed to find component with id "${this.name}"`);
634
642
  }
635
- const removeable = Array.from(this.childNodes);
643
+ const removable = Array.from(this.childNodes);
636
644
  const links = doc.querySelectorAll("link[href]");
637
645
  await Promise.all(
638
646
  Array.from(links).map((link) => {
@@ -649,7 +657,14 @@ if (typeof HTMLElement !== "undefined") {
649
657
  );
650
658
  };
651
659
  for (const attr of link.attributes) {
652
- newLink.setAttribute(attr.name, attr.value);
660
+ if (attr.name === "href") {
661
+ newLink.setAttribute(
662
+ attr.name,
663
+ new URL(attr.value, url ?? location.origin).href
664
+ );
665
+ } else {
666
+ newLink.setAttribute(attr.name, attr.value);
667
+ }
653
668
  }
654
669
  this.shadowRoot?.appendChild(newLink);
655
670
  });
@@ -658,7 +673,7 @@ if (typeof HTMLElement !== "undefined") {
658
673
  Array.from(component.children).forEach((el) => {
659
674
  this.shadowRoot?.appendChild(el);
660
675
  });
661
- for (const el of removeable) {
676
+ for (const el of removable) {
662
677
  el.parentElement?.removeChild(el);
663
678
  }
664
679
  this.shadowRoot?.removeChild(this.fallbackSlot);
@@ -669,13 +684,14 @@ if (typeof HTMLElement !== "undefined") {
669
684
  preloadScripts
670
685
  } = await getRuntime(
671
686
  component.getAttribute("data-runtime") ?? "webpack",
687
+ url ?? new URL(location.href),
672
688
  this.bundle,
673
689
  {
674
- react: () => import("react"),
675
- "react/jsx-dev-runtime": () => import("react/jsx-dev-runtime"),
676
- "react/jsx-runtime": () => import("react/jsx-runtime"),
677
- "react-dom": () => import("react-dom"),
678
- "react-dom/client": () => import("react-dom/client")
690
+ react: async () => (await import("react")).default,
691
+ "react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
692
+ "react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
693
+ "react-dom": async () => (await import("react-dom")).default,
694
+ "react-dom/client": async () => (await import("react-dom/client")).default
679
695
  },
680
696
  remoteShared
681
697
  );
@@ -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/script-loader.ts","../../src/shared/client/const.ts","../../src/shared/client/webpack-adapter.ts","../../src/html/runtime/turbopack.ts","../../src/html/host.tsx","../../src/html/runtime/index.ts"],"sourcesContent":["// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\nexport function applySharedModules(\n bundle: string,\n resolve: Record<string, unknown>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // if we have the bundle\n if (self.__remote_webpack_require__?.[bundle]) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ??\n self.__remote_webpack_require__[bundle].m ??\n {},\n );\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n const ids = modulePaths.filter((p) => p.includes(key));\n for (let id of ids) {\n const webpackBundle = self.__remote_webpack_require__[bundle];\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {\n id = `${self.__remote_webpack_module_map__[bundle][id]}`;\n }\n // create a mock module which exports the shared module\n webpackBundle.m[id] = (module) => {\n module.exports = value;\n };\n }\n }\n }\n }\n}\n","// module loader for Next.js Pages Router\nexport function nextClientPagesLoader(\n bundle: string,\n route: string,\n styleContainer: HTMLHeadElement | ShadowRoot | null = document.head,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string | number) => unknown) & {\n c?: Record<\n string | number,\n { id: string; parents: string[]; children: string[] }\n >;\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n type?: 'turbopack' | 'webpack';\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // Next.js client pages loader reference storage\n __NEXT_P?: [\n (\n | [\n string,\n () => { default?: React.ComponentType<Record<string, unknown>> },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n ];\n };\n\n // temporarily remove the original Next.js CSS loader\n const nextCssOriginal = document.getElementById('__next_css__DO_NOT_USE__');\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.removeChild(nextCssOriginal);\n }\n\n // create a new Next.js CSS loader element\n const nextCss = document.createElement('noscript');\n nextCss.id = '__next_css__DO_NOT_USE__';\n const lastNode =\n document.head.childNodes[document.head.childNodes.length - 1];\n document.head.appendChild(nextCss);\n\n // find the page component loader chunk\n const componentLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // find the app loader chunk\n const appLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // if we didn't find the component loader or app loader, throw an error\n if (!(componentLoaderChunk && appLoaderChunk)) {\n throw new Error(\n `Next.js client pages loader not found in bundle \"${bundle}\"`,\n );\n }\n\n // temporarily store the original __NEXT_P reference\n // this is required to avoid conflicts with the Next.js client pages loader\n // which uses the same global variable to store the page components\n const __NEXT_P_ORIGINAL = self.__NEXT_P;\n const selfOriginal = self;\n delete selfOriginal.__NEXT_P;\n\n // load the component and app loader chunks\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? componentLoaderChunk\n : `[${bundle}] ${componentLoaderChunk}`,\n );\n if (\n typeof appLoaderChunk === 'string' ||\n (typeof appLoaderChunk === 'number' && appLoaderChunk !== -1)\n ) {\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? appLoaderChunk\n : `[${bundle}] ${appLoaderChunk}`,\n );\n }\n\n // if we have the __NEXT_P global variable, we can extract the component and app\n if (self.__NEXT_P) {\n const [, componentLoader] = self.__NEXT_P[0] ?? [\n undefined,\n () => ({ default: null }),\n ];\n const [, appLoader] = self.__NEXT_P[2] ?? [\n undefined,\n () => ({\n default: null,\n }),\n ];\n const { default: Component } = componentLoader();\n const { default: App } = appLoader();\n\n // load the CSS files from the remote bundle\n const cssRE = /\\.s?css$/;\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {})\n .filter((id) => cssRE.test(id))\n .forEach((id) => {\n self.__remote_webpack_require__?.[bundle]?.(id);\n });\n\n Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {})\n .filter((path) => cssRE.test(path))\n .forEach((path) => {\n const id = self.__remote_webpack_module_map__?.[bundle]?.[path];\n if (id) {\n self.__remote_webpack_require__?.[bundle]?.(id);\n }\n });\n\n // if the styleContainer is provided, we need to move the styles to it\n if (styleContainer) {\n let node = nextCss.previousSibling;\n while (node && node !== lastNode) {\n styleContainer.appendChild(node);\n node = nextCss.previousSibling;\n }\n }\n\n // restore the original __NEXT_P reference\n delete self.__NEXT_P;\n self.__NEXT_P = __NEXT_P_ORIGINAL;\n\n // restore the original Next.js CSS loader\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.appendChild(nextCssOriginal);\n }\n\n return { Component, App };\n }\n\n return { Component: null, App: null };\n}\n","import { applySharedModules } from '../../shared/webpack/shared-modules';\nimport { nextClientPagesLoader } from '../../shared/webpack/next-client-pages-loader';\n\n// initializer for the webpack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function webpackRuntime() {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__: boolean;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __webpack_require_type__: 'webpack' | 'turbopack';\n } & Record<string, string[]>;\n\n // disable webpack exec to prevent automatically executing the entry module\n self.__DISABLE_WEBPACK_EXEC__ = true;\n // add a custom webpack require function to load remote components from multiple bundles / zones\n if (\n typeof self.__webpack_require__ !== 'function' &&\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n self.__webpack_require__ = (remoteId: string) => {\n const re = /\\[(?<bundle>[a-zA-Z0-9-_]+)\\] (?<id>.*)/;\n const match = re.exec(remoteId);\n const bundle = match?.groups?.bundle;\n const id = match?.groups?.id;\n if (!(id && bundle)) {\n throw new Error(`Module not found: \"${remoteId}\"`);\n }\n if (typeof self.__remote_webpack_require__?.[bundle] !== 'function') {\n throw new Error(`Remote component loading error \"${bundle}\"`);\n }\n return self.__remote_webpack_require__[bundle](id);\n };\n // not used but required by react-server-dom-webpack\n self.__webpack_chunk_load__ = () => {\n return Promise.resolve([]);\n };\n }\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const { createFromReadableStream } = await import(\n 'react-server-dom-webpack/client.browser'\n );\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 = script.src || script.getAttribute('data-src');\n if (scriptSrc) {\n newScript.src = new URL(\n scriptSrc.replace(\n /\\/_next\\/\\[remote-component-(?:.+)\\](?:%20| )/,\n '/_next/',\n ),\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'),\n '/react/jsx-dev-runtime.js': await import('react/jsx-dev-runtime'),\n '/react/jsx-runtime.js': await import('react/jsx-runtime'),\n '/react-dom/index.js': await import('react-dom'),\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","/**\n * Loads external scripts for remote components\n */\nexport async function loadScripts(scripts: { src: string }[]): Promise<void> {\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newSrc = new URL(\n // remove the remote component bundle name identifier from the script src\n script.src.replace(/\\/_next\\/\\[.+\\] /, '/_next/'),\n location.origin,\n ).href;\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 newScript.src = newSrc;\n newScript.async = true;\n document.head.appendChild(newScript);\n });\n }),\n );\n}\n\n/**\n * Loads a CSS file by creating a link element\n */\nexport function loadCSS(url: string): void {\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n document.head.appendChild(link);\n}\n","export const DEFAULT_ROUTE = '/';\n\nexport const RUNTIME_WEBPACK = 'webpack';\nexport const RUNTIME_TURBOPACK = 'turbopack';\n\nexport const REMOTE_COMPONENT_PREFIX = '[remote-component-';\nexport const REMOTE_COMPONENT_REGEX =\n /(?<prefix>.*)?\\[(?<bundle>remote-component-(?:[^\\]]+))\\](?:%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 { loadCSS } from './script-loader';\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 bundle?: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n): Promise<void> {\n const self = globalThis as GlobalScope;\n self.__DISABLE_WEBPACK_EXEC__ = true;\n await initializeSharedModules(bundle ?? 'default', shared, remoteShared);\n if (\n typeof self.__webpack_require__ !== 'function' ||\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n if (\n !self.__original_webpack_require__ &&\n !self.__original_webpack_chunk_load__\n ) {\n // eslint-disable-next-line camelcase\n self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;\n // eslint-disable-next-line camelcase\n self.__original_webpack_require__ = self.__webpack_require__;\n }\n\n self.__webpack_chunk_load__ = createChunkLoader(runtime);\n self.__webpack_require__ = createModuleRequire(runtime);\n // eslint-disable-next-line camelcase\n self.__webpack_require_type__ = runtime;\n\n if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {\n const remoteBundle = bundle ?? 'default';\n self.__remote_webpack_require__[remoteBundle] =\n self.__webpack_require__ as (remoteId: string | number) => unknown;\n self.__remote_webpack_require__[remoteBundle].type = 'turbopack';\n }\n }\n await Promise.all(\n scripts.map((script) => {\n if (script.src) {\n return self.__webpack_chunk_load__?.(script.src, bundle);\n }\n return Promise.resolve(undefined);\n }),\n );\n}\n\n/**\n * Creates chunk loader function for webpack runtime\n */\nfunction createChunkLoader(\n runtime: Runtime,\n): (chunkId: string) => Promise<unknown> | undefined {\n // eslint-disable-next-line camelcase\n return function __turbopack_chunk_load__(\n chunkId: string,\n scriptBundle?: string,\n ) {\n if (runtime === RUNTIME_WEBPACK) {\n // all scripts are already loaded for this remote\n return Promise.resolve(undefined);\n }\n const {\n bundle,\n id: path,\n prefix,\n } = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {\n bundle: scriptBundle ?? '',\n id: chunkId,\n };\n const url = new URL(\n path\n ? `${prefix ?? ''}${path}`.replace(\n /(?<char>[^:])(?<double>\\/\\/)/g,\n '$1/',\n )\n : '/',\n location.origin,\n ).href;\n if (url.endsWith('.css')) {\n loadCSS(url);\n return;\n }\n return new Promise((resolve, reject) => {\n fetch(url)\n .then((res) => res.text())\n .then((code) => {\n if (code.includes('globalThis.TURBOPACK')) {\n return handleTurbopackChunk(code, bundle ?? '', url);\n }\n })\n .then(resolve)\n .catch(reject);\n });\n };\n}\n\n/**\n * Handles Turbopack chunk loading\n */\nasync function handleTurbopackChunk(\n code: string,\n bundle: string,\n url: string,\n): Promise<void> {\n // skip this chunk as it is not needed for remote components\n if (\n code.includes('/next/dist/client/app-next-turbopack.js') &&\n code.includes('importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS')\n ) {\n // remove preload links for this chunk\n const preloadLinks = document.querySelectorAll(\n `link[rel=\"preload\"][href=\"${new URL(url).pathname}\"]`,\n );\n preloadLinks.forEach((preloadLink) => preloadLink.remove());\n return;\n }\n\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n\n // replace global variables with bundle-specific ones\n const transformedCode = code\n .replace(/globalThis\\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`)\n .replace(\n /TURBOPACK_WORKER_LOCATION/g,\n `TURBOPACK_WORKER_LOCATION_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_NEXT_CHUNK_URLS/g,\n `TURBOPACK_NEXT_CHUNK_URLS_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,\n `TURBOPACK_CHUNK_UPDATE_LISTENERS_${bundleKey}`,\n )\n .replace(/__next_require__/g, `__${bundleKey}_next_require__`)\n .replace(\n /\\/\\/# sourceMappingURL=(?<name>.+)\\._\\.js\\.map/g,\n `//# sourceMappingURL=${new URL('.', new URL(url)).pathname}$1._.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',\n });\n const scriptUrl = URL.createObjectURL(blob);\n const script = document.createElement('script');\n script.src = scriptUrl;\n script.async = true;\n script.onload = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptResolve(undefined);\n };\n script.onerror = (error) => {\n URL.revokeObjectURL(scriptUrl);\n scriptReject(\n new Error(\n `Failed to load script: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n };\n document.head.appendChild(script);\n });\n const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`] as\n | { chunks: string[] }[]\n | undefined;\n const loadChunkLists = [] as (Promise<unknown> | undefined)[];\n while (chunkLists?.length) {\n const { chunks } = chunkLists.shift() ?? { chunks: [] };\n if (chunks.length > 0) {\n chunks.forEach((id: string) => {\n const chunkLoadResult = self.__webpack_chunk_load__?.(\n `[${bundle}] ${url.slice(0, url.indexOf('/_next'))}/_next/${id}`,\n );\n if (chunkLoadResult) {\n loadChunkLists.push(chunkLoadResult);\n }\n });\n }\n }\n if (loadChunkLists.length > 0) {\n await Promise.all(loadChunkLists);\n }\n}\n\n/**\n * Creates module require function for webpack runtime\n */\nfunction createModuleRequire(runtime: Runtime): (id: string) => unknown {\n return (id: string) => {\n const self = globalThis as GlobalScope;\n const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)\n ?.groups ?? { bundle: 'default', id };\n try {\n if (runtime === RUNTIME_WEBPACK && bundle && moduleId) {\n return self.__remote_webpack_require__?.[bundle]?.(moduleId);\n }\n const sharedModule = getSharedModule(bundle ?? 'default', moduleId ?? id);\n if (sharedModule) {\n return sharedModule;\n }\n if (bundle && moduleId) {\n return handleTurbopackModule(bundle, moduleId, id);\n }\n throw new Error(`Module ${id} not found`);\n } catch {\n try {\n return self.__original_webpack_require__?.(id);\n } catch {\n throw new Error(\n `Module ${id} not found in remote component bundle ${bundle}`,\n );\n }\n }\n };\n}\n\nfunction initializeSharedModules(\n bundle: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n) {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, Record<string, unknown>>;\n __next_f?: unknown[];\n };\n // eslint-disable-next-line camelcase\n self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};\n\n if (!self.__remote_shared_modules__[bundle]) {\n self.__remote_shared_modules__[bundle] = {};\n }\n\n // ensure that the shared modules are initialized\n return Promise.all(\n Object.entries(remoteShared).map(async ([id, module]) => {\n if (self.__remote_shared_modules__?.[bundle]) {\n self.__remote_shared_modules__[bundle][\n id.replace('[app-ssr]', '[app-client]')\n ] = await (\n shared[module] ??\n (() => {\n // eslint-disable-next-line no-console\n console.warn(\n `Shared dependency not found for \"${bundle}\": ${module}`,\n );\n return Promise.resolve({});\n })\n )();\n }\n }),\n );\n}\n\n/**\n * Returns shared modules for common dependencies\n */\nfunction getSharedModule(bundle: string, id: string): unknown {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, unknown>;\n };\n\n for (const [key, value] of Object.entries(\n self.__remote_shared_modules__?.[bundle] ?? {},\n )) {\n if (id.includes(key)) {\n return value;\n }\n }\n return null;\n}\n\n/**\n * Handles Turbopack module resolution\n */\nfunction handleTurbopackModule(\n bundle: string,\n moduleId: string,\n id: string,\n): unknown {\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n const modules = (\n self[`TURBOPACK_${bundleKey}`] as\n | [unknown, Record<string, unknown>][]\n | undefined\n )?.find((mod: [unknown, Record<string, unknown>]) => moduleId in mod[1])?.[1];\n const moduleInit = modules?.[moduleId];\n if (typeof moduleInit !== 'function') {\n throw new Error(\n `Module ${id} not found in bundle ${bundle} with id ${moduleId}`,\n );\n }\n const exports = {} as Record<string, unknown>;\n moduleInit({\n // HMR not implemented for Remote Components\n k: {\n register() {\n // omit\n },\n registerExports() {\n // omit\n },\n signature() {\n return () => {\n // omit\n };\n },\n },\n s(m: Record<string, () => unknown>) {\n for (const [key, value] of Object.entries(m)) {\n exports[key] = value;\n }\n },\n i(iid: string) {\n return self.__webpack_require__?.(`[${bundle}] ${iid}`);\n },\n r(rid: string) {\n return self.__webpack_require__?.(`[${bundle}] ${rid}`);\n },\n m: {\n exports,\n },\n });\n for (const [key, value] of Object.entries(exports)) {\n if (typeof value === 'function') {\n exports[key] = value();\n }\n }\n return exports;\n}\n","import { applySharedModules } from '../../shared/webpack/shared-modules';\nimport { nextClientPagesLoader } from '../../shared/webpack/next-client-pages-loader';\nimport { setupWebpackRuntime } from '../../shared/client/webpack-adapter';\n\n// initializer for the turbopack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function turbopackRuntime(\n 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 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 { createFromReadableStream } = await import(\n 'react-server-dom-webpack/client.browser'\n );\n\n function preloadScripts(scripts: HTMLScriptElement[], __: URL) {\n return setupWebpackRuntime(\n 'turbopack',\n scripts.map((script) => ({\n src: script.src || script.getAttribute('data-src'),\n })),\n bundle,\n self.__remote_component_shared__ ?? shared,\n remoteShared,\n );\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","import { hydrateRoot } from 'react-dom/client';\nimport { getRuntime, type Runtime } from './runtime';\n\nif (typeof HTMLElement !== 'undefined') {\n class RemoteComponent extends HTMLElement {\n name: string;\n bundle: string;\n fallbackSlot: HTMLSlotElement;\n __next: HTMLDivElement | null = null;\n fouc: HTMLStyleElement | null = null;\n isLoading = false;\n\n constructor() {\n super();\n // use the shadow DOM to encapsulate the component\n this.attachShadow({ mode: 'open' });\n\n // create a slot element to allow the remote component to use the default slot\n this.fallbackSlot = document.createElement('slot');\n this.shadowRoot?.appendChild(this.fallbackSlot);\n\n this.name = this.getAttribute('name') || '__vercel_remote_component';\n this.bundle = 'default';\n\n // load when the custom element has an src, data-ssr attribute or contains an SSR remote component div\n if (\n this.hasAttribute('src') ||\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.hasAttribute('data-ssr')\n ) {\n // start loading and hydration\n this.load().catch((e) => {\n throw new Error(`Failed to load remote component: ${e}`);\n });\n }\n }\n\n static get observedAttributes() {\n return ['src'];\n }\n\n // watch for src attribute changes\n // this is required to reload the remote component when the src attribute is added later\n // this is for rendering the custom element using React\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (name === 'src' && oldValue !== newValue) {\n this.load().catch((e) => {\n throw new Error(`Failed to load remote component: ${e}`);\n });\n }\n }\n\n async load() {\n // prevent multiple loads\n if (this.isLoading) {\n return;\n }\n\n this.isLoading = true;\n const src = this.getAttribute('src');\n const remoteComponentChild = this.querySelector(\n 'div#__REMOTE_COMPONENT__',\n );\n\n if (!src && !remoteComponentChild) {\n throw new Error('src attribute is required');\n }\n\n let url: URL | null = null;\n let html = this.innerHTML;\n\n if (!remoteComponentChild && src) {\n url = new URL(src, window.location.href);\n\n // fetch the remote component\n const fetchInit = {\n method: 'GET',\n headers: {\n Accept: 'text/html',\n // pass the public address of the remote component to the server used for module map mutation\n 'Vercel-Remote-Component-Url': url.href,\n },\n credentials: 'include',\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 removeable = 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 newLink.setAttribute(attr.name, attr.value);\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 removeable) {\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 this.bundle,\n {\n react: () => import('react'),\n 'react/jsx-dev-runtime': () => import('react/jsx-dev-runtime'),\n 'react/jsx-runtime': () => import('react/jsx-runtime'),\n 'react-dom': () => import('react-dom'),\n 'react-dom/client': () => import('react-dom/client'),\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 await preloadScripts(Array.from(scripts), url, this.bundle, this.name);\n\n // using RSC hydration if the RSC flight data is available\n if (rsc) {\n // remove the RSC flight data script element\n rsc.parentElement?.removeChild(rsc);\n\n // reload the RSC flight data script to eval it's content\n const rscClone = document.createElement('script');\n rscClone.id = `${this.name}_rsc`;\n rscClone.textContent = rsc.textContent;\n document.body.appendChild(rscClone);\n\n let cache: React.ReactNode;\n // React component to convert the RSC flight data into a React component\n const RemoteComponentFromReadableStream = ({\n name,\n }: {\n name: string;\n }) => {\n const Component =\n cache ??\n // cache the component to avoid reloading the RSC flight data\n (cache = createFromReadableStream(\n // convert the RSC flight data array into a ReadableStream\n new ReadableStream({\n type: 'bytes',\n start(controller) {\n const encoder = new TextEncoder();\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n (self[name] ?? [`0:[null]\\n`]).forEach((chunk) => {\n // encode the chunk to a byte buffer\n controller.enqueue(encoder.encode(chunk));\n });\n // close the stream when all chunks are enqueued\n controller.close();\n },\n }),\n ) as React.ReactNode);\n\n // React can handle the component reference and will wait for the component to be ready\n return Component;\n };\n\n // hydrate the remote component using the RSC flight data\n hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.shadowRoot,\n <RemoteComponentFromReadableStream name={this.name} />,\n );\n } else if (nextData) {\n // using Next.js client pages loader if the Next.js hydration data is available\n const { Component, App } = nextClientPagesLoader(\n this.bundle,\n nextData.page,\n this.shadowRoot,\n );\n\n // if we have the component, we can hydrate it\n if (Component) {\n hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.shadowRoot,\n App ? (\n <App Component={Component} {...nextData.props} />\n ) : (\n <Component {...nextData.props} />\n ),\n );\n }\n\n // remove the FOUC workaround style element to show the remote component\n // this is only for development mode\n if (this.fouc) {\n this.shadowRoot?.removeChild(this.fouc);\n }\n }\n\n this.isLoading = false;\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n","export type Runtime = 'webpack' | 'turbopack' | 'esm';\n\nexport async function getRuntime(\n type: Runtime,\n 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(bundle, shared, remoteShared);\n }\n throw new Error(`Runtime ${type} is not supported`);\n}\n"],"mappings":";;;;;;;;;;;AAKO,SAAS,mBACd,QACA,SACA;AAEA,QAAM,OAAO;AAab,MAAI,KAAK,6BAA6B,MAAM,GAAG;AAC7C,UAAM,cAAc,OAAO;AAAA,MACzB,KAAK,gCAAgC,MAAM,KACzC,KAAK,2BAA2B,MAAM,EAAE,KACxC,CAAC;AAAA,IACL;AAEA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,YAAM,MAAM,YAAY,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC;AACrD,eAAS,MAAM,KAAK;AAClB,cAAM,gBAAgB,KAAK,2BAA2B,MAAM;AAC5D,YAAI,cAAc,GAAG;AAGnB,cAAI,KAAK,gCAAgC,MAAM,IAAI,EAAE,GAAG;AACtD,iBAAK,GAAG,KAAK,8BAA8B,MA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L,SAAS;AAAA,UACT,KAAK;AAAA,QACP;AAGA,YAAI,WAAW;AACb;AAAA;AAAA;AAAA,YAGE,KAAK;AAAA,YACL,MACE,oBAAC,OAAI,WAAuB,GAAG,SAAS,OAAO,IAE/C,oBAAC,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":["resolve","webpackRuntime","turbopackRuntime","nextClientPagesLoader"]}
1
+ {"version":3,"sources":["../../src/shared/webpack/shared-modules.ts","../../src/shared/webpack/next-client-pages-loader.ts","../../src/html/runtime/webpack.ts","../../src/shared/client/const.ts","../../src/shared/client/webpack-adapter.ts","../../src/html/runtime/turbopack.ts","../../src/html/host.tsx","../../src/html/runtime/index.ts"],"sourcesContent":["// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\nexport function applySharedModules(\n bundle: string,\n resolve: Record<string, unknown>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // if we have the bundle\n if (self.__remote_webpack_require__?.[bundle]) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ??\n self.__remote_webpack_require__[bundle].m ??\n {},\n );\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n const ids = modulePaths.filter((p) => p.includes(key));\n for (let id of ids) {\n const webpackBundle = self.__remote_webpack_require__[bundle];\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {\n id = `${self.__remote_webpack_module_map__[bundle][id]}`;\n }\n // create a mock module which exports the shared module\n webpackBundle.m[id] = (module) => {\n module.exports = value;\n };\n }\n }\n }\n }\n}\n","// module loader for Next.js Pages Router\nexport function nextClientPagesLoader(\n bundle: string,\n route: string,\n styleContainer: HTMLHeadElement | ShadowRoot | null = document.head,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string | number) => unknown) & {\n c?: Record<\n string | number,\n { id: string; parents: string[]; children: string[] }\n >;\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n type?: 'turbopack' | 'webpack';\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // Next.js client pages loader reference storage\n __NEXT_P?: [\n (\n | [\n string,\n () => { default?: React.ComponentType<Record<string, unknown>> },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n (\n | [\n string,\n () => {\n default?: React.ComponentType<\n {\n Component: React.ComponentType<Record<string, unknown>>;\n } & Record<string, unknown>\n >;\n },\n ]\n | undefined\n ),\n ];\n };\n\n // temporarily remove the original Next.js CSS loader\n const nextCssOriginal = document.getElementById('__next_css__DO_NOT_USE__');\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.removeChild(nextCssOriginal);\n }\n\n // create a new Next.js CSS loader element\n const nextCss = document.createElement('noscript');\n nextCss.id = '__next_css__DO_NOT_USE__';\n const lastNode =\n document.head.childNodes[document.head.childNodes.length - 1];\n document.head.appendChild(nextCss);\n\n // find the page component loader chunk\n const componentLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=${encodeURIComponent(route)}`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // find the app loader chunk\n const appLoaderChunk =\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n self.__remote_webpack_module_map__?.[bundle]?.[\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) =>\n key.includes('/webpack/loaders/next-client-pages-loader.js') &&\n key.includes(`page=%2F_app`),\n ) ??\n Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(\n (key) => key.includes('/next/dist/client/page-loader.js'),\n ) ??\n ''\n ] ??\n -1;\n\n // if we didn't find the component loader or app loader, throw an error\n if (!(componentLoaderChunk && appLoaderChunk)) {\n throw new Error(\n `Next.js client pages loader not found in bundle \"${bundle}\"`,\n );\n }\n\n // temporarily store the original __NEXT_P reference\n // this is required to avoid conflicts with the Next.js client pages loader\n // which uses the same global variable to store the page components\n const __NEXT_P_ORIGINAL = self.__NEXT_P;\n const selfOriginal = self;\n delete selfOriginal.__NEXT_P;\n\n // load the component and app loader chunks\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? componentLoaderChunk\n : `[${bundle}] ${componentLoaderChunk}`,\n );\n if (\n typeof appLoaderChunk === 'string' ||\n (typeof appLoaderChunk === 'number' && appLoaderChunk !== -1)\n ) {\n self.__remote_webpack_require__?.[bundle]?.(\n self.__remote_webpack_require__[bundle].type !== 'turbopack'\n ? appLoaderChunk\n : `[${bundle}] ${appLoaderChunk}`,\n );\n }\n\n // if we have the __NEXT_P global variable, we can extract the component and app\n if (self.__NEXT_P) {\n const [, componentLoader] = self.__NEXT_P[0] ?? [\n undefined,\n () => ({ default: null }),\n ];\n const [, appLoader] = self.__NEXT_P[2] ?? [\n undefined,\n () => ({\n default: null,\n }),\n ];\n const { default: Component } = componentLoader();\n const { default: App } = appLoader();\n\n // load the CSS files from the remote bundle\n const cssRE = /\\.s?css$/;\n Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {})\n .filter((id) => cssRE.test(id))\n .forEach((id) => {\n self.__remote_webpack_require__?.[bundle]?.(id);\n });\n\n Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {})\n .filter((path) => cssRE.test(path))\n .forEach((path) => {\n const id = self.__remote_webpack_module_map__?.[bundle]?.[path];\n if (id) {\n self.__remote_webpack_require__?.[bundle]?.(id);\n }\n });\n\n // if the styleContainer is provided, we need to move the styles to it\n if (styleContainer) {\n let node = nextCss.previousSibling;\n while (node && node !== lastNode) {\n styleContainer.appendChild(node);\n node = nextCss.previousSibling;\n }\n }\n\n // restore the original __NEXT_P reference\n delete self.__NEXT_P;\n self.__NEXT_P = __NEXT_P_ORIGINAL;\n\n // restore the original Next.js CSS loader\n if (nextCssOriginal) {\n nextCssOriginal.parentNode?.appendChild(nextCssOriginal);\n }\n\n return { Component, App };\n }\n\n return { Component: null, App: null };\n}\n","import { applySharedModules } from '../../shared/webpack/shared-modules';\nimport { nextClientPagesLoader } from '../../shared/webpack/next-client-pages-loader';\n\n// initializer for the webpack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function webpackRuntime() {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__: boolean;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __webpack_require_type__: 'webpack' | 'turbopack';\n } & Record<string, string[]>;\n\n // disable webpack exec to prevent automatically executing the entry module\n self.__DISABLE_WEBPACK_EXEC__ = true;\n // add a custom webpack require function to load remote components from multiple bundles / zones\n if (\n typeof self.__webpack_require__ !== 'function' &&\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n self.__webpack_require__ = (remoteId: string) => {\n const re = /\\[(?<bundle>[a-zA-Z0-9-_]+)\\] (?<id>.*)/;\n const match = re.exec(remoteId);\n const bundle = match?.groups?.bundle;\n const id = match?.groups?.id;\n if (!(id && bundle)) {\n throw new Error(`Module not found: \"${remoteId}\"`);\n }\n if (typeof self.__remote_webpack_require__?.[bundle] !== 'function') {\n throw new Error(`Remote component loading error \"${bundle}\"`);\n }\n return self.__remote_webpack_require__[bundle](id);\n };\n // not used but required by react-server-dom-webpack\n self.__webpack_chunk_load__ = () => {\n return Promise.resolve([]);\n };\n }\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n async function preloadScripts(\n scripts: HTMLScriptElement[],\n url: URL,\n bundle: string,\n _: string,\n ) {\n // we need to properly attach script elements to the document to load the remote component bundles\n // we need to wait for all scripts to load before we can hydrate the remote component\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newScript = document.createElement('script');\n newScript.onload = () => {\n resolve();\n };\n newScript.onerror = () => {\n reject(\n new Error(\n `Failed to load script ${script.src} for remote component`,\n ),\n );\n };\n const scriptSrc =\n script.getAttribute('src') || script.getAttribute('data-src');\n if (scriptSrc) {\n newScript.src = new URL(\n scriptSrc.replace(/\\/_next\\/\\[(?:.+)\\](?:%20| )/, '/_next/'),\n url,\n ).href;\n }\n newScript.async = true;\n document.body.appendChild(newScript);\n // safe to remove the original script element\n script.parentElement?.removeChild(script);\n });\n }),\n );\n\n // module resolution map for the shared modules\n const resolve = {\n '/react/index.js': (await import('react')).default,\n '/react/jsx-dev-runtime.js': (await import('react/jsx-dev-runtime'))\n .default,\n '/react/jsx-runtime.js': (await import('react/jsx-runtime')).default,\n '/react-dom/index.js': (await import('react-dom')).default,\n '/react-dom/client.js': (await import('react-dom/client')).default,\n };\n\n // apply shared modules to the bundle\n applySharedModules(bundle, resolve);\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","export const DEFAULT_ROUTE = '/';\n\nexport const RUNTIME_WEBPACK = 'webpack';\nexport const RUNTIME_TURBOPACK = 'turbopack';\n\nexport const REMOTE_COMPONENT_REGEX =\n /(?<prefix>.*?)\\[(?<bundle>[^\\]]+)\\](?:%20| )(?<id>.+)/;\n\nexport function getBundleKey(bundle: string): string {\n return bundle.replace(/-/g, '_');\n}\n\nexport type Runtime = typeof RUNTIME_WEBPACK | typeof RUNTIME_TURBOPACK;\n","import type { GlobalScope } from './types';\nimport {\n type Runtime,\n RUNTIME_TURBOPACK,\n RUNTIME_WEBPACK,\n REMOTE_COMPONENT_REGEX,\n getBundleKey,\n} from './const';\n\n/**\n * Sets up webpack runtime environment for remote components\n */\nexport async function setupWebpackRuntime(\n runtime: Runtime,\n scripts: { src: string | null }[] = [],\n url: URL = new URL(location.href),\n bundle?: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n): Promise<void> {\n const self = globalThis as GlobalScope;\n self.__DISABLE_WEBPACK_EXEC__ = true;\n\n if (!self.__remote_bundle_url__) {\n // eslint-disable-next-line camelcase\n self.__remote_bundle_url__ = {};\n }\n self.__remote_bundle_url__[bundle ?? 'default'] = url;\n\n await initializeSharedModules(bundle ?? 'default', shared, remoteShared);\n if (\n typeof self.__webpack_require__ !== 'function' ||\n self.__webpack_require_type__ !== 'turbopack'\n ) {\n if (\n !self.__original_webpack_require__ &&\n !self.__original_webpack_chunk_load__\n ) {\n // eslint-disable-next-line camelcase\n self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;\n // eslint-disable-next-line camelcase\n self.__original_webpack_require__ = self.__webpack_require__;\n }\n\n self.__webpack_chunk_load__ = createChunkLoader(runtime);\n self.__webpack_require__ = createModuleRequire(runtime);\n // eslint-disable-next-line camelcase\n self.__webpack_require_type__ = runtime;\n\n if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {\n const remoteBundle = bundle ?? 'default';\n self.__remote_webpack_require__[remoteBundle] =\n self.__webpack_require__ as (remoteId: string | number) => unknown;\n self.__remote_webpack_require__[remoteBundle].type = 'turbopack';\n }\n }\n await Promise.all(\n scripts.map((script) => {\n if (script.src) {\n return self.__webpack_chunk_load__?.(script.src, bundle);\n }\n return Promise.resolve(undefined);\n }),\n );\n}\n\n/**\n * Creates chunk loader function for webpack runtime\n */\nfunction createChunkLoader(\n runtime: Runtime,\n): (chunkId: string) => Promise<unknown> | undefined {\n // eslint-disable-next-line camelcase\n return function __turbopack_chunk_load__(\n chunkId: string,\n scriptBundle?: string,\n ) {\n if (runtime === RUNTIME_WEBPACK) {\n // all scripts are already loaded for this remote\n return Promise.resolve(undefined);\n }\n const {\n bundle,\n id: path,\n prefix,\n } = REMOTE_COMPONENT_REGEX.exec(chunkId)?.groups ?? {\n bundle: scriptBundle ?? '',\n id: chunkId,\n };\n const self = globalThis as GlobalScope;\n const url = new URL(\n path\n ? `${prefix ?? ''}${path}`.replace(\n /(?<char>[^:])(?<double>\\/\\/)/g,\n '$1/',\n )\n : '/',\n self.__remote_bundle_url__?.[bundle ?? 'default'] ??\n new URL(location.origin),\n ).href;\n if (url.endsWith('.css')) {\n return;\n }\n return new Promise((resolve, reject) => {\n fetch(url)\n .then((res) => res.text())\n .then((code) => {\n if (code.includes('globalThis.TURBOPACK')) {\n return handleTurbopackChunk(code, bundle ?? '', url);\n }\n })\n .then(resolve)\n .catch(reject);\n });\n };\n}\n\n/**\n * Handles Turbopack chunk loading\n */\nasync function handleTurbopackChunk(\n code: string,\n bundle: string,\n url: string,\n): Promise<void> {\n // skip this chunk as it is not needed for remote components\n if (\n code.includes('/next/dist/client/app-next-turbopack.js') &&\n code.includes('importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS')\n ) {\n // remove preload links for this chunk\n const preloadLinks = document.querySelectorAll(\n `link[rel=\"preload\"][href=\"${new URL(url).pathname}\"]`,\n );\n preloadLinks.forEach((preloadLink) => preloadLink.remove());\n return;\n }\n\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n\n // replace global variables with bundle-specific ones\n const transformedCode = code\n .replace(/globalThis\\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`)\n .replace(\n /TURBOPACK_WORKER_LOCATION/g,\n `TURBOPACK_WORKER_LOCATION_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_NEXT_CHUNK_URLS/g,\n `TURBOPACK_NEXT_CHUNK_URLS_${bundleKey}`,\n )\n .replace(\n /TURBOPACK_CHUNK_UPDATE_LISTENERS/g,\n `TURBOPACK_CHUNK_UPDATE_LISTENERS_${bundleKey}`,\n )\n .replace(/__next_require__/g, `__${bundleKey}_next_require__`)\n .replace(\n /\\/\\/# sourceMappingURL=(?<name>.+)(?<optional>\\._)?\\.js\\.map/g,\n `//# sourceMappingURL=${\n new URL(\n '.',\n new URL(\n url,\n self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin),\n ),\n ).href\n }$1$2.js.map`,\n );\n\n // load the script dynamically using a Blob URL\n await new Promise<void>((scriptResolve, scriptReject) => {\n const blob = new Blob([transformedCode], {\n type: 'application/javascript; charset=UTF-8',\n });\n const scriptUrl = URL.createObjectURL(blob);\n const script = document.createElement('script');\n script.src = scriptUrl;\n script.async = true;\n script.onload = () => {\n URL.revokeObjectURL(scriptUrl);\n scriptResolve(undefined);\n };\n script.onerror = (error) => {\n URL.revokeObjectURL(scriptUrl);\n scriptReject(\n new Error(\n `Failed to load script: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n };\n document.head.appendChild(script);\n });\n const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`] as\n | { chunks: string[] }[]\n | undefined;\n const loadChunkLists = [] as (Promise<unknown> | undefined)[];\n while (chunkLists?.length) {\n const { chunks } = chunkLists.shift() ?? { chunks: [] };\n if (chunks.length > 0) {\n chunks.forEach((id: string) => {\n const chunkLoadResult = self.__webpack_chunk_load__?.(\n `[${bundle}] ${url.slice(0, url.indexOf('/_next'))}/_next/${id}`,\n );\n if (chunkLoadResult) {\n loadChunkLists.push(chunkLoadResult);\n }\n });\n }\n }\n if (loadChunkLists.length > 0) {\n await Promise.all(loadChunkLists);\n }\n}\n\n/**\n * Creates module require function for webpack runtime\n */\nfunction createModuleRequire(runtime: Runtime): (id: string) => unknown {\n return (id: string) => {\n const self = globalThis as GlobalScope;\n const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)\n ?.groups ?? { bundle: 'default', id };\n try {\n if (runtime === RUNTIME_WEBPACK && bundle && moduleId) {\n return self.__remote_webpack_require__?.[bundle]?.(moduleId);\n }\n const sharedModule = getSharedModule(bundle ?? 'default', moduleId ?? id);\n if (sharedModule) {\n return sharedModule;\n }\n if (bundle && moduleId) {\n return handleTurbopackModule(bundle, moduleId, id);\n }\n throw new Error(`Module ${id} not found`);\n } catch {\n try {\n return self.__original_webpack_require__?.(id);\n } catch {\n throw new Error(\n `Module ${id} not found in remote component bundle ${bundle}`,\n );\n }\n }\n };\n}\n\nfunction initializeSharedModules(\n bundle: string,\n shared: Record<string, () => Promise<unknown>> = {},\n remoteShared: Record<string, string> = {},\n) {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, Record<string, unknown>>;\n __next_f?: unknown[];\n };\n // eslint-disable-next-line camelcase\n self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};\n\n if (!self.__remote_shared_modules__[bundle]) {\n self.__remote_shared_modules__[bundle] = {};\n }\n\n // ensure that the shared modules are initialized\n return Promise.all(\n Object.entries(remoteShared).map(async ([id, module]) => {\n if (self.__remote_shared_modules__?.[bundle]) {\n self.__remote_shared_modules__[bundle][\n id.replace('[app-ssr]', '[app-client]')\n ] = await (\n shared[module] ??\n (() =>\n Promise.resolve(\n new Proxy(\n {},\n {\n get(_, prop: string) {\n if (prop !== 'then') {\n // eslint-disable-next-line no-console\n console.warn(\n `Shared dependency \"${module}\" not found for \"${bundle}\" when trying to import \"${prop}\".`,\n );\n }\n },\n },\n ),\n ))\n )();\n }\n }),\n );\n}\n\n/**\n * Returns shared modules for common dependencies\n */\nfunction getSharedModule(bundle: string, id: string): unknown {\n const self = globalThis as {\n __remote_shared_modules__?: Record<string, unknown>;\n };\n\n for (const [key, value] of Object.entries(\n self.__remote_shared_modules__?.[bundle] ?? {},\n )) {\n if (id.includes(key)) {\n return value;\n }\n }\n return null;\n}\n\n/**\n * Handles Turbopack module resolution\n */\nfunction handleTurbopackModule(\n bundle: string,\n moduleId: string,\n id: string,\n): unknown {\n const self = globalThis as GlobalScope;\n const bundleKey = getBundleKey(bundle);\n const modules = (\n self[`TURBOPACK_${bundleKey}`] as\n | [unknown, Record<string, unknown>][]\n | undefined\n )?.find((mod: [unknown, Record<string, unknown>]) => moduleId in mod[1])?.[1];\n const moduleInit = modules?.[moduleId];\n if (typeof moduleInit !== 'function') {\n throw new Error(\n `Module ${id} not found in bundle ${bundle} with id ${moduleId}`,\n );\n }\n const exports = {} as Record<string, unknown>;\n moduleInit({\n // HMR not implemented for Remote Components\n k: {\n register() {\n // omit\n },\n registerExports() {\n // omit\n },\n signature() {\n return () => {\n // omit\n };\n },\n },\n s(m: Record<string, () => unknown>) {\n for (const [key, value] of Object.entries(m)) {\n exports[key] = value;\n }\n },\n i(iid: string) {\n return self.__webpack_require__?.(`[${bundle}] ${iid}`);\n },\n r(rid: string) {\n return self.__webpack_require__?.(`[${bundle}] ${rid}`);\n },\n m: {\n exports,\n },\n });\n for (const [key, value] of Object.entries(exports)) {\n if (typeof value === 'function') {\n exports[key] = value();\n }\n }\n return exports;\n}\n","import { applySharedModules } from '../../shared/webpack/shared-modules';\nimport { nextClientPagesLoader } from '../../shared/webpack/next-client-pages-loader';\nimport { setupWebpackRuntime } from '../../shared/client/webpack-adapter';\n\n// initializer for the turbopack runtime to be able to access modules\n// required to run exposed client components of the remote component\nexport async function turbopackRuntime(\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n // conditional flag to disable webpack exec\n __DISABLE_WEBPACK_EXEC__: boolean;\n // webpack chunk loading function\n __webpack_chunk_load__: () => Promise<[]>;\n __remote_component_shared__?: Record<string, () => Promise<unknown>>;\n } & Record<string, string[]>;\n\n await setupWebpackRuntime(\n 'turbopack',\n [],\n url,\n bundle,\n self.__remote_component_shared__ ?? shared,\n remoteShared,\n );\n // we can only import react-server-dom-webpack after initializing the __webpack_require__ and __webpack_chunk_load__ functions\n const {\n default: { createFromReadableStream },\n } = await import('react-server-dom-webpack/client.browser');\n\n function preloadScripts(scripts: HTMLScriptElement[], __: URL) {\n return setupWebpackRuntime(\n 'turbopack',\n scripts.map((script) => ({\n src:\n script.getAttribute('src') ||\n script.getAttribute('data-src') ||\n script.src,\n })),\n url,\n bundle,\n self.__remote_component_shared__ ?? shared,\n remoteShared,\n );\n }\n\n return {\n self,\n createFromReadableStream,\n applySharedModules,\n nextClientPagesLoader,\n preloadScripts,\n };\n}\n","import { hydrateRoot } from 'react-dom/client';\nimport { getRuntime, type Runtime } from './runtime';\n\nif (typeof HTMLElement !== 'undefined') {\n class RemoteComponent extends HTMLElement {\n name: string;\n bundle: string;\n fallbackSlot: HTMLSlotElement;\n __next: HTMLDivElement | null = null;\n fouc: HTMLStyleElement | null = null;\n isLoading = false;\n\n constructor() {\n super();\n // use the shadow DOM to encapsulate the component\n this.attachShadow({ mode: 'open' });\n\n // create a slot element to allow the remote component to use the default slot\n this.fallbackSlot = document.createElement('slot');\n this.shadowRoot?.appendChild(this.fallbackSlot);\n\n this.name = this.getAttribute('name') || '__vercel_remote_component';\n this.bundle = 'default';\n\n // load when the custom element has an src, data-ssr attribute or contains an SSR remote component div\n if (\n this.hasAttribute('src') ||\n this.querySelector('div#__REMOTE_COMPONENT__') ||\n this.hasAttribute('data-ssr')\n ) {\n // start loading and hydration\n this.load().catch((e) => {\n throw new Error(`Failed to load remote component: ${e}`);\n });\n }\n }\n\n static get observedAttributes() {\n return ['src'];\n }\n\n // watch for src attribute changes\n // this is required to reload the remote component when the src attribute is added later\n // this is for rendering the custom element using React\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (name === 'src' && oldValue !== newValue) {\n this.load().catch((e) => {\n throw new Error(`Failed to load remote component: ${e}`);\n });\n }\n }\n\n async load() {\n // prevent multiple loads\n if (this.isLoading) {\n return;\n }\n\n this.isLoading = true;\n const src = this.getAttribute('src');\n const remoteComponentChild = this.querySelector(\n 'div#__REMOTE_COMPONENT__',\n );\n\n if (!src && !remoteComponentChild) {\n throw new Error('src attribute is required');\n }\n\n let url: URL | null = null;\n let html = this.innerHTML;\n\n if (!remoteComponentChild && src) {\n url = new URL(src, window.location.href);\n\n // fetch the remote component\n const fetchInit = {\n method: 'GET',\n headers: {\n Accept: 'text/html',\n // pass the public address of the remote component to the server used for module map mutation\n 'Vercel-Remote-Component-Url': url.href,\n },\n credentials: this.getAttribute('credentials') || 'same-origin',\n } as RequestInit;\n\n const res = await fetch(url, fetchInit);\n\n if (!res.ok) {\n throw new Error(\n `Failed to fetch remote component \"${this.name}\": ${res.status}`,\n );\n }\n\n // get the full HTML content as a string\n html = await res.text();\n }\n // create a virtual element which will be used to parse the HTML and extract the component and RSC flight data\n const doc = document.createElement('div');\n doc.innerHTML = html;\n\n // reference to the remote component content\n const component =\n doc.querySelector(`div[data-bundle][data-route][id^=\"${this.name}\"]`) ??\n // fallback to the first element with the data-bundle and data-route attributes when not using a named remote component\n doc.querySelector('div[data-bundle][data-route]') ??\n // fallback to Next.js Pages Router\n doc.querySelector('div#__next');\n const nextData = JSON.parse(\n (\n doc.querySelector('#__NEXT_DATA__') ??\n doc.querySelector('#__REMOTE_NEXT_DATA__')\n )?.textContent ?? 'null',\n ) as {\n props: {\n pageProps: Record<string, unknown>;\n __REMOTE_COMPONENT__?: {\n bundle: string;\n runtime: 'turbopack' | 'webpack';\n };\n };\n page: string;\n buildId: string;\n } | null;\n\n // when using a Next.js Pages Router remote application in development mode\n // we hide the remote component to prevent flickering\n // until the CSS is loaded for the remote component\n if (nextData && nextData.buildId === 'development') {\n this.fouc = document.createElement('style');\n this.fouc.textContent = `:host { display: none; }`;\n this.shadowRoot?.appendChild(this.fouc);\n }\n\n this.name =\n component?.getAttribute('id')?.replace(/_ssr$/, '') ||\n (nextData ? '__next' : this.name);\n // reference to the RSC flight data\n const rsc = doc.querySelector(`#${this.name}_rsc`);\n\n // reference to the bundle containing the client components\n this.bundle =\n component?.getAttribute('data-bundle') ||\n nextData?.props.__REMOTE_COMPONENT__?.bundle ||\n this.bundle;\n\n // add remote component metadata information at the custom element\n const metadata = document.createElement('script');\n metadata.type = 'application/json';\n metadata.setAttribute('data-remote-component', '');\n metadata.textContent = JSON.stringify({\n name: this.name,\n bundle: this.bundle,\n route: component?.getAttribute('data-route') ?? nextData?.page ?? '/',\n runtime:\n component?.getAttribute('data-runtime') ??\n nextData?.props.__REMOTE_COMPONENT__?.runtime,\n });\n this.parentNode?.insertBefore(metadata, this);\n\n const remoteSharedEl = doc.querySelector(`#${this.name}_shared`);\n const remoteShared = (JSON.parse(remoteSharedEl?.textContent ?? '{}') ??\n {}) as Record<string, string>;\n remoteSharedEl?.parentElement?.removeChild(remoteSharedEl);\n\n if (!component || !(rsc || nextData)) {\n throw new Error(`Failed to find component with id \"${this.name}\"`);\n }\n\n // store the original loading content of the custom element\n // this is required to remove the loading content after the remote component is loaded\n const removable = Array.from(this.childNodes);\n\n // reference to all link elements in the remote component\n const links = doc.querySelectorAll<HTMLLinkElement>('link[href]');\n\n // attach each link element to the shadow DOM to load the styles\n await Promise.all(\n Array.from(links).map((link) => {\n return new Promise<void>((resolve, reject) => {\n const newLink = document.createElement('link');\n newLink.onload = () => {\n resolve();\n };\n newLink.onerror = () => {\n reject(\n new Error(\n `Failed to load link ${link.href} for remote component`,\n ),\n );\n };\n for (const attr of link.attributes) {\n if (attr.name === 'href') {\n newLink.setAttribute(\n attr.name,\n new URL(attr.value, url ?? location.origin).href,\n );\n } else {\n newLink.setAttribute(attr.name, attr.value);\n }\n }\n this.shadowRoot?.appendChild(newLink);\n });\n }),\n );\n\n // attach the remote component content to the shadow DOM\n Array.from(component.children).forEach((el) => {\n this.shadowRoot?.appendChild(el);\n });\n\n // clear the loading content of the shadow DOM root\n for (const el of removable) {\n el.parentElement?.removeChild(el);\n }\n this.shadowRoot?.removeChild(this.fallbackSlot);\n\n const {\n self,\n createFromReadableStream,\n nextClientPagesLoader,\n preloadScripts,\n } = await getRuntime(\n (component.getAttribute('data-runtime') ?? 'webpack') as Runtime,\n url ?? new URL(location.href),\n this.bundle,\n {\n react: async () => (await import('react')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react-dom/client': async () =>\n (await import('react-dom/client')).default,\n },\n remoteShared,\n );\n\n const scripts = doc.querySelectorAll<HTMLScriptElement>(\n 'script[src],script[data-src]',\n );\n if (!url) {\n url = new URL(\n component.getAttribute('data-route') ?? '/',\n window.location.href,\n );\n }\n\n await preloadScripts(Array.from(scripts), url, this.bundle, this.name);\n\n // using RSC hydration if the RSC flight data is available\n if (rsc) {\n // remove the RSC flight data script element\n rsc.parentElement?.removeChild(rsc);\n\n // reload the RSC flight data script to eval it's content\n const rscClone = document.createElement('script');\n rscClone.id = `${this.name}_rsc`;\n rscClone.textContent = rsc.textContent;\n document.body.appendChild(rscClone);\n\n let cache: React.ReactNode;\n // React component to convert the RSC flight data into a React component\n const RemoteComponentFromReadableStream = ({\n name,\n }: {\n name: string;\n }) => {\n const Component =\n cache ??\n // cache the component to avoid reloading the RSC flight data\n (cache = createFromReadableStream(\n // convert the RSC flight data array into a ReadableStream\n new ReadableStream({\n type: 'bytes',\n start(controller) {\n const encoder = new TextEncoder();\n // get the RSC flight data from the global scope\n // the RSC flight data is stored in an array\n // fallback to an empty RSC payload if the data is not found\n (self[name] ?? [`0:[null]\\n`]).forEach((chunk) => {\n // encode the chunk to a byte buffer\n controller.enqueue(encoder.encode(chunk));\n });\n // close the stream when all chunks are enqueued\n controller.close();\n },\n }),\n ) as React.ReactNode);\n\n // React can handle the component reference and will wait for the component to be ready\n return Component;\n };\n\n // hydrate the remote component using the RSC flight data\n hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.shadowRoot,\n <RemoteComponentFromReadableStream name={this.name} />,\n );\n } else if (nextData) {\n // using Next.js client pages loader if the Next.js hydration data is available\n const { Component, App } = nextClientPagesLoader(\n this.bundle,\n nextData.page,\n this.shadowRoot,\n );\n\n // if we have the component, we can hydrate it\n if (Component) {\n hydrateRoot(\n // hydrateRoot expects a document or element, but it works for the shadow DOM too\n // @ts-expect-error support for shadow DOM\n this.shadowRoot,\n App ? (\n <App Component={Component} {...nextData.props} />\n ) : (\n <Component {...nextData.props} />\n ),\n );\n }\n\n // remove the FOUC workaround style element to show the remote component\n // this is only for development mode\n if (this.fouc) {\n this.shadowRoot?.removeChild(this.fouc);\n }\n }\n\n this.isLoading = false;\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n","export type Runtime = 'webpack' | 'turbopack' | 'esm';\n\nexport async function getRuntime(\n type: Runtime,\n url: URL,\n bundle?: string,\n shared?: Record<string, () => Promise<unknown>>,\n remoteShared?: Record<string, string>,\n) {\n // minimally mock process.env for browser environments\n if (typeof globalThis.process === 'undefined') {\n globalThis.process = {\n env: {},\n } as NodeJS.Process;\n }\n\n if (type === 'webpack') {\n const { webpackRuntime } = await import(`./webpack`);\n return webpackRuntime();\n } else if (type === 'turbopack') {\n const { turbopackRuntime } = await import(`./turbopack`);\n return turbopackRuntime(url, bundle, shared, remoteShared);\n }\n throw new Error(`Runtime ${type} is not supported`);\n}\n"],"mappings":";;;;;;;;;;;AAKO,SAAS,mBACd,QACA,SACA;AAEA,QAAM,OAAO;AAab,MAAI,KAAK,6BAA6B,MAAM,GAAG;AAC7C,UAAM,cAAc,OAAO;AAAA,MACzB,KAAK,gCAAgC,MAAM,KACzC,KAAK,2BAA2B,MAAM,EAAE,KACxC,CAAC;AAAA,IACL;AAEA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,YAAM,MAAM,YAAY,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC;AACrD,eAAS,MAAM,KAAK;AAClB,cAAM,gBAAgB,KAAK,2BAA2B,MAAM;AAC5D,YAAI,cAAc,GAAG;AAGnB,cAAI,KAAK,gCAAgC,MAAM,IAAI,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