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