remote-components 0.2.2 → 0.3.1

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.
Files changed (100) hide show
  1. package/dist/config/nextjs.cjs +2 -4
  2. package/dist/config/nextjs.cjs.map +1 -1
  3. package/dist/config/nextjs.d.ts +1 -1
  4. package/dist/config/nextjs.js +2 -4
  5. package/dist/config/nextjs.js.map +1 -1
  6. package/dist/host/html.cjs +128 -112
  7. package/dist/host/html.cjs.map +1 -1
  8. package/dist/host/html.js +128 -115
  9. package/dist/host/html.js.map +1 -1
  10. package/dist/host/nextjs/app/client-only.cjs +233 -259
  11. package/dist/host/nextjs/app/client-only.cjs.map +1 -1
  12. package/dist/host/nextjs/app/client-only.js +234 -260
  13. package/dist/host/nextjs/app/client-only.js.map +1 -1
  14. package/dist/host/nextjs/app.cjs +5 -6
  15. package/dist/host/nextjs/app.cjs.map +1 -1
  16. package/dist/host/nextjs/app.js +5 -6
  17. package/dist/host/nextjs/app.js.map +1 -1
  18. package/dist/host/nextjs/pages.cjs +7 -19
  19. package/dist/host/nextjs/pages.cjs.map +1 -1
  20. package/dist/host/nextjs/pages.js +11 -20
  21. package/dist/host/nextjs/pages.js.map +1 -1
  22. package/dist/host/react.cjs +101 -93
  23. package/dist/host/react.cjs.map +1 -1
  24. package/dist/host/react.js +101 -93
  25. package/dist/host/react.js.map +1 -1
  26. package/dist/internal/host/nextjs/app-client.cjs +3 -8
  27. package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
  28. package/dist/internal/host/nextjs/app-client.js +4 -9
  29. package/dist/internal/host/nextjs/app-client.js.map +1 -1
  30. package/dist/internal/host/nextjs/dom-flight.cjs +16 -7
  31. package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -1
  32. package/dist/internal/host/nextjs/dom-flight.d.ts +2 -2
  33. package/dist/internal/host/nextjs/dom-flight.js +16 -7
  34. package/dist/internal/host/nextjs/dom-flight.js.map +1 -1
  35. package/dist/internal/host/nextjs/image-shared.cjs +25 -15
  36. package/dist/internal/host/nextjs/image-shared.cjs.map +1 -1
  37. package/dist/internal/host/nextjs/image-shared.d.ts +19 -6
  38. package/dist/internal/host/nextjs/image-shared.js +24 -14
  39. package/dist/internal/host/nextjs/image-shared.js.map +1 -1
  40. package/dist/internal/host/react/hooks/use-resolve-client-url.cjs +1 -5
  41. package/dist/internal/host/react/hooks/use-resolve-client-url.cjs.map +1 -1
  42. package/dist/internal/host/react/hooks/use-resolve-client-url.d.ts +1 -4
  43. package/dist/internal/host/react/hooks/use-resolve-client-url.js +1 -5
  44. package/dist/internal/host/react/hooks/use-resolve-client-url.js.map +1 -1
  45. package/dist/internal/host/server/fetch-remote-component.cjs +164 -149
  46. package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
  47. package/dist/internal/host/server/fetch-remote-component.js +166 -149
  48. package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
  49. package/dist/internal/host/shared/polyfill.cjs +10 -65
  50. package/dist/internal/host/shared/polyfill.cjs.map +1 -1
  51. package/dist/internal/host/shared/polyfill.d.ts +1 -3
  52. package/dist/internal/host/shared/polyfill.js +9 -63
  53. package/dist/internal/host/shared/polyfill.js.map +1 -1
  54. package/dist/internal/host/shared/remote-image-loader.cjs +53 -0
  55. package/dist/internal/host/shared/remote-image-loader.cjs.map +1 -0
  56. package/dist/internal/host/shared/remote-image-loader.d.ts +30 -0
  57. package/dist/internal/host/shared/remote-image-loader.js +29 -0
  58. package/dist/internal/host/shared/remote-image-loader.js.map +1 -0
  59. package/dist/internal/runtime/constants.cjs +6 -6
  60. package/dist/internal/runtime/constants.cjs.map +1 -1
  61. package/dist/internal/runtime/constants.d.ts +3 -3
  62. package/dist/internal/runtime/constants.js +4 -4
  63. package/dist/internal/runtime/constants.js.map +1 -1
  64. package/dist/internal/runtime/html/parse-remote-html.cjs +11 -15
  65. package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -1
  66. package/dist/internal/runtime/html/parse-remote-html.d.ts +2 -12
  67. package/dist/internal/runtime/html/parse-remote-html.js +17 -15
  68. package/dist/internal/runtime/html/parse-remote-html.js.map +1 -1
  69. package/dist/internal/runtime/loaders/script-loader.cjs +2 -2
  70. package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -1
  71. package/dist/internal/runtime/loaders/script-loader.js +1 -1
  72. package/dist/internal/runtime/loaders/script-loader.js.map +1 -1
  73. package/dist/internal/runtime/metadata.cjs +42 -0
  74. package/dist/internal/runtime/metadata.cjs.map +1 -1
  75. package/dist/internal/runtime/metadata.d.ts +21 -1
  76. package/dist/internal/runtime/metadata.js +38 -0
  77. package/dist/internal/runtime/metadata.js.map +1 -1
  78. package/dist/internal/runtime/patterns.cjs +38 -0
  79. package/dist/internal/runtime/patterns.cjs.map +1 -0
  80. package/dist/internal/runtime/patterns.d.ts +5 -0
  81. package/dist/internal/runtime/patterns.js +12 -0
  82. package/dist/internal/runtime/patterns.js.map +1 -0
  83. package/dist/internal/runtime/turbopack/chunk-loader.cjs +4 -3
  84. package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
  85. package/dist/internal/runtime/turbopack/chunk-loader.js +1 -1
  86. package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
  87. package/dist/internal/runtime/turbopack/webpack-runtime.cjs +11 -2
  88. package/dist/internal/runtime/turbopack/webpack-runtime.cjs.map +1 -1
  89. package/dist/internal/runtime/turbopack/webpack-runtime.js +10 -2
  90. package/dist/internal/runtime/turbopack/webpack-runtime.js.map +1 -1
  91. package/dist/remote/nextjs/app.cjs +2 -1
  92. package/dist/remote/nextjs/app.cjs.map +1 -1
  93. package/dist/remote/nextjs/app.js +2 -1
  94. package/dist/remote/nextjs/app.js.map +1 -1
  95. package/package.json +1 -1
  96. package/dist/internal/host/nextjs/image-impl.cjs +0 -64
  97. package/dist/internal/host/nextjs/image-impl.cjs.map +0 -1
  98. package/dist/internal/host/nextjs/image-impl.d.ts +0 -10
  99. package/dist/internal/host/nextjs/image-impl.js +0 -40
  100. package/dist/internal/host/nextjs/image-impl.js.map +0 -1
package/dist/host/html.js CHANGED
@@ -201,17 +201,17 @@ var init_utils = __esm({
201
201
  function getBundleKey(bundle) {
202
202
  return escapeString(bundle);
203
203
  }
204
- var DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT, REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE;
204
+ var DEFAULT_BUNDLE_NAME, DEFAULT_COMPONENT_NAME, DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT;
205
205
  var init_constants2 = __esm({
206
206
  "src/runtime/constants.ts"() {
207
207
  "use strict";
208
208
  init_utils();
209
+ DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
210
+ DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
209
211
  DEFAULT_ROUTE = "/";
210
212
  RUNTIME_WEBPACK = "webpack";
211
213
  RUNTIME_TURBOPACK = "turbopack";
212
214
  RUNTIME_SCRIPT = "script";
213
- REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
214
- NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
215
215
  }
216
216
  });
217
217
 
@@ -402,26 +402,40 @@ var init_next_client_pages_loader = __esm({
402
402
  }
403
403
  });
404
404
 
405
- // src/host/shared/polyfill.tsx
406
- import { jsx } from "react/jsx-runtime";
407
- function applyBundleUrlToSrc(bundle, src) {
405
+ // src/host/shared/remote-image-loader.ts
406
+ function getRemoteBundleOrigin(bundle) {
408
407
  const self = globalThis;
409
- if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {
410
- return src;
411
- }
412
- const { assetPrefix, path } = /^(?<assetPrefix>.*?)\/_next\/(?<path>.*)/.exec(src)?.groups ?? {};
413
- if (!path) {
414
- return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;
415
- }
416
- return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ""}${assetPrefix}/_next/${path}`;
408
+ return self.__remote_bundle_url__?.[bundle]?.origin ?? "";
417
409
  }
418
- function applyBundleUrlToImagePropsSrc(bundle, src) {
419
- if (typeof src === "string") {
420
- return applyBundleUrlToSrc(bundle, src);
421
- }
422
- const propSrc = src;
423
- return applyBundleUrlToSrc(bundle, propSrc.src);
410
+ function createRemoteImageLoader(bundle, resolveClientUrl) {
411
+ const loader = Object.assign(
412
+ ({
413
+ config,
414
+ src,
415
+ width,
416
+ quality
417
+ }) => {
418
+ const q = quality ?? 75;
419
+ const remoteOrigin = getRemoteBundleOrigin(bundle);
420
+ const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
421
+ const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
422
+ const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
423
+ return resolveClientUrl?.(url) ?? url;
424
+ },
425
+ // Signals to getImgProps that this is a default loader (not a user-defined
426
+ // one), enabling srcSet generation with device/image sizes from the config.
427
+ { __next_img_default: true }
428
+ );
429
+ return loader;
424
430
  }
431
+ var init_remote_image_loader = __esm({
432
+ "src/host/shared/remote-image-loader.ts"() {
433
+ "use strict";
434
+ }
435
+ });
436
+
437
+ // src/host/shared/polyfill.tsx
438
+ import { jsx } from "react/jsx-runtime";
425
439
  function sharedPolyfills(shared, resolveClientUrl) {
426
440
  const self = globalThis;
427
441
  const polyfill = {
@@ -512,17 +526,13 @@ function sharedPolyfills(shared, resolveClientUrl) {
512
526
  },
513
527
  __esModule: true
514
528
  })),
515
- "next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
516
- Image: imageImpl(bundle, resolveClientUrl),
517
- __esModule: true
518
- })),
519
- "next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
520
- default: imageImpl(bundle, resolveClientUrl),
521
- getImageProps: (_imgProps) => {
522
- throw new Error(
523
- "Next.js getImageProps() is not implemented in remote components"
524
- );
525
- },
529
+ // Instead of replacing next/image entirely, we let the real Next.js Image
530
+ // component load from the remote bundle and only replace its default loader.
531
+ // This gives us full next/image fidelity (fill, priority, srcSet, blur
532
+ // placeholders, error handling) while routing image optimization through the
533
+ // remote app's /_next/image endpoint.
534
+ "next/dist/shared/lib/image-loader": self.__remote_component_host_shared_modules__?.["next/dist/shared/lib/image-loader"] ?? shared?.["next/dist/shared/lib/image-loader"] ?? ((bundle) => Promise.resolve({
535
+ default: createRemoteImageLoader(bundle, resolveClientUrl),
526
536
  __esModule: true
527
537
  })),
528
538
  "next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
@@ -562,47 +572,25 @@ function sharedPolyfills(shared, resolveClientUrl) {
562
572
  polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
563
573
  polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
564
574
  polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
565
- polyfill["next/dist/api/image"] = polyfill["next/dist/client/image-component"];
575
+ polyfill["next/dist/esm/shared/lib/image-loader"] = polyfill["next/dist/shared/lib/image-loader"];
566
576
  polyfill["next/script"] = polyfill["next/dist/client/script"];
567
577
  return polyfill;
568
578
  }
569
- var imageImpl;
570
579
  var init_polyfill = __esm({
571
580
  "src/host/shared/polyfill.tsx"() {
572
581
  "use strict";
582
+ init_remote_image_loader();
573
583
  init_logger();
574
- imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
575
- fill: _fill,
576
- loader: _loader,
577
- quality: _quality,
578
- priority: _priority,
579
- loading: _loading,
580
- placeholder: _placeholder,
581
- blurDataURL: _blurDataURL,
582
- unoptimized: _unoptimized,
583
- overrideSrc: _overrideSrc,
584
- src,
585
- ...props
586
- }) {
587
- const newSrc = applyBundleUrlToImagePropsSrc(
588
- bundle,
589
- typeof src === "string" ? src : src.src
590
- );
591
- const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
592
- return (
593
- // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
594
- /* @__PURE__ */ jsx(
595
- "img",
596
- {
597
- decoding: "async",
598
- style: { color: "transparent" },
599
- ...props,
600
- src: proxiedSrc,
601
- suppressHydrationWarning: true
602
- }
603
- )
604
- );
605
- };
584
+ }
585
+ });
586
+
587
+ // src/runtime/patterns.ts
588
+ var REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE;
589
+ var init_patterns = __esm({
590
+ "src/runtime/patterns.ts"() {
591
+ "use strict";
592
+ REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
593
+ NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
606
594
  }
607
595
  });
608
596
 
@@ -642,7 +630,7 @@ async function loadScripts(scripts, resolveClientUrl) {
642
630
  var init_script_loader = __esm({
643
631
  "src/runtime/loaders/script-loader.ts"() {
644
632
  "use strict";
645
- init_constants2();
633
+ init_patterns();
646
634
  init_protected_rc_fallback();
647
635
  init_error();
648
636
  init_logger();
@@ -743,15 +731,15 @@ var init_webpack = __esm({
743
731
  init_apply_shared_modules();
744
732
  init_next_client_pages_loader();
745
733
  init_polyfill();
746
- init_constants2();
747
734
  init_script_loader();
735
+ init_patterns();
748
736
  init_error();
749
737
  }
750
738
  });
751
739
 
752
740
  // src/runtime/turbopack/patterns.ts
753
741
  var REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_RESOLVE_RE, ASYNC_MODULE_ALL_RE, TURBOPACK_GLOBAL_RE;
754
- var init_patterns = __esm({
742
+ var init_patterns2 = __esm({
755
743
  "src/runtime/turbopack/patterns.ts"() {
756
744
  "use strict";
757
745
  REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
@@ -974,10 +962,11 @@ var init_chunk_loader = __esm({
974
962
  "src/runtime/turbopack/chunk-loader.ts"() {
975
963
  "use strict";
976
964
  init_constants2();
965
+ init_patterns();
977
966
  init_protected_rc_fallback();
978
967
  init_error();
979
968
  init_logger();
980
- init_patterns();
969
+ init_patterns2();
981
970
  }
982
971
  });
983
972
 
@@ -1343,7 +1332,7 @@ var init_shared_modules = __esm({
1343
1332
  init_constants2();
1344
1333
  init_logger();
1345
1334
  init_module();
1346
- init_patterns();
1335
+ init_patterns2();
1347
1336
  DEDUPLICATION_WARNING = "This module will not be deduplicated \u2014 the remote may load its own copy, which can cause duplicate instance errors (e.g. invalid hook calls if React is loaded twice).";
1348
1337
  }
1349
1338
  });
@@ -1371,7 +1360,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
1371
1360
  }
1372
1361
  }
1373
1362
  if (runtime === RUNTIME_TURBOPACK) {
1374
- await Promise.all(
1363
+ const results = await Promise.allSettled(
1375
1364
  scripts.map((script) => {
1376
1365
  if (script.src) {
1377
1366
  return self.__webpack_chunk_load__?.(script.src, bundle);
@@ -1379,6 +1368,14 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
1379
1368
  return Promise.resolve(void 0);
1380
1369
  })
1381
1370
  );
1371
+ for (const result of results) {
1372
+ if (result.status === "rejected") {
1373
+ logWarn(
1374
+ "WebpackRuntime",
1375
+ `Initial chunk load failed: ${String(result.reason)}`
1376
+ );
1377
+ }
1378
+ }
1382
1379
  }
1383
1380
  const coreShared = {
1384
1381
  react: async () => (await import("react")).default,
@@ -1446,6 +1443,7 @@ var init_webpack_runtime = __esm({
1446
1443
  "src/runtime/turbopack/webpack-runtime.ts"() {
1447
1444
  "use strict";
1448
1445
  init_constants2();
1446
+ init_patterns();
1449
1447
  init_error();
1450
1448
  init_logger();
1451
1449
  init_chunk_loader();
@@ -1779,6 +1777,9 @@ function resolveNameFromSrc(src, defaultName) {
1779
1777
  return name || defaultName;
1780
1778
  }
1781
1779
 
1780
+ // src/host/html/index.tsx
1781
+ init_constants2();
1782
+
1782
1783
  // src/runtime/html/apply-origin.ts
1783
1784
  var tagNames = [
1784
1785
  "img",
@@ -1843,6 +1844,41 @@ function applyOriginToNodes(doc, url, resolveClientUrl) {
1843
1844
 
1844
1845
  // src/runtime/html/parse-remote-html.ts
1845
1846
  init_constants2();
1847
+
1848
+ // src/runtime/metadata.ts
1849
+ init_constants2();
1850
+ var VALID_RUNTIMES = /* @__PURE__ */ new Set(["webpack", "turbopack", "script"]);
1851
+ var VALID_TYPES = /* @__PURE__ */ new Set([
1852
+ "nextjs",
1853
+ "remote-component",
1854
+ "unknown"
1855
+ ]);
1856
+ function isRuntime(value) {
1857
+ return VALID_RUNTIMES.has(value);
1858
+ }
1859
+ function isComponentType(value) {
1860
+ return VALID_TYPES.has(value);
1861
+ }
1862
+ function toRuntime(value) {
1863
+ return value && isRuntime(value) ? value : "webpack";
1864
+ }
1865
+ function toComponentType(value) {
1866
+ return value && isComponentType(value) ? value : "unknown";
1867
+ }
1868
+ function buildMetadata(attrs, url) {
1869
+ const id = attrs.id || DEFAULT_COMPONENT_NAME;
1870
+ const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION || DEFAULT_BUNDLE_NAME;
1871
+ return {
1872
+ name: attrs.name || id.replace(/_ssr$/, ""),
1873
+ bundle,
1874
+ route: attrs.route || url.pathname || DEFAULT_ROUTE,
1875
+ runtime: toRuntime(attrs.runtime),
1876
+ id,
1877
+ type: toComponentType(attrs.type)
1878
+ };
1879
+ }
1880
+
1881
+ // src/runtime/html/parse-remote-html.ts
1846
1882
  init_error();
1847
1883
  function validateSingleComponent(doc, name, url) {
1848
1884
  if (doc.querySelectorAll("div[data-bundle][data-route]").length > 1 && !doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) || doc.querySelectorAll("remote-component:not([src])").length > 1 && !doc.querySelector(`remote-component[name="${name}"]`)) {
@@ -1862,14 +1898,6 @@ function resolveComponentName(component, nextData, fallbackName) {
1862
1898
  const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
1863
1899
  return { name, isRemoteComponent };
1864
1900
  }
1865
- function extractComponentMetadata(component, nextData, name, url) {
1866
- return {
1867
- name,
1868
- bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
1869
- route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
1870
- runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
1871
- };
1872
- }
1873
1901
  function extractRemoteShared(doc, name, nextData) {
1874
1902
  const remoteSharedEl = doc.querySelector(
1875
1903
  `#${name}_shared[data-remote-components-shared]`
@@ -1881,7 +1909,7 @@ function extractRemoteShared(doc, name, nextData) {
1881
1909
  function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
1882
1910
  if (!component || !(rsc || nextData || isRemoteComponent)) {
1883
1911
  throw new RemoteComponentsError(
1884
- `Remote Component not found on ${url}.${name !== "__vercel_remote_component" ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
1912
+ `Remote Component not found on ${url}.${name !== DEFAULT_COMPONENT_NAME ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
1885
1913
  );
1886
1914
  }
1887
1915
  }
@@ -1907,10 +1935,15 @@ function parseRemoteComponentDocument(doc, name, url) {
1907
1935
  name
1908
1936
  );
1909
1937
  const rsc = doc.querySelector(`#${resolvedName}_rsc`);
1910
- const metadata = extractComponentMetadata(
1911
- component,
1912
- nextData,
1913
- resolvedName,
1938
+ const metadata = buildMetadata(
1939
+ {
1940
+ name: resolvedName,
1941
+ bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle,
1942
+ route: component?.getAttribute("data-route") ?? nextData?.page,
1943
+ runtime: component?.getAttribute("data-runtime") ?? nextData?.props.__REMOTE_COMPONENT__?.runtime ?? RUNTIME_SCRIPT,
1944
+ id: component?.getAttribute("id"),
1945
+ type: component?.getAttribute("data-type")
1946
+ },
1914
1947
  url
1915
1948
  );
1916
1949
  const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
@@ -2126,12 +2159,7 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
2126
2159
  }
2127
2160
  if (type === "webpack") {
2128
2161
  const { webpackRuntime: webpackRuntime2 } = await Promise.resolve().then(() => (init_webpack(), webpack_exports));
2129
- return webpackRuntime2(
2130
- bundle ?? "default",
2131
- shared,
2132
- remoteShared,
2133
- resolveClientUrl
2134
- );
2162
+ return webpackRuntime2(bundle, shared, remoteShared, resolveClientUrl);
2135
2163
  } else if (type === "turbopack") {
2136
2164
  const { turbopackRuntime: turbopackRuntime2 } = await Promise.resolve().then(() => (init_turbopack(), turbopack_exports));
2137
2165
  return turbopackRuntime2(
@@ -2154,8 +2182,8 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
2154
2182
  import { jsx as jsx2 } from "react/jsx-runtime";
2155
2183
  if (typeof HTMLElement !== "undefined") {
2156
2184
  class RemoteComponent extends HTMLElement {
2157
- name;
2158
- bundle;
2185
+ name = DEFAULT_COMPONENT_NAME;
2186
+ bundle = DEFAULT_BUNDLE_NAME;
2159
2187
  fallbackSlot;
2160
2188
  __next = null;
2161
2189
  fouc = null;
@@ -2271,8 +2299,7 @@ if (typeof HTMLElement !== "undefined") {
2271
2299
  this.fallbackSlot = document.createElement("slot");
2272
2300
  this.root.appendChild(this.fallbackSlot);
2273
2301
  }
2274
- this.name = this.getAttribute("name") || "__vercel_remote_component";
2275
- this.bundle = "default";
2302
+ this.name = this.getAttribute("name") || this.name;
2276
2303
  this.hostState.stage = "loading";
2277
2304
  const src = this.src;
2278
2305
  this.hostState.abortController = new AbortController();
@@ -2292,10 +2319,7 @@ if (typeof HTMLElement !== "undefined") {
2292
2319
  let html = this.innerHTML;
2293
2320
  if (src) {
2294
2321
  url = getClientOrServerUrl(src, window.location.href);
2295
- this.name = resolveNameFromSrc(
2296
- src,
2297
- this.name ?? "__vercel_remote_component"
2298
- );
2322
+ this.name = resolveNameFromSrc(src, this.name);
2299
2323
  }
2300
2324
  const resolveClientUrl = url ? bindResolveClientUrl(this.resolveClientUrl, url.href) : void 0;
2301
2325
  if (!remoteComponentChild && url) {
@@ -2338,7 +2362,7 @@ if (typeof HTMLElement !== "undefined") {
2338
2362
  const doc = parser.parseFromString(html, "text/html");
2339
2363
  const parsed = parseRemoteComponentDocument(
2340
2364
  doc,
2341
- this.name ?? "__vercel_remote_component",
2365
+ this.name,
2342
2366
  url ?? new URL(window.location.href)
2343
2367
  );
2344
2368
  const {
@@ -2362,7 +2386,7 @@ if (typeof HTMLElement !== "undefined") {
2362
2386
  if (!self2.__remote_bundle_url__) {
2363
2387
  self2.__remote_bundle_url__ = {};
2364
2388
  }
2365
- self2.__remote_bundle_url__[this.bundle ?? "default"] = url;
2389
+ self2.__remote_bundle_url__[this.bundle] = url;
2366
2390
  }
2367
2391
  const metadataEl = document.createElement("script");
2368
2392
  metadataEl.type = "application/json";
@@ -2554,12 +2578,7 @@ if (typeof HTMLElement !== "undefined") {
2554
2578
  window.location.href
2555
2579
  );
2556
2580
  }
2557
- await preloadScripts(
2558
- Array.from(scripts),
2559
- url,
2560
- this.bundle ?? "default",
2561
- this.name ?? "__vercel_remote_component"
2562
- );
2581
+ await preloadScripts(Array.from(scripts), url, this.bundle, this.name);
2563
2582
  if (!isCurrentLoad()) {
2564
2583
  return abandonLoad();
2565
2584
  }
@@ -2638,7 +2657,7 @@ if (typeof HTMLElement !== "undefined") {
2638
2657
  RemoteComponentFromReadableStream,
2639
2658
  {
2640
2659
  initial: false,
2641
- name: this.name ?? "__vercel_remote_component"
2660
+ name: this.name
2642
2661
  }
2643
2662
  )
2644
2663
  );
@@ -2649,17 +2668,11 @@ if (typeof HTMLElement !== "undefined") {
2649
2668
  // hydrateRoot expects a document or element, but it works for the shadow DOM too
2650
2669
  // @ts-expect-error support for shadow DOM
2651
2670
  this.root,
2652
- /* @__PURE__ */ jsx2(
2653
- RemoteComponentFromReadableStream,
2654
- {
2655
- initial: true,
2656
- name: this.name ?? "__vercel_remote_component"
2657
- }
2658
- )
2671
+ /* @__PURE__ */ jsx2(RemoteComponentFromReadableStream, { initial: true, name: this.name })
2659
2672
  );
2660
2673
  } else if (nextData) {
2661
2674
  const { Component, App } = nextClientPagesLoader2(
2662
- this.bundle ?? "default",
2675
+ this.bundle,
2663
2676
  nextData.page ?? "/",
2664
2677
  this.root
2665
2678
  );