remote-components 0.3.1 → 0.3.3
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/config/nextjs.cjs +36 -25
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.js +30 -19
- package/dist/config/nextjs.js.map +1 -1
- package/dist/host/defaults/app.cjs +2 -5
- package/dist/host/defaults/app.cjs.map +1 -1
- package/dist/host/defaults/app.d.ts +1 -3
- package/dist/host/defaults/app.js +1 -4
- package/dist/host/defaults/app.js.map +1 -1
- package/dist/host/defaults/pages.cjs +2 -5
- package/dist/host/defaults/pages.cjs.map +1 -1
- package/dist/host/defaults/pages.d.ts +1 -3
- package/dist/host/defaults/pages.js +1 -4
- package/dist/host/defaults/pages.js.map +1 -1
- package/dist/host/defaults/shared.cjs +32 -0
- package/dist/host/defaults/shared.cjs.map +1 -0
- package/dist/host/defaults/shared.d.ts +3 -0
- package/dist/host/defaults/shared.js +8 -0
- package/dist/host/defaults/shared.js.map +1 -0
- package/dist/host/html.cjs +390 -357
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +390 -357
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +477 -453
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +485 -461
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/react.cjs +382 -367
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +382 -367
- package/dist/host/react.js.map +1 -1
- package/dist/internal/host/nextjs/app-client.cjs +2 -19
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/host/nextjs/app-client.js +1 -8
- package/dist/internal/host/nextjs/app-client.js.map +1 -1
- package/dist/internal/host/nextjs/image-shared.cjs +2 -2
- package/dist/internal/host/nextjs/image-shared.cjs.map +1 -1
- package/dist/internal/host/nextjs/image-shared.js +2 -2
- package/dist/internal/host/nextjs/image-shared.js.map +1 -1
- package/dist/internal/host/nextjs/shared-import.cjs +46 -0
- package/dist/internal/host/nextjs/shared-import.cjs.map +1 -0
- package/dist/internal/host/nextjs/shared-import.d.ts +3 -0
- package/dist/internal/host/nextjs/shared-import.js +12 -0
- package/dist/internal/host/nextjs/shared-import.js.map +1 -0
- package/dist/internal/host/server/fetch-remote-component.cjs +20 -1
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.js +20 -1
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/host/shared/remote-image-loader.cjs +2 -5
- package/dist/internal/host/shared/remote-image-loader.cjs.map +1 -1
- package/dist/internal/host/shared/remote-image-loader.js +2 -5
- package/dist/internal/host/shared/remote-image-loader.js.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.cjs +7 -0
- package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.js +7 -0
- package/dist/internal/runtime/loaders/script-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +76 -126
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.d.ts +22 -7
- package/dist/internal/runtime/turbopack/chunk-loader.js +85 -131
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/module.cjs +53 -65
- package/dist/internal/runtime/turbopack/module.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/module.d.ts +14 -11
- package/dist/internal/runtime/turbopack/module.js +51 -64
- package/dist/internal/runtime/turbopack/module.js.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.cjs +101 -0
- package/dist/internal/runtime/turbopack/remote-scope.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/remote-scope.d.ts +55 -0
- package/dist/internal/runtime/turbopack/remote-scope.js +73 -0
- package/dist/internal/runtime/turbopack/remote-scope.js.map +1 -0
- package/dist/internal/runtime/turbopack/shared-modules.cjs +64 -56
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.d.ts +13 -4
- package/dist/internal/runtime/turbopack/shared-modules.js +64 -57
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs +39 -29
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/webpack-runtime.d.ts +5 -2
- package/dist/internal/runtime/turbopack/webpack-runtime.js +42 -32
- package/dist/internal/runtime/turbopack/webpack-runtime.js.map +1 -1
- package/dist/internal/runtime/types.cjs.map +1 -1
- package/dist/internal/runtime/types.d.ts +4 -3
- package/dist/internal/utils/logger.cjs.map +1 -1
- package/dist/internal/utils/logger.d.ts +1 -1
- package/dist/internal/utils/logger.js.map +1 -1
- package/dist/internal/utils/project-id-env.cjs +31 -0
- package/dist/internal/utils/project-id-env.cjs.map +1 -0
- package/dist/internal/utils/project-id-env.d.ts +7 -0
- package/dist/internal/utils/project-id-env.js +7 -0
- package/dist/internal/utils/project-id-env.js.map +1 -0
- package/dist/internal/utils/project-id.cjs +46 -0
- package/dist/internal/utils/project-id.cjs.map +1 -0
- package/dist/internal/utils/project-id.d.ts +8 -0
- package/dist/internal/utils/project-id.js +22 -0
- package/dist/internal/utils/project-id.js.map +1 -0
- package/dist/internal/utils.cjs +5 -0
- package/dist/internal/utils.cjs.map +1 -1
- package/dist/internal/utils.d.ts +15 -1
- package/dist/internal/utils.js +4 -0
- package/dist/internal/utils.js.map +1 -1
- package/dist/remote/defaults/app.cjs +2 -5
- package/dist/remote/defaults/app.cjs.map +1 -1
- package/dist/remote/defaults/app.d.ts +1 -3
- package/dist/remote/defaults/app.js +1 -4
- package/dist/remote/defaults/app.js.map +1 -1
- package/dist/remote/defaults/pages.cjs +2 -5
- package/dist/remote/defaults/pages.cjs.map +1 -1
- package/dist/remote/defaults/pages.d.ts +1 -3
- package/dist/remote/defaults/pages.js +1 -4
- package/dist/remote/defaults/pages.js.map +1 -1
- package/dist/{internal/host/shared/resolved-data.cjs → remote/defaults/shared.cjs} +18 -3
- package/dist/remote/defaults/shared.cjs.map +1 -0
- package/dist/remote/defaults/shared.d.ts +3 -0
- package/dist/remote/defaults/shared.js +8 -0
- package/dist/remote/defaults/shared.js.map +1 -0
- package/dist/remote/html.cjs.map +1 -1
- package/dist/remote/html.js.map +1 -1
- package/dist/remote/nextjs/app.cjs +2 -1
- package/dist/remote/nextjs/app.cjs.map +1 -1
- package/dist/remote/nextjs/app.js +2 -1
- package/dist/remote/nextjs/app.js.map +1 -1
- package/dist/remote/nextjs/pages.cjs +2 -1
- package/dist/remote/nextjs/pages.cjs.map +1 -1
- package/dist/remote/nextjs/pages.js +2 -1
- package/dist/remote/nextjs/pages.js.map +1 -1
- package/package.json +1 -1
- package/dist/internal/host/shared/resolved-data.cjs.map +0 -1
- package/dist/internal/host/shared/resolved-data.d.ts +0 -48
- package/dist/internal/host/shared/resolved-data.js +0 -1
- package/dist/internal/host/shared/resolved-data.js.map +0 -1
|
@@ -20,117 +20,67 @@ var init_constants = __esm({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
// src/host/defaults/shared.ts
|
|
24
|
+
var shared;
|
|
25
|
+
var init_shared = __esm({
|
|
26
|
+
"src/host/defaults/shared.ts"() {
|
|
27
|
+
"use strict";
|
|
28
|
+
init_constants();
|
|
29
|
+
shared = {
|
|
30
|
+
__remote_components_missing_shared__: () => Promise.reject(new Error(MISSING_SHARED_MODULES_MESSAGE))
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
23
35
|
// src/host/defaults/app.ts
|
|
24
36
|
var app_exports = {};
|
|
25
37
|
__export(app_exports, {
|
|
26
38
|
shared: () => shared
|
|
27
39
|
});
|
|
28
|
-
var shared;
|
|
29
40
|
var init_app = __esm({
|
|
30
41
|
"src/host/defaults/app.ts"() {
|
|
31
42
|
"use strict";
|
|
32
|
-
|
|
33
|
-
shared = {
|
|
34
|
-
__remote_components_missing_shared__: () => Promise.reject(new Error(MISSING_SHARED_MODULES_MESSAGE))
|
|
35
|
-
};
|
|
43
|
+
init_shared();
|
|
36
44
|
}
|
|
37
45
|
});
|
|
38
46
|
|
|
39
47
|
// src/host/nextjs/app-client-only.tsx
|
|
40
48
|
import { useMemo as useMemo3 } from "react";
|
|
41
49
|
|
|
42
|
-
// src/
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
return self.__remote_bundle_url__?.[bundle]?.origin ?? "";
|
|
46
|
-
}
|
|
47
|
-
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
48
|
-
const loader = Object.assign(
|
|
49
|
-
({
|
|
50
|
-
config,
|
|
51
|
-
src,
|
|
52
|
-
width,
|
|
53
|
-
quality
|
|
54
|
-
}) => {
|
|
55
|
-
const q = quality ?? 75;
|
|
56
|
-
const remoteOrigin = getRemoteBundleOrigin(bundle);
|
|
57
|
-
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
58
|
-
const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
|
|
59
|
-
const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
60
|
-
return resolveClientUrl?.(url) ?? url;
|
|
61
|
-
},
|
|
62
|
-
// Signals to getImgProps that this is a default loader (not a user-defined
|
|
63
|
-
// one), enabling srcSet generation with device/image sizes from the config.
|
|
64
|
-
{ __next_img_default: true }
|
|
65
|
-
);
|
|
66
|
-
return loader;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// src/runtime/url/resolve-client-url.ts
|
|
70
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
71
|
-
const remoteOrigin = parseOrigin(remoteSrc);
|
|
72
|
-
return (url) => {
|
|
73
|
-
const urlOrigin = parseOrigin(url);
|
|
74
|
-
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
75
|
-
return void 0;
|
|
76
|
-
}
|
|
77
|
-
return resolveClientUrl(remoteSrc, url);
|
|
78
|
-
};
|
|
50
|
+
// src/utils/index.ts
|
|
51
|
+
function escapeString(str) {
|
|
52
|
+
return str.replace(/[^a-z0-9]/g, "_");
|
|
79
53
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
return new URL(url).origin;
|
|
83
|
-
} catch {
|
|
84
|
-
return void 0;
|
|
85
|
-
}
|
|
54
|
+
function computeScopedName(name, options) {
|
|
55
|
+
return options.isCrossOrigin ? `${name}_${escapeString(options.remoteHost.toLowerCase())}` : name;
|
|
86
56
|
}
|
|
57
|
+
var attrToProp = {
|
|
58
|
+
fetchpriority: "fetchPriority",
|
|
59
|
+
crossorigin: "crossOrigin",
|
|
60
|
+
imagesrcset: "imageSrcSet",
|
|
61
|
+
imagesizes: "imageSizes",
|
|
62
|
+
srcset: "srcSet"
|
|
63
|
+
};
|
|
87
64
|
|
|
88
|
-
// src/runtime/
|
|
89
|
-
|
|
90
|
-
|
|
65
|
+
// src/runtime/constants.ts
|
|
66
|
+
var DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
|
|
67
|
+
var DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
|
|
68
|
+
var DEFAULT_ROUTE = "/";
|
|
69
|
+
var RUNTIME_WEBPACK = "webpack";
|
|
70
|
+
var RUNTIME_TURBOPACK = "turbopack";
|
|
71
|
+
var RUNTIME_SCRIPT = "script";
|
|
72
|
+
function getBundleKey(bundle) {
|
|
73
|
+
return escapeString(bundle);
|
|
91
74
|
}
|
|
92
75
|
|
|
93
|
-
// src/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return bindResolveClientUrl(unbound, remoteSrc);
|
|
100
|
-
}
|
|
101
|
-
function createImageLoaderSharedEntries({
|
|
102
|
-
bound,
|
|
103
|
-
unbound
|
|
104
|
-
} = {}) {
|
|
105
|
-
const entry = (bundle) => {
|
|
106
|
-
const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);
|
|
107
|
-
return Promise.resolve({
|
|
108
|
-
default: createRemoteImageLoader(bundle, resolveClientUrl),
|
|
109
|
-
__esModule: true
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
return {
|
|
113
|
-
"next/dist/shared/lib/image-loader": entry,
|
|
114
|
-
"next/dist/esm/shared/lib/image-loader": entry
|
|
115
|
-
};
|
|
76
|
+
// src/runtime/patterns.ts
|
|
77
|
+
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
78
|
+
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
79
|
+
var DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
80
|
+
function collapseDoubleSlashes(path) {
|
|
81
|
+
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
116
82
|
}
|
|
117
83
|
|
|
118
|
-
// src/host/nextjs/app-client-only.tsx
|
|
119
|
-
import { RemoteComponentsContext } from "#internal/host/react/context";
|
|
120
|
-
|
|
121
|
-
// src/host/react/index.tsx
|
|
122
|
-
import {
|
|
123
|
-
startTransition,
|
|
124
|
-
useEffect,
|
|
125
|
-
useId,
|
|
126
|
-
useLayoutEffect as useLayoutEffect2,
|
|
127
|
-
useMemo as useMemo2,
|
|
128
|
-
useRef as useRef2,
|
|
129
|
-
useState as useState2
|
|
130
|
-
} from "react";
|
|
131
|
-
import { createPortal } from "react-dom";
|
|
132
|
-
import { useRemoteComponentsContext as useRemoteComponentsContext2 } from "#internal/host/react/context";
|
|
133
|
-
|
|
134
84
|
// src/utils/logger.ts
|
|
135
85
|
init_constants();
|
|
136
86
|
|
|
@@ -277,6 +227,166 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
277
227
|
}
|
|
278
228
|
}
|
|
279
229
|
|
|
230
|
+
// src/runtime/turbopack/remote-scope.ts
|
|
231
|
+
function getRegistry() {
|
|
232
|
+
const self = globalThis;
|
|
233
|
+
if (!self.__remote_component_scopes__) {
|
|
234
|
+
self.__remote_component_scopes__ = /* @__PURE__ */ new Map();
|
|
235
|
+
}
|
|
236
|
+
return self.__remote_component_scopes__;
|
|
237
|
+
}
|
|
238
|
+
function createScope(name, url, runtime, resolveClientUrl) {
|
|
239
|
+
const isCrossOrigin = url.origin !== location.origin;
|
|
240
|
+
const scopedName = computeScopedName(name, {
|
|
241
|
+
remoteHost: url.host,
|
|
242
|
+
isCrossOrigin
|
|
243
|
+
});
|
|
244
|
+
const globalKey = getBundleKey(scopedName);
|
|
245
|
+
return {
|
|
246
|
+
name,
|
|
247
|
+
scopedName,
|
|
248
|
+
globalKey,
|
|
249
|
+
url,
|
|
250
|
+
runtime,
|
|
251
|
+
resolveClientUrl,
|
|
252
|
+
moduleCache: {},
|
|
253
|
+
sharedModules: {},
|
|
254
|
+
moduleGlobal: {}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function registerScope(scope) {
|
|
258
|
+
const registry = getRegistry();
|
|
259
|
+
registry.set(scope.scopedName, scope);
|
|
260
|
+
if (scope.scopedName !== scope.name) {
|
|
261
|
+
const existing = registry.get(scope.name);
|
|
262
|
+
if (existing && existing.scopedName !== scope.scopedName) {
|
|
263
|
+
logWarn(
|
|
264
|
+
"RemoteScope",
|
|
265
|
+
`Plain name "${scope.name}" already registered by scope "${existing.scopedName}" \u2014 overwriting with "${scope.scopedName}". Static hosts will only resolve the latest one.`
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
registry.set(scope.name, scope);
|
|
269
|
+
}
|
|
270
|
+
logDebug(
|
|
271
|
+
"RemoteScope",
|
|
272
|
+
`Registered scope "${scope.scopedName}" (${registry.size} total)`
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
function getScope(name) {
|
|
276
|
+
return getRegistry().get(name);
|
|
277
|
+
}
|
|
278
|
+
function formatRemoteId(scope, path) {
|
|
279
|
+
return `[${scope.scopedName}] ${path}`;
|
|
280
|
+
}
|
|
281
|
+
function parseRemoteId(id) {
|
|
282
|
+
const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;
|
|
283
|
+
if (groups?.bundle && groups.id) {
|
|
284
|
+
return {
|
|
285
|
+
bundle: groups.bundle,
|
|
286
|
+
path: groups.id,
|
|
287
|
+
prefix: groups.prefix ?? ""
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
return { bundle: "default", path: id, prefix: "" };
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// src/host/shared/remote-image-loader.ts
|
|
294
|
+
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
295
|
+
const loader = Object.assign(
|
|
296
|
+
({
|
|
297
|
+
config,
|
|
298
|
+
src,
|
|
299
|
+
width,
|
|
300
|
+
quality
|
|
301
|
+
}) => {
|
|
302
|
+
const q = quality ?? 75;
|
|
303
|
+
const remoteOrigin = getScope(bundle)?.url.origin ?? "";
|
|
304
|
+
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
305
|
+
const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
|
|
306
|
+
const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
307
|
+
return resolveClientUrl?.(url) ?? url;
|
|
308
|
+
},
|
|
309
|
+
// Signals to getImgProps that this is a default loader (not a user-defined
|
|
310
|
+
// one), enabling srcSet generation with device/image sizes from the config.
|
|
311
|
+
{ __next_img_default: true }
|
|
312
|
+
);
|
|
313
|
+
return loader;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/runtime/url/resolve-client-url.ts
|
|
317
|
+
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
318
|
+
const remoteOrigin = parseOrigin(remoteSrc);
|
|
319
|
+
return (url) => {
|
|
320
|
+
const urlOrigin = parseOrigin(url);
|
|
321
|
+
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
322
|
+
return void 0;
|
|
323
|
+
}
|
|
324
|
+
return resolveClientUrl(remoteSrc, url);
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function parseOrigin(url) {
|
|
328
|
+
try {
|
|
329
|
+
return new URL(url).origin;
|
|
330
|
+
} catch {
|
|
331
|
+
return void 0;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/runtime/url/default-resolve-client-url.ts
|
|
336
|
+
function bindResolveClientUrl(prop, remoteSrc) {
|
|
337
|
+
return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/host/nextjs/image-shared.ts
|
|
341
|
+
function resolveForBundle(unbound, bundle) {
|
|
342
|
+
if (!unbound)
|
|
343
|
+
return void 0;
|
|
344
|
+
const remoteSrc = getScope(bundle)?.url.href ?? "";
|
|
345
|
+
return bindResolveClientUrl(unbound, remoteSrc);
|
|
346
|
+
}
|
|
347
|
+
function createImageLoaderSharedEntries({
|
|
348
|
+
bound,
|
|
349
|
+
unbound
|
|
350
|
+
} = {}) {
|
|
351
|
+
const entry = (bundle) => {
|
|
352
|
+
const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);
|
|
353
|
+
return Promise.resolve({
|
|
354
|
+
default: createRemoteImageLoader(bundle, resolveClientUrl),
|
|
355
|
+
__esModule: true
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
return {
|
|
359
|
+
"next/dist/shared/lib/image-loader": entry,
|
|
360
|
+
"next/dist/esm/shared/lib/image-loader": entry
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/host/nextjs/shared-import.ts
|
|
365
|
+
async function tryImportShared() {
|
|
366
|
+
try {
|
|
367
|
+
const { shared: shared2 } = await Promise.resolve().then(() => (init_app(), app_exports));
|
|
368
|
+
return shared2;
|
|
369
|
+
} catch {
|
|
370
|
+
return {};
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// src/host/nextjs/app-client-only.tsx
|
|
375
|
+
import { RemoteComponentsContext } from "#internal/host/react/context";
|
|
376
|
+
|
|
377
|
+
// src/host/react/index.tsx
|
|
378
|
+
import {
|
|
379
|
+
startTransition,
|
|
380
|
+
useEffect,
|
|
381
|
+
useId,
|
|
382
|
+
useLayoutEffect as useLayoutEffect2,
|
|
383
|
+
useMemo as useMemo2,
|
|
384
|
+
useRef as useRef2,
|
|
385
|
+
useState as useState2
|
|
386
|
+
} from "react";
|
|
387
|
+
import { createPortal } from "react-dom";
|
|
388
|
+
import { useRemoteComponentsContext as useRemoteComponentsContext2 } from "#internal/host/react/context";
|
|
389
|
+
|
|
280
390
|
// src/host/server/fetch-headers.ts
|
|
281
391
|
function remoteFetchHeaders() {
|
|
282
392
|
return {
|
|
@@ -501,29 +611,6 @@ function resolveNameFromSrc(src, defaultName) {
|
|
|
501
611
|
return name || defaultName;
|
|
502
612
|
}
|
|
503
613
|
|
|
504
|
-
// src/utils/index.ts
|
|
505
|
-
function escapeString(str) {
|
|
506
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
507
|
-
}
|
|
508
|
-
var attrToProp = {
|
|
509
|
-
fetchpriority: "fetchPriority",
|
|
510
|
-
crossorigin: "crossOrigin",
|
|
511
|
-
imagesrcset: "imageSrcSet",
|
|
512
|
-
imagesizes: "imageSizes",
|
|
513
|
-
srcset: "srcSet"
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
// src/runtime/constants.ts
|
|
517
|
-
var DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
|
|
518
|
-
var DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
|
|
519
|
-
var DEFAULT_ROUTE = "/";
|
|
520
|
-
var RUNTIME_WEBPACK = "webpack";
|
|
521
|
-
var RUNTIME_TURBOPACK = "turbopack";
|
|
522
|
-
var RUNTIME_SCRIPT = "script";
|
|
523
|
-
function getBundleKey(bundle) {
|
|
524
|
-
return escapeString(bundle);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
614
|
// src/runtime/html/apply-origin.ts
|
|
528
615
|
var tagNames = [
|
|
529
616
|
"img",
|
|
@@ -998,14 +1085,6 @@ function createRSCStream(rscName, data) {
|
|
|
998
1085
|
});
|
|
999
1086
|
}
|
|
1000
1087
|
|
|
1001
|
-
// src/runtime/patterns.ts
|
|
1002
|
-
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
1003
|
-
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
1004
|
-
var DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
1005
|
-
function collapseDoubleSlashes(path) {
|
|
1006
|
-
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
1088
|
// src/runtime/turbopack/patterns.ts
|
|
1010
1089
|
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
1011
1090
|
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|[a-z])\.A\((?<sharedModuleId>[0-9]+)\)/;
|
|
@@ -1015,62 +1094,39 @@ var ASYNC_MODULE_ALL_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<vCb
|
|
|
1015
1094
|
var TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
1016
1095
|
|
|
1017
1096
|
// src/runtime/turbopack/chunk-loader.ts
|
|
1018
|
-
function
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
).href;
|
|
1047
|
-
if (url.endsWith(".css")) {
|
|
1048
|
-
logDebug("ChunkLoader", `Skipping CSS file: "${url}"`);
|
|
1049
|
-
return;
|
|
1050
|
-
}
|
|
1051
|
-
if (!self.__remote_components_turbopack_chunk_loader_promise__) {
|
|
1052
|
-
self.__remote_components_turbopack_chunk_loader_promise__ = {};
|
|
1053
|
-
}
|
|
1054
|
-
if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
|
|
1055
|
-
logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
|
|
1056
|
-
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
1057
|
-
}
|
|
1058
|
-
const resolvedUrl = resolveClientUrl?.(url) ?? url;
|
|
1059
|
-
logDebug("ChunkLoader", `Fetching chunk from: "${resolvedUrl}"`);
|
|
1060
|
-
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
|
|
1097
|
+
function loadChunkWithScope(scope, chunkId) {
|
|
1098
|
+
logDebug(
|
|
1099
|
+
"ChunkLoader",
|
|
1100
|
+
`loadChunkWithScope: "${chunkId}" (scope: "${scope.scopedName}")`
|
|
1101
|
+
);
|
|
1102
|
+
const self = globalThis;
|
|
1103
|
+
const { bundle, path, prefix } = parseRemoteId(chunkId);
|
|
1104
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : scope.runtime;
|
|
1105
|
+
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
1106
|
+
return Promise.resolve(void 0);
|
|
1107
|
+
}
|
|
1108
|
+
const rawPath = path ? collapseDoubleSlashes(`${prefix}${path}`) : "/";
|
|
1109
|
+
const url = new URL(rawPath, scope.url).href;
|
|
1110
|
+
if (url.endsWith(".css")) {
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
if (!self.__remote_components_turbopack_chunk_loader_promise__) {
|
|
1114
|
+
self.__remote_components_turbopack_chunk_loader_promise__ = {};
|
|
1115
|
+
}
|
|
1116
|
+
if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
|
|
1117
|
+
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
1118
|
+
}
|
|
1119
|
+
const resolvedUrl = scope.resolveClientUrl?.(url) ?? url;
|
|
1120
|
+
if (resolvedUrl !== url) {
|
|
1121
|
+
logDebug("ChunkLoader", `Proxied chunk URL: "${url}" \u2192 "${resolvedUrl}"`);
|
|
1122
|
+
}
|
|
1123
|
+
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise(
|
|
1124
|
+
(resolve, reject) => {
|
|
1061
1125
|
fetch(resolvedUrl).then((res) => res.text()).then((code) => {
|
|
1062
1126
|
const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
|
|
1063
1127
|
if (hasTurbopack) {
|
|
1064
|
-
return handleTurbopackChunk(code,
|
|
1128
|
+
return handleTurbopackChunk(code, scope, url);
|
|
1065
1129
|
}
|
|
1066
|
-
logDebug(
|
|
1067
|
-
"ChunkLoader",
|
|
1068
|
-
`Chunk does not contain globalThis.TURBOPACK or self.TURBOPACK: "${url}"`
|
|
1069
|
-
);
|
|
1070
|
-
logDebug(
|
|
1071
|
-
"ChunkLoader",
|
|
1072
|
-
`First 500 chars of chunk: ${code.slice(0, 500)}`
|
|
1073
|
-
);
|
|
1074
1130
|
}).then(resolve).catch((error) => {
|
|
1075
1131
|
const isProxied = isProxiedUrl(resolvedUrl);
|
|
1076
1132
|
if (isProxied) {
|
|
@@ -1080,17 +1136,29 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
1080
1136
|
reject(error);
|
|
1081
1137
|
}
|
|
1082
1138
|
});
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1139
|
+
}
|
|
1140
|
+
);
|
|
1141
|
+
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
1142
|
+
}
|
|
1143
|
+
function createChunkDispatcher() {
|
|
1144
|
+
return function __chunk_dispatcher__(chunkId, scriptBundle) {
|
|
1145
|
+
logDebug("ChunkDispatcher", `Dispatching chunk: "${chunkId}"`);
|
|
1146
|
+
const { bundle } = parseRemoteId(chunkId);
|
|
1147
|
+
const bundleName = bundle || scriptBundle || "default";
|
|
1148
|
+
const scope = getScope(bundleName);
|
|
1149
|
+
logDebug(
|
|
1150
|
+
"ChunkDispatcher",
|
|
1151
|
+
`Scope resolution: bundle="${bundleName}", scope=${scope?.scopedName ?? "null"}`
|
|
1152
|
+
);
|
|
1153
|
+
if (!scope) {
|
|
1154
|
+
logWarn("ChunkDispatcher", `No scope found for bundle "${bundleName}"`);
|
|
1155
|
+
return Promise.resolve(void 0);
|
|
1156
|
+
}
|
|
1157
|
+
return loadChunkWithScope(scope, chunkId);
|
|
1085
1158
|
};
|
|
1086
1159
|
}
|
|
1087
|
-
async function handleTurbopackChunk(code,
|
|
1088
|
-
logDebug(
|
|
1089
|
-
"ChunkLoader",
|
|
1090
|
-
`Handling Turbopack chunk - bundle: "${bundle}", url: "${url}"`
|
|
1091
|
-
);
|
|
1160
|
+
async function handleTurbopackChunk(code, scope, url) {
|
|
1092
1161
|
if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
|
|
1093
|
-
logDebug("ChunkLoader", `Skipping worker chunk: "${url}"`);
|
|
1094
1162
|
const preloadLinks = document.querySelectorAll(
|
|
1095
1163
|
`link[rel="preload"][href="${new URL(url).pathname}"]`
|
|
1096
1164
|
);
|
|
@@ -1098,58 +1166,41 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
1098
1166
|
return;
|
|
1099
1167
|
}
|
|
1100
1168
|
const self = globalThis;
|
|
1101
|
-
const
|
|
1102
|
-
logDebug("ChunkLoader", `Bundle key: "${bundleKey}"`);
|
|
1169
|
+
const { globalKey } = scope;
|
|
1103
1170
|
const transformedCode = code.replace(
|
|
1104
1171
|
/globalThis\[\s*["']TURBOPACK["']\s*\]/g,
|
|
1105
|
-
`globalThis["TURBOPACK_${
|
|
1172
|
+
`globalThis["TURBOPACK_${globalKey}"]`
|
|
1106
1173
|
).replace(
|
|
1107
1174
|
/self\[\s*["']TURBOPACK["']\s*\]/g,
|
|
1108
|
-
`self["TURBOPACK_${
|
|
1109
|
-
).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${
|
|
1175
|
+
`self["TURBOPACK_${globalKey}"]`
|
|
1176
|
+
).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${globalKey}`).replace(/self\.TURBOPACK(?!_)/g, `self.TURBOPACK_${globalKey}`).replace(
|
|
1110
1177
|
/TURBOPACK_WORKER_LOCATION/g,
|
|
1111
|
-
`TURBOPACK_WORKER_LOCATION_${
|
|
1178
|
+
`TURBOPACK_WORKER_LOCATION_${globalKey}`
|
|
1112
1179
|
).replace(
|
|
1113
1180
|
/TURBOPACK_NEXT_CHUNK_URLS/g,
|
|
1114
|
-
`TURBOPACK_NEXT_CHUNK_URLS_${
|
|
1181
|
+
`TURBOPACK_NEXT_CHUNK_URLS_${globalKey}`
|
|
1115
1182
|
).replace(
|
|
1116
1183
|
/TURBOPACK_CHUNK_UPDATE_LISTENERS/g,
|
|
1117
|
-
`TURBOPACK_CHUNK_UPDATE_LISTENERS_${
|
|
1118
|
-
).replace(/__next_require__/g, `__${
|
|
1184
|
+
`TURBOPACK_CHUNK_UPDATE_LISTENERS_${globalKey}`
|
|
1185
|
+
).replace(/__next_require__/g, `__${globalKey}_next_require__`).replace(
|
|
1119
1186
|
/\/\/# sourceMappingURL=(?<name>.+)(?<optional>\._)?\.js\.map/g,
|
|
1120
|
-
`//# sourceMappingURL=${new URL(
|
|
1121
|
-
".",
|
|
1122
|
-
new URL(
|
|
1123
|
-
url,
|
|
1124
|
-
self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin)
|
|
1125
|
-
)
|
|
1126
|
-
).href}$1$2.js.map`
|
|
1187
|
+
`//# sourceMappingURL=${new URL(".", new URL(url, scope.url)).href}$1$2.js.map`
|
|
1127
1188
|
);
|
|
1128
|
-
if (!self[`TURBOPACK_${
|
|
1189
|
+
if (!self[`TURBOPACK_${globalKey}`]) {
|
|
1129
1190
|
const chunkData = [];
|
|
1130
1191
|
const turbopackObject = {
|
|
1131
1192
|
push: (item) => {
|
|
1132
|
-
logDebug(
|
|
1133
|
-
"ChunkLoader",
|
|
1134
|
-
`TURBOPACK_${bundleKey}.push() called with item type: ${Array.isArray(item) ? "array" : typeof item}`
|
|
1135
|
-
);
|
|
1136
1193
|
if (Array.isArray(item)) {
|
|
1137
1194
|
chunkData.push(item);
|
|
1138
|
-
logDebug(
|
|
1139
|
-
"ChunkLoader",
|
|
1140
|
-
`TURBOPACK_${bundleKey} now has ${chunkData.length} chunks`
|
|
1141
|
-
);
|
|
1142
1195
|
} else {
|
|
1143
1196
|
chunkData.push([item]);
|
|
1144
1197
|
}
|
|
1145
1198
|
return chunkData.length;
|
|
1146
1199
|
},
|
|
1147
|
-
// Store chunks for later access
|
|
1148
1200
|
__chunks__: chunkData
|
|
1149
1201
|
};
|
|
1150
|
-
self[`TURBOPACK_${
|
|
1202
|
+
self[`TURBOPACK_${globalKey}`] = turbopackObject;
|
|
1151
1203
|
}
|
|
1152
|
-
logDebug("ChunkLoader", `Creating blob script for: "${url}"`);
|
|
1153
1204
|
await new Promise((scriptResolve, scriptReject) => {
|
|
1154
1205
|
const blob = new Blob([transformedCode], {
|
|
1155
1206
|
type: "application/javascript; charset=UTF-8"
|
|
@@ -1161,21 +1212,6 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
1161
1212
|
script.async = true;
|
|
1162
1213
|
script.onload = () => {
|
|
1163
1214
|
URL.revokeObjectURL(scriptUrl);
|
|
1164
|
-
logDebug(
|
|
1165
|
-
"ChunkLoader",
|
|
1166
|
-
`Script loaded successfully for bundle "${bundle}"`
|
|
1167
|
-
);
|
|
1168
|
-
const turbopackBundle = self[`TURBOPACK_${bundleKey}`];
|
|
1169
|
-
logDebug(
|
|
1170
|
-
"ChunkLoader",
|
|
1171
|
-
`TURBOPACK_${bundleKey} type: ${typeof turbopackBundle}, isArray: ${Array.isArray(turbopackBundle)}, keys: ${turbopackBundle ? Object.keys(turbopackBundle).slice(0, 10).join(", ") : "none"}`
|
|
1172
|
-
);
|
|
1173
|
-
if (turbopackBundle && typeof turbopackBundle === "object") {
|
|
1174
|
-
logDebug(
|
|
1175
|
-
"ChunkLoader",
|
|
1176
|
-
`TURBOPACK_${bundleKey} length/size: ${Array.isArray(turbopackBundle) ? turbopackBundle.length : Object.keys(turbopackBundle).length}`
|
|
1177
|
-
);
|
|
1178
|
-
}
|
|
1179
1215
|
scriptResolve(void 0);
|
|
1180
1216
|
script.remove();
|
|
1181
1217
|
};
|
|
@@ -1190,93 +1226,203 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
1190
1226
|
};
|
|
1191
1227
|
document.head.appendChild(script);
|
|
1192
1228
|
});
|
|
1193
|
-
const chunkLists = self[`TURBOPACK_${
|
|
1194
|
-
|
|
1195
|
-
"ChunkLoader",
|
|
1196
|
-
`Processing chunk lists for bundle "${bundle}": ${chunkLists?.length ?? 0} lists`
|
|
1197
|
-
);
|
|
1198
|
-
const loadChunkLists = [];
|
|
1229
|
+
const chunkLists = self[`TURBOPACK_${globalKey}_CHUNK_LISTS`];
|
|
1230
|
+
const loadChunkPromises = [];
|
|
1199
1231
|
while (chunkLists?.length) {
|
|
1200
1232
|
const { chunks } = chunkLists.shift() ?? { chunks: [] };
|
|
1201
1233
|
if (chunks.length > 0) {
|
|
1202
|
-
|
|
1203
|
-
"
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
const chunkLoadResult = self.__webpack_chunk_load__?.(
|
|
1208
|
-
`[${bundle}] ${url.slice(0, url.indexOf("/_next"))}/_next/${id}`
|
|
1234
|
+
for (const id of chunks) {
|
|
1235
|
+
const baseUrl = url.slice(0, url.indexOf("/_next"));
|
|
1236
|
+
const chunkLoadResult = loadChunkWithScope(
|
|
1237
|
+
scope,
|
|
1238
|
+
formatRemoteId(scope, `${baseUrl}/_next/${id}`)
|
|
1209
1239
|
);
|
|
1210
1240
|
if (chunkLoadResult) {
|
|
1211
|
-
|
|
1241
|
+
loadChunkPromises.push(chunkLoadResult);
|
|
1212
1242
|
}
|
|
1213
|
-
}
|
|
1243
|
+
}
|
|
1214
1244
|
}
|
|
1215
1245
|
}
|
|
1216
|
-
if (
|
|
1217
|
-
|
|
1218
|
-
"ChunkLoader",
|
|
1219
|
-
`Waiting for ${loadChunkLists.length} additional chunks to load`
|
|
1220
|
-
);
|
|
1221
|
-
await Promise.all(loadChunkLists);
|
|
1246
|
+
if (loadChunkPromises.length > 0) {
|
|
1247
|
+
await Promise.all(loadChunkPromises);
|
|
1222
1248
|
}
|
|
1223
1249
|
}
|
|
1224
1250
|
|
|
1225
|
-
// src/runtime/turbopack/
|
|
1226
|
-
|
|
1251
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1252
|
+
var 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).";
|
|
1253
|
+
function getTurbopackModules(scope) {
|
|
1227
1254
|
const self = globalThis;
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
if (
|
|
1232
|
-
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1255
|
+
const raw = self[`TURBOPACK_${scope.globalKey}`];
|
|
1256
|
+
if (!raw)
|
|
1257
|
+
return void 0;
|
|
1258
|
+
if (typeof raw === "object" && "__chunks__" in raw) {
|
|
1259
|
+
return raw.__chunks__.flat();
|
|
1260
|
+
}
|
|
1261
|
+
if (Array.isArray(raw)) {
|
|
1262
|
+
return raw.flat();
|
|
1263
|
+
}
|
|
1264
|
+
return Object.entries(raw).flat();
|
|
1265
|
+
}
|
|
1266
|
+
async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}) {
|
|
1267
|
+
const allModules = getTurbopackModules(scope);
|
|
1268
|
+
logDebug(
|
|
1269
|
+
"SharedModules",
|
|
1270
|
+
`initializeSharedModules: scope="${scope.scopedName}", allModules=${allModules ? allModules.length : "null"}, hostShared=[${Object.keys(hostShared).join(", ")}], remoteShared=${JSON.stringify(remoteShared)}`
|
|
1271
|
+
);
|
|
1272
|
+
let sharedModuleInitializer = null;
|
|
1273
|
+
if (allModules) {
|
|
1274
|
+
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
1275
|
+
if (typeof idOrFunc !== "function") {
|
|
1276
|
+
return false;
|
|
1277
|
+
}
|
|
1278
|
+
const funcCode = idOrFunc.toString();
|
|
1279
|
+
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
1280
|
+
});
|
|
1281
|
+
if (sharedModuleInitializerIndex > 0) {
|
|
1282
|
+
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1283
|
+
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1284
|
+
const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
|
|
1285
|
+
if (sharedModuleId) {
|
|
1286
|
+
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1287
|
+
scope,
|
|
1288
|
+
sharedModuleId,
|
|
1289
|
+
formatRemoteId(scope, String(sharedModuleInitializerId))
|
|
1290
|
+
);
|
|
1291
|
+
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
if (sharedModuleInitializer) {
|
|
1295
|
+
const { shared: shared2 } = await sharedModuleInitializer;
|
|
1296
|
+
const sharedModuleIds = extractSharedModuleIds(shared2, scope);
|
|
1297
|
+
logDebug(
|
|
1298
|
+
"SharedModules",
|
|
1299
|
+
`Resolved shared modules for scope="${scope.scopedName}": ${JSON.stringify(sharedModuleIds)}`
|
|
1300
|
+
);
|
|
1301
|
+
return Promise.all(
|
|
1302
|
+
Object.entries(sharedModuleIds).map(async ([id, module]) => {
|
|
1303
|
+
if (hostShared[module]) {
|
|
1304
|
+
scope.sharedModules[id] = await hostShared[module](scope.name);
|
|
1305
|
+
} else {
|
|
1306
|
+
logError(
|
|
1307
|
+
"SharedModules",
|
|
1308
|
+
`Host shared module "${module}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1309
|
+
);
|
|
1310
|
+
}
|
|
1311
|
+
})
|
|
1312
|
+
);
|
|
1313
|
+
}
|
|
1314
|
+
logWarn(
|
|
1315
|
+
"SharedModules",
|
|
1316
|
+
`No shared module initializer found in bundle for scope="${scope.scopedName}" \u2014 falling back to remoteShared mapping`
|
|
1317
|
+
);
|
|
1235
1318
|
} else {
|
|
1236
|
-
|
|
1319
|
+
logWarn(
|
|
1320
|
+
"SharedModules",
|
|
1321
|
+
`No TURBOPACK modules found for scope="${scope.scopedName}" (TURBOPACK_${scope.globalKey} is empty)`
|
|
1322
|
+
);
|
|
1237
1323
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1324
|
+
return Promise.all(
|
|
1325
|
+
Object.entries(remoteShared).map(async ([id, module]) => {
|
|
1326
|
+
if (hostShared[module]) {
|
|
1327
|
+
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1328
|
+
scope.sharedModules[normalizedId] = await hostShared[module](
|
|
1329
|
+
scope.name
|
|
1330
|
+
);
|
|
1331
|
+
} else {
|
|
1332
|
+
logError(
|
|
1333
|
+
"SharedModules",
|
|
1334
|
+
`Shared module "${module}" not found for "${scope.name}". ${DEDUPLICATION_WARNING}`
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
})
|
|
1338
|
+
);
|
|
1339
|
+
}
|
|
1340
|
+
function extractSharedModuleIds(shared2, scope) {
|
|
1341
|
+
return Object.entries(shared2).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1342
|
+
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1343
|
+
if (asyncSharedModuleId) {
|
|
1344
|
+
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
1345
|
+
let asyncSharedModule;
|
|
1346
|
+
const turbopackModules = getTurbopackModules(scope) ?? [];
|
|
1347
|
+
const asyncSharedModuleIdIndex = turbopackModules.indexOf(
|
|
1348
|
+
asyncSharedModuleIdNumber
|
|
1349
|
+
);
|
|
1350
|
+
if (asyncSharedModuleIdIndex !== -1 && typeof turbopackModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1351
|
+
asyncSharedModule = turbopackModules[asyncSharedModuleIdIndex + 1];
|
|
1352
|
+
}
|
|
1353
|
+
if (asyncSharedModule) {
|
|
1354
|
+
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
1355
|
+
const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
|
|
1356
|
+
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1357
|
+
"__remote_shared_module_",
|
|
1358
|
+
""
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
return acc;
|
|
1363
|
+
}, {});
|
|
1364
|
+
}
|
|
1365
|
+
function getSharedModule(scope, id) {
|
|
1366
|
+
const idStr = String(id);
|
|
1367
|
+
if (scope.sharedModules[idStr] !== void 0) {
|
|
1368
|
+
return scope.sharedModules[idStr];
|
|
1240
1369
|
}
|
|
1241
|
-
|
|
1242
|
-
|
|
1370
|
+
for (const [key, value] of Object.entries(scope.sharedModules)) {
|
|
1371
|
+
if (typeof value !== "undefined" && idStr !== key && idStr.endsWith(key)) {
|
|
1372
|
+
return value;
|
|
1373
|
+
}
|
|
1243
1374
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1375
|
+
return null;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
// src/runtime/turbopack/module.ts
|
|
1379
|
+
function requireModule(scope, moduleId, fullId) {
|
|
1380
|
+
const idStr = String(moduleId);
|
|
1381
|
+
if (scope.moduleCache[idStr])
|
|
1382
|
+
return scope.moduleCache[idStr];
|
|
1383
|
+
const sharedModule = getSharedModule(scope, moduleId);
|
|
1384
|
+
if (sharedModule)
|
|
1385
|
+
return sharedModule;
|
|
1386
|
+
return handleTurbopackModule(
|
|
1387
|
+
scope,
|
|
1388
|
+
idStr,
|
|
1389
|
+
fullId ?? formatRemoteId(scope, idStr)
|
|
1390
|
+
);
|
|
1391
|
+
}
|
|
1392
|
+
function handleTurbopackModule(scope, moduleId, id) {
|
|
1393
|
+
if (scope.moduleCache[moduleId]) {
|
|
1394
|
+
return scope.moduleCache[moduleId];
|
|
1246
1395
|
}
|
|
1396
|
+
const modules = getTurbopackModules(scope);
|
|
1247
1397
|
if (!modules) {
|
|
1248
|
-
logError(
|
|
1398
|
+
logError(
|
|
1399
|
+
"TurbopackModule",
|
|
1400
|
+
`TURBOPACK_${scope.globalKey} is undefined (scope: "${scope.scopedName}")`
|
|
1401
|
+
);
|
|
1249
1402
|
}
|
|
1250
1403
|
const moduleInit = findModuleInit(modules, moduleId);
|
|
1251
1404
|
const exports = {};
|
|
1252
1405
|
const moduleExports = { exports };
|
|
1253
1406
|
if (typeof moduleInit !== "function") {
|
|
1254
1407
|
throw new Error(
|
|
1255
|
-
`Module ${id} not found in bundle ${
|
|
1408
|
+
`Module ${id} not found in bundle ${scope.name} with id ${moduleId}`
|
|
1256
1409
|
);
|
|
1257
1410
|
}
|
|
1258
|
-
|
|
1259
|
-
if (!self.__remote_components_turbopack_global__) {
|
|
1260
|
-
self.__remote_components_turbopack_global__ = {};
|
|
1261
|
-
}
|
|
1262
|
-
if (!self.__remote_components_turbopack_global__[bundle]) {
|
|
1263
|
-
self.__remote_components_turbopack_global__[bundle] = {};
|
|
1264
|
-
}
|
|
1411
|
+
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1265
1412
|
moduleInit(
|
|
1266
1413
|
createTurbopackContext(
|
|
1267
|
-
|
|
1414
|
+
scope,
|
|
1268
1415
|
exports,
|
|
1269
1416
|
moduleExports,
|
|
1270
1417
|
modules,
|
|
1271
1418
|
moduleInit,
|
|
1272
|
-
id
|
|
1273
|
-
self
|
|
1419
|
+
id
|
|
1274
1420
|
),
|
|
1275
1421
|
moduleExports,
|
|
1276
1422
|
exports
|
|
1277
1423
|
);
|
|
1278
|
-
if (
|
|
1279
|
-
|
|
1424
|
+
if (scope.moduleCache[moduleId] !== moduleExports.exports) {
|
|
1425
|
+
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1280
1426
|
}
|
|
1281
1427
|
return moduleExports.exports;
|
|
1282
1428
|
}
|
|
@@ -1301,7 +1447,8 @@ function findModuleInit(modules, moduleId) {
|
|
|
1301
1447
|
(e) => Boolean(e && typeof e === "object" && moduleId in e)
|
|
1302
1448
|
)?.[moduleId];
|
|
1303
1449
|
}
|
|
1304
|
-
function createTurbopackContext(
|
|
1450
|
+
function createTurbopackContext(scope, exports, moduleExports, modules, moduleInit, id) {
|
|
1451
|
+
const scopedRequire = (moduleId) => requireModule(scope, moduleId, formatRemoteId(scope, String(moduleId)));
|
|
1305
1452
|
return {
|
|
1306
1453
|
// HMR not implemented for Remote Components
|
|
1307
1454
|
k: {
|
|
@@ -1317,16 +1464,10 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1317
1464
|
s(bindings, esmId) {
|
|
1318
1465
|
let mod = exports;
|
|
1319
1466
|
if (typeof esmId === "string" || typeof esmId === "number") {
|
|
1320
|
-
if (!
|
|
1321
|
-
|
|
1322
|
-
}
|
|
1323
|
-
if (!self.__remote_components_turbopack_modules__[bundle]) {
|
|
1324
|
-
self.__remote_components_turbopack_modules__[bundle] = {};
|
|
1325
|
-
}
|
|
1326
|
-
if (!self.__remote_components_turbopack_modules__[bundle][esmId]) {
|
|
1327
|
-
self.__remote_components_turbopack_modules__[bundle][esmId] = {};
|
|
1467
|
+
if (!scope.moduleCache[esmId]) {
|
|
1468
|
+
scope.moduleCache[esmId] = {};
|
|
1328
1469
|
}
|
|
1329
|
-
mod =
|
|
1470
|
+
mod = scope.moduleCache[esmId];
|
|
1330
1471
|
}
|
|
1331
1472
|
Object.defineProperty(mod, "__esModule", { value: true });
|
|
1332
1473
|
if (Array.isArray(bindings)) {
|
|
@@ -1359,7 +1500,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1359
1500
|
}
|
|
1360
1501
|
}
|
|
1361
1502
|
},
|
|
1362
|
-
// import
|
|
1503
|
+
// import — resolves directly via scope, no global dispatch
|
|
1363
1504
|
i(importId) {
|
|
1364
1505
|
let mod;
|
|
1365
1506
|
if (typeof importId === "string") {
|
|
@@ -1370,7 +1511,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1370
1511
|
/\s+<export(?<specifier>.*)>$/,
|
|
1371
1512
|
""
|
|
1372
1513
|
);
|
|
1373
|
-
mod =
|
|
1514
|
+
mod = scopedRequire(normalizedId);
|
|
1374
1515
|
if (mod && exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
1375
1516
|
if (exportSource === "*") {
|
|
1376
1517
|
mod[exportName] = mod;
|
|
@@ -1379,7 +1520,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1379
1520
|
}
|
|
1380
1521
|
}
|
|
1381
1522
|
} else {
|
|
1382
|
-
mod =
|
|
1523
|
+
mod = scopedRequire(importId);
|
|
1383
1524
|
}
|
|
1384
1525
|
if (typeof mod !== "object" || mod === null) {
|
|
1385
1526
|
mod = { default: mod };
|
|
@@ -1391,16 +1532,14 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1391
1532
|
}
|
|
1392
1533
|
return mod;
|
|
1393
1534
|
},
|
|
1394
|
-
// require
|
|
1535
|
+
// require — resolves directly via scope
|
|
1395
1536
|
r(requireId) {
|
|
1396
|
-
return
|
|
1537
|
+
return scopedRequire(requireId);
|
|
1397
1538
|
},
|
|
1398
1539
|
// value exports
|
|
1399
1540
|
v(value) {
|
|
1400
1541
|
if (typeof value === "function") {
|
|
1401
|
-
exports.default = value((vid) =>
|
|
1402
|
-
return self.__webpack_require__?.(`[${bundle}] ${vid}`);
|
|
1403
|
-
});
|
|
1542
|
+
exports.default = value((vid) => scopedRequire(vid));
|
|
1404
1543
|
} else {
|
|
1405
1544
|
moduleExports.exports = value;
|
|
1406
1545
|
}
|
|
@@ -1415,17 +1554,15 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1415
1554
|
);
|
|
1416
1555
|
exports.default = result;
|
|
1417
1556
|
},
|
|
1418
|
-
// async module loader
|
|
1557
|
+
// async module loader — resolves directly via scope
|
|
1419
1558
|
async A(Aid) {
|
|
1420
|
-
const mod =
|
|
1421
|
-
return mod.default(
|
|
1422
|
-
(parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
|
|
1423
|
-
);
|
|
1559
|
+
const mod = scopedRequire(Aid);
|
|
1560
|
+
return mod.default((parentId) => scopedRequire(parentId));
|
|
1424
1561
|
},
|
|
1425
1562
|
// dynamic import tracking — no-op for remote components
|
|
1426
1563
|
j() {
|
|
1427
1564
|
},
|
|
1428
|
-
// chunk loader
|
|
1565
|
+
// chunk loader — loads directly via scope, no global dispatch
|
|
1429
1566
|
l(url) {
|
|
1430
1567
|
const flatModules = Array.isArray(modules) ? modules : [];
|
|
1431
1568
|
const moduleInitIndex = flatModules.indexOf(moduleInit);
|
|
@@ -1436,169 +1573,57 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1436
1573
|
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
1437
1574
|
const nextIndex = scriptSrc.indexOf("/_next");
|
|
1438
1575
|
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
1439
|
-
const
|
|
1440
|
-
return
|
|
1576
|
+
const chunkUrl = `${baseUrl}/_next/${url}`;
|
|
1577
|
+
return loadChunkWithScope(scope, formatRemoteId(scope, chunkUrl));
|
|
1441
1578
|
}
|
|
1442
1579
|
}
|
|
1443
1580
|
throw new Error(
|
|
1444
1581
|
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
1445
1582
|
);
|
|
1446
1583
|
},
|
|
1447
|
-
//
|
|
1448
|
-
g:
|
|
1584
|
+
// globalThis substitute shared across all modules in this scope
|
|
1585
|
+
g: scope.moduleGlobal,
|
|
1449
1586
|
m: moduleExports,
|
|
1450
1587
|
e: exports
|
|
1451
1588
|
};
|
|
1452
1589
|
}
|
|
1453
1590
|
|
|
1454
|
-
// src/runtime/turbopack/shared-modules.ts
|
|
1455
|
-
var 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).";
|
|
1456
|
-
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1457
|
-
const self = globalThis;
|
|
1458
|
-
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
1459
|
-
if (!self.__remote_shared_modules__[bundle]) {
|
|
1460
|
-
self.__remote_shared_modules__[bundle] = {};
|
|
1461
|
-
}
|
|
1462
|
-
const bundleKey = getBundleKey(bundle);
|
|
1463
|
-
let modules = self[`TURBOPACK_${bundleKey}`];
|
|
1464
|
-
if (modules && typeof modules === "object" && "__chunks__" in modules) {
|
|
1465
|
-
const chunks = modules.__chunks__;
|
|
1466
|
-
modules = chunks.flat();
|
|
1467
|
-
}
|
|
1468
|
-
let sharedModuleInitializer = null;
|
|
1469
|
-
if (modules) {
|
|
1470
|
-
const allModules = Array.isArray(modules) ? modules.flat() : Object.entries(modules).flat();
|
|
1471
|
-
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
1472
|
-
if (typeof idOrFunc !== "function") {
|
|
1473
|
-
return false;
|
|
1474
|
-
}
|
|
1475
|
-
const funcCode = idOrFunc.toString();
|
|
1476
|
-
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
1477
|
-
});
|
|
1478
|
-
if (sharedModuleInitializerIndex > 0) {
|
|
1479
|
-
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1480
|
-
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1481
|
-
const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
|
|
1482
|
-
if (sharedModuleId) {
|
|
1483
|
-
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1484
|
-
bundle,
|
|
1485
|
-
sharedModuleId,
|
|
1486
|
-
`[${bundle}] ${sharedModuleInitializerId}`
|
|
1487
|
-
);
|
|
1488
|
-
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
if (sharedModuleInitializer) {
|
|
1492
|
-
const { shared: shared2 } = await sharedModuleInitializer;
|
|
1493
|
-
const sharedModuleIds = extractSharedModuleIds(
|
|
1494
|
-
shared2,
|
|
1495
|
-
bundleKey,
|
|
1496
|
-
self
|
|
1497
|
-
);
|
|
1498
|
-
return Promise.all(
|
|
1499
|
-
Object.entries(sharedModuleIds).map(async ([id, module]) => {
|
|
1500
|
-
if (self.__remote_shared_modules__?.[bundle]) {
|
|
1501
|
-
if (hostShared[module]) {
|
|
1502
|
-
self.__remote_shared_modules__[bundle][id] = await hostShared[module](bundle);
|
|
1503
|
-
} else {
|
|
1504
|
-
logError(
|
|
1505
|
-
"SharedModules",
|
|
1506
|
-
`Host shared module "${module}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1507
|
-
);
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
})
|
|
1511
|
-
);
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
return Promise.all(
|
|
1515
|
-
Object.entries(remoteShared).map(async ([id, module]) => {
|
|
1516
|
-
if (self.__remote_shared_modules__?.[bundle]) {
|
|
1517
|
-
if (hostShared[module]) {
|
|
1518
|
-
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1519
|
-
self.__remote_shared_modules__[bundle][normalizedId] = await hostShared[module](bundle);
|
|
1520
|
-
} else {
|
|
1521
|
-
logError(
|
|
1522
|
-
"SharedModules",
|
|
1523
|
-
`Shared module "${module}" not found for "${bundle}". ${DEDUPLICATION_WARNING}`
|
|
1524
|
-
);
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
})
|
|
1528
|
-
);
|
|
1529
|
-
}
|
|
1530
|
-
function extractSharedModuleIds(shared2, bundleKey, self) {
|
|
1531
|
-
return Object.entries(shared2).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1532
|
-
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1533
|
-
if (asyncSharedModuleId) {
|
|
1534
|
-
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
1535
|
-
let asyncSharedModule;
|
|
1536
|
-
let turbopackModules = self[`TURBOPACK_${bundleKey}`];
|
|
1537
|
-
if (turbopackModules && typeof turbopackModules === "object" && "__chunks__" in turbopackModules) {
|
|
1538
|
-
const chunks = turbopackModules.__chunks__;
|
|
1539
|
-
turbopackModules = chunks.flat();
|
|
1540
|
-
}
|
|
1541
|
-
const newAllModules = Array.isArray(turbopackModules) ? turbopackModules.flat() : turbopackModules ? Object.entries(turbopackModules).flatMap(([key2, value2]) => [
|
|
1542
|
-
key2,
|
|
1543
|
-
value2
|
|
1544
|
-
]) : [];
|
|
1545
|
-
const asyncSharedModuleIdIndex = newAllModules.indexOf(
|
|
1546
|
-
asyncSharedModuleIdNumber
|
|
1547
|
-
);
|
|
1548
|
-
if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1549
|
-
asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
|
|
1550
|
-
}
|
|
1551
|
-
if (asyncSharedModule) {
|
|
1552
|
-
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
1553
|
-
const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
|
|
1554
|
-
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1555
|
-
"__remote_shared_module_",
|
|
1556
|
-
""
|
|
1557
|
-
);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
return acc;
|
|
1561
|
-
}, {});
|
|
1562
|
-
}
|
|
1563
|
-
function getSharedModule(bundle, id) {
|
|
1564
|
-
const self = globalThis;
|
|
1565
|
-
for (const [key, value] of Object.entries(
|
|
1566
|
-
self.__remote_shared_modules__?.[bundle] ?? {}
|
|
1567
|
-
)) {
|
|
1568
|
-
if (typeof value !== "undefined" && (typeof id === "string" && id.includes(key) || id === key)) {
|
|
1569
|
-
return value;
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
return null;
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
1591
|
// src/runtime/turbopack/webpack-runtime.ts
|
|
1576
1592
|
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared2 = {}, remoteShared = {}, resolveClientUrl) {
|
|
1577
1593
|
const self = globalThis;
|
|
1594
|
+
const bundleName = bundle ?? "default";
|
|
1595
|
+
const scope = createScope(bundleName, url, runtime, resolveClientUrl);
|
|
1596
|
+
registerScope(scope);
|
|
1578
1597
|
if (!self.__remote_bundle_url__) {
|
|
1579
1598
|
self.__remote_bundle_url__ = {};
|
|
1580
1599
|
}
|
|
1581
|
-
self.__remote_bundle_url__[
|
|
1600
|
+
self.__remote_bundle_url__[bundleName] = url;
|
|
1601
|
+
if (scope.scopedName !== bundleName) {
|
|
1602
|
+
self.__remote_bundle_url__[scope.scopedName] = url;
|
|
1603
|
+
}
|
|
1582
1604
|
self.__webpack_get_script_filename__ = () => null;
|
|
1583
|
-
|
|
1605
|
+
const willCreateDispatchers = typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack";
|
|
1606
|
+
if (willCreateDispatchers) {
|
|
1584
1607
|
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
1585
1608
|
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
1586
1609
|
self.__original_webpack_require__ = self.__webpack_require__;
|
|
1587
1610
|
}
|
|
1588
|
-
self.__webpack_chunk_load__ =
|
|
1589
|
-
self.__webpack_require__ =
|
|
1611
|
+
self.__webpack_chunk_load__ = createChunkDispatcher();
|
|
1612
|
+
self.__webpack_require__ = createModuleDispatcher(runtime);
|
|
1590
1613
|
self.__webpack_require_type__ = runtime;
|
|
1591
1614
|
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
1592
|
-
|
|
1593
|
-
self.__remote_webpack_require__[
|
|
1594
|
-
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
1615
|
+
self.__remote_webpack_require__[bundleName] = self.__webpack_require__;
|
|
1616
|
+
self.__remote_webpack_require__[bundleName].type = "turbopack";
|
|
1595
1617
|
}
|
|
1596
1618
|
}
|
|
1619
|
+
if (self.__remote_webpack_require__?.[bundleName] && scope.scopedName !== bundleName) {
|
|
1620
|
+
self.__remote_webpack_require__[scope.scopedName] = self.__remote_webpack_require__[bundleName];
|
|
1621
|
+
}
|
|
1597
1622
|
if (runtime === RUNTIME_TURBOPACK) {
|
|
1598
1623
|
const results = await Promise.allSettled(
|
|
1599
1624
|
scripts.map((script) => {
|
|
1600
1625
|
if (script.src) {
|
|
1601
|
-
return
|
|
1626
|
+
return loadChunkWithScope(scope, script.src);
|
|
1602
1627
|
}
|
|
1603
1628
|
return Promise.resolve(void 0);
|
|
1604
1629
|
})
|
|
@@ -1620,54 +1645,54 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1620
1645
|
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1621
1646
|
...shared2
|
|
1622
1647
|
};
|
|
1623
|
-
await initializeSharedModules(
|
|
1624
|
-
bundle ?? "default",
|
|
1625
|
-
// include all core modules as shared
|
|
1626
|
-
coreShared,
|
|
1627
|
-
remoteShared
|
|
1628
|
-
);
|
|
1648
|
+
await initializeSharedModules(scope, coreShared, remoteShared);
|
|
1629
1649
|
}
|
|
1630
|
-
function
|
|
1650
|
+
function createModuleDispatcher(runtime) {
|
|
1631
1651
|
return (id) => {
|
|
1632
1652
|
const self = globalThis;
|
|
1633
1653
|
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
1634
1654
|
bundle: "default",
|
|
1635
1655
|
id
|
|
1636
1656
|
};
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1657
|
+
const bundleName = bundle ?? "default";
|
|
1658
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundleName] ? self.__remote_webpack_require__[bundleName]?.type || "webpack" : runtime;
|
|
1659
|
+
logDebug(
|
|
1660
|
+
"ModuleDispatcher",
|
|
1661
|
+
`Resolving "${id}" (bundle: "${bundleName}", runtime: "${remoteRuntime}")`
|
|
1662
|
+
);
|
|
1639
1663
|
try {
|
|
1640
1664
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1641
1665
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
1642
1666
|
}
|
|
1643
|
-
const
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
return sharedModule;
|
|
1667
|
+
const scope = getScope(bundleName);
|
|
1668
|
+
if (scope) {
|
|
1669
|
+
return requireModule(scope, moduleId ?? id, id);
|
|
1647
1670
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
throw new Error(`Module "${id}" not found.`);
|
|
1671
|
+
throw new Error(
|
|
1672
|
+
`Module "${id}" not found \u2014 no scope for bundle "${bundleName}".`
|
|
1673
|
+
);
|
|
1652
1674
|
} catch (requireError) {
|
|
1653
1675
|
logWarn(
|
|
1654
|
-
"
|
|
1676
|
+
"ModuleDispatcher",
|
|
1655
1677
|
`Module require failed: ${String(requireError)}`
|
|
1656
1678
|
);
|
|
1657
1679
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
1658
1680
|
throw new RemoteComponentsError(
|
|
1659
|
-
`Module "${id}" not found in remote component bundle "${
|
|
1681
|
+
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1660
1682
|
{
|
|
1661
1683
|
cause: requireError instanceof Error ? requireError : void 0
|
|
1662
1684
|
}
|
|
1663
1685
|
);
|
|
1664
1686
|
}
|
|
1665
1687
|
try {
|
|
1666
|
-
logDebug(
|
|
1688
|
+
logDebug(
|
|
1689
|
+
"ModuleDispatcher",
|
|
1690
|
+
"Falling back to original webpack require"
|
|
1691
|
+
);
|
|
1667
1692
|
return self.__original_webpack_require__(id);
|
|
1668
1693
|
} catch (originalError) {
|
|
1669
1694
|
throw new RemoteComponentsError(
|
|
1670
|
-
`Module "${id}" not found in remote component bundle "${
|
|
1695
|
+
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1671
1696
|
{ cause: originalError instanceof Error ? originalError : void 0 }
|
|
1672
1697
|
);
|
|
1673
1698
|
}
|
|
@@ -1686,6 +1711,13 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
1686
1711
|
location.origin
|
|
1687
1712
|
).href;
|
|
1688
1713
|
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
1714
|
+
const alreadyLoaded = Array.from(
|
|
1715
|
+
document.querySelectorAll("script[src]")
|
|
1716
|
+
).some((s) => s.src === resolvedSrc);
|
|
1717
|
+
if (alreadyLoaded) {
|
|
1718
|
+
resolve();
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1689
1721
|
const newScript = document.createElement("script");
|
|
1690
1722
|
newScript.onload = () => resolve();
|
|
1691
1723
|
newScript.onerror = () => {
|
|
@@ -2668,14 +2700,6 @@ var routerImpl = async () => {
|
|
|
2668
2700
|
|
|
2669
2701
|
// src/host/nextjs/app-client-only.tsx
|
|
2670
2702
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
2671
|
-
async function tryImportShared() {
|
|
2672
|
-
try {
|
|
2673
|
-
const { shared: shared2 } = await Promise.resolve().then(() => (init_app(), app_exports));
|
|
2674
|
-
return shared2;
|
|
2675
|
-
} catch {
|
|
2676
|
-
return {};
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
2679
2703
|
var sharedModules = async (userShared, resolveClientUrl) => {
|
|
2680
2704
|
const [resolvedShared, resolvedUserShared] = await Promise.all([
|
|
2681
2705
|
tryImportShared(),
|