remote-components 0.0.51 → 0.1.0

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 (108) hide show
  1. package/dist/{component-loader-1838f572.d.ts → component-loader-76eb1b8b.d.ts} +3 -1
  2. package/dist/html/host.cjs +297 -217
  3. package/dist/html/host.cjs.map +1 -1
  4. package/dist/html/host.d.ts +2 -0
  5. package/dist/html/host.js +296 -217
  6. package/dist/html/host.js.map +1 -1
  7. package/dist/html/remote.cjs +65 -57
  8. package/dist/html/remote.cjs.map +1 -1
  9. package/dist/html/remote.js +65 -57
  10. package/dist/html/remote.js.map +1 -1
  11. package/dist/internal/next/host/app-router-client.cjs +12 -3
  12. package/dist/internal/next/host/app-router-client.cjs.map +1 -1
  13. package/dist/internal/next/host/app-router-client.d.ts +11 -2
  14. package/dist/internal/next/host/app-router-client.js +12 -3
  15. package/dist/internal/next/host/app-router-client.js.map +1 -1
  16. package/dist/internal/react/context.cjs +43 -0
  17. package/dist/internal/react/context.cjs.map +1 -0
  18. package/dist/internal/react/context.d.ts +20 -0
  19. package/dist/internal/react/context.js +18 -0
  20. package/dist/internal/react/context.js.map +1 -0
  21. package/dist/internal/react/hooks/use-resolve-client-url.cjs +39 -0
  22. package/dist/internal/react/hooks/use-resolve-client-url.cjs.map +1 -0
  23. package/dist/internal/react/hooks/use-resolve-client-url.d.ts +5 -0
  24. package/dist/internal/react/hooks/use-resolve-client-url.js +15 -0
  25. package/dist/internal/react/hooks/use-resolve-client-url.js.map +1 -0
  26. package/dist/internal/shared/client/apply-origin.cjs +10 -5
  27. package/dist/internal/shared/client/apply-origin.cjs.map +1 -1
  28. package/dist/internal/shared/client/apply-origin.d.ts +3 -1
  29. package/dist/internal/shared/client/apply-origin.js +10 -5
  30. package/dist/internal/shared/client/apply-origin.js.map +1 -1
  31. package/dist/internal/shared/client/default-resolve-client-url.cjs +32 -0
  32. package/dist/internal/shared/client/default-resolve-client-url.cjs.map +1 -0
  33. package/dist/internal/shared/client/default-resolve-client-url.d.ts +5 -0
  34. package/dist/internal/shared/client/default-resolve-client-url.js +10 -0
  35. package/dist/internal/shared/client/default-resolve-client-url.js.map +1 -0
  36. package/dist/internal/shared/client/protected-rc-fallback.cjs +11 -2
  37. package/dist/internal/shared/client/protected-rc-fallback.cjs.map +1 -1
  38. package/dist/internal/shared/client/protected-rc-fallback.d.ts +2 -1
  39. package/dist/internal/shared/client/protected-rc-fallback.js +9 -1
  40. package/dist/internal/shared/client/protected-rc-fallback.js.map +1 -1
  41. package/dist/internal/shared/client/proxy-through-host.cjs +51 -0
  42. package/dist/internal/shared/client/proxy-through-host.cjs.map +1 -0
  43. package/dist/internal/shared/client/proxy-through-host.d.ts +57 -0
  44. package/dist/internal/shared/client/proxy-through-host.js +26 -0
  45. package/dist/internal/shared/client/proxy-through-host.js.map +1 -0
  46. package/dist/internal/shared/client/remote-component.cjs +121 -137
  47. package/dist/internal/shared/client/remote-component.cjs.map +1 -1
  48. package/dist/internal/shared/client/remote-component.d.ts +7 -5
  49. package/dist/internal/shared/client/remote-component.js +120 -137
  50. package/dist/internal/shared/client/remote-component.js.map +1 -1
  51. package/dist/internal/shared/constants.cjs +3 -0
  52. package/dist/internal/shared/constants.cjs.map +1 -1
  53. package/dist/internal/shared/constants.d.ts +2 -1
  54. package/dist/internal/shared/constants.js +2 -0
  55. package/dist/internal/shared/constants.js.map +1 -1
  56. package/dist/internal/shared/error.cjs +70 -0
  57. package/dist/internal/shared/error.cjs.map +1 -1
  58. package/dist/internal/shared/error.d.ts +3 -1
  59. package/dist/internal/shared/error.js +71 -0
  60. package/dist/internal/shared/error.js.map +1 -1
  61. package/dist/internal/shared/ssr/fetch-with-hooks.cjs +7 -2
  62. package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +1 -1
  63. package/dist/internal/shared/ssr/fetch-with-hooks.js +7 -2
  64. package/dist/internal/shared/ssr/fetch-with-hooks.js.map +1 -1
  65. package/dist/internal/shared/utils/logger.cjs +26 -10
  66. package/dist/internal/shared/utils/logger.cjs.map +1 -1
  67. package/dist/internal/shared/utils/logger.d.ts +6 -1
  68. package/dist/internal/shared/utils/logger.js +24 -9
  69. package/dist/internal/shared/utils/logger.js.map +1 -1
  70. package/dist/next/config.cjs +2 -2
  71. package/dist/next/config.cjs.map +1 -1
  72. package/dist/next/config.js +2 -2
  73. package/dist/next/config.js.map +1 -1
  74. package/dist/next/host/client/index.cjs +270 -209
  75. package/dist/next/host/client/index.cjs.map +1 -1
  76. package/dist/next/host/client/index.d.ts +3 -1
  77. package/dist/next/host/client/index.js +244 -184
  78. package/dist/next/host/client/index.js.map +1 -1
  79. package/dist/next/host/pages-router-client.cjs +15 -2
  80. package/dist/next/host/pages-router-client.cjs.map +1 -1
  81. package/dist/next/host/pages-router-client.d.ts +12 -1
  82. package/dist/next/host/pages-router-client.js +15 -2
  83. package/dist/next/host/pages-router-client.js.map +1 -1
  84. package/dist/next/host/pages-router-server.cjs +2 -0
  85. package/dist/next/host/pages-router-server.cjs.map +1 -1
  86. package/dist/next/host/pages-router-server.d.ts +11 -0
  87. package/dist/next/host/pages-router-server.js +2 -0
  88. package/dist/next/host/pages-router-server.js.map +1 -1
  89. package/dist/next/proxy.cjs +33 -6
  90. package/dist/next/proxy.cjs.map +1 -1
  91. package/dist/next/proxy.js +33 -6
  92. package/dist/next/proxy.js.map +1 -1
  93. package/dist/proxy-through-host-a676a522.d.ts +52 -0
  94. package/dist/react/index.cjs +289 -209
  95. package/dist/react/index.cjs.map +1 -1
  96. package/dist/react/index.d.ts +28 -4
  97. package/dist/react/index.js +262 -184
  98. package/dist/react/index.js.map +1 -1
  99. package/dist/shared/host/proxy.cjs +32 -6
  100. package/dist/shared/host/proxy.cjs.map +1 -1
  101. package/dist/shared/host/proxy.js +36 -7
  102. package/dist/shared/host/proxy.js.map +1 -1
  103. package/package.json +1 -1
  104. package/dist/internal/shared/client/fetch-with-protected-rc-fallback.cjs +0 -65
  105. package/dist/internal/shared/client/fetch-with-protected-rc-fallback.cjs.map +0 -1
  106. package/dist/internal/shared/client/fetch-with-protected-rc-fallback.d.ts +0 -13
  107. package/dist/internal/shared/client/fetch-with-protected-rc-fallback.js +0 -41
  108. package/dist/internal/shared/client/fetch-with-protected-rc-fallback.js.map +0 -1
@@ -30,10 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/react/index.tsx
31
31
  var react_exports = {};
32
32
  __export(react_exports, {
33
- RemoteComponent: () => RemoteComponent
33
+ RemoteComponent: () => RemoteComponent,
34
+ RemoteComponentsProvider: () => import_context2.RemoteComponentsProvider,
35
+ proxyClientRequestsThroughHost: () => proxyClientRequestsThroughHost
34
36
  });
35
37
  module.exports = __toCommonJS(react_exports);
36
- var import_react2 = require("react");
38
+ var import_react3 = require("react");
37
39
  var import_react_dom = require("react-dom");
38
40
 
39
41
  // src/shared/client/apply-origin.ts
@@ -48,7 +50,7 @@ var tagNames = [
48
50
  "script",
49
51
  "link"
50
52
  ];
51
- function applyOriginToNodes(doc, url) {
53
+ function applyOriginToNodes(doc, url, resolveClientUrl) {
52
54
  if (url.origin !== location.origin) {
53
55
  const nodes = doc.querySelectorAll(
54
56
  tagNames.map(
@@ -57,12 +59,15 @@ function applyOriginToNodes(doc, url) {
57
59
  );
58
60
  nodes.forEach((node) => {
59
61
  if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
60
- node.src = new URL(node.getAttribute("src") ?? "/", url).href;
62
+ const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
63
+ const isScript = node.tagName.toLowerCase() === "script";
64
+ node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
61
65
  }
62
66
  if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
67
+ const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
63
68
  node.setAttribute(
64
69
  "href",
65
- new URL(node.getAttribute("href") ?? "/", url).href
70
+ resolveClientUrl?.(absoluteHref) ?? absoluteHref
66
71
  );
67
72
  }
68
73
  if (node.hasAttribute("srcset")) {
@@ -71,7 +76,8 @@ function applyOriginToNodes(doc, url) {
71
76
  if (!urlPart)
72
77
  return entry;
73
78
  const absoluteUrl = new URL(urlPart, url).href;
74
- return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
79
+ const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
80
+ return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
75
81
  }).join(", ");
76
82
  if (srcSet) {
77
83
  node.setAttribute("srcset", srcSet);
@@ -83,7 +89,8 @@ function applyOriginToNodes(doc, url) {
83
89
  if (!urlPart)
84
90
  return entry;
85
91
  const absoluteUrl = new URL(urlPart, url).href;
86
- return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
92
+ const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
93
+ return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
87
94
  }).join(", ");
88
95
  if (srcSet) {
89
96
  node.setAttribute("imagesrcset", srcSet);
@@ -93,6 +100,34 @@ function applyOriginToNodes(doc, url) {
93
100
  }
94
101
  }
95
102
 
103
+ // src/shared/constants.ts
104
+ var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
105
+ var CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
106
+
107
+ // src/shared/client/protected-rc-fallback.ts
108
+ function generateProtectedRcFallbackSrc(url) {
109
+ return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
110
+ }
111
+ function isProxiedUrl(url) {
112
+ try {
113
+ return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
114
+ } catch {
115
+ return false;
116
+ }
117
+ }
118
+
119
+ // src/shared/utils/abort.ts
120
+ function isAbortError(error) {
121
+ if (error instanceof DOMException && error.name === "AbortError") {
122
+ return true;
123
+ }
124
+ if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
125
+ const e = error;
126
+ return typeof e.code === "number" || e.constructor?.name === "DOMException";
127
+ }
128
+ return false;
129
+ }
130
+
96
131
  // src/shared/error.ts
97
132
  var RemoteComponentsError = class extends Error {
98
133
  code = "REMOTE_COMPONENTS_ERROR";
@@ -112,6 +147,69 @@ function failedToFetchRemoteComponentError(url, { status, statusText }, help = "
112
147
  { cause: new Error(`${status} ${statusText}`) }
113
148
  );
114
149
  }
150
+ async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
151
+ const isProxied = isProxiedUrl(resolvedUrl.href);
152
+ if (isProxied && res) {
153
+ const body = await res.text().catch(() => "");
154
+ return failedProxyFetchError(
155
+ originalUrl,
156
+ resolvedUrl.href,
157
+ res.status,
158
+ body
159
+ );
160
+ }
161
+ const fallback = failedToFetchRemoteComponentError(
162
+ originalUrl,
163
+ res ?? { status: 0, statusText: "No Response" }
164
+ );
165
+ if (!res)
166
+ return fallback;
167
+ try {
168
+ const body = await res.text();
169
+ const parser = new DOMParser();
170
+ const doc = parser.parseFromString(body, "text/html");
171
+ const errorTemplate = doc.querySelector(
172
+ "template[data-next-error-message]"
173
+ );
174
+ const errorMessage = errorTemplate?.getAttribute("data-next-error-message");
175
+ if (errorMessage) {
176
+ const error = new RemoteComponentsError(errorMessage);
177
+ const errorStack = errorTemplate?.getAttribute("data-next-error-stack");
178
+ if (errorStack) {
179
+ error.stack = errorStack;
180
+ }
181
+ return error;
182
+ }
183
+ } catch (parseError) {
184
+ if (isAbortError(parseError))
185
+ throw parseError;
186
+ }
187
+ return fallback;
188
+ }
189
+ function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
190
+ if (status === 404) {
191
+ return new RemoteComponentsError(
192
+ `Could not proxy the request to "${originalUrl}" \u2014 the proxy endpoint "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" returned 404.
193
+
194
+ The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
195
+
196
+ Proxying requires two pieces:
197
+ 1. resolveClientUrl={proxyClientRequestsThroughHost} on <RemoteComponent>
198
+ 2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
199
+
200
+ Docs: ${CORS_DOCS_URL}`
201
+ );
202
+ }
203
+ if (status === 403) {
204
+ const detail = responseBody ? ` ${responseBody}` : "";
205
+ return new RemoteComponentsError(
206
+ `Proxied request to "${proxyUrl}" was forbidden.${detail} See: ${CORS_DOCS_URL}`
207
+ );
208
+ }
209
+ return new RemoteComponentsError(
210
+ `Proxied request for "${originalUrl}" via "${proxyUrl}" failed with status ${status}. See: ${CORS_DOCS_URL}`
211
+ );
212
+ }
115
213
 
116
214
  // src/shared/utils/logger.ts
117
215
  var PREFIX = "remote-components";
@@ -121,9 +219,6 @@ function logDebug(location2, message) {
121
219
  console.debug(`[${PREFIX}:${location2}]: ${message}`);
122
220
  }
123
221
  }
124
- function logInfo(location2, message) {
125
- console.info(`[${PREFIX}:${location2}]: ${message}`);
126
- }
127
222
  function logWarn(location2, message) {
128
223
  console.warn(`[${PREFIX}:${location2}]: ${message}`);
129
224
  }
@@ -134,6 +229,19 @@ function logError(location2, message, cause) {
134
229
  })
135
230
  );
136
231
  }
232
+ function warnCrossOriginFetchError(logLocation, url) {
233
+ try {
234
+ const parsed = typeof url === "string" ? new URL(url) : url;
235
+ if (typeof location === "undefined" || parsed.origin === location.origin) {
236
+ return;
237
+ }
238
+ logWarn(
239
+ logLocation,
240
+ `Failed to fetch cross-origin resource "${parsed.href}". If this is a protected deployment, ensure withRemoteComponentsHost middleware is configured in your host and that the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
241
+ );
242
+ } catch {
243
+ }
244
+ }
137
245
 
138
246
  // src/shared/client/polyfill.tsx
139
247
  var import_jsx_runtime = (
@@ -577,19 +685,11 @@ function createRSCStream(rscName, data) {
577
685
  });
578
686
  }
579
687
 
580
- // src/shared/constants.ts
581
- var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
582
-
583
- // src/shared/client/protected-rc-fallback.ts
584
- function generateProtectedRcFallbackSrc(url) {
585
- return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
586
- }
587
-
588
688
  // src/shared/client/webpack-patterns.ts
589
689
  var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
590
690
 
591
691
  // src/shared/client/script-loader.ts
592
- async function loadScripts(scripts) {
692
+ async function loadScripts(scripts, resolveClientUrl) {
593
693
  await Promise.all(
594
694
  scripts.map((script) => {
595
695
  return new Promise((resolve, reject) => {
@@ -598,42 +698,29 @@ async function loadScripts(scripts) {
598
698
  script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
599
699
  location.origin
600
700
  ).href;
601
- const loadScriptWithProtectedRcFallback = (src, isFallback = false) => {
602
- const newScript = document.createElement("script");
603
- newScript.onload = () => {
604
- if (isFallback) {
605
- logInfo(
606
- "ScriptLoader",
607
- `Successfully loaded <script src="${newSrc}"> using fallback.`
608
- );
609
- }
610
- resolve();
611
- };
612
- newScript.onerror = () => {
613
- if (!isFallback) {
614
- const fallbackSrc = generateProtectedRcFallbackSrc(newSrc);
615
- logWarn(
616
- "ScriptLoader",
617
- `Failed to load <script src="${newSrc}"> for Remote Component. Trying fallback with ${RC_PROTECTED_REMOTE_FETCH_PATHNAME} (withRemoteComponentsHost)...`
618
- );
619
- loadScriptWithProtectedRcFallback(fallbackSrc, true);
620
- } else {
621
- logError(
622
- "ScriptLoader",
623
- `Failed to load fallback for <script src="${newSrc}"> for Remote Component.`
624
- );
625
- reject(
626
- new RemoteComponentsError(
627
- `Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
628
- )
629
- );
630
- }
631
- };
632
- newScript.src = src;
633
- newScript.async = true;
634
- document.head.appendChild(newScript);
701
+ const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
702
+ const newScript = document.createElement("script");
703
+ newScript.onload = () => resolve();
704
+ newScript.onerror = () => {
705
+ const isProxied = isProxiedUrl(resolvedSrc);
706
+ if (isProxied) {
707
+ reject(
708
+ new RemoteComponentsError(
709
+ `Failed to load script "${newSrc}" via proxy "${resolvedSrc}". Ensure withRemoteComponentsHost middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
710
+ )
711
+ );
712
+ } else {
713
+ warnCrossOriginFetchError("ScriptLoader", newSrc);
714
+ reject(
715
+ new RemoteComponentsError(
716
+ `Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
717
+ )
718
+ );
719
+ }
635
720
  };
636
- loadScriptWithProtectedRcFallback(newSrc);
721
+ newScript.src = resolvedSrc;
722
+ newScript.async = true;
723
+ document.head.appendChild(newScript);
637
724
  });
638
725
  })
639
726
  );
@@ -661,54 +748,6 @@ function getBundleKey(bundle) {
661
748
  return escapeString(bundle);
662
749
  }
663
750
 
664
- // src/shared/utils/abort.ts
665
- function isAbortError(error) {
666
- if (error instanceof DOMException && error.name === "AbortError") {
667
- return true;
668
- }
669
- if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
670
- const e = error;
671
- return typeof e.code === "number" || e.constructor?.name === "DOMException";
672
- }
673
- return false;
674
- }
675
-
676
- // src/shared/client/fetch-with-protected-rc-fallback.ts
677
- async function fetchWithProtectedRcFallback(url, init) {
678
- try {
679
- const res = await fetch(url, init);
680
- return res;
681
- } catch (error) {
682
- if (isAbortError(error)) {
683
- throw error;
684
- }
685
- const parsedUrl = new URL(url);
686
- if (typeof document === "object" && typeof document.location === "object" && document.location.origin !== parsedUrl.origin) {
687
- logWarn(
688
- "FetchRemoteComponent",
689
- "Request failed due to CORS, attempting to fetch it via the withRemoteComponentsHost proxy."
690
- );
691
- const proxiedRes = await fetch(
692
- generateProtectedRcFallbackSrc(parsedUrl.href),
693
- init?.signal ? { signal: init.signal } : void 0
694
- );
695
- if (proxiedRes.status === 200) {
696
- logInfo(
697
- "FetchRemoteComponent",
698
- `Successfully fetched ${parsedUrl.href} with fallback withRemoteComponentsHost proxy`
699
- );
700
- return proxiedRes;
701
- } else {
702
- logError(
703
- "FetchRemoteComponent",
704
- `Could not proxy remote: [response status ${proxiedRes.status}] ${await proxiedRes.text()}`
705
- );
706
- }
707
- }
708
- throw error;
709
- }
710
- }
711
-
712
751
  // src/shared/client/turbopack-patterns.ts
713
752
  var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
714
753
  var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|e)\.A\((?<sharedModuleId>[0-9]+)\)/;
@@ -718,7 +757,7 @@ var ASYNC_MODULE_ALL_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<vCb
718
757
  var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
719
758
 
720
759
  // src/shared/client/chunk-loader.ts
721
- function createChunkLoader(runtime) {
760
+ function createChunkLoader(runtime, resolveClientUrl) {
722
761
  return function __turbopack_chunk_load__(chunkId, scriptBundle) {
723
762
  logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
724
763
  const self = globalThis;
@@ -758,9 +797,10 @@ function createChunkLoader(runtime) {
758
797
  logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
759
798
  return self.__remote_components_turbopack_chunk_loader_promise__[url];
760
799
  }
761
- logDebug("ChunkLoader", `Fetching chunk from: "${url}"`);
800
+ const resolvedUrl = resolveClientUrl?.(url) ?? url;
801
+ logDebug("ChunkLoader", `Fetching chunk from: "${resolvedUrl}"`);
762
802
  self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
763
- fetchWithProtectedRcFallback(url).then((res) => res.text()).then((code) => {
803
+ fetch(resolvedUrl).then((res) => res.text()).then((code) => {
764
804
  const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
765
805
  if (hasTurbopack) {
766
806
  return handleTurbopackChunk(code, bundle ?? "", url);
@@ -773,7 +813,19 @@ function createChunkLoader(runtime) {
773
813
  "ChunkLoader",
774
814
  `First 500 chars of chunk: ${code.slice(0, 500)}`
775
815
  );
776
- }).then(resolve).catch(reject);
816
+ }).then(resolve).catch((error) => {
817
+ const isProxied = isProxiedUrl(resolvedUrl);
818
+ if (isProxied) {
819
+ reject(
820
+ new RemoteComponentsError(
821
+ `Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHost middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
822
+ )
823
+ );
824
+ } else {
825
+ warnCrossOriginFetchError("ChunkLoader", url);
826
+ reject(error);
827
+ }
828
+ });
777
829
  });
778
830
  return self.__remote_components_turbopack_chunk_loader_promise__[url];
779
831
  };
@@ -1266,7 +1318,7 @@ function getSharedModule(bundle, id) {
1266
1318
  }
1267
1319
 
1268
1320
  // src/shared/client/webpack-adapter.ts
1269
- async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}) {
1321
+ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
1270
1322
  const self = globalThis;
1271
1323
  if (!self.__remote_bundle_url__) {
1272
1324
  self.__remote_bundle_url__ = {};
@@ -1278,7 +1330,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
1278
1330
  self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
1279
1331
  self.__original_webpack_require__ = self.__webpack_require__;
1280
1332
  }
1281
- self.__webpack_chunk_load__ = createChunkLoader(runtime);
1333
+ self.__webpack_chunk_load__ = createChunkLoader(runtime, resolveClientUrl);
1282
1334
  self.__webpack_require__ = createModuleRequire(runtime);
1283
1335
  self.__webpack_require_type__ = runtime;
1284
1336
  if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
@@ -1373,7 +1425,8 @@ async function loadRemoteComponent({
1373
1425
  scripts = [],
1374
1426
  shared = Promise.resolve({}),
1375
1427
  remoteShared = {},
1376
- container
1428
+ container,
1429
+ resolveClientUrl
1377
1430
  }) {
1378
1431
  try {
1379
1432
  if (runtime === "webpack") {
@@ -1382,7 +1435,7 @@ async function loadRemoteComponent({
1382
1435
  self.__DISABLE_WEBPACK_EXEC__ = {};
1383
1436
  }
1384
1437
  self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
1385
- await loadScripts(scripts);
1438
+ await loadScripts(scripts, resolveClientUrl);
1386
1439
  }
1387
1440
  const hostShared = await shared;
1388
1441
  logDebug(
@@ -1403,7 +1456,8 @@ async function loadRemoteComponent({
1403
1456
  url,
1404
1457
  bundle,
1405
1458
  hostShared,
1406
- remoteShared
1459
+ remoteShared,
1460
+ resolveClientUrl
1407
1461
  );
1408
1462
  if (bundle) {
1409
1463
  const resolve = {
@@ -1492,6 +1546,28 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
1492
1546
  return { component };
1493
1547
  }
1494
1548
 
1549
+ // src/shared/client/proxy-through-host.ts
1550
+ function withRemoteSrc(resolveClientUrl, remoteSrc) {
1551
+ return (url) => resolveClientUrl(remoteSrc, url);
1552
+ }
1553
+ var proxyClientRequestsThroughHost = (remoteSrc, url) => {
1554
+ if (typeof location === "undefined") {
1555
+ return void 0;
1556
+ }
1557
+ const remoteOrigin = new URL(remoteSrc, location.href).origin;
1558
+ if (remoteOrigin === location.origin) {
1559
+ return void 0;
1560
+ }
1561
+ try {
1562
+ const parsed = new URL(url, location.href);
1563
+ if (parsed.origin === remoteOrigin) {
1564
+ return generateProtectedRcFallbackSrc(url);
1565
+ }
1566
+ } catch {
1567
+ }
1568
+ return void 0;
1569
+ };
1570
+
1495
1571
  // src/shared/client/set-attributes-from-props.ts
1496
1572
  var DOMAttributeNames = {
1497
1573
  acceptCharset: "accept-charset",
@@ -1535,27 +1611,21 @@ function setAttributesFromProps(el, props) {
1535
1611
  }
1536
1612
 
1537
1613
  // src/shared/client/static-loader.ts
1538
- async function importViaProxy(absoluteSrc) {
1539
- const proxyUrl = new URL(
1540
- generateProtectedRcFallbackSrc(absoluteSrc),
1541
- location.href
1542
- ).href;
1543
- const response = await fetch(proxyUrl);
1614
+ async function importViaCallback(absoluteSrc, resolveClientUrl) {
1615
+ const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
1616
+ const fetchUrl = new URL(resolvedUrl, location.href).href;
1617
+ const response = await fetch(fetchUrl);
1544
1618
  if (!response.ok)
1545
- throw new Error(`Proxy fetch failed: ${response.status}`);
1546
- logInfo(
1547
- "StaticLoader",
1548
- `Successfully loaded ${absoluteSrc} via protected RC proxy fallback.`
1549
- );
1619
+ throw new Error(`Proxied fetch failed: ${response.status}`);
1550
1620
  const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
1551
1621
  /\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
1552
1622
  (_, keyword, quote, relativePath) => {
1553
1623
  const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
1554
- const absoluteProxyUrl = new URL(
1555
- generateProtectedRcFallbackSrc(absoluteImportUrl),
1624
+ const resolvedImportUrl = new URL(
1625
+ resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
1556
1626
  location.href
1557
1627
  ).href;
1558
- return `${keyword} ${quote}${absoluteProxyUrl}${quote}`;
1628
+ return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
1559
1629
  }
1560
1630
  );
1561
1631
  const moduleBlobUrl = URL.createObjectURL(
@@ -1589,6 +1659,20 @@ async function importViaProxy(absoluteSrc) {
1589
1659
  delete registry[absoluteSrc];
1590
1660
  return mod;
1591
1661
  }
1662
+ async function importDirectly(absoluteSrc) {
1663
+ try {
1664
+ return await import(
1665
+ /* @vite-ignore */
1666
+ /* webpackIgnore: true */
1667
+ absoluteSrc
1668
+ );
1669
+ } catch (importError) {
1670
+ if (!absoluteSrc.startsWith("blob:")) {
1671
+ warnCrossOriginFetchError("StaticLoader", absoluteSrc);
1672
+ }
1673
+ throw importError;
1674
+ }
1675
+ }
1592
1676
  function resolveScriptSrc(script, url) {
1593
1677
  const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
1594
1678
  if (!rawSrc && script.textContent) {
@@ -1601,24 +1685,7 @@ function resolveScriptSrc(script, url) {
1601
1685
  }
1602
1686
  return rawSrc;
1603
1687
  }
1604
- async function importScriptMod(absoluteSrc) {
1605
- try {
1606
- return await import(
1607
- /* @vite-ignore */
1608
- /* webpackIgnore: true */
1609
- absoluteSrc
1610
- );
1611
- } catch (importError) {
1612
- if (absoluteSrc.startsWith("blob:"))
1613
- throw importError;
1614
- logWarn(
1615
- "StaticLoader",
1616
- `Direct import of ${absoluteSrc} failed, attempting via protected RC proxy fallback.`
1617
- );
1618
- return importViaProxy(absoluteSrc);
1619
- }
1620
- }
1621
- async function loadStaticRemoteComponent(scripts, url) {
1688
+ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
1622
1689
  const self = globalThis;
1623
1690
  if (self.__remote_script_entrypoint_mount__?.[url.href]) {
1624
1691
  self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
@@ -1631,7 +1698,7 @@ async function loadStaticRemoteComponent(scripts, url) {
1631
1698
  try {
1632
1699
  const src = resolveScriptSrc(script, url);
1633
1700
  const absoluteSrc = new URL(src, url).href;
1634
- const mod = await importScriptMod(absoluteSrc);
1701
+ const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
1635
1702
  if (src.startsWith("blob:")) {
1636
1703
  URL.revokeObjectURL(src);
1637
1704
  }
@@ -1729,7 +1796,12 @@ async function fetchWithHooks(url, additionalInit, options = {}) {
1729
1796
  };
1730
1797
  let res = await onRequest?.(url, init, hookOptions);
1731
1798
  if (!res) {
1732
- res = await fetchWithProtectedRcFallback(url, init);
1799
+ try {
1800
+ res = await fetch(url, init);
1801
+ } catch (error) {
1802
+ warnCrossOriginFetchError("FetchRemoteComponent", url);
1803
+ throw error;
1804
+ }
1733
1805
  }
1734
1806
  const transformedRes = await onResponse?.(url, res, hookOptions);
1735
1807
  if (transformedRes) {
@@ -1747,15 +1819,34 @@ function getClientOrServerUrl(src, serverFallback) {
1747
1819
  return typeof src === "string" ? new URL(src, fallback) : src;
1748
1820
  }
1749
1821
 
1750
- // src/react/hooks/use-shadow-root.ts
1822
+ // src/react/hooks/use-resolve-client-url.ts
1751
1823
  var import_react = require("react");
1824
+ var import_context = require("#internal/react/context");
1825
+
1826
+ // src/shared/client/default-resolve-client-url.ts
1827
+ function bindResolveClientUrl(prop, remoteSrc) {
1828
+ return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
1829
+ }
1830
+
1831
+ // src/react/hooks/use-resolve-client-url.ts
1832
+ function useResolveClientUrl(prop, urlHref) {
1833
+ const { resolveClientUrl: contextValue } = (0, import_context.useRemoteComponentsContext)();
1834
+ const resolveClientUrl = prop ?? contextValue;
1835
+ return (0, import_react.useMemo)(
1836
+ () => bindResolveClientUrl(resolveClientUrl, urlHref),
1837
+ [resolveClientUrl, urlHref]
1838
+ );
1839
+ }
1840
+
1841
+ // src/react/hooks/use-shadow-root.ts
1842
+ var import_react2 = require("react");
1752
1843
  function useShadowRoot({
1753
1844
  isolate,
1754
1845
  mode,
1755
1846
  keySuffix
1756
1847
  }) {
1757
- const shadowRootContainerRef = (0, import_react.useRef)(null);
1758
- const [shadowRoot, setShadowRoot] = (0, import_react.useState)(() => {
1848
+ const shadowRootContainerRef = (0, import_react2.useRef)(null);
1849
+ const [shadowRoot, setShadowRoot] = (0, import_react2.useState)(() => {
1759
1850
  const self = globalThis;
1760
1851
  const shadowRootKey = `__remote_components_shadowroot_${keySuffix}`;
1761
1852
  const ssrShadowRoot = typeof document !== "undefined" ? document.querySelector(
@@ -1764,7 +1855,7 @@ function useShadowRoot({
1764
1855
  self[shadowRootKey] = null;
1765
1856
  return ssrShadowRoot;
1766
1857
  });
1767
- (0, import_react.useLayoutEffect)(() => {
1858
+ (0, import_react2.useLayoutEffect)(() => {
1768
1859
  if (isolate !== false && typeof document !== "undefined" && (!shadowRoot || !shadowRoot.isConnected)) {
1769
1860
  const self = globalThis;
1770
1861
  const shadowRootKey = `__remote_components_shadowroot_${keySuffix}`;
@@ -1819,11 +1910,12 @@ function getRemoteComponentHtml(html) {
1819
1910
  }
1820
1911
 
1821
1912
  // src/react/index.tsx
1913
+ var import_context2 = require("#internal/react/context");
1822
1914
  var import_jsx_runtime2 = (
1823
1915
  // TODO: remove wrapper div by converting HTML to RSC or React tree
1824
1916
  require("react/jsx-runtime")
1825
1917
  );
1826
- var import_react3 = require("react");
1918
+ var import_react4 = require("react");
1827
1919
  function RemoteComponent({
1828
1920
  src,
1829
1921
  isolate,
@@ -1838,10 +1930,11 @@ function RemoteComponent({
1838
1930
  onError,
1839
1931
  onChange,
1840
1932
  onRequest,
1841
- onResponse
1933
+ onResponse,
1934
+ resolveClientUrl: _resolveClientUrl
1842
1935
  }) {
1843
- const instanceId = (0, import_react2.useId)();
1844
- const name = (0, import_react2.useMemo)(() => {
1936
+ const instanceId = (0, import_react3.useId)();
1937
+ const name = (0, import_react3.useMemo)(() => {
1845
1938
  if (typeof src === "string") {
1846
1939
  const url2 = new URL(
1847
1940
  src,
@@ -1855,23 +1948,26 @@ function RemoteComponent({
1855
1948
  }
1856
1949
  return nameProp;
1857
1950
  }, [src, nameProp]);
1858
- const [data, setData] = (0, import_react2.useState)(null);
1859
- const url = (0, import_react2.useMemo)(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
1951
+ const [data, setData] = (0, import_react3.useState)(null);
1952
+ const url = (0, import_react3.useMemo)(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
1953
+ const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
1860
1954
  const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
1861
- const keySuffix = `${escapeString(id)}_${escapeString(data?.name ?? name)}_${escapeString(instanceId)}`;
1862
- const [remoteComponent, setRemoteComponent] = (0, import_react2.useState)(null);
1955
+ const keySuffix = `${escapeString(id)}_${escapeString(
1956
+ data?.name ?? name
1957
+ )}_${escapeString(instanceId)}`;
1958
+ const [remoteComponent, setRemoteComponent] = (0, import_react3.useState)(null);
1863
1959
  const { shadowRoot, shadowRootContainerRef } = useShadowRoot({
1864
1960
  isolate,
1865
1961
  mode,
1866
1962
  keySuffix
1867
1963
  });
1868
- const htmlRef = (0, import_react2.useRef)(
1964
+ const htmlRef = (0, import_react3.useRef)(
1869
1965
  typeof document !== "undefined" ? document.querySelector(
1870
1966
  `[data-remote-component-id="shadowroot_${keySuffix}"]`
1871
1967
  )?.shadowRoot?.innerHTML ?? document.getElementById(`__REMOTE_COMPONENT${name}`)?.innerHTML ?? document.querySelector(`div[data-bundle][data-route][id^="${name}"]`)?.innerHTML ?? document.querySelector("div[data-bundle][data-route]")?.innerHTML : null
1872
1968
  );
1873
- const endTemplateRef = (0, import_react2.useRef)(null);
1874
- const childrenRef = (0, import_react2.useRef)(
1969
+ const endTemplateRef = (0, import_react3.useRef)(null);
1970
+ const childrenRef = (0, import_react3.useRef)(
1875
1971
  typeof document !== "undefined" ? (() => {
1876
1972
  let el = document.querySelector(`template[id="${name}_start"]`);
1877
1973
  const elements = [];
@@ -1884,20 +1980,20 @@ function RemoteComponent({
1884
1980
  return elements;
1885
1981
  })() : []
1886
1982
  );
1887
- const prevSrcRef = (0, import_react2.useRef)(null);
1888
- const componentHydrationHtml = (0, import_react2.useRef)(null);
1889
- const prevIsRemoteComponentRef = (0, import_react2.useRef)(false);
1890
- const prevUrlRef = (0, import_react2.useRef)(null);
1891
- const prevRemoteComponentContainerRef = (0, import_react2.useRef)(null);
1892
- const unmountRef = (0, import_react2.useRef)(null);
1893
- const prevNameRef = (0, import_react2.useRef)(void 0);
1894
- (0, import_react2.useLayoutEffect)(() => {
1983
+ const prevSrcRef = (0, import_react3.useRef)(null);
1984
+ const componentHydrationHtml = (0, import_react3.useRef)(null);
1985
+ const prevIsRemoteComponentRef = (0, import_react3.useRef)(false);
1986
+ const prevUrlRef = (0, import_react3.useRef)(null);
1987
+ const prevRemoteComponentContainerRef = (0, import_react3.useRef)(null);
1988
+ const unmountRef = (0, import_react3.useRef)(null);
1989
+ const prevNameRef = (0, import_react3.useRef)(void 0);
1990
+ (0, import_react3.useLayoutEffect)(() => {
1895
1991
  const shadowRootKey = `__remote_components_shadowroot_${keySuffix}`;
1896
1992
  return () => {
1897
1993
  delete globalThis[shadowRootKey];
1898
1994
  };
1899
1995
  }, [keySuffix]);
1900
- (0, import_react2.useLayoutEffect)(() => {
1996
+ (0, import_react3.useLayoutEffect)(() => {
1901
1997
  if (childrenRef.current.length > 0 && remoteComponent) {
1902
1998
  childrenRef.current.forEach((el) => {
1903
1999
  el.remove();
@@ -1905,7 +2001,7 @@ function RemoteComponent({
1905
2001
  childrenRef.current = [];
1906
2002
  }
1907
2003
  }, [remoteComponent]);
1908
- (0, import_react2.useLayoutEffect)(() => {
2004
+ (0, import_react3.useLayoutEffect)(() => {
1909
2005
  if (shadowRoot && remoteComponent) {
1910
2006
  const resetStyles = shadowRoot.querySelectorAll(
1911
2007
  "style[data-remote-components-reset]"
@@ -1928,7 +2024,7 @@ function RemoteComponent({
1928
2024
  }
1929
2025
  }
1930
2026
  }, [shadowRoot, remoteComponent, name]);
1931
- (0, import_react2.useEffect)(() => {
2027
+ (0, import_react3.useEffect)(() => {
1932
2028
  if (src && src !== prevSrcRef.current) {
1933
2029
  const previousSrc = prevSrcRef.current;
1934
2030
  const previousName = prevNameRef.current;
@@ -1937,7 +2033,7 @@ function RemoteComponent({
1937
2033
  htmlRef.current = null;
1938
2034
  }
1939
2035
  onBeforeLoad?.(src);
1940
- (0, import_react2.startTransition)(async () => {
2036
+ (0, import_react3.startTransition)(async () => {
1941
2037
  try {
1942
2038
  let html = getRemoteComponentHtml(
1943
2039
  htmlRef.current ?? (endTemplateRef.current?.previousElementSibling?.tagName === "div" ? endTemplateRef.current.previousElementSibling.innerHTML : "")
@@ -1946,41 +2042,18 @@ function RemoteComponent({
1946
2042
  const fetchInit = {
1947
2043
  credentials
1948
2044
  };
2045
+ const resolvedUrl = new URL(
2046
+ resolveClientUrl?.(url.href) ?? url.href,
2047
+ location.href
2048
+ );
1949
2049
  const abortController = new AbortController();
1950
- const res = await fetchWithHooks(url, fetchInit, {
2050
+ const res = await fetchWithHooks(resolvedUrl, fetchInit, {
1951
2051
  onRequest,
1952
2052
  onResponse,
1953
2053
  abortController
1954
2054
  });
1955
2055
  if (!res || !res.ok) {
1956
- let error = failedToFetchRemoteComponentError(
1957
- url.href,
1958
- res ?? new Response(null, { status: 0 })
1959
- );
1960
- try {
1961
- const body = await res.text();
1962
- const parser2 = new DOMParser();
1963
- const doc2 = parser2.parseFromString(body, "text/html");
1964
- const errorTemplate = doc2.querySelector(
1965
- "template[data-next-error-message]"
1966
- );
1967
- const errorMessage = errorTemplate?.getAttribute(
1968
- "data-next-error-message"
1969
- );
1970
- const errorStack = errorTemplate?.getAttribute(
1971
- "data-next-error-stack"
1972
- );
1973
- if (errorMessage) {
1974
- error = new RemoteComponentsError(errorMessage);
1975
- if (errorStack) {
1976
- error.stack = errorStack;
1977
- }
1978
- }
1979
- } catch (parseError) {
1980
- if (isAbortError(parseError))
1981
- throw parseError;
1982
- }
1983
- throw error;
2056
+ throw await errorFromFailedFetch(url.href, resolvedUrl, res);
1984
2057
  }
1985
2058
  const remoteHtml = await res.text();
1986
2059
  htmlRef.current = remoteHtml;
@@ -2041,7 +2114,7 @@ function RemoteComponent({
2041
2114
  prevIsRemoteComponentRef.current = isRemoteComponent;
2042
2115
  prevUrlRef.current = url;
2043
2116
  prevNameRef.current = remoteName;
2044
- applyOriginToNodes(doc, url);
2117
+ applyOriginToNodes(doc, url, resolveClientUrl);
2045
2118
  const links = Array.from(
2046
2119
  doc.querySelectorAll("link[href]")
2047
2120
  ).filter((link) => {
@@ -2165,7 +2238,8 @@ function RemoteComponent({
2165
2238
  setRemoteComponent(null);
2166
2239
  const { mount, unmount } = await loadStaticRemoteComponent(
2167
2240
  Array.from(shadowRoot.querySelectorAll("script")),
2168
- url
2241
+ url,
2242
+ resolveClientUrl
2169
2243
  );
2170
2244
  unmountRef.current = unmount;
2171
2245
  await Promise.all(
@@ -2185,7 +2259,8 @@ function RemoteComponent({
2185
2259
  htmlRef.current = null;
2186
2260
  const { mount, unmount } = await loadStaticRemoteComponent(
2187
2261
  Array.from(component.querySelectorAll("script")),
2188
- url
2262
+ url,
2263
+ resolveClientUrl
2189
2264
  );
2190
2265
  unmountRef.current = unmount;
2191
2266
  await Promise.all(
@@ -2228,7 +2303,8 @@ function RemoteComponent({
2228
2303
  ...userShared
2229
2304
  },
2230
2305
  remoteShared,
2231
- container: shadowRoot
2306
+ container: shadowRoot,
2307
+ resolveClientUrl
2232
2308
  });
2233
2309
  if (rsc) {
2234
2310
  rsc.remove();
@@ -2274,7 +2350,8 @@ function RemoteComponent({
2274
2350
  onError,
2275
2351
  onChange,
2276
2352
  onRequest,
2277
- onResponse
2353
+ onResponse,
2354
+ resolveClientUrl
2278
2355
  ]);
2279
2356
  if (remoteComponent instanceof Error) {
2280
2357
  throw remoteComponent;
@@ -2286,7 +2363,7 @@ function RemoteComponent({
2286
2363
  runtime: prevIsRemoteComponentRef.current ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
2287
2364
  }) });
2288
2365
  const resetStyle = reset ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
2289
- const linksToRender = data?.links?.map((link) => /* @__PURE__ */ (0, import_react3.createElement)(
2366
+ const linksToRender = data?.links?.map((link) => /* @__PURE__ */ (0, import_react4.createElement)(
2290
2367
  "link",
2291
2368
  {
2292
2369
  ...link,
@@ -2305,7 +2382,8 @@ function RemoteComponent({
2305
2382
  if (prevIsRemoteComponentRef.current) {
2306
2383
  loadStaticRemoteComponent(
2307
2384
  Array.from(shadowRoot.querySelectorAll("script")),
2308
- url
2385
+ url,
2386
+ resolveClientUrl
2309
2387
  ).then(({ mount }) => {
2310
2388
  return Promise.all(
2311
2389
  Array.from(mount).map((mountFn) => mountFn(shadowRoot))
@@ -2389,6 +2467,8 @@ function RemoteComponent({
2389
2467
  }
2390
2468
  // Annotate the CommonJS export names for ESM import in node:
2391
2469
  0 && (module.exports = {
2392
- RemoteComponent
2470
+ RemoteComponent,
2471
+ RemoteComponentsProvider,
2472
+ proxyClientRequestsThroughHost
2393
2473
  });
2394
2474
  //# sourceMappingURL=index.cjs.map