remote-components 0.3.0 → 0.3.2
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.map +1 -1
- package/dist/config/nextjs.js.map +1 -1
- package/dist/host/html.cjs +467 -395
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +467 -395
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +507 -447
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +515 -455
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/nextjs/app.cjs +5 -6
- package/dist/host/nextjs/app.cjs.map +1 -1
- package/dist/host/nextjs/app.js +5 -6
- package/dist/host/nextjs/app.js.map +1 -1
- package/dist/host/nextjs/pages.cjs +6 -11
- package/dist/host/nextjs/pages.cjs.map +1 -1
- package/dist/host/nextjs/pages.js +9 -11
- package/dist/host/nextjs/pages.js.map +1 -1
- package/dist/host/react.cjs +435 -374
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +435 -374
- package/dist/host/react.js.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.cjs +16 -7
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.d.ts +2 -2
- package/dist/internal/host/nextjs/dom-flight.js +16 -7
- package/dist/internal/host/nextjs/dom-flight.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/server/fetch-remote-component.cjs +183 -149
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.js +185 -149
- 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/constants.cjs +6 -6
- package/dist/internal/runtime/constants.cjs.map +1 -1
- package/dist/internal/runtime/constants.d.ts +3 -3
- package/dist/internal/runtime/constants.js +4 -4
- package/dist/internal/runtime/constants.js.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.cjs +11 -15
- package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.d.ts +2 -12
- package/dist/internal/runtime/html/parse-remote-html.js +17 -15
- package/dist/internal/runtime/html/parse-remote-html.js.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.cjs +2 -2
- package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.js +1 -1
- package/dist/internal/runtime/loaders/script-loader.js.map +1 -1
- package/dist/internal/runtime/metadata.cjs +42 -0
- package/dist/internal/runtime/metadata.cjs.map +1 -1
- package/dist/internal/runtime/metadata.d.ts +21 -1
- package/dist/internal/runtime/metadata.js +38 -0
- package/dist/internal/runtime/metadata.js.map +1 -1
- package/dist/internal/runtime/patterns.cjs +38 -0
- package/dist/internal/runtime/patterns.cjs.map +1 -0
- package/dist/internal/runtime/patterns.d.ts +5 -0
- package/dist/internal/runtime/patterns.js +12 -0
- package/dist/internal/runtime/patterns.js.map +1 -0
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +79 -128
- 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 +56 -57
- 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 +54 -56
- 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 +62 -56
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.d.ts +7 -3
- package/dist/internal/runtime/turbopack/shared-modules.js +63 -57
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs +50 -31
- 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 +52 -34
- 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.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/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/package.json +1 -1
package/dist/host/html.js
CHANGED
|
@@ -191,6 +191,9 @@ var init_logger = __esm({
|
|
|
191
191
|
function escapeString(str) {
|
|
192
192
|
return str.replace(/[^a-z0-9]/g, "_");
|
|
193
193
|
}
|
|
194
|
+
function computeScopedName(name, options) {
|
|
195
|
+
return options.isCrossOrigin ? `${name}_${escapeString(options.remoteHost.toLowerCase())}` : name;
|
|
196
|
+
}
|
|
194
197
|
var init_utils = __esm({
|
|
195
198
|
"src/utils/index.ts"() {
|
|
196
199
|
"use strict";
|
|
@@ -201,17 +204,17 @@ var init_utils = __esm({
|
|
|
201
204
|
function getBundleKey(bundle) {
|
|
202
205
|
return escapeString(bundle);
|
|
203
206
|
}
|
|
204
|
-
var DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT
|
|
207
|
+
var DEFAULT_BUNDLE_NAME, DEFAULT_COMPONENT_NAME, DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT;
|
|
205
208
|
var init_constants2 = __esm({
|
|
206
209
|
"src/runtime/constants.ts"() {
|
|
207
210
|
"use strict";
|
|
208
211
|
init_utils();
|
|
212
|
+
DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
|
|
213
|
+
DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
|
|
209
214
|
DEFAULT_ROUTE = "/";
|
|
210
215
|
RUNTIME_WEBPACK = "webpack";
|
|
211
216
|
RUNTIME_TURBOPACK = "turbopack";
|
|
212
217
|
RUNTIME_SCRIPT = "script";
|
|
213
|
-
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
214
|
-
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
215
218
|
}
|
|
216
219
|
});
|
|
217
220
|
|
|
@@ -402,11 +405,93 @@ var init_next_client_pages_loader = __esm({
|
|
|
402
405
|
}
|
|
403
406
|
});
|
|
404
407
|
|
|
405
|
-
// src/
|
|
406
|
-
function
|
|
408
|
+
// src/runtime/patterns.ts
|
|
409
|
+
function collapseDoubleSlashes(path) {
|
|
410
|
+
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
411
|
+
}
|
|
412
|
+
var REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE, DOUBLE_SLASH_RE;
|
|
413
|
+
var init_patterns = __esm({
|
|
414
|
+
"src/runtime/patterns.ts"() {
|
|
415
|
+
"use strict";
|
|
416
|
+
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
417
|
+
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
418
|
+
DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
// src/runtime/turbopack/remote-scope.ts
|
|
423
|
+
function getRegistry() {
|
|
407
424
|
const self = globalThis;
|
|
408
|
-
|
|
425
|
+
if (!self.__remote_component_scopes__) {
|
|
426
|
+
self.__remote_component_scopes__ = /* @__PURE__ */ new Map();
|
|
427
|
+
}
|
|
428
|
+
return self.__remote_component_scopes__;
|
|
429
|
+
}
|
|
430
|
+
function createScope(name, url, runtime, resolveClientUrl) {
|
|
431
|
+
const isCrossOrigin = url.origin !== location.origin;
|
|
432
|
+
const scopedName = computeScopedName(name, {
|
|
433
|
+
remoteHost: url.host,
|
|
434
|
+
isCrossOrigin
|
|
435
|
+
});
|
|
436
|
+
const globalKey = getBundleKey(scopedName);
|
|
437
|
+
return {
|
|
438
|
+
name,
|
|
439
|
+
scopedName,
|
|
440
|
+
globalKey,
|
|
441
|
+
url,
|
|
442
|
+
runtime,
|
|
443
|
+
resolveClientUrl,
|
|
444
|
+
moduleCache: {},
|
|
445
|
+
sharedModules: {},
|
|
446
|
+
moduleGlobal: {}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
function registerScope(scope) {
|
|
450
|
+
const registry = getRegistry();
|
|
451
|
+
registry.set(scope.scopedName, scope);
|
|
452
|
+
if (scope.scopedName !== scope.name) {
|
|
453
|
+
const existing = registry.get(scope.name);
|
|
454
|
+
if (existing && existing.scopedName !== scope.scopedName) {
|
|
455
|
+
logWarn(
|
|
456
|
+
"RemoteScope",
|
|
457
|
+
`Plain name "${scope.name}" already registered by scope "${existing.scopedName}" \u2014 overwriting with "${scope.scopedName}". Static hosts will only resolve the latest one.`
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
registry.set(scope.name, scope);
|
|
461
|
+
}
|
|
462
|
+
logDebug(
|
|
463
|
+
"RemoteScope",
|
|
464
|
+
`Registered scope "${scope.scopedName}" (${registry.size} total)`
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
function getScope(name) {
|
|
468
|
+
return getRegistry().get(name);
|
|
469
|
+
}
|
|
470
|
+
function formatRemoteId(scope, path) {
|
|
471
|
+
return `[${scope.scopedName}] ${path}`;
|
|
409
472
|
}
|
|
473
|
+
function parseRemoteId(id) {
|
|
474
|
+
const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;
|
|
475
|
+
if (groups?.bundle && groups.id) {
|
|
476
|
+
return {
|
|
477
|
+
bundle: groups.bundle,
|
|
478
|
+
path: groups.id,
|
|
479
|
+
prefix: groups.prefix ?? ""
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
return { bundle: "default", path: id, prefix: "" };
|
|
483
|
+
}
|
|
484
|
+
var init_remote_scope = __esm({
|
|
485
|
+
"src/runtime/turbopack/remote-scope.ts"() {
|
|
486
|
+
"use strict";
|
|
487
|
+
init_constants2();
|
|
488
|
+
init_patterns();
|
|
489
|
+
init_utils();
|
|
490
|
+
init_logger();
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
// src/host/shared/remote-image-loader.ts
|
|
410
495
|
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
411
496
|
const loader = Object.assign(
|
|
412
497
|
({
|
|
@@ -416,7 +501,7 @@ function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
|
416
501
|
quality
|
|
417
502
|
}) => {
|
|
418
503
|
const q = quality ?? 75;
|
|
419
|
-
const remoteOrigin =
|
|
504
|
+
const remoteOrigin = getScope(bundle)?.url.origin ?? "";
|
|
420
505
|
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
421
506
|
const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
|
|
422
507
|
const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
@@ -431,6 +516,7 @@ function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
|
431
516
|
var init_remote_image_loader = __esm({
|
|
432
517
|
"src/host/shared/remote-image-loader.ts"() {
|
|
433
518
|
"use strict";
|
|
519
|
+
init_remote_scope();
|
|
434
520
|
}
|
|
435
521
|
});
|
|
436
522
|
|
|
@@ -620,7 +706,7 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
620
706
|
var init_script_loader = __esm({
|
|
621
707
|
"src/runtime/loaders/script-loader.ts"() {
|
|
622
708
|
"use strict";
|
|
623
|
-
|
|
709
|
+
init_patterns();
|
|
624
710
|
init_protected_rc_fallback();
|
|
625
711
|
init_error();
|
|
626
712
|
init_logger();
|
|
@@ -721,15 +807,15 @@ var init_webpack = __esm({
|
|
|
721
807
|
init_apply_shared_modules();
|
|
722
808
|
init_next_client_pages_loader();
|
|
723
809
|
init_polyfill();
|
|
724
|
-
init_constants2();
|
|
725
810
|
init_script_loader();
|
|
811
|
+
init_patterns();
|
|
726
812
|
init_error();
|
|
727
813
|
}
|
|
728
814
|
});
|
|
729
815
|
|
|
730
816
|
// src/runtime/turbopack/patterns.ts
|
|
731
817
|
var REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_RESOLVE_RE, ASYNC_MODULE_ALL_RE, TURBOPACK_GLOBAL_RE;
|
|
732
|
-
var
|
|
818
|
+
var init_patterns2 = __esm({
|
|
733
819
|
"src/runtime/turbopack/patterns.ts"() {
|
|
734
820
|
"use strict";
|
|
735
821
|
REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
@@ -742,62 +828,39 @@ var init_patterns = __esm({
|
|
|
742
828
|
});
|
|
743
829
|
|
|
744
830
|
// src/runtime/turbopack/chunk-loader.ts
|
|
745
|
-
function
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
).href;
|
|
774
|
-
if (url.endsWith(".css")) {
|
|
775
|
-
logDebug("ChunkLoader", `Skipping CSS file: "${url}"`);
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
if (!self.__remote_components_turbopack_chunk_loader_promise__) {
|
|
779
|
-
self.__remote_components_turbopack_chunk_loader_promise__ = {};
|
|
780
|
-
}
|
|
781
|
-
if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
|
|
782
|
-
logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
|
|
783
|
-
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
784
|
-
}
|
|
785
|
-
const resolvedUrl = resolveClientUrl?.(url) ?? url;
|
|
786
|
-
logDebug("ChunkLoader", `Fetching chunk from: "${resolvedUrl}"`);
|
|
787
|
-
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
|
|
831
|
+
function loadChunkWithScope(scope, chunkId) {
|
|
832
|
+
logDebug(
|
|
833
|
+
"ChunkLoader",
|
|
834
|
+
`loadChunkWithScope: "${chunkId}" (scope: "${scope.scopedName}")`
|
|
835
|
+
);
|
|
836
|
+
const self = globalThis;
|
|
837
|
+
const { bundle, path, prefix } = parseRemoteId(chunkId);
|
|
838
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : scope.runtime;
|
|
839
|
+
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
840
|
+
return Promise.resolve(void 0);
|
|
841
|
+
}
|
|
842
|
+
const rawPath = path ? collapseDoubleSlashes(`${prefix}${path}`) : "/";
|
|
843
|
+
const url = new URL(rawPath, scope.url).href;
|
|
844
|
+
if (url.endsWith(".css")) {
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
if (!self.__remote_components_turbopack_chunk_loader_promise__) {
|
|
848
|
+
self.__remote_components_turbopack_chunk_loader_promise__ = {};
|
|
849
|
+
}
|
|
850
|
+
if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
|
|
851
|
+
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
852
|
+
}
|
|
853
|
+
const resolvedUrl = scope.resolveClientUrl?.(url) ?? url;
|
|
854
|
+
if (resolvedUrl !== url) {
|
|
855
|
+
logDebug("ChunkLoader", `Proxied chunk URL: "${url}" \u2192 "${resolvedUrl}"`);
|
|
856
|
+
}
|
|
857
|
+
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise(
|
|
858
|
+
(resolve, reject) => {
|
|
788
859
|
fetch(resolvedUrl).then((res) => res.text()).then((code) => {
|
|
789
860
|
const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
|
|
790
861
|
if (hasTurbopack) {
|
|
791
|
-
return handleTurbopackChunk(code,
|
|
862
|
+
return handleTurbopackChunk(code, scope, url);
|
|
792
863
|
}
|
|
793
|
-
logDebug(
|
|
794
|
-
"ChunkLoader",
|
|
795
|
-
`Chunk does not contain globalThis.TURBOPACK or self.TURBOPACK: "${url}"`
|
|
796
|
-
);
|
|
797
|
-
logDebug(
|
|
798
|
-
"ChunkLoader",
|
|
799
|
-
`First 500 chars of chunk: ${code.slice(0, 500)}`
|
|
800
|
-
);
|
|
801
864
|
}).then(resolve).catch((error) => {
|
|
802
865
|
const isProxied = isProxiedUrl(resolvedUrl);
|
|
803
866
|
if (isProxied) {
|
|
@@ -807,17 +870,29 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
807
870
|
reject(error);
|
|
808
871
|
}
|
|
809
872
|
});
|
|
810
|
-
}
|
|
811
|
-
|
|
873
|
+
}
|
|
874
|
+
);
|
|
875
|
+
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
876
|
+
}
|
|
877
|
+
function createChunkDispatcher() {
|
|
878
|
+
return function __chunk_dispatcher__(chunkId, scriptBundle) {
|
|
879
|
+
logDebug("ChunkDispatcher", `Dispatching chunk: "${chunkId}"`);
|
|
880
|
+
const { bundle } = parseRemoteId(chunkId);
|
|
881
|
+
const bundleName = bundle || scriptBundle || "default";
|
|
882
|
+
const scope = getScope(bundleName);
|
|
883
|
+
logDebug(
|
|
884
|
+
"ChunkDispatcher",
|
|
885
|
+
`Scope resolution: bundle="${bundleName}", scope=${scope?.scopedName ?? "null"}`
|
|
886
|
+
);
|
|
887
|
+
if (!scope) {
|
|
888
|
+
logWarn("ChunkDispatcher", `No scope found for bundle "${bundleName}"`);
|
|
889
|
+
return Promise.resolve(void 0);
|
|
890
|
+
}
|
|
891
|
+
return loadChunkWithScope(scope, chunkId);
|
|
812
892
|
};
|
|
813
893
|
}
|
|
814
|
-
async function handleTurbopackChunk(code,
|
|
815
|
-
logDebug(
|
|
816
|
-
"ChunkLoader",
|
|
817
|
-
`Handling Turbopack chunk - bundle: "${bundle}", url: "${url}"`
|
|
818
|
-
);
|
|
894
|
+
async function handleTurbopackChunk(code, scope, url) {
|
|
819
895
|
if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
|
|
820
|
-
logDebug("ChunkLoader", `Skipping worker chunk: "${url}"`);
|
|
821
896
|
const preloadLinks = document.querySelectorAll(
|
|
822
897
|
`link[rel="preload"][href="${new URL(url).pathname}"]`
|
|
823
898
|
);
|
|
@@ -825,58 +900,41 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
825
900
|
return;
|
|
826
901
|
}
|
|
827
902
|
const self = globalThis;
|
|
828
|
-
const
|
|
829
|
-
logDebug("ChunkLoader", `Bundle key: "${bundleKey}"`);
|
|
903
|
+
const { globalKey } = scope;
|
|
830
904
|
const transformedCode = code.replace(
|
|
831
905
|
/globalThis\[\s*["']TURBOPACK["']\s*\]/g,
|
|
832
|
-
`globalThis["TURBOPACK_${
|
|
906
|
+
`globalThis["TURBOPACK_${globalKey}"]`
|
|
833
907
|
).replace(
|
|
834
908
|
/self\[\s*["']TURBOPACK["']\s*\]/g,
|
|
835
|
-
`self["TURBOPACK_${
|
|
836
|
-
).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${
|
|
909
|
+
`self["TURBOPACK_${globalKey}"]`
|
|
910
|
+
).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${globalKey}`).replace(/self\.TURBOPACK(?!_)/g, `self.TURBOPACK_${globalKey}`).replace(
|
|
837
911
|
/TURBOPACK_WORKER_LOCATION/g,
|
|
838
|
-
`TURBOPACK_WORKER_LOCATION_${
|
|
912
|
+
`TURBOPACK_WORKER_LOCATION_${globalKey}`
|
|
839
913
|
).replace(
|
|
840
914
|
/TURBOPACK_NEXT_CHUNK_URLS/g,
|
|
841
|
-
`TURBOPACK_NEXT_CHUNK_URLS_${
|
|
915
|
+
`TURBOPACK_NEXT_CHUNK_URLS_${globalKey}`
|
|
842
916
|
).replace(
|
|
843
917
|
/TURBOPACK_CHUNK_UPDATE_LISTENERS/g,
|
|
844
|
-
`TURBOPACK_CHUNK_UPDATE_LISTENERS_${
|
|
845
|
-
).replace(/__next_require__/g, `__${
|
|
918
|
+
`TURBOPACK_CHUNK_UPDATE_LISTENERS_${globalKey}`
|
|
919
|
+
).replace(/__next_require__/g, `__${globalKey}_next_require__`).replace(
|
|
846
920
|
/\/\/# sourceMappingURL=(?<name>.+)(?<optional>\._)?\.js\.map/g,
|
|
847
|
-
`//# sourceMappingURL=${new URL(
|
|
848
|
-
".",
|
|
849
|
-
new URL(
|
|
850
|
-
url,
|
|
851
|
-
self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin)
|
|
852
|
-
)
|
|
853
|
-
).href}$1$2.js.map`
|
|
921
|
+
`//# sourceMappingURL=${new URL(".", new URL(url, scope.url)).href}$1$2.js.map`
|
|
854
922
|
);
|
|
855
|
-
if (!self[`TURBOPACK_${
|
|
923
|
+
if (!self[`TURBOPACK_${globalKey}`]) {
|
|
856
924
|
const chunkData = [];
|
|
857
925
|
const turbopackObject = {
|
|
858
926
|
push: (item) => {
|
|
859
|
-
logDebug(
|
|
860
|
-
"ChunkLoader",
|
|
861
|
-
`TURBOPACK_${bundleKey}.push() called with item type: ${Array.isArray(item) ? "array" : typeof item}`
|
|
862
|
-
);
|
|
863
927
|
if (Array.isArray(item)) {
|
|
864
928
|
chunkData.push(item);
|
|
865
|
-
logDebug(
|
|
866
|
-
"ChunkLoader",
|
|
867
|
-
`TURBOPACK_${bundleKey} now has ${chunkData.length} chunks`
|
|
868
|
-
);
|
|
869
929
|
} else {
|
|
870
930
|
chunkData.push([item]);
|
|
871
931
|
}
|
|
872
932
|
return chunkData.length;
|
|
873
933
|
},
|
|
874
|
-
// Store chunks for later access
|
|
875
934
|
__chunks__: chunkData
|
|
876
935
|
};
|
|
877
|
-
self[`TURBOPACK_${
|
|
936
|
+
self[`TURBOPACK_${globalKey}`] = turbopackObject;
|
|
878
937
|
}
|
|
879
|
-
logDebug("ChunkLoader", `Creating blob script for: "${url}"`);
|
|
880
938
|
await new Promise((scriptResolve, scriptReject) => {
|
|
881
939
|
const blob = new Blob([transformedCode], {
|
|
882
940
|
type: "application/javascript; charset=UTF-8"
|
|
@@ -888,21 +946,6 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
888
946
|
script.async = true;
|
|
889
947
|
script.onload = () => {
|
|
890
948
|
URL.revokeObjectURL(scriptUrl);
|
|
891
|
-
logDebug(
|
|
892
|
-
"ChunkLoader",
|
|
893
|
-
`Script loaded successfully for bundle "${bundle}"`
|
|
894
|
-
);
|
|
895
|
-
const turbopackBundle = self[`TURBOPACK_${bundleKey}`];
|
|
896
|
-
logDebug(
|
|
897
|
-
"ChunkLoader",
|
|
898
|
-
`TURBOPACK_${bundleKey} type: ${typeof turbopackBundle}, isArray: ${Array.isArray(turbopackBundle)}, keys: ${turbopackBundle ? Object.keys(turbopackBundle).slice(0, 10).join(", ") : "none"}`
|
|
899
|
-
);
|
|
900
|
-
if (turbopackBundle && typeof turbopackBundle === "object") {
|
|
901
|
-
logDebug(
|
|
902
|
-
"ChunkLoader",
|
|
903
|
-
`TURBOPACK_${bundleKey} length/size: ${Array.isArray(turbopackBundle) ? turbopackBundle.length : Object.keys(turbopackBundle).length}`
|
|
904
|
-
);
|
|
905
|
-
}
|
|
906
949
|
scriptResolve(void 0);
|
|
907
950
|
script.remove();
|
|
908
951
|
};
|
|
@@ -917,53 +960,199 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
917
960
|
};
|
|
918
961
|
document.head.appendChild(script);
|
|
919
962
|
});
|
|
920
|
-
const chunkLists = self[`TURBOPACK_${
|
|
921
|
-
|
|
922
|
-
"ChunkLoader",
|
|
923
|
-
`Processing chunk lists for bundle "${bundle}": ${chunkLists?.length ?? 0} lists`
|
|
924
|
-
);
|
|
925
|
-
const loadChunkLists = [];
|
|
963
|
+
const chunkLists = self[`TURBOPACK_${globalKey}_CHUNK_LISTS`];
|
|
964
|
+
const loadChunkPromises = [];
|
|
926
965
|
while (chunkLists?.length) {
|
|
927
966
|
const { chunks } = chunkLists.shift() ?? { chunks: [] };
|
|
928
967
|
if (chunks.length > 0) {
|
|
929
|
-
|
|
930
|
-
"
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
const chunkLoadResult = self.__webpack_chunk_load__?.(
|
|
935
|
-
`[${bundle}] ${url.slice(0, url.indexOf("/_next"))}/_next/${id}`
|
|
968
|
+
for (const id of chunks) {
|
|
969
|
+
const baseUrl = url.slice(0, url.indexOf("/_next"));
|
|
970
|
+
const chunkLoadResult = loadChunkWithScope(
|
|
971
|
+
scope,
|
|
972
|
+
formatRemoteId(scope, `${baseUrl}/_next/${id}`)
|
|
936
973
|
);
|
|
937
974
|
if (chunkLoadResult) {
|
|
938
|
-
|
|
975
|
+
loadChunkPromises.push(chunkLoadResult);
|
|
939
976
|
}
|
|
940
|
-
}
|
|
977
|
+
}
|
|
941
978
|
}
|
|
942
979
|
}
|
|
943
|
-
if (
|
|
944
|
-
|
|
945
|
-
"ChunkLoader",
|
|
946
|
-
`Waiting for ${loadChunkLists.length} additional chunks to load`
|
|
947
|
-
);
|
|
948
|
-
await Promise.all(loadChunkLists);
|
|
980
|
+
if (loadChunkPromises.length > 0) {
|
|
981
|
+
await Promise.all(loadChunkPromises);
|
|
949
982
|
}
|
|
950
983
|
}
|
|
951
984
|
var init_chunk_loader = __esm({
|
|
952
985
|
"src/runtime/turbopack/chunk-loader.ts"() {
|
|
953
986
|
"use strict";
|
|
954
987
|
init_constants2();
|
|
988
|
+
init_patterns();
|
|
955
989
|
init_protected_rc_fallback();
|
|
956
990
|
init_error();
|
|
957
991
|
init_logger();
|
|
958
|
-
|
|
992
|
+
init_patterns2();
|
|
993
|
+
init_remote_scope();
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
998
|
+
function getTurbopackModules(scope) {
|
|
999
|
+
const self = globalThis;
|
|
1000
|
+
const raw = self[`TURBOPACK_${scope.globalKey}`];
|
|
1001
|
+
if (!raw)
|
|
1002
|
+
return void 0;
|
|
1003
|
+
if (typeof raw === "object" && "__chunks__" in raw) {
|
|
1004
|
+
return raw.__chunks__.flat();
|
|
1005
|
+
}
|
|
1006
|
+
if (Array.isArray(raw)) {
|
|
1007
|
+
return raw.flat();
|
|
1008
|
+
}
|
|
1009
|
+
return Object.entries(raw).flat();
|
|
1010
|
+
}
|
|
1011
|
+
async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}) {
|
|
1012
|
+
const allModules = getTurbopackModules(scope);
|
|
1013
|
+
logDebug(
|
|
1014
|
+
"SharedModules",
|
|
1015
|
+
`initializeSharedModules: scope="${scope.scopedName}", allModules=${allModules ? allModules.length : "null"}, hostShared=[${Object.keys(hostShared).join(", ")}], remoteShared=${JSON.stringify(remoteShared)}`
|
|
1016
|
+
);
|
|
1017
|
+
let sharedModuleInitializer = null;
|
|
1018
|
+
if (allModules) {
|
|
1019
|
+
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
1020
|
+
if (typeof idOrFunc !== "function") {
|
|
1021
|
+
return false;
|
|
1022
|
+
}
|
|
1023
|
+
const funcCode = idOrFunc.toString();
|
|
1024
|
+
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
1025
|
+
});
|
|
1026
|
+
if (sharedModuleInitializerIndex > 0) {
|
|
1027
|
+
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1028
|
+
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1029
|
+
const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
|
|
1030
|
+
if (sharedModuleId) {
|
|
1031
|
+
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1032
|
+
scope,
|
|
1033
|
+
sharedModuleId,
|
|
1034
|
+
formatRemoteId(scope, String(sharedModuleInitializerId))
|
|
1035
|
+
);
|
|
1036
|
+
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
if (sharedModuleInitializer) {
|
|
1040
|
+
const { shared } = await sharedModuleInitializer;
|
|
1041
|
+
const sharedModuleIds = extractSharedModuleIds(shared, scope);
|
|
1042
|
+
logDebug(
|
|
1043
|
+
"SharedModules",
|
|
1044
|
+
`Resolved shared modules for scope="${scope.scopedName}": ${JSON.stringify(sharedModuleIds)}`
|
|
1045
|
+
);
|
|
1046
|
+
return Promise.all(
|
|
1047
|
+
Object.entries(sharedModuleIds).map(async ([id, module]) => {
|
|
1048
|
+
if (hostShared[module]) {
|
|
1049
|
+
scope.sharedModules[id] = await hostShared[module](scope.name);
|
|
1050
|
+
} else {
|
|
1051
|
+
logError(
|
|
1052
|
+
"SharedModules",
|
|
1053
|
+
`Host shared module "${module}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
})
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
logWarn(
|
|
1060
|
+
"SharedModules",
|
|
1061
|
+
`No shared module initializer found in bundle for scope="${scope.scopedName}" \u2014 falling back to remoteShared mapping`
|
|
1062
|
+
);
|
|
1063
|
+
} else {
|
|
1064
|
+
logWarn(
|
|
1065
|
+
"SharedModules",
|
|
1066
|
+
`No TURBOPACK modules found for scope="${scope.scopedName}" (TURBOPACK_${scope.globalKey} is empty)`
|
|
1067
|
+
);
|
|
1068
|
+
}
|
|
1069
|
+
return Promise.all(
|
|
1070
|
+
Object.entries(remoteShared).map(async ([id, module]) => {
|
|
1071
|
+
if (hostShared[module]) {
|
|
1072
|
+
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1073
|
+
scope.sharedModules[normalizedId] = await hostShared[module](
|
|
1074
|
+
scope.name
|
|
1075
|
+
);
|
|
1076
|
+
} else {
|
|
1077
|
+
logError(
|
|
1078
|
+
"SharedModules",
|
|
1079
|
+
`Shared module "${module}" not found for "${scope.name}". ${DEDUPLICATION_WARNING}`
|
|
1080
|
+
);
|
|
1081
|
+
}
|
|
1082
|
+
})
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
function extractSharedModuleIds(shared, scope) {
|
|
1086
|
+
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1087
|
+
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1088
|
+
if (asyncSharedModuleId) {
|
|
1089
|
+
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
1090
|
+
let asyncSharedModule;
|
|
1091
|
+
const turbopackModules = getTurbopackModules(scope) ?? [];
|
|
1092
|
+
const asyncSharedModuleIdIndex = turbopackModules.indexOf(
|
|
1093
|
+
asyncSharedModuleIdNumber
|
|
1094
|
+
);
|
|
1095
|
+
if (asyncSharedModuleIdIndex !== -1 && typeof turbopackModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1096
|
+
asyncSharedModule = turbopackModules[asyncSharedModuleIdIndex + 1];
|
|
1097
|
+
}
|
|
1098
|
+
if (asyncSharedModule) {
|
|
1099
|
+
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
1100
|
+
const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
|
|
1101
|
+
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1102
|
+
"__remote_shared_module_",
|
|
1103
|
+
""
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
return acc;
|
|
1108
|
+
}, {});
|
|
1109
|
+
}
|
|
1110
|
+
function getSharedModule(scope, id) {
|
|
1111
|
+
const idStr = String(id);
|
|
1112
|
+
if (scope.sharedModules[idStr] !== void 0) {
|
|
1113
|
+
return scope.sharedModules[idStr];
|
|
1114
|
+
}
|
|
1115
|
+
for (const [key, value] of Object.entries(scope.sharedModules)) {
|
|
1116
|
+
if (typeof value !== "undefined" && idStr !== key && idStr.endsWith(key)) {
|
|
1117
|
+
return value;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
return null;
|
|
1121
|
+
}
|
|
1122
|
+
var DEDUPLICATION_WARNING;
|
|
1123
|
+
var init_shared_modules = __esm({
|
|
1124
|
+
"src/runtime/turbopack/shared-modules.ts"() {
|
|
1125
|
+
"use strict";
|
|
1126
|
+
init_logger();
|
|
1127
|
+
init_module();
|
|
1128
|
+
init_patterns2();
|
|
1129
|
+
init_remote_scope();
|
|
1130
|
+
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).";
|
|
959
1131
|
}
|
|
960
1132
|
});
|
|
961
1133
|
|
|
962
1134
|
// src/runtime/turbopack/module.ts
|
|
963
|
-
function
|
|
1135
|
+
function requireModule(scope, moduleId, fullId) {
|
|
1136
|
+
const idStr = String(moduleId);
|
|
1137
|
+
if (scope.moduleCache[idStr])
|
|
1138
|
+
return scope.moduleCache[idStr];
|
|
1139
|
+
const sharedModule = getSharedModule(scope, moduleId);
|
|
1140
|
+
if (sharedModule) {
|
|
1141
|
+
scope.moduleCache[idStr] = sharedModule;
|
|
1142
|
+
return sharedModule;
|
|
1143
|
+
}
|
|
1144
|
+
return handleTurbopackModule(
|
|
1145
|
+
scope,
|
|
1146
|
+
idStr,
|
|
1147
|
+
fullId ?? formatRemoteId(scope, idStr)
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
function handleTurbopackModule(scope, moduleId, id) {
|
|
964
1151
|
const self = globalThis;
|
|
965
|
-
|
|
966
|
-
|
|
1152
|
+
if (scope.moduleCache[moduleId]) {
|
|
1153
|
+
return scope.moduleCache[moduleId];
|
|
1154
|
+
}
|
|
1155
|
+
const raw = self[`TURBOPACK_${scope.globalKey}`];
|
|
967
1156
|
let modules;
|
|
968
1157
|
if (raw && typeof raw === "object" && "__chunks__" in raw) {
|
|
969
1158
|
modules = raw.__chunks__.flat();
|
|
@@ -972,48 +1161,35 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
972
1161
|
} else {
|
|
973
1162
|
modules = raw;
|
|
974
1163
|
}
|
|
975
|
-
if (!self.__remote_components_turbopack_modules__) {
|
|
976
|
-
self.__remote_components_turbopack_modules__ = {};
|
|
977
|
-
}
|
|
978
|
-
if (!self.__remote_components_turbopack_modules__[bundle]) {
|
|
979
|
-
self.__remote_components_turbopack_modules__[bundle] = {};
|
|
980
|
-
}
|
|
981
|
-
if (self.__remote_components_turbopack_modules__[bundle][moduleId]) {
|
|
982
|
-
return self.__remote_components_turbopack_modules__[bundle][moduleId];
|
|
983
|
-
}
|
|
984
1164
|
if (!modules) {
|
|
985
|
-
logError(
|
|
1165
|
+
logError(
|
|
1166
|
+
"TurbopackModule",
|
|
1167
|
+
`TURBOPACK_${scope.globalKey} is undefined (scope: "${scope.scopedName}")`
|
|
1168
|
+
);
|
|
986
1169
|
}
|
|
987
1170
|
const moduleInit = findModuleInit(modules, moduleId);
|
|
988
1171
|
const exports = {};
|
|
989
1172
|
const moduleExports = { exports };
|
|
990
1173
|
if (typeof moduleInit !== "function") {
|
|
991
1174
|
throw new Error(
|
|
992
|
-
`Module ${id} not found in bundle ${
|
|
1175
|
+
`Module ${id} not found in bundle ${scope.name} with id ${moduleId}`
|
|
993
1176
|
);
|
|
994
1177
|
}
|
|
995
|
-
|
|
996
|
-
if (!self.__remote_components_turbopack_global__) {
|
|
997
|
-
self.__remote_components_turbopack_global__ = {};
|
|
998
|
-
}
|
|
999
|
-
if (!self.__remote_components_turbopack_global__[bundle]) {
|
|
1000
|
-
self.__remote_components_turbopack_global__[bundle] = {};
|
|
1001
|
-
}
|
|
1178
|
+
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1002
1179
|
moduleInit(
|
|
1003
1180
|
createTurbopackContext(
|
|
1004
|
-
|
|
1181
|
+
scope,
|
|
1005
1182
|
exports,
|
|
1006
1183
|
moduleExports,
|
|
1007
1184
|
modules,
|
|
1008
1185
|
moduleInit,
|
|
1009
|
-
id
|
|
1010
|
-
self
|
|
1186
|
+
id
|
|
1011
1187
|
),
|
|
1012
1188
|
moduleExports,
|
|
1013
1189
|
exports
|
|
1014
1190
|
);
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1191
|
+
if (scope.moduleCache[moduleId] !== moduleExports.exports) {
|
|
1192
|
+
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1017
1193
|
}
|
|
1018
1194
|
return moduleExports.exports;
|
|
1019
1195
|
}
|
|
@@ -1038,7 +1214,8 @@ function findModuleInit(modules, moduleId) {
|
|
|
1038
1214
|
(e) => Boolean(e && typeof e === "object" && moduleId in e)
|
|
1039
1215
|
)?.[moduleId];
|
|
1040
1216
|
}
|
|
1041
|
-
function createTurbopackContext(
|
|
1217
|
+
function createTurbopackContext(scope, exports, moduleExports, modules, moduleInit, id) {
|
|
1218
|
+
const scopedRequire = (moduleId) => requireModule(scope, moduleId, formatRemoteId(scope, String(moduleId)));
|
|
1042
1219
|
return {
|
|
1043
1220
|
// HMR not implemented for Remote Components
|
|
1044
1221
|
k: {
|
|
@@ -1054,16 +1231,10 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1054
1231
|
s(bindings, esmId) {
|
|
1055
1232
|
let mod = exports;
|
|
1056
1233
|
if (typeof esmId === "string" || typeof esmId === "number") {
|
|
1057
|
-
if (!
|
|
1058
|
-
|
|
1234
|
+
if (!scope.moduleCache[esmId]) {
|
|
1235
|
+
scope.moduleCache[esmId] = {};
|
|
1059
1236
|
}
|
|
1060
|
-
|
|
1061
|
-
self.__remote_components_turbopack_modules__[bundle] = {};
|
|
1062
|
-
}
|
|
1063
|
-
if (!self.__remote_components_turbopack_modules__[bundle][esmId]) {
|
|
1064
|
-
self.__remote_components_turbopack_modules__[bundle][esmId] = {};
|
|
1065
|
-
}
|
|
1066
|
-
mod = self.__remote_components_turbopack_modules__[bundle][esmId];
|
|
1237
|
+
mod = scope.moduleCache[esmId];
|
|
1067
1238
|
}
|
|
1068
1239
|
Object.defineProperty(mod, "__esModule", { value: true });
|
|
1069
1240
|
if (Array.isArray(bindings)) {
|
|
@@ -1096,7 +1267,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1096
1267
|
}
|
|
1097
1268
|
}
|
|
1098
1269
|
},
|
|
1099
|
-
// import
|
|
1270
|
+
// import — resolves directly via scope, no global dispatch
|
|
1100
1271
|
i(importId) {
|
|
1101
1272
|
let mod;
|
|
1102
1273
|
if (typeof importId === "string") {
|
|
@@ -1107,7 +1278,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1107
1278
|
/\s+<export(?<specifier>.*)>$/,
|
|
1108
1279
|
""
|
|
1109
1280
|
);
|
|
1110
|
-
mod =
|
|
1281
|
+
mod = scopedRequire(normalizedId);
|
|
1111
1282
|
if (mod && exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
1112
1283
|
if (exportSource === "*") {
|
|
1113
1284
|
mod[exportName] = mod;
|
|
@@ -1116,7 +1287,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1116
1287
|
}
|
|
1117
1288
|
}
|
|
1118
1289
|
} else {
|
|
1119
|
-
mod =
|
|
1290
|
+
mod = scopedRequire(importId);
|
|
1120
1291
|
}
|
|
1121
1292
|
if (typeof mod !== "object" || mod === null) {
|
|
1122
1293
|
mod = { default: mod };
|
|
@@ -1128,16 +1299,14 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1128
1299
|
}
|
|
1129
1300
|
return mod;
|
|
1130
1301
|
},
|
|
1131
|
-
// require
|
|
1302
|
+
// require — resolves directly via scope
|
|
1132
1303
|
r(requireId) {
|
|
1133
|
-
return
|
|
1304
|
+
return scopedRequire(requireId);
|
|
1134
1305
|
},
|
|
1135
1306
|
// value exports
|
|
1136
1307
|
v(value) {
|
|
1137
1308
|
if (typeof value === "function") {
|
|
1138
|
-
exports.default = value((vid) =>
|
|
1139
|
-
return self.__webpack_require__?.(`[${bundle}] ${vid}`);
|
|
1140
|
-
});
|
|
1309
|
+
exports.default = value((vid) => scopedRequire(vid));
|
|
1141
1310
|
} else {
|
|
1142
1311
|
moduleExports.exports = value;
|
|
1143
1312
|
}
|
|
@@ -1152,17 +1321,15 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1152
1321
|
);
|
|
1153
1322
|
exports.default = result;
|
|
1154
1323
|
},
|
|
1155
|
-
// async module loader
|
|
1324
|
+
// async module loader — resolves directly via scope
|
|
1156
1325
|
async A(Aid) {
|
|
1157
|
-
const mod =
|
|
1158
|
-
return mod.default(
|
|
1159
|
-
(parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
|
|
1160
|
-
);
|
|
1326
|
+
const mod = scopedRequire(Aid);
|
|
1327
|
+
return mod.default((parentId) => scopedRequire(parentId));
|
|
1161
1328
|
},
|
|
1162
1329
|
// dynamic import tracking — no-op for remote components
|
|
1163
1330
|
j() {
|
|
1164
1331
|
},
|
|
1165
|
-
// chunk loader
|
|
1332
|
+
// chunk loader — loads directly via scope, no global dispatch
|
|
1166
1333
|
l(url) {
|
|
1167
1334
|
const flatModules = Array.isArray(modules) ? modules : [];
|
|
1168
1335
|
const moduleInitIndex = flatModules.indexOf(moduleInit);
|
|
@@ -1173,16 +1340,16 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1173
1340
|
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
1174
1341
|
const nextIndex = scriptSrc.indexOf("/_next");
|
|
1175
1342
|
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
1176
|
-
const
|
|
1177
|
-
return
|
|
1343
|
+
const chunkUrl = `${baseUrl}/_next/${url}`;
|
|
1344
|
+
return loadChunkWithScope(scope, formatRemoteId(scope, chunkUrl));
|
|
1178
1345
|
}
|
|
1179
1346
|
}
|
|
1180
1347
|
throw new Error(
|
|
1181
1348
|
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
1182
1349
|
);
|
|
1183
1350
|
},
|
|
1184
|
-
//
|
|
1185
|
-
g:
|
|
1351
|
+
// globalThis substitute shared across all modules in this scope
|
|
1352
|
+
g: scope.moduleGlobal,
|
|
1186
1353
|
m: moduleExports,
|
|
1187
1354
|
e: exports
|
|
1188
1355
|
};
|
|
@@ -1190,173 +1357,61 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1190
1357
|
var init_module = __esm({
|
|
1191
1358
|
"src/runtime/turbopack/module.ts"() {
|
|
1192
1359
|
"use strict";
|
|
1193
|
-
init_constants2();
|
|
1194
|
-
init_logger();
|
|
1195
|
-
}
|
|
1196
|
-
});
|
|
1197
|
-
|
|
1198
|
-
// src/runtime/turbopack/shared-modules.ts
|
|
1199
|
-
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1200
|
-
const self = globalThis;
|
|
1201
|
-
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
1202
|
-
if (!self.__remote_shared_modules__[bundle]) {
|
|
1203
|
-
self.__remote_shared_modules__[bundle] = {};
|
|
1204
|
-
}
|
|
1205
|
-
const bundleKey = getBundleKey(bundle);
|
|
1206
|
-
let modules = self[`TURBOPACK_${bundleKey}`];
|
|
1207
|
-
if (modules && typeof modules === "object" && "__chunks__" in modules) {
|
|
1208
|
-
const chunks = modules.__chunks__;
|
|
1209
|
-
modules = chunks.flat();
|
|
1210
|
-
}
|
|
1211
|
-
let sharedModuleInitializer = null;
|
|
1212
|
-
if (modules) {
|
|
1213
|
-
const allModules = Array.isArray(modules) ? modules.flat() : Object.entries(modules).flat();
|
|
1214
|
-
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
1215
|
-
if (typeof idOrFunc !== "function") {
|
|
1216
|
-
return false;
|
|
1217
|
-
}
|
|
1218
|
-
const funcCode = idOrFunc.toString();
|
|
1219
|
-
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
1220
|
-
});
|
|
1221
|
-
if (sharedModuleInitializerIndex > 0) {
|
|
1222
|
-
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1223
|
-
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1224
|
-
const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
|
|
1225
|
-
if (sharedModuleId) {
|
|
1226
|
-
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1227
|
-
bundle,
|
|
1228
|
-
sharedModuleId,
|
|
1229
|
-
`[${bundle}] ${sharedModuleInitializerId}`
|
|
1230
|
-
);
|
|
1231
|
-
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
if (sharedModuleInitializer) {
|
|
1235
|
-
const { shared } = await sharedModuleInitializer;
|
|
1236
|
-
const sharedModuleIds = extractSharedModuleIds(
|
|
1237
|
-
shared,
|
|
1238
|
-
bundleKey,
|
|
1239
|
-
self
|
|
1240
|
-
);
|
|
1241
|
-
return Promise.all(
|
|
1242
|
-
Object.entries(sharedModuleIds).map(async ([id, module]) => {
|
|
1243
|
-
if (self.__remote_shared_modules__?.[bundle]) {
|
|
1244
|
-
if (hostShared[module]) {
|
|
1245
|
-
self.__remote_shared_modules__[bundle][id] = await hostShared[module](bundle);
|
|
1246
|
-
} else {
|
|
1247
|
-
logError(
|
|
1248
|
-
"SharedModules",
|
|
1249
|
-
`Host shared module "${module}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1250
|
-
);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
})
|
|
1254
|
-
);
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
return Promise.all(
|
|
1258
|
-
Object.entries(remoteShared).map(async ([id, module]) => {
|
|
1259
|
-
if (self.__remote_shared_modules__?.[bundle]) {
|
|
1260
|
-
if (hostShared[module]) {
|
|
1261
|
-
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1262
|
-
self.__remote_shared_modules__[bundle][normalizedId] = await hostShared[module](bundle);
|
|
1263
|
-
} else {
|
|
1264
|
-
logError(
|
|
1265
|
-
"SharedModules",
|
|
1266
|
-
`Shared module "${module}" not found for "${bundle}". ${DEDUPLICATION_WARNING}`
|
|
1267
|
-
);
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
})
|
|
1271
|
-
);
|
|
1272
|
-
}
|
|
1273
|
-
function extractSharedModuleIds(shared, bundleKey, self) {
|
|
1274
|
-
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1275
|
-
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1276
|
-
if (asyncSharedModuleId) {
|
|
1277
|
-
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
1278
|
-
let asyncSharedModule;
|
|
1279
|
-
let turbopackModules = self[`TURBOPACK_${bundleKey}`];
|
|
1280
|
-
if (turbopackModules && typeof turbopackModules === "object" && "__chunks__" in turbopackModules) {
|
|
1281
|
-
const chunks = turbopackModules.__chunks__;
|
|
1282
|
-
turbopackModules = chunks.flat();
|
|
1283
|
-
}
|
|
1284
|
-
const newAllModules = Array.isArray(turbopackModules) ? turbopackModules.flat() : turbopackModules ? Object.entries(turbopackModules).flatMap(([key2, value2]) => [
|
|
1285
|
-
key2,
|
|
1286
|
-
value2
|
|
1287
|
-
]) : [];
|
|
1288
|
-
const asyncSharedModuleIdIndex = newAllModules.indexOf(
|
|
1289
|
-
asyncSharedModuleIdNumber
|
|
1290
|
-
);
|
|
1291
|
-
if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1292
|
-
asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
|
|
1293
|
-
}
|
|
1294
|
-
if (asyncSharedModule) {
|
|
1295
|
-
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
1296
|
-
const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
|
|
1297
|
-
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1298
|
-
"__remote_shared_module_",
|
|
1299
|
-
""
|
|
1300
|
-
);
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
return acc;
|
|
1304
|
-
}, {});
|
|
1305
|
-
}
|
|
1306
|
-
function getSharedModule(bundle, id) {
|
|
1307
|
-
const self = globalThis;
|
|
1308
|
-
for (const [key, value] of Object.entries(
|
|
1309
|
-
self.__remote_shared_modules__?.[bundle] ?? {}
|
|
1310
|
-
)) {
|
|
1311
|
-
if (typeof value !== "undefined" && (typeof id === "string" && id.includes(key) || id === key)) {
|
|
1312
|
-
return value;
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
return null;
|
|
1316
|
-
}
|
|
1317
|
-
var DEDUPLICATION_WARNING;
|
|
1318
|
-
var init_shared_modules = __esm({
|
|
1319
|
-
"src/runtime/turbopack/shared-modules.ts"() {
|
|
1320
|
-
"use strict";
|
|
1321
|
-
init_constants2();
|
|
1322
1360
|
init_logger();
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1361
|
+
init_chunk_loader();
|
|
1362
|
+
init_remote_scope();
|
|
1363
|
+
init_shared_modules();
|
|
1326
1364
|
}
|
|
1327
1365
|
});
|
|
1328
1366
|
|
|
1329
1367
|
// src/runtime/turbopack/webpack-runtime.ts
|
|
1330
1368
|
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
|
|
1331
1369
|
const self = globalThis;
|
|
1370
|
+
const bundleName = bundle ?? "default";
|
|
1371
|
+
const scope = createScope(bundleName, url, runtime, resolveClientUrl);
|
|
1372
|
+
registerScope(scope);
|
|
1332
1373
|
if (!self.__remote_bundle_url__) {
|
|
1333
1374
|
self.__remote_bundle_url__ = {};
|
|
1334
1375
|
}
|
|
1335
|
-
self.__remote_bundle_url__[
|
|
1376
|
+
self.__remote_bundle_url__[bundleName] = url;
|
|
1377
|
+
if (scope.scopedName !== bundleName) {
|
|
1378
|
+
self.__remote_bundle_url__[scope.scopedName] = url;
|
|
1379
|
+
}
|
|
1336
1380
|
self.__webpack_get_script_filename__ = () => null;
|
|
1337
|
-
|
|
1381
|
+
const willCreateDispatchers = typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack";
|
|
1382
|
+
if (willCreateDispatchers) {
|
|
1338
1383
|
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
1339
1384
|
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
1340
1385
|
self.__original_webpack_require__ = self.__webpack_require__;
|
|
1341
1386
|
}
|
|
1342
|
-
self.__webpack_chunk_load__ =
|
|
1343
|
-
self.__webpack_require__ =
|
|
1387
|
+
self.__webpack_chunk_load__ = createChunkDispatcher();
|
|
1388
|
+
self.__webpack_require__ = createModuleDispatcher(runtime);
|
|
1344
1389
|
self.__webpack_require_type__ = runtime;
|
|
1345
1390
|
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
1346
|
-
|
|
1347
|
-
self.__remote_webpack_require__[
|
|
1348
|
-
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
1391
|
+
self.__remote_webpack_require__[bundleName] = self.__webpack_require__;
|
|
1392
|
+
self.__remote_webpack_require__[bundleName].type = "turbopack";
|
|
1349
1393
|
}
|
|
1350
1394
|
}
|
|
1395
|
+
if (self.__remote_webpack_require__?.[bundleName] && scope.scopedName !== bundleName) {
|
|
1396
|
+
self.__remote_webpack_require__[scope.scopedName] = self.__remote_webpack_require__[bundleName];
|
|
1397
|
+
}
|
|
1351
1398
|
if (runtime === RUNTIME_TURBOPACK) {
|
|
1352
|
-
await Promise.
|
|
1399
|
+
const results = await Promise.allSettled(
|
|
1353
1400
|
scripts.map((script) => {
|
|
1354
1401
|
if (script.src) {
|
|
1355
|
-
return
|
|
1402
|
+
return loadChunkWithScope(scope, script.src);
|
|
1356
1403
|
}
|
|
1357
1404
|
return Promise.resolve(void 0);
|
|
1358
1405
|
})
|
|
1359
1406
|
);
|
|
1407
|
+
for (const result of results) {
|
|
1408
|
+
if (result.status === "rejected") {
|
|
1409
|
+
logWarn(
|
|
1410
|
+
"WebpackRuntime",
|
|
1411
|
+
`Initial chunk load failed: ${String(result.reason)}`
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1360
1415
|
}
|
|
1361
1416
|
const coreShared = {
|
|
1362
1417
|
react: async () => (await import("react")).default,
|
|
@@ -1366,54 +1421,54 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1366
1421
|
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1367
1422
|
...shared
|
|
1368
1423
|
};
|
|
1369
|
-
await initializeSharedModules(
|
|
1370
|
-
bundle ?? "default",
|
|
1371
|
-
// include all core modules as shared
|
|
1372
|
-
coreShared,
|
|
1373
|
-
remoteShared
|
|
1374
|
-
);
|
|
1424
|
+
await initializeSharedModules(scope, coreShared, remoteShared);
|
|
1375
1425
|
}
|
|
1376
|
-
function
|
|
1426
|
+
function createModuleDispatcher(runtime) {
|
|
1377
1427
|
return (id) => {
|
|
1378
1428
|
const self = globalThis;
|
|
1379
1429
|
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
1380
1430
|
bundle: "default",
|
|
1381
1431
|
id
|
|
1382
1432
|
};
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1433
|
+
const bundleName = bundle ?? "default";
|
|
1434
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundleName] ? self.__remote_webpack_require__[bundleName]?.type || "webpack" : runtime;
|
|
1435
|
+
logDebug(
|
|
1436
|
+
"ModuleDispatcher",
|
|
1437
|
+
`Resolving "${id}" (bundle: "${bundleName}", runtime: "${remoteRuntime}")`
|
|
1438
|
+
);
|
|
1385
1439
|
try {
|
|
1386
1440
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1387
1441
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
1388
1442
|
}
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
return sharedModule;
|
|
1393
|
-
}
|
|
1394
|
-
if (bundle && moduleId) {
|
|
1395
|
-
return handleTurbopackModule(bundle, moduleId, id);
|
|
1443
|
+
const scope = getScope(bundleName);
|
|
1444
|
+
if (scope) {
|
|
1445
|
+
return requireModule(scope, moduleId ?? id, id);
|
|
1396
1446
|
}
|
|
1397
|
-
throw new Error(
|
|
1447
|
+
throw new Error(
|
|
1448
|
+
`Module "${id}" not found \u2014 no scope for bundle "${bundleName}".`
|
|
1449
|
+
);
|
|
1398
1450
|
} catch (requireError) {
|
|
1399
1451
|
logWarn(
|
|
1400
|
-
"
|
|
1452
|
+
"ModuleDispatcher",
|
|
1401
1453
|
`Module require failed: ${String(requireError)}`
|
|
1402
1454
|
);
|
|
1403
1455
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
1404
1456
|
throw new RemoteComponentsError(
|
|
1405
|
-
`Module "${id}" not found in remote component bundle "${
|
|
1457
|
+
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1406
1458
|
{
|
|
1407
1459
|
cause: requireError instanceof Error ? requireError : void 0
|
|
1408
1460
|
}
|
|
1409
1461
|
);
|
|
1410
1462
|
}
|
|
1411
1463
|
try {
|
|
1412
|
-
logDebug(
|
|
1464
|
+
logDebug(
|
|
1465
|
+
"ModuleDispatcher",
|
|
1466
|
+
"Falling back to original webpack require"
|
|
1467
|
+
);
|
|
1413
1468
|
return self.__original_webpack_require__(id);
|
|
1414
1469
|
} catch (originalError) {
|
|
1415
1470
|
throw new RemoteComponentsError(
|
|
1416
|
-
`Module "${id}" not found in remote component bundle "${
|
|
1471
|
+
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1417
1472
|
{ cause: originalError instanceof Error ? originalError : void 0 }
|
|
1418
1473
|
);
|
|
1419
1474
|
}
|
|
@@ -1424,10 +1479,12 @@ var init_webpack_runtime = __esm({
|
|
|
1424
1479
|
"src/runtime/turbopack/webpack-runtime.ts"() {
|
|
1425
1480
|
"use strict";
|
|
1426
1481
|
init_constants2();
|
|
1482
|
+
init_patterns();
|
|
1427
1483
|
init_error();
|
|
1428
1484
|
init_logger();
|
|
1429
1485
|
init_chunk_loader();
|
|
1430
1486
|
init_module();
|
|
1487
|
+
init_remote_scope();
|
|
1431
1488
|
init_shared_modules();
|
|
1432
1489
|
}
|
|
1433
1490
|
});
|
|
@@ -1757,6 +1814,9 @@ function resolveNameFromSrc(src, defaultName) {
|
|
|
1757
1814
|
return name || defaultName;
|
|
1758
1815
|
}
|
|
1759
1816
|
|
|
1817
|
+
// src/host/html/index.tsx
|
|
1818
|
+
init_constants2();
|
|
1819
|
+
|
|
1760
1820
|
// src/runtime/html/apply-origin.ts
|
|
1761
1821
|
var tagNames = [
|
|
1762
1822
|
"img",
|
|
@@ -1821,6 +1881,41 @@ function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
|
1821
1881
|
|
|
1822
1882
|
// src/runtime/html/parse-remote-html.ts
|
|
1823
1883
|
init_constants2();
|
|
1884
|
+
|
|
1885
|
+
// src/runtime/metadata.ts
|
|
1886
|
+
init_constants2();
|
|
1887
|
+
var VALID_RUNTIMES = /* @__PURE__ */ new Set(["webpack", "turbopack", "script"]);
|
|
1888
|
+
var VALID_TYPES = /* @__PURE__ */ new Set([
|
|
1889
|
+
"nextjs",
|
|
1890
|
+
"remote-component",
|
|
1891
|
+
"unknown"
|
|
1892
|
+
]);
|
|
1893
|
+
function isRuntime(value) {
|
|
1894
|
+
return VALID_RUNTIMES.has(value);
|
|
1895
|
+
}
|
|
1896
|
+
function isComponentType(value) {
|
|
1897
|
+
return VALID_TYPES.has(value);
|
|
1898
|
+
}
|
|
1899
|
+
function toRuntime(value) {
|
|
1900
|
+
return value && isRuntime(value) ? value : "webpack";
|
|
1901
|
+
}
|
|
1902
|
+
function toComponentType(value) {
|
|
1903
|
+
return value && isComponentType(value) ? value : "unknown";
|
|
1904
|
+
}
|
|
1905
|
+
function buildMetadata(attrs, url) {
|
|
1906
|
+
const id = attrs.id || DEFAULT_COMPONENT_NAME;
|
|
1907
|
+
const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION || DEFAULT_BUNDLE_NAME;
|
|
1908
|
+
return {
|
|
1909
|
+
name: attrs.name || id.replace(/_ssr$/, ""),
|
|
1910
|
+
bundle,
|
|
1911
|
+
route: attrs.route || url.pathname || DEFAULT_ROUTE,
|
|
1912
|
+
runtime: toRuntime(attrs.runtime),
|
|
1913
|
+
id,
|
|
1914
|
+
type: toComponentType(attrs.type)
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
// src/runtime/html/parse-remote-html.ts
|
|
1824
1919
|
init_error();
|
|
1825
1920
|
function validateSingleComponent(doc, name, url) {
|
|
1826
1921
|
if (doc.querySelectorAll("div[data-bundle][data-route]").length > 1 && !doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) || doc.querySelectorAll("remote-component:not([src])").length > 1 && !doc.querySelector(`remote-component[name="${name}"]`)) {
|
|
@@ -1840,14 +1935,6 @@ function resolveComponentName(component, nextData, fallbackName) {
|
|
|
1840
1935
|
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
1841
1936
|
return { name, isRemoteComponent };
|
|
1842
1937
|
}
|
|
1843
|
-
function extractComponentMetadata(component, nextData, name, url) {
|
|
1844
|
-
return {
|
|
1845
|
-
name,
|
|
1846
|
-
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
1847
|
-
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
1848
|
-
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
1849
|
-
};
|
|
1850
|
-
}
|
|
1851
1938
|
function extractRemoteShared(doc, name, nextData) {
|
|
1852
1939
|
const remoteSharedEl = doc.querySelector(
|
|
1853
1940
|
`#${name}_shared[data-remote-components-shared]`
|
|
@@ -1859,7 +1946,7 @@ function extractRemoteShared(doc, name, nextData) {
|
|
|
1859
1946
|
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
1860
1947
|
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
1861
1948
|
throw new RemoteComponentsError(
|
|
1862
|
-
`Remote Component not found on ${url}.${name !==
|
|
1949
|
+
`Remote Component not found on ${url}.${name !== DEFAULT_COMPONENT_NAME ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
|
|
1863
1950
|
);
|
|
1864
1951
|
}
|
|
1865
1952
|
}
|
|
@@ -1885,10 +1972,15 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
1885
1972
|
name
|
|
1886
1973
|
);
|
|
1887
1974
|
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
1888
|
-
const metadata =
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1975
|
+
const metadata = buildMetadata(
|
|
1976
|
+
{
|
|
1977
|
+
name: resolvedName,
|
|
1978
|
+
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle,
|
|
1979
|
+
route: component?.getAttribute("data-route") ?? nextData?.page,
|
|
1980
|
+
runtime: component?.getAttribute("data-runtime") ?? nextData?.props.__REMOTE_COMPONENT__?.runtime ?? RUNTIME_SCRIPT,
|
|
1981
|
+
id: component?.getAttribute("id"),
|
|
1982
|
+
type: component?.getAttribute("data-type")
|
|
1983
|
+
},
|
|
1892
1984
|
url
|
|
1893
1985
|
);
|
|
1894
1986
|
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
@@ -2104,12 +2196,7 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2104
2196
|
}
|
|
2105
2197
|
if (type === "webpack") {
|
|
2106
2198
|
const { webpackRuntime: webpackRuntime2 } = await Promise.resolve().then(() => (init_webpack(), webpack_exports));
|
|
2107
|
-
return webpackRuntime2(
|
|
2108
|
-
bundle ?? "default",
|
|
2109
|
-
shared,
|
|
2110
|
-
remoteShared,
|
|
2111
|
-
resolveClientUrl
|
|
2112
|
-
);
|
|
2199
|
+
return webpackRuntime2(bundle, shared, remoteShared, resolveClientUrl);
|
|
2113
2200
|
} else if (type === "turbopack") {
|
|
2114
2201
|
const { turbopackRuntime: turbopackRuntime2 } = await Promise.resolve().then(() => (init_turbopack(), turbopack_exports));
|
|
2115
2202
|
return turbopackRuntime2(
|
|
@@ -2132,8 +2219,8 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2132
2219
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
2133
2220
|
if (typeof HTMLElement !== "undefined") {
|
|
2134
2221
|
class RemoteComponent extends HTMLElement {
|
|
2135
|
-
name;
|
|
2136
|
-
bundle;
|
|
2222
|
+
name = DEFAULT_COMPONENT_NAME;
|
|
2223
|
+
bundle = DEFAULT_BUNDLE_NAME;
|
|
2137
2224
|
fallbackSlot;
|
|
2138
2225
|
__next = null;
|
|
2139
2226
|
fouc = null;
|
|
@@ -2249,8 +2336,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2249
2336
|
this.fallbackSlot = document.createElement("slot");
|
|
2250
2337
|
this.root.appendChild(this.fallbackSlot);
|
|
2251
2338
|
}
|
|
2252
|
-
this.name = this.getAttribute("name") ||
|
|
2253
|
-
this.bundle = "default";
|
|
2339
|
+
this.name = this.getAttribute("name") || this.name;
|
|
2254
2340
|
this.hostState.stage = "loading";
|
|
2255
2341
|
const src = this.src;
|
|
2256
2342
|
this.hostState.abortController = new AbortController();
|
|
@@ -2270,10 +2356,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2270
2356
|
let html = this.innerHTML;
|
|
2271
2357
|
if (src) {
|
|
2272
2358
|
url = getClientOrServerUrl(src, window.location.href);
|
|
2273
|
-
this.name = resolveNameFromSrc(
|
|
2274
|
-
src,
|
|
2275
|
-
this.name ?? "__vercel_remote_component"
|
|
2276
|
-
);
|
|
2359
|
+
this.name = resolveNameFromSrc(src, this.name);
|
|
2277
2360
|
}
|
|
2278
2361
|
const resolveClientUrl = url ? bindResolveClientUrl(this.resolveClientUrl, url.href) : void 0;
|
|
2279
2362
|
if (!remoteComponentChild && url) {
|
|
@@ -2316,7 +2399,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2316
2399
|
const doc = parser.parseFromString(html, "text/html");
|
|
2317
2400
|
const parsed = parseRemoteComponentDocument(
|
|
2318
2401
|
doc,
|
|
2319
|
-
this.name
|
|
2402
|
+
this.name,
|
|
2320
2403
|
url ?? new URL(window.location.href)
|
|
2321
2404
|
);
|
|
2322
2405
|
const {
|
|
@@ -2340,7 +2423,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2340
2423
|
if (!self2.__remote_bundle_url__) {
|
|
2341
2424
|
self2.__remote_bundle_url__ = {};
|
|
2342
2425
|
}
|
|
2343
|
-
self2.__remote_bundle_url__[this.bundle
|
|
2426
|
+
self2.__remote_bundle_url__[this.bundle] = url;
|
|
2344
2427
|
}
|
|
2345
2428
|
const metadataEl = document.createElement("script");
|
|
2346
2429
|
metadataEl.type = "application/json";
|
|
@@ -2532,12 +2615,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2532
2615
|
window.location.href
|
|
2533
2616
|
);
|
|
2534
2617
|
}
|
|
2535
|
-
await preloadScripts(
|
|
2536
|
-
Array.from(scripts),
|
|
2537
|
-
url,
|
|
2538
|
-
this.bundle ?? "default",
|
|
2539
|
-
this.name ?? "__vercel_remote_component"
|
|
2540
|
-
);
|
|
2618
|
+
await preloadScripts(Array.from(scripts), url, this.bundle, this.name);
|
|
2541
2619
|
if (!isCurrentLoad()) {
|
|
2542
2620
|
return abandonLoad();
|
|
2543
2621
|
}
|
|
@@ -2616,7 +2694,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2616
2694
|
RemoteComponentFromReadableStream,
|
|
2617
2695
|
{
|
|
2618
2696
|
initial: false,
|
|
2619
|
-
name: this.name
|
|
2697
|
+
name: this.name
|
|
2620
2698
|
}
|
|
2621
2699
|
)
|
|
2622
2700
|
);
|
|
@@ -2627,17 +2705,11 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2627
2705
|
// hydrateRoot expects a document or element, but it works for the shadow DOM too
|
|
2628
2706
|
// @ts-expect-error support for shadow DOM
|
|
2629
2707
|
this.root,
|
|
2630
|
-
/* @__PURE__ */ jsx2(
|
|
2631
|
-
RemoteComponentFromReadableStream,
|
|
2632
|
-
{
|
|
2633
|
-
initial: true,
|
|
2634
|
-
name: this.name ?? "__vercel_remote_component"
|
|
2635
|
-
}
|
|
2636
|
-
)
|
|
2708
|
+
/* @__PURE__ */ jsx2(RemoteComponentFromReadableStream, { initial: true, name: this.name })
|
|
2637
2709
|
);
|
|
2638
2710
|
} else if (nextData) {
|
|
2639
2711
|
const { Component, App } = nextClientPagesLoader2(
|
|
2640
|
-
this.bundle
|
|
2712
|
+
this.bundle,
|
|
2641
2713
|
nextData.page ?? "/",
|
|
2642
2714
|
this.root
|
|
2643
2715
|
);
|