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
@@ -223,17 +223,17 @@ var init_utils = __esm({
223
223
  function getBundleKey(bundle) {
224
224
  return escapeString(bundle);
225
225
  }
226
- var DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT, REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE;
226
+ var DEFAULT_BUNDLE_NAME, DEFAULT_COMPONENT_NAME, DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT;
227
227
  var init_constants2 = __esm({
228
228
  "src/runtime/constants.ts"() {
229
229
  "use strict";
230
230
  init_utils();
231
+ DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
232
+ DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
231
233
  DEFAULT_ROUTE = "/";
232
234
  RUNTIME_WEBPACK = "webpack";
233
235
  RUNTIME_TURBOPACK = "turbopack";
234
236
  RUNTIME_SCRIPT = "script";
235
- REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
236
- NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
237
237
  }
238
238
  });
239
239
 
@@ -424,25 +424,39 @@ var init_next_client_pages_loader = __esm({
424
424
  }
425
425
  });
426
426
 
427
- // src/host/shared/polyfill.tsx
428
- function applyBundleUrlToSrc(bundle, src) {
427
+ // src/host/shared/remote-image-loader.ts
428
+ function getRemoteBundleOrigin(bundle) {
429
429
  const self = globalThis;
430
- if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {
431
- return src;
432
- }
433
- const { assetPrefix, path } = /^(?<assetPrefix>.*?)\/_next\/(?<path>.*)/.exec(src)?.groups ?? {};
434
- if (!path) {
435
- return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;
436
- }
437
- return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ""}${assetPrefix}/_next/${path}`;
430
+ return self.__remote_bundle_url__?.[bundle]?.origin ?? "";
438
431
  }
439
- function applyBundleUrlToImagePropsSrc(bundle, src) {
440
- if (typeof src === "string") {
441
- return applyBundleUrlToSrc(bundle, src);
442
- }
443
- const propSrc = src;
444
- return applyBundleUrlToSrc(bundle, propSrc.src);
432
+ function createRemoteImageLoader(bundle, resolveClientUrl) {
433
+ const loader = Object.assign(
434
+ ({
435
+ config,
436
+ src,
437
+ width,
438
+ quality
439
+ }) => {
440
+ const q = quality ?? 75;
441
+ const remoteOrigin = getRemoteBundleOrigin(bundle);
442
+ const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
443
+ const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
444
+ const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
445
+ return resolveClientUrl?.(url) ?? url;
446
+ },
447
+ // Signals to getImgProps that this is a default loader (not a user-defined
448
+ // one), enabling srcSet generation with device/image sizes from the config.
449
+ { __next_img_default: true }
450
+ );
451
+ return loader;
445
452
  }
453
+ var init_remote_image_loader = __esm({
454
+ "src/host/shared/remote-image-loader.ts"() {
455
+ "use strict";
456
+ }
457
+ });
458
+
459
+ // src/host/shared/polyfill.tsx
446
460
  function sharedPolyfills(shared, resolveClientUrl) {
447
461
  const self = globalThis;
448
462
  const polyfill = {
@@ -533,17 +547,13 @@ function sharedPolyfills(shared, resolveClientUrl) {
533
547
  },
534
548
  __esModule: true
535
549
  })),
536
- "next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
537
- Image: imageImpl(bundle, resolveClientUrl),
538
- __esModule: true
539
- })),
540
- "next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
541
- default: imageImpl(bundle, resolveClientUrl),
542
- getImageProps: (_imgProps) => {
543
- throw new Error(
544
- "Next.js getImageProps() is not implemented in remote components"
545
- );
546
- },
550
+ // Instead of replacing next/image entirely, we let the real Next.js Image
551
+ // component load from the remote bundle and only replace its default loader.
552
+ // This gives us full next/image fidelity (fill, priority, srcSet, blur
553
+ // placeholders, error handling) while routing image optimization through the
554
+ // remote app's /_next/image endpoint.
555
+ "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({
556
+ default: createRemoteImageLoader(bundle, resolveClientUrl),
547
557
  __esModule: true
548
558
  })),
549
559
  "next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
@@ -583,46 +593,27 @@ function sharedPolyfills(shared, resolveClientUrl) {
583
593
  polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
584
594
  polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
585
595
  polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
586
- polyfill["next/dist/api/image"] = polyfill["next/dist/client/image-component"];
596
+ polyfill["next/dist/esm/shared/lib/image-loader"] = polyfill["next/dist/shared/lib/image-loader"];
587
597
  polyfill["next/script"] = polyfill["next/dist/client/script"];
588
598
  return polyfill;
589
599
  }
590
- var import_jsx_runtime, imageImpl;
600
+ var import_jsx_runtime;
591
601
  var init_polyfill = __esm({
592
602
  "src/host/shared/polyfill.tsx"() {
593
603
  "use strict";
604
+ init_remote_image_loader();
594
605
  init_logger();
595
- // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
596
606
  import_jsx_runtime = require("react/jsx-runtime");
597
- imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
598
- fill: _fill,
599
- loader: _loader,
600
- quality: _quality,
601
- priority: _priority,
602
- loading: _loading,
603
- placeholder: _placeholder,
604
- blurDataURL: _blurDataURL,
605
- unoptimized: _unoptimized,
606
- overrideSrc: _overrideSrc,
607
- src,
608
- ...props
609
- }) {
610
- const newSrc = applyBundleUrlToImagePropsSrc(
611
- bundle,
612
- typeof src === "string" ? src : src.src
613
- );
614
- const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
615
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
616
- "img",
617
- {
618
- decoding: "async",
619
- style: { color: "transparent" },
620
- ...props,
621
- src: proxiedSrc,
622
- suppressHydrationWarning: true
623
- }
624
- );
625
- };
607
+ }
608
+ });
609
+
610
+ // src/runtime/patterns.ts
611
+ var REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE;
612
+ var init_patterns = __esm({
613
+ "src/runtime/patterns.ts"() {
614
+ "use strict";
615
+ REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
616
+ NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
626
617
  }
627
618
  });
628
619
 
@@ -662,7 +653,7 @@ async function loadScripts(scripts, resolveClientUrl) {
662
653
  var init_script_loader = __esm({
663
654
  "src/runtime/loaders/script-loader.ts"() {
664
655
  "use strict";
665
- init_constants2();
656
+ init_patterns();
666
657
  init_protected_rc_fallback();
667
658
  init_error();
668
659
  init_logger();
@@ -763,15 +754,15 @@ var init_webpack = __esm({
763
754
  init_apply_shared_modules();
764
755
  init_next_client_pages_loader();
765
756
  init_polyfill();
766
- init_constants2();
767
757
  init_script_loader();
758
+ init_patterns();
768
759
  init_error();
769
760
  }
770
761
  });
771
762
 
772
763
  // src/runtime/turbopack/patterns.ts
773
764
  var REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_RESOLVE_RE, ASYNC_MODULE_ALL_RE, TURBOPACK_GLOBAL_RE;
774
- var init_patterns = __esm({
765
+ var init_patterns2 = __esm({
775
766
  "src/runtime/turbopack/patterns.ts"() {
776
767
  "use strict";
777
768
  REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
@@ -994,10 +985,11 @@ var init_chunk_loader = __esm({
994
985
  "src/runtime/turbopack/chunk-loader.ts"() {
995
986
  "use strict";
996
987
  init_constants2();
988
+ init_patterns();
997
989
  init_protected_rc_fallback();
998
990
  init_error();
999
991
  init_logger();
1000
- init_patterns();
992
+ init_patterns2();
1001
993
  }
1002
994
  });
1003
995
 
@@ -1363,7 +1355,7 @@ var init_shared_modules = __esm({
1363
1355
  init_constants2();
1364
1356
  init_logger();
1365
1357
  init_module();
1366
- init_patterns();
1358
+ init_patterns2();
1367
1359
  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).";
1368
1360
  }
1369
1361
  });
@@ -1391,7 +1383,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
1391
1383
  }
1392
1384
  }
1393
1385
  if (runtime === RUNTIME_TURBOPACK) {
1394
- await Promise.all(
1386
+ const results = await Promise.allSettled(
1395
1387
  scripts.map((script) => {
1396
1388
  if (script.src) {
1397
1389
  return self.__webpack_chunk_load__?.(script.src, bundle);
@@ -1399,6 +1391,14 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
1399
1391
  return Promise.resolve(void 0);
1400
1392
  })
1401
1393
  );
1394
+ for (const result of results) {
1395
+ if (result.status === "rejected") {
1396
+ logWarn(
1397
+ "WebpackRuntime",
1398
+ `Initial chunk load failed: ${String(result.reason)}`
1399
+ );
1400
+ }
1401
+ }
1402
1402
  }
1403
1403
  const coreShared = {
1404
1404
  react: async () => (await import("react")).default,
@@ -1466,6 +1466,7 @@ var init_webpack_runtime = __esm({
1466
1466
  "src/runtime/turbopack/webpack-runtime.ts"() {
1467
1467
  "use strict";
1468
1468
  init_constants2();
1469
+ init_patterns();
1469
1470
  init_error();
1470
1471
  init_logger();
1471
1472
  init_chunk_loader();
@@ -1804,6 +1805,9 @@ function resolveNameFromSrc(src, defaultName) {
1804
1805
  return name || defaultName;
1805
1806
  }
1806
1807
 
1808
+ // src/host/html/index.tsx
1809
+ init_constants2();
1810
+
1807
1811
  // src/runtime/html/apply-origin.ts
1808
1812
  var tagNames = [
1809
1813
  "img",
@@ -1868,6 +1872,41 @@ function applyOriginToNodes(doc, url, resolveClientUrl) {
1868
1872
 
1869
1873
  // src/runtime/html/parse-remote-html.ts
1870
1874
  init_constants2();
1875
+
1876
+ // src/runtime/metadata.ts
1877
+ init_constants2();
1878
+ var VALID_RUNTIMES = /* @__PURE__ */ new Set(["webpack", "turbopack", "script"]);
1879
+ var VALID_TYPES = /* @__PURE__ */ new Set([
1880
+ "nextjs",
1881
+ "remote-component",
1882
+ "unknown"
1883
+ ]);
1884
+ function isRuntime(value) {
1885
+ return VALID_RUNTIMES.has(value);
1886
+ }
1887
+ function isComponentType(value) {
1888
+ return VALID_TYPES.has(value);
1889
+ }
1890
+ function toRuntime(value) {
1891
+ return value && isRuntime(value) ? value : "webpack";
1892
+ }
1893
+ function toComponentType(value) {
1894
+ return value && isComponentType(value) ? value : "unknown";
1895
+ }
1896
+ function buildMetadata(attrs, url) {
1897
+ const id = attrs.id || DEFAULT_COMPONENT_NAME;
1898
+ const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION || DEFAULT_BUNDLE_NAME;
1899
+ return {
1900
+ name: attrs.name || id.replace(/_ssr$/, ""),
1901
+ bundle,
1902
+ route: attrs.route || url.pathname || DEFAULT_ROUTE,
1903
+ runtime: toRuntime(attrs.runtime),
1904
+ id,
1905
+ type: toComponentType(attrs.type)
1906
+ };
1907
+ }
1908
+
1909
+ // src/runtime/html/parse-remote-html.ts
1871
1910
  init_error();
1872
1911
  function validateSingleComponent(doc, name, url) {
1873
1912
  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}"]`)) {
@@ -1887,14 +1926,6 @@ function resolveComponentName(component, nextData, fallbackName) {
1887
1926
  const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
1888
1927
  return { name, isRemoteComponent };
1889
1928
  }
1890
- function extractComponentMetadata(component, nextData, name, url) {
1891
- return {
1892
- name,
1893
- bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
1894
- route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
1895
- runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
1896
- };
1897
- }
1898
1929
  function extractRemoteShared(doc, name, nextData) {
1899
1930
  const remoteSharedEl = doc.querySelector(
1900
1931
  `#${name}_shared[data-remote-components-shared]`
@@ -1906,7 +1937,7 @@ function extractRemoteShared(doc, name, nextData) {
1906
1937
  function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
1907
1938
  if (!component || !(rsc || nextData || isRemoteComponent)) {
1908
1939
  throw new RemoteComponentsError(
1909
- `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>?`
1940
+ `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>?`
1910
1941
  );
1911
1942
  }
1912
1943
  }
@@ -1932,10 +1963,15 @@ function parseRemoteComponentDocument(doc, name, url) {
1932
1963
  name
1933
1964
  );
1934
1965
  const rsc = doc.querySelector(`#${resolvedName}_rsc`);
1935
- const metadata = extractComponentMetadata(
1936
- component,
1937
- nextData,
1938
- resolvedName,
1966
+ const metadata = buildMetadata(
1967
+ {
1968
+ name: resolvedName,
1969
+ bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle,
1970
+ route: component?.getAttribute("data-route") ?? nextData?.page,
1971
+ runtime: component?.getAttribute("data-runtime") ?? nextData?.props.__REMOTE_COMPONENT__?.runtime ?? RUNTIME_SCRIPT,
1972
+ id: component?.getAttribute("id"),
1973
+ type: component?.getAttribute("data-type")
1974
+ },
1939
1975
  url
1940
1976
  );
1941
1977
  const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
@@ -2151,12 +2187,7 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
2151
2187
  }
2152
2188
  if (type === "webpack") {
2153
2189
  const { webpackRuntime: webpackRuntime2 } = await Promise.resolve().then(() => (init_webpack(), webpack_exports));
2154
- return webpackRuntime2(
2155
- bundle ?? "default",
2156
- shared,
2157
- remoteShared,
2158
- resolveClientUrl
2159
- );
2190
+ return webpackRuntime2(bundle, shared, remoteShared, resolveClientUrl);
2160
2191
  } else if (type === "turbopack") {
2161
2192
  const { turbopackRuntime: turbopackRuntime2 } = await Promise.resolve().then(() => (init_turbopack(), turbopack_exports));
2162
2193
  return turbopackRuntime2(
@@ -2179,8 +2210,8 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
2179
2210
  var import_jsx_runtime2 = require("react/jsx-runtime");
2180
2211
  if (typeof HTMLElement !== "undefined") {
2181
2212
  class RemoteComponent extends HTMLElement {
2182
- name;
2183
- bundle;
2213
+ name = DEFAULT_COMPONENT_NAME;
2214
+ bundle = DEFAULT_BUNDLE_NAME;
2184
2215
  fallbackSlot;
2185
2216
  __next = null;
2186
2217
  fouc = null;
@@ -2296,8 +2327,7 @@ if (typeof HTMLElement !== "undefined") {
2296
2327
  this.fallbackSlot = document.createElement("slot");
2297
2328
  this.root.appendChild(this.fallbackSlot);
2298
2329
  }
2299
- this.name = this.getAttribute("name") || "__vercel_remote_component";
2300
- this.bundle = "default";
2330
+ this.name = this.getAttribute("name") || this.name;
2301
2331
  this.hostState.stage = "loading";
2302
2332
  const src = this.src;
2303
2333
  this.hostState.abortController = new AbortController();
@@ -2317,10 +2347,7 @@ if (typeof HTMLElement !== "undefined") {
2317
2347
  let html = this.innerHTML;
2318
2348
  if (src) {
2319
2349
  url = getClientOrServerUrl(src, window.location.href);
2320
- this.name = resolveNameFromSrc(
2321
- src,
2322
- this.name ?? "__vercel_remote_component"
2323
- );
2350
+ this.name = resolveNameFromSrc(src, this.name);
2324
2351
  }
2325
2352
  const resolveClientUrl = url ? bindResolveClientUrl(this.resolveClientUrl, url.href) : void 0;
2326
2353
  if (!remoteComponentChild && url) {
@@ -2363,7 +2390,7 @@ if (typeof HTMLElement !== "undefined") {
2363
2390
  const doc = parser.parseFromString(html, "text/html");
2364
2391
  const parsed = parseRemoteComponentDocument(
2365
2392
  doc,
2366
- this.name ?? "__vercel_remote_component",
2393
+ this.name,
2367
2394
  url ?? new URL(window.location.href)
2368
2395
  );
2369
2396
  const {
@@ -2387,7 +2414,7 @@ if (typeof HTMLElement !== "undefined") {
2387
2414
  if (!self2.__remote_bundle_url__) {
2388
2415
  self2.__remote_bundle_url__ = {};
2389
2416
  }
2390
- self2.__remote_bundle_url__[this.bundle ?? "default"] = url;
2417
+ self2.__remote_bundle_url__[this.bundle] = url;
2391
2418
  }
2392
2419
  const metadataEl = document.createElement("script");
2393
2420
  metadataEl.type = "application/json";
@@ -2579,12 +2606,7 @@ if (typeof HTMLElement !== "undefined") {
2579
2606
  window.location.href
2580
2607
  );
2581
2608
  }
2582
- await preloadScripts(
2583
- Array.from(scripts),
2584
- url,
2585
- this.bundle ?? "default",
2586
- this.name ?? "__vercel_remote_component"
2587
- );
2609
+ await preloadScripts(Array.from(scripts), url, this.bundle, this.name);
2588
2610
  if (!isCurrentLoad()) {
2589
2611
  return abandonLoad();
2590
2612
  }
@@ -2663,7 +2685,7 @@ if (typeof HTMLElement !== "undefined") {
2663
2685
  RemoteComponentFromReadableStream,
2664
2686
  {
2665
2687
  initial: false,
2666
- name: this.name ?? "__vercel_remote_component"
2688
+ name: this.name
2667
2689
  }
2668
2690
  )
2669
2691
  );
@@ -2674,17 +2696,11 @@ if (typeof HTMLElement !== "undefined") {
2674
2696
  // hydrateRoot expects a document or element, but it works for the shadow DOM too
2675
2697
  // @ts-expect-error support for shadow DOM
2676
2698
  this.root,
2677
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2678
- RemoteComponentFromReadableStream,
2679
- {
2680
- initial: true,
2681
- name: this.name ?? "__vercel_remote_component"
2682
- }
2683
- )
2699
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RemoteComponentFromReadableStream, { initial: true, name: this.name })
2684
2700
  );
2685
2701
  } else if (nextData) {
2686
2702
  const { Component, App } = nextClientPagesLoader2(
2687
- this.bundle ?? "default",
2703
+ this.bundle,
2688
2704
  nextData.page ?? "/",
2689
2705
  this.root
2690
2706
  );