remote-components 0.0.50 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{component-loader-1838f572.d.ts → component-loader-76eb1b8b.d.ts} +3 -1
- package/dist/html/host.cjs +486 -242
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.d.ts +2 -0
- package/dist/html/host.js +485 -242
- package/dist/html/host.js.map +1 -1
- package/dist/html/remote.cjs +123 -21
- package/dist/html/remote.cjs.map +1 -1
- package/dist/html/remote.js +123 -21
- package/dist/html/remote.js.map +1 -1
- package/dist/internal/next/host/app-router-client.cjs +12 -3
- package/dist/internal/next/host/app-router-client.cjs.map +1 -1
- package/dist/internal/next/host/app-router-client.d.ts +11 -2
- package/dist/internal/next/host/app-router-client.js +12 -3
- package/dist/internal/next/host/app-router-client.js.map +1 -1
- package/dist/internal/react/context.cjs +43 -0
- package/dist/internal/react/context.cjs.map +1 -0
- package/dist/internal/react/context.d.ts +20 -0
- package/dist/internal/react/context.js +18 -0
- package/dist/internal/react/context.js.map +1 -0
- package/dist/internal/react/hooks/use-resolve-client-url.cjs +39 -0
- package/dist/internal/react/hooks/use-resolve-client-url.cjs.map +1 -0
- package/dist/internal/react/hooks/use-resolve-client-url.d.ts +5 -0
- package/dist/internal/react/hooks/use-resolve-client-url.js +15 -0
- package/dist/internal/react/hooks/use-resolve-client-url.js.map +1 -0
- package/dist/internal/shared/client/apply-origin.cjs +10 -5
- package/dist/internal/shared/client/apply-origin.cjs.map +1 -1
- package/dist/internal/shared/client/apply-origin.d.ts +3 -1
- package/dist/internal/shared/client/apply-origin.js +10 -5
- package/dist/internal/shared/client/apply-origin.js.map +1 -1
- package/dist/internal/shared/client/default-resolve-client-url.cjs +32 -0
- package/dist/internal/shared/client/default-resolve-client-url.cjs.map +1 -0
- package/dist/internal/shared/client/default-resolve-client-url.d.ts +5 -0
- package/dist/internal/shared/client/default-resolve-client-url.js +10 -0
- package/dist/internal/shared/client/default-resolve-client-url.js.map +1 -0
- package/dist/internal/shared/client/protected-rc-fallback.cjs +41 -0
- package/dist/internal/shared/client/protected-rc-fallback.cjs.map +1 -0
- package/dist/internal/shared/client/protected-rc-fallback.d.ts +7 -0
- package/dist/internal/shared/client/protected-rc-fallback.js +16 -0
- package/dist/internal/shared/client/protected-rc-fallback.js.map +1 -0
- package/dist/internal/shared/client/proxy-through-host.cjs +51 -0
- package/dist/internal/shared/client/proxy-through-host.cjs.map +1 -0
- package/dist/internal/shared/client/proxy-through-host.d.ts +57 -0
- package/dist/internal/shared/client/proxy-through-host.js +26 -0
- package/dist/internal/shared/client/proxy-through-host.js.map +1 -0
- package/dist/internal/shared/client/remote-component.cjs +208 -134
- package/dist/internal/shared/client/remote-component.cjs.map +1 -1
- package/dist/internal/shared/client/remote-component.d.ts +7 -5
- package/dist/internal/shared/client/remote-component.js +207 -134
- package/dist/internal/shared/client/remote-component.js.map +1 -1
- package/dist/internal/shared/constants.cjs +32 -0
- package/dist/internal/shared/constants.cjs.map +1 -0
- package/dist/internal/shared/constants.d.ts +4 -0
- package/dist/internal/shared/constants.js +7 -0
- package/dist/internal/shared/constants.js.map +1 -0
- package/dist/internal/shared/error.cjs +70 -0
- package/dist/internal/shared/error.cjs.map +1 -1
- package/dist/internal/shared/error.d.ts +3 -1
- package/dist/internal/shared/error.js +71 -0
- package/dist/internal/shared/error.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.cjs +1 -2
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.js +1 -2
- package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs +7 -2
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.js +7 -2
- package/dist/internal/shared/ssr/fetch-with-hooks.js.map +1 -1
- package/dist/internal/shared/utils/logger.cjs +26 -10
- package/dist/internal/shared/utils/logger.cjs.map +1 -1
- package/dist/internal/shared/utils/logger.d.ts +7 -2
- package/dist/internal/shared/utils/logger.js +24 -9
- package/dist/internal/shared/utils/logger.js.map +1 -1
- package/dist/next/config.cjs +2 -2
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +2 -2
- package/dist/next/config.js.map +1 -1
- package/dist/next/host/client/index.cjs +363 -207
- package/dist/next/host/client/index.cjs.map +1 -1
- package/dist/next/host/client/index.d.ts +3 -1
- package/dist/next/host/client/index.js +336 -181
- package/dist/next/host/client/index.js.map +1 -1
- package/dist/next/host/pages-router-client.cjs +15 -2
- package/dist/next/host/pages-router-client.cjs.map +1 -1
- package/dist/next/host/pages-router-client.d.ts +12 -1
- package/dist/next/host/pages-router-client.js +15 -2
- package/dist/next/host/pages-router-client.js.map +1 -1
- package/dist/next/host/pages-router-server.cjs +3 -2
- package/dist/next/host/pages-router-server.cjs.map +1 -1
- package/dist/next/host/pages-router-server.d.ts +16 -0
- package/dist/next/host/pages-router-server.js +3 -2
- package/dist/next/host/pages-router-server.js.map +1 -1
- package/dist/next/proxy.cjs +66 -27
- package/dist/next/proxy.cjs.map +1 -1
- package/dist/next/proxy.d.ts +0 -1
- package/dist/next/proxy.js +66 -27
- package/dist/next/proxy.js.map +1 -1
- package/dist/proxy-through-host-a676a522.d.ts +52 -0
- package/dist/react/index.cjs +381 -206
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +28 -4
- package/dist/react/index.js +354 -181
- package/dist/react/index.js.map +1 -1
- package/dist/shared/host/proxy.cjs +52 -23
- package/dist/shared/host/proxy.cjs.map +1 -1
- package/dist/shared/host/proxy.d.ts +0 -3
- package/dist/shared/host/proxy.js +55 -22
- package/dist/shared/host/proxy.js.map +1 -1
- package/dist/shared/remote/proxy.cjs +9 -1
- package/dist/shared/remote/proxy.cjs.map +1 -1
- package/dist/shared/remote/proxy.d.ts +7 -1
- package/dist/shared/remote/proxy.js +8 -1
- package/dist/shared/remote/proxy.js.map +1 -1
- package/package.json +1 -1
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs +0 -62
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs.map +0 -1
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.d.ts +0 -14
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js +0 -37
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js.map +0 -1
package/dist/html/host.cjs
CHANGED
|
@@ -30,6 +30,51 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
+
// src/shared/constants.ts
|
|
34
|
+
var RC_PROTECTED_REMOTE_FETCH_PATHNAME, CORS_DOCS_URL;
|
|
35
|
+
var init_constants = __esm({
|
|
36
|
+
"src/shared/constants.ts"() {
|
|
37
|
+
"use strict";
|
|
38
|
+
RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
39
|
+
CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// src/shared/client/protected-rc-fallback.ts
|
|
44
|
+
function generateProtectedRcFallbackSrc(url) {
|
|
45
|
+
return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
|
|
46
|
+
}
|
|
47
|
+
function isProxiedUrl(url) {
|
|
48
|
+
try {
|
|
49
|
+
return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
var init_protected_rc_fallback = __esm({
|
|
55
|
+
"src/shared/client/protected-rc-fallback.ts"() {
|
|
56
|
+
"use strict";
|
|
57
|
+
init_constants();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// src/shared/utils/abort.ts
|
|
62
|
+
function isAbortError(error) {
|
|
63
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
|
|
67
|
+
const e = error;
|
|
68
|
+
return typeof e.code === "number" || e.constructor?.name === "DOMException";
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
var init_abort = __esm({
|
|
73
|
+
"src/shared/utils/abort.ts"() {
|
|
74
|
+
"use strict";
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
33
78
|
// src/shared/error.ts
|
|
34
79
|
function multipleRemoteComponentsError(url) {
|
|
35
80
|
return new RemoteComponentsError(
|
|
@@ -42,10 +87,76 @@ function failedToFetchRemoteComponentError(url, { status, statusText }, help = "
|
|
|
42
87
|
{ cause: new Error(`${status} ${statusText}`) }
|
|
43
88
|
);
|
|
44
89
|
}
|
|
90
|
+
async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
|
|
91
|
+
const isProxied = isProxiedUrl(resolvedUrl.href);
|
|
92
|
+
if (isProxied && res) {
|
|
93
|
+
const body = await res.text().catch(() => "");
|
|
94
|
+
return failedProxyFetchError(
|
|
95
|
+
originalUrl,
|
|
96
|
+
resolvedUrl.href,
|
|
97
|
+
res.status,
|
|
98
|
+
body
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const fallback = failedToFetchRemoteComponentError(
|
|
102
|
+
originalUrl,
|
|
103
|
+
res ?? { status: 0, statusText: "No Response" }
|
|
104
|
+
);
|
|
105
|
+
if (!res)
|
|
106
|
+
return fallback;
|
|
107
|
+
try {
|
|
108
|
+
const body = await res.text();
|
|
109
|
+
const parser = new DOMParser();
|
|
110
|
+
const doc = parser.parseFromString(body, "text/html");
|
|
111
|
+
const errorTemplate = doc.querySelector(
|
|
112
|
+
"template[data-next-error-message]"
|
|
113
|
+
);
|
|
114
|
+
const errorMessage = errorTemplate?.getAttribute("data-next-error-message");
|
|
115
|
+
if (errorMessage) {
|
|
116
|
+
const error = new RemoteComponentsError(errorMessage);
|
|
117
|
+
const errorStack = errorTemplate?.getAttribute("data-next-error-stack");
|
|
118
|
+
if (errorStack) {
|
|
119
|
+
error.stack = errorStack;
|
|
120
|
+
}
|
|
121
|
+
return error;
|
|
122
|
+
}
|
|
123
|
+
} catch (parseError) {
|
|
124
|
+
if (isAbortError(parseError))
|
|
125
|
+
throw parseError;
|
|
126
|
+
}
|
|
127
|
+
return fallback;
|
|
128
|
+
}
|
|
129
|
+
function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
130
|
+
if (status === 404) {
|
|
131
|
+
return new RemoteComponentsError(
|
|
132
|
+
`Could not proxy the request to "${originalUrl}" \u2014 the proxy endpoint "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" returned 404.
|
|
133
|
+
|
|
134
|
+
The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
135
|
+
|
|
136
|
+
Proxying requires two pieces:
|
|
137
|
+
1. resolveClientUrl={proxyClientRequestsThroughHost} on <RemoteComponent>
|
|
138
|
+
2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
139
|
+
|
|
140
|
+
Docs: ${CORS_DOCS_URL}`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
if (status === 403) {
|
|
144
|
+
const detail = responseBody ? ` ${responseBody}` : "";
|
|
145
|
+
return new RemoteComponentsError(
|
|
146
|
+
`Proxied request to "${proxyUrl}" was forbidden.${detail} See: ${CORS_DOCS_URL}`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
return new RemoteComponentsError(
|
|
150
|
+
`Proxied request for "${originalUrl}" via "${proxyUrl}" failed with status ${status}. See: ${CORS_DOCS_URL}`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
45
153
|
var RemoteComponentsError;
|
|
46
154
|
var init_error = __esm({
|
|
47
155
|
"src/shared/error.ts"() {
|
|
48
156
|
"use strict";
|
|
157
|
+
init_protected_rc_fallback();
|
|
158
|
+
init_constants();
|
|
159
|
+
init_abort();
|
|
49
160
|
RemoteComponentsError = class extends Error {
|
|
50
161
|
code = "REMOTE_COMPONENTS_ERROR";
|
|
51
162
|
constructor(message, options) {
|
|
@@ -62,9 +173,6 @@ function logDebug(location2, message) {
|
|
|
62
173
|
console.debug(`[${PREFIX}:${location2}]: ${message}`);
|
|
63
174
|
}
|
|
64
175
|
}
|
|
65
|
-
function logInfo(location2, message) {
|
|
66
|
-
console.info(`[${PREFIX}:${location2}]: ${message}`);
|
|
67
|
-
}
|
|
68
176
|
function logWarn(location2, message) {
|
|
69
177
|
console.warn(`[${PREFIX}:${location2}]: ${message}`);
|
|
70
178
|
}
|
|
@@ -75,10 +183,24 @@ function logError(location2, message, cause) {
|
|
|
75
183
|
})
|
|
76
184
|
);
|
|
77
185
|
}
|
|
186
|
+
function warnCrossOriginFetchError(logLocation, url) {
|
|
187
|
+
try {
|
|
188
|
+
const parsed = typeof url === "string" ? new URL(url) : url;
|
|
189
|
+
if (typeof location === "undefined" || parsed.origin === location.origin) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
logWarn(
|
|
193
|
+
logLocation,
|
|
194
|
+
`Failed to fetch cross-origin resource "${parsed.href}". If this is a protected deployment, ensure withRemoteComponentsHost middleware is configured in your host and that the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
|
|
195
|
+
);
|
|
196
|
+
} catch {
|
|
197
|
+
}
|
|
198
|
+
}
|
|
78
199
|
var PREFIX, DEBUG;
|
|
79
200
|
var init_logger = __esm({
|
|
80
201
|
"src/shared/utils/logger.ts"() {
|
|
81
202
|
"use strict";
|
|
203
|
+
init_constants();
|
|
82
204
|
init_error();
|
|
83
205
|
PREFIX = "remote-components";
|
|
84
206
|
DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
@@ -270,60 +392,60 @@ var init_shared_modules = __esm({
|
|
|
270
392
|
}
|
|
271
393
|
});
|
|
272
394
|
|
|
273
|
-
// src/shared/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
|
|
279
|
-
const e = error;
|
|
280
|
-
return typeof e.code === "number" || e.constructor?.name === "DOMException";
|
|
281
|
-
}
|
|
282
|
-
return false;
|
|
283
|
-
}
|
|
284
|
-
var init_abort = __esm({
|
|
285
|
-
"src/shared/utils/abort.ts"() {
|
|
395
|
+
// src/shared/client/webpack-patterns.ts
|
|
396
|
+
var NEXT_BUNDLE_PATH_RE;
|
|
397
|
+
var init_webpack_patterns = __esm({
|
|
398
|
+
"src/shared/client/webpack-patterns.ts"() {
|
|
286
399
|
"use strict";
|
|
400
|
+
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
287
401
|
}
|
|
288
402
|
});
|
|
289
403
|
|
|
290
|
-
// src/shared/
|
|
291
|
-
async function
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
"
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
404
|
+
// src/shared/client/script-loader.ts
|
|
405
|
+
async function loadScripts(scripts, resolveClientUrl) {
|
|
406
|
+
await Promise.all(
|
|
407
|
+
scripts.map((script) => {
|
|
408
|
+
return new Promise((resolve, reject) => {
|
|
409
|
+
const newSrc = new URL(
|
|
410
|
+
// remove the remote component bundle name identifier from the script src
|
|
411
|
+
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
412
|
+
location.origin
|
|
413
|
+
).href;
|
|
414
|
+
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
415
|
+
const newScript = document.createElement("script");
|
|
416
|
+
newScript.onload = () => resolve();
|
|
417
|
+
newScript.onerror = () => {
|
|
418
|
+
const isProxied = isProxiedUrl(resolvedSrc);
|
|
419
|
+
if (isProxied) {
|
|
420
|
+
reject(
|
|
421
|
+
new RemoteComponentsError(
|
|
422
|
+
`Failed to load script "${newSrc}" via proxy "${resolvedSrc}". Ensure withRemoteComponentsHost middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
|
|
423
|
+
)
|
|
424
|
+
);
|
|
425
|
+
} else {
|
|
426
|
+
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
427
|
+
reject(
|
|
428
|
+
new RemoteComponentsError(
|
|
429
|
+
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
430
|
+
)
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
newScript.src = resolvedSrc;
|
|
435
|
+
newScript.async = true;
|
|
436
|
+
document.head.appendChild(newScript);
|
|
437
|
+
});
|
|
438
|
+
})
|
|
439
|
+
);
|
|
319
440
|
}
|
|
320
|
-
var
|
|
321
|
-
|
|
322
|
-
"src/shared/ssr/fetch-with-protected-rc-fallback.ts"() {
|
|
441
|
+
var init_script_loader = __esm({
|
|
442
|
+
"src/shared/client/script-loader.ts"() {
|
|
323
443
|
"use strict";
|
|
324
|
-
|
|
444
|
+
init_constants();
|
|
445
|
+
init_error();
|
|
325
446
|
init_logger();
|
|
326
|
-
|
|
447
|
+
init_protected_rc_fallback();
|
|
448
|
+
init_webpack_patterns();
|
|
327
449
|
}
|
|
328
450
|
});
|
|
329
451
|
|
|
@@ -353,7 +475,7 @@ var init_const = __esm({
|
|
|
353
475
|
});
|
|
354
476
|
|
|
355
477
|
// src/shared/client/turbopack-patterns.ts
|
|
356
|
-
var REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_RESOLVE_RE, ASYNC_MODULE_ALL_RE,
|
|
478
|
+
var REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_RESOLVE_RE, ASYNC_MODULE_ALL_RE, TURBOPACK_GLOBAL_RE;
|
|
357
479
|
var init_turbopack_patterns = __esm({
|
|
358
480
|
"src/shared/client/turbopack-patterns.ts"() {
|
|
359
481
|
"use strict";
|
|
@@ -362,13 +484,12 @@ var init_turbopack_patterns = __esm({
|
|
|
362
484
|
ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
363
485
|
ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
364
486
|
ASYNC_MODULE_ALL_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<vCb>parentImport|t)=>Promise\.all\(\["[^"]+"\]\.map\((?<mapCb>chunk|t)=>\k<ctx>\.l\(\k<mapCb>\)\)\)\.then\(\(\)=>\k<vCb>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
365
|
-
NUMERIC_MODULE_ID_RE = /^[0-9]+$/;
|
|
366
487
|
TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
367
488
|
}
|
|
368
489
|
});
|
|
369
490
|
|
|
370
491
|
// src/shared/client/chunk-loader.ts
|
|
371
|
-
function createChunkLoader(runtime) {
|
|
492
|
+
function createChunkLoader(runtime, resolveClientUrl) {
|
|
372
493
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
373
494
|
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
374
495
|
const self = globalThis;
|
|
@@ -408,9 +529,10 @@ function createChunkLoader(runtime) {
|
|
|
408
529
|
logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
|
|
409
530
|
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
410
531
|
}
|
|
411
|
-
|
|
532
|
+
const resolvedUrl = resolveClientUrl?.(url) ?? url;
|
|
533
|
+
logDebug("ChunkLoader", `Fetching chunk from: "${resolvedUrl}"`);
|
|
412
534
|
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
|
|
413
|
-
|
|
535
|
+
fetch(resolvedUrl).then((res) => res.text()).then((code) => {
|
|
414
536
|
const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
|
|
415
537
|
if (hasTurbopack) {
|
|
416
538
|
return handleTurbopackChunk(code, bundle ?? "", url);
|
|
@@ -423,7 +545,19 @@ function createChunkLoader(runtime) {
|
|
|
423
545
|
"ChunkLoader",
|
|
424
546
|
`First 500 chars of chunk: ${code.slice(0, 500)}`
|
|
425
547
|
);
|
|
426
|
-
}).then(resolve).catch(
|
|
548
|
+
}).then(resolve).catch((error) => {
|
|
549
|
+
const isProxied = isProxiedUrl(resolvedUrl);
|
|
550
|
+
if (isProxied) {
|
|
551
|
+
reject(
|
|
552
|
+
new RemoteComponentsError(
|
|
553
|
+
`Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHost middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
|
|
554
|
+
)
|
|
555
|
+
);
|
|
556
|
+
} else {
|
|
557
|
+
warnCrossOriginFetchError("ChunkLoader", url);
|
|
558
|
+
reject(error);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
427
561
|
});
|
|
428
562
|
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
429
563
|
};
|
|
@@ -568,10 +702,11 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
568
702
|
var init_chunk_loader = __esm({
|
|
569
703
|
"src/shared/client/chunk-loader.ts"() {
|
|
570
704
|
"use strict";
|
|
705
|
+
init_constants();
|
|
571
706
|
init_error();
|
|
572
|
-
init_fetch_with_protected_rc_fallback();
|
|
573
707
|
init_logger();
|
|
574
708
|
init_const();
|
|
709
|
+
init_protected_rc_fallback();
|
|
575
710
|
init_turbopack_patterns();
|
|
576
711
|
}
|
|
577
712
|
});
|
|
@@ -580,10 +715,14 @@ var init_chunk_loader = __esm({
|
|
|
580
715
|
function handleTurbopackModule(bundle, moduleId, id) {
|
|
581
716
|
const self = globalThis;
|
|
582
717
|
const bundleKey = getBundleKey(bundle);
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
modules =
|
|
718
|
+
const raw = self[`TURBOPACK_${bundleKey}`];
|
|
719
|
+
let modules;
|
|
720
|
+
if (raw && typeof raw === "object" && "__chunks__" in raw) {
|
|
721
|
+
modules = raw.__chunks__.flat();
|
|
722
|
+
} else if (Array.isArray(raw)) {
|
|
723
|
+
modules = raw.flat();
|
|
724
|
+
} else {
|
|
725
|
+
modules = raw;
|
|
587
726
|
}
|
|
588
727
|
if (!self.__remote_components_turbopack_modules__) {
|
|
589
728
|
self.__remote_components_turbopack_modules__ = {};
|
|
@@ -612,13 +751,12 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
612
751
|
if (!self.__remote_components_turbopack_global__[bundle]) {
|
|
613
752
|
self.__remote_components_turbopack_global__[bundle] = {};
|
|
614
753
|
}
|
|
615
|
-
const allModules = Array.isArray(modules) ? modules.flat() : modules ? Object.values(modules) : [];
|
|
616
754
|
moduleInit(
|
|
617
755
|
createTurbopackContext(
|
|
618
756
|
bundle,
|
|
619
757
|
exports,
|
|
620
758
|
moduleExports,
|
|
621
|
-
|
|
759
|
+
modules,
|
|
622
760
|
moduleInit,
|
|
623
761
|
id,
|
|
624
762
|
self
|
|
@@ -632,46 +770,27 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
632
770
|
return moduleExports.exports;
|
|
633
771
|
}
|
|
634
772
|
function findModuleInit(modules, moduleId) {
|
|
635
|
-
if (
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
773
|
+
if (!modules || typeof modules !== "object")
|
|
774
|
+
return;
|
|
775
|
+
if (!Array.isArray(modules)) {
|
|
776
|
+
const key = moduleId in modules ? moduleId : Object.keys(modules).find((k) => k.startsWith(moduleId));
|
|
777
|
+
return key !== void 0 ? modules[key] : void 0;
|
|
778
|
+
}
|
|
779
|
+
const flat = modules.flat();
|
|
780
|
+
let idx = flat.findIndex((e) => String(e) === String(moduleId));
|
|
781
|
+
if (idx < 0) {
|
|
782
|
+
idx = flat.findIndex(
|
|
783
|
+
(e) => typeof e === "string" && e.startsWith(moduleId)
|
|
645
784
|
);
|
|
646
|
-
if (matchingKey) {
|
|
647
|
-
return modules[matchingKey];
|
|
648
|
-
}
|
|
649
|
-
logError("TurbopackModule", `No match found for module ID: ${moduleId}`);
|
|
650
|
-
return void 0;
|
|
651
785
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
const normalizedId = NUMERIC_MODULE_ID_RE.test(moduleId) ? Number(moduleId) : moduleId;
|
|
655
|
-
let moduleIdIndex = allModules.indexOf(normalizedId);
|
|
656
|
-
if (moduleIdIndex === -1) {
|
|
657
|
-
moduleIdIndex = allModules.findIndex(
|
|
658
|
-
(bundleEntry) => typeof bundleEntry === "string" && bundleEntry.startsWith(moduleId) || bundleEntry === normalizedId
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
if (moduleIdIndex !== -1) {
|
|
662
|
-
while (typeof allModules[moduleIdIndex] !== "function" && moduleIdIndex < allModules.length) {
|
|
663
|
-
moduleIdIndex++;
|
|
664
|
-
}
|
|
665
|
-
return allModules[moduleIdIndex];
|
|
666
|
-
}
|
|
667
|
-
} else {
|
|
668
|
-
return allModules.find(
|
|
669
|
-
(bundleEntry) => typeof bundleEntry === "object" && bundleEntry !== null && moduleId in bundleEntry
|
|
670
|
-
)?.[moduleId];
|
|
786
|
+
if (idx >= 0) {
|
|
787
|
+
return flat.slice(idx + 1).find((e) => typeof e === "function");
|
|
671
788
|
}
|
|
672
|
-
return
|
|
789
|
+
return flat.find(
|
|
790
|
+
(e) => Boolean(e && typeof e === "object" && moduleId in e)
|
|
791
|
+
)?.[moduleId];
|
|
673
792
|
}
|
|
674
|
-
function createTurbopackContext(bundle, exports, moduleExports,
|
|
793
|
+
function createTurbopackContext(bundle, exports, moduleExports, modules, moduleInit, id, self) {
|
|
675
794
|
return {
|
|
676
795
|
// HMR not implemented for Remote Components
|
|
677
796
|
k: {
|
|
@@ -792,13 +911,17 @@ function createTurbopackContext(bundle, exports, moduleExports, allModules, modu
|
|
|
792
911
|
(parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
|
|
793
912
|
);
|
|
794
913
|
},
|
|
914
|
+
// dynamic import tracking — no-op for remote components
|
|
915
|
+
j() {
|
|
916
|
+
},
|
|
795
917
|
// chunk loader
|
|
796
918
|
l(url) {
|
|
797
|
-
const
|
|
919
|
+
const flatModules = Array.isArray(modules) ? modules : [];
|
|
920
|
+
const moduleInitIndex = flatModules.indexOf(moduleInit);
|
|
798
921
|
if (moduleInitIndex !== -1) {
|
|
799
|
-
const scriptIndex =
|
|
922
|
+
const scriptIndex = flatModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
800
923
|
if (scriptIndex !== -1) {
|
|
801
|
-
const script =
|
|
924
|
+
const script = flatModules[scriptIndex];
|
|
802
925
|
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
803
926
|
const nextIndex = scriptSrc.indexOf("/_next");
|
|
804
927
|
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
@@ -821,7 +944,6 @@ var init_turbopack_module = __esm({
|
|
|
821
944
|
"use strict";
|
|
822
945
|
init_logger();
|
|
823
946
|
init_const();
|
|
824
|
-
init_turbopack_patterns();
|
|
825
947
|
}
|
|
826
948
|
});
|
|
827
949
|
|
|
@@ -955,7 +1077,7 @@ var init_shared_modules2 = __esm({
|
|
|
955
1077
|
});
|
|
956
1078
|
|
|
957
1079
|
// src/shared/client/webpack-adapter.ts
|
|
958
|
-
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}) {
|
|
1080
|
+
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
|
|
959
1081
|
const self = globalThis;
|
|
960
1082
|
if (!self.__remote_bundle_url__) {
|
|
961
1083
|
self.__remote_bundle_url__ = {};
|
|
@@ -967,7 +1089,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
967
1089
|
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
968
1090
|
self.__original_webpack_require__ = self.__webpack_require__;
|
|
969
1091
|
}
|
|
970
|
-
self.__webpack_chunk_load__ = createChunkLoader(runtime);
|
|
1092
|
+
self.__webpack_chunk_load__ = createChunkLoader(runtime, resolveClientUrl);
|
|
971
1093
|
self.__webpack_require__ = createModuleRequire(runtime);
|
|
972
1094
|
self.__webpack_require_type__ = runtime;
|
|
973
1095
|
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
@@ -1061,7 +1183,81 @@ var init_webpack_adapter = __esm({
|
|
|
1061
1183
|
});
|
|
1062
1184
|
|
|
1063
1185
|
// src/shared/client/static-loader.ts
|
|
1064
|
-
async function
|
|
1186
|
+
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1187
|
+
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1188
|
+
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
1189
|
+
const response = await fetch(fetchUrl);
|
|
1190
|
+
if (!response.ok)
|
|
1191
|
+
throw new Error(`Proxied fetch failed: ${response.status}`);
|
|
1192
|
+
const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
|
|
1193
|
+
/\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
|
|
1194
|
+
(_, keyword, quote, relativePath) => {
|
|
1195
|
+
const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
|
|
1196
|
+
const resolvedImportUrl = new URL(
|
|
1197
|
+
resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
|
|
1198
|
+
location.href
|
|
1199
|
+
).href;
|
|
1200
|
+
return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
|
|
1201
|
+
}
|
|
1202
|
+
);
|
|
1203
|
+
const moduleBlobUrl = URL.createObjectURL(
|
|
1204
|
+
new Blob([content], { type: "text/javascript" })
|
|
1205
|
+
);
|
|
1206
|
+
const wrapperContent = [
|
|
1207
|
+
`import*as m from${JSON.stringify(moduleBlobUrl)};`,
|
|
1208
|
+
`globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
|
|
1209
|
+
`globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
|
|
1210
|
+
].join("");
|
|
1211
|
+
const wrapperBlobUrl = URL.createObjectURL(
|
|
1212
|
+
new Blob([wrapperContent], { type: "text/javascript" })
|
|
1213
|
+
);
|
|
1214
|
+
const scriptEl = document.createElement("script");
|
|
1215
|
+
scriptEl.type = "module";
|
|
1216
|
+
scriptEl.src = wrapperBlobUrl;
|
|
1217
|
+
try {
|
|
1218
|
+
await new Promise((resolve, reject) => {
|
|
1219
|
+
scriptEl.onload = () => resolve();
|
|
1220
|
+
scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
|
|
1221
|
+
document.head.appendChild(scriptEl);
|
|
1222
|
+
});
|
|
1223
|
+
} finally {
|
|
1224
|
+
scriptEl.remove();
|
|
1225
|
+
URL.revokeObjectURL(moduleBlobUrl);
|
|
1226
|
+
URL.revokeObjectURL(wrapperBlobUrl);
|
|
1227
|
+
}
|
|
1228
|
+
const registry = globalThis.__rc_module_registry__;
|
|
1229
|
+
const mod = registry?.[absoluteSrc] ?? {};
|
|
1230
|
+
if (registry)
|
|
1231
|
+
delete registry[absoluteSrc];
|
|
1232
|
+
return mod;
|
|
1233
|
+
}
|
|
1234
|
+
async function importDirectly(absoluteSrc) {
|
|
1235
|
+
try {
|
|
1236
|
+
return await import(
|
|
1237
|
+
/* @vite-ignore */
|
|
1238
|
+
/* webpackIgnore: true */
|
|
1239
|
+
absoluteSrc
|
|
1240
|
+
);
|
|
1241
|
+
} catch (importError) {
|
|
1242
|
+
if (!absoluteSrc.startsWith("blob:")) {
|
|
1243
|
+
warnCrossOriginFetchError("StaticLoader", absoluteSrc);
|
|
1244
|
+
}
|
|
1245
|
+
throw importError;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
function resolveScriptSrc(script, url) {
|
|
1249
|
+
const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
|
|
1250
|
+
if (!rawSrc && script.textContent) {
|
|
1251
|
+
return URL.createObjectURL(
|
|
1252
|
+
new Blob(
|
|
1253
|
+
[script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
|
|
1254
|
+
{ type: "text/javascript" }
|
|
1255
|
+
)
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
return rawSrc;
|
|
1259
|
+
}
|
|
1260
|
+
async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
1065
1261
|
const self = globalThis;
|
|
1066
1262
|
if (self.__remote_script_entrypoint_mount__?.[url.href]) {
|
|
1067
1263
|
self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
|
|
@@ -1072,26 +1268,9 @@ async function loadStaticRemoteComponent(scripts, url) {
|
|
|
1072
1268
|
const mountUnmountSets = await Promise.all(
|
|
1073
1269
|
scripts.map(async (script) => {
|
|
1074
1270
|
try {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
[
|
|
1079
|
-
script.textContent.replace(
|
|
1080
|
-
/import\.meta\.url/g,
|
|
1081
|
-
JSON.stringify(url)
|
|
1082
|
-
)
|
|
1083
|
-
],
|
|
1084
|
-
{
|
|
1085
|
-
type: "text/javascript"
|
|
1086
|
-
}
|
|
1087
|
-
);
|
|
1088
|
-
src = URL.createObjectURL(blob);
|
|
1089
|
-
}
|
|
1090
|
-
const mod = await import(
|
|
1091
|
-
/* @vite-ignore */
|
|
1092
|
-
/* webpackIgnore: true */
|
|
1093
|
-
new URL(src, url).href
|
|
1094
|
-
);
|
|
1271
|
+
const src = resolveScriptSrc(script, url);
|
|
1272
|
+
const absoluteSrc = new URL(src, url).href;
|
|
1273
|
+
const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
|
|
1095
1274
|
if (src.startsWith("blob:")) {
|
|
1096
1275
|
URL.revokeObjectURL(src);
|
|
1097
1276
|
}
|
|
@@ -1365,7 +1544,7 @@ var webpack_exports = {};
|
|
|
1365
1544
|
__export(webpack_exports, {
|
|
1366
1545
|
webpackRuntime: () => webpackRuntime
|
|
1367
1546
|
});
|
|
1368
|
-
async function webpackRuntime(bundle, shared, remoteShared) {
|
|
1547
|
+
async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
1369
1548
|
const self = globalThis;
|
|
1370
1549
|
if (!self.__DISABLE_WEBPACK_EXEC__) {
|
|
1371
1550
|
self.__DISABLE_WEBPACK_EXEC__ = {};
|
|
@@ -1397,35 +1576,18 @@ async function webpackRuntime(bundle, shared, remoteShared) {
|
|
|
1397
1576
|
default: { createFromReadableStream }
|
|
1398
1577
|
} = await import("react-server-dom-webpack/client.browser");
|
|
1399
1578
|
async function preloadScripts(scripts, url, remoteBundle, _) {
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
)
|
|
1413
|
-
);
|
|
1414
|
-
newScript.remove();
|
|
1415
|
-
};
|
|
1416
|
-
const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
|
|
1417
|
-
if (scriptSrc) {
|
|
1418
|
-
newScript.src = new URL(
|
|
1419
|
-
scriptSrc.replace(/\/_next\/\[(?:.+)\](?:%20| )/, "/_next/"),
|
|
1420
|
-
url
|
|
1421
|
-
).href;
|
|
1422
|
-
}
|
|
1423
|
-
newScript.async = true;
|
|
1424
|
-
document.body.appendChild(newScript);
|
|
1425
|
-
script.parentElement?.removeChild(script);
|
|
1426
|
-
});
|
|
1427
|
-
})
|
|
1428
|
-
);
|
|
1579
|
+
const scriptSrcs = scripts.flatMap((script) => {
|
|
1580
|
+
const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
|
|
1581
|
+
script.parentElement?.removeChild(script);
|
|
1582
|
+
if (!scriptSrc)
|
|
1583
|
+
return [];
|
|
1584
|
+
return [
|
|
1585
|
+
{
|
|
1586
|
+
src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
1587
|
+
}
|
|
1588
|
+
];
|
|
1589
|
+
});
|
|
1590
|
+
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
1429
1591
|
const hostShared = {
|
|
1430
1592
|
...sharedPolyfills(shared),
|
|
1431
1593
|
...self.__remote_component_host_shared_modules__,
|
|
@@ -1469,6 +1631,8 @@ var init_webpack = __esm({
|
|
|
1469
1631
|
"src/html/host/runtime/webpack.ts"() {
|
|
1470
1632
|
"use strict";
|
|
1471
1633
|
init_polyfill();
|
|
1634
|
+
init_script_loader();
|
|
1635
|
+
init_webpack_patterns();
|
|
1472
1636
|
init_error();
|
|
1473
1637
|
init_next_client_pages_loader();
|
|
1474
1638
|
init_shared_modules();
|
|
@@ -1480,7 +1644,7 @@ var turbopack_exports = {};
|
|
|
1480
1644
|
__export(turbopack_exports, {
|
|
1481
1645
|
turbopackRuntime: () => turbopackRuntime
|
|
1482
1646
|
});
|
|
1483
|
-
async function turbopackRuntime(url, bundle, shared, remoteShared) {
|
|
1647
|
+
async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
1484
1648
|
const self = globalThis;
|
|
1485
1649
|
const hostShared = {
|
|
1486
1650
|
...sharedPolyfills(shared),
|
|
@@ -1494,7 +1658,8 @@ async function turbopackRuntime(url, bundle, shared, remoteShared) {
|
|
|
1494
1658
|
url,
|
|
1495
1659
|
bundle,
|
|
1496
1660
|
hostShared,
|
|
1497
|
-
remoteShared
|
|
1661
|
+
remoteShared,
|
|
1662
|
+
resolveClientUrl
|
|
1498
1663
|
);
|
|
1499
1664
|
const {
|
|
1500
1665
|
default: { createFromReadableStream }
|
|
@@ -1508,7 +1673,8 @@ async function turbopackRuntime(url, bundle, shared, remoteShared) {
|
|
|
1508
1673
|
url,
|
|
1509
1674
|
bundle,
|
|
1510
1675
|
hostShared,
|
|
1511
|
-
remoteShared
|
|
1676
|
+
remoteShared,
|
|
1677
|
+
resolveClientUrl
|
|
1512
1678
|
);
|
|
1513
1679
|
}
|
|
1514
1680
|
return {
|
|
@@ -1534,7 +1700,7 @@ var script_exports = {};
|
|
|
1534
1700
|
__export(script_exports, {
|
|
1535
1701
|
scriptRuntime: () => scriptRuntime
|
|
1536
1702
|
});
|
|
1537
|
-
function scriptRuntime() {
|
|
1703
|
+
function scriptRuntime(resolveClientUrl) {
|
|
1538
1704
|
const self = globalThis;
|
|
1539
1705
|
return {
|
|
1540
1706
|
self,
|
|
@@ -1544,7 +1710,7 @@ function scriptRuntime() {
|
|
|
1544
1710
|
Component: null,
|
|
1545
1711
|
App: null
|
|
1546
1712
|
}),
|
|
1547
|
-
preloadScripts: loadStaticRemoteComponent
|
|
1713
|
+
preloadScripts: (scripts, url) => loadStaticRemoteComponent(scripts, url, resolveClientUrl)
|
|
1548
1714
|
};
|
|
1549
1715
|
}
|
|
1550
1716
|
var init_script = __esm({
|
|
@@ -1557,6 +1723,7 @@ var init_script = __esm({
|
|
|
1557
1723
|
// src/html/host/index.tsx
|
|
1558
1724
|
var host_exports = {};
|
|
1559
1725
|
__export(host_exports, {
|
|
1726
|
+
proxyClientRequestsThroughHost: () => proxyClientRequestsThroughHost,
|
|
1560
1727
|
registerSharedModules: () => registerSharedModules
|
|
1561
1728
|
});
|
|
1562
1729
|
module.exports = __toCommonJS(host_exports);
|
|
@@ -1575,7 +1742,7 @@ var tagNames = [
|
|
|
1575
1742
|
"script",
|
|
1576
1743
|
"link"
|
|
1577
1744
|
];
|
|
1578
|
-
function applyOriginToNodes(doc, url) {
|
|
1745
|
+
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
1579
1746
|
if (url.origin !== location.origin) {
|
|
1580
1747
|
const nodes = doc.querySelectorAll(
|
|
1581
1748
|
tagNames.map(
|
|
@@ -1584,12 +1751,15 @@ function applyOriginToNodes(doc, url) {
|
|
|
1584
1751
|
);
|
|
1585
1752
|
nodes.forEach((node) => {
|
|
1586
1753
|
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
1587
|
-
|
|
1754
|
+
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
1755
|
+
const isScript = node.tagName.toLowerCase() === "script";
|
|
1756
|
+
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
1588
1757
|
}
|
|
1589
1758
|
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
1759
|
+
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
1590
1760
|
node.setAttribute(
|
|
1591
1761
|
"href",
|
|
1592
|
-
|
|
1762
|
+
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
1593
1763
|
);
|
|
1594
1764
|
}
|
|
1595
1765
|
if (node.hasAttribute("srcset")) {
|
|
@@ -1598,7 +1768,8 @@ function applyOriginToNodes(doc, url) {
|
|
|
1598
1768
|
if (!urlPart)
|
|
1599
1769
|
return entry;
|
|
1600
1770
|
const absoluteUrl = new URL(urlPart, url).href;
|
|
1601
|
-
|
|
1771
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
1772
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
1602
1773
|
}).join(", ");
|
|
1603
1774
|
if (srcSet) {
|
|
1604
1775
|
node.setAttribute("srcset", srcSet);
|
|
@@ -1610,7 +1781,8 @@ function applyOriginToNodes(doc, url) {
|
|
|
1610
1781
|
if (!urlPart)
|
|
1611
1782
|
return entry;
|
|
1612
1783
|
const absoluteUrl = new URL(urlPart, url).href;
|
|
1613
|
-
|
|
1784
|
+
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
1785
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
1614
1786
|
}).join(", ");
|
|
1615
1787
|
if (srcSet) {
|
|
1616
1788
|
node.setAttribute("imagesrcset", srcSet);
|
|
@@ -1620,6 +1792,34 @@ function applyOriginToNodes(doc, url) {
|
|
|
1620
1792
|
}
|
|
1621
1793
|
}
|
|
1622
1794
|
|
|
1795
|
+
// src/shared/client/proxy-through-host.ts
|
|
1796
|
+
init_protected_rc_fallback();
|
|
1797
|
+
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
1798
|
+
return (url) => resolveClientUrl(remoteSrc, url);
|
|
1799
|
+
}
|
|
1800
|
+
var proxyClientRequestsThroughHost = (remoteSrc, url) => {
|
|
1801
|
+
if (typeof location === "undefined") {
|
|
1802
|
+
return void 0;
|
|
1803
|
+
}
|
|
1804
|
+
const remoteOrigin = new URL(remoteSrc, location.href).origin;
|
|
1805
|
+
if (remoteOrigin === location.origin) {
|
|
1806
|
+
return void 0;
|
|
1807
|
+
}
|
|
1808
|
+
try {
|
|
1809
|
+
const parsed = new URL(url, location.href);
|
|
1810
|
+
if (parsed.origin === remoteOrigin) {
|
|
1811
|
+
return generateProtectedRcFallbackSrc(url);
|
|
1812
|
+
}
|
|
1813
|
+
} catch {
|
|
1814
|
+
}
|
|
1815
|
+
return void 0;
|
|
1816
|
+
};
|
|
1817
|
+
|
|
1818
|
+
// src/shared/client/default-resolve-client-url.ts
|
|
1819
|
+
function bindResolveClientUrl(prop, remoteSrc) {
|
|
1820
|
+
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1623
1823
|
// src/shared/client/remote-component.ts
|
|
1624
1824
|
init_error();
|
|
1625
1825
|
|
|
@@ -1700,20 +1900,22 @@ function createRSCStream(rscName, data) {
|
|
|
1700
1900
|
});
|
|
1701
1901
|
}
|
|
1702
1902
|
|
|
1703
|
-
// src/shared/client/script-loader.ts
|
|
1704
|
-
init_error();
|
|
1705
|
-
|
|
1706
1903
|
// src/shared/client/component-loader.ts
|
|
1904
|
+
init_script_loader();
|
|
1707
1905
|
init_webpack_adapter();
|
|
1708
1906
|
|
|
1709
1907
|
// src/shared/client/remote-component.ts
|
|
1710
1908
|
init_const();
|
|
1909
|
+
init_script_loader();
|
|
1711
1910
|
init_static_loader();
|
|
1712
1911
|
init_webpack_adapter();
|
|
1713
1912
|
|
|
1714
1913
|
// src/html/host/index.tsx
|
|
1715
1914
|
init_error();
|
|
1716
1915
|
|
|
1916
|
+
// src/shared/ssr/fetch-with-hooks.ts
|
|
1917
|
+
init_logger();
|
|
1918
|
+
|
|
1717
1919
|
// src/shared/ssr/fetch-headers.ts
|
|
1718
1920
|
function remoteFetchHeaders() {
|
|
1719
1921
|
return {
|
|
@@ -1731,7 +1933,6 @@ function remoteFetchHeaders() {
|
|
|
1731
1933
|
}
|
|
1732
1934
|
|
|
1733
1935
|
// src/shared/ssr/fetch-with-hooks.ts
|
|
1734
|
-
init_fetch_with_protected_rc_fallback();
|
|
1735
1936
|
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1736
1937
|
const {
|
|
1737
1938
|
onRequest,
|
|
@@ -1751,7 +1952,12 @@ async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
|
1751
1952
|
};
|
|
1752
1953
|
let res = await onRequest?.(url, init, hookOptions);
|
|
1753
1954
|
if (!res) {
|
|
1754
|
-
|
|
1955
|
+
try {
|
|
1956
|
+
res = await fetch(url, init);
|
|
1957
|
+
} catch (error) {
|
|
1958
|
+
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1959
|
+
throw error;
|
|
1960
|
+
}
|
|
1755
1961
|
}
|
|
1756
1962
|
const transformedRes = await onResponse?.(url, res, hookOptions);
|
|
1757
1963
|
if (transformedRes) {
|
|
@@ -1774,7 +1980,8 @@ async function attachStyles({
|
|
|
1774
1980
|
signal,
|
|
1775
1981
|
baseUrl,
|
|
1776
1982
|
remoteComponentSrc,
|
|
1777
|
-
root
|
|
1983
|
+
root,
|
|
1984
|
+
resolveClientUrl
|
|
1778
1985
|
}) {
|
|
1779
1986
|
const appendedLinks = [];
|
|
1780
1987
|
let abortReject = null;
|
|
@@ -1809,9 +2016,13 @@ async function attachStyles({
|
|
|
1809
2016
|
});
|
|
1810
2017
|
for (const attr of link.attributes) {
|
|
1811
2018
|
if (attr.name === "href") {
|
|
2019
|
+
const absoluteHref = new URL(
|
|
2020
|
+
attr.value,
|
|
2021
|
+
baseUrl ?? location.origin
|
|
2022
|
+
).href;
|
|
1812
2023
|
newLink.setAttribute(
|
|
1813
2024
|
attr.name,
|
|
1814
|
-
|
|
2025
|
+
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
1815
2026
|
);
|
|
1816
2027
|
} else {
|
|
1817
2028
|
newLink.setAttribute(attr.name, attr.value);
|
|
@@ -1845,7 +2056,7 @@ async function attachStyles({
|
|
|
1845
2056
|
|
|
1846
2057
|
// src/html/host/runtime/index.ts
|
|
1847
2058
|
init_error();
|
|
1848
|
-
async function getRuntime(type, url, bundle, shared, remoteShared) {
|
|
2059
|
+
async function getRuntime(type, url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
1849
2060
|
if (typeof globalThis.process === "undefined") {
|
|
1850
2061
|
globalThis.process = {
|
|
1851
2062
|
env: {}
|
|
@@ -1853,13 +2064,24 @@ async function getRuntime(type, url, bundle, shared, remoteShared) {
|
|
|
1853
2064
|
}
|
|
1854
2065
|
if (type === "webpack") {
|
|
1855
2066
|
const { webpackRuntime: webpackRuntime2 } = await Promise.resolve().then(() => (init_webpack(), webpack_exports));
|
|
1856
|
-
return webpackRuntime2(
|
|
2067
|
+
return webpackRuntime2(
|
|
2068
|
+
bundle ?? "default",
|
|
2069
|
+
shared,
|
|
2070
|
+
remoteShared,
|
|
2071
|
+
resolveClientUrl
|
|
2072
|
+
);
|
|
1857
2073
|
} else if (type === "turbopack") {
|
|
1858
2074
|
const { turbopackRuntime: turbopackRuntime2 } = await Promise.resolve().then(() => (init_turbopack(), turbopack_exports));
|
|
1859
|
-
return turbopackRuntime2(
|
|
2075
|
+
return turbopackRuntime2(
|
|
2076
|
+
url,
|
|
2077
|
+
bundle,
|
|
2078
|
+
shared,
|
|
2079
|
+
remoteShared,
|
|
2080
|
+
resolveClientUrl
|
|
2081
|
+
);
|
|
1860
2082
|
} else if (type === "script") {
|
|
1861
2083
|
const { scriptRuntime: scriptRuntime2 } = await Promise.resolve().then(() => (init_script(), script_exports));
|
|
1862
|
-
return scriptRuntime2();
|
|
2084
|
+
return scriptRuntime2(resolveClientUrl);
|
|
1863
2085
|
}
|
|
1864
2086
|
throw new RemoteComponentsError(
|
|
1865
2087
|
`Remote Components runtime "${type}" is not supported. Supported runtimes are "webpack", "turbopack", and "script".`
|
|
@@ -1884,6 +2106,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1884
2106
|
reactRoot;
|
|
1885
2107
|
onRequest;
|
|
1886
2108
|
onResponse;
|
|
2109
|
+
resolveClientUrl;
|
|
1887
2110
|
/** Current AbortController for the loading operation - can be used to cancel loading via controller.abort() */
|
|
1888
2111
|
abortController;
|
|
1889
2112
|
static get observedAttributes() {
|
|
@@ -1897,7 +2120,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1897
2120
|
if (this.getAttribute("src")) {
|
|
1898
2121
|
this.load().catch((e) => {
|
|
1899
2122
|
if (isAbortError(e)) {
|
|
1900
|
-
this.isLoading = false;
|
|
1901
2123
|
return;
|
|
1902
2124
|
}
|
|
1903
2125
|
logError("HtmlHost", "Error loading remote component.", e);
|
|
@@ -1923,7 +2145,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1923
2145
|
this.root = newRoot;
|
|
1924
2146
|
this.load().catch((e) => {
|
|
1925
2147
|
if (isAbortError(e)) {
|
|
1926
|
-
this.isLoading = false;
|
|
1927
2148
|
return;
|
|
1928
2149
|
}
|
|
1929
2150
|
logError("HtmlHost", "Error reloading remote component.", e);
|
|
@@ -1946,7 +2167,14 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1946
2167
|
});
|
|
1947
2168
|
});
|
|
1948
2169
|
if (this.isLoading) {
|
|
1949
|
-
|
|
2170
|
+
this.abortController?.abort();
|
|
2171
|
+
this.isLoading = false;
|
|
2172
|
+
if (this.root && !this.reactRoot) {
|
|
2173
|
+
this.root.innerHTML = "";
|
|
2174
|
+
this.fouc = null;
|
|
2175
|
+
this.fallbackSlot = document.createElement("slot");
|
|
2176
|
+
this.root.appendChild(this.fallbackSlot);
|
|
2177
|
+
}
|
|
1950
2178
|
}
|
|
1951
2179
|
if (!this.root) {
|
|
1952
2180
|
this.root = this.attachShadow({
|
|
@@ -1957,28 +2185,16 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1957
2185
|
}
|
|
1958
2186
|
this.name = this.getAttribute("name") || "__vercel_remote_component";
|
|
1959
2187
|
this.bundle = "default";
|
|
1960
|
-
if (this.hasAttribute("src") || this.querySelector("div#__REMOTE_COMPONENT__") || this.hasAttribute("data-ssr")) {
|
|
1961
|
-
this.load().catch((e) => {
|
|
1962
|
-
if (isAbortError(e)) {
|
|
1963
|
-
this.isLoading = false;
|
|
1964
|
-
return;
|
|
1965
|
-
}
|
|
1966
|
-
logError("HtmlHost", "Error loading remote component.", e);
|
|
1967
|
-
const errorEvent = new Event("error", {
|
|
1968
|
-
bubbles: true,
|
|
1969
|
-
composed: true
|
|
1970
|
-
});
|
|
1971
|
-
Object.assign(errorEvent, {
|
|
1972
|
-
error: e,
|
|
1973
|
-
src: this.getAttribute("src")
|
|
1974
|
-
});
|
|
1975
|
-
this.dispatchEvent(errorEvent);
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
2188
|
this.isLoading = true;
|
|
1979
2189
|
const src = this.getAttribute("src");
|
|
1980
2190
|
this.abortController = new AbortController();
|
|
1981
2191
|
const signal = this.abortController.signal;
|
|
2192
|
+
const isCurrentLoad = () => !signal.aborted && this.getAttribute("src") === src;
|
|
2193
|
+
const abandonLoad = () => {
|
|
2194
|
+
if (this.abortController?.signal === signal && this.isLoading) {
|
|
2195
|
+
this.isLoading = false;
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
1982
2198
|
const beforeLoadEvent = new Event("beforeload", {
|
|
1983
2199
|
bubbles: true,
|
|
1984
2200
|
composed: true
|
|
@@ -1997,46 +2213,42 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1997
2213
|
this.name = url.hash.slice(1);
|
|
1998
2214
|
}
|
|
1999
2215
|
}
|
|
2216
|
+
const resolveClientUrl = url ? bindResolveClientUrl(this.resolveClientUrl, url.href) : void 0;
|
|
2000
2217
|
if (!remoteComponentChild && url) {
|
|
2001
2218
|
const fetchInit = {
|
|
2002
2219
|
credentials: this.getAttribute("credentials") || "same-origin"
|
|
2003
2220
|
};
|
|
2004
|
-
const
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2221
|
+
const resolvedUrl = new URL(
|
|
2222
|
+
resolveClientUrl?.(url.href) ?? url.href,
|
|
2223
|
+
window.location.href
|
|
2224
|
+
);
|
|
2225
|
+
let res;
|
|
2226
|
+
try {
|
|
2227
|
+
res = await fetchWithHooks(resolvedUrl, fetchInit, {
|
|
2228
|
+
onRequest: this.onRequest,
|
|
2229
|
+
onResponse: this.onResponse,
|
|
2230
|
+
abortController: this.abortController
|
|
2231
|
+
});
|
|
2232
|
+
} catch (e) {
|
|
2233
|
+
if (isAbortError(e)) {
|
|
2234
|
+
return abandonLoad();
|
|
2235
|
+
}
|
|
2236
|
+
throw e;
|
|
2237
|
+
}
|
|
2009
2238
|
if (!res || !res.ok) {
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
);
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
const doc2 = parser2.parseFromString(body, "text/html");
|
|
2018
|
-
const errorTemplate = doc2.querySelector(
|
|
2019
|
-
"template[data-next-error-message]"
|
|
2020
|
-
);
|
|
2021
|
-
const errorMessage = errorTemplate?.getAttribute(
|
|
2022
|
-
"data-next-error-message"
|
|
2023
|
-
);
|
|
2024
|
-
const errorStack = errorTemplate?.getAttribute(
|
|
2025
|
-
"data-next-error-stack"
|
|
2026
|
-
);
|
|
2027
|
-
if (errorMessage) {
|
|
2028
|
-
error = new RemoteComponentsError(errorMessage);
|
|
2029
|
-
if (errorStack) {
|
|
2030
|
-
error.stack = errorStack;
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
} catch (parseError) {
|
|
2034
|
-
if (isAbortError(parseError))
|
|
2035
|
-
throw parseError;
|
|
2239
|
+
throw await errorFromFailedFetch(url.href, resolvedUrl, res);
|
|
2240
|
+
}
|
|
2241
|
+
try {
|
|
2242
|
+
html = await res.text();
|
|
2243
|
+
} catch (e) {
|
|
2244
|
+
if (isAbortError(e)) {
|
|
2245
|
+
return abandonLoad();
|
|
2036
2246
|
}
|
|
2037
|
-
throw
|
|
2247
|
+
throw e;
|
|
2248
|
+
}
|
|
2249
|
+
if (!isCurrentLoad()) {
|
|
2250
|
+
return abandonLoad();
|
|
2038
2251
|
}
|
|
2039
|
-
html = await res.text();
|
|
2040
2252
|
}
|
|
2041
2253
|
const parser = new DOMParser();
|
|
2042
2254
|
const doc = parser.parseFromString(html, "text/html");
|
|
@@ -2119,6 +2331,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2119
2331
|
}
|
|
2120
2332
|
})
|
|
2121
2333
|
);
|
|
2334
|
+
if (!isCurrentLoad()) {
|
|
2335
|
+
return abandonLoad();
|
|
2336
|
+
}
|
|
2122
2337
|
}
|
|
2123
2338
|
}
|
|
2124
2339
|
this.root.innerHTML = "";
|
|
@@ -2136,7 +2351,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2136
2351
|
});
|
|
2137
2352
|
this.dispatchEvent(changeEvent);
|
|
2138
2353
|
}
|
|
2139
|
-
this.prevUrl = url ?? new URL(location.href);
|
|
2354
|
+
this.prevUrl = url ?? new URL(window.location.href);
|
|
2140
2355
|
this.prevIsRemoteComponent = isRemoteComponent;
|
|
2141
2356
|
this.prevSrc = src;
|
|
2142
2357
|
this.prevName = this.name;
|
|
@@ -2151,7 +2366,8 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2151
2366
|
// Effects run after load, no abort needed
|
|
2152
2367
|
baseUrl: url?.href,
|
|
2153
2368
|
remoteComponentSrc,
|
|
2154
|
-
root: this.root ?? null
|
|
2369
|
+
root: this.root ?? null,
|
|
2370
|
+
resolveClientUrl
|
|
2155
2371
|
});
|
|
2156
2372
|
if (!this.reactRoot) {
|
|
2157
2373
|
await attachStyles({
|
|
@@ -2161,19 +2377,31 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2161
2377
|
signal,
|
|
2162
2378
|
baseUrl: url?.href,
|
|
2163
2379
|
remoteComponentSrc,
|
|
2164
|
-
root: this.root
|
|
2380
|
+
root: this.root,
|
|
2381
|
+
resolveClientUrl
|
|
2165
2382
|
});
|
|
2383
|
+
if (!isCurrentLoad()) {
|
|
2384
|
+
return abandonLoad();
|
|
2385
|
+
}
|
|
2166
2386
|
}
|
|
2167
|
-
applyOriginToNodes(
|
|
2387
|
+
applyOriginToNodes(
|
|
2388
|
+
doc,
|
|
2389
|
+
url ?? new URL(window.location.href),
|
|
2390
|
+
resolveClientUrl
|
|
2391
|
+
);
|
|
2168
2392
|
if (!this.reactRoot) {
|
|
2169
2393
|
Array.from(component.children).forEach((el) => {
|
|
2170
2394
|
if (!isRemoteComponent && el.tagName.toLowerCase() === "script") {
|
|
2171
2395
|
const newScript = document.createElement("script");
|
|
2172
2396
|
for (const attr of el.attributes) {
|
|
2173
2397
|
if (attr.name === "src") {
|
|
2398
|
+
const absoluteSrc = new URL(
|
|
2399
|
+
attr.value,
|
|
2400
|
+
url ?? window.location.origin
|
|
2401
|
+
).href;
|
|
2174
2402
|
newScript.setAttribute(
|
|
2175
2403
|
attr.name,
|
|
2176
|
-
|
|
2404
|
+
resolveClientUrl?.(absoluteSrc) ?? absoluteSrc
|
|
2177
2405
|
);
|
|
2178
2406
|
} else {
|
|
2179
2407
|
newScript.setAttribute(attr.name, attr.value);
|
|
@@ -2235,7 +2463,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2235
2463
|
preloadScripts
|
|
2236
2464
|
} = await getRuntime(
|
|
2237
2465
|
metadataObj.runtime,
|
|
2238
|
-
url ?? new URL(location.href),
|
|
2466
|
+
url ?? new URL(window.location.href),
|
|
2239
2467
|
this.bundle,
|
|
2240
2468
|
{
|
|
2241
2469
|
react: async () => (await import("react")).default,
|
|
@@ -2244,8 +2472,12 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2244
2472
|
"react-dom": async () => (await import("react-dom")).default,
|
|
2245
2473
|
"react-dom/client": async () => (await import("react-dom/client")).default
|
|
2246
2474
|
},
|
|
2247
|
-
remoteShared
|
|
2475
|
+
remoteShared,
|
|
2476
|
+
resolveClientUrl
|
|
2248
2477
|
);
|
|
2478
|
+
if (!isCurrentLoad()) {
|
|
2479
|
+
return abandonLoad();
|
|
2480
|
+
}
|
|
2249
2481
|
const scripts = isRemoteComponent ? component.querySelectorAll("script") : doc.querySelectorAll(
|
|
2250
2482
|
"script[src],script[data-src],script[data-remote-component-entrypoint]"
|
|
2251
2483
|
);
|
|
@@ -2261,6 +2493,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2261
2493
|
this.bundle ?? "default",
|
|
2262
2494
|
this.name ?? "__vercel_remote_component"
|
|
2263
2495
|
);
|
|
2496
|
+
if (!isCurrentLoad()) {
|
|
2497
|
+
return abandonLoad();
|
|
2498
|
+
}
|
|
2264
2499
|
if (isRemoteComponent) {
|
|
2265
2500
|
Array.from(component.children).forEach((child) => {
|
|
2266
2501
|
if (child.tagName === "SCRIPT") {
|
|
@@ -2321,7 +2556,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2321
2556
|
logError("HtmlHost", "Error attaching styles.", e);
|
|
2322
2557
|
});
|
|
2323
2558
|
}
|
|
2324
|
-
|
|
2559
|
+
if (isCurrentLoad()) {
|
|
2560
|
+
this.isLoading = false;
|
|
2561
|
+
}
|
|
2325
2562
|
const loadEvent = new Event("load", {
|
|
2326
2563
|
bubbles: true,
|
|
2327
2564
|
composed: true
|
|
@@ -2374,7 +2611,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2374
2611
|
logError("HtmlHost", "Error attaching styles.", e);
|
|
2375
2612
|
});
|
|
2376
2613
|
}
|
|
2377
|
-
|
|
2614
|
+
if (isCurrentLoad()) {
|
|
2615
|
+
remoteComponent.isLoading = false;
|
|
2616
|
+
}
|
|
2378
2617
|
const loadEvent = new Event("load", {
|
|
2379
2618
|
bubbles: true,
|
|
2380
2619
|
composed: true
|
|
@@ -2391,7 +2630,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2391
2630
|
(0, import_react.startTransition)(() => {
|
|
2392
2631
|
root.render(/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RemoteComponentFromNext, { initial: false }));
|
|
2393
2632
|
doCleanup();
|
|
2394
|
-
|
|
2633
|
+
if (isCurrentLoad()) {
|
|
2634
|
+
this.isLoading = false;
|
|
2635
|
+
}
|
|
2395
2636
|
});
|
|
2396
2637
|
return;
|
|
2397
2638
|
}
|
|
@@ -2435,7 +2676,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2435
2676
|
Object.assign(loadEvent, { src: this.getAttribute("src") });
|
|
2436
2677
|
this.dispatchEvent(loadEvent);
|
|
2437
2678
|
}
|
|
2438
|
-
|
|
2679
|
+
if (isCurrentLoad()) {
|
|
2680
|
+
this.isLoading = false;
|
|
2681
|
+
}
|
|
2439
2682
|
}
|
|
2440
2683
|
}
|
|
2441
2684
|
customElements.define("remote-component", RemoteComponent);
|
|
@@ -2453,6 +2696,7 @@ function registerSharedModules(modules = {}) {
|
|
|
2453
2696
|
}
|
|
2454
2697
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2455
2698
|
0 && (module.exports = {
|
|
2699
|
+
proxyClientRequestsThroughHost,
|
|
2456
2700
|
registerSharedModules
|
|
2457
2701
|
});
|
|
2458
2702
|
//# sourceMappingURL=host.cjs.map
|