remote-components 0.3.5 → 0.3.7
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/app-63L5THIQ.js +12 -0
- package/dist/app-63L5THIQ.js.map +1 -0
- package/dist/app-A5QE7XRH.cjs +12 -0
- package/dist/app-A5QE7XRH.cjs.map +1 -0
- package/dist/chunk-52BJ7VFA.js +202 -0
- package/dist/chunk-52BJ7VFA.js.map +1 -0
- package/dist/chunk-AWWWK2ZY.cjs +670 -0
- package/dist/chunk-AWWWK2ZY.cjs.map +1 -0
- package/dist/chunk-CTUJSWCM.js +215 -0
- package/dist/chunk-CTUJSWCM.js.map +1 -0
- package/dist/chunk-D5GNZB6O.js +61 -0
- package/dist/chunk-D5GNZB6O.js.map +1 -0
- package/dist/chunk-ENYGL5CO.js +11 -0
- package/dist/chunk-ENYGL5CO.js.map +1 -0
- package/dist/chunk-GAXJTFBV.js +20 -0
- package/dist/chunk-GAXJTFBV.js.map +1 -0
- package/dist/chunk-GBFUPMMI.js +670 -0
- package/dist/chunk-GBFUPMMI.js.map +1 -0
- package/dist/chunk-I47KE3EC.cjs +703 -0
- package/dist/chunk-I47KE3EC.cjs.map +1 -0
- package/dist/chunk-KE7QPAQ4.cjs +21 -0
- package/dist/chunk-KE7QPAQ4.cjs.map +1 -0
- package/dist/chunk-LCXO7BUY.cjs +57 -0
- package/dist/chunk-LCXO7BUY.cjs.map +1 -0
- package/dist/chunk-LQ7VQ74E.js +155 -0
- package/dist/chunk-LQ7VQ74E.js.map +1 -0
- package/dist/chunk-N5VQR2PW.cjs +215 -0
- package/dist/chunk-N5VQR2PW.cjs.map +1 -0
- package/dist/chunk-NZAB7REE.js +703 -0
- package/dist/chunk-NZAB7REE.js.map +1 -0
- package/dist/chunk-QKB74MLO.js +709 -0
- package/dist/chunk-QKB74MLO.js.map +1 -0
- package/dist/chunk-RJW3EZJP.cjs +709 -0
- package/dist/chunk-RJW3EZJP.cjs.map +1 -0
- package/dist/chunk-RUWR74XQ.cjs +152 -0
- package/dist/chunk-RUWR74XQ.cjs.map +1 -0
- package/dist/chunk-S2A4TFLS.js +152 -0
- package/dist/chunk-S2A4TFLS.js.map +1 -0
- package/dist/chunk-SHFJ5OQA.cjs +11 -0
- package/dist/chunk-SHFJ5OQA.cjs.map +1 -0
- package/dist/chunk-SJM7AAGU.js +358 -0
- package/dist/chunk-SJM7AAGU.js.map +1 -0
- package/dist/chunk-SZFCBE54.js +57 -0
- package/dist/chunk-SZFCBE54.js.map +1 -0
- package/dist/chunk-T64P7BAG.cjs +202 -0
- package/dist/chunk-T64P7BAG.cjs.map +1 -0
- package/dist/chunk-TCFLEBQM.cjs +20 -0
- package/dist/chunk-TCFLEBQM.cjs.map +1 -0
- package/dist/chunk-TZT7DLO5.cjs +155 -0
- package/dist/chunk-TZT7DLO5.cjs.map +1 -0
- package/dist/chunk-X6W464D6.cjs +358 -0
- package/dist/chunk-X6W464D6.cjs.map +1 -0
- package/dist/chunk-X6YKUJKH.js +21 -0
- package/dist/chunk-X6YKUJKH.js.map +1 -0
- package/dist/chunk-Z2SLBFQL.cjs +61 -0
- package/dist/chunk-Z2SLBFQL.cjs.map +1 -0
- package/dist/config/nextjs.cjs +74 -355
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.js +25 -271
- package/dist/config/nextjs.js.map +1 -1
- package/dist/config/webpack.cjs +12 -240
- package/dist/config/webpack.cjs.map +1 -1
- package/dist/config/webpack.js +6 -207
- package/dist/config/webpack.js.map +1 -1
- package/dist/host/html.cjs +128 -2494
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +45 -2382
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +53 -2939
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +31 -2894
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/proxy/client.cjs +8 -38
- package/dist/host/proxy/client.cjs.map +1 -1
- package/dist/host/proxy/client.js +4 -7
- package/dist/host/proxy/client.js.map +1 -1
- package/dist/host/proxy.cjs +19 -56
- package/dist/host/proxy.cjs.map +1 -1
- package/dist/host/proxy.js +8 -20
- package/dist/host/proxy.js.map +1 -1
- package/dist/host/react.cjs +17 -2870
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +13 -2837
- package/dist/host/react.js.map +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.cjs +27 -15
- package/dist/internal/config/webpack/next-client-pages-loader.cjs.map +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.d.ts +3 -5
- package/dist/internal/config/webpack/next-client-pages-loader.js +27 -15
- package/dist/internal/config/webpack/next-client-pages-loader.js.map +1 -1
- package/dist/internal/host/nextjs/app-client.d.ts +1 -1
- package/dist/internal/host/react/context.d.ts +2 -2
- package/dist/internal/host/server/fetch-remote-component.cjs +1 -18
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.js +1 -18
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/host/shared/pipeline.d.ts +2 -2
- package/dist/internal/runtime/loaders/component-loader.cjs +5 -2
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.d.ts +2 -2
- package/dist/internal/runtime/loaders/component-loader.js +5 -2
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
- package/dist/internal/runtime/loaders/static-loader.d.ts +2 -1
- package/dist/internal/runtime/namespace.cjs +1 -0
- package/dist/internal/runtime/namespace.cjs.map +1 -1
- package/dist/internal/runtime/namespace.d.ts +2 -1
- package/dist/internal/runtime/namespace.js +1 -0
- package/dist/internal/runtime/namespace.js.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.cjs +1 -5
- package/dist/internal/runtime/turbopack/remote-scope.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.js +1 -5
- package/dist/internal/runtime/turbopack/remote-scope.js.map +1 -1
- package/dist/internal/runtime/types.d.ts +2 -1
- package/dist/internal/utils.cjs +1 -1
- package/dist/internal/utils.cjs.map +1 -1
- package/dist/internal/utils.d.ts +5 -5
- package/dist/internal/utils.js +1 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/remote/html.cjs +15 -314
- package/dist/remote/html.cjs.map +1 -1
- package/dist/remote/html.js +7 -305
- package/dist/remote/html.js.map +1 -1
- package/dist/remote/middleware.cjs +16 -41
- package/dist/remote/middleware.cjs.map +1 -1
- package/dist/script-D5AD7HLV.cjs +26 -0
- package/dist/script-D5AD7HLV.cjs.map +1 -0
- package/dist/script-VPOI7ARP.js +26 -0
- package/dist/script-VPOI7ARP.js.map +1 -0
- package/dist/{server-handoff-ce13bebc.d.ts → server-handoff-8c89b856.d.ts} +2 -2
- package/dist/static-loader-OHSAUD62.js +11 -0
- package/dist/static-loader-OHSAUD62.js.map +1 -0
- package/dist/static-loader-UDIXK5MV.cjs +11 -0
- package/dist/static-loader-UDIXK5MV.cjs.map +1 -0
- package/dist/turbopack-5LW6V6IT.js +55 -0
- package/dist/turbopack-5LW6V6IT.js.map +1 -0
- package/dist/turbopack-KRKECGY2.cjs +55 -0
- package/dist/turbopack-KRKECGY2.cjs.map +1 -0
- package/dist/{types-59251814.d.ts → types-8b0edd78.d.ts} +7 -0
- package/dist/webpack-NPZNXRNL.js +92 -0
- package/dist/webpack-NPZNXRNL.js.map +1 -0
- package/dist/webpack-TTZDARNY.cjs +92 -0
- package/dist/webpack-TTZDARNY.cjs.map +1 -0
- package/package.json +9 -2
package/dist/host/html.js
CHANGED
|
@@ -1,2376 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
init_constants();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// src/utils/abort.ts
|
|
37
|
-
function isAbortError(error) {
|
|
38
|
-
if (error instanceof DOMException && error.name === "AbortError") {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
|
|
42
|
-
const e = error;
|
|
43
|
-
return typeof e.code === "number" || e.constructor?.name === "DOMException";
|
|
44
|
-
}
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
var init_abort = __esm({
|
|
48
|
-
"src/utils/abort.ts"() {
|
|
49
|
-
"use strict";
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// src/utils/error.ts
|
|
54
|
-
function multipleRemoteComponentsError(url) {
|
|
55
|
-
return new RemoteComponentsError(
|
|
56
|
-
`Multiple Remote Components found at "${url}". When a page exposes multiple Remote Components you must specify the "name" prop to select which one to load.`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
function failedToFetchRemoteComponentError(url, { status, statusText }, help = "Is the URL correct and accessible?") {
|
|
60
|
-
return new RemoteComponentsError(
|
|
61
|
-
`Failed to fetch Remote Component from "${url}". ${help}`,
|
|
62
|
-
{ cause: new Error(`${status} ${statusText}`) }
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
|
|
66
|
-
const isProxied = isProxiedUrl(resolvedUrl.href);
|
|
67
|
-
if (isProxied && res) {
|
|
68
|
-
const body = await res.text().catch(() => "");
|
|
69
|
-
return failedProxyFetchError(
|
|
70
|
-
originalUrl,
|
|
71
|
-
resolvedUrl.href,
|
|
72
|
-
res.status,
|
|
73
|
-
body
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
const fallback = failedToFetchRemoteComponentError(
|
|
77
|
-
originalUrl,
|
|
78
|
-
res ?? { status: 0, statusText: "No Response" }
|
|
79
|
-
);
|
|
80
|
-
if (!res)
|
|
81
|
-
return fallback;
|
|
82
|
-
try {
|
|
83
|
-
const body = await res.text();
|
|
84
|
-
const parser = new DOMParser();
|
|
85
|
-
const doc = parser.parseFromString(body, "text/html");
|
|
86
|
-
const errorTemplate = doc.querySelector(
|
|
87
|
-
"template[data-next-error-message]"
|
|
88
|
-
);
|
|
89
|
-
const errorMessage = errorTemplate?.getAttribute("data-next-error-message");
|
|
90
|
-
if (errorMessage) {
|
|
91
|
-
const error = new RemoteComponentsError(errorMessage);
|
|
92
|
-
const errorStack = errorTemplate?.getAttribute("data-next-error-stack");
|
|
93
|
-
if (errorStack) {
|
|
94
|
-
error.stack = errorStack;
|
|
95
|
-
}
|
|
96
|
-
return error;
|
|
97
|
-
}
|
|
98
|
-
} catch (parseError) {
|
|
99
|
-
if (isAbortError(parseError))
|
|
100
|
-
throw parseError;
|
|
101
|
-
}
|
|
102
|
-
return fallback;
|
|
103
|
-
}
|
|
104
|
-
function failedProxiedAssetError(kind, url, resolvedUrl) {
|
|
105
|
-
return new RemoteComponentsError(
|
|
106
|
-
`Failed to load ${kind} "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured, "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher, and the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
110
|
-
if (status === 404) {
|
|
111
|
-
return new RemoteComponentsError(
|
|
112
|
-
`Could not proxy the request to "${originalUrl}" \u2014 the proxy endpoint "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" returned 404.
|
|
113
|
-
|
|
114
|
-
The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
115
|
-
|
|
116
|
-
Proxying requires two pieces:
|
|
117
|
-
1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
|
|
118
|
-
2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
119
|
-
|
|
120
|
-
Docs: ${CORS_DOCS_URL}`
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
if (status === 403) {
|
|
124
|
-
const detail = responseBody ? ` ${responseBody}` : "";
|
|
125
|
-
return new RemoteComponentsError(
|
|
126
|
-
`Proxied request to "${proxyUrl}" was forbidden.${detail} See: ${CORS_DOCS_URL}`
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
return new RemoteComponentsError(
|
|
130
|
-
`Proxied request for "${originalUrl}" via "${proxyUrl}" failed with status ${status}. See: ${CORS_DOCS_URL}`
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
var RemoteComponentsError;
|
|
134
|
-
var init_error = __esm({
|
|
135
|
-
"src/utils/error.ts"() {
|
|
136
|
-
"use strict";
|
|
137
|
-
init_protected_rc_fallback();
|
|
138
|
-
init_abort();
|
|
139
|
-
init_constants();
|
|
140
|
-
RemoteComponentsError = class extends Error {
|
|
141
|
-
code = "REMOTE_COMPONENTS_ERROR";
|
|
142
|
-
constructor(message, options) {
|
|
143
|
-
super(message, options);
|
|
144
|
-
this.name = "RemoteComponentsError";
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
// src/utils/logger.ts
|
|
151
|
-
function logDebug(location2, message) {
|
|
152
|
-
if (DEBUG) {
|
|
153
|
-
console.debug(`[${PREFIX}:${location2}]: ${message}`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function logWarn(location2, message) {
|
|
157
|
-
console.warn(`[${PREFIX}:${location2}]: ${message}`);
|
|
158
|
-
}
|
|
159
|
-
function logError(location2, message, cause) {
|
|
160
|
-
console.error(
|
|
161
|
-
new RemoteComponentsError(`[${PREFIX}:${location2}]: ${message}`, {
|
|
162
|
-
cause
|
|
163
|
-
})
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
function warnCrossOriginFetchError(logLocation, url) {
|
|
167
|
-
try {
|
|
168
|
-
const parsed = typeof url === "string" ? new URL(url) : url;
|
|
169
|
-
if (typeof location === "undefined" || parsed.origin === location.origin) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
logWarn(
|
|
173
|
-
logLocation,
|
|
174
|
-
`Failed to fetch cross-origin resource "${parsed.href}". To load assets from a protected deployment, two steps are required: (1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. See: ${CORS_DOCS_URL}`
|
|
175
|
-
);
|
|
176
|
-
} catch {
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
var PREFIX, DEBUG;
|
|
180
|
-
var init_logger = __esm({
|
|
181
|
-
"src/utils/logger.ts"() {
|
|
182
|
-
"use strict";
|
|
183
|
-
init_constants();
|
|
184
|
-
init_error();
|
|
185
|
-
PREFIX = "remote-components";
|
|
186
|
-
DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true" || typeof process !== "undefined" && process.env.RC_DEBUG === "true";
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
// src/utils/index.ts
|
|
191
|
-
function escapeString(str) {
|
|
192
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
193
|
-
}
|
|
194
|
-
function computeScopedName(name, options) {
|
|
195
|
-
return options.isCrossOrigin ? `${name}_${escapeString(options.remoteHost.toLowerCase())}` : name;
|
|
196
|
-
}
|
|
197
|
-
var init_utils = __esm({
|
|
198
|
-
"src/utils/index.ts"() {
|
|
199
|
-
"use strict";
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// src/runtime/constants.ts
|
|
204
|
-
function getBundleKey(bundle) {
|
|
205
|
-
return escapeString(bundle);
|
|
206
|
-
}
|
|
207
|
-
var DEFAULT_BUNDLE_NAME, DEFAULT_COMPONENT_NAME, DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT;
|
|
208
|
-
var init_constants2 = __esm({
|
|
209
|
-
"src/runtime/constants.ts"() {
|
|
210
|
-
"use strict";
|
|
211
|
-
init_utils();
|
|
212
|
-
DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
|
|
213
|
-
DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
|
|
214
|
-
DEFAULT_ROUTE = "/";
|
|
215
|
-
RUNTIME_WEBPACK = "webpack";
|
|
216
|
-
RUNTIME_TURBOPACK = "turbopack";
|
|
217
|
-
RUNTIME_SCRIPT = "script";
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
// src/runtime/namespace.ts
|
|
222
|
-
function getNamespace() {
|
|
223
|
-
const g = globalThis;
|
|
224
|
-
const existing = g.__remote_components__;
|
|
225
|
-
if (existing) {
|
|
226
|
-
return existing;
|
|
227
|
-
}
|
|
228
|
-
const ns = {
|
|
229
|
-
scopes: /* @__PURE__ */ new Map(),
|
|
230
|
-
chunkCache: {},
|
|
231
|
-
mountFns: {},
|
|
232
|
-
unmountFns: {},
|
|
233
|
-
bundleUrls: {},
|
|
234
|
-
moduleRegistry: {},
|
|
235
|
-
dispatcherRuntime: void 0,
|
|
236
|
-
hostSharedModules: {},
|
|
237
|
-
cssCache: {},
|
|
238
|
-
shadowRoots: {}
|
|
239
|
-
};
|
|
240
|
-
const nsRecord = ns;
|
|
241
|
-
for (const { global, prop } of LEGACY_ALIASES) {
|
|
242
|
-
const legacyValue = g[global];
|
|
243
|
-
if (legacyValue != null) {
|
|
244
|
-
nsRecord[prop] = legacyValue;
|
|
245
|
-
}
|
|
246
|
-
g[global] = ns[prop];
|
|
247
|
-
}
|
|
248
|
-
const gRecord = g;
|
|
249
|
-
for (const key of Object.keys(gRecord)) {
|
|
250
|
-
if (key.startsWith(SHADOW_ROOT_PREFIX)) {
|
|
251
|
-
const suffix = key.slice(SHADOW_ROOT_PREFIX.length);
|
|
252
|
-
ns.shadowRoots[suffix] = gRecord[key];
|
|
253
|
-
delete gRecord[key];
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
g.__remote_components__ = ns;
|
|
257
|
-
return ns;
|
|
258
|
-
}
|
|
259
|
-
var SHADOW_ROOT_PREFIX, LEGACY_ALIASES;
|
|
260
|
-
var init_namespace = __esm({
|
|
261
|
-
"src/runtime/namespace.ts"() {
|
|
262
|
-
"use strict";
|
|
263
|
-
SHADOW_ROOT_PREFIX = "__remote_components_shadowroot_";
|
|
264
|
-
LEGACY_ALIASES = [
|
|
265
|
-
{ global: "__remote_component_scopes__", prop: "scopes" },
|
|
266
|
-
{
|
|
267
|
-
global: "__remote_components_turbopack_chunk_loader_promise__",
|
|
268
|
-
prop: "chunkCache"
|
|
269
|
-
},
|
|
270
|
-
{ global: "__remote_script_entrypoint_mount__", prop: "mountFns" },
|
|
271
|
-
{ global: "__remote_script_entrypoint_unmount__", prop: "unmountFns" },
|
|
272
|
-
{ global: "__remote_bundle_url__", prop: "bundleUrls" },
|
|
273
|
-
{ global: "__rc_module_registry__", prop: "moduleRegistry" },
|
|
274
|
-
{
|
|
275
|
-
global: "__remote_component_host_shared_modules__",
|
|
276
|
-
prop: "hostSharedModules"
|
|
277
|
-
},
|
|
278
|
-
{ global: "__remote_next_css__", prop: "cssCache" }
|
|
279
|
-
];
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
// src/runtime/patterns.ts
|
|
284
|
-
function collapseDoubleSlashes(path) {
|
|
285
|
-
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
286
|
-
}
|
|
287
|
-
var REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE, DOUBLE_SLASH_RE;
|
|
288
|
-
var init_patterns = __esm({
|
|
289
|
-
"src/runtime/patterns.ts"() {
|
|
290
|
-
"use strict";
|
|
291
|
-
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
292
|
-
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
293
|
-
DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
// src/runtime/turbopack/remote-scope.ts
|
|
298
|
-
function getRegistry() {
|
|
299
|
-
return getNamespace().scopes;
|
|
300
|
-
}
|
|
301
|
-
function createScope(name, url, runtime, resolveClientUrl) {
|
|
302
|
-
const isCrossOrigin = url.origin !== location.origin;
|
|
303
|
-
const scopedName = computeScopedName(name, {
|
|
304
|
-
remoteHost: url.host,
|
|
305
|
-
isCrossOrigin
|
|
306
|
-
});
|
|
307
|
-
const globalKey = getBundleKey(scopedName);
|
|
308
|
-
return {
|
|
309
|
-
name,
|
|
310
|
-
scopedName,
|
|
311
|
-
globalKey,
|
|
312
|
-
url,
|
|
313
|
-
runtime,
|
|
314
|
-
resolveClientUrl,
|
|
315
|
-
moduleCache: {},
|
|
316
|
-
sharedModules: {},
|
|
317
|
-
moduleGlobal: {},
|
|
318
|
-
turbopackModules: []
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
function registerScope(scope) {
|
|
322
|
-
const registry = getRegistry();
|
|
323
|
-
registry.set(scope.scopedName, scope);
|
|
324
|
-
if (scope.scopedName !== scope.name) {
|
|
325
|
-
const existing = registry.get(scope.name);
|
|
326
|
-
if (existing && existing.scopedName !== scope.scopedName) {
|
|
327
|
-
logWarn(
|
|
328
|
-
"RemoteScope",
|
|
329
|
-
`Plain name "${scope.name}" already registered by scope "${existing.scopedName}" \u2014 overwriting with "${scope.scopedName}". Static hosts will only resolve the latest one.`
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
registry.set(scope.name, scope);
|
|
333
|
-
}
|
|
334
|
-
logDebug(
|
|
335
|
-
"RemoteScope",
|
|
336
|
-
`Registered scope "${scope.scopedName}" (${registry.size} total)`
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
function getScope(name) {
|
|
340
|
-
return getRegistry().get(name);
|
|
341
|
-
}
|
|
342
|
-
function formatRemoteId(scope, path) {
|
|
343
|
-
return `[${scope.scopedName}] ${path}`;
|
|
344
|
-
}
|
|
345
|
-
function parseRemoteId(id) {
|
|
346
|
-
const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;
|
|
347
|
-
if (groups?.bundle && groups.id) {
|
|
348
|
-
return {
|
|
349
|
-
bundle: groups.bundle,
|
|
350
|
-
path: groups.id,
|
|
351
|
-
prefix: groups.prefix ?? ""
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
return { bundle: "default", path: id, prefix: "" };
|
|
355
|
-
}
|
|
356
|
-
var init_remote_scope = __esm({
|
|
357
|
-
"src/runtime/turbopack/remote-scope.ts"() {
|
|
358
|
-
"use strict";
|
|
359
|
-
init_constants2();
|
|
360
|
-
init_namespace();
|
|
361
|
-
init_patterns();
|
|
362
|
-
init_utils();
|
|
363
|
-
init_logger();
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
// src/host/shared/remote-image-loader.ts
|
|
368
|
-
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
369
|
-
const loader = Object.assign(
|
|
370
|
-
({
|
|
371
|
-
config,
|
|
372
|
-
src,
|
|
373
|
-
width,
|
|
374
|
-
quality
|
|
375
|
-
}) => {
|
|
376
|
-
const q = quality ?? 75;
|
|
377
|
-
const remoteOrigin = getScope(bundle)?.url.origin ?? "";
|
|
378
|
-
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
379
|
-
const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
|
|
380
|
-
const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
381
|
-
return resolveClientUrl?.(url) ?? url;
|
|
382
|
-
},
|
|
383
|
-
// Signals to getImgProps that this is a default loader (not a user-defined
|
|
384
|
-
// one), enabling srcSet generation with device/image sizes from the config.
|
|
385
|
-
{ __next_img_default: true }
|
|
386
|
-
);
|
|
387
|
-
return loader;
|
|
388
|
-
}
|
|
389
|
-
var init_remote_image_loader = __esm({
|
|
390
|
-
"src/host/shared/remote-image-loader.ts"() {
|
|
391
|
-
"use strict";
|
|
392
|
-
init_remote_scope();
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
// src/host/shared/polyfill.tsx
|
|
397
|
-
import { jsx } from "react/jsx-runtime";
|
|
398
|
-
function sharedPolyfills(shared, resolveClientUrl) {
|
|
399
|
-
const hostShared = getNamespace().hostSharedModules;
|
|
400
|
-
const polyfill = {
|
|
401
|
-
"next/dist/client/components/navigation": hostShared["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
402
|
-
useRouter() {
|
|
403
|
-
return {
|
|
404
|
-
push: (routerUrl) => {
|
|
405
|
-
history.pushState({}, "", routerUrl);
|
|
406
|
-
},
|
|
407
|
-
replace: (routerUrl) => {
|
|
408
|
-
history.replaceState({}, "", routerUrl);
|
|
409
|
-
},
|
|
410
|
-
back: () => {
|
|
411
|
-
history.back();
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
},
|
|
415
|
-
usePathname() {
|
|
416
|
-
return location.pathname;
|
|
417
|
-
},
|
|
418
|
-
useParams() {
|
|
419
|
-
return {};
|
|
420
|
-
},
|
|
421
|
-
useSearchParams() {
|
|
422
|
-
return new URLSearchParams(location.search);
|
|
423
|
-
},
|
|
424
|
-
useSelectedLayoutSegment() {
|
|
425
|
-
return null;
|
|
426
|
-
},
|
|
427
|
-
useSelectedLayoutSegments() {
|
|
428
|
-
return [];
|
|
429
|
-
},
|
|
430
|
-
__esModule: true
|
|
431
|
-
})),
|
|
432
|
-
"next/dist/client/app-dir/link": hostShared["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
|
|
433
|
-
default: ({
|
|
434
|
-
scroll: _,
|
|
435
|
-
replace,
|
|
436
|
-
prefetch,
|
|
437
|
-
onNavigate,
|
|
438
|
-
children,
|
|
439
|
-
...props
|
|
440
|
-
}) => {
|
|
441
|
-
if (prefetch) {
|
|
442
|
-
logWarn(
|
|
443
|
-
"Polyfill",
|
|
444
|
-
"Next.js Link prefetch is not supported in remote components"
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
return /* @__PURE__ */ jsx(
|
|
448
|
-
"a",
|
|
449
|
-
{
|
|
450
|
-
...props,
|
|
451
|
-
href: props.href,
|
|
452
|
-
onClick: (e) => {
|
|
453
|
-
e.preventDefault();
|
|
454
|
-
let preventDefaulted = false;
|
|
455
|
-
e.preventDefault = () => {
|
|
456
|
-
preventDefaulted = true;
|
|
457
|
-
e.defaultPrevented = true;
|
|
458
|
-
};
|
|
459
|
-
if (typeof props.onClick === "function") {
|
|
460
|
-
props.onClick(e);
|
|
461
|
-
}
|
|
462
|
-
onNavigate?.(e);
|
|
463
|
-
if (preventDefaulted) {
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
if (replace) {
|
|
467
|
-
history.replaceState({}, "", props.href);
|
|
468
|
-
} else {
|
|
469
|
-
history.pushState({}, "", props.href);
|
|
470
|
-
}
|
|
471
|
-
},
|
|
472
|
-
suppressHydrationWarning: true,
|
|
473
|
-
children: children ?? null
|
|
474
|
-
}
|
|
475
|
-
);
|
|
476
|
-
},
|
|
477
|
-
useLinkStatus() {
|
|
478
|
-
return { pending: false };
|
|
479
|
-
},
|
|
480
|
-
__esModule: true
|
|
481
|
-
})),
|
|
482
|
-
"next/dist/client/app-dir/form": hostShared["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
|
|
483
|
-
default: () => {
|
|
484
|
-
throw new Error("Next.js <Form> component not implemented");
|
|
485
|
-
},
|
|
486
|
-
__esModule: true
|
|
487
|
-
})),
|
|
488
|
-
// Instead of replacing next/image entirely, we let the real Next.js Image
|
|
489
|
-
// component load from the remote bundle and only replace its default loader.
|
|
490
|
-
// This gives us full next/image fidelity (fill, priority, srcSet, blur
|
|
491
|
-
// placeholders, error handling) while routing image optimization through the
|
|
492
|
-
// remote app's /_next/image endpoint.
|
|
493
|
-
"next/dist/shared/lib/image-loader": hostShared["next/dist/shared/lib/image-loader"] ?? shared?.["next/dist/shared/lib/image-loader"] ?? ((bundle) => Promise.resolve({
|
|
494
|
-
default: createRemoteImageLoader(bundle, resolveClientUrl),
|
|
495
|
-
__esModule: true
|
|
496
|
-
})),
|
|
497
|
-
"next/dist/client/script": hostShared["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
|
|
498
|
-
// TODO: implement <Script> component for non-Next.js host applications
|
|
499
|
-
// do not throw an error for now
|
|
500
|
-
default: () => null,
|
|
501
|
-
__esModule: true
|
|
502
|
-
})),
|
|
503
|
-
"next/router": hostShared["next/router"] ?? shared?.["next/router"] ?? (() => (
|
|
504
|
-
// TODO: incomplete implementation
|
|
505
|
-
Promise.resolve({
|
|
506
|
-
useRouter() {
|
|
507
|
-
return {
|
|
508
|
-
push: (routerUrl) => {
|
|
509
|
-
history.pushState({}, "", routerUrl);
|
|
510
|
-
},
|
|
511
|
-
replace: (routerUrl) => {
|
|
512
|
-
history.replaceState({}, "", routerUrl);
|
|
513
|
-
},
|
|
514
|
-
back: () => {
|
|
515
|
-
history.back();
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
},
|
|
519
|
-
__esModule: true
|
|
520
|
-
})
|
|
521
|
-
)),
|
|
522
|
-
"next/dist/build/polyfills/process": () => Promise.resolve({
|
|
523
|
-
default: {
|
|
524
|
-
env: {
|
|
525
|
-
NODE_ENV: "production"
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
__esModule: true
|
|
529
|
-
})
|
|
530
|
-
};
|
|
531
|
-
polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
|
|
532
|
-
polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
|
|
533
|
-
polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
|
|
534
|
-
polyfill["next/dist/esm/shared/lib/image-loader"] = polyfill["next/dist/shared/lib/image-loader"];
|
|
535
|
-
polyfill["next/script"] = polyfill["next/dist/client/script"];
|
|
536
|
-
return polyfill;
|
|
537
|
-
}
|
|
538
|
-
var init_polyfill = __esm({
|
|
539
|
-
"src/host/shared/polyfill.tsx"() {
|
|
540
|
-
"use strict";
|
|
541
|
-
init_remote_image_loader();
|
|
542
|
-
init_namespace();
|
|
543
|
-
init_logger();
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
// src/host/shared/shared-module-resolver.ts
|
|
548
|
-
function buildCoreShared(userShared) {
|
|
549
|
-
return {
|
|
550
|
-
react: async () => (await import("react")).default,
|
|
551
|
-
"react-dom": async () => (await import("react-dom")).default,
|
|
552
|
-
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
553
|
-
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
554
|
-
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
555
|
-
...userShared
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
function buildHostShared(userShared, resolveClientUrl, options) {
|
|
559
|
-
const self = globalThis;
|
|
560
|
-
const result = {
|
|
561
|
-
...sharedPolyfills(userShared, resolveClientUrl),
|
|
562
|
-
...self.__remote_component_host_shared_modules__,
|
|
563
|
-
...userShared
|
|
564
|
-
};
|
|
565
|
-
if (options?.includeRemoteComponentShared) {
|
|
566
|
-
Object.assign(result, self.__remote_component_shared__);
|
|
567
|
-
}
|
|
568
|
-
return result;
|
|
569
|
-
}
|
|
570
|
-
async function buildWebpackResolve(hostShared, remoteShared, bundle, reactModules, callerTag = "SharedModuleResolver") {
|
|
571
|
-
const resolve = {
|
|
572
|
-
...reactModules,
|
|
573
|
-
...Object.entries(remoteShared).reduce(
|
|
574
|
-
(acc, [key, value]) => {
|
|
575
|
-
if (typeof hostShared[value] !== "undefined") {
|
|
576
|
-
acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
|
|
577
|
-
} else {
|
|
578
|
-
logDebug(
|
|
579
|
-
callerTag,
|
|
580
|
-
`Remote requests "${value}" but host doesn't provide it`
|
|
581
|
-
);
|
|
582
|
-
}
|
|
583
|
-
return acc;
|
|
584
|
-
},
|
|
585
|
-
{}
|
|
586
|
-
)
|
|
587
|
-
};
|
|
588
|
-
await Promise.all(
|
|
589
|
-
Object.entries(resolve).map(async ([key, value]) => {
|
|
590
|
-
if (typeof value === "function") {
|
|
591
|
-
resolve[key] = await value(bundle);
|
|
592
|
-
}
|
|
593
|
-
return Promise.resolve(value);
|
|
594
|
-
})
|
|
595
|
-
);
|
|
596
|
-
return resolve;
|
|
597
|
-
}
|
|
598
|
-
var CORE_REACT_PATH_MAP, VENDOR_SHARED;
|
|
599
|
-
var init_shared_module_resolver = __esm({
|
|
600
|
-
"src/host/shared/shared-module-resolver.ts"() {
|
|
601
|
-
"use strict";
|
|
602
|
-
init_polyfill();
|
|
603
|
-
init_logger();
|
|
604
|
-
CORE_REACT_PATH_MAP = {
|
|
605
|
-
react: "/react/index.js",
|
|
606
|
-
"react/jsx-dev-runtime": "/react/jsx-dev-runtime.js",
|
|
607
|
-
"react/jsx-runtime": "/react/jsx-runtime.js",
|
|
608
|
-
"react-dom": "/react-dom/index.js",
|
|
609
|
-
"react-dom/client": "/react-dom/client.js"
|
|
610
|
-
};
|
|
611
|
-
VENDOR_SHARED = Object.fromEntries(
|
|
612
|
-
Object.entries(CORE_REACT_PATH_MAP).filter(([key]) => key !== "react-dom/client").map(([key, path]) => [key, `'${path}'`])
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
// src/config/webpack/apply-shared-modules.ts
|
|
618
|
-
function applySharedModules(bundle, resolve) {
|
|
619
|
-
logDebug(
|
|
620
|
-
"SharedModules",
|
|
621
|
-
`applySharedModules called for bundle: "${bundle}"`
|
|
622
|
-
);
|
|
623
|
-
logDebug(
|
|
624
|
-
"SharedModules",
|
|
625
|
-
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
626
|
-
);
|
|
627
|
-
const self = globalThis;
|
|
628
|
-
const scope = getScope(bundle);
|
|
629
|
-
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
630
|
-
if (webpackBundle) {
|
|
631
|
-
const modulePaths = Object.keys(
|
|
632
|
-
self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {}
|
|
633
|
-
);
|
|
634
|
-
logDebug(
|
|
635
|
-
"SharedModules",
|
|
636
|
-
`Available module paths for bundle "${bundle}": ${modulePaths}`
|
|
637
|
-
);
|
|
638
|
-
for (const [key, value] of Object.entries(resolve)) {
|
|
639
|
-
const exactIds = modulePaths.filter((p) => p === key);
|
|
640
|
-
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
641
|
-
if (ids.length === 0) {
|
|
642
|
-
logDebug(
|
|
643
|
-
"SharedModules",
|
|
644
|
-
`No matching module path found for shared module "${key}"`
|
|
645
|
-
);
|
|
646
|
-
}
|
|
647
|
-
for (const id of ids) {
|
|
648
|
-
if (webpackBundle.m) {
|
|
649
|
-
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
650
|
-
if (resolvedId !== id) {
|
|
651
|
-
logDebug(
|
|
652
|
-
"SharedModules",
|
|
653
|
-
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
webpackBundle.m[resolvedId] = (module) => {
|
|
657
|
-
module.exports = value;
|
|
658
|
-
};
|
|
659
|
-
} else {
|
|
660
|
-
logWarn(
|
|
661
|
-
"SharedModules",
|
|
662
|
-
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
663
|
-
);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
} else {
|
|
668
|
-
logWarn(
|
|
669
|
-
"SharedModules",
|
|
670
|
-
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
671
|
-
);
|
|
672
|
-
logDebug(
|
|
673
|
-
"SharedModules",
|
|
674
|
-
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
675
|
-
);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
var DEDUPLICATION_SKIPPED;
|
|
679
|
-
var init_apply_shared_modules = __esm({
|
|
680
|
-
"src/config/webpack/apply-shared-modules.ts"() {
|
|
681
|
-
"use strict";
|
|
682
|
-
init_remote_scope();
|
|
683
|
-
init_logger();
|
|
684
|
-
DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
685
|
-
}
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
// src/config/webpack/next-client-pages-loader.ts
|
|
689
|
-
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
690
|
-
const self = globalThis;
|
|
691
|
-
const nextCssOriginal = document.querySelector(
|
|
692
|
-
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
693
|
-
);
|
|
694
|
-
if (nextCssOriginal) {
|
|
695
|
-
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
696
|
-
}
|
|
697
|
-
const nextCss = document.createElement("noscript");
|
|
698
|
-
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
699
|
-
nextCss.setAttribute("data-bundle", bundle);
|
|
700
|
-
nextCss.setAttribute("data-route", route);
|
|
701
|
-
const nextCssEnd = document.createElement("noscript");
|
|
702
|
-
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
703
|
-
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
704
|
-
nextCssEnd.setAttribute("data-route", route);
|
|
705
|
-
document.head.appendChild(nextCssEnd);
|
|
706
|
-
document.head.appendChild(nextCss);
|
|
707
|
-
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
708
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
709
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
710
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
711
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
712
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
713
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
714
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
715
|
-
) ?? ""] ?? -1;
|
|
716
|
-
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
717
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
718
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
719
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
720
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
721
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
722
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
723
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
724
|
-
) ?? ""] ?? -1;
|
|
725
|
-
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
726
|
-
throw new RemoteComponentsError(
|
|
727
|
-
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
728
|
-
);
|
|
729
|
-
}
|
|
730
|
-
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
731
|
-
const selfOriginal = self;
|
|
732
|
-
delete selfOriginal.__NEXT_P;
|
|
733
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
734
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
735
|
-
);
|
|
736
|
-
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
737
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
738
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
739
|
-
);
|
|
740
|
-
}
|
|
741
|
-
if (self.__NEXT_P) {
|
|
742
|
-
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
743
|
-
void 0,
|
|
744
|
-
() => ({ default: null })
|
|
745
|
-
];
|
|
746
|
-
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
747
|
-
void 0,
|
|
748
|
-
() => ({
|
|
749
|
-
default: null
|
|
750
|
-
})
|
|
751
|
-
];
|
|
752
|
-
const { default: Component } = componentLoader();
|
|
753
|
-
const { default: App } = appLoader();
|
|
754
|
-
const cssCache = getNamespace().cssCache;
|
|
755
|
-
if (!cssCache[bundle]) {
|
|
756
|
-
const cssRE = /\.s?css$/;
|
|
757
|
-
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
758
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
759
|
-
});
|
|
760
|
-
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
761
|
-
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
762
|
-
if (id) {
|
|
763
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
764
|
-
}
|
|
765
|
-
});
|
|
766
|
-
const elements = [];
|
|
767
|
-
let node = nextCss.previousSibling;
|
|
768
|
-
while (node && node !== nextCssEnd) {
|
|
769
|
-
elements.push(node);
|
|
770
|
-
node.remove();
|
|
771
|
-
node = nextCss.previousSibling;
|
|
772
|
-
}
|
|
773
|
-
cssCache[bundle] = elements;
|
|
774
|
-
}
|
|
775
|
-
if (styleContainer) {
|
|
776
|
-
const elements = cssCache[bundle];
|
|
777
|
-
elements.forEach((el) => {
|
|
778
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
779
|
-
});
|
|
780
|
-
} else {
|
|
781
|
-
const elements = cssCache[bundle];
|
|
782
|
-
elements.forEach((el) => {
|
|
783
|
-
document.head.appendChild(el);
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
delete self.__NEXT_P;
|
|
787
|
-
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
788
|
-
if (nextCssOriginal) {
|
|
789
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
790
|
-
}
|
|
791
|
-
nextCss.remove();
|
|
792
|
-
nextCssEnd.remove();
|
|
793
|
-
return { Component, App };
|
|
794
|
-
}
|
|
795
|
-
return { Component: null, App: null };
|
|
796
|
-
}
|
|
797
|
-
var init_next_client_pages_loader = __esm({
|
|
798
|
-
"src/config/webpack/next-client-pages-loader.ts"() {
|
|
799
|
-
"use strict";
|
|
800
|
-
init_namespace();
|
|
801
|
-
init_error();
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
// src/runtime/turbopack/patterns.ts
|
|
806
|
-
function stripQuotes(value) {
|
|
807
|
-
if (value.startsWith('"') && value.endsWith('"')) {
|
|
808
|
-
return value.slice(1, -1);
|
|
809
|
-
}
|
|
810
|
-
return value;
|
|
811
|
-
}
|
|
812
|
-
function extractGroup(re, input, group) {
|
|
813
|
-
const raw = re.exec(input)?.groups?.[group];
|
|
814
|
-
return raw ? stripQuotes(raw) : void 0;
|
|
815
|
-
}
|
|
816
|
-
var MODULE_ID_PATTERN, REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_CALLBACK_RE, TURBOPACK_GLOBAL_RE;
|
|
817
|
-
var init_patterns2 = __esm({
|
|
818
|
-
"src/runtime/turbopack/patterns.ts"() {
|
|
819
|
-
"use strict";
|
|
820
|
-
MODULE_ID_PATTERN = '"[^"]+"|[0-9]+';
|
|
821
|
-
REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
822
|
-
REMOTE_SHARED_ASSIGNMENT_RE = new RegExp(
|
|
823
|
-
`\\.TURBOPACK_REMOTE_SHARED\\s*=\\s*await (?:__turbopack_context__|[a-z])\\.A\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
824
|
-
);
|
|
825
|
-
ASYNC_MODULE_LOADER_RE = new RegExp(
|
|
826
|
-
`(?:__turbopack_context__|[a-z])\\.A\\((?<asyncSharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
827
|
-
);
|
|
828
|
-
ASYNC_MODULE_CALLBACK_RE = new RegExp(
|
|
829
|
-
`(?:parentImport|[a-z])\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
830
|
-
);
|
|
831
|
-
TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
// src/runtime/turbopack/chunk-loader.ts
|
|
836
|
-
function loadChunkWithScope(scope, chunkId) {
|
|
837
|
-
logDebug(
|
|
838
|
-
"ChunkLoader",
|
|
839
|
-
`loadChunkWithScope: "${chunkId}" (scope: "${scope.scopedName}")`
|
|
840
|
-
);
|
|
841
|
-
const self = globalThis;
|
|
842
|
-
const ns = getNamespace();
|
|
843
|
-
const { bundle, path, prefix } = parseRemoteId(chunkId);
|
|
844
|
-
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : scope.runtime;
|
|
845
|
-
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
846
|
-
return Promise.resolve(void 0);
|
|
847
|
-
}
|
|
848
|
-
const rawPath = path ? collapseDoubleSlashes(`${prefix}${path}`) : "/";
|
|
849
|
-
const url = new URL(rawPath, scope.url).href;
|
|
850
|
-
if (url.endsWith(".css")) {
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
if (ns.chunkCache[url]) {
|
|
854
|
-
logDebug("ChunkLoader", `Cache hit for "${chunkId}" (url="${url}")`);
|
|
855
|
-
return ns.chunkCache[url];
|
|
856
|
-
}
|
|
857
|
-
const resolvedUrl = scope.resolveClientUrl?.(url) ?? url;
|
|
858
|
-
if (resolvedUrl !== url) {
|
|
859
|
-
logDebug("ChunkLoader", `Proxied chunk URL: "${url}" \u2192 "${resolvedUrl}"`);
|
|
860
|
-
}
|
|
861
|
-
ns.chunkCache[url] = new Promise((resolve, reject) => {
|
|
862
|
-
fetch(resolvedUrl).then((res) => res.text()).then((code) => {
|
|
863
|
-
const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
|
|
864
|
-
if (hasTurbopack) {
|
|
865
|
-
return handleTurbopackChunk(code, scope, url);
|
|
866
|
-
}
|
|
867
|
-
}).then(resolve).catch((error) => {
|
|
868
|
-
const isProxied = isProxiedUrl(resolvedUrl);
|
|
869
|
-
if (isProxied) {
|
|
870
|
-
reject(failedProxiedAssetError("chunk", url, resolvedUrl));
|
|
871
|
-
} else {
|
|
872
|
-
warnCrossOriginFetchError("ChunkLoader", url);
|
|
873
|
-
reject(error);
|
|
874
|
-
}
|
|
875
|
-
});
|
|
876
|
-
});
|
|
877
|
-
return ns.chunkCache[url];
|
|
878
|
-
}
|
|
879
|
-
function createChunkDispatcher() {
|
|
880
|
-
return function __chunk_dispatcher__(chunkId, scriptBundle) {
|
|
881
|
-
logDebug("ChunkDispatcher", `Dispatching chunk: "${chunkId}"`);
|
|
882
|
-
const { bundle } = parseRemoteId(chunkId);
|
|
883
|
-
const bundleName = bundle || scriptBundle || "default";
|
|
884
|
-
const scope = getScope(bundleName);
|
|
885
|
-
logDebug(
|
|
886
|
-
"ChunkDispatcher",
|
|
887
|
-
`Scope resolution: bundle="${bundleName}", scope=${scope?.scopedName ?? "null"}`
|
|
888
|
-
);
|
|
889
|
-
if (!scope) {
|
|
890
|
-
logWarn("ChunkDispatcher", `No scope found for bundle "${bundleName}"`);
|
|
891
|
-
return Promise.resolve(void 0);
|
|
892
|
-
}
|
|
893
|
-
return loadChunkWithScope(scope, chunkId);
|
|
894
|
-
};
|
|
895
|
-
}
|
|
896
|
-
async function handleTurbopackChunk(code, scope, url) {
|
|
897
|
-
if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
|
|
898
|
-
const preloadLinks = document.querySelectorAll(
|
|
899
|
-
`link[rel="preload"][href="${new URL(url).pathname}"]`
|
|
900
|
-
);
|
|
901
|
-
preloadLinks.forEach((preloadLink) => preloadLink.remove());
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
const self = globalThis;
|
|
905
|
-
const { globalKey } = scope;
|
|
906
|
-
const transformedCode = code.replace(
|
|
907
|
-
/globalThis\[\s*["']TURBOPACK["']\s*\]/g,
|
|
908
|
-
`globalThis["TURBOPACK_${globalKey}"]`
|
|
909
|
-
).replace(
|
|
910
|
-
/self\[\s*["']TURBOPACK["']\s*\]/g,
|
|
911
|
-
`self["TURBOPACK_${globalKey}"]`
|
|
912
|
-
).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${globalKey}`).replace(/self\.TURBOPACK(?!_)/g, `self.TURBOPACK_${globalKey}`).replace(
|
|
913
|
-
/TURBOPACK_WORKER_LOCATION/g,
|
|
914
|
-
`TURBOPACK_WORKER_LOCATION_${globalKey}`
|
|
915
|
-
).replace(
|
|
916
|
-
/TURBOPACK_NEXT_CHUNK_URLS/g,
|
|
917
|
-
`TURBOPACK_NEXT_CHUNK_URLS_${globalKey}`
|
|
918
|
-
).replace(
|
|
919
|
-
/TURBOPACK_CHUNK_UPDATE_LISTENERS/g,
|
|
920
|
-
`TURBOPACK_CHUNK_UPDATE_LISTENERS_${globalKey}`
|
|
921
|
-
).replace(/__next_require__/g, `__${globalKey}_next_require__`).replace(
|
|
922
|
-
/\/\/# sourceMappingURL=(?<name>.+)(?<optional>\._)?\.js\.map/g,
|
|
923
|
-
`//# sourceMappingURL=${new URL(".", new URL(url, scope.url)).href}$1$2.js.map`
|
|
924
|
-
);
|
|
925
|
-
if (!self[`TURBOPACK_${globalKey}`]) {
|
|
926
|
-
const wrapPush = (target) => {
|
|
927
|
-
const originalPush = target.push;
|
|
928
|
-
if (typeof originalPush !== "function")
|
|
929
|
-
return target;
|
|
930
|
-
target.push = (...items) => {
|
|
931
|
-
for (const item of items) {
|
|
932
|
-
if (Array.isArray(item)) {
|
|
933
|
-
for (const entry of item) {
|
|
934
|
-
scope.turbopackModules.push(entry);
|
|
935
|
-
}
|
|
936
|
-
} else {
|
|
937
|
-
scope.turbopackModules.push(item);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
return originalPush.apply(target, items);
|
|
941
|
-
};
|
|
942
|
-
return target;
|
|
943
|
-
};
|
|
944
|
-
const globalProp = `TURBOPACK_${globalKey}`;
|
|
945
|
-
let currentValue = wrapPush([]);
|
|
946
|
-
Object.defineProperty(self, globalProp, {
|
|
947
|
-
get() {
|
|
948
|
-
return currentValue;
|
|
949
|
-
},
|
|
950
|
-
set(newValue) {
|
|
951
|
-
if (newValue && typeof newValue === "object") {
|
|
952
|
-
wrapPush(newValue);
|
|
953
|
-
}
|
|
954
|
-
currentValue = newValue;
|
|
955
|
-
},
|
|
956
|
-
configurable: true,
|
|
957
|
-
enumerable: true
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
await new Promise((scriptResolve, scriptReject) => {
|
|
961
|
-
const blob = new Blob([transformedCode], {
|
|
962
|
-
type: "application/javascript; charset=UTF-8"
|
|
963
|
-
});
|
|
964
|
-
const scriptUrl = URL.createObjectURL(blob);
|
|
965
|
-
const script = document.createElement("script");
|
|
966
|
-
script.setAttribute("data-turbopack-src", url);
|
|
967
|
-
script.src = scriptUrl;
|
|
968
|
-
script.async = true;
|
|
969
|
-
script.onload = () => {
|
|
970
|
-
URL.revokeObjectURL(scriptUrl);
|
|
971
|
-
scriptResolve(void 0);
|
|
972
|
-
script.remove();
|
|
973
|
-
};
|
|
974
|
-
script.onerror = () => {
|
|
975
|
-
URL.revokeObjectURL(scriptUrl);
|
|
976
|
-
scriptReject(
|
|
977
|
-
new RemoteComponentsError(
|
|
978
|
-
`Failed to load <script src="${script.src}"> for Remote Component. Check the URL is correct.`
|
|
979
|
-
)
|
|
980
|
-
);
|
|
981
|
-
script.remove();
|
|
982
|
-
};
|
|
983
|
-
document.head.appendChild(script);
|
|
984
|
-
});
|
|
985
|
-
const chunkLists = self[`TURBOPACK_${globalKey}_CHUNK_LISTS`];
|
|
986
|
-
const loadChunkPromises = [];
|
|
987
|
-
while (chunkLists?.length) {
|
|
988
|
-
const { chunks } = chunkLists.shift() ?? { chunks: [] };
|
|
989
|
-
if (chunks.length > 0) {
|
|
990
|
-
for (const id of chunks) {
|
|
991
|
-
const baseUrl = url.slice(0, url.indexOf("/_next"));
|
|
992
|
-
const chunkLoadResult = loadChunkWithScope(
|
|
993
|
-
scope,
|
|
994
|
-
formatRemoteId(scope, `${baseUrl}/_next/${id}`)
|
|
995
|
-
);
|
|
996
|
-
if (chunkLoadResult) {
|
|
997
|
-
loadChunkPromises.push(chunkLoadResult);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
if (loadChunkPromises.length > 0) {
|
|
1003
|
-
await Promise.all(loadChunkPromises);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
var init_chunk_loader = __esm({
|
|
1007
|
-
"src/runtime/turbopack/chunk-loader.ts"() {
|
|
1008
|
-
"use strict";
|
|
1009
|
-
init_constants2();
|
|
1010
|
-
init_namespace();
|
|
1011
|
-
init_patterns();
|
|
1012
|
-
init_protected_rc_fallback();
|
|
1013
|
-
init_error();
|
|
1014
|
-
init_logger();
|
|
1015
|
-
init_patterns2();
|
|
1016
|
-
init_remote_scope();
|
|
1017
|
-
}
|
|
1018
|
-
});
|
|
1019
|
-
|
|
1020
|
-
// src/runtime/turbopack/shared-modules.ts
|
|
1021
|
-
function getTurbopackModules(scope) {
|
|
1022
|
-
if (scope.turbopackModules.length > 0) {
|
|
1023
|
-
return scope.turbopackModules;
|
|
1024
|
-
}
|
|
1025
|
-
const self = globalThis;
|
|
1026
|
-
const raw = self[`TURBOPACK_${scope.globalKey}`];
|
|
1027
|
-
if (!raw)
|
|
1028
|
-
return void 0;
|
|
1029
|
-
if (Array.isArray(raw)) {
|
|
1030
|
-
return raw.flat();
|
|
1031
|
-
}
|
|
1032
|
-
return Object.entries(raw).flat();
|
|
1033
|
-
}
|
|
1034
|
-
async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}) {
|
|
1035
|
-
const allModules = getTurbopackModules(scope);
|
|
1036
|
-
logDebug(
|
|
1037
|
-
"SharedModules",
|
|
1038
|
-
`initializeSharedModules: scope="${scope.scopedName}", allModules=${allModules ? allModules.length : "null"}, hostShared=[${Object.keys(hostShared).join(", ")}], remoteShared=${JSON.stringify(remoteShared)}`
|
|
1039
|
-
);
|
|
1040
|
-
let sharedModuleInitializer = null;
|
|
1041
|
-
if (allModules) {
|
|
1042
|
-
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
1043
|
-
if (typeof idOrFunc !== "function") {
|
|
1044
|
-
return false;
|
|
1045
|
-
}
|
|
1046
|
-
const funcCode = idOrFunc.toString();
|
|
1047
|
-
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
1048
|
-
});
|
|
1049
|
-
if (sharedModuleInitializerIndex > 0) {
|
|
1050
|
-
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1051
|
-
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1052
|
-
const sharedModuleId = extractGroup(
|
|
1053
|
-
REMOTE_SHARED_ASSIGNMENT_RE,
|
|
1054
|
-
sharedModuleInitializerCode,
|
|
1055
|
-
"sharedModuleId"
|
|
1056
|
-
);
|
|
1057
|
-
if (sharedModuleId) {
|
|
1058
|
-
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1059
|
-
scope,
|
|
1060
|
-
sharedModuleId,
|
|
1061
|
-
formatRemoteId(scope, String(sharedModuleInitializerId))
|
|
1062
|
-
);
|
|
1063
|
-
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
if (sharedModuleInitializer) {
|
|
1067
|
-
const { shared } = await sharedModuleInitializer;
|
|
1068
|
-
const sharedModuleIds = extractSharedModuleIds(shared, scope);
|
|
1069
|
-
logDebug(
|
|
1070
|
-
"SharedModules",
|
|
1071
|
-
`Resolved shared modules for scope="${scope.scopedName}": ${JSON.stringify(sharedModuleIds)}`
|
|
1072
|
-
);
|
|
1073
|
-
return Promise.all(
|
|
1074
|
-
Object.entries(sharedModuleIds).map(async ([id, module]) => {
|
|
1075
|
-
if (hostShared[module]) {
|
|
1076
|
-
scope.sharedModules[id] = await hostShared[module](scope.name);
|
|
1077
|
-
} else {
|
|
1078
|
-
logError(
|
|
1079
|
-
"SharedModules",
|
|
1080
|
-
`Host shared module "${module}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1081
|
-
);
|
|
1082
|
-
}
|
|
1083
|
-
})
|
|
1084
|
-
);
|
|
1085
|
-
}
|
|
1086
|
-
logWarn(
|
|
1087
|
-
"SharedModules",
|
|
1088
|
-
`No shared module initializer found in bundle for scope="${scope.scopedName}" \u2014 falling back to remoteShared mapping`
|
|
1089
|
-
);
|
|
1090
|
-
} else {
|
|
1091
|
-
logWarn(
|
|
1092
|
-
"SharedModules",
|
|
1093
|
-
`No TURBOPACK modules found for scope="${scope.scopedName}" (TURBOPACK_${scope.globalKey} is empty)`
|
|
1094
|
-
);
|
|
1095
|
-
}
|
|
1096
|
-
return Promise.all(
|
|
1097
|
-
Object.entries(remoteShared).map(async ([id, module]) => {
|
|
1098
|
-
if (hostShared[module]) {
|
|
1099
|
-
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1100
|
-
scope.sharedModules[normalizedId] = await hostShared[module](
|
|
1101
|
-
scope.name
|
|
1102
|
-
);
|
|
1103
|
-
} else {
|
|
1104
|
-
logError(
|
|
1105
|
-
"SharedModules",
|
|
1106
|
-
`Shared module "${module}" not found for "${scope.name}". ${DEDUPLICATION_WARNING}`
|
|
1107
|
-
);
|
|
1108
|
-
}
|
|
1109
|
-
})
|
|
1110
|
-
);
|
|
1111
|
-
}
|
|
1112
|
-
function extractSharedModuleIds(shared, scope) {
|
|
1113
|
-
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1114
|
-
const asyncSharedModuleId = extractGroup(
|
|
1115
|
-
ASYNC_MODULE_LOADER_RE,
|
|
1116
|
-
value.toString(),
|
|
1117
|
-
"asyncSharedModuleId"
|
|
1118
|
-
);
|
|
1119
|
-
if (asyncSharedModuleId) {
|
|
1120
|
-
const asyncSharedModule = findModuleInit(
|
|
1121
|
-
getTurbopackModules(scope),
|
|
1122
|
-
asyncSharedModuleId
|
|
1123
|
-
);
|
|
1124
|
-
if (asyncSharedModule) {
|
|
1125
|
-
const sharedModuleId = extractGroup(
|
|
1126
|
-
ASYNC_MODULE_CALLBACK_RE,
|
|
1127
|
-
asyncSharedModule.toString(),
|
|
1128
|
-
"sharedModuleId"
|
|
1129
|
-
);
|
|
1130
|
-
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1131
|
-
"__remote_shared_module_",
|
|
1132
|
-
""
|
|
1133
|
-
);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
return acc;
|
|
1137
|
-
}, {});
|
|
1138
|
-
}
|
|
1139
|
-
function getSharedModule(scope, id) {
|
|
1140
|
-
const idStr = String(id);
|
|
1141
|
-
if (scope.sharedModules[idStr] !== void 0) {
|
|
1142
|
-
return scope.sharedModules[idStr];
|
|
1143
|
-
}
|
|
1144
|
-
for (const [key, value] of Object.entries(scope.sharedModules)) {
|
|
1145
|
-
if (typeof value !== "undefined" && idStr !== key && idStr.endsWith(key)) {
|
|
1146
|
-
return value;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
return null;
|
|
1150
|
-
}
|
|
1151
|
-
var DEDUPLICATION_WARNING;
|
|
1152
|
-
var init_shared_modules = __esm({
|
|
1153
|
-
"src/runtime/turbopack/shared-modules.ts"() {
|
|
1154
|
-
"use strict";
|
|
1155
|
-
init_logger();
|
|
1156
|
-
init_module();
|
|
1157
|
-
init_patterns2();
|
|
1158
|
-
init_remote_scope();
|
|
1159
|
-
DEDUPLICATION_WARNING = "This module will not be deduplicated \u2014 the remote may load its own copy, which can cause duplicate instance errors (e.g. invalid hook calls if React is loaded twice).";
|
|
1160
|
-
}
|
|
1161
|
-
});
|
|
1162
|
-
|
|
1163
|
-
// src/runtime/turbopack/module.ts
|
|
1164
|
-
function requireModule(scope, moduleId, fullId) {
|
|
1165
|
-
const idStr = String(moduleId);
|
|
1166
|
-
if (scope.moduleCache[idStr])
|
|
1167
|
-
return scope.moduleCache[idStr];
|
|
1168
|
-
const sharedModule = getSharedModule(scope, moduleId);
|
|
1169
|
-
if (sharedModule)
|
|
1170
|
-
return sharedModule;
|
|
1171
|
-
return handleTurbopackModule(
|
|
1172
|
-
scope,
|
|
1173
|
-
idStr,
|
|
1174
|
-
fullId ?? formatRemoteId(scope, idStr)
|
|
1175
|
-
);
|
|
1176
|
-
}
|
|
1177
|
-
function handleTurbopackModule(scope, moduleId, id) {
|
|
1178
|
-
if (scope.moduleCache[moduleId]) {
|
|
1179
|
-
return scope.moduleCache[moduleId];
|
|
1180
|
-
}
|
|
1181
|
-
const modules = getTurbopackModules(scope);
|
|
1182
|
-
if (!modules) {
|
|
1183
|
-
logError(
|
|
1184
|
-
"TurbopackModule",
|
|
1185
|
-
`TURBOPACK_${scope.globalKey} is undefined (scope: "${scope.scopedName}")`
|
|
1186
|
-
);
|
|
1187
|
-
}
|
|
1188
|
-
const moduleInit = findModuleInit(modules, moduleId);
|
|
1189
|
-
const exports = {};
|
|
1190
|
-
const moduleExports = { exports };
|
|
1191
|
-
if (typeof moduleInit !== "function") {
|
|
1192
|
-
throw new Error(
|
|
1193
|
-
`Module ${id} not found in bundle ${scope.name} with id ${moduleId}`
|
|
1194
|
-
);
|
|
1195
|
-
}
|
|
1196
|
-
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1197
|
-
moduleInit(
|
|
1198
|
-
createTurbopackContext(
|
|
1199
|
-
scope,
|
|
1200
|
-
exports,
|
|
1201
|
-
moduleExports,
|
|
1202
|
-
modules,
|
|
1203
|
-
moduleInit,
|
|
1204
|
-
id
|
|
1205
|
-
),
|
|
1206
|
-
moduleExports,
|
|
1207
|
-
exports
|
|
1208
|
-
);
|
|
1209
|
-
if (scope.moduleCache[moduleId] !== moduleExports.exports) {
|
|
1210
|
-
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1211
|
-
}
|
|
1212
|
-
return moduleExports.exports;
|
|
1213
|
-
}
|
|
1214
|
-
function findModuleInit(modules, moduleId) {
|
|
1215
|
-
if (!modules || typeof modules !== "object")
|
|
1216
|
-
return;
|
|
1217
|
-
if (!Array.isArray(modules)) {
|
|
1218
|
-
const key = moduleId in modules ? moduleId : Object.keys(modules).find((k) => k.startsWith(moduleId));
|
|
1219
|
-
return key !== void 0 ? modules[key] : void 0;
|
|
1220
|
-
}
|
|
1221
|
-
const flat = modules.flat();
|
|
1222
|
-
let idx = flat.findIndex((e) => String(e) === String(moduleId));
|
|
1223
|
-
if (idx < 0) {
|
|
1224
|
-
idx = flat.findIndex(
|
|
1225
|
-
(e) => typeof e === "string" && e.startsWith(moduleId)
|
|
1226
|
-
);
|
|
1227
|
-
}
|
|
1228
|
-
if (idx >= 0) {
|
|
1229
|
-
return flat.slice(idx + 1).find((e) => typeof e === "function");
|
|
1230
|
-
}
|
|
1231
|
-
for (const entry of flat) {
|
|
1232
|
-
if (!entry || typeof entry !== "object")
|
|
1233
|
-
continue;
|
|
1234
|
-
const obj = entry;
|
|
1235
|
-
if (moduleId in obj)
|
|
1236
|
-
return obj[moduleId];
|
|
1237
|
-
const prefixKey = Object.keys(obj).find((k) => k.startsWith(moduleId));
|
|
1238
|
-
if (prefixKey)
|
|
1239
|
-
return obj[prefixKey];
|
|
1240
|
-
}
|
|
1241
|
-
return void 0;
|
|
1242
|
-
}
|
|
1243
|
-
function createTurbopackContext(scope, exports, moduleExports, modules, moduleInit, id) {
|
|
1244
|
-
const scopedRequire = (moduleId) => requireModule(scope, moduleId, formatRemoteId(scope, String(moduleId)));
|
|
1245
|
-
return {
|
|
1246
|
-
// HMR not implemented for Remote Components
|
|
1247
|
-
k: {
|
|
1248
|
-
register() {
|
|
1249
|
-
},
|
|
1250
|
-
registerExports() {
|
|
1251
|
-
},
|
|
1252
|
-
signature() {
|
|
1253
|
-
return (fn) => fn;
|
|
1254
|
-
}
|
|
1255
|
-
},
|
|
1256
|
-
// ESM exports setup
|
|
1257
|
-
s(bindings, esmId) {
|
|
1258
|
-
let mod = exports;
|
|
1259
|
-
if (typeof esmId === "string" || typeof esmId === "number") {
|
|
1260
|
-
if (!scope.moduleCache[esmId]) {
|
|
1261
|
-
scope.moduleCache[esmId] = {};
|
|
1262
|
-
}
|
|
1263
|
-
mod = scope.moduleCache[esmId];
|
|
1264
|
-
}
|
|
1265
|
-
Object.defineProperty(mod, "__esModule", { value: true });
|
|
1266
|
-
if (Array.isArray(bindings)) {
|
|
1267
|
-
let i = 0;
|
|
1268
|
-
while (i < bindings.length) {
|
|
1269
|
-
const propName = bindings[i++];
|
|
1270
|
-
const tagOrFunc = bindings[i++];
|
|
1271
|
-
if (typeof tagOrFunc === "number") {
|
|
1272
|
-
Object.defineProperty(mod, propName, {
|
|
1273
|
-
value: bindings[i++],
|
|
1274
|
-
enumerable: true,
|
|
1275
|
-
writable: false
|
|
1276
|
-
});
|
|
1277
|
-
} else {
|
|
1278
|
-
const getterFn = tagOrFunc;
|
|
1279
|
-
if (typeof bindings[i] === "function") {
|
|
1280
|
-
const setterFn = bindings[i++];
|
|
1281
|
-
Object.defineProperty(mod, propName, {
|
|
1282
|
-
get: getterFn,
|
|
1283
|
-
set: setterFn,
|
|
1284
|
-
enumerable: true
|
|
1285
|
-
});
|
|
1286
|
-
} else {
|
|
1287
|
-
Object.defineProperty(mod, propName, {
|
|
1288
|
-
get: getterFn,
|
|
1289
|
-
enumerable: true
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
},
|
|
1296
|
-
// import — resolves directly via scope, no global dispatch
|
|
1297
|
-
i(importId) {
|
|
1298
|
-
let mod;
|
|
1299
|
-
if (typeof importId === "string") {
|
|
1300
|
-
const { exportSource, exportName } = /\s+<export (?<exportSource>.*?) as (?<exportName>.*?)>$/.exec(
|
|
1301
|
-
importId
|
|
1302
|
-
)?.groups ?? {};
|
|
1303
|
-
const normalizedId = importId.replace(
|
|
1304
|
-
/\s+<export(?<specifier>.*)>$/,
|
|
1305
|
-
""
|
|
1306
|
-
);
|
|
1307
|
-
mod = scopedRequire(normalizedId);
|
|
1308
|
-
if (mod && exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
1309
|
-
if (exportSource === "*") {
|
|
1310
|
-
mod[exportName] = mod;
|
|
1311
|
-
} else {
|
|
1312
|
-
mod[exportName] = mod[exportSource];
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
} else {
|
|
1316
|
-
mod = scopedRequire(importId);
|
|
1317
|
-
}
|
|
1318
|
-
if (typeof mod !== "object" || mod === null) {
|
|
1319
|
-
mod = { default: mod };
|
|
1320
|
-
} else if (!("default" in mod) && // ES module namespace objects have a null prototype, so calling
|
|
1321
|
-
// mod.toString() directly throws. Use Object.prototype.toString
|
|
1322
|
-
// to safely detect them.
|
|
1323
|
-
Object.prototype.toString.call(mod) !== "[object Module]") {
|
|
1324
|
-
try {
|
|
1325
|
-
mod.default = mod;
|
|
1326
|
-
} catch {
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
return mod;
|
|
1330
|
-
},
|
|
1331
|
-
// require — resolves directly via scope
|
|
1332
|
-
r(requireId) {
|
|
1333
|
-
return scopedRequire(requireId);
|
|
1334
|
-
},
|
|
1335
|
-
// value exports
|
|
1336
|
-
v(value) {
|
|
1337
|
-
if (typeof value === "function") {
|
|
1338
|
-
exports.default = value((vid) => scopedRequire(vid));
|
|
1339
|
-
} else {
|
|
1340
|
-
moduleExports.exports = value;
|
|
1341
|
-
}
|
|
1342
|
-
},
|
|
1343
|
-
// async module initializer
|
|
1344
|
-
async a(mod) {
|
|
1345
|
-
let result;
|
|
1346
|
-
await mod(
|
|
1347
|
-
() => {
|
|
1348
|
-
},
|
|
1349
|
-
(value) => result = value
|
|
1350
|
-
);
|
|
1351
|
-
exports.default = result;
|
|
1352
|
-
},
|
|
1353
|
-
// async module loader — resolves directly via scope
|
|
1354
|
-
async A(Aid) {
|
|
1355
|
-
const mod = scopedRequire(Aid);
|
|
1356
|
-
return mod.default((parentId) => scopedRequire(parentId));
|
|
1357
|
-
},
|
|
1358
|
-
// dynamic import tracking — no-op for remote components
|
|
1359
|
-
j() {
|
|
1360
|
-
},
|
|
1361
|
-
// chunk loader — loads directly via scope, no global dispatch
|
|
1362
|
-
l(url) {
|
|
1363
|
-
const flatModules = Array.isArray(modules) ? modules : [];
|
|
1364
|
-
const moduleInitIndex = flatModules.indexOf(moduleInit);
|
|
1365
|
-
if (moduleInitIndex !== -1) {
|
|
1366
|
-
const scriptIndex = flatModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
1367
|
-
if (scriptIndex !== -1) {
|
|
1368
|
-
const script = flatModules[scriptIndex];
|
|
1369
|
-
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
1370
|
-
const nextIndex = scriptSrc.indexOf("/_next");
|
|
1371
|
-
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
1372
|
-
const chunkUrl = `${baseUrl}/_next/${url}`;
|
|
1373
|
-
return loadChunkWithScope(scope, formatRemoteId(scope, chunkUrl));
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
throw new Error(
|
|
1377
|
-
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
1378
|
-
);
|
|
1379
|
-
},
|
|
1380
|
-
// globalThis substitute shared across all modules in this scope
|
|
1381
|
-
g: scope.moduleGlobal,
|
|
1382
|
-
m: moduleExports,
|
|
1383
|
-
e: exports
|
|
1384
|
-
};
|
|
1385
|
-
}
|
|
1386
|
-
var init_module = __esm({
|
|
1387
|
-
"src/runtime/turbopack/module.ts"() {
|
|
1388
|
-
"use strict";
|
|
1389
|
-
init_logger();
|
|
1390
|
-
init_chunk_loader();
|
|
1391
|
-
init_remote_scope();
|
|
1392
|
-
init_shared_modules();
|
|
1393
|
-
}
|
|
1394
|
-
});
|
|
1395
|
-
|
|
1396
|
-
// src/runtime/turbopack/remote-scope-setup.ts
|
|
1397
|
-
async function setupRemoteScope(runtime, scripts = [], url = new URL(location.href), bundle, resolveClientUrl) {
|
|
1398
|
-
const self = globalThis;
|
|
1399
|
-
const ns = getNamespace();
|
|
1400
|
-
const bundleName = bundle ?? "default";
|
|
1401
|
-
const existingScope = getScope(bundleName);
|
|
1402
|
-
if (existingScope && existingScope.url.origin === url.origin) {
|
|
1403
|
-
logDebug(
|
|
1404
|
-
"WebpackRuntime",
|
|
1405
|
-
`Reusing scope "${existingScope.scopedName}" (turbopackModules=${existingScope.turbopackModules.length})`
|
|
1406
|
-
);
|
|
1407
|
-
existingScope.resolveClientUrl = resolveClientUrl;
|
|
1408
|
-
if (runtime === RUNTIME_TURBOPACK) {
|
|
1409
|
-
await Promise.allSettled(
|
|
1410
|
-
scripts.map(
|
|
1411
|
-
(script) => script.src ? loadChunkWithScope(existingScope, script.src) : Promise.resolve(void 0)
|
|
1412
|
-
)
|
|
1413
|
-
);
|
|
1414
|
-
}
|
|
1415
|
-
return existingScope;
|
|
1416
|
-
}
|
|
1417
|
-
const scope = createScope(bundleName, url, runtime, resolveClientUrl);
|
|
1418
|
-
registerScope(scope);
|
|
1419
|
-
if (runtime === RUNTIME_WEBPACK && self.__remote_webpack_require__?.[bundleName]) {
|
|
1420
|
-
scope.webpackRequire = self.__remote_webpack_require__[bundleName];
|
|
1421
|
-
}
|
|
1422
|
-
ns.bundleUrls[bundleName] = url;
|
|
1423
|
-
if (scope.scopedName !== bundleName) {
|
|
1424
|
-
ns.bundleUrls[scope.scopedName] = url;
|
|
1425
|
-
}
|
|
1426
|
-
self.__webpack_get_script_filename__ = () => null;
|
|
1427
|
-
const willCreateDispatchers = typeof self.__webpack_require__ !== "function" || ns.dispatcherRuntime !== "turbopack";
|
|
1428
|
-
if (willCreateDispatchers) {
|
|
1429
|
-
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
1430
|
-
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
1431
|
-
self.__original_webpack_require__ = self.__webpack_require__;
|
|
1432
|
-
}
|
|
1433
|
-
self.__webpack_chunk_load__ = createChunkDispatcher();
|
|
1434
|
-
self.__webpack_require__ = createModuleDispatcher(runtime);
|
|
1435
|
-
ns.dispatcherRuntime = runtime;
|
|
1436
|
-
self.__webpack_require_type__ = runtime;
|
|
1437
|
-
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
1438
|
-
self.__remote_webpack_require__[bundleName] = self.__webpack_require__;
|
|
1439
|
-
self.__remote_webpack_require__[bundleName].type = "turbopack";
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
if (self.__remote_webpack_require__?.[bundleName] && scope.scopedName !== bundleName) {
|
|
1443
|
-
self.__remote_webpack_require__[scope.scopedName] = self.__remote_webpack_require__[bundleName];
|
|
1444
|
-
}
|
|
1445
|
-
if (runtime === RUNTIME_TURBOPACK) {
|
|
1446
|
-
const results = await Promise.allSettled(
|
|
1447
|
-
scripts.map((script) => {
|
|
1448
|
-
if (script.src) {
|
|
1449
|
-
return loadChunkWithScope(scope, script.src);
|
|
1450
|
-
}
|
|
1451
|
-
return Promise.resolve(void 0);
|
|
1452
|
-
})
|
|
1453
|
-
);
|
|
1454
|
-
for (const result of results) {
|
|
1455
|
-
if (result.status === "rejected") {
|
|
1456
|
-
logWarn(
|
|
1457
|
-
"WebpackRuntime",
|
|
1458
|
-
`Initial chunk load failed: ${String(result.reason)}`
|
|
1459
|
-
);
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
return scope;
|
|
1464
|
-
}
|
|
1465
|
-
function createModuleDispatcher(runtime) {
|
|
1466
|
-
return (id) => {
|
|
1467
|
-
const self = globalThis;
|
|
1468
|
-
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
1469
|
-
bundle: "default",
|
|
1470
|
-
id
|
|
1471
|
-
};
|
|
1472
|
-
const bundleName = bundle ?? "default";
|
|
1473
|
-
const remoteRuntime = self.__remote_webpack_require__?.[bundleName] ? self.__remote_webpack_require__[bundleName]?.type || "webpack" : runtime;
|
|
1474
|
-
logDebug(
|
|
1475
|
-
"ModuleDispatcher",
|
|
1476
|
-
`Resolving "${id}" (bundle: "${bundleName}", runtime: "${remoteRuntime}")`
|
|
1477
|
-
);
|
|
1478
|
-
try {
|
|
1479
|
-
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1480
|
-
const scope2 = getScope(bundle);
|
|
1481
|
-
if (scope2?.webpackRequire)
|
|
1482
|
-
return scope2.webpackRequire(moduleId);
|
|
1483
|
-
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
1484
|
-
}
|
|
1485
|
-
const scope = getScope(bundleName);
|
|
1486
|
-
if (scope) {
|
|
1487
|
-
return requireModule(scope, moduleId ?? id, id);
|
|
1488
|
-
}
|
|
1489
|
-
throw new Error(
|
|
1490
|
-
`Module "${id}" not found \u2014 no scope for bundle "${bundleName}".`
|
|
1491
|
-
);
|
|
1492
|
-
} catch (requireError) {
|
|
1493
|
-
logWarn(
|
|
1494
|
-
"ModuleDispatcher",
|
|
1495
|
-
`Module require failed: ${String(requireError)}`
|
|
1496
|
-
);
|
|
1497
|
-
if (typeof self.__original_webpack_require__ !== "function") {
|
|
1498
|
-
throw new RemoteComponentsError(
|
|
1499
|
-
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1500
|
-
{
|
|
1501
|
-
cause: requireError instanceof Error ? requireError : void 0
|
|
1502
|
-
}
|
|
1503
|
-
);
|
|
1504
|
-
}
|
|
1505
|
-
try {
|
|
1506
|
-
logDebug(
|
|
1507
|
-
"ModuleDispatcher",
|
|
1508
|
-
"Falling back to original webpack require"
|
|
1509
|
-
);
|
|
1510
|
-
return self.__original_webpack_require__(id);
|
|
1511
|
-
} catch (originalError) {
|
|
1512
|
-
throw new RemoteComponentsError(
|
|
1513
|
-
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1514
|
-
{ cause: originalError instanceof Error ? originalError : void 0 }
|
|
1515
|
-
);
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
};
|
|
1519
|
-
}
|
|
1520
|
-
var init_remote_scope_setup = __esm({
|
|
1521
|
-
"src/runtime/turbopack/remote-scope-setup.ts"() {
|
|
1522
|
-
"use strict";
|
|
1523
|
-
init_constants2();
|
|
1524
|
-
init_namespace();
|
|
1525
|
-
init_patterns();
|
|
1526
|
-
init_error();
|
|
1527
|
-
init_logger();
|
|
1528
|
-
init_chunk_loader();
|
|
1529
|
-
init_module();
|
|
1530
|
-
init_remote_scope();
|
|
1531
|
-
}
|
|
1532
|
-
});
|
|
1533
|
-
|
|
1534
|
-
// src/runtime/loaders/script-loader.ts
|
|
1535
|
-
async function loadScripts(scripts, resolveClientUrl) {
|
|
1536
|
-
await Promise.all(
|
|
1537
|
-
scripts.map((script) => {
|
|
1538
|
-
return new Promise((resolve, reject) => {
|
|
1539
|
-
const newSrc = new URL(
|
|
1540
|
-
// remove the remote component bundle name identifier from the script src
|
|
1541
|
-
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
1542
|
-
location.origin
|
|
1543
|
-
).href;
|
|
1544
|
-
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
1545
|
-
const alreadyLoaded = Array.from(
|
|
1546
|
-
document.querySelectorAll("script[src]")
|
|
1547
|
-
).some((s) => s.src === resolvedSrc);
|
|
1548
|
-
if (alreadyLoaded) {
|
|
1549
|
-
resolve();
|
|
1550
|
-
return;
|
|
1551
|
-
}
|
|
1552
|
-
const newScript = document.createElement("script");
|
|
1553
|
-
newScript.onload = () => resolve();
|
|
1554
|
-
newScript.onerror = () => {
|
|
1555
|
-
const isProxied = isProxiedUrl(resolvedSrc);
|
|
1556
|
-
if (isProxied) {
|
|
1557
|
-
reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
|
|
1558
|
-
} else {
|
|
1559
|
-
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
1560
|
-
reject(
|
|
1561
|
-
new RemoteComponentsError(
|
|
1562
|
-
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
1563
|
-
)
|
|
1564
|
-
);
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
|
-
newScript.src = resolvedSrc;
|
|
1568
|
-
newScript.async = true;
|
|
1569
|
-
document.head.appendChild(newScript);
|
|
1570
|
-
});
|
|
1571
|
-
})
|
|
1572
|
-
);
|
|
1573
|
-
}
|
|
1574
|
-
var init_script_loader = __esm({
|
|
1575
|
-
"src/runtime/loaders/script-loader.ts"() {
|
|
1576
|
-
"use strict";
|
|
1577
|
-
init_patterns();
|
|
1578
|
-
init_protected_rc_fallback();
|
|
1579
|
-
init_error();
|
|
1580
|
-
init_logger();
|
|
1581
|
-
}
|
|
1582
|
-
});
|
|
1583
|
-
|
|
1584
|
-
// src/runtime/loaders/static-loader.ts
|
|
1585
|
-
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1586
|
-
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1587
|
-
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
1588
|
-
const response = await fetch(fetchUrl);
|
|
1589
|
-
if (!response.ok)
|
|
1590
|
-
throw new Error(`Proxied fetch failed: ${response.status}`);
|
|
1591
|
-
const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
|
|
1592
|
-
/\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
|
|
1593
|
-
(_, keyword, quote, relativePath) => {
|
|
1594
|
-
const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
|
|
1595
|
-
const resolvedImportUrl = new URL(
|
|
1596
|
-
resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
|
|
1597
|
-
location.href
|
|
1598
|
-
).href;
|
|
1599
|
-
return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
|
|
1600
|
-
}
|
|
1601
|
-
);
|
|
1602
|
-
const moduleBlobUrl = URL.createObjectURL(
|
|
1603
|
-
new Blob([content], { type: "text/javascript" })
|
|
1604
|
-
);
|
|
1605
|
-
const wrapperContent = [
|
|
1606
|
-
`import*as m from${JSON.stringify(moduleBlobUrl)};`,
|
|
1607
|
-
`globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
|
|
1608
|
-
`globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
|
|
1609
|
-
].join("");
|
|
1610
|
-
const wrapperBlobUrl = URL.createObjectURL(
|
|
1611
|
-
new Blob([wrapperContent], { type: "text/javascript" })
|
|
1612
|
-
);
|
|
1613
|
-
const scriptEl = document.createElement("script");
|
|
1614
|
-
scriptEl.type = "module";
|
|
1615
|
-
scriptEl.src = wrapperBlobUrl;
|
|
1616
|
-
try {
|
|
1617
|
-
await new Promise((resolve, reject) => {
|
|
1618
|
-
scriptEl.onload = () => resolve();
|
|
1619
|
-
scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
|
|
1620
|
-
document.head.appendChild(scriptEl);
|
|
1621
|
-
});
|
|
1622
|
-
} finally {
|
|
1623
|
-
scriptEl.remove();
|
|
1624
|
-
URL.revokeObjectURL(moduleBlobUrl);
|
|
1625
|
-
URL.revokeObjectURL(wrapperBlobUrl);
|
|
1626
|
-
}
|
|
1627
|
-
const registry = getNamespace().moduleRegistry;
|
|
1628
|
-
const mod = registry[absoluteSrc] ?? {};
|
|
1629
|
-
delete registry[absoluteSrc];
|
|
1630
|
-
return mod;
|
|
1631
|
-
}
|
|
1632
|
-
async function importDirectly(absoluteSrc) {
|
|
1633
|
-
try {
|
|
1634
|
-
return await import(
|
|
1635
|
-
/* @vite-ignore */
|
|
1636
|
-
/* webpackIgnore: true */
|
|
1637
|
-
absoluteSrc
|
|
1638
|
-
);
|
|
1639
|
-
} catch (importError) {
|
|
1640
|
-
if (!absoluteSrc.startsWith("blob:")) {
|
|
1641
|
-
warnCrossOriginFetchError("StaticLoader", absoluteSrc);
|
|
1642
|
-
}
|
|
1643
|
-
throw importError;
|
|
1644
|
-
}
|
|
1645
|
-
}
|
|
1646
|
-
function resolveScriptSrc(script, url) {
|
|
1647
|
-
const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
|
|
1648
|
-
if (!rawSrc && script.textContent) {
|
|
1649
|
-
return URL.createObjectURL(
|
|
1650
|
-
new Blob(
|
|
1651
|
-
[script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
|
|
1652
|
-
{ type: "text/javascript" }
|
|
1653
|
-
)
|
|
1654
|
-
);
|
|
1655
|
-
}
|
|
1656
|
-
return rawSrc;
|
|
1657
|
-
}
|
|
1658
|
-
async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
1659
|
-
const ns = getNamespace();
|
|
1660
|
-
if (ns.mountFns[url.href]) {
|
|
1661
|
-
ns.mountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1662
|
-
}
|
|
1663
|
-
if (ns.unmountFns[url.href]) {
|
|
1664
|
-
ns.unmountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1665
|
-
}
|
|
1666
|
-
const mountUnmountSets = await Promise.all(
|
|
1667
|
-
scripts.map(async (script) => {
|
|
1668
|
-
try {
|
|
1669
|
-
const src = resolveScriptSrc(script, url);
|
|
1670
|
-
const absoluteSrc = new URL(src, url).href;
|
|
1671
|
-
const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
|
|
1672
|
-
if (src.startsWith("blob:")) {
|
|
1673
|
-
URL.revokeObjectURL(src);
|
|
1674
|
-
}
|
|
1675
|
-
if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
|
|
1676
|
-
if (!ns.mountFns[url.href]) {
|
|
1677
|
-
ns.mountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1678
|
-
}
|
|
1679
|
-
ns.mountFns[url.href]?.add(
|
|
1680
|
-
mod.mount || mod.default?.mount || (() => {
|
|
1681
|
-
})
|
|
1682
|
-
);
|
|
1683
|
-
}
|
|
1684
|
-
if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
|
|
1685
|
-
if (!ns.unmountFns[url.href]) {
|
|
1686
|
-
ns.unmountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1687
|
-
}
|
|
1688
|
-
ns.unmountFns[url.href]?.add(
|
|
1689
|
-
mod.unmount || mod.default?.unmount || (() => {
|
|
1690
|
-
})
|
|
1691
|
-
);
|
|
1692
|
-
}
|
|
1693
|
-
return {
|
|
1694
|
-
mount: mod.mount || mod.default?.mount,
|
|
1695
|
-
unmount: mod.unmount || mod.default?.unmount
|
|
1696
|
-
};
|
|
1697
|
-
} catch (e) {
|
|
1698
|
-
logError(
|
|
1699
|
-
"StaticLoader",
|
|
1700
|
-
`Error loading remote component script from "${script.src || url.href}".`,
|
|
1701
|
-
e
|
|
1702
|
-
);
|
|
1703
|
-
return {
|
|
1704
|
-
mount: void 0,
|
|
1705
|
-
unmount: void 0
|
|
1706
|
-
};
|
|
1707
|
-
}
|
|
1708
|
-
})
|
|
1709
|
-
);
|
|
1710
|
-
return mountUnmountSets.reduce(
|
|
1711
|
-
(acc, { mount, unmount }) => {
|
|
1712
|
-
if (typeof mount === "function") {
|
|
1713
|
-
acc.mount.add(mount);
|
|
1714
|
-
}
|
|
1715
|
-
if (typeof unmount === "function") {
|
|
1716
|
-
acc.unmount.add(unmount);
|
|
1717
|
-
}
|
|
1718
|
-
return acc;
|
|
1719
|
-
},
|
|
1720
|
-
{
|
|
1721
|
-
mount: /* @__PURE__ */ new Set(),
|
|
1722
|
-
unmount: /* @__PURE__ */ new Set()
|
|
1723
|
-
}
|
|
1724
|
-
);
|
|
1725
|
-
}
|
|
1726
|
-
var init_static_loader = __esm({
|
|
1727
|
-
"src/runtime/loaders/static-loader.ts"() {
|
|
1728
|
-
"use strict";
|
|
1729
|
-
init_namespace();
|
|
1730
|
-
init_logger();
|
|
1731
|
-
}
|
|
1732
|
-
});
|
|
1733
|
-
|
|
1734
|
-
// src/host/html/runtime/webpack.ts
|
|
1735
|
-
var webpack_exports = {};
|
|
1736
|
-
__export(webpack_exports, {
|
|
1737
|
-
webpackRuntime: () => webpackRuntime
|
|
1738
|
-
});
|
|
1739
|
-
async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
1740
|
-
const self = globalThis;
|
|
1741
|
-
if (!self.__DISABLE_WEBPACK_EXEC__) {
|
|
1742
|
-
self.__DISABLE_WEBPACK_EXEC__ = {};
|
|
1743
|
-
}
|
|
1744
|
-
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
1745
|
-
if (typeof self.__webpack_require__ !== "function" && self.__webpack_require_type__ !== "turbopack") {
|
|
1746
|
-
self.__webpack_require__ = (remoteId) => {
|
|
1747
|
-
const re = /\[(?<bundle>[^\]]+)\] (?<id>.*)/;
|
|
1748
|
-
const match = re.exec(remoteId);
|
|
1749
|
-
const remoteBundle = match?.groups?.bundle;
|
|
1750
|
-
const id = match?.groups?.id;
|
|
1751
|
-
if (!(id && remoteBundle)) {
|
|
1752
|
-
throw new RemoteComponentsError(
|
|
1753
|
-
`Remote Component module "${remoteId}" not found. Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
1754
|
-
);
|
|
1755
|
-
}
|
|
1756
|
-
if (typeof self.__remote_webpack_require__?.[remoteBundle] !== "function") {
|
|
1757
|
-
throw new RemoteComponentsError(
|
|
1758
|
-
`Remote Components are not available in "${remoteBundle}". Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
1759
|
-
);
|
|
1760
|
-
}
|
|
1761
|
-
return self.__remote_webpack_require__[remoteBundle](id);
|
|
1762
|
-
};
|
|
1763
|
-
self.__webpack_chunk_load__ = () => {
|
|
1764
|
-
return Promise.resolve([]);
|
|
1765
|
-
};
|
|
1766
|
-
}
|
|
1767
|
-
const {
|
|
1768
|
-
default: { createFromReadableStream }
|
|
1769
|
-
} = await import("react-server-dom-webpack/client.browser");
|
|
1770
|
-
async function preloadScripts(scripts, url, remoteBundle, _) {
|
|
1771
|
-
const scriptSrcs = scripts.flatMap((script) => {
|
|
1772
|
-
const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
|
|
1773
|
-
script.parentElement?.removeChild(script);
|
|
1774
|
-
if (!scriptSrc)
|
|
1775
|
-
return [];
|
|
1776
|
-
return [
|
|
1777
|
-
{
|
|
1778
|
-
src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
1779
|
-
}
|
|
1780
|
-
];
|
|
1781
|
-
});
|
|
1782
|
-
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
1783
|
-
const hostShared = buildHostShared(shared, resolveClientUrl);
|
|
1784
|
-
const resolve = await buildWebpackResolve(
|
|
1785
|
-
hostShared,
|
|
1786
|
-
remoteShared ?? {},
|
|
1787
|
-
remoteBundle,
|
|
1788
|
-
{
|
|
1789
|
-
"/react/index.js": (await import("react")).default,
|
|
1790
|
-
"/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
|
|
1791
|
-
"/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
|
|
1792
|
-
"/react-dom/index.js": (await import("react-dom")).default,
|
|
1793
|
-
"/react-dom/client.js": (await import("react-dom/client")).default
|
|
1794
|
-
},
|
|
1795
|
-
"WebpackRuntime"
|
|
1796
|
-
);
|
|
1797
|
-
applySharedModules(remoteBundle, resolve);
|
|
1798
|
-
}
|
|
1799
|
-
return {
|
|
1800
|
-
self,
|
|
1801
|
-
createFromReadableStream,
|
|
1802
|
-
applySharedModules,
|
|
1803
|
-
nextClientPagesLoader,
|
|
1804
|
-
preloadScripts
|
|
1805
|
-
};
|
|
1806
|
-
}
|
|
1807
|
-
var init_webpack = __esm({
|
|
1808
|
-
"src/host/html/runtime/webpack.ts"() {
|
|
1809
|
-
"use strict";
|
|
1810
|
-
init_apply_shared_modules();
|
|
1811
|
-
init_next_client_pages_loader();
|
|
1812
|
-
init_shared_module_resolver();
|
|
1813
|
-
init_script_loader();
|
|
1814
|
-
init_patterns();
|
|
1815
|
-
init_error();
|
|
1816
|
-
}
|
|
1817
|
-
});
|
|
1818
|
-
|
|
1819
|
-
// src/host/html/runtime/turbopack.ts
|
|
1820
|
-
var turbopack_exports = {};
|
|
1821
|
-
__export(turbopack_exports, {
|
|
1822
|
-
turbopackRuntime: () => turbopackRuntime
|
|
1823
|
-
});
|
|
1824
|
-
async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
1825
|
-
const self = globalThis;
|
|
1826
|
-
const hostShared = buildHostShared(shared, resolveClientUrl, {
|
|
1827
|
-
includeRemoteComponentShared: true
|
|
1828
|
-
});
|
|
1829
|
-
await setupRemoteScope("turbopack", [], url, bundle, resolveClientUrl);
|
|
1830
|
-
const {
|
|
1831
|
-
default: { createFromReadableStream }
|
|
1832
|
-
} = await import("react-server-dom-webpack/client.browser");
|
|
1833
|
-
async function preloadScripts(scripts, __) {
|
|
1834
|
-
const scope = await setupRemoteScope(
|
|
1835
|
-
"turbopack",
|
|
1836
|
-
scripts.map((script) => ({
|
|
1837
|
-
src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
|
|
1838
|
-
})),
|
|
1839
|
-
url,
|
|
1840
|
-
bundle,
|
|
1841
|
-
resolveClientUrl
|
|
1842
|
-
);
|
|
1843
|
-
await initializeSharedModules(
|
|
1844
|
-
scope,
|
|
1845
|
-
buildCoreShared(hostShared),
|
|
1846
|
-
remoteShared ?? {}
|
|
1847
|
-
);
|
|
1848
|
-
}
|
|
1849
|
-
return {
|
|
1850
|
-
self,
|
|
1851
|
-
createFromReadableStream,
|
|
1852
|
-
applySharedModules,
|
|
1853
|
-
nextClientPagesLoader,
|
|
1854
|
-
preloadScripts
|
|
1855
|
-
};
|
|
1856
|
-
}
|
|
1857
|
-
var init_turbopack = __esm({
|
|
1858
|
-
"src/host/html/runtime/turbopack.ts"() {
|
|
1859
|
-
"use strict";
|
|
1860
|
-
init_apply_shared_modules();
|
|
1861
|
-
init_next_client_pages_loader();
|
|
1862
|
-
init_shared_module_resolver();
|
|
1863
|
-
init_remote_scope_setup();
|
|
1864
|
-
init_shared_modules();
|
|
1865
|
-
}
|
|
1866
|
-
});
|
|
1867
|
-
|
|
1868
|
-
// src/host/html/runtime/script.ts
|
|
1869
|
-
var script_exports = {};
|
|
1870
|
-
__export(script_exports, {
|
|
1871
|
-
scriptRuntime: () => scriptRuntime
|
|
1872
|
-
});
|
|
1873
|
-
function scriptRuntime(resolveClientUrl) {
|
|
1874
|
-
const self = globalThis;
|
|
1875
|
-
return {
|
|
1876
|
-
self,
|
|
1877
|
-
createFromReadableStream: () => Promise.resolve(null),
|
|
1878
|
-
applySharedModules: () => Promise.resolve(),
|
|
1879
|
-
nextClientPagesLoader: () => ({
|
|
1880
|
-
Component: null,
|
|
1881
|
-
App: null
|
|
1882
|
-
}),
|
|
1883
|
-
preloadScripts: (scripts, url) => loadStaticRemoteComponent(scripts, url, resolveClientUrl)
|
|
1884
|
-
};
|
|
1885
|
-
}
|
|
1886
|
-
var init_script = __esm({
|
|
1887
|
-
"src/host/html/runtime/script.ts"() {
|
|
1888
|
-
"use strict";
|
|
1889
|
-
init_static_loader();
|
|
1890
|
-
}
|
|
1891
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
bindResolveClientUrl,
|
|
3
|
+
createHostState,
|
|
4
|
+
createRSCStream,
|
|
5
|
+
fetchWithHooks,
|
|
6
|
+
getClientOrServerUrl,
|
|
7
|
+
makeEventEmitter,
|
|
8
|
+
preparePipeline,
|
|
9
|
+
resolveNameFromSrc
|
|
10
|
+
} from "../chunk-NZAB7REE.js";
|
|
11
|
+
import "../chunk-SZFCBE54.js";
|
|
12
|
+
import "../chunk-QKB74MLO.js";
|
|
13
|
+
import "../chunk-52BJ7VFA.js";
|
|
14
|
+
import "../chunk-LQ7VQ74E.js";
|
|
15
|
+
import {
|
|
16
|
+
DEFAULT_BUNDLE_NAME,
|
|
17
|
+
DEFAULT_COMPONENT_NAME,
|
|
18
|
+
escapeString
|
|
19
|
+
} from "../chunk-SJM7AAGU.js";
|
|
20
|
+
import {
|
|
21
|
+
getNamespace
|
|
22
|
+
} from "../chunk-D5GNZB6O.js";
|
|
23
|
+
import {
|
|
24
|
+
RemoteComponentsError,
|
|
25
|
+
errorFromFailedFetch,
|
|
26
|
+
isAbortError,
|
|
27
|
+
logError
|
|
28
|
+
} from "../chunk-S2A4TFLS.js";
|
|
29
|
+
import "../chunk-GAXJTFBV.js";
|
|
30
|
+
import "../chunk-X6YKUJKH.js";
|
|
31
|
+
import "../chunk-ENYGL5CO.js";
|
|
1892
32
|
|
|
1893
33
|
// src/host/html/index.tsx
|
|
1894
34
|
import { startTransition, useLayoutEffect } from "react";
|
|
1895
35
|
import { hydrateRoot } from "react-dom/client";
|
|
1896
36
|
|
|
1897
|
-
// src/host/server/fetch-with-hooks.ts
|
|
1898
|
-
init_logger();
|
|
1899
|
-
|
|
1900
|
-
// src/host/server/fetch-headers.ts
|
|
1901
|
-
function remoteFetchHeaders() {
|
|
1902
|
-
return {
|
|
1903
|
-
/**
|
|
1904
|
-
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1905
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1906
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1907
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1908
|
-
*/
|
|
1909
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1910
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1911
|
-
} : {},
|
|
1912
|
-
Accept: "text/html"
|
|
1913
|
-
};
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
// src/host/server/fetch-with-hooks.ts
|
|
1917
|
-
async function fetchWithWarning(url, init) {
|
|
1918
|
-
try {
|
|
1919
|
-
return await fetch(url, init);
|
|
1920
|
-
} catch (error) {
|
|
1921
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1922
|
-
throw error;
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1926
|
-
const {
|
|
1927
|
-
onRequest,
|
|
1928
|
-
onResponse,
|
|
1929
|
-
abortController = new AbortController()
|
|
1930
|
-
} = options;
|
|
1931
|
-
const signal = abortController.signal;
|
|
1932
|
-
const hookOptions = {
|
|
1933
|
-
signal,
|
|
1934
|
-
abort: (reason) => abortController.abort(reason)
|
|
1935
|
-
};
|
|
1936
|
-
const init = {
|
|
1937
|
-
method: "GET",
|
|
1938
|
-
headers: remoteFetchHeaders(),
|
|
1939
|
-
signal,
|
|
1940
|
-
...additionalInit
|
|
1941
|
-
};
|
|
1942
|
-
const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
|
|
1943
|
-
return await onResponse?.(url, res, hookOptions) ?? res;
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
// src/host/server/get-client-or-server-url.ts
|
|
1947
|
-
function getClientOrServerUrl(src, serverFallback) {
|
|
1948
|
-
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
1949
|
-
if (!src) {
|
|
1950
|
-
return new URL(fallback);
|
|
1951
|
-
}
|
|
1952
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
// src/host/shared/lifecycle.ts
|
|
1956
|
-
function makeEventEmitter(element) {
|
|
1957
|
-
function dispatch(type, detail) {
|
|
1958
|
-
const event = new Event(type, { bubbles: true, composed: true });
|
|
1959
|
-
if (detail) {
|
|
1960
|
-
Object.assign(event, detail);
|
|
1961
|
-
}
|
|
1962
|
-
element.dispatchEvent(event);
|
|
1963
|
-
}
|
|
1964
|
-
return {
|
|
1965
|
-
beforeLoad(src) {
|
|
1966
|
-
dispatch("beforeload", { src });
|
|
1967
|
-
},
|
|
1968
|
-
load(src) {
|
|
1969
|
-
dispatch("load", { src });
|
|
1970
|
-
},
|
|
1971
|
-
error(error, src) {
|
|
1972
|
-
dispatch("error", src != null ? { error, src } : { error });
|
|
1973
|
-
},
|
|
1974
|
-
change(info) {
|
|
1975
|
-
dispatch("change", info);
|
|
1976
|
-
}
|
|
1977
|
-
};
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
// src/host/shared/pipeline.ts
|
|
1981
|
-
init_shared_module_resolver();
|
|
1982
|
-
|
|
1983
|
-
// src/runtime/html/html-spec.ts
|
|
1984
|
-
var ORIGIN_REWRITE_TAGS = [
|
|
1985
|
-
"img",
|
|
1986
|
-
"source",
|
|
1987
|
-
"video",
|
|
1988
|
-
"audio",
|
|
1989
|
-
"track",
|
|
1990
|
-
"iframe",
|
|
1991
|
-
"embed",
|
|
1992
|
-
"script",
|
|
1993
|
-
"link"
|
|
1994
|
-
];
|
|
1995
|
-
var ID_SUFFIX_RSC = "_rsc";
|
|
1996
|
-
var ID_SUFFIX_SSR = "_ssr";
|
|
1997
|
-
var ID_SUFFIX_SHARED = "_shared";
|
|
1998
|
-
var DATA_BUNDLE = "data-bundle";
|
|
1999
|
-
var DATA_ROUTE = "data-route";
|
|
2000
|
-
var DATA_RUNTIME = "data-runtime";
|
|
2001
|
-
var DATA_TYPE = "data-type";
|
|
2002
|
-
var DATA_SRC = "data-src";
|
|
2003
|
-
var DATA_REMOTE_COMPONENTS_SHARED = "data-remote-components-shared";
|
|
2004
|
-
var TAG_REMOTE_COMPONENT = "remote-component";
|
|
2005
|
-
var NEXT_DATA_ID = "__NEXT_DATA__";
|
|
2006
|
-
var REMOTE_NEXT_DATA_ID = "__REMOTE_NEXT_DATA__";
|
|
2007
|
-
var NEXT_CONTAINER_ID = "__next";
|
|
2008
|
-
|
|
2009
|
-
// src/runtime/html/rewrite-srcset.ts
|
|
2010
|
-
function rewriteSrcset(srcset, base, resolve) {
|
|
2011
|
-
return srcset.split(",").map((entry) => {
|
|
2012
|
-
const [url, descriptor] = entry.trim().split(/\s+/);
|
|
2013
|
-
if (!url)
|
|
2014
|
-
return entry;
|
|
2015
|
-
const absoluteUrl = new URL(url, base).href;
|
|
2016
|
-
const resolvedUrl = resolve ? resolve(absoluteUrl) : absoluteUrl;
|
|
2017
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
2018
|
-
}).join(", ");
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
// src/runtime/html/apply-origin.ts
|
|
2022
|
-
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
2023
|
-
if (url.origin !== location.origin) {
|
|
2024
|
-
const nodes = doc.querySelectorAll(
|
|
2025
|
-
ORIGIN_REWRITE_TAGS.map(
|
|
2026
|
-
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
2027
|
-
).join(",")
|
|
2028
|
-
);
|
|
2029
|
-
nodes.forEach((node) => {
|
|
2030
|
-
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
2031
|
-
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
2032
|
-
const isScript = node.tagName.toLowerCase() === "script";
|
|
2033
|
-
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
2034
|
-
}
|
|
2035
|
-
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
2036
|
-
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
2037
|
-
node.setAttribute(
|
|
2038
|
-
"href",
|
|
2039
|
-
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
2040
|
-
);
|
|
2041
|
-
}
|
|
2042
|
-
if (node.hasAttribute("srcset")) {
|
|
2043
|
-
const raw = node.getAttribute("srcset");
|
|
2044
|
-
if (raw) {
|
|
2045
|
-
const resolve = resolveClientUrl ? (abs) => resolveClientUrl(abs) ?? abs : void 0;
|
|
2046
|
-
node.setAttribute("srcset", rewriteSrcset(raw, url, resolve));
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
if (node.hasAttribute("imagesrcset")) {
|
|
2050
|
-
const raw = node.getAttribute("imagesrcset");
|
|
2051
|
-
if (raw) {
|
|
2052
|
-
const resolve = resolveClientUrl ? (abs) => resolveClientUrl(abs) ?? abs : void 0;
|
|
2053
|
-
node.setAttribute("imagesrcset", rewriteSrcset(raw, url, resolve));
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
// src/runtime/html/parse-remote-html.ts
|
|
2061
|
-
init_constants2();
|
|
2062
|
-
|
|
2063
|
-
// src/runtime/metadata.ts
|
|
2064
|
-
init_constants2();
|
|
2065
|
-
var VALID_RUNTIMES = /* @__PURE__ */ new Set(["webpack", "turbopack", "script"]);
|
|
2066
|
-
var VALID_TYPES = /* @__PURE__ */ new Set([
|
|
2067
|
-
"nextjs",
|
|
2068
|
-
"remote-component",
|
|
2069
|
-
"unknown"
|
|
2070
|
-
]);
|
|
2071
|
-
function isRuntime(value) {
|
|
2072
|
-
return VALID_RUNTIMES.has(value);
|
|
2073
|
-
}
|
|
2074
|
-
function isComponentType(value) {
|
|
2075
|
-
return VALID_TYPES.has(value);
|
|
2076
|
-
}
|
|
2077
|
-
function toRuntime(value) {
|
|
2078
|
-
return value && isRuntime(value) ? value : "webpack";
|
|
2079
|
-
}
|
|
2080
|
-
function toComponentType(value) {
|
|
2081
|
-
return value && isComponentType(value) ? value : "unknown";
|
|
2082
|
-
}
|
|
2083
|
-
function buildMetadata(attrs, url) {
|
|
2084
|
-
const id = attrs.id || DEFAULT_COMPONENT_NAME;
|
|
2085
|
-
const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION || DEFAULT_BUNDLE_NAME;
|
|
2086
|
-
return {
|
|
2087
|
-
name: attrs.name || id.replace(/_ssr$/, ""),
|
|
2088
|
-
bundle,
|
|
2089
|
-
route: attrs.route || url.pathname || DEFAULT_ROUTE,
|
|
2090
|
-
runtime: toRuntime(attrs.runtime),
|
|
2091
|
-
id,
|
|
2092
|
-
type: toComponentType(attrs.type)
|
|
2093
|
-
};
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
// src/runtime/html/parse-remote-html.ts
|
|
2097
|
-
init_error();
|
|
2098
|
-
function validateSingleComponent(doc, name, url) {
|
|
2099
|
-
if (doc.querySelectorAll(`div[${DATA_BUNDLE}][${DATA_ROUTE}]`).length > 1 && !doc.querySelector(
|
|
2100
|
-
`div[${DATA_BUNDLE}][${DATA_ROUTE}][id^="${name}"]`
|
|
2101
|
-
) || doc.querySelectorAll(`${TAG_REMOTE_COMPONENT}:not([src])`).length > 1 && !doc.querySelector(`${TAG_REMOTE_COMPONENT}[name="${name}"]`)) {
|
|
2102
|
-
throw multipleRemoteComponentsError(url);
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
function findComponentElement(doc, name) {
|
|
2106
|
-
return doc.querySelector(`div[${DATA_BUNDLE}][${DATA_ROUTE}][id^="${name}"]`) ?? doc.querySelector(`div[${DATA_BUNDLE}][${DATA_ROUTE}]`) ?? doc.querySelector(`div#${NEXT_CONTAINER_ID}`) ?? doc.querySelector(`${TAG_REMOTE_COMPONENT}[name="${name}"]:not([src])`) ?? doc.querySelector(`${TAG_REMOTE_COMPONENT}:not([src])`);
|
|
2107
|
-
}
|
|
2108
|
-
function parseNextData(doc) {
|
|
2109
|
-
return JSON.parse(
|
|
2110
|
-
(doc.querySelector(`#${NEXT_DATA_ID}`) ?? doc.querySelector(`#${REMOTE_NEXT_DATA_ID}`))?.textContent ?? "null"
|
|
2111
|
-
);
|
|
2112
|
-
}
|
|
2113
|
-
function resolveComponentName(component, nextData, fallbackName) {
|
|
2114
|
-
const isRemoteComponent = component?.tagName.toLowerCase() === TAG_REMOTE_COMPONENT;
|
|
2115
|
-
const name = component?.getAttribute("id")?.replace(new RegExp(`${ID_SUFFIX_SSR}$`), "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
2116
|
-
return { name, isRemoteComponent };
|
|
2117
|
-
}
|
|
2118
|
-
function extractRemoteShared(doc, name, nextData) {
|
|
2119
|
-
const remoteSharedEl = doc.querySelector(
|
|
2120
|
-
`#${name}${ID_SUFFIX_SHARED}[${DATA_REMOTE_COMPONENTS_SHARED}]`
|
|
2121
|
-
);
|
|
2122
|
-
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
2123
|
-
remoteSharedEl?.remove();
|
|
2124
|
-
return remoteShared;
|
|
2125
|
-
}
|
|
2126
|
-
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
2127
|
-
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
2128
|
-
throw new RemoteComponentsError(
|
|
2129
|
-
`Remote Component not found on ${url}.${name !== DEFAULT_COMPONENT_NAME ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
|
|
2130
|
-
);
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
function extractLinks(doc, component) {
|
|
2134
|
-
return Array.from(doc.querySelectorAll("link[href]")).filter(
|
|
2135
|
-
(link) => !component.contains(link)
|
|
2136
|
-
);
|
|
2137
|
-
}
|
|
2138
|
-
function extractScripts(doc, component, isRemoteComponent) {
|
|
2139
|
-
return Array.from(
|
|
2140
|
-
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
2141
|
-
`script[src],script[${DATA_SRC}]`
|
|
2142
|
-
)
|
|
2143
|
-
);
|
|
2144
|
-
}
|
|
2145
|
-
function parseRemoteComponentDocument(doc, name, url) {
|
|
2146
|
-
validateSingleComponent(doc, name, url.href);
|
|
2147
|
-
const component = findComponentElement(doc, name);
|
|
2148
|
-
const nextData = parseNextData(doc);
|
|
2149
|
-
const { name: resolvedName, isRemoteComponent } = resolveComponentName(
|
|
2150
|
-
component,
|
|
2151
|
-
nextData,
|
|
2152
|
-
name
|
|
2153
|
-
);
|
|
2154
|
-
const rsc = doc.querySelector(`#${resolvedName}${ID_SUFFIX_RSC}`);
|
|
2155
|
-
const metadata = buildMetadata(
|
|
2156
|
-
{
|
|
2157
|
-
name: resolvedName,
|
|
2158
|
-
bundle: component?.getAttribute(DATA_BUNDLE) || nextData?.props.__REMOTE_COMPONENT__?.bundle,
|
|
2159
|
-
route: component?.getAttribute(DATA_ROUTE) ?? nextData?.page,
|
|
2160
|
-
runtime: component?.getAttribute(DATA_RUNTIME) ?? nextData?.props.__REMOTE_COMPONENT__?.runtime ?? RUNTIME_SCRIPT,
|
|
2161
|
-
id: component?.getAttribute("id"),
|
|
2162
|
-
type: component?.getAttribute(DATA_TYPE)
|
|
2163
|
-
},
|
|
2164
|
-
url
|
|
2165
|
-
);
|
|
2166
|
-
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
2167
|
-
validateComponentFound(
|
|
2168
|
-
component,
|
|
2169
|
-
rsc,
|
|
2170
|
-
nextData,
|
|
2171
|
-
isRemoteComponent,
|
|
2172
|
-
url.href,
|
|
2173
|
-
resolvedName
|
|
2174
|
-
);
|
|
2175
|
-
const links = extractLinks(doc, component);
|
|
2176
|
-
const scripts = extractScripts(doc, component, isRemoteComponent);
|
|
2177
|
-
return {
|
|
2178
|
-
component,
|
|
2179
|
-
name: resolvedName,
|
|
2180
|
-
isRemoteComponent,
|
|
2181
|
-
metadata,
|
|
2182
|
-
nextData,
|
|
2183
|
-
rsc,
|
|
2184
|
-
remoteShared,
|
|
2185
|
-
links,
|
|
2186
|
-
scripts
|
|
2187
|
-
};
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
// src/runtime/loaders/component-loader.ts
|
|
2191
|
-
init_apply_shared_modules();
|
|
2192
|
-
init_next_client_pages_loader();
|
|
2193
|
-
init_shared_module_resolver();
|
|
2194
|
-
import * as React from "react";
|
|
2195
|
-
import * as JSXDevRuntime from "react/jsx-dev-runtime";
|
|
2196
|
-
import * as JSXRuntime from "react/jsx-runtime";
|
|
2197
|
-
import * as ReactDOM from "react-dom";
|
|
2198
|
-
import * as ReactDOMClient from "react-dom/client";
|
|
2199
|
-
|
|
2200
|
-
// src/runtime/rsc.ts
|
|
2201
|
-
import { ReadableStream } from "web-streams-polyfill";
|
|
2202
|
-
function fixPayload(payload) {
|
|
2203
|
-
if (Array.isArray(payload)) {
|
|
2204
|
-
if (payload[0] === "$") {
|
|
2205
|
-
fixPayload(payload[3]);
|
|
2206
|
-
if (payload.length === 4) {
|
|
2207
|
-
payload.push(null, null, 1);
|
|
2208
|
-
}
|
|
2209
|
-
} else {
|
|
2210
|
-
for (const item of payload) {
|
|
2211
|
-
fixPayload(item);
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
} else if (typeof payload === "object" && payload !== null) {
|
|
2215
|
-
for (const key in payload) {
|
|
2216
|
-
fixPayload(payload[key]);
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
function buildRSCChunks(rscName, data) {
|
|
2221
|
-
const chunks = [];
|
|
2222
|
-
for (const chunk of data) {
|
|
2223
|
-
for (const line of chunk.split("\n")) {
|
|
2224
|
-
const match = /\.push\("(?<rsc>.*)"\);$/.exec(line);
|
|
2225
|
-
if (match?.groups?.rsc) {
|
|
2226
|
-
chunks.push(JSON.parse(`"${match.groups.rsc}"`));
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
|
-
}
|
|
2230
|
-
return chunks;
|
|
2231
|
-
}
|
|
2232
|
-
function createRSCStream(rscName, data) {
|
|
2233
|
-
return new ReadableStream({
|
|
2234
|
-
type: "bytes",
|
|
2235
|
-
start(controller) {
|
|
2236
|
-
const encoder = new TextEncoder();
|
|
2237
|
-
const self = globalThis;
|
|
2238
|
-
if (data.length > 0) {
|
|
2239
|
-
const parsed = buildRSCChunks(rscName, data);
|
|
2240
|
-
if (parsed.length > 0) {
|
|
2241
|
-
self[rscName] = self[rscName] ?? [];
|
|
2242
|
-
self[rscName].push(...parsed);
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
const allChunks = (self[rscName] ?? [`0:[null]
|
|
2246
|
-
`]).join("");
|
|
2247
|
-
self[rscName] = null;
|
|
2248
|
-
allChunks.split("\n").forEach((chunk) => {
|
|
2249
|
-
if (chunk.length > 0) {
|
|
2250
|
-
const { before, id, prefix, payload } = /^(?<before>[^:]*?)?(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\[.*\])/.exec(
|
|
2251
|
-
chunk
|
|
2252
|
-
)?.groups ?? {};
|
|
2253
|
-
if (payload) {
|
|
2254
|
-
const jsonPayload = JSON.parse(payload);
|
|
2255
|
-
fixPayload(jsonPayload);
|
|
2256
|
-
const reconstruct = `${before ?? ""}${id}:${prefix ?? ""}${JSON.stringify(jsonPayload)}`;
|
|
2257
|
-
controller.enqueue(encoder.encode(`${reconstruct}
|
|
2258
|
-
`));
|
|
2259
|
-
} else {
|
|
2260
|
-
controller.enqueue(encoder.encode(`${chunk}
|
|
2261
|
-
`));
|
|
2262
|
-
}
|
|
2263
|
-
} else {
|
|
2264
|
-
controller.enqueue(encoder.encode(`${chunk}
|
|
2265
|
-
`));
|
|
2266
|
-
}
|
|
2267
|
-
});
|
|
2268
|
-
controller.close();
|
|
2269
|
-
}
|
|
2270
|
-
});
|
|
2271
|
-
}
|
|
2272
|
-
|
|
2273
|
-
// src/runtime/loaders/component-loader.ts
|
|
2274
|
-
init_remote_scope_setup();
|
|
2275
|
-
init_shared_modules();
|
|
2276
|
-
init_error();
|
|
2277
|
-
init_logger();
|
|
2278
|
-
init_script_loader();
|
|
2279
|
-
|
|
2280
|
-
// src/host/shared/pipeline.ts
|
|
2281
|
-
init_static_loader();
|
|
2282
|
-
init_patterns();
|
|
2283
|
-
init_utils();
|
|
2284
|
-
init_error();
|
|
2285
|
-
function preparePipeline(input) {
|
|
2286
|
-
const parser = new DOMParser();
|
|
2287
|
-
const doc = parser.parseFromString(input.html, "text/html");
|
|
2288
|
-
const parsed = parseRemoteComponentDocument(doc, input.name, input.url);
|
|
2289
|
-
const remoteShared = input.remoteShared ?? parsed.remoteShared;
|
|
2290
|
-
if ("__remote_components_missing_shared__" in remoteShared) {
|
|
2291
|
-
throw new RemoteComponentsError(
|
|
2292
|
-
remoteShared.__remote_components_missing_shared__
|
|
2293
|
-
);
|
|
2294
|
-
}
|
|
2295
|
-
applyOriginToNodes(doc, input.url, input.resolveClientUrl);
|
|
2296
|
-
const scriptDescriptors = buildScriptDescriptors(parsed.scripts, input.url);
|
|
2297
|
-
return { doc, parsed, scriptDescriptors };
|
|
2298
|
-
}
|
|
2299
|
-
function buildScriptDescriptors(scripts, url) {
|
|
2300
|
-
return scripts.map((script) => {
|
|
2301
|
-
const scriptSrc = script.getAttribute("data-src") || script.getAttribute("src") || script.src;
|
|
2302
|
-
const { prefix, id: path } = REMOTE_COMPONENT_REGEX.exec(scriptSrc)?.groups ?? {
|
|
2303
|
-
prefix: void 0,
|
|
2304
|
-
id: scriptSrc
|
|
2305
|
-
};
|
|
2306
|
-
return {
|
|
2307
|
-
src: new URL(collapseDoubleSlashes(`${prefix ?? ""}${path}`), url).href
|
|
2308
|
-
};
|
|
2309
|
-
});
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
|
-
// src/host/shared/state.ts
|
|
2313
|
-
function createHostState() {
|
|
2314
|
-
return {
|
|
2315
|
-
stage: "idle",
|
|
2316
|
-
prevSrc: void 0,
|
|
2317
|
-
prevUrl: void 0,
|
|
2318
|
-
prevName: void 0,
|
|
2319
|
-
prevIsRemoteComponent: false,
|
|
2320
|
-
abortController: void 0
|
|
2321
|
-
};
|
|
2322
|
-
}
|
|
2323
|
-
|
|
2324
|
-
// src/host/utils/resolve-name-from-src.ts
|
|
2325
|
-
function resolveNameFromSrc(src, defaultName) {
|
|
2326
|
-
if (!src) {
|
|
2327
|
-
return defaultName;
|
|
2328
|
-
}
|
|
2329
|
-
const hash = typeof src === "string" ? src : src.hash;
|
|
2330
|
-
const hashIndex = hash.indexOf("#");
|
|
2331
|
-
if (hashIndex < 0) {
|
|
2332
|
-
return defaultName;
|
|
2333
|
-
}
|
|
2334
|
-
const name = hash.slice(hashIndex + 1);
|
|
2335
|
-
return name || defaultName;
|
|
2336
|
-
}
|
|
2337
|
-
|
|
2338
|
-
// src/host/html/index.tsx
|
|
2339
|
-
init_constants2();
|
|
2340
|
-
init_namespace();
|
|
2341
|
-
|
|
2342
|
-
// src/runtime/url/resolve-client-url.ts
|
|
2343
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
2344
|
-
const remoteOrigin = parseOrigin(remoteSrc);
|
|
2345
|
-
return (url) => {
|
|
2346
|
-
const urlOrigin = parseOrigin(url);
|
|
2347
|
-
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
2348
|
-
return void 0;
|
|
2349
|
-
}
|
|
2350
|
-
return resolveClientUrl(remoteSrc, url);
|
|
2351
|
-
};
|
|
2352
|
-
}
|
|
2353
|
-
function parseOrigin(url) {
|
|
2354
|
-
try {
|
|
2355
|
-
return new URL(url).origin;
|
|
2356
|
-
} catch {
|
|
2357
|
-
return void 0;
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
|
|
2361
|
-
// src/runtime/url/default-resolve-client-url.ts
|
|
2362
|
-
function bindResolveClientUrl(prop, remoteSrc) {
|
|
2363
|
-
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
2364
|
-
}
|
|
2365
|
-
|
|
2366
|
-
// src/host/html/index.tsx
|
|
2367
|
-
init_utils();
|
|
2368
|
-
init_abort();
|
|
2369
|
-
init_error();
|
|
2370
|
-
init_logger();
|
|
2371
|
-
|
|
2372
37
|
// src/host/html/attach-styles.ts
|
|
2373
|
-
init_error();
|
|
2374
38
|
async function attachStyles({
|
|
2375
39
|
doc,
|
|
2376
40
|
component,
|
|
@@ -2453,7 +117,6 @@ async function attachStyles({
|
|
|
2453
117
|
}
|
|
2454
118
|
|
|
2455
119
|
// src/host/html/runtime/index.ts
|
|
2456
|
-
init_error();
|
|
2457
120
|
async function getRuntime(type, url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
2458
121
|
if (typeof globalThis.process === "undefined") {
|
|
2459
122
|
globalThis.process = {
|
|
@@ -2461,11 +124,11 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2461
124
|
};
|
|
2462
125
|
}
|
|
2463
126
|
if (type === "webpack") {
|
|
2464
|
-
const { webpackRuntime
|
|
2465
|
-
return
|
|
127
|
+
const { webpackRuntime } = await import("../webpack-NPZNXRNL.js");
|
|
128
|
+
return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);
|
|
2466
129
|
} else if (type === "turbopack") {
|
|
2467
|
-
const { turbopackRuntime
|
|
2468
|
-
return
|
|
130
|
+
const { turbopackRuntime } = await import("../turbopack-5LW6V6IT.js");
|
|
131
|
+
return turbopackRuntime(
|
|
2469
132
|
url,
|
|
2470
133
|
bundle,
|
|
2471
134
|
shared,
|
|
@@ -2473,8 +136,8 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2473
136
|
resolveClientUrl
|
|
2474
137
|
);
|
|
2475
138
|
} else if (type === "script") {
|
|
2476
|
-
const { scriptRuntime
|
|
2477
|
-
return
|
|
139
|
+
const { scriptRuntime } = await import("../script-VPOI7ARP.js");
|
|
140
|
+
return scriptRuntime(resolveClientUrl);
|
|
2478
141
|
}
|
|
2479
142
|
throw new RemoteComponentsError(
|
|
2480
143
|
`Remote Components runtime "${type}" is not supported. Supported runtimes are "webpack", "turbopack", and "script".`
|
|
@@ -2482,7 +145,7 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2482
145
|
}
|
|
2483
146
|
|
|
2484
147
|
// src/host/html/index.tsx
|
|
2485
|
-
import { jsx
|
|
148
|
+
import { jsx } from "react/jsx-runtime";
|
|
2486
149
|
if (typeof HTMLElement !== "undefined") {
|
|
2487
150
|
class RemoteComponent extends HTMLElement {
|
|
2488
151
|
name = DEFAULT_COMPONENT_NAME;
|
|
@@ -2834,7 +497,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2834
497
|
const {
|
|
2835
498
|
self,
|
|
2836
499
|
createFromReadableStream,
|
|
2837
|
-
nextClientPagesLoader
|
|
500
|
+
nextClientPagesLoader,
|
|
2838
501
|
preloadScripts
|
|
2839
502
|
} = await getRuntime(
|
|
2840
503
|
metadataObj.runtime,
|
|
@@ -2937,7 +600,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2937
600
|
const root = this.reactRoot;
|
|
2938
601
|
startTransition(() => {
|
|
2939
602
|
root.render(
|
|
2940
|
-
/* @__PURE__ */
|
|
603
|
+
/* @__PURE__ */ jsx(
|
|
2941
604
|
RemoteComponentFromReadableStream,
|
|
2942
605
|
{
|
|
2943
606
|
initial: false,
|
|
@@ -2952,10 +615,10 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2952
615
|
// hydrateRoot expects a document or element, but it works for the shadow DOM too
|
|
2953
616
|
// @ts-expect-error support for shadow DOM
|
|
2954
617
|
this.root,
|
|
2955
|
-
/* @__PURE__ */
|
|
618
|
+
/* @__PURE__ */ jsx(RemoteComponentFromReadableStream, { initial: true, name: this.name })
|
|
2956
619
|
);
|
|
2957
620
|
} else if (nextData) {
|
|
2958
|
-
const { Component, App } =
|
|
621
|
+
const { Component, App } = nextClientPagesLoader(
|
|
2959
622
|
this.bundle,
|
|
2960
623
|
nextData.page ?? "/",
|
|
2961
624
|
this.root
|
|
@@ -2975,12 +638,12 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2975
638
|
}
|
|
2976
639
|
remoteComponent.emitter.load(remoteComponent.src ?? "");
|
|
2977
640
|
}, [initial, remoteComponent]);
|
|
2978
|
-
return NextApp ? /* @__PURE__ */
|
|
641
|
+
return NextApp ? /* @__PURE__ */ jsx(NextApp, { Component: NextComponent, ...nextData.props }) : /* @__PURE__ */ jsx(NextComponent, { ...nextData.props });
|
|
2979
642
|
})(App, Component, this);
|
|
2980
643
|
if (this.reactRoot) {
|
|
2981
644
|
const root = this.reactRoot;
|
|
2982
645
|
startTransition(() => {
|
|
2983
|
-
root.render(/* @__PURE__ */
|
|
646
|
+
root.render(/* @__PURE__ */ jsx(RemoteComponentFromNext, { initial: false }));
|
|
2984
647
|
doCleanup();
|
|
2985
648
|
if (isCurrentLoad()) {
|
|
2986
649
|
this.hostState.stage = "loaded";
|
|
@@ -2992,7 +655,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2992
655
|
// hydrateRoot expects a document or element, but it works for the shadow DOM too
|
|
2993
656
|
// @ts-expect-error support for shadow DOM
|
|
2994
657
|
this.root,
|
|
2995
|
-
/* @__PURE__ */
|
|
658
|
+
/* @__PURE__ */ jsx(RemoteComponentFromNext, { initial: true })
|
|
2996
659
|
);
|
|
2997
660
|
}
|
|
2998
661
|
if (this.fouc) {
|