remote-components 0.0.50 → 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 (119) hide show
  1. package/dist/{component-loader-1838f572.d.ts → component-loader-76eb1b8b.d.ts} +3 -1
  2. package/dist/html/host.cjs +486 -242
  3. package/dist/html/host.cjs.map +1 -1
  4. package/dist/html/host.d.ts +2 -0
  5. package/dist/html/host.js +485 -242
  6. package/dist/html/host.js.map +1 -1
  7. package/dist/html/remote.cjs +123 -21
  8. package/dist/html/remote.cjs.map +1 -1
  9. package/dist/html/remote.js +123 -21
  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 +41 -0
  37. package/dist/internal/shared/client/protected-rc-fallback.cjs.map +1 -0
  38. package/dist/internal/shared/client/protected-rc-fallback.d.ts +7 -0
  39. package/dist/internal/shared/client/protected-rc-fallback.js +16 -0
  40. package/dist/internal/shared/client/protected-rc-fallback.js.map +1 -0
  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 +208 -134
  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 +207 -134
  50. package/dist/internal/shared/client/remote-component.js.map +1 -1
  51. package/dist/internal/shared/constants.cjs +32 -0
  52. package/dist/internal/shared/constants.cjs.map +1 -0
  53. package/dist/internal/shared/constants.d.ts +4 -0
  54. package/dist/internal/shared/constants.js +7 -0
  55. package/dist/internal/shared/constants.js.map +1 -0
  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-remote-component.cjs +1 -2
  62. package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
  63. package/dist/internal/shared/ssr/fetch-remote-component.js +1 -2
  64. package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
  65. package/dist/internal/shared/ssr/fetch-with-hooks.cjs +7 -2
  66. package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +1 -1
  67. package/dist/internal/shared/ssr/fetch-with-hooks.js +7 -2
  68. package/dist/internal/shared/ssr/fetch-with-hooks.js.map +1 -1
  69. package/dist/internal/shared/utils/logger.cjs +26 -10
  70. package/dist/internal/shared/utils/logger.cjs.map +1 -1
  71. package/dist/internal/shared/utils/logger.d.ts +7 -2
  72. package/dist/internal/shared/utils/logger.js +24 -9
  73. package/dist/internal/shared/utils/logger.js.map +1 -1
  74. package/dist/next/config.cjs +2 -2
  75. package/dist/next/config.cjs.map +1 -1
  76. package/dist/next/config.js +2 -2
  77. package/dist/next/config.js.map +1 -1
  78. package/dist/next/host/client/index.cjs +363 -207
  79. package/dist/next/host/client/index.cjs.map +1 -1
  80. package/dist/next/host/client/index.d.ts +3 -1
  81. package/dist/next/host/client/index.js +336 -181
  82. package/dist/next/host/client/index.js.map +1 -1
  83. package/dist/next/host/pages-router-client.cjs +15 -2
  84. package/dist/next/host/pages-router-client.cjs.map +1 -1
  85. package/dist/next/host/pages-router-client.d.ts +12 -1
  86. package/dist/next/host/pages-router-client.js +15 -2
  87. package/dist/next/host/pages-router-client.js.map +1 -1
  88. package/dist/next/host/pages-router-server.cjs +3 -2
  89. package/dist/next/host/pages-router-server.cjs.map +1 -1
  90. package/dist/next/host/pages-router-server.d.ts +16 -0
  91. package/dist/next/host/pages-router-server.js +3 -2
  92. package/dist/next/host/pages-router-server.js.map +1 -1
  93. package/dist/next/proxy.cjs +66 -27
  94. package/dist/next/proxy.cjs.map +1 -1
  95. package/dist/next/proxy.d.ts +0 -1
  96. package/dist/next/proxy.js +66 -27
  97. package/dist/next/proxy.js.map +1 -1
  98. package/dist/proxy-through-host-a676a522.d.ts +52 -0
  99. package/dist/react/index.cjs +381 -206
  100. package/dist/react/index.cjs.map +1 -1
  101. package/dist/react/index.d.ts +28 -4
  102. package/dist/react/index.js +354 -181
  103. package/dist/react/index.js.map +1 -1
  104. package/dist/shared/host/proxy.cjs +52 -23
  105. package/dist/shared/host/proxy.cjs.map +1 -1
  106. package/dist/shared/host/proxy.d.ts +0 -3
  107. package/dist/shared/host/proxy.js +55 -22
  108. package/dist/shared/host/proxy.js.map +1 -1
  109. package/dist/shared/remote/proxy.cjs +9 -1
  110. package/dist/shared/remote/proxy.cjs.map +1 -1
  111. package/dist/shared/remote/proxy.d.ts +7 -1
  112. package/dist/shared/remote/proxy.js +8 -1
  113. package/dist/shared/remote/proxy.js.map +1 -1
  114. package/package.json +1 -1
  115. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs +0 -62
  116. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs.map +0 -1
  117. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.d.ts +0 -14
  118. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js +0 -37
  119. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js.map +0 -1
@@ -9,7 +9,7 @@ import {
9
9
  useEffect,
10
10
  useId,
11
11
  useLayoutEffect as useLayoutEffect2,
12
- useMemo,
12
+ useMemo as useMemo2,
13
13
  useRef as useRef2,
14
14
  useState as useState2
15
15
  } from "react";
@@ -27,7 +27,7 @@ var tagNames = [
27
27
  "script",
28
28
  "link"
29
29
  ];
30
- function applyOriginToNodes(doc, url) {
30
+ function applyOriginToNodes(doc, url, resolveClientUrl) {
31
31
  if (url.origin !== location.origin) {
32
32
  const nodes = doc.querySelectorAll(
33
33
  tagNames.map(
@@ -36,12 +36,15 @@ function applyOriginToNodes(doc, url) {
36
36
  );
37
37
  nodes.forEach((node) => {
38
38
  if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
39
- node.src = new URL(node.getAttribute("src") ?? "/", url).href;
39
+ const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
40
+ const isScript = node.tagName.toLowerCase() === "script";
41
+ node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
40
42
  }
41
43
  if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
44
+ const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
42
45
  node.setAttribute(
43
46
  "href",
44
- new URL(node.getAttribute("href") ?? "/", url).href
47
+ resolveClientUrl?.(absoluteHref) ?? absoluteHref
45
48
  );
46
49
  }
47
50
  if (node.hasAttribute("srcset")) {
@@ -50,7 +53,8 @@ function applyOriginToNodes(doc, url) {
50
53
  if (!urlPart)
51
54
  return entry;
52
55
  const absoluteUrl = new URL(urlPart, url).href;
53
- return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
56
+ const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
57
+ return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
54
58
  }).join(", ");
55
59
  if (srcSet) {
56
60
  node.setAttribute("srcset", srcSet);
@@ -62,7 +66,8 @@ function applyOriginToNodes(doc, url) {
62
66
  if (!urlPart)
63
67
  return entry;
64
68
  const absoluteUrl = new URL(urlPart, url).href;
65
- return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
69
+ const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
70
+ return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
66
71
  }).join(", ");
67
72
  if (srcSet) {
68
73
  node.setAttribute("imagesrcset", srcSet);
@@ -72,6 +77,31 @@ function applyOriginToNodes(doc, url) {
72
77
  }
73
78
  }
74
79
 
80
+ // src/shared/constants.ts
81
+ var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
82
+ var CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
83
+
84
+ // src/shared/client/protected-rc-fallback.ts
85
+ function isProxiedUrl(url) {
86
+ try {
87
+ return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
88
+ } catch {
89
+ return false;
90
+ }
91
+ }
92
+
93
+ // src/shared/utils/abort.ts
94
+ function isAbortError(error) {
95
+ if (error instanceof DOMException && error.name === "AbortError") {
96
+ return true;
97
+ }
98
+ if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
99
+ const e = error;
100
+ return typeof e.code === "number" || e.constructor?.name === "DOMException";
101
+ }
102
+ return false;
103
+ }
104
+
75
105
  // src/shared/error.ts
76
106
  var RemoteComponentsError = class extends Error {
77
107
  code = "REMOTE_COMPONENTS_ERROR";
@@ -91,6 +121,69 @@ function failedToFetchRemoteComponentError(url, { status, statusText }, help = "
91
121
  { cause: new Error(`${status} ${statusText}`) }
92
122
  );
93
123
  }
124
+ async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
125
+ const isProxied = isProxiedUrl(resolvedUrl.href);
126
+ if (isProxied && res) {
127
+ const body = await res.text().catch(() => "");
128
+ return failedProxyFetchError(
129
+ originalUrl,
130
+ resolvedUrl.href,
131
+ res.status,
132
+ body
133
+ );
134
+ }
135
+ const fallback = failedToFetchRemoteComponentError(
136
+ originalUrl,
137
+ res ?? { status: 0, statusText: "No Response" }
138
+ );
139
+ if (!res)
140
+ return fallback;
141
+ try {
142
+ const body = await res.text();
143
+ const parser = new DOMParser();
144
+ const doc = parser.parseFromString(body, "text/html");
145
+ const errorTemplate = doc.querySelector(
146
+ "template[data-next-error-message]"
147
+ );
148
+ const errorMessage = errorTemplate?.getAttribute("data-next-error-message");
149
+ if (errorMessage) {
150
+ const error = new RemoteComponentsError(errorMessage);
151
+ const errorStack = errorTemplate?.getAttribute("data-next-error-stack");
152
+ if (errorStack) {
153
+ error.stack = errorStack;
154
+ }
155
+ return error;
156
+ }
157
+ } catch (parseError) {
158
+ if (isAbortError(parseError))
159
+ throw parseError;
160
+ }
161
+ return fallback;
162
+ }
163
+ function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
164
+ if (status === 404) {
165
+ return new RemoteComponentsError(
166
+ `Could not proxy the request to "${originalUrl}" \u2014 the proxy endpoint "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" returned 404.
167
+
168
+ The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
169
+
170
+ Proxying requires two pieces:
171
+ 1. resolveClientUrl={proxyClientRequestsThroughHost} on <RemoteComponent>
172
+ 2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
173
+
174
+ Docs: ${CORS_DOCS_URL}`
175
+ );
176
+ }
177
+ if (status === 403) {
178
+ const detail = responseBody ? ` ${responseBody}` : "";
179
+ return new RemoteComponentsError(
180
+ `Proxied request to "${proxyUrl}" was forbidden.${detail} See: ${CORS_DOCS_URL}`
181
+ );
182
+ }
183
+ return new RemoteComponentsError(
184
+ `Proxied request for "${originalUrl}" via "${proxyUrl}" failed with status ${status}. See: ${CORS_DOCS_URL}`
185
+ );
186
+ }
94
187
 
95
188
  // src/shared/utils/logger.ts
96
189
  var PREFIX = "remote-components";
@@ -100,9 +193,6 @@ function logDebug(location2, message) {
100
193
  console.debug(`[${PREFIX}:${location2}]: ${message}`);
101
194
  }
102
195
  }
103
- function logInfo(location2, message) {
104
- console.info(`[${PREFIX}:${location2}]: ${message}`);
105
- }
106
196
  function logWarn(location2, message) {
107
197
  console.warn(`[${PREFIX}:${location2}]: ${message}`);
108
198
  }
@@ -113,6 +203,19 @@ function logError(location2, message, cause) {
113
203
  })
114
204
  );
115
205
  }
206
+ function warnCrossOriginFetchError(logLocation, url) {
207
+ try {
208
+ const parsed = typeof url === "string" ? new URL(url) : url;
209
+ if (typeof location === "undefined" || parsed.origin === location.origin) {
210
+ return;
211
+ }
212
+ logWarn(
213
+ logLocation,
214
+ `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}`
215
+ );
216
+ } catch {
217
+ }
218
+ }
116
219
 
117
220
  // src/shared/client/polyfill.tsx
118
221
  import { jsx } from "react/jsx-runtime";
@@ -556,28 +659,40 @@ function createRSCStream(rscName, data) {
556
659
  });
557
660
  }
558
661
 
662
+ // src/shared/client/webpack-patterns.ts
663
+ var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
664
+
559
665
  // src/shared/client/script-loader.ts
560
- async function loadScripts(scripts) {
666
+ async function loadScripts(scripts, resolveClientUrl) {
561
667
  await Promise.all(
562
668
  scripts.map((script) => {
563
669
  return new Promise((resolve, reject) => {
564
670
  const newSrc = new URL(
565
671
  // remove the remote component bundle name identifier from the script src
566
- script.src.replace(/\/_next\/\[.+\](?<whitespace>%20| )/, "/_next/"),
672
+ script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
567
673
  location.origin
568
674
  ).href;
675
+ const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
569
676
  const newScript = document.createElement("script");
570
- newScript.onload = () => {
571
- resolve();
572
- };
677
+ newScript.onload = () => resolve();
573
678
  newScript.onerror = () => {
574
- reject(
575
- new RemoteComponentsError(
576
- `Failed to load <script src="${script.src}"> for Remote Component. Check the URL is correct.`
577
- )
578
- );
679
+ const isProxied = isProxiedUrl(resolvedSrc);
680
+ if (isProxied) {
681
+ reject(
682
+ new RemoteComponentsError(
683
+ `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}`
684
+ )
685
+ );
686
+ } else {
687
+ warnCrossOriginFetchError("ScriptLoader", newSrc);
688
+ reject(
689
+ new RemoteComponentsError(
690
+ `Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
691
+ )
692
+ );
693
+ }
579
694
  };
580
- newScript.src = newSrc;
695
+ newScript.src = resolvedSrc;
581
696
  newScript.async = true;
582
697
  document.head.appendChild(newScript);
583
698
  });
@@ -585,50 +700,6 @@ async function loadScripts(scripts) {
585
700
  );
586
701
  }
587
702
 
588
- // src/shared/utils/abort.ts
589
- function isAbortError(error) {
590
- if (error instanceof DOMException && error.name === "AbortError") {
591
- return true;
592
- }
593
- if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
594
- const e = error;
595
- return typeof e.code === "number" || e.constructor?.name === "DOMException";
596
- }
597
- return false;
598
- }
599
-
600
- // src/shared/ssr/fetch-with-protected-rc-fallback.ts
601
- var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
602
- async function fetchWithProtectedRcFallback(url, init) {
603
- try {
604
- const res = await fetch(url, init);
605
- return res;
606
- } catch (error) {
607
- if (isAbortError(error)) {
608
- throw error;
609
- }
610
- if (typeof document === "object" && typeof document.location === "object" && document.location.origin !== new URL(url).origin) {
611
- logInfo(
612
- "FetchRemoteComponent",
613
- "Request failed due to CORS, attempting to fetch it via the withRemoteComponentsHost proxy."
614
- );
615
- const proxiedRes = await fetch(
616
- `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${url}`,
617
- init?.signal ? { signal: init.signal } : void 0
618
- );
619
- if (proxiedRes.status === 200) {
620
- return proxiedRes;
621
- } else {
622
- logError(
623
- "FetchRemoteComponent",
624
- `Could not proxy remote: [response status ${proxiedRes.status}] ${await proxiedRes.text()}`
625
- );
626
- }
627
- }
628
- throw error;
629
- }
630
- }
631
-
632
703
  // src/shared/utils/index.ts
633
704
  function escapeString(str) {
634
705
  return str.replace(/[^a-z0-9]/g, "_");
@@ -657,11 +728,10 @@ var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopac
657
728
  var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
658
729
  var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
659
730
  var ASYNC_MODULE_ALL_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<vCb>parentImport|t)=>Promise\.all\(\["[^"]+"\]\.map\((?<mapCb>chunk|t)=>\k<ctx>\.l\(\k<mapCb>\)\)\)\.then\(\(\)=>\k<vCb>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
660
- var NUMERIC_MODULE_ID_RE = /^[0-9]+$/;
661
731
  var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
662
732
 
663
733
  // src/shared/client/chunk-loader.ts
664
- function createChunkLoader(runtime) {
734
+ function createChunkLoader(runtime, resolveClientUrl) {
665
735
  return function __turbopack_chunk_load__(chunkId, scriptBundle) {
666
736
  logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
667
737
  const self = globalThis;
@@ -701,9 +771,10 @@ function createChunkLoader(runtime) {
701
771
  logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
702
772
  return self.__remote_components_turbopack_chunk_loader_promise__[url];
703
773
  }
704
- logDebug("ChunkLoader", `Fetching chunk from: "${url}"`);
774
+ const resolvedUrl = resolveClientUrl?.(url) ?? url;
775
+ logDebug("ChunkLoader", `Fetching chunk from: "${resolvedUrl}"`);
705
776
  self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
706
- fetchWithProtectedRcFallback(url).then((res) => res.text()).then((code) => {
777
+ fetch(resolvedUrl).then((res) => res.text()).then((code) => {
707
778
  const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
708
779
  if (hasTurbopack) {
709
780
  return handleTurbopackChunk(code, bundle ?? "", url);
@@ -716,7 +787,19 @@ function createChunkLoader(runtime) {
716
787
  "ChunkLoader",
717
788
  `First 500 chars of chunk: ${code.slice(0, 500)}`
718
789
  );
719
- }).then(resolve).catch(reject);
790
+ }).then(resolve).catch((error) => {
791
+ const isProxied = isProxiedUrl(resolvedUrl);
792
+ if (isProxied) {
793
+ reject(
794
+ new RemoteComponentsError(
795
+ `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}`
796
+ )
797
+ );
798
+ } else {
799
+ warnCrossOriginFetchError("ChunkLoader", url);
800
+ reject(error);
801
+ }
802
+ });
720
803
  });
721
804
  return self.__remote_components_turbopack_chunk_loader_promise__[url];
722
805
  };
@@ -863,10 +946,14 @@ async function handleTurbopackChunk(code, bundle, url) {
863
946
  function handleTurbopackModule(bundle, moduleId, id) {
864
947
  const self = globalThis;
865
948
  const bundleKey = getBundleKey(bundle);
866
- let modules = self[`TURBOPACK_${bundleKey}`];
867
- if (modules && typeof modules === "object" && "__chunks__" in modules) {
868
- const chunks = modules.__chunks__;
869
- modules = chunks.flat();
949
+ const raw = self[`TURBOPACK_${bundleKey}`];
950
+ let modules;
951
+ if (raw && typeof raw === "object" && "__chunks__" in raw) {
952
+ modules = raw.__chunks__.flat();
953
+ } else if (Array.isArray(raw)) {
954
+ modules = raw.flat();
955
+ } else {
956
+ modules = raw;
870
957
  }
871
958
  if (!self.__remote_components_turbopack_modules__) {
872
959
  self.__remote_components_turbopack_modules__ = {};
@@ -895,13 +982,12 @@ function handleTurbopackModule(bundle, moduleId, id) {
895
982
  if (!self.__remote_components_turbopack_global__[bundle]) {
896
983
  self.__remote_components_turbopack_global__[bundle] = {};
897
984
  }
898
- const allModules = Array.isArray(modules) ? modules.flat() : modules ? Object.values(modules) : [];
899
985
  moduleInit(
900
986
  createTurbopackContext(
901
987
  bundle,
902
988
  exports,
903
989
  moduleExports,
904
- allModules,
990
+ modules,
905
991
  moduleInit,
906
992
  id,
907
993
  self
@@ -915,46 +1001,27 @@ function handleTurbopackModule(bundle, moduleId, id) {
915
1001
  return moduleExports.exports;
916
1002
  }
917
1003
  function findModuleInit(modules, moduleId) {
918
- if (modules && !Array.isArray(modules) && typeof modules === "object") {
919
- const normalizedId = NUMERIC_MODULE_ID_RE.test(moduleId) ? Number(moduleId) : moduleId;
920
- if (normalizedId in modules) {
921
- return modules[normalizedId];
922
- }
923
- if (typeof normalizedId === "number" && String(normalizedId) in modules) {
924
- return modules[String(normalizedId)];
925
- }
926
- const matchingKey = Object.keys(modules).find(
927
- (key) => typeof key === "string" && key.includes(String(moduleId))
1004
+ if (!modules || typeof modules !== "object")
1005
+ return;
1006
+ if (!Array.isArray(modules)) {
1007
+ const key = moduleId in modules ? moduleId : Object.keys(modules).find((k) => k.startsWith(moduleId));
1008
+ return key !== void 0 ? modules[key] : void 0;
1009
+ }
1010
+ const flat = modules.flat();
1011
+ let idx = flat.findIndex((e) => String(e) === String(moduleId));
1012
+ if (idx < 0) {
1013
+ idx = flat.findIndex(
1014
+ (e) => typeof e === "string" && e.startsWith(moduleId)
928
1015
  );
929
- if (matchingKey) {
930
- return modules[matchingKey];
931
- }
932
- logError("TurbopackModule", `No match found for module ID: ${moduleId}`);
933
- return void 0;
934
1016
  }
935
- const allModules = modules?.flat() ?? [];
936
- if (typeof allModules[1] === "string" || typeof allModules[1] === "number") {
937
- const normalizedId = NUMERIC_MODULE_ID_RE.test(moduleId) ? Number(moduleId) : moduleId;
938
- let moduleIdIndex = allModules.indexOf(normalizedId);
939
- if (moduleIdIndex === -1) {
940
- moduleIdIndex = allModules.findIndex(
941
- (bundleEntry) => typeof bundleEntry === "string" && bundleEntry.startsWith(moduleId) || bundleEntry === normalizedId
942
- );
943
- }
944
- if (moduleIdIndex !== -1) {
945
- while (typeof allModules[moduleIdIndex] !== "function" && moduleIdIndex < allModules.length) {
946
- moduleIdIndex++;
947
- }
948
- return allModules[moduleIdIndex];
949
- }
950
- } else {
951
- return allModules.find(
952
- (bundleEntry) => typeof bundleEntry === "object" && bundleEntry !== null && moduleId in bundleEntry
953
- )?.[moduleId];
1017
+ if (idx >= 0) {
1018
+ return flat.slice(idx + 1).find((e) => typeof e === "function");
954
1019
  }
955
- return void 0;
1020
+ return flat.find(
1021
+ (e) => Boolean(e && typeof e === "object" && moduleId in e)
1022
+ )?.[moduleId];
956
1023
  }
957
- function createTurbopackContext(bundle, exports, moduleExports, allModules, moduleInit, id, self) {
1024
+ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleInit, id, self) {
958
1025
  return {
959
1026
  // HMR not implemented for Remote Components
960
1027
  k: {
@@ -1075,13 +1142,17 @@ function createTurbopackContext(bundle, exports, moduleExports, allModules, modu
1075
1142
  (parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
1076
1143
  );
1077
1144
  },
1145
+ // dynamic import tracking — no-op for remote components
1146
+ j() {
1147
+ },
1078
1148
  // chunk loader
1079
1149
  l(url) {
1080
- const moduleInitIndex = allModules.indexOf(moduleInit);
1150
+ const flatModules = Array.isArray(modules) ? modules : [];
1151
+ const moduleInitIndex = flatModules.indexOf(moduleInit);
1081
1152
  if (moduleInitIndex !== -1) {
1082
- const scriptIndex = allModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
1153
+ const scriptIndex = flatModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
1083
1154
  if (scriptIndex !== -1) {
1084
- const script = allModules[scriptIndex];
1155
+ const script = flatModules[scriptIndex];
1085
1156
  const scriptSrc = script.getAttribute("data-turbopack-src") || "";
1086
1157
  const nextIndex = scriptSrc.indexOf("/_next");
1087
1158
  const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
@@ -1221,7 +1292,7 @@ function getSharedModule(bundle, id) {
1221
1292
  }
1222
1293
 
1223
1294
  // src/shared/client/webpack-adapter.ts
1224
- async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}) {
1295
+ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
1225
1296
  const self = globalThis;
1226
1297
  if (!self.__remote_bundle_url__) {
1227
1298
  self.__remote_bundle_url__ = {};
@@ -1233,7 +1304,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
1233
1304
  self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
1234
1305
  self.__original_webpack_require__ = self.__webpack_require__;
1235
1306
  }
1236
- self.__webpack_chunk_load__ = createChunkLoader(runtime);
1307
+ self.__webpack_chunk_load__ = createChunkLoader(runtime, resolveClientUrl);
1237
1308
  self.__webpack_require__ = createModuleRequire(runtime);
1238
1309
  self.__webpack_require_type__ = runtime;
1239
1310
  if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
@@ -1328,7 +1399,8 @@ async function loadRemoteComponent({
1328
1399
  scripts = [],
1329
1400
  shared = Promise.resolve({}),
1330
1401
  remoteShared = {},
1331
- container
1402
+ container,
1403
+ resolveClientUrl
1332
1404
  }) {
1333
1405
  try {
1334
1406
  if (runtime === "webpack") {
@@ -1337,7 +1409,7 @@ async function loadRemoteComponent({
1337
1409
  self.__DISABLE_WEBPACK_EXEC__ = {};
1338
1410
  }
1339
1411
  self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
1340
- await loadScripts(scripts);
1412
+ await loadScripts(scripts, resolveClientUrl);
1341
1413
  }
1342
1414
  const hostShared = await shared;
1343
1415
  logDebug(
@@ -1358,7 +1430,8 @@ async function loadRemoteComponent({
1358
1430
  url,
1359
1431
  bundle,
1360
1432
  hostShared,
1361
- remoteShared
1433
+ remoteShared,
1434
+ resolveClientUrl
1362
1435
  );
1363
1436
  if (bundle) {
1364
1437
  const resolve = {
@@ -1447,6 +1520,11 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
1447
1520
  return { component };
1448
1521
  }
1449
1522
 
1523
+ // src/shared/client/proxy-through-host.ts
1524
+ function withRemoteSrc(resolveClientUrl, remoteSrc) {
1525
+ return (url) => resolveClientUrl(remoteSrc, url);
1526
+ }
1527
+
1450
1528
  // src/shared/client/set-attributes-from-props.ts
1451
1529
  var DOMAttributeNames = {
1452
1530
  acceptCharset: "accept-charset",
@@ -1490,7 +1568,81 @@ function setAttributesFromProps(el, props) {
1490
1568
  }
1491
1569
 
1492
1570
  // src/shared/client/static-loader.ts
1493
- async function loadStaticRemoteComponent(scripts, url) {
1571
+ async function importViaCallback(absoluteSrc, resolveClientUrl) {
1572
+ const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
1573
+ const fetchUrl = new URL(resolvedUrl, location.href).href;
1574
+ const response = await fetch(fetchUrl);
1575
+ if (!response.ok)
1576
+ throw new Error(`Proxied fetch failed: ${response.status}`);
1577
+ const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
1578
+ /\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
1579
+ (_, keyword, quote, relativePath) => {
1580
+ const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
1581
+ const resolvedImportUrl = new URL(
1582
+ resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
1583
+ location.href
1584
+ ).href;
1585
+ return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
1586
+ }
1587
+ );
1588
+ const moduleBlobUrl = URL.createObjectURL(
1589
+ new Blob([content], { type: "text/javascript" })
1590
+ );
1591
+ const wrapperContent = [
1592
+ `import*as m from${JSON.stringify(moduleBlobUrl)};`,
1593
+ `globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
1594
+ `globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
1595
+ ].join("");
1596
+ const wrapperBlobUrl = URL.createObjectURL(
1597
+ new Blob([wrapperContent], { type: "text/javascript" })
1598
+ );
1599
+ const scriptEl = document.createElement("script");
1600
+ scriptEl.type = "module";
1601
+ scriptEl.src = wrapperBlobUrl;
1602
+ try {
1603
+ await new Promise((resolve, reject) => {
1604
+ scriptEl.onload = () => resolve();
1605
+ scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
1606
+ document.head.appendChild(scriptEl);
1607
+ });
1608
+ } finally {
1609
+ scriptEl.remove();
1610
+ URL.revokeObjectURL(moduleBlobUrl);
1611
+ URL.revokeObjectURL(wrapperBlobUrl);
1612
+ }
1613
+ const registry = globalThis.__rc_module_registry__;
1614
+ const mod = registry?.[absoluteSrc] ?? {};
1615
+ if (registry)
1616
+ delete registry[absoluteSrc];
1617
+ return mod;
1618
+ }
1619
+ async function importDirectly(absoluteSrc) {
1620
+ try {
1621
+ return await import(
1622
+ /* @vite-ignore */
1623
+ /* webpackIgnore: true */
1624
+ absoluteSrc
1625
+ );
1626
+ } catch (importError) {
1627
+ if (!absoluteSrc.startsWith("blob:")) {
1628
+ warnCrossOriginFetchError("StaticLoader", absoluteSrc);
1629
+ }
1630
+ throw importError;
1631
+ }
1632
+ }
1633
+ function resolveScriptSrc(script, url) {
1634
+ const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
1635
+ if (!rawSrc && script.textContent) {
1636
+ return URL.createObjectURL(
1637
+ new Blob(
1638
+ [script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
1639
+ { type: "text/javascript" }
1640
+ )
1641
+ );
1642
+ }
1643
+ return rawSrc;
1644
+ }
1645
+ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
1494
1646
  const self = globalThis;
1495
1647
  if (self.__remote_script_entrypoint_mount__?.[url.href]) {
1496
1648
  self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
@@ -1501,26 +1653,9 @@ async function loadStaticRemoteComponent(scripts, url) {
1501
1653
  const mountUnmountSets = await Promise.all(
1502
1654
  scripts.map(async (script) => {
1503
1655
  try {
1504
- let src = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
1505
- if (!src && script.textContent) {
1506
- const blob = new Blob(
1507
- [
1508
- script.textContent.replace(
1509
- /import\.meta\.url/g,
1510
- JSON.stringify(url)
1511
- )
1512
- ],
1513
- {
1514
- type: "text/javascript"
1515
- }
1516
- );
1517
- src = URL.createObjectURL(blob);
1518
- }
1519
- const mod = await import(
1520
- /* @vite-ignore */
1521
- /* webpackIgnore: true */
1522
- new URL(src, url).href
1523
- );
1656
+ const src = resolveScriptSrc(script, url);
1657
+ const absoluteSrc = new URL(src, url).href;
1658
+ const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
1524
1659
  if (src.startsWith("blob:")) {
1525
1660
  URL.revokeObjectURL(src);
1526
1661
  }
@@ -1618,7 +1753,12 @@ async function fetchWithHooks(url, additionalInit, options = {}) {
1618
1753
  };
1619
1754
  let res = await onRequest?.(url, init, hookOptions);
1620
1755
  if (!res) {
1621
- res = await fetchWithProtectedRcFallback(url, init);
1756
+ try {
1757
+ res = await fetch(url, init);
1758
+ } catch (error) {
1759
+ warnCrossOriginFetchError("FetchRemoteComponent", url);
1760
+ throw error;
1761
+ }
1622
1762
  }
1623
1763
  const transformedRes = await onResponse?.(url, res, hookOptions);
1624
1764
  if (transformedRes) {
@@ -1636,6 +1776,25 @@ function getClientOrServerUrl(src, serverFallback) {
1636
1776
  return typeof src === "string" ? new URL(src, fallback) : src;
1637
1777
  }
1638
1778
 
1779
+ // src/react/hooks/use-resolve-client-url.ts
1780
+ import { useMemo } from "react";
1781
+ import { useRemoteComponentsContext } from "#internal/react/context";
1782
+
1783
+ // src/shared/client/default-resolve-client-url.ts
1784
+ function bindResolveClientUrl(prop, remoteSrc) {
1785
+ return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
1786
+ }
1787
+
1788
+ // src/react/hooks/use-resolve-client-url.ts
1789
+ function useResolveClientUrl(prop, urlHref) {
1790
+ const { resolveClientUrl: contextValue } = useRemoteComponentsContext();
1791
+ const resolveClientUrl = prop ?? contextValue;
1792
+ return useMemo(
1793
+ () => bindResolveClientUrl(resolveClientUrl, urlHref),
1794
+ [resolveClientUrl, urlHref]
1795
+ );
1796
+ }
1797
+
1639
1798
  // src/react/hooks/use-shadow-root.ts
1640
1799
  import { useLayoutEffect, useRef, useState } from "react";
1641
1800
  function useShadowRoot({
@@ -1708,6 +1867,7 @@ function getRemoteComponentHtml(html) {
1708
1867
  }
1709
1868
 
1710
1869
  // src/react/index.tsx
1870
+ import { RemoteComponentsProvider } from "#internal/react/context";
1711
1871
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
1712
1872
  import { createElement as createElement2 } from "react";
1713
1873
  function RemoteComponent({
@@ -1724,10 +1884,11 @@ function RemoteComponent({
1724
1884
  onError,
1725
1885
  onChange,
1726
1886
  onRequest,
1727
- onResponse
1887
+ onResponse,
1888
+ resolveClientUrl: _resolveClientUrl
1728
1889
  }) {
1729
1890
  const instanceId = useId();
1730
- const name = useMemo(() => {
1891
+ const name = useMemo2(() => {
1731
1892
  if (typeof src === "string") {
1732
1893
  const url2 = new URL(
1733
1894
  src,
@@ -1742,9 +1903,12 @@ function RemoteComponent({
1742
1903
  return nameProp;
1743
1904
  }, [src, nameProp]);
1744
1905
  const [data, setData] = useState2(null);
1745
- const url = useMemo(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
1906
+ const url = useMemo2(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
1907
+ const resolveClientUrl = useResolveClientUrl(_resolveClientUrl, url.href);
1746
1908
  const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
1747
- const keySuffix = `${escapeString(id)}_${escapeString(data?.name ?? name)}_${escapeString(instanceId)}`;
1909
+ const keySuffix = `${escapeString(id)}_${escapeString(
1910
+ data?.name ?? name
1911
+ )}_${escapeString(instanceId)}`;
1748
1912
  const [remoteComponent, setRemoteComponent] = useState2(null);
1749
1913
  const { shadowRoot, shadowRootContainerRef } = useShadowRoot({
1750
1914
  isolate,
@@ -1819,6 +1983,9 @@ function RemoteComponent({
1819
1983
  const previousSrc = prevSrcRef.current;
1820
1984
  const previousName = prevNameRef.current;
1821
1985
  prevSrcRef.current = src;
1986
+ if (previousSrc !== null) {
1987
+ htmlRef.current = null;
1988
+ }
1822
1989
  onBeforeLoad?.(src);
1823
1990
  startTransition(async () => {
1824
1991
  try {
@@ -1829,41 +1996,18 @@ function RemoteComponent({
1829
1996
  const fetchInit = {
1830
1997
  credentials
1831
1998
  };
1999
+ const resolvedUrl = new URL(
2000
+ resolveClientUrl?.(url.href) ?? url.href,
2001
+ location.href
2002
+ );
1832
2003
  const abortController = new AbortController();
1833
- const res = await fetchWithHooks(url, fetchInit, {
2004
+ const res = await fetchWithHooks(resolvedUrl, fetchInit, {
1834
2005
  onRequest,
1835
2006
  onResponse,
1836
2007
  abortController
1837
2008
  });
1838
2009
  if (!res || !res.ok) {
1839
- let error = failedToFetchRemoteComponentError(
1840
- url.href,
1841
- res ?? new Response(null, { status: 0 })
1842
- );
1843
- try {
1844
- const body = await res.text();
1845
- const parser2 = new DOMParser();
1846
- const doc2 = parser2.parseFromString(body, "text/html");
1847
- const errorTemplate = doc2.querySelector(
1848
- "template[data-next-error-message]"
1849
- );
1850
- const errorMessage = errorTemplate?.getAttribute(
1851
- "data-next-error-message"
1852
- );
1853
- const errorStack = errorTemplate?.getAttribute(
1854
- "data-next-error-stack"
1855
- );
1856
- if (errorMessage) {
1857
- error = new RemoteComponentsError(errorMessage);
1858
- if (errorStack) {
1859
- error.stack = errorStack;
1860
- }
1861
- }
1862
- } catch (parseError) {
1863
- if (isAbortError(parseError))
1864
- throw parseError;
1865
- }
1866
- throw error;
2010
+ throw await errorFromFailedFetch(url.href, resolvedUrl, res);
1867
2011
  }
1868
2012
  const remoteHtml = await res.text();
1869
2013
  htmlRef.current = remoteHtml;
@@ -1924,7 +2068,7 @@ function RemoteComponent({
1924
2068
  prevIsRemoteComponentRef.current = isRemoteComponent;
1925
2069
  prevUrlRef.current = url;
1926
2070
  prevNameRef.current = remoteName;
1927
- applyOriginToNodes(doc, url);
2071
+ applyOriginToNodes(doc, url, resolveClientUrl);
1928
2072
  const links = Array.from(
1929
2073
  doc.querySelectorAll("link[href]")
1930
2074
  ).filter((link) => {
@@ -2044,10 +2188,12 @@ function RemoteComponent({
2044
2188
  shadowRootHtml = `<style data-remote-components-reset="">:host { all: initial; }</style>${shadowRootHtml}`;
2045
2189
  }
2046
2190
  shadowRoot.innerHTML = shadowRootHtml;
2191
+ htmlRef.current = null;
2047
2192
  setRemoteComponent(null);
2048
2193
  const { mount, unmount } = await loadStaticRemoteComponent(
2049
2194
  Array.from(shadowRoot.querySelectorAll("script")),
2050
- url
2195
+ url,
2196
+ resolveClientUrl
2051
2197
  );
2052
2198
  unmountRef.current = unmount;
2053
2199
  await Promise.all(
@@ -2065,9 +2211,11 @@ function RemoteComponent({
2065
2211
  }
2066
2212
  )
2067
2213
  );
2214
+ htmlRef.current = null;
2068
2215
  const { mount, unmount } = await loadStaticRemoteComponent(
2069
2216
  Array.from(component.querySelectorAll("script")),
2070
- url
2217
+ url,
2218
+ resolveClientUrl
2071
2219
  );
2072
2220
  unmountRef.current = unmount;
2073
2221
  await Promise.all(
@@ -2110,7 +2258,8 @@ function RemoteComponent({
2110
2258
  ...userShared
2111
2259
  },
2112
2260
  remoteShared,
2113
- container: shadowRoot
2261
+ container: shadowRoot,
2262
+ resolveClientUrl
2114
2263
  });
2115
2264
  if (rsc) {
2116
2265
  rsc.remove();
@@ -2156,7 +2305,8 @@ function RemoteComponent({
2156
2305
  onError,
2157
2306
  onChange,
2158
2307
  onRequest,
2159
- onResponse
2308
+ onResponse,
2309
+ resolveClientUrl
2160
2310
  ]);
2161
2311
  if (remoteComponent instanceof Error) {
2162
2312
  throw remoteComponent;
@@ -2187,7 +2337,8 @@ function RemoteComponent({
2187
2337
  if (prevIsRemoteComponentRef.current) {
2188
2338
  loadStaticRemoteComponent(
2189
2339
  Array.from(shadowRoot.querySelectorAll("script")),
2190
- url
2340
+ url,
2341
+ resolveClientUrl
2191
2342
  ).then(({ mount }) => {
2192
2343
  return Promise.all(
2193
2344
  Array.from(mount).map((mountFn) => mountFn(shadowRoot))
@@ -2270,6 +2421,9 @@ function RemoteComponent({
2270
2421
  ] });
2271
2422
  }
2272
2423
 
2424
+ // src/next/host/client/index.tsx
2425
+ import { RemoteComponentsProvider as RemoteComponentsProvider2 } from "#internal/react/context";
2426
+
2273
2427
  // src/next/host/app-router-compat.tsx
2274
2428
  import { usePathname, useSearchParams } from "next/navigation";
2275
2429
  import { jsx as jsx3 } from "react/jsx-runtime";
@@ -2379,6 +2533,7 @@ function RemoteComponent2(props) {
2379
2533
  return /* @__PURE__ */ jsx4(RemoteComponent, { ...props, shared: sharedModules(props.shared) });
2380
2534
  }
2381
2535
  export {
2382
- RemoteComponent2 as RemoteComponent
2536
+ RemoteComponent2 as RemoteComponent,
2537
+ RemoteComponentsProvider2 as RemoteComponentsProvider
2383
2538
  };
2384
2539
  //# sourceMappingURL=index.js.map