remote-components 0.3.4 → 0.3.6

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 (153) hide show
  1. package/dist/app-63L5THIQ.js +12 -0
  2. package/dist/app-63L5THIQ.js.map +1 -0
  3. package/dist/app-A5QE7XRH.cjs +12 -0
  4. package/dist/app-A5QE7XRH.cjs.map +1 -0
  5. package/dist/chunk-2VQGCACH.js +190 -0
  6. package/dist/chunk-2VQGCACH.js.map +1 -0
  7. package/dist/chunk-42N2ZLE2.js +703 -0
  8. package/dist/chunk-42N2ZLE2.js.map +1 -0
  9. package/dist/chunk-6IUP26UK.cjs +57 -0
  10. package/dist/chunk-6IUP26UK.cjs.map +1 -0
  11. package/dist/chunk-7MVFHOIP.cjs +60 -0
  12. package/dist/chunk-7MVFHOIP.cjs.map +1 -0
  13. package/dist/chunk-CREXMFMF.cjs +155 -0
  14. package/dist/chunk-CREXMFMF.cjs.map +1 -0
  15. package/dist/chunk-CTUJSWCM.js +215 -0
  16. package/dist/chunk-CTUJSWCM.js.map +1 -0
  17. package/dist/chunk-ENYGL5CO.js +11 -0
  18. package/dist/chunk-ENYGL5CO.js.map +1 -0
  19. package/dist/chunk-ER73O65F.cjs +703 -0
  20. package/dist/chunk-ER73O65F.cjs.map +1 -0
  21. package/dist/chunk-F44NODUS.cjs +709 -0
  22. package/dist/chunk-F44NODUS.cjs.map +1 -0
  23. package/dist/chunk-GAXJTFBV.js +20 -0
  24. package/dist/chunk-GAXJTFBV.js.map +1 -0
  25. package/dist/chunk-HNZVEIKN.js +358 -0
  26. package/dist/chunk-HNZVEIKN.js.map +1 -0
  27. package/dist/chunk-KE7QPAQ4.cjs +21 -0
  28. package/dist/chunk-KE7QPAQ4.cjs.map +1 -0
  29. package/dist/chunk-KEPHL25S.js +60 -0
  30. package/dist/chunk-KEPHL25S.js.map +1 -0
  31. package/dist/chunk-KKBEMQU7.cjs +670 -0
  32. package/dist/chunk-KKBEMQU7.cjs.map +1 -0
  33. package/dist/chunk-KYJWRZ2B.js +709 -0
  34. package/dist/chunk-KYJWRZ2B.js.map +1 -0
  35. package/dist/chunk-N5VQR2PW.cjs +215 -0
  36. package/dist/chunk-N5VQR2PW.cjs.map +1 -0
  37. package/dist/chunk-OO4AMJWO.js +155 -0
  38. package/dist/chunk-OO4AMJWO.js.map +1 -0
  39. package/dist/chunk-R4QFK5TN.cjs +358 -0
  40. package/dist/chunk-R4QFK5TN.cjs.map +1 -0
  41. package/dist/chunk-RUWR74XQ.cjs +152 -0
  42. package/dist/chunk-RUWR74XQ.cjs.map +1 -0
  43. package/dist/chunk-S2A4TFLS.js +152 -0
  44. package/dist/chunk-S2A4TFLS.js.map +1 -0
  45. package/dist/chunk-SHFJ5OQA.cjs +11 -0
  46. package/dist/chunk-SHFJ5OQA.cjs.map +1 -0
  47. package/dist/chunk-TCFLEBQM.cjs +20 -0
  48. package/dist/chunk-TCFLEBQM.cjs.map +1 -0
  49. package/dist/chunk-W5ESPGHH.js +670 -0
  50. package/dist/chunk-W5ESPGHH.js.map +1 -0
  51. package/dist/chunk-X6YKUJKH.js +21 -0
  52. package/dist/chunk-X6YKUJKH.js.map +1 -0
  53. package/dist/chunk-XCFYWSLD.cjs +190 -0
  54. package/dist/chunk-XCFYWSLD.cjs.map +1 -0
  55. package/dist/chunk-ZPMTZ3KJ.js +57 -0
  56. package/dist/chunk-ZPMTZ3KJ.js.map +1 -0
  57. package/dist/config/nextjs.cjs +76 -351
  58. package/dist/config/nextjs.cjs.map +1 -1
  59. package/dist/config/nextjs.js +26 -266
  60. package/dist/config/nextjs.js.map +1 -1
  61. package/dist/config/webpack.cjs +12 -240
  62. package/dist/config/webpack.cjs.map +1 -1
  63. package/dist/config/webpack.js +6 -207
  64. package/dist/config/webpack.js.map +1 -1
  65. package/dist/host/html.cjs +139 -2447
  66. package/dist/host/html.cjs.map +1 -1
  67. package/dist/host/html.js +66 -2345
  68. package/dist/host/html.js.map +1 -1
  69. package/dist/host/nextjs/app/client-only.cjs +53 -2825
  70. package/dist/host/nextjs/app/client-only.cjs.map +1 -1
  71. package/dist/host/nextjs/app/client-only.js +31 -2780
  72. package/dist/host/nextjs/app/client-only.js.map +1 -1
  73. package/dist/host/nextjs/app.cjs +34 -2
  74. package/dist/host/nextjs/app.cjs.map +1 -1
  75. package/dist/host/nextjs/app.js +35 -3
  76. package/dist/host/nextjs/app.js.map +1 -1
  77. package/dist/host/proxy/client.cjs +8 -38
  78. package/dist/host/proxy/client.cjs.map +1 -1
  79. package/dist/host/proxy/client.js +4 -7
  80. package/dist/host/proxy/client.js.map +1 -1
  81. package/dist/host/proxy.cjs +19 -56
  82. package/dist/host/proxy.cjs.map +1 -1
  83. package/dist/host/proxy.js +8 -20
  84. package/dist/host/proxy.js.map +1 -1
  85. package/dist/host/react.cjs +17 -2756
  86. package/dist/host/react.cjs.map +1 -1
  87. package/dist/host/react.js +13 -2723
  88. package/dist/host/react.js.map +1 -1
  89. package/dist/internal/host/nextjs/app-client.cjs +38 -24
  90. package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
  91. package/dist/internal/host/nextjs/app-client.js +38 -24
  92. package/dist/internal/host/nextjs/app-client.js.map +1 -1
  93. package/dist/internal/host/nextjs/remote-component-links.cjs +24 -13
  94. package/dist/internal/host/nextjs/remote-component-links.cjs.map +1 -1
  95. package/dist/internal/host/nextjs/remote-component-links.d.ts +3 -0
  96. package/dist/internal/host/nextjs/remote-component-links.js +24 -13
  97. package/dist/internal/host/nextjs/remote-component-links.js.map +1 -1
  98. package/dist/internal/host/server/fetch-remote-component.cjs +1 -18
  99. package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
  100. package/dist/internal/host/server/fetch-remote-component.js +1 -18
  101. package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
  102. package/dist/internal/host/shared/lifecycle.cjs +69 -0
  103. package/dist/internal/host/shared/lifecycle.cjs.map +1 -0
  104. package/dist/internal/host/shared/lifecycle.d.ts +34 -0
  105. package/dist/internal/host/shared/lifecycle.js +44 -0
  106. package/dist/internal/host/shared/lifecycle.js.map +1 -0
  107. package/dist/internal/host/shared/pipeline.cjs +222 -0
  108. package/dist/internal/host/shared/pipeline.cjs.map +1 -0
  109. package/dist/internal/host/shared/pipeline.d.ts +153 -0
  110. package/dist/internal/host/shared/pipeline.js +200 -0
  111. package/dist/internal/host/shared/pipeline.js.map +1 -0
  112. package/dist/internal/runtime/loaders/component-loader.cjs +5 -2
  113. package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
  114. package/dist/internal/runtime/loaders/component-loader.js +5 -2
  115. package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
  116. package/dist/internal/runtime/turbopack/patterns.cjs +1 -1
  117. package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -1
  118. package/dist/internal/runtime/turbopack/patterns.js +1 -1
  119. package/dist/internal/runtime/turbopack/patterns.js.map +1 -1
  120. package/dist/internal/runtime/turbopack/remote-scope-setup.cjs.map +1 -1
  121. package/dist/internal/runtime/turbopack/remote-scope-setup.js.map +1 -1
  122. package/dist/internal/runtime/turbopack/remote-scope.cjs +1 -5
  123. package/dist/internal/runtime/turbopack/remote-scope.cjs.map +1 -1
  124. package/dist/internal/runtime/turbopack/remote-scope.js +1 -5
  125. package/dist/internal/runtime/turbopack/remote-scope.js.map +1 -1
  126. package/dist/internal/utils.cjs +1 -1
  127. package/dist/internal/utils.cjs.map +1 -1
  128. package/dist/internal/utils.d.ts +5 -5
  129. package/dist/internal/utils.js +1 -1
  130. package/dist/internal/utils.js.map +1 -1
  131. package/dist/remote/html.cjs +15 -314
  132. package/dist/remote/html.cjs.map +1 -1
  133. package/dist/remote/html.js +7 -305
  134. package/dist/remote/html.js.map +1 -1
  135. package/dist/remote/middleware.cjs +16 -41
  136. package/dist/remote/middleware.cjs.map +1 -1
  137. package/dist/script-6W5JRBZK.cjs +26 -0
  138. package/dist/script-6W5JRBZK.cjs.map +1 -0
  139. package/dist/script-IFEBOLIA.js +26 -0
  140. package/dist/script-IFEBOLIA.js.map +1 -0
  141. package/dist/static-loader-X4TSF5KW.js +11 -0
  142. package/dist/static-loader-X4TSF5KW.js.map +1 -0
  143. package/dist/static-loader-ZYD5BO4D.cjs +11 -0
  144. package/dist/static-loader-ZYD5BO4D.cjs.map +1 -0
  145. package/dist/turbopack-NPGO3MWS.js +55 -0
  146. package/dist/turbopack-NPGO3MWS.js.map +1 -0
  147. package/dist/turbopack-WRMKPNN4.cjs +55 -0
  148. package/dist/turbopack-WRMKPNN4.cjs.map +1 -0
  149. package/dist/webpack-DUBHPYD6.js +92 -0
  150. package/dist/webpack-DUBHPYD6.js.map +1 -0
  151. package/dist/webpack-KSCMCL7M.cjs +92 -0
  152. package/dist/webpack-KSCMCL7M.cjs.map +1 -0
  153. package/package.json +10 -3
@@ -1,308 +1,10 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __esm = (fn, res) => function __init() {
4
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
5
- };
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
-
11
- // src/utils/constants.ts
12
- var CORS_DOCS_URL;
13
- var init_constants = __esm({
14
- "src/utils/constants.ts"() {
15
- "use strict";
16
- CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
17
- }
18
- });
19
-
20
- // src/runtime/url/protected-rc-fallback.ts
21
- var init_protected_rc_fallback = __esm({
22
- "src/runtime/url/protected-rc-fallback.ts"() {
23
- "use strict";
24
- init_constants();
25
- }
26
- });
27
-
28
- // src/utils/abort.ts
29
- var init_abort = __esm({
30
- "src/utils/abort.ts"() {
31
- "use strict";
32
- }
33
- });
34
-
35
- // src/utils/error.ts
36
- var RemoteComponentsError;
37
- var init_error = __esm({
38
- "src/utils/error.ts"() {
39
- "use strict";
40
- init_protected_rc_fallback();
41
- init_abort();
42
- init_constants();
43
- RemoteComponentsError = class extends Error {
44
- code = "REMOTE_COMPONENTS_ERROR";
45
- constructor(message, options) {
46
- super(message, options);
47
- this.name = "RemoteComponentsError";
48
- }
49
- };
50
- }
51
- });
52
-
53
- // src/utils/logger.ts
54
- function logWarn(location2, message) {
55
- console.warn(`[${PREFIX}:${location2}]: ${message}`);
56
- }
57
- function logError(location2, message, cause) {
58
- console.error(
59
- new RemoteComponentsError(`[${PREFIX}:${location2}]: ${message}`, {
60
- cause
61
- })
62
- );
63
- }
64
- function warnCrossOriginFetchError(logLocation, url) {
65
- try {
66
- const parsed = typeof url === "string" ? new URL(url) : url;
67
- if (typeof location === "undefined" || parsed.origin === location.origin) {
68
- return;
69
- }
70
- logWarn(
71
- logLocation,
72
- `Failed to fetch cross-origin resource "${parsed.href}". To load assets from a protected deployment, two steps are required: (1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. See: ${CORS_DOCS_URL}`
73
- );
74
- } catch {
75
- }
76
- }
77
- var PREFIX, DEBUG;
78
- var init_logger = __esm({
79
- "src/utils/logger.ts"() {
80
- "use strict";
81
- init_constants();
82
- init_error();
83
- PREFIX = "remote-components";
84
- DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true" || typeof process !== "undefined" && process.env.RC_DEBUG === "true";
85
- }
86
- });
87
-
88
- // src/runtime/namespace.ts
89
- function getNamespace() {
90
- const g = globalThis;
91
- const existing = g.__remote_components__;
92
- if (existing) {
93
- return existing;
94
- }
95
- const ns = {
96
- scopes: /* @__PURE__ */ new Map(),
97
- chunkCache: {},
98
- mountFns: {},
99
- unmountFns: {},
100
- bundleUrls: {},
101
- moduleRegistry: {},
102
- dispatcherRuntime: void 0,
103
- hostSharedModules: {},
104
- cssCache: {},
105
- shadowRoots: {}
106
- };
107
- const nsRecord = ns;
108
- for (const { global, prop } of LEGACY_ALIASES) {
109
- const legacyValue = g[global];
110
- if (legacyValue != null) {
111
- nsRecord[prop] = legacyValue;
112
- }
113
- g[global] = ns[prop];
114
- }
115
- const gRecord = g;
116
- for (const key of Object.keys(gRecord)) {
117
- if (key.startsWith(SHADOW_ROOT_PREFIX)) {
118
- const suffix = key.slice(SHADOW_ROOT_PREFIX.length);
119
- ns.shadowRoots[suffix] = gRecord[key];
120
- delete gRecord[key];
121
- }
122
- }
123
- g.__remote_components__ = ns;
124
- return ns;
125
- }
126
- var SHADOW_ROOT_PREFIX, LEGACY_ALIASES;
127
- var init_namespace = __esm({
128
- "src/runtime/namespace.ts"() {
129
- "use strict";
130
- SHADOW_ROOT_PREFIX = "__remote_components_shadowroot_";
131
- LEGACY_ALIASES = [
132
- { global: "__remote_component_scopes__", prop: "scopes" },
133
- {
134
- global: "__remote_components_turbopack_chunk_loader_promise__",
135
- prop: "chunkCache"
136
- },
137
- { global: "__remote_script_entrypoint_mount__", prop: "mountFns" },
138
- { global: "__remote_script_entrypoint_unmount__", prop: "unmountFns" },
139
- { global: "__remote_bundle_url__", prop: "bundleUrls" },
140
- { global: "__rc_module_registry__", prop: "moduleRegistry" },
141
- {
142
- global: "__remote_component_host_shared_modules__",
143
- prop: "hostSharedModules"
144
- },
145
- { global: "__remote_next_css__", prop: "cssCache" }
146
- ];
147
- }
148
- });
149
-
150
- // src/runtime/loaders/static-loader.ts
151
- var static_loader_exports = {};
152
- __export(static_loader_exports, {
153
- loadStaticRemoteComponent: () => loadStaticRemoteComponent
154
- });
155
- async function importViaCallback(absoluteSrc, resolveClientUrl) {
156
- const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
157
- const fetchUrl = new URL(resolvedUrl, location.href).href;
158
- const response = await fetch(fetchUrl);
159
- if (!response.ok)
160
- throw new Error(`Proxied fetch failed: ${response.status}`);
161
- const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
162
- /\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
163
- (_, keyword, quote, relativePath) => {
164
- const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
165
- const resolvedImportUrl = new URL(
166
- resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
167
- location.href
168
- ).href;
169
- return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
170
- }
171
- );
172
- const moduleBlobUrl = URL.createObjectURL(
173
- new Blob([content], { type: "text/javascript" })
174
- );
175
- const wrapperContent = [
176
- `import*as m from${JSON.stringify(moduleBlobUrl)};`,
177
- `globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
178
- `globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
179
- ].join("");
180
- const wrapperBlobUrl = URL.createObjectURL(
181
- new Blob([wrapperContent], { type: "text/javascript" })
182
- );
183
- const scriptEl = document.createElement("script");
184
- scriptEl.type = "module";
185
- scriptEl.src = wrapperBlobUrl;
186
- try {
187
- await new Promise((resolve, reject) => {
188
- scriptEl.onload = () => resolve();
189
- scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
190
- document.head.appendChild(scriptEl);
191
- });
192
- } finally {
193
- scriptEl.remove();
194
- URL.revokeObjectURL(moduleBlobUrl);
195
- URL.revokeObjectURL(wrapperBlobUrl);
196
- }
197
- const registry = getNamespace().moduleRegistry;
198
- const mod = registry[absoluteSrc] ?? {};
199
- delete registry[absoluteSrc];
200
- return mod;
201
- }
202
- async function importDirectly(absoluteSrc) {
203
- try {
204
- return await import(
205
- /* @vite-ignore */
206
- /* webpackIgnore: true */
207
- absoluteSrc
208
- );
209
- } catch (importError) {
210
- if (!absoluteSrc.startsWith("blob:")) {
211
- warnCrossOriginFetchError("StaticLoader", absoluteSrc);
212
- }
213
- throw importError;
214
- }
215
- }
216
- function resolveScriptSrc(script, url) {
217
- const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
218
- if (!rawSrc && script.textContent) {
219
- return URL.createObjectURL(
220
- new Blob(
221
- [script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
222
- { type: "text/javascript" }
223
- )
224
- );
225
- }
226
- return rawSrc;
227
- }
228
- async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
229
- const ns = getNamespace();
230
- if (ns.mountFns[url.href]) {
231
- ns.mountFns[url.href] = /* @__PURE__ */ new Set();
232
- }
233
- if (ns.unmountFns[url.href]) {
234
- ns.unmountFns[url.href] = /* @__PURE__ */ new Set();
235
- }
236
- const mountUnmountSets = await Promise.all(
237
- scripts.map(async (script) => {
238
- try {
239
- const src = resolveScriptSrc(script, url);
240
- const absoluteSrc = new URL(src, url).href;
241
- const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
242
- if (src.startsWith("blob:")) {
243
- URL.revokeObjectURL(src);
244
- }
245
- if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
246
- if (!ns.mountFns[url.href]) {
247
- ns.mountFns[url.href] = /* @__PURE__ */ new Set();
248
- }
249
- ns.mountFns[url.href]?.add(
250
- mod.mount || mod.default?.mount || (() => {
251
- })
252
- );
253
- }
254
- if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
255
- if (!ns.unmountFns[url.href]) {
256
- ns.unmountFns[url.href] = /* @__PURE__ */ new Set();
257
- }
258
- ns.unmountFns[url.href]?.add(
259
- mod.unmount || mod.default?.unmount || (() => {
260
- })
261
- );
262
- }
263
- return {
264
- mount: mod.mount || mod.default?.mount,
265
- unmount: mod.unmount || mod.default?.unmount
266
- };
267
- } catch (e) {
268
- logError(
269
- "StaticLoader",
270
- `Error loading remote component script from "${script.src || url.href}".`,
271
- e
272
- );
273
- return {
274
- mount: void 0,
275
- unmount: void 0
276
- };
277
- }
278
- })
279
- );
280
- return mountUnmountSets.reduce(
281
- (acc, { mount, unmount }) => {
282
- if (typeof mount === "function") {
283
- acc.mount.add(mount);
284
- }
285
- if (typeof unmount === "function") {
286
- acc.unmount.add(unmount);
287
- }
288
- return acc;
289
- },
290
- {
291
- mount: /* @__PURE__ */ new Set(),
292
- unmount: /* @__PURE__ */ new Set()
293
- }
294
- );
295
- }
296
- var init_static_loader = __esm({
297
- "src/runtime/loaders/static-loader.ts"() {
298
- "use strict";
299
- init_namespace();
300
- init_logger();
301
- }
302
- });
1
+ import {
2
+ logError
3
+ } from "../chunk-S2A4TFLS.js";
4
+ import "../chunk-X6YKUJKH.js";
5
+ import "../chunk-ENYGL5CO.js";
303
6
 
304
7
  // src/remote/html/index.tsx
305
- init_logger();
306
8
  if (typeof HTMLElement !== "undefined") {
307
9
  class RemoteComponent extends HTMLElement {
308
10
  name;
@@ -317,8 +19,8 @@ if (typeof HTMLElement !== "undefined") {
317
19
  this.root.innerHTML = html;
318
20
  this.replaceChildren();
319
21
  (async () => {
320
- const { loadStaticRemoteComponent: loadStaticRemoteComponent2 } = await Promise.resolve().then(() => (init_static_loader(), static_loader_exports));
321
- loadStaticRemoteComponent2(
22
+ const { loadStaticRemoteComponent } = await import("../static-loader-X4TSF5KW.js");
23
+ loadStaticRemoteComponent(
322
24
  Array.from(this.root?.querySelectorAll("script") ?? []),
323
25
  new URL(location.href)
324
26
  ).then(({ mount, unmount }) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/constants.ts","../../src/runtime/url/protected-rc-fallback.ts","../../src/utils/abort.ts","../../src/utils/error.ts","../../src/utils/logger.ts","../../src/runtime/namespace.ts","../../src/runtime/loaders/static-loader.ts","../../src/remote/html/index.tsx"],"sourcesContent":["export const RC_PROTECTED_REMOTE_FETCH_PATHNAME = '/rc-fetch-protected-remote';\n\nexport const MISSING_SHARED_MODULES_MESSAGE =\n 'Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponentsConfig` on both host and remote?';\n\nexport const CORS_DOCS_URL =\n 'https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components';\n","import { RC_PROTECTED_REMOTE_FETCH_PATHNAME } from '#internal/utils/constants';\n\n/**\n * Generates a fallback URL that proxies the request through the host's protected remote fetch endpoint\n */\nexport function generateProtectedRcFallbackSrc(url: string): string {\n return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;\n}\n\nexport function isProxiedUrl(url: string): boolean {\n try {\n return (\n new URL(url, location.href).pathname ===\n RC_PROTECTED_REMOTE_FETCH_PATHNAME\n );\n } catch {\n return false;\n }\n}\n","/**\n * Type guard to check if an error is an AbortError.\n * Handles cross-environment differences (Node.js, browsers, JSDOM).\n */\nexport function isAbortError(error: unknown): error is DOMException {\n if (error instanceof DOMException && error.name === 'AbortError') {\n return true;\n }\n\n // Handle Node.js native AbortError which may not be instanceof global DOMException\n if (\n error !== null &&\n typeof error === 'object' &&\n 'name' in error &&\n error.name === 'AbortError' &&\n 'message' in error &&\n typeof (error as { message: unknown }).message === 'string'\n ) {\n // Additional check: verify it has DOMException-like structure\n const e = error as { code?: unknown; constructor?: { name?: string } };\n return typeof e.code === 'number' || e.constructor?.name === 'DOMException';\n }\n\n return false;\n}\n","import { isProxiedUrl } from '#internal/runtime/url/protected-rc-fallback';\nimport { isAbortError } from '#internal/utils/abort';\nimport {\n CORS_DOCS_URL,\n RC_PROTECTED_REMOTE_FETCH_PATHNAME,\n} from '#internal/utils/constants';\n\nexport class RemoteComponentsError extends Error {\n code = 'REMOTE_COMPONENTS_ERROR';\n\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'RemoteComponentsError';\n }\n}\n\nexport function multipleRemoteComponentsError(url: string | undefined) {\n return new RemoteComponentsError(\n `Multiple Remote Components found at \"${url}\". When a page exposes multiple Remote Components you must specify the \"name\" prop to select which one to load.`,\n );\n}\n\nexport function failedToFetchRemoteComponentError(\n url: string,\n { status, statusText }: { status: number; statusText: string },\n help: string = 'Is the URL correct and accessible?',\n) {\n return new RemoteComponentsError(\n `Failed to fetch Remote Component from \"${url}\". ${help}`,\n { cause: new Error(`${status} ${statusText}`) },\n );\n}\n\nexport async function errorFromFailedFetch(\n originalUrl: string,\n resolvedUrl: URL,\n res: Response | null | undefined,\n): Promise<RemoteComponentsError> {\n const isProxied = isProxiedUrl(resolvedUrl.href);\n\n if (isProxied && res) {\n const body = await res.text().catch(() => '');\n return failedProxyFetchError(\n originalUrl,\n resolvedUrl.href,\n res.status,\n body,\n );\n }\n\n const fallback = failedToFetchRemoteComponentError(\n originalUrl,\n res ?? { status: 0, statusText: 'No Response' },\n );\n\n if (!res) return fallback;\n\n try {\n const body = await res.text();\n const parser = new DOMParser();\n const doc = parser.parseFromString(body, 'text/html');\n const errorTemplate = doc.querySelector(\n 'template[data-next-error-message]',\n );\n const errorMessage = errorTemplate?.getAttribute('data-next-error-message');\n if (errorMessage) {\n const error = new RemoteComponentsError(errorMessage);\n const errorStack = errorTemplate?.getAttribute('data-next-error-stack');\n if (errorStack) {\n error.stack = errorStack;\n }\n return error;\n }\n } catch (parseError) {\n // Re-throw abort errors, ignore parse errors\n if (isAbortError(parseError)) throw parseError;\n }\n\n return fallback;\n}\n\nexport function failedProxiedAssetError(\n kind: 'chunk' | 'script',\n url: string,\n resolvedUrl: string,\n): RemoteComponentsError {\n return new RemoteComponentsError(\n `Failed to load ${kind} \"${url}\" via proxy \"${resolvedUrl}\". ` +\n `Ensure withRemoteComponentsHostProxy middleware is configured, \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\" is in the matcher, ` +\n `and the remote URL is included in allowedProxyUrls. ` +\n `See: ${CORS_DOCS_URL}`,\n );\n}\n\nexport function failedProxyFetchError(\n originalUrl: string,\n proxyUrl: string,\n status: number,\n responseBody?: string,\n): RemoteComponentsError {\n if (status === 404) {\n return new RemoteComponentsError(\n `Could not proxy the request to \"${originalUrl}\" — the proxy endpoint \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\" returned 404.\\n\\n` +\n `The host server needs middleware or a route that handles \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\".\\n\\n` +\n `Proxying requires two pieces:\\n` +\n ` 1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>\\n` +\n ` 2. Middleware or a route for \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\" on the host server\\n\\n` +\n `Docs: ${CORS_DOCS_URL}`,\n );\n }\n if (status === 403) {\n const detail = responseBody ? ` ${responseBody}` : '';\n return new RemoteComponentsError(\n `Proxied request to \"${proxyUrl}\" was forbidden.${detail} ` +\n `See: ${CORS_DOCS_URL}`,\n );\n }\n return new RemoteComponentsError(\n `Proxied request for \"${originalUrl}\" via \"${proxyUrl}\" failed with status ${status}. ` +\n `See: ${CORS_DOCS_URL}`,\n );\n}\n","import { CORS_DOCS_URL } from '#internal/utils/constants';\nimport { RemoteComponentsError } from '#internal/utils/error';\n\nexport type LogLocation =\n | 'ChunkLoader'\n | 'ChunkDispatcher'\n | 'ComponentLoader'\n | 'ModuleDispatcher'\n | 'RemoteScope'\n | 'SharedModules'\n | 'WebpackRuntime'\n | 'TurbopackModule'\n | 'StaticLoader'\n | 'ScriptLoader'\n | 'Polyfill'\n | 'HtmlRemote'\n | 'HtmlHost'\n | 'Config'\n | 'NextAppRouter'\n | 'NextAppRouterCompat'\n | 'FetchRemoteComponent'\n | 'SharedModuleResolver';\n\nconst PREFIX = 'remote-components';\nconst DEBUG =\n (typeof window !== 'undefined' &&\n localStorage.getItem('RC_DEBUG') === 'true') ||\n (typeof process !== 'undefined' && process.env.RC_DEBUG === 'true');\n\nexport function logDebug(location: LogLocation, message: string) {\n if (DEBUG) {\n // eslint-disable-next-line no-console\n console.debug(`[${PREFIX}:${location}]: ${message}`);\n }\n}\n\nexport function logInfo(location: LogLocation, message: string) {\n // eslint-disable-next-line no-console\n console.info(`[${PREFIX}:${location}]: ${message}`);\n}\n\nexport function logWarn(location: LogLocation, message: string) {\n // eslint-disable-next-line no-console\n console.warn(`[${PREFIX}:${location}]: ${message}`);\n}\n\nexport function logError(\n location: LogLocation,\n message: string,\n cause?: unknown,\n) {\n // eslint-disable-next-line no-console\n console.error(\n new RemoteComponentsError(`[${PREFIX}:${location}]: ${message}`, {\n cause,\n }),\n );\n}\n\n/**\n * Logs a warning when a cross-origin asset request fails, guiding users\n * to configure the proxy middleware and resolveClientUrl on their host.\n */\nexport function warnCrossOriginFetchError(\n logLocation: LogLocation,\n url: string | URL,\n): void {\n try {\n const parsed = typeof url === 'string' ? new URL(url) : url;\n if (typeof location === 'undefined' || parsed.origin === location.origin) {\n return;\n }\n logWarn(\n logLocation,\n `Failed to fetch cross-origin resource \"${parsed.href}\". ` +\n 'To load assets from a protected deployment, two steps are required: ' +\n '(1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, ' +\n 'and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. ' +\n `See: ${CORS_DOCS_URL}`,\n );\n } catch {\n // URL parsing failed — skip the warning\n }\n}\n","import type { RemoteScope } from '#internal/runtime/turbopack/remote-scope';\nimport type {\n GlobalScope,\n MountOrUnmountFunction,\n MountUnmountFunctions,\n} from '#internal/runtime/types';\n\n/**\n * Typed namespace for all remote-components runtime state.\n *\n * Consolidates scattered `globalThis` globals into a single object at\n * `globalThis.__remote_components__`. Each property corresponds to a\n * previously independent global — see inline `@see` tags for the original\n * global name. Code that previously read from those globals still works\n * because each migration writes through to both the namespace and the\n * legacy global (pointing at the same underlying object).\n */\nexport interface RemoteComponentsNamespace {\n /** @see `__remote_component_scopes__` */\n scopes: Map<string, RemoteScope>;\n /** @see `__remote_components_turbopack_chunk_loader_promise__` */\n chunkCache: Record<string, Promise<unknown>>;\n /** @see `__remote_script_entrypoint_mount__` */\n mountFns: Record<string, Set<MountOrUnmountFunction>>;\n /** @see `__remote_script_entrypoint_unmount__` */\n unmountFns: Record<string, Set<MountOrUnmountFunction>>;\n /** @see `__remote_bundle_url__` */\n bundleUrls: Record<string, string | URL>;\n /** @see `__rc_module_registry__` */\n moduleRegistry: Record<string, unknown>;\n /** @see `__webpack_require_type__` */\n dispatcherRuntime: string | undefined;\n /** @see `__remote_component_host_shared_modules__` */\n hostSharedModules: Record<string, () => Promise<unknown>>;\n /** @see `__remote_next_css__` */\n cssCache: Record<string, ChildNode[]>;\n /** @see `__remote_components_shadowroot_*` */\n shadowRoots: Record<string, ShadowRoot | null>;\n}\n\n/** Prefix for legacy per-key shadow root globals (`__remote_components_shadowroot_*`). */\nconst SHADOW_ROOT_PREFIX = '__remote_components_shadowroot_';\n\n/**\n * Backward-compat aliases for globals used in <=0.3.3.\n *\n * Only includes object/Map values that can be aliased by reference.\n * Primitives (`dispatcherRuntime`) must use write-through at their call sites.\n * Dynamic-key shadow root globals are adopted separately in `getNamespace()`.\n */\nconst LEGACY_ALIASES: ReadonlyArray<{\n global: string;\n prop: keyof RemoteComponentsNamespace;\n}> = [\n { global: '__remote_component_scopes__', prop: 'scopes' },\n {\n global: '__remote_components_turbopack_chunk_loader_promise__',\n prop: 'chunkCache',\n },\n { global: '__remote_script_entrypoint_mount__', prop: 'mountFns' },\n { global: '__remote_script_entrypoint_unmount__', prop: 'unmountFns' },\n { global: '__remote_bundle_url__', prop: 'bundleUrls' },\n { global: '__rc_module_registry__', prop: 'moduleRegistry' },\n {\n global: '__remote_component_host_shared_modules__',\n prop: 'hostSharedModules',\n },\n { global: '__remote_next_css__', prop: 'cssCache' },\n];\n\n/**\n * Returns the single shared `RemoteComponentsNamespace` instance, creating\n * it on first access. The namespace lives at `globalThis.__remote_components__`\n * so every module in the page shares the same state regardless of how many\n * copies of the library are loaded.\n *\n * On first initialization this function also handles backward compatibility\n * with legacy globals:\n * 1. **Adopt**: if a legacy global already exists (written by older code before\n * the namespace was created), its value becomes the initial namespace value.\n * 2. **Alias**: legacy globals are assigned to point at the namespace's objects,\n * so older code that reads the legacy global sees the same reference.\n */\nexport function getNamespace(): RemoteComponentsNamespace {\n const g = globalThis as GlobalScope & MountUnmountFunctions;\n const existing = g.__remote_components__;\n if (existing) {\n return existing;\n }\n\n const ns: RemoteComponentsNamespace = {\n scopes: new Map(),\n chunkCache: {},\n mountFns: {},\n unmountFns: {},\n bundleUrls: {},\n moduleRegistry: {},\n dispatcherRuntime: undefined,\n hostSharedModules: {},\n cssCache: {},\n shadowRoots: {},\n };\n\n // Adopt any pre-existing legacy globals, then alias them to the namespace.\n const nsRecord = ns as unknown as Record<string, unknown>;\n for (const { global, prop } of LEGACY_ALIASES) {\n const legacyValue = (g as Record<string, unknown>)[global];\n if (legacyValue != null) {\n nsRecord[prop] = legacyValue;\n }\n (g as Record<string, unknown>)[global] = ns[prop];\n }\n\n // Adopt per-key shadow root globals used in <=0.3.3\n // (e.g. `globalThis.__remote_components_shadowroot_<key> = root`).\n const gRecord = g as Record<string, unknown>;\n for (const key of Object.keys(gRecord)) {\n if (key.startsWith(SHADOW_ROOT_PREFIX)) {\n const suffix = key.slice(SHADOW_ROOT_PREFIX.length);\n ns.shadowRoots[suffix] = gRecord[key] as ShadowRoot | null;\n delete gRecord[key];\n }\n }\n\n g.__remote_components__ = ns;\n return ns;\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport type { MountOrUnmountFunction } from '#internal/runtime/types';\nimport { logError, warnCrossOriginFetchError } from '#internal/utils/logger';\n\ntype ScriptMod = {\n mount?: MountOrUnmountFunction;\n unmount?: MountOrUnmountFunction;\n default?: {\n mount?: MountOrUnmountFunction;\n unmount?: MountOrUnmountFunction;\n };\n};\n\n/**\n * Fetches an ES module via the resolveClientUrl callback, rewrites its\n * relative imports to also go through the callback, then loads it by injecting a\n * wrapper <script type=\"module\"> tag. The module's namespace is captured via\n * a temporary global and returned.\n *\n * This is needed when a direct import() of a cross-origin module fails due to\n * CORS restrictions or Vercel preview-deployment auth. A simple URL rewrite\n * doesn't work for import() because relative imports inside the module would\n * resolve against the rewritten URL instead of the original remote origin.\n */\nasync function importViaCallback<T>(\n absoluteSrc: string,\n resolveClientUrl: InternalResolveClientUrl,\n): Promise<T> {\n const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;\n const fetchUrl = new URL(resolvedUrl, location.href).href;\n const response = await fetch(fetchUrl);\n if (!response.ok) throw new Error(`Proxied fetch failed: ${response.status}`);\n\n // Restore import.meta.url to the original module URL so any code that\n // relies on it (e.g. for asset resolution) gets the right value.\n // Rewrite relative imports to absolute URLs resolved through the callback so\n // that transitive dependencies also bypass CORS/auth.\n const content = (await response.text())\n .replace(/import\\.meta\\.url/g, JSON.stringify(absoluteSrc))\n .replace(\n /\\b(from|import)\\s*([\"'])(\\.\\.?\\/[^\"']+)\\2/g,\n (_, keyword, quote, relativePath) => {\n const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;\n const resolvedImportUrl = new URL(\n resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,\n location.href,\n ).href;\n return `${keyword} ${quote}${resolvedImportUrl}${quote}`;\n },\n );\n const moduleBlobUrl = URL.createObjectURL(\n new Blob([content], { type: 'text/javascript' }),\n );\n const wrapperContent = [\n `import*as m from${JSON.stringify(moduleBlobUrl)};`,\n `globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,\n `globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`,\n ].join('');\n const wrapperBlobUrl = URL.createObjectURL(\n new Blob([wrapperContent], { type: 'text/javascript' }),\n );\n const scriptEl = document.createElement('script');\n scriptEl.type = 'module';\n scriptEl.src = wrapperBlobUrl;\n try {\n await new Promise<void>((resolve, reject) => {\n scriptEl.onload = () => resolve();\n scriptEl.onerror = () =>\n reject(new Error(`Failed to load module for ${absoluteSrc}`));\n document.head.appendChild(scriptEl);\n });\n } finally {\n scriptEl.remove();\n URL.revokeObjectURL(moduleBlobUrl);\n URL.revokeObjectURL(wrapperBlobUrl);\n }\n const registry = getNamespace().moduleRegistry as Record<string, T>;\n const mod = registry[absoluteSrc] ?? ({} as T);\n delete registry[absoluteSrc];\n return mod;\n}\n\nasync function importDirectly<T>(absoluteSrc: string): Promise<T> {\n try {\n return (await import(\n /* @vite-ignore */\n /* webpackIgnore: true */ absoluteSrc\n )) as T;\n } catch (importError) {\n if (!absoluteSrc.startsWith('blob:')) {\n warnCrossOriginFetchError('StaticLoader', absoluteSrc);\n }\n throw importError;\n }\n}\n\nfunction resolveScriptSrc(script: HTMLScriptElement, url: URL): string {\n const rawSrc =\n typeof script.getAttribute === 'function'\n ? (script.getAttribute('src') ?? script.src)\n : script.src;\n if (!rawSrc && script.textContent) {\n return URL.createObjectURL(\n new Blob(\n [script.textContent.replace(/import\\.meta\\.url/g, JSON.stringify(url))],\n { type: 'text/javascript' },\n ),\n );\n }\n return rawSrc;\n}\n\nexport async function loadStaticRemoteComponent(\n scripts: HTMLScriptElement[],\n url: URL,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n const ns = getNamespace();\n\n if (ns.mountFns[url.href]) {\n ns.mountFns[url.href] = new Set();\n }\n if (ns.unmountFns[url.href]) {\n ns.unmountFns[url.href] = new Set();\n }\n const mountUnmountSets = await Promise.all(\n scripts.map(async (script) => {\n try {\n const src = resolveScriptSrc(script, url);\n const absoluteSrc = new URL(src, url).href;\n const mod: ScriptMod = resolveClientUrl\n ? await importViaCallback<ScriptMod>(absoluteSrc, resolveClientUrl)\n : await importDirectly<ScriptMod>(absoluteSrc);\n // revoke the object URL if we created one for inline script content\n if (src.startsWith('blob:')) {\n URL.revokeObjectURL(src);\n }\n if (\n typeof mod.mount === 'function' ||\n typeof mod.default?.mount === 'function'\n ) {\n if (!ns.mountFns[url.href]) {\n ns.mountFns[url.href] = new Set();\n }\n ns.mountFns[url.href]?.add(\n mod.mount ||\n mod.default?.mount ||\n (() => {\n // noop\n }),\n );\n }\n if (\n typeof mod.unmount === 'function' ||\n typeof mod.default?.unmount === 'function'\n ) {\n if (!ns.unmountFns[url.href]) {\n ns.unmountFns[url.href] = new Set();\n }\n ns.unmountFns[url.href]?.add(\n mod.unmount ||\n mod.default?.unmount ||\n (() => {\n // noop\n }),\n );\n }\n return {\n mount: mod.mount || mod.default?.mount,\n unmount: mod.unmount || mod.default?.unmount,\n };\n } catch (e) {\n logError(\n 'StaticLoader',\n `Error loading remote component script from \"${script.src || url.href}\".`,\n e,\n );\n return {\n mount: undefined,\n unmount: undefined,\n };\n }\n }),\n );\n return mountUnmountSets.reduce(\n (acc, { mount, unmount }) => {\n if (typeof mount === 'function') {\n acc.mount.add(mount);\n }\n if (typeof unmount === 'function') {\n acc.unmount.add(unmount);\n }\n return acc;\n },\n {\n mount: new Set<MountOrUnmountFunction>(),\n unmount: new Set<MountOrUnmountFunction>(),\n },\n );\n}\n","import type { MountOrUnmountFunction } from '#internal/runtime/types';\nimport { logError } from '#internal/utils/logger';\n\nif (typeof HTMLElement !== 'undefined') {\n class RemoteComponent extends HTMLElement {\n name?: string;\n root?: ShadowRoot | null = null;\n unmount?: Set<MountOrUnmountFunction> | null = null;\n\n constructor() {\n super();\n\n const html = this.innerHTML;\n this.root = this.attachShadow({\n mode: this.getAttribute('mode') === 'closed' ? 'closed' : 'open',\n });\n this.root.innerHTML = html;\n // Clear light DOM — content was copied into the shadow root above.\n // Without this the original children render twice (once in light DOM,\n // once in shadow DOM).\n this.replaceChildren();\n\n // run the mount functions for any scripts inside the shadow root asynchronously\n (async () => {\n const { loadStaticRemoteComponent } = await import(\n '../../runtime/loaders/static-loader'\n );\n loadStaticRemoteComponent(\n Array.from(this.root?.querySelectorAll('script') ?? []),\n new URL(location.href),\n )\n .then(({ mount, unmount }) => {\n this.unmount = unmount;\n return Promise.all(\n Array.from(mount).map((mountFn) => mountFn(this.root)),\n );\n })\n .catch((e) => {\n logError('HtmlRemote', 'Error mounting remote component.', e);\n });\n })().catch((e) => {\n logError('HtmlRemote', 'Error mounting remote component.', e);\n });\n }\n\n disconnectedCallback() {\n // run the unmount functions for any scripts inside the shadow root asynchronously\n (async () => {\n if (this.unmount) {\n await Promise.all(\n Array.from(this.unmount).map(async (unmount) => {\n try {\n await unmount(this.root);\n } catch (e) {\n logError('HtmlRemote', 'Error unmounting remote component.', e);\n }\n }),\n );\n }\n })().catch((e) => {\n logError('HtmlRemote', 'Error unmounting remote component.', e);\n });\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAKa;AALb;AAAA;AAAA;AAKO,IAAM,gBACX;AAAA;AAAA;;;ACNF;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAOa;AAPb;AAAA;AAAA;AAAA;AACA;AACA;AAKO,IAAM,wBAAN,cAAoC,MAAM;AAAA,MAC/C,OAAO;AAAA,MAEP,YAAY,SAAiB,SAA+B;AAC1D,cAAM,SAAS,OAAO;AACtB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA;AAAA;;;AC2BO,SAAS,QAAQA,WAAuB,SAAiB;AAE9D,UAAQ,KAAK,IAAI,UAAUA,eAAc,SAAS;AACpD;AAEO,SAAS,SACdA,WACA,SACA,OACA;AAEA,UAAQ;AAAA,IACN,IAAI,sBAAsB,IAAI,UAAUA,eAAc,WAAW;AAAA,MAC/D;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAMO,SAAS,0BACd,aACA,KACM;AACN,MAAI;AACF,UAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,IAAI,GAAG,IAAI;AACxD,QAAI,OAAO,aAAa,eAAe,OAAO,WAAW,SAAS,QAAQ;AACxE;AAAA,IACF;AACA;AAAA,MACE;AAAA,MACA,0CAA0C,OAAO,uSAIvC;AAAA,IACZ;AAAA,EACF,QAAE;AAAA,EAEF;AACF;AAnFA,IAuBM,QACA;AAxBN;AAAA;AAAA;AAAA;AACA;AAsBA,IAAM,SAAS;AACf,IAAM,QACH,OAAO,WAAW,eACjB,aAAa,QAAQ,UAAU,MAAM,UACtC,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa;AAAA;AAAA;;;ACwDvD,SAAS,eAA0C;AACxD,QAAM,IAAI;AACV,QAAM,WAAW,EAAE;AACnB,MAAI,UAAU;AACZ,WAAO;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;AAC9C,kBAAI;AACF,sBAAM,QAAQ,KAAK,IAAI;AAAA,cACzB,SAAS,GAAP;AACA,yBAAS,cAAc,sCAAsC,CAAC;AAAA,cAChE;AAAA,YACF,CAAC;AAAA,UACH;AAAA,QACF;AAAA,MACF,GAAG,EAAE,MAAM,CAAC,MAAM;AAChB,iBAAS,cAAc,sCAAsC,CAAC;AAAA,MAChE,CAAC;AAAA,IACH;AAAA,EACF;AAGA,iBAAe,OAAO,oBAAoB,eAAe;AAC3D;","names":["location","loadStaticRemoteComponent"]}
1
+ {"version":3,"sources":["../../src/remote/html/index.tsx"],"sourcesContent":["import type { MountOrUnmountFunction } from '#internal/runtime/types';\nimport { logError } from '#internal/utils/logger';\n\nif (typeof HTMLElement !== 'undefined') {\n class RemoteComponent extends HTMLElement {\n name?: string;\n root?: ShadowRoot | null = null;\n unmount?: Set<MountOrUnmountFunction> | null = null;\n\n constructor() {\n super();\n\n const html = this.innerHTML;\n this.root = this.attachShadow({\n mode: this.getAttribute('mode') === 'closed' ? 'closed' : 'open',\n });\n this.root.innerHTML = html;\n // Clear light DOM — content was copied into the shadow root above.\n // Without this the original children render twice (once in light DOM,\n // once in shadow DOM).\n this.replaceChildren();\n\n // run the mount functions for any scripts inside the shadow root asynchronously\n (async () => {\n const { loadStaticRemoteComponent } = await import(\n '../../runtime/loaders/static-loader'\n );\n loadStaticRemoteComponent(\n Array.from(this.root?.querySelectorAll('script') ?? []),\n new URL(location.href),\n )\n .then(({ mount, unmount }) => {\n this.unmount = unmount;\n return Promise.all(\n Array.from(mount).map((mountFn) => mountFn(this.root)),\n );\n })\n .catch((e) => {\n logError('HtmlRemote', 'Error mounting remote component.', e);\n });\n })().catch((e) => {\n logError('HtmlRemote', 'Error mounting remote component.', e);\n });\n }\n\n disconnectedCallback() {\n // run the unmount functions for any scripts inside the shadow root asynchronously\n (async () => {\n if (this.unmount) {\n await Promise.all(\n Array.from(this.unmount).map(async (unmount) => {\n try {\n await unmount(this.root);\n } catch (e) {\n logError('HtmlRemote', 'Error unmounting remote component.', e);\n }\n }),\n );\n }\n })().catch((e) => {\n logError('HtmlRemote', 'Error unmounting remote component.', e);\n });\n }\n }\n\n // register the custom element\n customElements.define('remote-component', RemoteComponent);\n}\n"],"mappings":";;;;;;;AAGA,IAAI,OAAO,gBAAgB,aAAa;AACtC,QAAM,wBAAwB,YAAY;AAAA,IACxC;AAAA,IACA,OAA2B;AAAA,IAC3B,UAA+C;AAAA,IAE/C,cAAc;AACZ,YAAM;AAEN,YAAM,OAAO,KAAK;AAClB,WAAK,OAAO,KAAK,aAAa;AAAA,QAC5B,MAAM,KAAK,aAAa,MAAM,MAAM,WAAW,WAAW;AAAA,MAC5D,CAAC;AACD,WAAK,KAAK,YAAY;AAItB,WAAK,gBAAgB;AAGrB,OAAC,YAAY;AACX,cAAM,EAAE,0BAA0B,IAAI,MAAM,OAC1C,8BACF;AACA;AAAA,UACE,MAAM,KAAK,KAAK,MAAM,iBAAiB,QAAQ,KAAK,CAAC,CAAC;AAAA,UACtD,IAAI,IAAI,SAAS,IAAI;AAAA,QACvB,EACG,KAAK,CAAC,EAAE,OAAO,QAAQ,MAAM;AAC5B,eAAK,UAAU;AACf,iBAAO,QAAQ;AAAA,YACb,MAAM,KAAK,KAAK,EAAE,IAAI,CAAC,YAAY,QAAQ,KAAK,IAAI,CAAC;AAAA,UACvD;AAAA,QACF,CAAC,EACA,MAAM,CAAC,MAAM;AACZ,mBAAS,cAAc,oCAAoC,CAAC;AAAA,QAC9D,CAAC;AAAA,MACL,GAAG,EAAE,MAAM,CAAC,MAAM;AAChB,iBAAS,cAAc,oCAAoC,CAAC;AAAA,MAC9D,CAAC;AAAA,IACH;AAAA,IAEA,uBAAuB;AAErB,OAAC,YAAY;AACX,YAAI,KAAK,SAAS;AAChB,gBAAM,QAAQ;AAAA,YACZ,MAAM,KAAK,KAAK,OAAO,EAAE,IAAI,OAAO,YAAY;AAC9C,kBAAI;AACF,sBAAM,QAAQ,KAAK,IAAI;AAAA,cACzB,SAAS,GAAP;AACA,yBAAS,cAAc,sCAAsC,CAAC;AAAA,cAChE;AAAA,YACF,CAAC;AAAA,UACH;AAAA,QACF;AAAA,MACF,GAAG,EAAE,MAAM,CAAC,MAAM;AAChB,iBAAS,cAAc,sCAAsC,CAAC;AAAA,MAChE,CAAC;AAAA,IACH;AAAA,EACF;AAGA,iBAAe,OAAO,oBAAoB,eAAe;AAC3D;","names":[]}
@@ -1,34 +1,10 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/remote/middleware/index.ts
21
- var middleware_exports = {};
22
- __export(middleware_exports, {
23
- withExposeRemoteComponents: () => withExposeRemoteComponents
24
- });
25
- module.exports = __toCommonJS(middleware_exports);
26
- var import_server = require("next/server");
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/remote/middleware/index.ts
2
+ var _server = require('next/server');
27
3
 
28
4
  // src/remote/middleware/headers.ts
29
5
  function getHeader(headers, name) {
30
6
  if (headers instanceof Headers) {
31
- return headers.get(name) ?? void 0;
7
+ return _nullishCoalesce(headers.get(name), () => ( void 0));
32
8
  }
33
9
  const value = headers[name];
34
10
  return Array.isArray(value) ? value[0] : value;
@@ -39,18 +15,18 @@ function getCorsHeaders(options, requestHeaders) {
39
15
  }
40
16
  const originHeader = getHeader(requestHeaders, "origin");
41
17
  const refererHeader = getHeader(requestHeaders, "referer");
42
- const origin = originHeader ?? (refererHeader ? new URL(refererHeader).origin : "*");
43
- const ALLOWED_ORIGINS = (process.env.REMOTE_COMPONENTS_ALLOWED_ORIGINS || (Array.isArray(options?.origin) ? options.origin.join(",") : options?.origin) || "*").split(",").map((allowedOrigin) => allowedOrigin.trim());
18
+ const origin = _nullishCoalesce(originHeader, () => ( (refererHeader ? new URL(refererHeader).origin : "*")));
19
+ const ALLOWED_ORIGINS = (process.env.REMOTE_COMPONENTS_ALLOWED_ORIGINS || (Array.isArray(_optionalChain([options, 'optionalAccess', _ => _.origin])) ? options.origin.join(",") : _optionalChain([options, 'optionalAccess', _2 => _2.origin])) || "*").split(",").map((allowedOrigin) => allowedOrigin.trim());
44
20
  const isAllowed = ALLOWED_ORIGINS.includes("*") || ALLOWED_ORIGINS.includes(origin);
45
- const allowedHeaders = process.env.REMOTE_COMPONENTS_ALLOW_HEADERS || (Array.isArray(options?.headers) ? options.headers.map((h) => h.trim()).join(",") : options?.headers) || getHeader(requestHeaders, "access-control-request-headers");
21
+ const allowedHeaders = process.env.REMOTE_COMPONENTS_ALLOW_HEADERS || (Array.isArray(_optionalChain([options, 'optionalAccess', _3 => _3.headers])) ? options.headers.map((h) => h.trim()).join(",") : _optionalChain([options, 'optionalAccess', _4 => _4.headers])) || getHeader(requestHeaders, "access-control-request-headers");
46
22
  const CORS_HEADERS = isAllowed ? {
47
23
  "Access-Control-Allow-Origin": origin,
48
- "Access-Control-Allow-Methods": process.env.REMOTE_COMPONENTS_ALLOW_METHODS || (Array.isArray(options?.method) ? options.method.map((m) => m.trim()).join(",") : options?.method) || "GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS",
24
+ "Access-Control-Allow-Methods": process.env.REMOTE_COMPONENTS_ALLOW_METHODS || (Array.isArray(_optionalChain([options, 'optionalAccess', _5 => _5.method])) ? options.method.map((m) => m.trim()).join(",") : _optionalChain([options, 'optionalAccess', _6 => _6.method])) || "GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS",
49
25
  ...allowedHeaders ? { "Access-Control-Allow-Headers": allowedHeaders } : {},
50
- ...process.env.REMOTE_COMPONENTS_ALLOW_CREDENTIALS || options?.credentials ? {
26
+ ...process.env.REMOTE_COMPONENTS_ALLOW_CREDENTIALS || _optionalChain([options, 'optionalAccess', _7 => _7.credentials]) ? {
51
27
  "Access-Control-Allow-Credentials": process.env.REMOTE_COMPONENTS_ALLOW_CREDENTIALS || "true"
52
28
  } : {},
53
- "Access-Control-Max-Age": options?.maxAge || "600",
29
+ "Access-Control-Max-Age": _optionalChain([options, 'optionalAccess', _8 => _8.maxAge]) || "600",
54
30
  Vary: "Origin"
55
31
  } : {};
56
32
  return CORS_HEADERS;
@@ -78,14 +54,14 @@ function withExposeRemoteComponents(proxy, options) {
78
54
  const preflightResponse = handleCorsPreflightRequest(
79
55
  request.method,
80
56
  request.headers,
81
- options?.cors
57
+ _optionalChain([options, 'optionalAccess', _9 => _9.cors])
82
58
  );
83
59
  if (preflightResponse) {
84
60
  return preflightResponse;
85
61
  }
86
- const response = typeof proxy === "function" ? await proxy(request) : import_server.NextResponse.next();
87
- if (options?.cors !== false) {
88
- const corsHeaders = getCorsHeaders(options?.cors, request.headers);
62
+ const response = typeof proxy === "function" ? await proxy(request) : _server.NextResponse.next();
63
+ if (_optionalChain([options, 'optionalAccess', _10 => _10.cors]) !== false) {
64
+ const corsHeaders = getCorsHeaders(_optionalChain([options, 'optionalAccess', _11 => _11.cors]), request.headers);
89
65
  Object.entries(corsHeaders).forEach(
90
66
  ([k, v]) => response.headers.set(k, v)
91
67
  );
@@ -97,8 +73,7 @@ function withExposeRemoteComponents(proxy, options) {
97
73
  return response;
98
74
  };
99
75
  }
100
- // Annotate the CommonJS export names for ESM import in node:
101
- 0 && (module.exports = {
102
- withExposeRemoteComponents
103
- });
76
+
77
+
78
+ exports.withExposeRemoteComponents = withExposeRemoteComponents;
104
79
  //# sourceMappingURL=middleware.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/remote/middleware/index.ts","../../src/remote/middleware/headers.ts"],"sourcesContent":["import { type NextRequest, NextResponse } from 'next/server';\nimport {\n getCorsHeaders,\n getSecurityHeaders,\n handleCorsPreflightRequest,\n type RemoteComponentProxyOptions,\n} from './headers';\n\n/**\n * This proxy is used to handle CORS and other remote component related tasks.\n * It can be used to wrap a Next.js proxy handler function to add CORS headers and handle preflight requests.\n *\n * @param proxy - The Next.js proxy handler function to wrap.\n * @param options - Optional configuration for handling remote components.\n * @returns A Next.js proxy handler function that handles CORS and preflight requests\n */\nexport function withExposeRemoteComponents(\n proxy?: (request: NextRequest) => NextResponse | Promise<NextResponse>,\n options?: RemoteComponentProxyOptions,\n) {\n return async (request: NextRequest) => {\n // Check if this is a CORS preflight request\n const preflightResponse = handleCorsPreflightRequest(\n request.method,\n request.headers,\n options?.cors,\n );\n\n if (preflightResponse) {\n return preflightResponse;\n }\n\n // For all other requests, continue and attach CORS headers\n const response =\n typeof proxy === 'function' ? await proxy(request) : NextResponse.next();\n\n if (options?.cors !== false) {\n const corsHeaders = getCorsHeaders(options?.cors, request.headers);\n Object.entries(corsHeaders).forEach(([k, v]) =>\n response.headers.set(k, v),\n );\n }\n\n const securityHeaders = getSecurityHeaders();\n Object.entries(securityHeaders).forEach(([k, v]) =>\n response.headers.set(k, v),\n );\n\n return response;\n };\n}\n\nexport type { RemoteComponentProxyOptions } from './headers';\n","/**\n * Proxy utilities for remote applications that expose components to hosts.\n */\n\nimport type { IncomingHttpHeaders } from 'node:http';\n\nexport interface RemoteComponentProxyOptions {\n cors?:\n | {\n origin?: string | string[];\n method?: string | string[];\n headers?: string | string[];\n credentials?: boolean;\n maxAge?: string;\n }\n | false;\n}\n\n/**\n * Gets a header value from either a Headers object or a plain object.\n */\nexport function getHeader(\n headers: Record<string, string> | Headers | IncomingHttpHeaders,\n name: string,\n): string | undefined {\n if (headers instanceof Headers) {\n return headers.get(name) ?? undefined;\n }\n const value = headers[name];\n // IncomingHttpHeaders can have string | string[] | undefined\n return Array.isArray(value) ? value[0] : value;\n}\n\n/**\n * Computes CORS headers based on the provided options and request headers.\n *\n * @param options - CORS configuration options\n * @param requestHeaders - Headers from the incoming request (can be a Headers object or a plain object)\n * @returns Object containing CORS headers to be added to the response\n */\nexport function getCorsHeaders(\n options: RemoteComponentProxyOptions['cors'],\n requestHeaders: Record<string, string> | Headers | IncomingHttpHeaders,\n): Record<string, string> {\n if (options === false) {\n return {};\n }\n\n const originHeader = getHeader(requestHeaders, 'origin');\n const refererHeader = getHeader(requestHeaders, 'referer');\n const origin =\n originHeader ?? (refererHeader ? new URL(refererHeader).origin : '*');\n\n const ALLOWED_ORIGINS = (\n process.env.REMOTE_COMPONENTS_ALLOWED_ORIGINS ||\n (Array.isArray(options?.origin)\n ? options.origin.join(',')\n : options?.origin) ||\n '*'\n )\n .split(',')\n .map((allowedOrigin) => allowedOrigin.trim());\n\n const isAllowed =\n ALLOWED_ORIGINS.includes('*') || ALLOWED_ORIGINS.includes(origin);\n\n const allowedHeaders =\n process.env.REMOTE_COMPONENTS_ALLOW_HEADERS ||\n (Array.isArray(options?.headers)\n ? options.headers.map((h) => h.trim()).join(',')\n : options?.headers) ||\n getHeader(requestHeaders, 'access-control-request-headers');\n\n const CORS_HEADERS = (\n isAllowed\n ? {\n 'Access-Control-Allow-Origin': origin,\n 'Access-Control-Allow-Methods':\n process.env.REMOTE_COMPONENTS_ALLOW_METHODS ||\n (Array.isArray(options?.method)\n ? options.method.map((m) => m.trim()).join(',')\n : options?.method) ||\n 'GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS',\n ...(allowedHeaders\n ? { 'Access-Control-Allow-Headers': allowedHeaders }\n : {}),\n ...(process.env.REMOTE_COMPONENTS_ALLOW_CREDENTIALS ||\n options?.credentials\n ? {\n 'Access-Control-Allow-Credentials':\n process.env.REMOTE_COMPONENTS_ALLOW_CREDENTIALS || 'true',\n }\n : {}),\n 'Access-Control-Max-Age': options?.maxAge || '600',\n Vary: 'Origin',\n }\n : {}\n ) as Record<string, string>;\n\n return CORS_HEADERS;\n}\n\n/**\n * Returns security headers that prevent the remote component pages from being\n * embedded in frames. Remote components are fetched via HTTP and rendered\n * directly into the host's DOM — they should never be loaded in an iframe.\n */\nexport function getSecurityHeaders(): Record<string, string> {\n return {\n 'Content-Security-Policy': \"frame-ancestors 'none'\",\n 'X-Frame-Options': 'DENY',\n };\n}\n\n/**\n * Handles CORS preflight OPTIONS requests.\n *\n * @param method - The HTTP method of the incoming request\n * @param headers - Headers from the incoming request (can be a Headers object or a plain object)\n * @param options - CORS configuration options\n * @returns Response object for the preflight request, or null if not a preflight\n */\nexport function handleCorsPreflightRequest(\n method: string,\n headers: Record<string, string> | Headers | IncomingHttpHeaders,\n options?: RemoteComponentProxyOptions['cors'],\n): Response | null {\n if (method !== 'OPTIONS' || options === false) {\n return null;\n }\n\n const corsHeaders = getCorsHeaders(options, headers);\n\n return new Response(undefined, {\n status: 200,\n headers: { ...corsHeaders, ...getSecurityHeaders() },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;;;ACqBxC,SAAS,UACd,SACA,MACoB;AACpB,MAAI,mBAAmB,SAAS;AAC9B,WAAO,QAAQ,IAAI,IAAI,KAAK;AAAA,EAC9B;AACA,QAAM,QAAQ,QAAQ,IAAI;AAE1B,SAAO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AI,WAAW,aAAa,YAAY,OAAO;AAC7C,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,eAAe,SAAS,OAAO;AAEnD,SAAO,IAAI,SAAS,QAAW;AAAA,IAC7B,QAAQ;AAAA,IACR,SAAS,EAAE,GAAG,aAAa,GAAG,mBAAmB,EAAE;AAAA,EACrD,CAAC;AACH;;;ADzHO,SAAS,2BACd,OACA,SACA;AACA,SAAO,OAAO,YAAyB;AAErC,UAAM,oBAAoB;AAAA,MACxB,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,SAAS;AAAA,IACX;AAEA,QAAI,mBAAmB;AACrB,aAAO;AAAA,IACT;AAGA,UAAM,WACJ,OAAO,UAAU,aAAa,MAAM,MAAM,OAAO,IAAI,aAAa,KAAK;AAEzE,QAAI,SAAS,SAAS,OAAO;AAC3B,YAAM,cAAc,eAAe,SAAS,MAAM,QAAQ,OAAO;AACjE,aAAO,QAAQ,WAAW,EAAE;AAAA,QAAQ,CAAC,CAAC,GAAG,CAAC,MACxC,SAAS,QAAQ,IAAI,GAAG,CAAC;AAAA,MAC3B;AAAA,IACF;AAEA,UAAM,kBAAkB,mBAAmB;AAC3C,WAAO,QAAQ,eAAe,EAAE;AAAA,MAAQ,CAAC,CAAC,GAAG,CAAC,MAC5C,SAAS,QAAQ,IAAI,GAAG,CAAC;AAAA,IAC3B;AAEA,WAAO;AAAA,EACT;AACF","sourcesContent":["import { type NextRequest, NextResponse } from 'next/server';\nimport {\n getCorsHeaders,\n getSecurityHeaders,\n handleCorsPreflightRequest,\n type RemoteComponentProxyOptions,\n} from './headers';\n\n/**\n * This proxy is used to handle CORS and other remote component related tasks.\n * It can be used to wrap a Next.js proxy handler function to add CORS headers and handle preflight requests.\n *\n * @param proxy - The Next.js proxy handler function to wrap.\n * @param options - Optional configuration for handling remote components.\n * @returns A Next.js proxy handler function that handles CORS and preflight requests\n */\nexport function withExposeRemoteComponents(\n proxy?: (request: NextRequest) => NextResponse | Promise<NextResponse>,\n options?: RemoteComponentProxyOptions,\n) {\n return async (request: NextRequest) => {\n // Check if this is a CORS preflight request\n const preflightResponse = handleCorsPreflightRequest(\n request.method,\n request.headers,\n options?.cors,\n );\n\n if (preflightResponse) {\n return preflightResponse;\n }\n\n // For all other requests, continue and attach CORS headers\n const response =\n typeof proxy === 'function' ? await proxy(request) : NextResponse.next();\n\n if (options?.cors !== false) {\n const corsHeaders = getCorsHeaders(options?.cors, request.headers);\n Object.entries(corsHeaders).forEach(([k, v]) =>\n response.headers.set(k, v),\n );\n }\n\n const securityHeaders = getSecurityHeaders();\n Object.entries(securityHeaders).forEach(([k, v]) =>\n response.headers.set(k, v),\n );\n\n return response;\n };\n}\n\nexport type { RemoteComponentProxyOptions } from './headers';\n","/**\n * Proxy utilities for remote applications that expose components to hosts.\n */\n\nimport type { IncomingHttpHeaders } from 'node:http';\n\nexport interface RemoteComponentProxyOptions {\n cors?:\n | {\n origin?: string | string[];\n method?: string | string[];\n headers?: string | string[];\n credentials?: boolean;\n maxAge?: string;\n }\n | false;\n}\n\n/**\n * Gets a header value from either a Headers object or a plain object.\n */\nexport function getHeader(\n headers: Record<string, string> | Headers | IncomingHttpHeaders,\n name: string,\n): string | undefined {\n if (headers instanceof Headers) {\n return headers.get(name) ?? undefined;\n }\n const value = headers[name];\n // IncomingHttpHeaders can have string | string[] | undefined\n return Array.isArray(value) ? value[0] : value;\n}\n\n/**\n * Computes CORS headers based on the provided options and request headers.\n *\n * @param options - CORS configuration options\n * @param requestHeaders - Headers from the incoming request (can be a Headers object or a plain object)\n * @returns Object containing CORS headers to be added to the response\n */\nexport function getCorsHeaders(\n options: RemoteComponentProxyOptions['cors'],\n requestHeaders: Record<string, string> | Headers | IncomingHttpHeaders,\n): Record<string, string> {\n if (options === false) {\n return {};\n }\n\n const originHeader = getHeader(requestHeaders, 'origin');\n const refererHeader = getHeader(requestHeaders, 'referer');\n const origin =\n originHeader ?? (refererHeader ? new URL(refererHeader).origin : '*');\n\n const ALLOWED_ORIGINS = (\n process.env.REMOTE_COMPONENTS_ALLOWED_ORIGINS ||\n (Array.isArray(options?.origin)\n ? options.origin.join(',')\n : options?.origin) ||\n '*'\n )\n .split(',')\n .map((allowedOrigin) => allowedOrigin.trim());\n\n const isAllowed =\n ALLOWED_ORIGINS.includes('*') || ALLOWED_ORIGINS.includes(origin);\n\n const allowedHeaders =\n process.env.REMOTE_COMPONENTS_ALLOW_HEADERS ||\n (Array.isArray(options?.headers)\n ? options.headers.map((h) => h.trim()).join(',')\n : options?.headers) ||\n getHeader(requestHeaders, 'access-control-request-headers');\n\n const CORS_HEADERS = (\n isAllowed\n ? {\n 'Access-Control-Allow-Origin': origin,\n 'Access-Control-Allow-Methods':\n process.env.REMOTE_COMPONENTS_ALLOW_METHODS ||\n (Array.isArray(options?.method)\n ? options.method.map((m) => m.trim()).join(',')\n : options?.method) ||\n 'GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS',\n ...(allowedHeaders\n ? { 'Access-Control-Allow-Headers': allowedHeaders }\n : {}),\n ...(process.env.REMOTE_COMPONENTS_ALLOW_CREDENTIALS ||\n options?.credentials\n ? {\n 'Access-Control-Allow-Credentials':\n process.env.REMOTE_COMPONENTS_ALLOW_CREDENTIALS || 'true',\n }\n : {}),\n 'Access-Control-Max-Age': options?.maxAge || '600',\n Vary: 'Origin',\n }\n : {}\n ) as Record<string, string>;\n\n return CORS_HEADERS;\n}\n\n/**\n * Returns security headers that prevent the remote component pages from being\n * embedded in frames. Remote components are fetched via HTTP and rendered\n * directly into the host's DOM — they should never be loaded in an iframe.\n */\nexport function getSecurityHeaders(): Record<string, string> {\n return {\n 'Content-Security-Policy': \"frame-ancestors 'none'\",\n 'X-Frame-Options': 'DENY',\n };\n}\n\n/**\n * Handles CORS preflight OPTIONS requests.\n *\n * @param method - The HTTP method of the incoming request\n * @param headers - Headers from the incoming request (can be a Headers object or a plain object)\n * @param options - CORS configuration options\n * @returns Response object for the preflight request, or null if not a preflight\n */\nexport function handleCorsPreflightRequest(\n method: string,\n headers: Record<string, string> | Headers | IncomingHttpHeaders,\n options?: RemoteComponentProxyOptions['cors'],\n): Response | null {\n if (method !== 'OPTIONS' || options === false) {\n return null;\n }\n\n const corsHeaders = getCorsHeaders(options, headers);\n\n return new Response(undefined, {\n status: 200,\n headers: { ...corsHeaders, ...getSecurityHeaders() },\n });\n}\n"]}
@@ -0,0 +1,26 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkCREXMFMFcjs = require('./chunk-CREXMFMF.cjs');
4
+ require('./chunk-7MVFHOIP.cjs');
5
+ require('./chunk-RUWR74XQ.cjs');
6
+ require('./chunk-KE7QPAQ4.cjs');
7
+ require('./chunk-SHFJ5OQA.cjs');
8
+
9
+ // src/host/html/runtime/script.ts
10
+ function scriptRuntime(resolveClientUrl) {
11
+ const self = globalThis;
12
+ return {
13
+ self,
14
+ createFromReadableStream: () => Promise.resolve(null),
15
+ applySharedModules: () => Promise.resolve(),
16
+ nextClientPagesLoader: () => ({
17
+ Component: null,
18
+ App: null
19
+ }),
20
+ preloadScripts: (scripts, url) => _chunkCREXMFMFcjs.loadStaticRemoteComponent.call(void 0, scripts, url, resolveClientUrl)
21
+ };
22
+ }
23
+
24
+
25
+ exports.scriptRuntime = scriptRuntime;
26
+ //# sourceMappingURL=script-6W5JRBZK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/host/html/runtime/script.ts"],"names":[],"mappings":";;;;;;;;;AAOO,SAAS,cAAc,kBAA6C;AAEzE,QAAM,OAAO;AAMb,SAAO;AAAA,IACL;AAAA,IACA,0BAA0B,MAAM,QAAQ,QAAQ,IAAI;AAAA,IACpD,oBAAoB,MAAM,QAAQ,QAAQ;AAAA,IAC1C,uBAAuB,OAAO;AAAA,MAC5B,WAAW;AAAA,MACX,KAAK;AAAA,IACP;AAAA,IACA,gBAAgB,CAAC,SAA8B,QAC7C,0BAA0B,SAAS,KAAK,gBAAgB;AAAA,EAC5D;AACF","sourcesContent":["// initializer for the script runtime\n\nimport type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { loadStaticRemoteComponent } from '#internal/runtime/loaders/static-loader';\nimport type { MountUnmountFunctions, RSCKey } from '#internal/runtime/types';\n\n// required to run exposed client components of the remote component\nexport function scriptRuntime(resolveClientUrl?: InternalResolveClientUrl) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n } & MountUnmountFunctions &\n Record<RSCKey, string[]>;\n\n return {\n self,\n createFromReadableStream: () => Promise.resolve(null),\n applySharedModules: () => Promise.resolve(),\n nextClientPagesLoader: () => ({\n Component: null,\n App: null,\n }),\n preloadScripts: (scripts: HTMLScriptElement[], url: URL) =>\n loadStaticRemoteComponent(scripts, url, resolveClientUrl),\n };\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import {
2
+ loadStaticRemoteComponent
3
+ } from "./chunk-OO4AMJWO.js";
4
+ import "./chunk-KEPHL25S.js";
5
+ import "./chunk-S2A4TFLS.js";
6
+ import "./chunk-X6YKUJKH.js";
7
+ import "./chunk-ENYGL5CO.js";
8
+
9
+ // src/host/html/runtime/script.ts
10
+ function scriptRuntime(resolveClientUrl) {
11
+ const self = globalThis;
12
+ return {
13
+ self,
14
+ createFromReadableStream: () => Promise.resolve(null),
15
+ applySharedModules: () => Promise.resolve(),
16
+ nextClientPagesLoader: () => ({
17
+ Component: null,
18
+ App: null
19
+ }),
20
+ preloadScripts: (scripts, url) => loadStaticRemoteComponent(scripts, url, resolveClientUrl)
21
+ };
22
+ }
23
+ export {
24
+ scriptRuntime
25
+ };
26
+ //# sourceMappingURL=script-IFEBOLIA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/host/html/runtime/script.ts"],"sourcesContent":["// initializer for the script runtime\n\nimport type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { loadStaticRemoteComponent } from '#internal/runtime/loaders/static-loader';\nimport type { MountUnmountFunctions, RSCKey } from '#internal/runtime/types';\n\n// required to run exposed client components of the remote component\nexport function scriptRuntime(resolveClientUrl?: InternalResolveClientUrl) {\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack runtime globals\n __webpack_require__: (remoteId: string) => unknown;\n } & MountUnmountFunctions &\n Record<RSCKey, string[]>;\n\n return {\n self,\n createFromReadableStream: () => Promise.resolve(null),\n applySharedModules: () => Promise.resolve(),\n nextClientPagesLoader: () => ({\n Component: null,\n App: null,\n }),\n preloadScripts: (scripts: HTMLScriptElement[], url: URL) =>\n loadStaticRemoteComponent(scripts, url, resolveClientUrl),\n };\n}\n"],"mappings":";;;;;;;;;AAOO,SAAS,cAAc,kBAA6C;AAEzE,QAAM,OAAO;AAMb,SAAO;AAAA,IACL;AAAA,IACA,0BAA0B,MAAM,QAAQ,QAAQ,IAAI;AAAA,IACpD,oBAAoB,MAAM,QAAQ,QAAQ;AAAA,IAC1C,uBAAuB,OAAO;AAAA,MAC5B,WAAW;AAAA,MACX,KAAK;AAAA,IACP;AAAA,IACA,gBAAgB,CAAC,SAA8B,QAC7C,0BAA0B,SAAS,KAAK,gBAAgB;AAAA,EAC5D;AACF;","names":[]}
@@ -0,0 +1,11 @@
1
+ import {
2
+ loadStaticRemoteComponent
3
+ } from "./chunk-OO4AMJWO.js";
4
+ import "./chunk-KEPHL25S.js";
5
+ import "./chunk-S2A4TFLS.js";
6
+ import "./chunk-X6YKUJKH.js";
7
+ import "./chunk-ENYGL5CO.js";
8
+ export {
9
+ loadStaticRemoteComponent
10
+ };
11
+ //# sourceMappingURL=static-loader-X4TSF5KW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkCREXMFMFcjs = require('./chunk-CREXMFMF.cjs');
4
+ require('./chunk-7MVFHOIP.cjs');
5
+ require('./chunk-RUWR74XQ.cjs');
6
+ require('./chunk-KE7QPAQ4.cjs');
7
+ require('./chunk-SHFJ5OQA.cjs');
8
+
9
+
10
+ exports.loadStaticRemoteComponent = _chunkCREXMFMFcjs.loadStaticRemoteComponent;
11
+ //# sourceMappingURL=static-loader-ZYD5BO4D.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}