remote-components 0.3.7 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LCXO7BUY.cjs → chunk-42TVDI3G.cjs} +5 -4
- package/dist/chunk-42TVDI3G.cjs.map +1 -0
- package/dist/{chunk-AWWWK2ZY.cjs → chunk-4O3EOST4.cjs} +32 -20
- package/dist/chunk-4O3EOST4.cjs.map +1 -0
- package/dist/chunk-5KTAEO52.cjs +28 -0
- package/dist/chunk-5KTAEO52.cjs.map +1 -0
- package/dist/{chunk-SZFCBE54.js → chunk-AKOMV2UF.js} +4 -3
- package/dist/chunk-AKOMV2UF.js.map +1 -0
- package/dist/{chunk-NZAB7REE.js → chunk-CC3WOSDO.js} +5 -5
- package/dist/{chunk-T64P7BAG.cjs → chunk-JJTCFQHE.cjs} +3 -3
- package/dist/{chunk-I47KE3EC.cjs → chunk-KVQI55BZ.cjs} +21 -21
- package/dist/{chunk-GBFUPMMI.js → chunk-LOYJP2V2.js} +25 -13
- package/dist/chunk-LOYJP2V2.js.map +1 -0
- package/dist/{chunk-52BJ7VFA.js → chunk-MKO52FRO.js} +2 -2
- package/dist/{chunk-RJW3EZJP.cjs → chunk-MQ2BBSL4.cjs} +24 -24
- package/dist/chunk-MQ2BBSL4.cjs.map +1 -0
- package/dist/{chunk-QKB74MLO.js → chunk-MTMDXJLM.js} +3 -3
- package/dist/chunk-MTMDXJLM.js.map +1 -0
- package/dist/chunk-N3SQTOSE.cjs +25 -0
- package/dist/chunk-N3SQTOSE.cjs.map +1 -0
- package/dist/chunk-RHGEBXPL.js +25 -0
- package/dist/chunk-RHGEBXPL.js.map +1 -0
- package/dist/{chunk-X6W464D6.cjs → chunk-RLI4YTBJ.cjs} +17 -1
- package/dist/chunk-RLI4YTBJ.cjs.map +1 -0
- package/dist/{chunk-SJM7AAGU.js → chunk-SAGYPGIQ.js} +17 -1
- package/dist/chunk-SAGYPGIQ.js.map +1 -0
- package/dist/chunk-STIJO4AG.js +28 -0
- package/dist/chunk-STIJO4AG.js.map +1 -0
- package/dist/config/nextjs.cjs +6 -5
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.js +3 -2
- package/dist/config/nextjs.js.map +1 -1
- package/dist/host/html.cjs +21 -20
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +9 -8
- package/dist/host/html.js.map +1 -1
- package/dist/host/navigation.cjs +8 -0
- package/dist/host/navigation.cjs.map +1 -0
- package/dist/host/navigation.d.ts +30 -0
- package/dist/host/navigation.js +8 -0
- package/dist/host/navigation.js.map +1 -0
- package/dist/host/nextjs/app/client-only.cjs +14 -12
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.d.ts +2 -1
- package/dist/host/nextjs/app/client-only.js +9 -7
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/react.cjs +12 -8
- package/dist/host/react.d.ts +2 -1
- package/dist/host/react.js +13 -9
- package/dist/{index-4c65355c.d.ts → index-d2ce8a3f.d.ts} +22 -2
- package/dist/internal/host/shared/navigate-event.cjs +51 -0
- package/dist/internal/host/shared/navigate-event.cjs.map +1 -0
- package/dist/internal/host/shared/navigate-event.d.ts +21 -0
- package/dist/internal/host/shared/navigate-event.js +26 -0
- package/dist/internal/host/shared/navigate-event.js.map +1 -0
- package/dist/internal/host/shared/polyfill.cjs +14 -0
- package/dist/internal/host/shared/polyfill.cjs.map +1 -1
- package/dist/internal/host/shared/polyfill.js +16 -0
- package/dist/internal/host/shared/polyfill.js.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.cjs +2 -1
- package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.js +2 -1
- package/dist/internal/runtime/loaders/script-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.js +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
- package/dist/navigate-event-baee0b63.d.ts +14 -0
- package/dist/{turbopack-5LW6V6IT.js → turbopack-5N44NVPT.js} +5 -4
- package/dist/{turbopack-5LW6V6IT.js.map → turbopack-5N44NVPT.js.map} +1 -1
- package/dist/{turbopack-KRKECGY2.cjs → turbopack-EPXGK4EV.cjs} +12 -11
- package/dist/turbopack-EPXGK4EV.cjs.map +1 -0
- package/dist/{webpack-NPZNXRNL.js → webpack-KSDNIXMS.js} +5 -4
- package/dist/{webpack-NPZNXRNL.js.map → webpack-KSDNIXMS.js.map} +1 -1
- package/dist/{webpack-TTZDARNY.cjs → webpack-SIFRCBIN.cjs} +12 -11
- package/dist/webpack-SIFRCBIN.cjs.map +1 -0
- package/package.json +9 -1
- package/dist/chunk-AWWWK2ZY.cjs.map +0 -1
- package/dist/chunk-GBFUPMMI.js.map +0 -1
- package/dist/chunk-LCXO7BUY.cjs.map +0 -1
- package/dist/chunk-QKB74MLO.js.map +0 -1
- package/dist/chunk-RJW3EZJP.cjs.map +0 -1
- package/dist/chunk-SJM7AAGU.js.map +0 -1
- package/dist/chunk-SZFCBE54.js.map +0 -1
- package/dist/chunk-X6W464D6.cjs.map +0 -1
- package/dist/turbopack-KRKECGY2.cjs.map +0 -1
- package/dist/webpack-TTZDARNY.cjs.map +0 -1
- /package/dist/{chunk-NZAB7REE.js.map → chunk-CC3WOSDO.js.map} +0 -0
- /package/dist/{chunk-T64P7BAG.cjs.map → chunk-JJTCFQHE.cjs.map} +0 -0
- /package/dist/{chunk-I47KE3EC.cjs.map → chunk-KVQI55BZ.cjs.map} +0 -0
- /package/dist/{chunk-52BJ7VFA.js.map → chunk-MKO52FRO.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkRLI4YTBJcjs = require('./chunk-RLI4YTBJ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -17,10 +17,11 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
17
17
|
return new Promise((resolve, reject) => {
|
|
18
18
|
const newSrc = new URL(
|
|
19
19
|
// remove the remote component bundle name identifier from the script src
|
|
20
|
-
script.src.replace(
|
|
20
|
+
script.src.replace(_chunkRLI4YTBJcjs.NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
21
21
|
location.origin
|
|
22
22
|
).href;
|
|
23
|
-
const
|
|
23
|
+
const rawResolved = _nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _ => _(newSrc)]), () => ( newSrc));
|
|
24
|
+
const resolvedSrc = new URL(rawResolved, location.href).href;
|
|
24
25
|
const alreadyLoaded = Array.from(
|
|
25
26
|
document.querySelectorAll("script[src]")
|
|
26
27
|
).some((s) => s.src === resolvedSrc);
|
|
@@ -54,4 +55,4 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
54
55
|
|
|
55
56
|
|
|
56
57
|
exports.loadScripts = loadScripts;
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-42TVDI3G.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/loaders/script-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAYA,eAAsB,YACpB,SACA,kBACe;AACf,QAAM,QAAQ;AAAA,IACZ,QAAQ,IAAI,CAAC,WAAW;AACtB,aAAO,IAAI,QAAc,CAAC,SAAS,WAAW;AAC5C,cAAM,SAAS,IAAI;AAAA;AAAA,UAEjB,OAAO,IAAI,QAAQ,qBAAqB,SAAS;AAAA,UACjD,SAAS;AAAA,QACX,EAAE;AAMF,cAAM,cAAc,mBAAmB,MAAM,KAAK;AAClD,cAAM,cAAc,IAAI,IAAI,aAAa,SAAS,IAAI,EAAE;AAExD,cAAM,gBAAgB,MAAM;AAAA,UAC1B,SAAS,iBAAoC,aAAa;AAAA,QAC5D,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,WAAW;AACnC,YAAI,eAAe;AACjB,kBAAQ;AACR;AAAA,QACF;AAEA,cAAM,YAAY,SAAS,cAAc,QAAQ;AACjD,kBAAU,SAAS,MAAM,QAAQ;AACjC,kBAAU,UAAU,MAAM;AACxB,gBAAM,YAAY,aAAa,WAAW;AAC1C,cAAI,WAAW;AACb,mBAAO,wBAAwB,UAAU,QAAQ,WAAW,CAAC;AAAA,UAC/D,OAAO;AACL,sCAA0B,gBAAgB,MAAM;AAChD;AAAA,cACE,IAAI;AAAA,gBACF,+BAA+B;AAAA,cACjC;AAAA,YACF;AAAA,UACF;AAAA,QACF;AACA,kBAAU,MAAM;AAChB,kBAAU,QAAQ;AAClB,iBAAS,KAAK,YAAY,SAAS;AAAA,MACrC,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF","sourcesContent":["import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { NEXT_BUNDLE_PATH_RE } from '#internal/runtime/patterns';\nimport { isProxiedUrl } from '#internal/runtime/url/protected-rc-fallback';\nimport {\n failedProxiedAssetError,\n RemoteComponentsError,\n} from '#internal/utils/error';\nimport { warnCrossOriginFetchError } from '#internal/utils/logger';\n\n/**\n * Loads external scripts for remote components\n */\nexport async function loadScripts(\n scripts: { src: string }[],\n resolveClientUrl?: InternalResolveClientUrl,\n): Promise<void> {\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newSrc = new URL(\n // remove the remote component bundle name identifier from the script src\n script.src.replace(NEXT_BUNDLE_PATH_RE, '/_next/'),\n location.origin,\n ).href;\n\n // resolveClientUrl may return a relative URL (e.g. the host-proxy\n // path \"/rc-fetch-protected-remote?url=...\"). Normalize to absolute\n // before comparing with s.src, which browsers always expose as\n // absolute, so the deduplication check works in deployed contexts.\n const rawResolved = resolveClientUrl?.(newSrc) ?? newSrc;\n const resolvedSrc = new URL(rawResolved, location.href).href;\n\n const alreadyLoaded = Array.from(\n document.querySelectorAll<HTMLScriptElement>('script[src]'),\n ).some((s) => s.src === resolvedSrc);\n if (alreadyLoaded) {\n resolve();\n return;\n }\n\n const newScript = document.createElement('script');\n newScript.onload = () => resolve();\n newScript.onerror = () => {\n const isProxied = isProxiedUrl(resolvedSrc);\n if (isProxied) {\n reject(failedProxiedAssetError('script', newSrc, resolvedSrc));\n } else {\n warnCrossOriginFetchError('ScriptLoader', newSrc);\n reject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${newSrc}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n }\n };\n newScript.src = resolvedSrc;\n newScript.async = true;\n document.head.appendChild(newScript);\n });\n }),\n );\n}\n"]}
|
|
@@ -7,18 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkKVQI55BZcjs = require('./chunk-KVQI55BZ.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkTZT7DLO5cjs = require('./chunk-TZT7DLO5.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
var _chunkN3SQTOSEcjs = require('./chunk-N3SQTOSE.cjs');
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var _chunkRLI4YTBJcjs = require('./chunk-RLI4YTBJ.cjs');
|
|
22
25
|
|
|
23
26
|
|
|
24
27
|
var _chunkZ2SLBFQLcjs = require('./chunk-Z2SLBFQL.cjs');
|
|
@@ -89,7 +92,7 @@ function setAttributesFromProps(el, props) {
|
|
|
89
92
|
function useResolveClientUrl(prop, urlHref) {
|
|
90
93
|
const { resolveClientUrl: contextValue } = _context.useRemoteComponentsContext.call(void 0, );
|
|
91
94
|
const raw = _nullishCoalesce(prop, () => ( contextValue));
|
|
92
|
-
return _react.useMemo.call(void 0, () =>
|
|
95
|
+
return _react.useMemo.call(void 0, () => _chunkKVQI55BZcjs.bindResolveClientUrl.call(void 0, raw, urlHref), [raw, urlHref]);
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
// src/host/react/hooks/use-shadow-root.ts
|
|
@@ -151,7 +154,7 @@ function getRemoteComponentHtml(html) {
|
|
|
151
154
|
return ssrRemoteComponentContainer.innerHTML;
|
|
152
155
|
}
|
|
153
156
|
const remoteComponentContainer = temp.querySelectorAll(
|
|
154
|
-
`div[data-bundle][data-route][data-runtime][id^="${
|
|
157
|
+
`div[data-bundle][data-route][data-runtime][id^="${_chunkRLI4YTBJcjs.DEFAULT_COMPONENT_NAME}"],div[data-bundle][data-route],div#__next,remote-component:not([src])`
|
|
155
158
|
);
|
|
156
159
|
if (remoteComponentContainer.length > 0) {
|
|
157
160
|
return `${Array.from(temp.querySelectorAll("link,script")).map((link) => link.outerHTML).join("")}${Array.from(remoteComponentContainer).map((container) => container.outerHTML).join("")}`;
|
|
@@ -159,6 +162,14 @@ function getRemoteComponentHtml(html) {
|
|
|
159
162
|
return "";
|
|
160
163
|
}
|
|
161
164
|
|
|
165
|
+
// src/host/react/hooks/use-remote-navigate.ts
|
|
166
|
+
|
|
167
|
+
function useRemoteNavigate(callback) {
|
|
168
|
+
const callbackRef = _react.useRef.call(void 0, callback);
|
|
169
|
+
callbackRef.current = callback;
|
|
170
|
+
_react.useEffect.call(void 0, () => _chunkN3SQTOSEcjs.onRemoteNavigate.call(void 0, (event) => callbackRef.current(event)), []);
|
|
171
|
+
}
|
|
172
|
+
|
|
162
173
|
// src/host/react/index.tsx
|
|
163
174
|
var _jsxruntime = require('react/jsx-runtime');
|
|
164
175
|
|
|
@@ -168,7 +179,7 @@ function ConsumeRemoteComponent({
|
|
|
168
179
|
mode = "open",
|
|
169
180
|
reset,
|
|
170
181
|
credentials: credentialsProp,
|
|
171
|
-
name: nameProp =
|
|
182
|
+
name: nameProp = _chunkRLI4YTBJcjs.DEFAULT_COMPONENT_NAME,
|
|
172
183
|
shared: sharedProp,
|
|
173
184
|
children,
|
|
174
185
|
onBeforeLoad,
|
|
@@ -184,22 +195,22 @@ function ConsumeRemoteComponent({
|
|
|
184
195
|
const credentials = _nullishCoalesce(_nullishCoalesce(credentialsProp, () => ( contextCredentials)), () => ( "same-origin"));
|
|
185
196
|
const shared = _nullishCoalesce(_nullishCoalesce(sharedProp, () => ( contextShared)), () => ( {}));
|
|
186
197
|
const emitter = _react.useMemo.call(void 0,
|
|
187
|
-
() =>
|
|
198
|
+
() => _chunkKVQI55BZcjs.makeReactEmitter.call(void 0, { onBeforeLoad, onLoad, onError, onChange }),
|
|
188
199
|
[onBeforeLoad, onLoad, onError, onChange]
|
|
189
200
|
);
|
|
190
201
|
const name = _react.useMemo.call(void 0,
|
|
191
|
-
() =>
|
|
202
|
+
() => _chunkKVQI55BZcjs.resolveNameFromSrc.call(void 0, src, nameProp),
|
|
192
203
|
[src, nameProp]
|
|
193
204
|
);
|
|
194
205
|
const [data, setData] = _react.useState.call(void 0,
|
|
195
206
|
null
|
|
196
207
|
);
|
|
197
|
-
const url = _react.useMemo.call(void 0, () =>
|
|
208
|
+
const url = _react.useMemo.call(void 0, () => _chunkKVQI55BZcjs.getClientOrServerUrl.call(void 0, src, DUMMY_FALLBACK), [src]);
|
|
198
209
|
const resolveClientUrl = useResolveClientUrl(resolveClientUrlProp, url.href);
|
|
199
210
|
const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
|
|
200
|
-
const keySuffix = `${
|
|
211
|
+
const keySuffix = `${_chunkRLI4YTBJcjs.escapeString.call(void 0, id)}_${_chunkRLI4YTBJcjs.escapeString.call(void 0,
|
|
201
212
|
_nullishCoalesce(_optionalChain([data, 'optionalAccess', _5 => _5.name]), () => ( name))
|
|
202
|
-
)}_${
|
|
213
|
+
)}_${_chunkRLI4YTBJcjs.escapeString.call(void 0, instanceId)}`;
|
|
203
214
|
const [remoteComponent, setRemoteComponent] = _react.useState.call(void 0, null);
|
|
204
215
|
const { shadowRoot, shadowRootContainerRef } = useShadowRoot({
|
|
205
216
|
isolate,
|
|
@@ -225,7 +236,7 @@ function ConsumeRemoteComponent({
|
|
|
225
236
|
return elements;
|
|
226
237
|
})() : []
|
|
227
238
|
);
|
|
228
|
-
const hostStateRef = _react.useRef.call(void 0,
|
|
239
|
+
const hostStateRef = _react.useRef.call(void 0, _chunkKVQI55BZcjs.createHostState.call(void 0, ));
|
|
229
240
|
const componentHydrationHtml = _react.useRef.call(void 0, null);
|
|
230
241
|
const prevRemoteComponentContainerRef = _react.useRef.call(void 0, null);
|
|
231
242
|
const unmountRef = _react.useRef.call(void 0, null);
|
|
@@ -291,7 +302,7 @@ function ConsumeRemoteComponent({
|
|
|
291
302
|
_nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _29 => _29(url.href)]), () => ( url.href)),
|
|
292
303
|
location.href
|
|
293
304
|
);
|
|
294
|
-
const res = await
|
|
305
|
+
const res = await _chunkKVQI55BZcjs.fetchWithHooks.call(void 0, resolvedUrl, fetchInit, {
|
|
295
306
|
onRequest,
|
|
296
307
|
onResponse,
|
|
297
308
|
abortController: hostStateRef.current.abortController
|
|
@@ -310,7 +321,7 @@ function ConsumeRemoteComponent({
|
|
|
310
321
|
const userShared = await shared;
|
|
311
322
|
if (signal.aborted)
|
|
312
323
|
return;
|
|
313
|
-
const prepared =
|
|
324
|
+
const prepared = _chunkKVQI55BZcjs.preparePipeline.call(void 0, {
|
|
314
325
|
html,
|
|
315
326
|
name,
|
|
316
327
|
url,
|
|
@@ -351,7 +362,7 @@ function ConsumeRemoteComponent({
|
|
|
351
362
|
href: new URL(_nullishCoalesce(link.getAttribute("href"), () => ( link.href)), url).href,
|
|
352
363
|
...link.getAttributeNames().reduce((acc, key) => {
|
|
353
364
|
if (key !== "href") {
|
|
354
|
-
acc[_nullishCoalesce(
|
|
365
|
+
acc[_nullishCoalesce(_chunkRLI4YTBJcjs.attrToProp[key], () => ( key))] = _nullishCoalesce(link.getAttribute(key), () => ( ""));
|
|
355
366
|
}
|
|
356
367
|
return acc;
|
|
357
368
|
}, {})
|
|
@@ -413,7 +424,7 @@ function ConsumeRemoteComponent({
|
|
|
413
424
|
});
|
|
414
425
|
self.__next_s = prevNextScripts;
|
|
415
426
|
}
|
|
416
|
-
const rscName = rsc ? `__remote_component_rsc_${
|
|
427
|
+
const rscName = rsc ? `__remote_component_rsc_${_chunkRLI4YTBJcjs.escapeString.call(void 0, id)}_${_chunkRLI4YTBJcjs.escapeString.call(void 0,
|
|
417
428
|
remoteName
|
|
418
429
|
)}` : void 0;
|
|
419
430
|
if (rsc) {
|
|
@@ -486,7 +497,7 @@ function ConsumeRemoteComponent({
|
|
|
486
497
|
}
|
|
487
498
|
hostStateRef.current.stage = "loaded";
|
|
488
499
|
} else {
|
|
489
|
-
const result = await
|
|
500
|
+
const result = await _chunkKVQI55BZcjs.loadPrepared.call(void 0, {
|
|
490
501
|
prepared,
|
|
491
502
|
url,
|
|
492
503
|
signal,
|
|
@@ -555,8 +566,8 @@ function ConsumeRemoteComponent({
|
|
|
555
566
|
const metadataJson = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
|
|
556
567
|
name: _optionalChain([data, 'optionalAccess', _33 => _33.name]) || name,
|
|
557
568
|
bundle: _optionalChain([data, 'optionalAccess', _34 => _34.bundle]) || "default",
|
|
558
|
-
route: _optionalChain([data, 'optionalAccess', _35 => _35.route]) ||
|
|
559
|
-
runtime: hostStateRef.current.prevIsRemoteComponent ?
|
|
569
|
+
route: _optionalChain([data, 'optionalAccess', _35 => _35.route]) || _chunkRLI4YTBJcjs.DEFAULT_ROUTE,
|
|
570
|
+
runtime: hostStateRef.current.prevIsRemoteComponent ? _chunkRLI4YTBJcjs.RUNTIME_SCRIPT : _optionalChain([data, 'optionalAccess', _36 => _36.runtime]) || _chunkRLI4YTBJcjs.RUNTIME_WEBPACK
|
|
560
571
|
}) });
|
|
561
572
|
const resetStyle = reset ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
|
|
562
573
|
const linksToRender = _optionalChain([data, 'optionalAccess', _37 => _37.links, 'optionalAccess', _38 => _38.map, 'call', _39 => _39((link) => /* @__PURE__ */ _react.createElement.call(void 0,
|
|
@@ -666,5 +677,6 @@ function ConsumeRemoteComponent({
|
|
|
666
677
|
|
|
667
678
|
|
|
668
679
|
|
|
669
|
-
|
|
670
|
-
|
|
680
|
+
|
|
681
|
+
exports.useRemoteNavigate = useRemoteNavigate; exports.ConsumeRemoteComponent = ConsumeRemoteComponent;
|
|
682
|
+
//# sourceMappingURL=chunk-4O3EOST4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/host/react/index.tsx","../src/runtime/html/set-attributes-from-props.ts","../src/host/react/hooks/use-resolve-client-url.ts","../src/host/react/hooks/use-shadow-root.ts","../src/host/react/utils/extract-remote-html.ts","../src/host/react/hooks/use-remote-navigate.ts"],"names":["useEffect","useLayoutEffect","useMemo","useRef","useState","useRemoteComponentsContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA,aAAAA;AAAA,EACA;AAAA,EACA,mBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,OACK;AACP,SAAS,oB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A,gBACD,oBAAC,cAAS,IAAI,GAAG,YAAY,KAAK,gBAAgB;AAAA,iBACpD;AAAA,cACA;AAAA,YACF,IACA;AAAA;AAAA;AAAA,MACN;AAAA,OACF;AAAA,EAEJ;AACA,UAAQ,UAAU;AAGlB,SACE,iCACE;AAAA,wBAAC,cAAS,IAAI,GAAG,cAAc;AAAA,IAC9B;AAAA,IACA;AAAA,IACD,oBAAC,cAAS,IAAI,GAAG,YAAY,KAAK,gBAAgB;AAAA,KACpD;AAEJ","sourcesContent":["import {\n startTransition,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useRemoteComponentsContext } from '#internal/host/react/context';\nimport { fetchWithHooks } from '#internal/host/server/fetch-with-hooks';\nimport { getClientOrServerUrl } from '#internal/host/server/get-client-or-server-url';\nimport type { ConsumeRemoteComponentConfig } from '#internal/host/shared/config';\nimport { makeReactEmitter } from '#internal/host/shared/lifecycle';\nimport { loadPrepared, preparePipeline } from '#internal/host/shared/pipeline';\nimport type { ConsumeServerData } from '#internal/host/shared/server-handoff';\nimport { createHostState } from '#internal/host/shared/state';\nimport { resolveNameFromSrc } from '#internal/host/utils/resolve-name-from-src';\nimport {\n DEFAULT_COMPONENT_NAME,\n DEFAULT_ROUTE,\n RUNTIME_SCRIPT,\n RUNTIME_WEBPACK,\n} from '#internal/runtime/constants';\nimport { setAttributesFromProps } from '#internal/runtime/html/set-attributes-from-props';\nimport { loadStaticRemoteComponent } from '#internal/runtime/loaders/static-loader';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport { attrToProp, escapeString } from '#internal/utils';\nimport { isAbortError } from '#internal/utils/abort';\nimport {\n errorFromFailedFetch,\n RemoteComponentsError,\n} from '#internal/utils/error';\nimport type { MountOrUnmountFunction } from '#remote-components/runtime/types';\nimport { useResolveClientUrl } from './hooks/use-resolve-client-url';\nimport { useShadowRoot } from './hooks/use-shadow-root';\nimport {\n DUMMY_FALLBACK,\n getRemoteComponentHtml,\n} from './utils/extract-remote-html';\n\n/**\n * Props for the React remote component host.\n *\n * Extends {@link ConsumeRemoteComponentConfig} with `children` for loading\n * fallback content.\n *\n * To react to navigations originating from embedded remote components, set up\n * a single top-level subscription with `onRemoteNavigate` from\n * `remote-components/host/navigation` and route the event to your host's\n * router.\n */\nexport interface ConsumeRemoteComponentProps\n extends ConsumeRemoteComponentConfig {\n /** Loading fallback content displayed while the remote component is being fetched. */\n children?: React.ReactNode;\n}\n\n/**\n * ConsumeRemoteComponent is a React component that fetches and renders a remote component.\n * It supports SSR and can isolate the remote component in a shadow DOM.\n *\n * @param props - The properties for the remote component.\n * @returns A React component that renders the remote component.\n *\n * @example\n *\n * Use the `<ConsumeRemoteComponent>` in your React application to consume a remote component from a remote application:\n *\n * ```tsx\n * import { ConsumeRemoteComponent } from 'remote-components/host/react';\n *\n * export default function App() {\n * return (\n * <>\n * <h1>Welcome to My App</h1>\n * <p>This page consumes a remote component from another application.</p>\n * <ConsumeRemoteComponent src=\"/nextjs-app-remote/components/header\" />\n * </>\n * );\n * }\n * ```\n *\n * To share modules, you can provide a shared module map with references to the shared modules:\n *\n * ```tsx\n * <ConsumeRemoteComponent\n * src=\"/nextjs-app-remote/components/header\"\n * shared={{\n * '@/components/provider': () => import('@/components/host-provider')\n * }}\n * />\n * ```\n */\nexport function ConsumeRemoteComponent({\n src,\n isolate,\n mode = 'open',\n reset,\n credentials: credentialsProp,\n name: nameProp = DEFAULT_COMPONENT_NAME,\n shared: sharedProp,\n children,\n onBeforeLoad,\n onLoad,\n onError,\n onChange,\n onRequest,\n onResponse,\n resolveClientUrl: resolveClientUrlProp,\n}: ConsumeRemoteComponentProps) {\n const instanceId = useId();\n\n const { credentials: contextCredentials, shared: contextShared } =\n useRemoteComponentsContext();\n const credentials = credentialsProp ?? contextCredentials ?? 'same-origin';\n const shared = sharedProp ?? contextShared ?? {};\n const emitter = useMemo(\n () => makeReactEmitter({ onBeforeLoad, onLoad, onError, onChange }),\n [onBeforeLoad, onLoad, onError, onChange],\n );\n\n const name = useMemo(\n () => resolveNameFromSrc(src, nameProp),\n [src, nameProp],\n );\n\n const [data, setData] = useState<Omit<ConsumeServerData, 'children'> | null>(\n null,\n );\n\n const url = useMemo(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);\n\n const resolveClientUrl = useResolveClientUrl(resolveClientUrlProp, url.href);\n\n // for relative src paths, use just the pathname as the unique id.\n // for static urls, use the full url as the unique id as the path may not be unique.\n // this id needs to be the same for server and client side rendering.\n // note that if this needs to be more unique, can pass through the bundle as an id prop and ammend it to this id.\n const id =\n url.origin ===\n (typeof location !== 'undefined' ? location.origin : DUMMY_FALLBACK)\n ? url.pathname\n : url.href;\n\n //instanceId prevents multiple components with the same src from sharing a shadow root\n const keySuffix = `${escapeString(id)}_${escapeString(\n data?.name ?? name,\n )}_${escapeString(instanceId)}`;\n\n const [remoteComponent, setRemoteComponent] = useState<\n React.ReactNode | Error\n >(null);\n\n const { shadowRoot, shadowRootContainerRef } = useShadowRoot({\n isolate,\n mode,\n keySuffix,\n });\n\n const htmlRef = useRef<string | null>(\n typeof document !== 'undefined'\n ? (document.querySelector(\n `[data-remote-component-id=\"shadowroot_${keySuffix}\"]`,\n )?.shadowRoot?.innerHTML ??\n document.getElementById(`__REMOTE_COMPONENT${name}`)?.innerHTML ??\n document.querySelector(`div[data-bundle][data-route][id^=\"${name}\"]`)\n ?.innerHTML ??\n document.querySelector('div[data-bundle][data-route]')?.innerHTML)\n : null,\n );\n const endTemplateRef = useRef<HTMLTemplateElement | null>(null);\n // collect initial content that needs to be removed after remote component renders\n const childrenRef = useRef(\n typeof document !== 'undefined'\n ? (() => {\n let el = document.querySelector(`template[id=\"${name}_start\"]`);\n const elements = [];\n while (el && el.id !== `${name}_end`) {\n if (\n el.id !== `${name}_start` &&\n !el.getAttribute('data-remote-component')\n ) {\n elements.push(el);\n }\n el = el.nextElementSibling as HTMLTemplateElement | null;\n }\n return elements;\n })()\n : [],\n );\n const hostStateRef = useRef(createHostState());\n const componentHydrationHtml = useRef<string | null>(null);\n const prevRemoteComponentContainerRef = useRef<HTMLDivElement | null>(null);\n const unmountRef = useRef<Set<MountOrUnmountFunction> | null>(null);\n\n // Clean up the shadow root cache on unmount to prevent memory leaks\n useLayoutEffect(() => {\n return () => {\n delete getNamespace().shadowRoots[keySuffix];\n };\n }, [keySuffix]);\n\n useLayoutEffect(() => {\n // Clear initial content after remote component renders\n if (childrenRef.current.length > 0 && remoteComponent) {\n childrenRef.current.forEach((el) => {\n el.remove();\n });\n childrenRef.current = [];\n }\n }, [remoteComponent]);\n\n useLayoutEffect(() => {\n if (shadowRoot && remoteComponent) {\n const resetStyles = shadowRoot.querySelectorAll(\n 'style[data-remote-components-reset]',\n );\n // ensure we only have one reset style in the shadow root\n if (resetStyles.length > 1) {\n resetStyles.forEach((style, index) => {\n if (\n index > 0 &&\n style.getAttribute('data-remote-components-reset') !== 'react'\n ) {\n style.remove();\n }\n });\n }\n\n // clear the html ref after hydration\n htmlRef.current = null;\n\n // clear all nodes except links and styles until the start marker\n // the marker gets only rendered on hydration\n let el: ChildNode | null = shadowRoot.childNodes[0] ?? null;\n while (el && (!('id' in el) || el.id !== `${name}_start`)) {\n const nextEl = el.nextSibling;\n if (el.nodeName !== 'LINK' && el.nodeName !== 'STYLE') {\n el.parentNode?.removeChild(el);\n }\n el = nextEl;\n }\n }\n }, [shadowRoot, remoteComponent, name]);\n\n useEffect(() => {\n if (src && src !== hostStateRef.current.prevSrc) {\n const previousSrc = hostStateRef.current.prevSrc;\n const previousName = hostStateRef.current.prevName;\n hostStateRef.current.prevSrc = src;\n\n if (previousSrc !== null) {\n htmlRef.current = null;\n }\n\n // Abort any in-progress load so the latest src always wins.\n hostStateRef.current.abortController?.abort();\n hostStateRef.current.abortController = new AbortController();\n const { signal } = hostStateRef.current.abortController;\n\n emitter.beforeLoad(src);\n hostStateRef.current.stage = 'loading';\n\n startTransition(async () => {\n try {\n let html = getRemoteComponentHtml(\n htmlRef.current ??\n (endTemplateRef.current?.previousElementSibling?.tagName === 'div'\n ? endTemplateRef.current.previousElementSibling.innerHTML\n : ''),\n );\n\n if (!html && src) {\n // fetch the remote component\n const fetchInit = {\n credentials,\n } as RequestInit;\n\n const resolvedUrl = new URL(\n resolveClientUrl?.(url.href) ?? url.href,\n location.href,\n );\n const res = await fetchWithHooks(resolvedUrl, fetchInit, {\n onRequest,\n onResponse,\n abortController: hostStateRef.current.abortController,\n });\n\n if (!res || !res.ok) {\n throw await errorFromFailedFetch(url.href, resolvedUrl, res);\n }\n\n // get the full HTML content as a string\n const remoteHtml = await res.text();\n if (signal.aborted) return;\n htmlRef.current = remoteHtml;\n html = getRemoteComponentHtml(remoteHtml);\n }\n\n if (signal.aborted) return;\n\n const userShared = await shared;\n if (signal.aborted) return;\n\n const prepared = preparePipeline({\n html,\n name,\n url,\n shared: userShared,\n resolveClientUrl,\n });\n const { doc, parsed } = prepared;\n const {\n component,\n name: remoteName,\n isRemoteComponent,\n metadata,\n rsc,\n remoteShared,\n links: linkElements,\n } = parsed;\n\n if (hostStateRef.current.prevIsRemoteComponent) {\n if (shadowRoot) {\n shadowRoot.innerHTML = '';\n }\n const prevUrl = hostStateRef.current.prevUrl;\n if (prevUrl && getNamespace().unmountFns[prevUrl.href]) {\n const unmountPromises = Promise.all(\n Array.from(unmountRef.current ?? []).map(async (unmount) =>\n unmount(\n shadowRoot ?? prevRemoteComponentContainerRef.current,\n ),\n ),\n );\n unmountRef.current = null;\n await unmountPromises;\n }\n }\n hostStateRef.current.prevIsRemoteComponent = isRemoteComponent;\n hostStateRef.current.prevUrl = url;\n hostStateRef.current.prevName = remoteName;\n\n const links = linkElements.map((link) => ({\n href: new URL(link.getAttribute('href') ?? link.href, url).href,\n ...link\n .getAttributeNames()\n .reduce<Record<string, string>>((acc, key) => {\n if (key !== 'href') {\n acc[attrToProp[key] ?? key] = link.getAttribute(key) ?? '';\n }\n return acc;\n }, {}),\n }));\n\n // handle inline scripts in the remote component\n const inlineScripts = (\n isRemoteComponent ? component : doc\n ).querySelectorAll(\n \"script:not([src]):not([data-src]):not([id*='_rsc']):not([id='__NEXT_DATA__']):not([id='__REMOTE_NEXT_DATA__'])\",\n );\n\n if (!isRemoteComponent) {\n // Next.js Script support\n const self = globalThis as typeof globalThis & {\n __next_s: [string, Record<string, string>][];\n };\n const prevNextScripts = self.__next_s;\n const nextScripts = [] as [string, Record<string, string>][];\n // eslint-disable-next-line camelcase\n self.__next_s = nextScripts;\n\n // TODO: needs to be cancellable with a singular listener for the abort signal https://linear.app/vercel/issue/MFES-1253/handle-abortcontroller-clean-up-scenarios\n await Promise.all(\n Array.from(inlineScripts)\n .filter(\n (script) =>\n !(\n script.id.endsWith('_shared') &&\n script.getAttribute('type') === 'application/json' &&\n typeof script.getAttribute(\n 'data-remote-components-shared',\n ) === 'string'\n ),\n )\n .map((script) => {\n return new Promise((resolve) => {\n // only handle inline scripts with content, but not Next.js RSC scripts\n if (\n script.textContent &&\n !script.textContent.includes('self.__next_f=') &&\n !script.textContent.includes('self.__next_f.push')\n ) {\n // if script is inline javascript, then execute using blob\n if (\n !script.getAttribute('type') ||\n script.getAttribute('type') === 'text/javascript' ||\n script.getAttribute('type') === 'application/javascript'\n ) {\n const newScript = document.createElement('script');\n\n // scripts loaded from external sources needs this workaround\n const blob = new Blob([script.textContent], {\n type: 'application/javascript',\n });\n const blobUrl = URL.createObjectURL(blob);\n\n newScript.onload = () => {\n resolve(undefined);\n // script executed and safe to remove\n URL.revokeObjectURL(blobUrl);\n newScript.remove();\n };\n // on error we still want to resolve to not block the remote component loading\n newScript.onerror = () => {\n URL.revokeObjectURL(blobUrl);\n newScript.remove();\n resolve(undefined);\n };\n\n newScript.src = blobUrl;\n // TODO: needs to be cancellable https://linear.app/vercel/issue/MFES-1253/handle-abortcontroller-clean-up-scenarios\n document.body.appendChild(newScript);\n } else {\n resolve(undefined);\n document.body.appendChild(script);\n }\n } else {\n resolve(undefined);\n }\n });\n }),\n );\n // process the remote component Next.js Script container\n nextScripts.forEach(([scriptSrc, props]) => {\n const script = document.createElement('script');\n // when we have a script src, apply it (inline scripts have `0` as src)\n if (scriptSrc) {\n script.src = scriptSrc;\n }\n // apply Script props\n if (typeof props.children === 'string') {\n script.textContent = props.children;\n }\n setAttributesFromProps(script, props);\n document.head.appendChild(script);\n });\n // restore previous Next.js Script container\n // eslint-disable-next-line camelcase\n self.__next_s = prevNextScripts;\n }\n\n const rscName = rsc\n ? `__remote_component_rsc_${escapeString(id)}_${escapeString(\n remoteName,\n )}`\n : undefined;\n if (rsc) {\n rsc.textContent =\n rsc.textContent?.replace(\n new RegExp(`self\\\\[\"${remoteName}\"\\\\]`, 'g'),\n `self[\"${rscName}\"]`,\n ) ?? '';\n document.body.appendChild(rsc);\n }\n\n const newData = {\n ...metadata,\n links,\n remoteShared,\n src: typeof src === 'string' ? src : src.href,\n serverUrl: url.href,\n data: rsc\n ? (rsc.textContent || '').split('\\n').filter(Boolean)\n : [],\n };\n\n componentHydrationHtml.current = `${Array.from(\n doc.querySelectorAll('link,style'),\n )\n .map((link) => link.outerHTML)\n .join('')}${\n reset\n ? `<style data-remote-components-reset=\"\">:host { all: initial; }</style>`\n : ''\n }${component.innerHTML}`;\n\n if (isRemoteComponent) {\n // Only call onChange when not on first load (matching HTML implementation)\n if (previousSrc !== undefined) {\n emitter.change({\n previousSrc: previousSrc ?? null,\n nextSrc: src,\n previousName,\n nextName: remoteName,\n });\n }\n setData(newData);\n if (shadowRoot) {\n const shadowRootHtml = reset\n ? `<style data-remote-components-reset=\"\">:host { all: initial; }</style>${component.innerHTML}`\n : component.innerHTML;\n shadowRoot.innerHTML = shadowRootHtml;\n htmlRef.current = null;\n setRemoteComponent(null);\n const { mount, unmount } = await loadStaticRemoteComponent(\n Array.from(shadowRoot.querySelectorAll('script')),\n url,\n resolveClientUrl,\n );\n unmountRef.current = unmount;\n await Promise.all(\n Array.from(mount).map((mountFn) => mountFn(shadowRoot)),\n );\n emitter.load(src);\n } else if (isolate === false) {\n setRemoteComponent(\n // TODO: remove wrapper div by converting HTML to RSC or React tree\n <div\n dangerouslySetInnerHTML={{ __html: component.innerHTML }}\n ref={prevRemoteComponentContainerRef}\n />,\n );\n htmlRef.current = null;\n const { mount, unmount } = await loadStaticRemoteComponent(\n Array.from(component.querySelectorAll('script')),\n url,\n resolveClientUrl,\n );\n unmountRef.current = unmount;\n await Promise.all(\n Array.from(mount).map((mountFn) =>\n mountFn(prevRemoteComponentContainerRef.current),\n ),\n );\n emitter.load(src);\n }\n hostStateRef.current.stage = 'loaded';\n } else {\n const result = await loadPrepared({\n prepared,\n url,\n signal,\n shared: userShared,\n resolveClientUrl,\n container: shadowRoot,\n rscName,\n });\n if (rsc) {\n rsc.remove();\n }\n\n setData(newData);\n // Only call onChange when not on first load (matching HTML implementation)\n if (previousSrc !== undefined) {\n emitter.change({\n previousSrc: previousSrc ?? null,\n nextSrc: src,\n previousName,\n nextName: remoteName,\n });\n }\n if (result.status === 'aborted') {\n return;\n }\n if (result.status === 'error') {\n hostStateRef.current.stage = 'error';\n setRemoteComponent(result.error);\n emitter.error(result.error);\n } else if (result.status === 'loaded') {\n hostStateRef.current.stage = 'loaded';\n setRemoteComponent(result.component);\n emitter.load(src);\n }\n }\n } catch (error) {\n // AbortError is expected when loading is cancelled - exit cleanly\n if (isAbortError(error)) {\n hostStateRef.current.stage = 'idle';\n return;\n }\n hostStateRef.current.stage = 'error';\n setRemoteComponent(error as Error);\n emitter.error(error);\n }\n });\n }\n }, [\n url,\n src,\n isolate,\n credentials,\n name,\n shared,\n shadowRoot,\n reset,\n id,\n emitter.beforeLoad,\n emitter.load,\n emitter.error,\n emitter.change,\n onRequest,\n onResponse,\n resolveClientUrl,\n ]);\n\n if (remoteComponent instanceof Error) {\n throw remoteComponent;\n }\n\n const metadataJson = (\n <script data-remote-component type=\"application/json\">\n {JSON.stringify({\n name: data?.name || name,\n bundle: data?.bundle || 'default',\n route: data?.route || DEFAULT_ROUTE,\n runtime: hostStateRef.current.prevIsRemoteComponent\n ? RUNTIME_SCRIPT\n : data?.runtime || RUNTIME_WEBPACK,\n })}\n </script>\n );\n const resetStyle = reset ? (\n <style data-remote-components-reset=\"react\">{`:host { all: initial; }`}</style>\n ) : null;\n const linksToRender: React.ReactNode[] | null =\n data?.links?.map((link) => (\n <link\n {...link}\n href={new URL(link.href as string, url).href}\n key={JSON.stringify(link)}\n />\n )) || null;\n const componentToRender = (\n <>\n {resetStyle}\n {linksToRender}\n {remoteComponent ?? children}\n </>\n );\n\n if (componentHydrationHtml.current && shadowRoot && !shadowRoot.innerHTML) {\n shadowRoot.innerHTML = componentHydrationHtml.current;\n componentHydrationHtml.current = null;\n\n if (hostStateRef.current.prevIsRemoteComponent) {\n // ensure we load static resources when hydrating a remote component in shadow DOM\n loadStaticRemoteComponent(\n Array.from(shadowRoot.querySelectorAll('script')),\n url,\n resolveClientUrl,\n )\n .then(({ mount }) => {\n return Promise.all(\n Array.from(mount).map((mountFn) => mountFn(shadowRoot)),\n );\n })\n .then(() => {\n if (src) {\n emitter.load(src);\n }\n })\n .catch((e) => {\n const error = new RemoteComponentsError(\n `Error mounting remote component from \"${url.href}\"`,\n {\n cause: e,\n },\n );\n setRemoteComponent(error);\n emitter.error(error);\n });\n }\n }\n\n if (isolate !== false) {\n const shadowRemoteComponentHtml =\n shadowRoot?.querySelector(`#__REMOTE_COMPONENT${name}`) ??\n shadowRoot?.querySelector('div[data-bundle][data-route]');\n if (shadowRemoteComponentHtml) {\n shadowRemoteComponentHtml.remove();\n }\n\n return (\n <>\n {metadataJson}\n <div\n data-remote-component-id={`shadowroot_${keySuffix}`}\n id={`shadowroot_${data?.name ?? name}`}\n ref={shadowRootContainerRef}\n >\n {typeof document === 'undefined' ? (\n // eslint-disable-next-line react/no-unknown-property\n <template shadowrootmode={mode}>\n {typeof document === 'undefined' ? (\n <div\n dangerouslySetInnerHTML={{\n __html: `<img\n alt=\"\" decoding=\"async\" style=\"display:none\"\n src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==\"\n onload=\"(function(el){\n // Capture the shadow root during SSR hydration so the client-side\n // useShadowRoot hook can find it.\n const root = el.getRootNode();\n globalThis.__remote_components_shadowroot_${keySuffix}=root;\n el.parentElement.remove();\n })(this)\"\n />`,\n }}\n />\n ) : null}\n {resetStyle}\n {linksToRender}\n {children}\n </template>\n ) : null}\n {shadowRoot && remoteComponent\n ? createPortal(\n <>\n <template id={`${name}_start`} />\n {resetStyle}\n {linksToRender}\n {remoteComponent}\n <template id={`${name}_end`} ref={endTemplateRef} />\n </>,\n shadowRoot,\n )\n : null}\n </div>\n </>\n );\n }\n htmlRef.current = null;\n\n // render start/end markers for the remote component\n return (\n <>\n <template id={`${name}_start`} />\n {metadataJson}\n {componentToRender}\n <template id={`${name}_end`} ref={endTemplateRef} />\n </>\n );\n}\n\nexport type {\n HookOptions,\n OnRequestHook,\n OnResponseHook,\n} from '#internal/host/shared/fetch-interceptors';\nexport type { RemoteNavigateEvent } from '#internal/host/shared/navigate-event';\nexport { useRemoteNavigate } from './hooks/use-remote-navigate';\n","// extracted from Next.js source at https://github.com/vercel/next.js/blob/canary/packages/next/src/client/set-attributes-from-props.ts\n\nconst DOMAttributeNames: Record<string, string> = {\n acceptCharset: 'accept-charset',\n className: 'class',\n htmlFor: 'for',\n httpEquiv: 'http-equiv',\n noModule: 'noModule',\n};\n\nconst ignoreProps = [\n 'onLoad',\n 'onReady',\n 'dangerouslySetInnerHTML',\n 'children',\n 'onError',\n 'strategy',\n 'stylesheets',\n];\n\nfunction isBooleanScriptAttribute(\n attr: string,\n): attr is 'async' | 'defer' | 'noModule' {\n return ['async', 'defer', 'noModule'].includes(attr);\n}\n\nexport function setAttributesFromProps(el: HTMLElement, props: object) {\n for (const [p, value] of Object.entries(props)) {\n if (!Object.hasOwn(props, p)) continue;\n if (ignoreProps.includes(p)) continue;\n\n // we don't render undefined props to the DOM\n if (value === undefined) {\n continue;\n }\n\n const attr = DOMAttributeNames[p] || p.toLowerCase();\n\n if (el.tagName === 'SCRIPT' && isBooleanScriptAttribute(attr)) {\n // Correctly assign boolean script attributes\n // https://github.com/vercel/next.js/pull/20748\n (el as HTMLScriptElement)[attr] = Boolean(value);\n } else {\n el.setAttribute(attr, String(value));\n }\n\n // Remove falsy non-zero boolean attributes so they are correctly interpreted\n // (e.g. if we set them to false, this coerces to the string \"false\", which the browser interprets as true)\n if (\n value === false ||\n (el.tagName === 'SCRIPT' &&\n isBooleanScriptAttribute(attr) &&\n (!value || value === 'false'))\n ) {\n // Call setAttribute before, as we need to set and unset the attribute to override force async:\n // https://html.spec.whatwg.org/multipage/scripting.html#script-force-async\n el.setAttribute(attr, '');\n el.removeAttribute(attr);\n }\n }\n}\n","import { useMemo } from 'react';\nimport { useRemoteComponentsContext } from '#internal/host/react/context';\nimport { bindResolveClientUrl } from '#internal/runtime/url/default-resolve-client-url';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\n\nexport function useResolveClientUrl(\n prop: ResolveClientUrl | undefined,\n urlHref: string,\n) {\n const { resolveClientUrl: contextValue } = useRemoteComponentsContext();\n const raw = prop ?? contextValue;\n return useMemo(() => bindResolveClientUrl(raw, urlHref), [raw, urlHref]);\n}\n","import { useLayoutEffect, useRef, useState } from 'react';\nimport { getNamespace } from '#internal/runtime/namespace';\n\ninterface UseShadowRootOptions {\n /** Whether CSS isolation is enabled */\n isolate: boolean | undefined;\n /** Shadow DOM mode */\n mode: 'open' | 'closed';\n /** Unique key suffix for identifying this shadow root */\n keySuffix: string;\n}\n\ninterface UseShadowRootResult {\n /** The shadow root element, or null if not isolated */\n shadowRoot: ShadowRoot | null;\n /** Ref to attach to the shadow host container element */\n shadowRootContainerRef: React.RefObject<HTMLDivElement | null>;\n}\n\n/**\n * Manages shadow root lifecycle for CSS isolation.\n *\n * Handles:\n * - Initial shadow root discovery from SSR or declarative shadow DOM\n * - Creating shadow root as fallback for browsers without declarative shadow DOM support\n * - Cleanup when isolation is disabled\n * - Re-attachment when isolation is re-enabled\n */\nexport function useShadowRoot({\n isolate,\n mode,\n keySuffix,\n}: UseShadowRootOptions): UseShadowRootResult {\n const shadowRootContainerRef = useRef<HTMLDivElement | null>(null);\n\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(() => {\n const shadowRoots = getNamespace().shadowRoots;\n const ssrShadowRoot =\n typeof document !== 'undefined'\n ? (document.querySelector(\n `[data-remote-component-id=\"shadowroot_${keySuffix}\"]`,\n )?.shadowRoot ??\n shadowRoots[keySuffix] ??\n null)\n : null;\n // Clear the reference after reading it\n shadowRoots[keySuffix] = null;\n return ssrShadowRoot;\n });\n\n useLayoutEffect(() => {\n const shadowRoots = getNamespace().shadowRoots;\n if (\n isolate !== false &&\n typeof document !== 'undefined' &&\n (!shadowRoot || !shadowRoot.isConnected)\n ) {\n let shadowRootElement: ShadowRoot | null = null;\n const element = document.querySelector(\n `[data-remote-component-id=\"shadowroot_${keySuffix}\"]`,\n );\n shadowRootElement = shadowRoots[keySuffix] ?? element?.shadowRoot ?? null;\n\n if (!shadowRootElement && element) {\n // Create a shadow root if it doesn't exist.\n // This is a fallback for browsers that don't support declarative shadow DOM.\n try {\n shadowRootElement = element.attachShadow({ mode });\n shadowRoots[keySuffix] = shadowRootElement;\n } catch {\n // Do nothing if attachShadow fails because of existing shadow root\n }\n }\n\n if (shadowRootElement) {\n // Remove all nodes from the shadow root except links (preserves stylesheets)\n shadowRootElement.querySelectorAll('*:not(link)').forEach((node) => {\n node.remove();\n });\n setShadowRoot(shadowRootElement);\n }\n } else if (isolate === false && shadowRoot) {\n shadowRoots[keySuffix] = null;\n setShadowRoot(null);\n }\n }, [isolate, shadowRoot, mode, keySuffix]);\n\n return { shadowRoot, shadowRootContainerRef };\n}\n","import { DEFAULT_COMPONENT_NAME } from '#internal/runtime/constants';\n\n/**\n * Dummy URL used as a fallback base for URL parsing when no real base URL is available.\n * This is used during SSR or when location is not defined.\n */\nexport const DUMMY_FALLBACK = 'http://remote-components-dummy-fallback';\n\n/**\n * Extracts the relevant HTML content from a remote component response.\n *\n * Handles multiple remote component formats:\n * - Next.js Pages Router SSR wrapper (`div[id^=\"__REMOTE_COMPONENT\"]`)\n * - App Router remote components (`div[data-bundle][data-route]`)\n * - Next.js pages (`div#__next`)\n * - Web component format (`remote-component:not([src])`)\n *\n * @param html - Raw HTML string from the remote component response\n * @returns Extracted HTML content with links and scripts, or empty string if not found\n */\nexport function getRemoteComponentHtml(html: string): string {\n if (typeof document === 'undefined') return html;\n\n const parser = new DOMParser();\n const temp = parser.parseFromString(html, 'text/html');\n\n // Used by the Next.js Pages Router remote as a wrapper\n const ssrRemoteComponentContainer = temp.querySelector(\n 'div[id^=\"__REMOTE_COMPONENT\"]',\n );\n if (ssrRemoteComponentContainer) {\n return ssrRemoteComponentContainer.innerHTML;\n }\n\n // Remote component content from various sources\n const remoteComponentContainer = temp.querySelectorAll(\n `div[data-bundle][data-route][data-runtime][id^=\"${DEFAULT_COMPONENT_NAME}\"],div[data-bundle][data-route],div#__next,remote-component:not([src])`,\n );\n if (remoteComponentContainer.length > 0) {\n return `${Array.from(temp.querySelectorAll('link,script'))\n .map((link) => link.outerHTML)\n .join('')}${Array.from(remoteComponentContainer)\n .map((container) => container.outerHTML)\n .join('')}`;\n }\n\n return '';\n}\n","import { useEffect, useRef } from 'react';\nimport { onRemoteNavigate } from '#internal/host/navigation';\nimport type { RemoteNavigateEvent } from '#internal/host/shared/navigate-event';\n\n/**\n * Subscribe to remote component navigations. The callback is captured in a ref\n * so the listener is registered once — no `useCallback` or dep array needed.\n *\n * @example React Router\n * ```tsx\n * const navigate = useNavigate();\n * // Always replace — the polyfill already pushed/replaced the browser history entry.\n * useRemoteNavigate((e) => navigate(e.pathname + e.search, { replace: true }));\n * ```\n */\nexport function useRemoteNavigate(\n callback: (event: RemoteNavigateEvent) => void,\n): void {\n const callbackRef = useRef(callback);\n // Written during render (not in an effect) — the standard useCallbackRef\n // pattern. Safe under concurrent rendering: navigation events are user-driven\n // and can't fire mid-render.\n callbackRef.current = callback;\n useEffect(() => onRemoteNavigate((event) => callbackRef.current(event)), []);\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/host/shared/navigate-event.ts
|
|
2
|
+
var REMOTE_NAVIGATE_EVENT = "remote-components:navigate";
|
|
3
|
+
function parseRemoteNavigateDetail(detail) {
|
|
4
|
+
try {
|
|
5
|
+
const parsed = new URL(detail.url, window.location.origin);
|
|
6
|
+
return {
|
|
7
|
+
url: detail.url,
|
|
8
|
+
pathname: parsed.pathname,
|
|
9
|
+
search: parsed.search,
|
|
10
|
+
hash: parsed.hash,
|
|
11
|
+
type: detail.type
|
|
12
|
+
};
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return {
|
|
15
|
+
url: detail.url,
|
|
16
|
+
pathname: detail.url,
|
|
17
|
+
search: "",
|
|
18
|
+
hash: "",
|
|
19
|
+
type: detail.type
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
exports.REMOTE_NAVIGATE_EVENT = REMOTE_NAVIGATE_EVENT; exports.parseRemoteNavigateDetail = parseRemoteNavigateDetail;
|
|
28
|
+
//# sourceMappingURL=chunk-5KTAEO52.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/host/shared/navigate-event.ts"],"names":[],"mappings":";AAAO,IAAM,wBAAwB;AAqB9B,SAAS,0BACd,QACqB;AACrB,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,OAAO,KAAK,OAAO,SAAS,MAAM;AACzD,WAAO;AAAA,MACL,KAAK,OAAO;AAAA,MACZ,UAAU,OAAO;AAAA,MACjB,QAAQ,OAAO;AAAA,MACf,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,IACf;AAAA,EACF,QAAE;AACA,WAAO;AAAA,MACL,KAAK,OAAO;AAAA,MACZ,UAAU,OAAO;AAAA,MACjB,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAM,OAAO;AAAA,IACf;AAAA,EACF;AACF","sourcesContent":["export const REMOTE_NAVIGATE_EVENT = 'remote-components:navigate';\n\nexport interface RemoteNavigateDetail {\n url: string;\n type: 'push' | 'replace';\n}\n\n/** Parsed navigation request surfaced to `onRemoteNavigate` / `useRemoteNavigate` callbacks. */\nexport interface RemoteNavigateEvent {\n /** Raw value from the remote; may be absolute or relative. */\n url: string;\n pathname: string;\n /** Includes leading `?`, or `''` if none. */\n search: string;\n /** Includes leading `#`, or `''` if none. */\n hash: string;\n /** `'push'` / `'replace'` mirror the remote's history call. */\n type: 'push' | 'replace';\n}\n\n/** Handles both absolute URLs and relative paths; falls back to pathname-only on parse failure. */\nexport function parseRemoteNavigateDetail(\n detail: RemoteNavigateDetail,\n): RemoteNavigateEvent {\n try {\n const parsed = new URL(detail.url, window.location.origin);\n return {\n url: detail.url,\n pathname: parsed.pathname,\n search: parsed.search,\n hash: parsed.hash,\n type: detail.type,\n };\n } catch {\n return {\n url: detail.url,\n pathname: detail.url,\n search: '',\n hash: '',\n type: detail.type,\n };\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NEXT_BUNDLE_PATH_RE
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SAGYPGIQ.js";
|
|
4
4
|
import {
|
|
5
5
|
RemoteComponentsError,
|
|
6
6
|
failedProxiedAssetError,
|
|
@@ -20,7 +20,8 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
20
20
|
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
21
21
|
location.origin
|
|
22
22
|
).href;
|
|
23
|
-
const
|
|
23
|
+
const rawResolved = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
24
|
+
const resolvedSrc = new URL(rawResolved, location.href).href;
|
|
24
25
|
const alreadyLoaded = Array.from(
|
|
25
26
|
document.querySelectorAll("script[src]")
|
|
26
27
|
).some((s) => s.src === resolvedSrc);
|
|
@@ -54,4 +55,4 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
54
55
|
export {
|
|
55
56
|
loadScripts
|
|
56
57
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-AKOMV2UF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/loaders/script-loader.ts"],"sourcesContent":["import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { NEXT_BUNDLE_PATH_RE } from '#internal/runtime/patterns';\nimport { isProxiedUrl } from '#internal/runtime/url/protected-rc-fallback';\nimport {\n failedProxiedAssetError,\n RemoteComponentsError,\n} from '#internal/utils/error';\nimport { warnCrossOriginFetchError } from '#internal/utils/logger';\n\n/**\n * Loads external scripts for remote components\n */\nexport async function loadScripts(\n scripts: { src: string }[],\n resolveClientUrl?: InternalResolveClientUrl,\n): Promise<void> {\n await Promise.all(\n scripts.map((script) => {\n return new Promise<void>((resolve, reject) => {\n const newSrc = new URL(\n // remove the remote component bundle name identifier from the script src\n script.src.replace(NEXT_BUNDLE_PATH_RE, '/_next/'),\n location.origin,\n ).href;\n\n // resolveClientUrl may return a relative URL (e.g. the host-proxy\n // path \"/rc-fetch-protected-remote?url=...\"). Normalize to absolute\n // before comparing with s.src, which browsers always expose as\n // absolute, so the deduplication check works in deployed contexts.\n const rawResolved = resolveClientUrl?.(newSrc) ?? newSrc;\n const resolvedSrc = new URL(rawResolved, location.href).href;\n\n const alreadyLoaded = Array.from(\n document.querySelectorAll<HTMLScriptElement>('script[src]'),\n ).some((s) => s.src === resolvedSrc);\n if (alreadyLoaded) {\n resolve();\n return;\n }\n\n const newScript = document.createElement('script');\n newScript.onload = () => resolve();\n newScript.onerror = () => {\n const isProxied = isProxiedUrl(resolvedSrc);\n if (isProxied) {\n reject(failedProxiedAssetError('script', newSrc, resolvedSrc));\n } else {\n warnCrossOriginFetchError('ScriptLoader', newSrc);\n reject(\n new RemoteComponentsError(\n `Failed to load <script src=\"${newSrc}\"> for Remote Component. Check the URL is correct.`,\n ),\n );\n }\n };\n newScript.src = resolvedSrc;\n newScript.async = true;\n document.head.appendChild(newScript);\n });\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,eAAsB,YACpB,SACA,kBACe;AACf,QAAM,QAAQ;AAAA,IACZ,QAAQ,IAAI,CAAC,WAAW;AACtB,aAAO,IAAI,QAAc,CAAC,SAAS,WAAW;AAC5C,cAAM,SAAS,IAAI;AAAA;AAAA,UAEjB,OAAO,IAAI,QAAQ,qBAAqB,SAAS;AAAA,UACjD,SAAS;AAAA,QACX,EAAE;AAMF,cAAM,cAAc,mBAAmB,MAAM,KAAK;AAClD,cAAM,cAAc,IAAI,IAAI,aAAa,SAAS,IAAI,EAAE;AAExD,cAAM,gBAAgB,MAAM;AAAA,UAC1B,SAAS,iBAAoC,aAAa;AAAA,QAC5D,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,WAAW;AACnC,YAAI,eAAe;AACjB,kBAAQ;AACR;AAAA,QACF;AAEA,cAAM,YAAY,SAAS,cAAc,QAAQ;AACjD,kBAAU,SAAS,MAAM,QAAQ;AACjC,kBAAU,UAAU,MAAM;AACxB,gBAAM,YAAY,aAAa,WAAW;AAC1C,cAAI,WAAW;AACb,mBAAO,wBAAwB,UAAU,QAAQ,WAAW,CAAC;AAAA,UAC/D,OAAO;AACL,sCAA0B,gBAAgB,MAAM;AAChD;AAAA,cACE,IAAI;AAAA,gBACF,+BAA+B;AAAA,cACjC;AAAA,YACF;AAAA,UACF;AAAA,QACF;AACA,kBAAU,MAAM;AAChB,kBAAU,QAAQ;AAClB,iBAAS,KAAK,YAAY,SAAS;AAAA,MACrC,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadScripts
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AKOMV2UF.js";
|
|
4
4
|
import {
|
|
5
5
|
initializeSharedModules,
|
|
6
6
|
setupRemoteScope
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MTMDXJLM.js";
|
|
8
8
|
import {
|
|
9
9
|
applySharedModules,
|
|
10
10
|
nextClientPagesLoader
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MKO52FRO.js";
|
|
12
12
|
import {
|
|
13
13
|
loadStaticRemoteComponent
|
|
14
14
|
} from "./chunk-LQ7VQ74E.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
buildWebpackResolve,
|
|
24
24
|
collapseDoubleSlashes,
|
|
25
25
|
escapeString
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-SAGYPGIQ.js";
|
|
27
27
|
import {
|
|
28
28
|
RemoteComponentsError,
|
|
29
29
|
logDebug,
|
|
@@ -700,4 +700,4 @@ export {
|
|
|
700
700
|
resolveNameFromSrc,
|
|
701
701
|
bindResolveClientUrl
|
|
702
702
|
};
|
|
703
|
-
//# sourceMappingURL=chunk-
|
|
703
|
+
//# sourceMappingURL=chunk-CC3WOSDO.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkRLI4YTBJcjs = require('./chunk-RLI4YTBJ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkZ2SLBFQLcjs = require('./chunk-Z2SLBFQL.cjs');
|
|
@@ -22,7 +22,7 @@ function applySharedModules(bundle, resolve) {
|
|
|
22
22
|
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
23
23
|
);
|
|
24
24
|
const self = globalThis;
|
|
25
|
-
const scope =
|
|
25
|
+
const scope = _chunkRLI4YTBJcjs.getScope.call(void 0, bundle);
|
|
26
26
|
const webpackBundle = _nullishCoalesce(_optionalChain([scope, 'optionalAccess', _ => _.webpackRequire]), () => ( _optionalChain([self, 'access', _2 => _2.__remote_webpack_require__, 'optionalAccess', _3 => _3[bundle]])));
|
|
27
27
|
if (webpackBundle) {
|
|
28
28
|
const modulePaths = Object.keys(
|
|
@@ -199,4 +199,4 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
199
199
|
|
|
200
200
|
|
|
201
201
|
exports.applySharedModules = applySharedModules; exports.nextClientPagesLoader = nextClientPagesLoader;
|
|
202
|
-
//# sourceMappingURL=chunk-
|
|
202
|
+
//# sourceMappingURL=chunk-JJTCFQHE.cjs.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await 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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk42TVDI3Gcjs = require('./chunk-42TVDI3G.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkMQ2BBSL4cjs = require('./chunk-MQ2BBSL4.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkJJTCFQHEcjs = require('./chunk-JJTCFQHE.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkTZT7DLO5cjs = require('./chunk-TZT7DLO5.cjs');
|
|
@@ -23,7 +23,7 @@ var _chunkTZT7DLO5cjs = require('./chunk-TZT7DLO5.cjs');
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunkRLI4YTBJcjs = require('./chunk-RLI4YTBJ.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
@@ -285,12 +285,12 @@ function toComponentType(value) {
|
|
|
285
285
|
return value && isComponentType(value) ? value : "unknown";
|
|
286
286
|
}
|
|
287
287
|
function buildMetadata(attrs, url) {
|
|
288
|
-
const id = attrs.id ||
|
|
289
|
-
const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION ||
|
|
288
|
+
const id = attrs.id || _chunkRLI4YTBJcjs.DEFAULT_COMPONENT_NAME;
|
|
289
|
+
const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION || _chunkRLI4YTBJcjs.DEFAULT_BUNDLE_NAME;
|
|
290
290
|
return {
|
|
291
291
|
name: attrs.name || id.replace(/_ssr$/, ""),
|
|
292
292
|
bundle,
|
|
293
|
-
route: attrs.route || url.pathname ||
|
|
293
|
+
route: attrs.route || url.pathname || _chunkRLI4YTBJcjs.DEFAULT_ROUTE,
|
|
294
294
|
runtime: toRuntime(attrs.runtime),
|
|
295
295
|
id,
|
|
296
296
|
type: toComponentType(attrs.type)
|
|
@@ -329,7 +329,7 @@ function extractRemoteShared(doc, name, nextData) {
|
|
|
329
329
|
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
330
330
|
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
331
331
|
throw new (0, _chunkRUWR74XQcjs.RemoteComponentsError)(
|
|
332
|
-
`Remote Component not found on ${url}.${name !==
|
|
332
|
+
`Remote Component not found on ${url}.${name !== _chunkRLI4YTBJcjs.DEFAULT_COMPONENT_NAME ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
|
|
333
333
|
);
|
|
334
334
|
}
|
|
335
335
|
}
|
|
@@ -360,7 +360,7 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
360
360
|
name: resolvedName,
|
|
361
361
|
bundle: _optionalChain([component, 'optionalAccess', _34 => _34.getAttribute, 'call', _35 => _35(DATA_BUNDLE)]) || _optionalChain([nextData, 'optionalAccess', _36 => _36.props, 'access', _37 => _37.__REMOTE_COMPONENT__, 'optionalAccess', _38 => _38.bundle]),
|
|
362
362
|
route: _nullishCoalesce(_optionalChain([component, 'optionalAccess', _39 => _39.getAttribute, 'call', _40 => _40(DATA_ROUTE)]), () => ( _optionalChain([nextData, 'optionalAccess', _41 => _41.page]))),
|
|
363
|
-
runtime: _nullishCoalesce(_nullishCoalesce(_optionalChain([component, 'optionalAccess', _42 => _42.getAttribute, 'call', _43 => _43(DATA_RUNTIME)]), () => ( _optionalChain([nextData, 'optionalAccess', _44 => _44.props, 'access', _45 => _45.__REMOTE_COMPONENT__, 'optionalAccess', _46 => _46.runtime]))), () => (
|
|
363
|
+
runtime: _nullishCoalesce(_nullishCoalesce(_optionalChain([component, 'optionalAccess', _42 => _42.getAttribute, 'call', _43 => _43(DATA_RUNTIME)]), () => ( _optionalChain([nextData, 'optionalAccess', _44 => _44.props, 'access', _45 => _45.__REMOTE_COMPONENT__, 'optionalAccess', _46 => _46.runtime]))), () => ( _chunkRLI4YTBJcjs.RUNTIME_SCRIPT)),
|
|
364
364
|
id: _optionalChain([component, 'optionalAccess', _47 => _47.getAttribute, 'call', _48 => _48("id")]),
|
|
365
365
|
type: _optionalChain([component, 'optionalAccess', _49 => _49.getAttribute, 'call', _50 => _50(DATA_TYPE)])
|
|
366
366
|
},
|
|
@@ -430,7 +430,7 @@ async function loadRemoteComponent({
|
|
|
430
430
|
self.__DISABLE_WEBPACK_EXEC__ = {};
|
|
431
431
|
}
|
|
432
432
|
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
433
|
-
await
|
|
433
|
+
await _chunk42TVDI3Gcjs.loadScripts.call(void 0, scripts, resolveClientUrl);
|
|
434
434
|
}
|
|
435
435
|
const hostShared = await shared;
|
|
436
436
|
_chunkRUWR74XQcjs.logDebug.call(void 0,
|
|
@@ -445,7 +445,7 @@ async function loadRemoteComponent({
|
|
|
445
445
|
"ComponentLoader",
|
|
446
446
|
`Remote shared modules requested: ${JSON.stringify(remoteShared)}`
|
|
447
447
|
);
|
|
448
|
-
const scope = await
|
|
448
|
+
const scope = await _chunkMQ2BBSL4cjs.setupRemoteScope.call(void 0,
|
|
449
449
|
runtime,
|
|
450
450
|
scripts,
|
|
451
451
|
url,
|
|
@@ -453,14 +453,14 @@ async function loadRemoteComponent({
|
|
|
453
453
|
resolveClientUrl
|
|
454
454
|
);
|
|
455
455
|
if (runtime === "turbopack") {
|
|
456
|
-
await
|
|
456
|
+
await _chunkMQ2BBSL4cjs.initializeSharedModules.call(void 0,
|
|
457
457
|
scope,
|
|
458
|
-
|
|
458
|
+
_chunkRLI4YTBJcjs.buildCoreShared.call(void 0, hostShared),
|
|
459
459
|
remoteShared
|
|
460
460
|
);
|
|
461
461
|
}
|
|
462
462
|
if (bundle) {
|
|
463
|
-
const resolve = await
|
|
463
|
+
const resolve = await _chunkRLI4YTBJcjs.buildWebpackResolve.call(void 0,
|
|
464
464
|
hostShared,
|
|
465
465
|
remoteShared,
|
|
466
466
|
bundle,
|
|
@@ -473,7 +473,7 @@ async function loadRemoteComponent({
|
|
|
473
473
|
},
|
|
474
474
|
"ComponentLoader"
|
|
475
475
|
);
|
|
476
|
-
|
|
476
|
+
_chunkJJTCFQHEcjs.applySharedModules.call(void 0, bundle, resolve);
|
|
477
477
|
} else {
|
|
478
478
|
_chunkRUWR74XQcjs.logWarn.call(void 0,
|
|
479
479
|
"ComponentLoader",
|
|
@@ -514,7 +514,7 @@ async function loadRSCComponent(rscName, data) {
|
|
|
514
514
|
return { component };
|
|
515
515
|
}
|
|
516
516
|
function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
517
|
-
const { Component, App } =
|
|
517
|
+
const { Component, App } = _chunkJJTCFQHEcjs.nextClientPagesLoader.call(void 0, bundle, route, container);
|
|
518
518
|
if (!Component) {
|
|
519
519
|
throw new (0, _chunkRUWR74XQcjs.RemoteComponentsError)(
|
|
520
520
|
`Remote Component "${name}" is trying to load the component for route "${route}" but it is not available.`
|
|
@@ -571,12 +571,12 @@ async function loadPrepared(input) {
|
|
|
571
571
|
function buildScriptDescriptors(scripts, url) {
|
|
572
572
|
return scripts.map((script) => {
|
|
573
573
|
const scriptSrc = script.getAttribute("data-src") || script.getAttribute("src") || script.src;
|
|
574
|
-
const { prefix, id: path } = _nullishCoalesce(_optionalChain([
|
|
574
|
+
const { prefix, id: path } = _nullishCoalesce(_optionalChain([_chunkRLI4YTBJcjs.REMOTE_COMPONENT_REGEX, 'access', _51 => _51.exec, 'call', _52 => _52(scriptSrc), 'optionalAccess', _53 => _53.groups]), () => ( {
|
|
575
575
|
prefix: void 0,
|
|
576
576
|
id: scriptSrc
|
|
577
577
|
}));
|
|
578
578
|
return {
|
|
579
|
-
src: new URL(
|
|
579
|
+
src: new URL(_chunkRLI4YTBJcjs.collapseDoubleSlashes.call(void 0, `${_nullishCoalesce(prefix, () => ( ""))}${path}`), url).href
|
|
580
580
|
};
|
|
581
581
|
});
|
|
582
582
|
}
|
|
@@ -609,7 +609,7 @@ async function loadDynamicPath(input) {
|
|
|
609
609
|
resolveClientUrl,
|
|
610
610
|
container
|
|
611
611
|
} = input;
|
|
612
|
-
const rscName = _nullishCoalesce(input.rscName, () => ( (parsed.rsc ? `__remote_component_rsc_${
|
|
612
|
+
const rscName = _nullishCoalesce(input.rscName, () => ( (parsed.rsc ? `__remote_component_rsc_${_chunkRLI4YTBJcjs.escapeString.call(void 0, url.href)}_${_chunkRLI4YTBJcjs.escapeString.call(void 0, parsed.name)}` : void 0)));
|
|
613
613
|
const rscData = parsed.rsc ? (parsed.rsc.textContent || "").split("\n").filter(Boolean) : [];
|
|
614
614
|
const result = await loadRemoteComponent({
|
|
615
615
|
url,
|
|
@@ -621,7 +621,7 @@ async function loadDynamicPath(input) {
|
|
|
621
621
|
data: rscData,
|
|
622
622
|
nextData: parsed.nextData,
|
|
623
623
|
scripts: scriptDescriptors,
|
|
624
|
-
shared:
|
|
624
|
+
shared: _chunkRLI4YTBJcjs.buildHostShared.call(void 0, shared, resolveClientUrl),
|
|
625
625
|
remoteShared: parsed.remoteShared,
|
|
626
626
|
container,
|
|
627
627
|
resolveClientUrl
|
|
@@ -700,4 +700,4 @@ function bindResolveClientUrl(prop, remoteSrc) {
|
|
|
700
700
|
|
|
701
701
|
|
|
702
702
|
exports.fetchWithHooks = fetchWithHooks; exports.getClientOrServerUrl = getClientOrServerUrl; exports.makeReactEmitter = makeReactEmitter; exports.makeEventEmitter = makeEventEmitter; exports.createRSCStream = createRSCStream; exports.preparePipeline = preparePipeline; exports.loadPrepared = loadPrepared; exports.createHostState = createHostState; exports.resolveNameFromSrc = resolveNameFromSrc; exports.bindResolveClientUrl = bindResolveClientUrl;
|
|
703
|
-
//# sourceMappingURL=chunk-
|
|
703
|
+
//# sourceMappingURL=chunk-KVQI55BZ.cjs.map
|