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.cjs
CHANGED
|
@@ -213,6 +213,9 @@ var init_logger = __esm({
|
|
|
213
213
|
function escapeString(str) {
|
|
214
214
|
return str.replace(/[^a-z0-9]/g, "_");
|
|
215
215
|
}
|
|
216
|
+
function computeScopedName(name, options) {
|
|
217
|
+
return options.isCrossOrigin ? `${name}_${escapeString(options.remoteHost.toLowerCase())}` : name;
|
|
218
|
+
}
|
|
216
219
|
var init_utils = __esm({
|
|
217
220
|
"src/utils/index.ts"() {
|
|
218
221
|
"use strict";
|
|
@@ -223,17 +226,17 @@ var init_utils = __esm({
|
|
|
223
226
|
function getBundleKey(bundle) {
|
|
224
227
|
return escapeString(bundle);
|
|
225
228
|
}
|
|
226
|
-
var DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT
|
|
229
|
+
var DEFAULT_BUNDLE_NAME, DEFAULT_COMPONENT_NAME, DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT;
|
|
227
230
|
var init_constants2 = __esm({
|
|
228
231
|
"src/runtime/constants.ts"() {
|
|
229
232
|
"use strict";
|
|
230
233
|
init_utils();
|
|
234
|
+
DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
|
|
235
|
+
DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
|
|
231
236
|
DEFAULT_ROUTE = "/";
|
|
232
237
|
RUNTIME_WEBPACK = "webpack";
|
|
233
238
|
RUNTIME_TURBOPACK = "turbopack";
|
|
234
239
|
RUNTIME_SCRIPT = "script";
|
|
235
|
-
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
236
|
-
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
237
240
|
}
|
|
238
241
|
});
|
|
239
242
|
|
|
@@ -424,11 +427,93 @@ var init_next_client_pages_loader = __esm({
|
|
|
424
427
|
}
|
|
425
428
|
});
|
|
426
429
|
|
|
427
|
-
// src/
|
|
428
|
-
function
|
|
430
|
+
// src/runtime/patterns.ts
|
|
431
|
+
function collapseDoubleSlashes(path) {
|
|
432
|
+
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
433
|
+
}
|
|
434
|
+
var REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE, DOUBLE_SLASH_RE;
|
|
435
|
+
var init_patterns = __esm({
|
|
436
|
+
"src/runtime/patterns.ts"() {
|
|
437
|
+
"use strict";
|
|
438
|
+
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
439
|
+
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
440
|
+
DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// src/runtime/turbopack/remote-scope.ts
|
|
445
|
+
function getRegistry() {
|
|
429
446
|
const self = globalThis;
|
|
430
|
-
|
|
447
|
+
if (!self.__remote_component_scopes__) {
|
|
448
|
+
self.__remote_component_scopes__ = /* @__PURE__ */ new Map();
|
|
449
|
+
}
|
|
450
|
+
return self.__remote_component_scopes__;
|
|
451
|
+
}
|
|
452
|
+
function createScope(name, url, runtime, resolveClientUrl) {
|
|
453
|
+
const isCrossOrigin = url.origin !== location.origin;
|
|
454
|
+
const scopedName = computeScopedName(name, {
|
|
455
|
+
remoteHost: url.host,
|
|
456
|
+
isCrossOrigin
|
|
457
|
+
});
|
|
458
|
+
const globalKey = getBundleKey(scopedName);
|
|
459
|
+
return {
|
|
460
|
+
name,
|
|
461
|
+
scopedName,
|
|
462
|
+
globalKey,
|
|
463
|
+
url,
|
|
464
|
+
runtime,
|
|
465
|
+
resolveClientUrl,
|
|
466
|
+
moduleCache: {},
|
|
467
|
+
sharedModules: {},
|
|
468
|
+
moduleGlobal: {}
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
function registerScope(scope) {
|
|
472
|
+
const registry = getRegistry();
|
|
473
|
+
registry.set(scope.scopedName, scope);
|
|
474
|
+
if (scope.scopedName !== scope.name) {
|
|
475
|
+
const existing = registry.get(scope.name);
|
|
476
|
+
if (existing && existing.scopedName !== scope.scopedName) {
|
|
477
|
+
logWarn(
|
|
478
|
+
"RemoteScope",
|
|
479
|
+
`Plain name "${scope.name}" already registered by scope "${existing.scopedName}" \u2014 overwriting with "${scope.scopedName}". Static hosts will only resolve the latest one.`
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
registry.set(scope.name, scope);
|
|
483
|
+
}
|
|
484
|
+
logDebug(
|
|
485
|
+
"RemoteScope",
|
|
486
|
+
`Registered scope "${scope.scopedName}" (${registry.size} total)`
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
function getScope(name) {
|
|
490
|
+
return getRegistry().get(name);
|
|
491
|
+
}
|
|
492
|
+
function formatRemoteId(scope, path) {
|
|
493
|
+
return `[${scope.scopedName}] ${path}`;
|
|
431
494
|
}
|
|
495
|
+
function parseRemoteId(id) {
|
|
496
|
+
const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;
|
|
497
|
+
if (groups?.bundle && groups.id) {
|
|
498
|
+
return {
|
|
499
|
+
bundle: groups.bundle,
|
|
500
|
+
path: groups.id,
|
|
501
|
+
prefix: groups.prefix ?? ""
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
return { bundle: "default", path: id, prefix: "" };
|
|
505
|
+
}
|
|
506
|
+
var init_remote_scope = __esm({
|
|
507
|
+
"src/runtime/turbopack/remote-scope.ts"() {
|
|
508
|
+
"use strict";
|
|
509
|
+
init_constants2();
|
|
510
|
+
init_patterns();
|
|
511
|
+
init_utils();
|
|
512
|
+
init_logger();
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
// src/host/shared/remote-image-loader.ts
|
|
432
517
|
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
433
518
|
const loader = Object.assign(
|
|
434
519
|
({
|
|
@@ -438,7 +523,7 @@ function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
|
438
523
|
quality
|
|
439
524
|
}) => {
|
|
440
525
|
const q = quality ?? 75;
|
|
441
|
-
const remoteOrigin =
|
|
526
|
+
const remoteOrigin = getScope(bundle)?.url.origin ?? "";
|
|
442
527
|
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
443
528
|
const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
|
|
444
529
|
const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
@@ -453,6 +538,7 @@ function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
|
453
538
|
var init_remote_image_loader = __esm({
|
|
454
539
|
"src/host/shared/remote-image-loader.ts"() {
|
|
455
540
|
"use strict";
|
|
541
|
+
init_remote_scope();
|
|
456
542
|
}
|
|
457
543
|
});
|
|
458
544
|
|
|
@@ -643,7 +729,7 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
643
729
|
var init_script_loader = __esm({
|
|
644
730
|
"src/runtime/loaders/script-loader.ts"() {
|
|
645
731
|
"use strict";
|
|
646
|
-
|
|
732
|
+
init_patterns();
|
|
647
733
|
init_protected_rc_fallback();
|
|
648
734
|
init_error();
|
|
649
735
|
init_logger();
|
|
@@ -744,15 +830,15 @@ var init_webpack = __esm({
|
|
|
744
830
|
init_apply_shared_modules();
|
|
745
831
|
init_next_client_pages_loader();
|
|
746
832
|
init_polyfill();
|
|
747
|
-
init_constants2();
|
|
748
833
|
init_script_loader();
|
|
834
|
+
init_patterns();
|
|
749
835
|
init_error();
|
|
750
836
|
}
|
|
751
837
|
});
|
|
752
838
|
|
|
753
839
|
// src/runtime/turbopack/patterns.ts
|
|
754
840
|
var REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_RESOLVE_RE, ASYNC_MODULE_ALL_RE, TURBOPACK_GLOBAL_RE;
|
|
755
|
-
var
|
|
841
|
+
var init_patterns2 = __esm({
|
|
756
842
|
"src/runtime/turbopack/patterns.ts"() {
|
|
757
843
|
"use strict";
|
|
758
844
|
REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
@@ -765,62 +851,39 @@ var init_patterns = __esm({
|
|
|
765
851
|
});
|
|
766
852
|
|
|
767
853
|
// src/runtime/turbopack/chunk-loader.ts
|
|
768
|
-
function
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
).href;
|
|
797
|
-
if (url.endsWith(".css")) {
|
|
798
|
-
logDebug("ChunkLoader", `Skipping CSS file: "${url}"`);
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
|
-
if (!self.__remote_components_turbopack_chunk_loader_promise__) {
|
|
802
|
-
self.__remote_components_turbopack_chunk_loader_promise__ = {};
|
|
803
|
-
}
|
|
804
|
-
if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
|
|
805
|
-
logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
|
|
806
|
-
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
807
|
-
}
|
|
808
|
-
const resolvedUrl = resolveClientUrl?.(url) ?? url;
|
|
809
|
-
logDebug("ChunkLoader", `Fetching chunk from: "${resolvedUrl}"`);
|
|
810
|
-
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
|
|
854
|
+
function loadChunkWithScope(scope, chunkId) {
|
|
855
|
+
logDebug(
|
|
856
|
+
"ChunkLoader",
|
|
857
|
+
`loadChunkWithScope: "${chunkId}" (scope: "${scope.scopedName}")`
|
|
858
|
+
);
|
|
859
|
+
const self = globalThis;
|
|
860
|
+
const { bundle, path, prefix } = parseRemoteId(chunkId);
|
|
861
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : scope.runtime;
|
|
862
|
+
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
863
|
+
return Promise.resolve(void 0);
|
|
864
|
+
}
|
|
865
|
+
const rawPath = path ? collapseDoubleSlashes(`${prefix}${path}`) : "/";
|
|
866
|
+
const url = new URL(rawPath, scope.url).href;
|
|
867
|
+
if (url.endsWith(".css")) {
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
if (!self.__remote_components_turbopack_chunk_loader_promise__) {
|
|
871
|
+
self.__remote_components_turbopack_chunk_loader_promise__ = {};
|
|
872
|
+
}
|
|
873
|
+
if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
|
|
874
|
+
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
875
|
+
}
|
|
876
|
+
const resolvedUrl = scope.resolveClientUrl?.(url) ?? url;
|
|
877
|
+
if (resolvedUrl !== url) {
|
|
878
|
+
logDebug("ChunkLoader", `Proxied chunk URL: "${url}" \u2192 "${resolvedUrl}"`);
|
|
879
|
+
}
|
|
880
|
+
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise(
|
|
881
|
+
(resolve, reject) => {
|
|
811
882
|
fetch(resolvedUrl).then((res) => res.text()).then((code) => {
|
|
812
883
|
const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
|
|
813
884
|
if (hasTurbopack) {
|
|
814
|
-
return handleTurbopackChunk(code,
|
|
885
|
+
return handleTurbopackChunk(code, scope, url);
|
|
815
886
|
}
|
|
816
|
-
logDebug(
|
|
817
|
-
"ChunkLoader",
|
|
818
|
-
`Chunk does not contain globalThis.TURBOPACK or self.TURBOPACK: "${url}"`
|
|
819
|
-
);
|
|
820
|
-
logDebug(
|
|
821
|
-
"ChunkLoader",
|
|
822
|
-
`First 500 chars of chunk: ${code.slice(0, 500)}`
|
|
823
|
-
);
|
|
824
887
|
}).then(resolve).catch((error) => {
|
|
825
888
|
const isProxied = isProxiedUrl(resolvedUrl);
|
|
826
889
|
if (isProxied) {
|
|
@@ -830,17 +893,29 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
830
893
|
reject(error);
|
|
831
894
|
}
|
|
832
895
|
});
|
|
833
|
-
}
|
|
834
|
-
|
|
896
|
+
}
|
|
897
|
+
);
|
|
898
|
+
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
899
|
+
}
|
|
900
|
+
function createChunkDispatcher() {
|
|
901
|
+
return function __chunk_dispatcher__(chunkId, scriptBundle) {
|
|
902
|
+
logDebug("ChunkDispatcher", `Dispatching chunk: "${chunkId}"`);
|
|
903
|
+
const { bundle } = parseRemoteId(chunkId);
|
|
904
|
+
const bundleName = bundle || scriptBundle || "default";
|
|
905
|
+
const scope = getScope(bundleName);
|
|
906
|
+
logDebug(
|
|
907
|
+
"ChunkDispatcher",
|
|
908
|
+
`Scope resolution: bundle="${bundleName}", scope=${scope?.scopedName ?? "null"}`
|
|
909
|
+
);
|
|
910
|
+
if (!scope) {
|
|
911
|
+
logWarn("ChunkDispatcher", `No scope found for bundle "${bundleName}"`);
|
|
912
|
+
return Promise.resolve(void 0);
|
|
913
|
+
}
|
|
914
|
+
return loadChunkWithScope(scope, chunkId);
|
|
835
915
|
};
|
|
836
916
|
}
|
|
837
|
-
async function handleTurbopackChunk(code,
|
|
838
|
-
logDebug(
|
|
839
|
-
"ChunkLoader",
|
|
840
|
-
`Handling Turbopack chunk - bundle: "${bundle}", url: "${url}"`
|
|
841
|
-
);
|
|
917
|
+
async function handleTurbopackChunk(code, scope, url) {
|
|
842
918
|
if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
|
|
843
|
-
logDebug("ChunkLoader", `Skipping worker chunk: "${url}"`);
|
|
844
919
|
const preloadLinks = document.querySelectorAll(
|
|
845
920
|
`link[rel="preload"][href="${new URL(url).pathname}"]`
|
|
846
921
|
);
|
|
@@ -848,58 +923,41 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
848
923
|
return;
|
|
849
924
|
}
|
|
850
925
|
const self = globalThis;
|
|
851
|
-
const
|
|
852
|
-
logDebug("ChunkLoader", `Bundle key: "${bundleKey}"`);
|
|
926
|
+
const { globalKey } = scope;
|
|
853
927
|
const transformedCode = code.replace(
|
|
854
928
|
/globalThis\[\s*["']TURBOPACK["']\s*\]/g,
|
|
855
|
-
`globalThis["TURBOPACK_${
|
|
929
|
+
`globalThis["TURBOPACK_${globalKey}"]`
|
|
856
930
|
).replace(
|
|
857
931
|
/self\[\s*["']TURBOPACK["']\s*\]/g,
|
|
858
|
-
`self["TURBOPACK_${
|
|
859
|
-
).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${
|
|
932
|
+
`self["TURBOPACK_${globalKey}"]`
|
|
933
|
+
).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${globalKey}`).replace(/self\.TURBOPACK(?!_)/g, `self.TURBOPACK_${globalKey}`).replace(
|
|
860
934
|
/TURBOPACK_WORKER_LOCATION/g,
|
|
861
|
-
`TURBOPACK_WORKER_LOCATION_${
|
|
935
|
+
`TURBOPACK_WORKER_LOCATION_${globalKey}`
|
|
862
936
|
).replace(
|
|
863
937
|
/TURBOPACK_NEXT_CHUNK_URLS/g,
|
|
864
|
-
`TURBOPACK_NEXT_CHUNK_URLS_${
|
|
938
|
+
`TURBOPACK_NEXT_CHUNK_URLS_${globalKey}`
|
|
865
939
|
).replace(
|
|
866
940
|
/TURBOPACK_CHUNK_UPDATE_LISTENERS/g,
|
|
867
|
-
`TURBOPACK_CHUNK_UPDATE_LISTENERS_${
|
|
868
|
-
).replace(/__next_require__/g, `__${
|
|
941
|
+
`TURBOPACK_CHUNK_UPDATE_LISTENERS_${globalKey}`
|
|
942
|
+
).replace(/__next_require__/g, `__${globalKey}_next_require__`).replace(
|
|
869
943
|
/\/\/# sourceMappingURL=(?<name>.+)(?<optional>\._)?\.js\.map/g,
|
|
870
|
-
`//# sourceMappingURL=${new URL(
|
|
871
|
-
".",
|
|
872
|
-
new URL(
|
|
873
|
-
url,
|
|
874
|
-
self.__remote_bundle_url__?.[bundle] ?? new URL(location.origin)
|
|
875
|
-
)
|
|
876
|
-
).href}$1$2.js.map`
|
|
944
|
+
`//# sourceMappingURL=${new URL(".", new URL(url, scope.url)).href}$1$2.js.map`
|
|
877
945
|
);
|
|
878
|
-
if (!self[`TURBOPACK_${
|
|
946
|
+
if (!self[`TURBOPACK_${globalKey}`]) {
|
|
879
947
|
const chunkData = [];
|
|
880
948
|
const turbopackObject = {
|
|
881
949
|
push: (item) => {
|
|
882
|
-
logDebug(
|
|
883
|
-
"ChunkLoader",
|
|
884
|
-
`TURBOPACK_${bundleKey}.push() called with item type: ${Array.isArray(item) ? "array" : typeof item}`
|
|
885
|
-
);
|
|
886
950
|
if (Array.isArray(item)) {
|
|
887
951
|
chunkData.push(item);
|
|
888
|
-
logDebug(
|
|
889
|
-
"ChunkLoader",
|
|
890
|
-
`TURBOPACK_${bundleKey} now has ${chunkData.length} chunks`
|
|
891
|
-
);
|
|
892
952
|
} else {
|
|
893
953
|
chunkData.push([item]);
|
|
894
954
|
}
|
|
895
955
|
return chunkData.length;
|
|
896
956
|
},
|
|
897
|
-
// Store chunks for later access
|
|
898
957
|
__chunks__: chunkData
|
|
899
958
|
};
|
|
900
|
-
self[`TURBOPACK_${
|
|
959
|
+
self[`TURBOPACK_${globalKey}`] = turbopackObject;
|
|
901
960
|
}
|
|
902
|
-
logDebug("ChunkLoader", `Creating blob script for: "${url}"`);
|
|
903
961
|
await new Promise((scriptResolve, scriptReject) => {
|
|
904
962
|
const blob = new Blob([transformedCode], {
|
|
905
963
|
type: "application/javascript; charset=UTF-8"
|
|
@@ -911,21 +969,6 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
911
969
|
script.async = true;
|
|
912
970
|
script.onload = () => {
|
|
913
971
|
URL.revokeObjectURL(scriptUrl);
|
|
914
|
-
logDebug(
|
|
915
|
-
"ChunkLoader",
|
|
916
|
-
`Script loaded successfully for bundle "${bundle}"`
|
|
917
|
-
);
|
|
918
|
-
const turbopackBundle = self[`TURBOPACK_${bundleKey}`];
|
|
919
|
-
logDebug(
|
|
920
|
-
"ChunkLoader",
|
|
921
|
-
`TURBOPACK_${bundleKey} type: ${typeof turbopackBundle}, isArray: ${Array.isArray(turbopackBundle)}, keys: ${turbopackBundle ? Object.keys(turbopackBundle).slice(0, 10).join(", ") : "none"}`
|
|
922
|
-
);
|
|
923
|
-
if (turbopackBundle && typeof turbopackBundle === "object") {
|
|
924
|
-
logDebug(
|
|
925
|
-
"ChunkLoader",
|
|
926
|
-
`TURBOPACK_${bundleKey} length/size: ${Array.isArray(turbopackBundle) ? turbopackBundle.length : Object.keys(turbopackBundle).length}`
|
|
927
|
-
);
|
|
928
|
-
}
|
|
929
972
|
scriptResolve(void 0);
|
|
930
973
|
script.remove();
|
|
931
974
|
};
|
|
@@ -940,53 +983,199 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
940
983
|
};
|
|
941
984
|
document.head.appendChild(script);
|
|
942
985
|
});
|
|
943
|
-
const chunkLists = self[`TURBOPACK_${
|
|
944
|
-
|
|
945
|
-
"ChunkLoader",
|
|
946
|
-
`Processing chunk lists for bundle "${bundle}": ${chunkLists?.length ?? 0} lists`
|
|
947
|
-
);
|
|
948
|
-
const loadChunkLists = [];
|
|
986
|
+
const chunkLists = self[`TURBOPACK_${globalKey}_CHUNK_LISTS`];
|
|
987
|
+
const loadChunkPromises = [];
|
|
949
988
|
while (chunkLists?.length) {
|
|
950
989
|
const { chunks } = chunkLists.shift() ?? { chunks: [] };
|
|
951
990
|
if (chunks.length > 0) {
|
|
952
|
-
|
|
953
|
-
"
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
const chunkLoadResult = self.__webpack_chunk_load__?.(
|
|
958
|
-
`[${bundle}] ${url.slice(0, url.indexOf("/_next"))}/_next/${id}`
|
|
991
|
+
for (const id of chunks) {
|
|
992
|
+
const baseUrl = url.slice(0, url.indexOf("/_next"));
|
|
993
|
+
const chunkLoadResult = loadChunkWithScope(
|
|
994
|
+
scope,
|
|
995
|
+
formatRemoteId(scope, `${baseUrl}/_next/${id}`)
|
|
959
996
|
);
|
|
960
997
|
if (chunkLoadResult) {
|
|
961
|
-
|
|
998
|
+
loadChunkPromises.push(chunkLoadResult);
|
|
962
999
|
}
|
|
963
|
-
}
|
|
1000
|
+
}
|
|
964
1001
|
}
|
|
965
1002
|
}
|
|
966
|
-
if (
|
|
967
|
-
|
|
968
|
-
"ChunkLoader",
|
|
969
|
-
`Waiting for ${loadChunkLists.length} additional chunks to load`
|
|
970
|
-
);
|
|
971
|
-
await Promise.all(loadChunkLists);
|
|
1003
|
+
if (loadChunkPromises.length > 0) {
|
|
1004
|
+
await Promise.all(loadChunkPromises);
|
|
972
1005
|
}
|
|
973
1006
|
}
|
|
974
1007
|
var init_chunk_loader = __esm({
|
|
975
1008
|
"src/runtime/turbopack/chunk-loader.ts"() {
|
|
976
1009
|
"use strict";
|
|
977
1010
|
init_constants2();
|
|
1011
|
+
init_patterns();
|
|
978
1012
|
init_protected_rc_fallback();
|
|
979
1013
|
init_error();
|
|
980
1014
|
init_logger();
|
|
981
|
-
|
|
1015
|
+
init_patterns2();
|
|
1016
|
+
init_remote_scope();
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
// src/runtime/turbopack/shared-modules.ts
|
|
1021
|
+
function getTurbopackModules(scope) {
|
|
1022
|
+
const self = globalThis;
|
|
1023
|
+
const raw = self[`TURBOPACK_${scope.globalKey}`];
|
|
1024
|
+
if (!raw)
|
|
1025
|
+
return void 0;
|
|
1026
|
+
if (typeof raw === "object" && "__chunks__" in raw) {
|
|
1027
|
+
return raw.__chunks__.flat();
|
|
1028
|
+
}
|
|
1029
|
+
if (Array.isArray(raw)) {
|
|
1030
|
+
return raw.flat();
|
|
1031
|
+
}
|
|
1032
|
+
return Object.entries(raw).flat();
|
|
1033
|
+
}
|
|
1034
|
+
async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}) {
|
|
1035
|
+
const allModules = getTurbopackModules(scope);
|
|
1036
|
+
logDebug(
|
|
1037
|
+
"SharedModules",
|
|
1038
|
+
`initializeSharedModules: scope="${scope.scopedName}", allModules=${allModules ? allModules.length : "null"}, hostShared=[${Object.keys(hostShared).join(", ")}], remoteShared=${JSON.stringify(remoteShared)}`
|
|
1039
|
+
);
|
|
1040
|
+
let sharedModuleInitializer = null;
|
|
1041
|
+
if (allModules) {
|
|
1042
|
+
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
1043
|
+
if (typeof idOrFunc !== "function") {
|
|
1044
|
+
return false;
|
|
1045
|
+
}
|
|
1046
|
+
const funcCode = idOrFunc.toString();
|
|
1047
|
+
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
1048
|
+
});
|
|
1049
|
+
if (sharedModuleInitializerIndex > 0) {
|
|
1050
|
+
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1051
|
+
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1052
|
+
const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
|
|
1053
|
+
if (sharedModuleId) {
|
|
1054
|
+
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1055
|
+
scope,
|
|
1056
|
+
sharedModuleId,
|
|
1057
|
+
formatRemoteId(scope, String(sharedModuleInitializerId))
|
|
1058
|
+
);
|
|
1059
|
+
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
if (sharedModuleInitializer) {
|
|
1063
|
+
const { shared } = await sharedModuleInitializer;
|
|
1064
|
+
const sharedModuleIds = extractSharedModuleIds(shared, scope);
|
|
1065
|
+
logDebug(
|
|
1066
|
+
"SharedModules",
|
|
1067
|
+
`Resolved shared modules for scope="${scope.scopedName}": ${JSON.stringify(sharedModuleIds)}`
|
|
1068
|
+
);
|
|
1069
|
+
return Promise.all(
|
|
1070
|
+
Object.entries(sharedModuleIds).map(async ([id, module2]) => {
|
|
1071
|
+
if (hostShared[module2]) {
|
|
1072
|
+
scope.sharedModules[id] = await hostShared[module2](scope.name);
|
|
1073
|
+
} else {
|
|
1074
|
+
logError(
|
|
1075
|
+
"SharedModules",
|
|
1076
|
+
`Host shared module "${module2}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
})
|
|
1080
|
+
);
|
|
1081
|
+
}
|
|
1082
|
+
logWarn(
|
|
1083
|
+
"SharedModules",
|
|
1084
|
+
`No shared module initializer found in bundle for scope="${scope.scopedName}" \u2014 falling back to remoteShared mapping`
|
|
1085
|
+
);
|
|
1086
|
+
} else {
|
|
1087
|
+
logWarn(
|
|
1088
|
+
"SharedModules",
|
|
1089
|
+
`No TURBOPACK modules found for scope="${scope.scopedName}" (TURBOPACK_${scope.globalKey} is empty)`
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
return Promise.all(
|
|
1093
|
+
Object.entries(remoteShared).map(async ([id, module2]) => {
|
|
1094
|
+
if (hostShared[module2]) {
|
|
1095
|
+
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1096
|
+
scope.sharedModules[normalizedId] = await hostShared[module2](
|
|
1097
|
+
scope.name
|
|
1098
|
+
);
|
|
1099
|
+
} else {
|
|
1100
|
+
logError(
|
|
1101
|
+
"SharedModules",
|
|
1102
|
+
`Shared module "${module2}" not found for "${scope.name}". ${DEDUPLICATION_WARNING}`
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
})
|
|
1106
|
+
);
|
|
1107
|
+
}
|
|
1108
|
+
function extractSharedModuleIds(shared, scope) {
|
|
1109
|
+
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1110
|
+
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1111
|
+
if (asyncSharedModuleId) {
|
|
1112
|
+
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
1113
|
+
let asyncSharedModule;
|
|
1114
|
+
const turbopackModules = getTurbopackModules(scope) ?? [];
|
|
1115
|
+
const asyncSharedModuleIdIndex = turbopackModules.indexOf(
|
|
1116
|
+
asyncSharedModuleIdNumber
|
|
1117
|
+
);
|
|
1118
|
+
if (asyncSharedModuleIdIndex !== -1 && typeof turbopackModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1119
|
+
asyncSharedModule = turbopackModules[asyncSharedModuleIdIndex + 1];
|
|
1120
|
+
}
|
|
1121
|
+
if (asyncSharedModule) {
|
|
1122
|
+
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
1123
|
+
const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
|
|
1124
|
+
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1125
|
+
"__remote_shared_module_",
|
|
1126
|
+
""
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
return acc;
|
|
1131
|
+
}, {});
|
|
1132
|
+
}
|
|
1133
|
+
function getSharedModule(scope, id) {
|
|
1134
|
+
const idStr = String(id);
|
|
1135
|
+
if (scope.sharedModules[idStr] !== void 0) {
|
|
1136
|
+
return scope.sharedModules[idStr];
|
|
1137
|
+
}
|
|
1138
|
+
for (const [key, value] of Object.entries(scope.sharedModules)) {
|
|
1139
|
+
if (typeof value !== "undefined" && idStr !== key && idStr.endsWith(key)) {
|
|
1140
|
+
return value;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
return null;
|
|
1144
|
+
}
|
|
1145
|
+
var DEDUPLICATION_WARNING;
|
|
1146
|
+
var init_shared_modules = __esm({
|
|
1147
|
+
"src/runtime/turbopack/shared-modules.ts"() {
|
|
1148
|
+
"use strict";
|
|
1149
|
+
init_logger();
|
|
1150
|
+
init_module();
|
|
1151
|
+
init_patterns2();
|
|
1152
|
+
init_remote_scope();
|
|
1153
|
+
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).";
|
|
982
1154
|
}
|
|
983
1155
|
});
|
|
984
1156
|
|
|
985
1157
|
// src/runtime/turbopack/module.ts
|
|
986
|
-
function
|
|
1158
|
+
function requireModule(scope, moduleId, fullId) {
|
|
1159
|
+
const idStr = String(moduleId);
|
|
1160
|
+
if (scope.moduleCache[idStr])
|
|
1161
|
+
return scope.moduleCache[idStr];
|
|
1162
|
+
const sharedModule = getSharedModule(scope, moduleId);
|
|
1163
|
+
if (sharedModule) {
|
|
1164
|
+
scope.moduleCache[idStr] = sharedModule;
|
|
1165
|
+
return sharedModule;
|
|
1166
|
+
}
|
|
1167
|
+
return handleTurbopackModule(
|
|
1168
|
+
scope,
|
|
1169
|
+
idStr,
|
|
1170
|
+
fullId ?? formatRemoteId(scope, idStr)
|
|
1171
|
+
);
|
|
1172
|
+
}
|
|
1173
|
+
function handleTurbopackModule(scope, moduleId, id) {
|
|
987
1174
|
const self = globalThis;
|
|
988
|
-
|
|
989
|
-
|
|
1175
|
+
if (scope.moduleCache[moduleId]) {
|
|
1176
|
+
return scope.moduleCache[moduleId];
|
|
1177
|
+
}
|
|
1178
|
+
const raw = self[`TURBOPACK_${scope.globalKey}`];
|
|
990
1179
|
let modules;
|
|
991
1180
|
if (raw && typeof raw === "object" && "__chunks__" in raw) {
|
|
992
1181
|
modules = raw.__chunks__.flat();
|
|
@@ -995,48 +1184,35 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
995
1184
|
} else {
|
|
996
1185
|
modules = raw;
|
|
997
1186
|
}
|
|
998
|
-
if (!self.__remote_components_turbopack_modules__) {
|
|
999
|
-
self.__remote_components_turbopack_modules__ = {};
|
|
1000
|
-
}
|
|
1001
|
-
if (!self.__remote_components_turbopack_modules__[bundle]) {
|
|
1002
|
-
self.__remote_components_turbopack_modules__[bundle] = {};
|
|
1003
|
-
}
|
|
1004
|
-
if (self.__remote_components_turbopack_modules__[bundle][moduleId]) {
|
|
1005
|
-
return self.__remote_components_turbopack_modules__[bundle][moduleId];
|
|
1006
|
-
}
|
|
1007
1187
|
if (!modules) {
|
|
1008
|
-
logError(
|
|
1188
|
+
logError(
|
|
1189
|
+
"TurbopackModule",
|
|
1190
|
+
`TURBOPACK_${scope.globalKey} is undefined (scope: "${scope.scopedName}")`
|
|
1191
|
+
);
|
|
1009
1192
|
}
|
|
1010
1193
|
const moduleInit = findModuleInit(modules, moduleId);
|
|
1011
1194
|
const exports = {};
|
|
1012
1195
|
const moduleExports = { exports };
|
|
1013
1196
|
if (typeof moduleInit !== "function") {
|
|
1014
1197
|
throw new Error(
|
|
1015
|
-
`Module ${id} not found in bundle ${
|
|
1198
|
+
`Module ${id} not found in bundle ${scope.name} with id ${moduleId}`
|
|
1016
1199
|
);
|
|
1017
1200
|
}
|
|
1018
|
-
|
|
1019
|
-
if (!self.__remote_components_turbopack_global__) {
|
|
1020
|
-
self.__remote_components_turbopack_global__ = {};
|
|
1021
|
-
}
|
|
1022
|
-
if (!self.__remote_components_turbopack_global__[bundle]) {
|
|
1023
|
-
self.__remote_components_turbopack_global__[bundle] = {};
|
|
1024
|
-
}
|
|
1201
|
+
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1025
1202
|
moduleInit(
|
|
1026
1203
|
createTurbopackContext(
|
|
1027
|
-
|
|
1204
|
+
scope,
|
|
1028
1205
|
exports,
|
|
1029
1206
|
moduleExports,
|
|
1030
1207
|
modules,
|
|
1031
1208
|
moduleInit,
|
|
1032
|
-
id
|
|
1033
|
-
self
|
|
1209
|
+
id
|
|
1034
1210
|
),
|
|
1035
1211
|
moduleExports,
|
|
1036
1212
|
exports
|
|
1037
1213
|
);
|
|
1038
|
-
if (
|
|
1039
|
-
|
|
1214
|
+
if (scope.moduleCache[moduleId] !== moduleExports.exports) {
|
|
1215
|
+
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1040
1216
|
}
|
|
1041
1217
|
return moduleExports.exports;
|
|
1042
1218
|
}
|
|
@@ -1061,7 +1237,8 @@ function findModuleInit(modules, moduleId) {
|
|
|
1061
1237
|
(e) => Boolean(e && typeof e === "object" && moduleId in e)
|
|
1062
1238
|
)?.[moduleId];
|
|
1063
1239
|
}
|
|
1064
|
-
function createTurbopackContext(
|
|
1240
|
+
function createTurbopackContext(scope, exports, moduleExports, modules, moduleInit, id) {
|
|
1241
|
+
const scopedRequire = (moduleId) => requireModule(scope, moduleId, formatRemoteId(scope, String(moduleId)));
|
|
1065
1242
|
return {
|
|
1066
1243
|
// HMR not implemented for Remote Components
|
|
1067
1244
|
k: {
|
|
@@ -1077,16 +1254,10 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1077
1254
|
s(bindings, esmId) {
|
|
1078
1255
|
let mod = exports;
|
|
1079
1256
|
if (typeof esmId === "string" || typeof esmId === "number") {
|
|
1080
|
-
if (!
|
|
1081
|
-
|
|
1257
|
+
if (!scope.moduleCache[esmId]) {
|
|
1258
|
+
scope.moduleCache[esmId] = {};
|
|
1082
1259
|
}
|
|
1083
|
-
|
|
1084
|
-
self.__remote_components_turbopack_modules__[bundle] = {};
|
|
1085
|
-
}
|
|
1086
|
-
if (!self.__remote_components_turbopack_modules__[bundle][esmId]) {
|
|
1087
|
-
self.__remote_components_turbopack_modules__[bundle][esmId] = {};
|
|
1088
|
-
}
|
|
1089
|
-
mod = self.__remote_components_turbopack_modules__[bundle][esmId];
|
|
1260
|
+
mod = scope.moduleCache[esmId];
|
|
1090
1261
|
}
|
|
1091
1262
|
Object.defineProperty(mod, "__esModule", { value: true });
|
|
1092
1263
|
if (Array.isArray(bindings)) {
|
|
@@ -1119,7 +1290,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1119
1290
|
}
|
|
1120
1291
|
}
|
|
1121
1292
|
},
|
|
1122
|
-
// import
|
|
1293
|
+
// import — resolves directly via scope, no global dispatch
|
|
1123
1294
|
i(importId) {
|
|
1124
1295
|
let mod;
|
|
1125
1296
|
if (typeof importId === "string") {
|
|
@@ -1130,7 +1301,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1130
1301
|
/\s+<export(?<specifier>.*)>$/,
|
|
1131
1302
|
""
|
|
1132
1303
|
);
|
|
1133
|
-
mod =
|
|
1304
|
+
mod = scopedRequire(normalizedId);
|
|
1134
1305
|
if (mod && exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
1135
1306
|
if (exportSource === "*") {
|
|
1136
1307
|
mod[exportName] = mod;
|
|
@@ -1139,7 +1310,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1139
1310
|
}
|
|
1140
1311
|
}
|
|
1141
1312
|
} else {
|
|
1142
|
-
mod =
|
|
1313
|
+
mod = scopedRequire(importId);
|
|
1143
1314
|
}
|
|
1144
1315
|
if (typeof mod !== "object" || mod === null) {
|
|
1145
1316
|
mod = { default: mod };
|
|
@@ -1151,16 +1322,14 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1151
1322
|
}
|
|
1152
1323
|
return mod;
|
|
1153
1324
|
},
|
|
1154
|
-
// require
|
|
1325
|
+
// require — resolves directly via scope
|
|
1155
1326
|
r(requireId) {
|
|
1156
|
-
return
|
|
1327
|
+
return scopedRequire(requireId);
|
|
1157
1328
|
},
|
|
1158
1329
|
// value exports
|
|
1159
1330
|
v(value) {
|
|
1160
1331
|
if (typeof value === "function") {
|
|
1161
|
-
exports.default = value((vid) =>
|
|
1162
|
-
return self.__webpack_require__?.(`[${bundle}] ${vid}`);
|
|
1163
|
-
});
|
|
1332
|
+
exports.default = value((vid) => scopedRequire(vid));
|
|
1164
1333
|
} else {
|
|
1165
1334
|
moduleExports.exports = value;
|
|
1166
1335
|
}
|
|
@@ -1175,17 +1344,15 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1175
1344
|
);
|
|
1176
1345
|
exports.default = result;
|
|
1177
1346
|
},
|
|
1178
|
-
// async module loader
|
|
1347
|
+
// async module loader — resolves directly via scope
|
|
1179
1348
|
async A(Aid) {
|
|
1180
|
-
const mod =
|
|
1181
|
-
return mod.default(
|
|
1182
|
-
(parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
|
|
1183
|
-
);
|
|
1349
|
+
const mod = scopedRequire(Aid);
|
|
1350
|
+
return mod.default((parentId) => scopedRequire(parentId));
|
|
1184
1351
|
},
|
|
1185
1352
|
// dynamic import tracking — no-op for remote components
|
|
1186
1353
|
j() {
|
|
1187
1354
|
},
|
|
1188
|
-
// chunk loader
|
|
1355
|
+
// chunk loader — loads directly via scope, no global dispatch
|
|
1189
1356
|
l(url) {
|
|
1190
1357
|
const flatModules = Array.isArray(modules) ? modules : [];
|
|
1191
1358
|
const moduleInitIndex = flatModules.indexOf(moduleInit);
|
|
@@ -1196,16 +1363,16 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1196
1363
|
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
1197
1364
|
const nextIndex = scriptSrc.indexOf("/_next");
|
|
1198
1365
|
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
1199
|
-
const
|
|
1200
|
-
return
|
|
1366
|
+
const chunkUrl = `${baseUrl}/_next/${url}`;
|
|
1367
|
+
return loadChunkWithScope(scope, formatRemoteId(scope, chunkUrl));
|
|
1201
1368
|
}
|
|
1202
1369
|
}
|
|
1203
1370
|
throw new Error(
|
|
1204
1371
|
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
1205
1372
|
);
|
|
1206
1373
|
},
|
|
1207
|
-
//
|
|
1208
|
-
g:
|
|
1374
|
+
// globalThis substitute shared across all modules in this scope
|
|
1375
|
+
g: scope.moduleGlobal,
|
|
1209
1376
|
m: moduleExports,
|
|
1210
1377
|
e: exports
|
|
1211
1378
|
};
|
|
@@ -1213,173 +1380,61 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1213
1380
|
var init_module = __esm({
|
|
1214
1381
|
"src/runtime/turbopack/module.ts"() {
|
|
1215
1382
|
"use strict";
|
|
1216
|
-
init_constants2();
|
|
1217
|
-
init_logger();
|
|
1218
|
-
}
|
|
1219
|
-
});
|
|
1220
|
-
|
|
1221
|
-
// src/runtime/turbopack/shared-modules.ts
|
|
1222
|
-
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1223
|
-
const self = globalThis;
|
|
1224
|
-
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
1225
|
-
if (!self.__remote_shared_modules__[bundle]) {
|
|
1226
|
-
self.__remote_shared_modules__[bundle] = {};
|
|
1227
|
-
}
|
|
1228
|
-
const bundleKey = getBundleKey(bundle);
|
|
1229
|
-
let modules = self[`TURBOPACK_${bundleKey}`];
|
|
1230
|
-
if (modules && typeof modules === "object" && "__chunks__" in modules) {
|
|
1231
|
-
const chunks = modules.__chunks__;
|
|
1232
|
-
modules = chunks.flat();
|
|
1233
|
-
}
|
|
1234
|
-
let sharedModuleInitializer = null;
|
|
1235
|
-
if (modules) {
|
|
1236
|
-
const allModules = Array.isArray(modules) ? modules.flat() : Object.entries(modules).flat();
|
|
1237
|
-
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
1238
|
-
if (typeof idOrFunc !== "function") {
|
|
1239
|
-
return false;
|
|
1240
|
-
}
|
|
1241
|
-
const funcCode = idOrFunc.toString();
|
|
1242
|
-
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
1243
|
-
});
|
|
1244
|
-
if (sharedModuleInitializerIndex > 0) {
|
|
1245
|
-
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1246
|
-
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1247
|
-
const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
|
|
1248
|
-
if (sharedModuleId) {
|
|
1249
|
-
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1250
|
-
bundle,
|
|
1251
|
-
sharedModuleId,
|
|
1252
|
-
`[${bundle}] ${sharedModuleInitializerId}`
|
|
1253
|
-
);
|
|
1254
|
-
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
if (sharedModuleInitializer) {
|
|
1258
|
-
const { shared } = await sharedModuleInitializer;
|
|
1259
|
-
const sharedModuleIds = extractSharedModuleIds(
|
|
1260
|
-
shared,
|
|
1261
|
-
bundleKey,
|
|
1262
|
-
self
|
|
1263
|
-
);
|
|
1264
|
-
return Promise.all(
|
|
1265
|
-
Object.entries(sharedModuleIds).map(async ([id, module2]) => {
|
|
1266
|
-
if (self.__remote_shared_modules__?.[bundle]) {
|
|
1267
|
-
if (hostShared[module2]) {
|
|
1268
|
-
self.__remote_shared_modules__[bundle][id] = await hostShared[module2](bundle);
|
|
1269
|
-
} else {
|
|
1270
|
-
logError(
|
|
1271
|
-
"SharedModules",
|
|
1272
|
-
`Host shared module "${module2}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1273
|
-
);
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
})
|
|
1277
|
-
);
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
return Promise.all(
|
|
1281
|
-
Object.entries(remoteShared).map(async ([id, module2]) => {
|
|
1282
|
-
if (self.__remote_shared_modules__?.[bundle]) {
|
|
1283
|
-
if (hostShared[module2]) {
|
|
1284
|
-
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1285
|
-
self.__remote_shared_modules__[bundle][normalizedId] = await hostShared[module2](bundle);
|
|
1286
|
-
} else {
|
|
1287
|
-
logError(
|
|
1288
|
-
"SharedModules",
|
|
1289
|
-
`Shared module "${module2}" not found for "${bundle}". ${DEDUPLICATION_WARNING}`
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
})
|
|
1294
|
-
);
|
|
1295
|
-
}
|
|
1296
|
-
function extractSharedModuleIds(shared, bundleKey, self) {
|
|
1297
|
-
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1298
|
-
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1299
|
-
if (asyncSharedModuleId) {
|
|
1300
|
-
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
1301
|
-
let asyncSharedModule;
|
|
1302
|
-
let turbopackModules = self[`TURBOPACK_${bundleKey}`];
|
|
1303
|
-
if (turbopackModules && typeof turbopackModules === "object" && "__chunks__" in turbopackModules) {
|
|
1304
|
-
const chunks = turbopackModules.__chunks__;
|
|
1305
|
-
turbopackModules = chunks.flat();
|
|
1306
|
-
}
|
|
1307
|
-
const newAllModules = Array.isArray(turbopackModules) ? turbopackModules.flat() : turbopackModules ? Object.entries(turbopackModules).flatMap(([key2, value2]) => [
|
|
1308
|
-
key2,
|
|
1309
|
-
value2
|
|
1310
|
-
]) : [];
|
|
1311
|
-
const asyncSharedModuleIdIndex = newAllModules.indexOf(
|
|
1312
|
-
asyncSharedModuleIdNumber
|
|
1313
|
-
);
|
|
1314
|
-
if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1315
|
-
asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
|
|
1316
|
-
}
|
|
1317
|
-
if (asyncSharedModule) {
|
|
1318
|
-
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
1319
|
-
const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
|
|
1320
|
-
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1321
|
-
"__remote_shared_module_",
|
|
1322
|
-
""
|
|
1323
|
-
);
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
return acc;
|
|
1327
|
-
}, {});
|
|
1328
|
-
}
|
|
1329
|
-
function getSharedModule(bundle, id) {
|
|
1330
|
-
const self = globalThis;
|
|
1331
|
-
for (const [key, value] of Object.entries(
|
|
1332
|
-
self.__remote_shared_modules__?.[bundle] ?? {}
|
|
1333
|
-
)) {
|
|
1334
|
-
if (typeof value !== "undefined" && (typeof id === "string" && id.includes(key) || id === key)) {
|
|
1335
|
-
return value;
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
return null;
|
|
1339
|
-
}
|
|
1340
|
-
var DEDUPLICATION_WARNING;
|
|
1341
|
-
var init_shared_modules = __esm({
|
|
1342
|
-
"src/runtime/turbopack/shared-modules.ts"() {
|
|
1343
|
-
"use strict";
|
|
1344
|
-
init_constants2();
|
|
1345
1383
|
init_logger();
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1384
|
+
init_chunk_loader();
|
|
1385
|
+
init_remote_scope();
|
|
1386
|
+
init_shared_modules();
|
|
1349
1387
|
}
|
|
1350
1388
|
});
|
|
1351
1389
|
|
|
1352
1390
|
// src/runtime/turbopack/webpack-runtime.ts
|
|
1353
1391
|
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}, resolveClientUrl) {
|
|
1354
1392
|
const self = globalThis;
|
|
1393
|
+
const bundleName = bundle ?? "default";
|
|
1394
|
+
const scope = createScope(bundleName, url, runtime, resolveClientUrl);
|
|
1395
|
+
registerScope(scope);
|
|
1355
1396
|
if (!self.__remote_bundle_url__) {
|
|
1356
1397
|
self.__remote_bundle_url__ = {};
|
|
1357
1398
|
}
|
|
1358
|
-
self.__remote_bundle_url__[
|
|
1399
|
+
self.__remote_bundle_url__[bundleName] = url;
|
|
1400
|
+
if (scope.scopedName !== bundleName) {
|
|
1401
|
+
self.__remote_bundle_url__[scope.scopedName] = url;
|
|
1402
|
+
}
|
|
1359
1403
|
self.__webpack_get_script_filename__ = () => null;
|
|
1360
|
-
|
|
1404
|
+
const willCreateDispatchers = typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack";
|
|
1405
|
+
if (willCreateDispatchers) {
|
|
1361
1406
|
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
1362
1407
|
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
1363
1408
|
self.__original_webpack_require__ = self.__webpack_require__;
|
|
1364
1409
|
}
|
|
1365
|
-
self.__webpack_chunk_load__ =
|
|
1366
|
-
self.__webpack_require__ =
|
|
1410
|
+
self.__webpack_chunk_load__ = createChunkDispatcher();
|
|
1411
|
+
self.__webpack_require__ = createModuleDispatcher(runtime);
|
|
1367
1412
|
self.__webpack_require_type__ = runtime;
|
|
1368
1413
|
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
1369
|
-
|
|
1370
|
-
self.__remote_webpack_require__[
|
|
1371
|
-
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
1414
|
+
self.__remote_webpack_require__[bundleName] = self.__webpack_require__;
|
|
1415
|
+
self.__remote_webpack_require__[bundleName].type = "turbopack";
|
|
1372
1416
|
}
|
|
1373
1417
|
}
|
|
1418
|
+
if (self.__remote_webpack_require__?.[bundleName] && scope.scopedName !== bundleName) {
|
|
1419
|
+
self.__remote_webpack_require__[scope.scopedName] = self.__remote_webpack_require__[bundleName];
|
|
1420
|
+
}
|
|
1374
1421
|
if (runtime === RUNTIME_TURBOPACK) {
|
|
1375
|
-
await Promise.
|
|
1422
|
+
const results = await Promise.allSettled(
|
|
1376
1423
|
scripts.map((script) => {
|
|
1377
1424
|
if (script.src) {
|
|
1378
|
-
return
|
|
1425
|
+
return loadChunkWithScope(scope, script.src);
|
|
1379
1426
|
}
|
|
1380
1427
|
return Promise.resolve(void 0);
|
|
1381
1428
|
})
|
|
1382
1429
|
);
|
|
1430
|
+
for (const result of results) {
|
|
1431
|
+
if (result.status === "rejected") {
|
|
1432
|
+
logWarn(
|
|
1433
|
+
"WebpackRuntime",
|
|
1434
|
+
`Initial chunk load failed: ${String(result.reason)}`
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1383
1438
|
}
|
|
1384
1439
|
const coreShared = {
|
|
1385
1440
|
react: async () => (await import("react")).default,
|
|
@@ -1389,54 +1444,54 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1389
1444
|
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1390
1445
|
...shared
|
|
1391
1446
|
};
|
|
1392
|
-
await initializeSharedModules(
|
|
1393
|
-
bundle ?? "default",
|
|
1394
|
-
// include all core modules as shared
|
|
1395
|
-
coreShared,
|
|
1396
|
-
remoteShared
|
|
1397
|
-
);
|
|
1447
|
+
await initializeSharedModules(scope, coreShared, remoteShared);
|
|
1398
1448
|
}
|
|
1399
|
-
function
|
|
1449
|
+
function createModuleDispatcher(runtime) {
|
|
1400
1450
|
return (id) => {
|
|
1401
1451
|
const self = globalThis;
|
|
1402
1452
|
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
1403
1453
|
bundle: "default",
|
|
1404
1454
|
id
|
|
1405
1455
|
};
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1456
|
+
const bundleName = bundle ?? "default";
|
|
1457
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundleName] ? self.__remote_webpack_require__[bundleName]?.type || "webpack" : runtime;
|
|
1458
|
+
logDebug(
|
|
1459
|
+
"ModuleDispatcher",
|
|
1460
|
+
`Resolving "${id}" (bundle: "${bundleName}", runtime: "${remoteRuntime}")`
|
|
1461
|
+
);
|
|
1408
1462
|
try {
|
|
1409
1463
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1410
1464
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
1411
1465
|
}
|
|
1412
|
-
const
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
return sharedModule;
|
|
1416
|
-
}
|
|
1417
|
-
if (bundle && moduleId) {
|
|
1418
|
-
return handleTurbopackModule(bundle, moduleId, id);
|
|
1466
|
+
const scope = getScope(bundleName);
|
|
1467
|
+
if (scope) {
|
|
1468
|
+
return requireModule(scope, moduleId ?? id, id);
|
|
1419
1469
|
}
|
|
1420
|
-
throw new Error(
|
|
1470
|
+
throw new Error(
|
|
1471
|
+
`Module "${id}" not found \u2014 no scope for bundle "${bundleName}".`
|
|
1472
|
+
);
|
|
1421
1473
|
} catch (requireError) {
|
|
1422
1474
|
logWarn(
|
|
1423
|
-
"
|
|
1475
|
+
"ModuleDispatcher",
|
|
1424
1476
|
`Module require failed: ${String(requireError)}`
|
|
1425
1477
|
);
|
|
1426
1478
|
if (typeof self.__original_webpack_require__ !== "function") {
|
|
1427
1479
|
throw new RemoteComponentsError(
|
|
1428
|
-
`Module "${id}" not found in remote component bundle "${
|
|
1480
|
+
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1429
1481
|
{
|
|
1430
1482
|
cause: requireError instanceof Error ? requireError : void 0
|
|
1431
1483
|
}
|
|
1432
1484
|
);
|
|
1433
1485
|
}
|
|
1434
1486
|
try {
|
|
1435
|
-
logDebug(
|
|
1487
|
+
logDebug(
|
|
1488
|
+
"ModuleDispatcher",
|
|
1489
|
+
"Falling back to original webpack require"
|
|
1490
|
+
);
|
|
1436
1491
|
return self.__original_webpack_require__(id);
|
|
1437
1492
|
} catch (originalError) {
|
|
1438
1493
|
throw new RemoteComponentsError(
|
|
1439
|
-
`Module "${id}" not found in remote component bundle "${
|
|
1494
|
+
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1440
1495
|
{ cause: originalError instanceof Error ? originalError : void 0 }
|
|
1441
1496
|
);
|
|
1442
1497
|
}
|
|
@@ -1447,10 +1502,12 @@ var init_webpack_runtime = __esm({
|
|
|
1447
1502
|
"src/runtime/turbopack/webpack-runtime.ts"() {
|
|
1448
1503
|
"use strict";
|
|
1449
1504
|
init_constants2();
|
|
1505
|
+
init_patterns();
|
|
1450
1506
|
init_error();
|
|
1451
1507
|
init_logger();
|
|
1452
1508
|
init_chunk_loader();
|
|
1453
1509
|
init_module();
|
|
1510
|
+
init_remote_scope();
|
|
1454
1511
|
init_shared_modules();
|
|
1455
1512
|
}
|
|
1456
1513
|
});
|
|
@@ -1785,6 +1842,9 @@ function resolveNameFromSrc(src, defaultName) {
|
|
|
1785
1842
|
return name || defaultName;
|
|
1786
1843
|
}
|
|
1787
1844
|
|
|
1845
|
+
// src/host/html/index.tsx
|
|
1846
|
+
init_constants2();
|
|
1847
|
+
|
|
1788
1848
|
// src/runtime/html/apply-origin.ts
|
|
1789
1849
|
var tagNames = [
|
|
1790
1850
|
"img",
|
|
@@ -1849,6 +1909,41 @@ function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
|
1849
1909
|
|
|
1850
1910
|
// src/runtime/html/parse-remote-html.ts
|
|
1851
1911
|
init_constants2();
|
|
1912
|
+
|
|
1913
|
+
// src/runtime/metadata.ts
|
|
1914
|
+
init_constants2();
|
|
1915
|
+
var VALID_RUNTIMES = /* @__PURE__ */ new Set(["webpack", "turbopack", "script"]);
|
|
1916
|
+
var VALID_TYPES = /* @__PURE__ */ new Set([
|
|
1917
|
+
"nextjs",
|
|
1918
|
+
"remote-component",
|
|
1919
|
+
"unknown"
|
|
1920
|
+
]);
|
|
1921
|
+
function isRuntime(value) {
|
|
1922
|
+
return VALID_RUNTIMES.has(value);
|
|
1923
|
+
}
|
|
1924
|
+
function isComponentType(value) {
|
|
1925
|
+
return VALID_TYPES.has(value);
|
|
1926
|
+
}
|
|
1927
|
+
function toRuntime(value) {
|
|
1928
|
+
return value && isRuntime(value) ? value : "webpack";
|
|
1929
|
+
}
|
|
1930
|
+
function toComponentType(value) {
|
|
1931
|
+
return value && isComponentType(value) ? value : "unknown";
|
|
1932
|
+
}
|
|
1933
|
+
function buildMetadata(attrs, url) {
|
|
1934
|
+
const id = attrs.id || DEFAULT_COMPONENT_NAME;
|
|
1935
|
+
const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION || DEFAULT_BUNDLE_NAME;
|
|
1936
|
+
return {
|
|
1937
|
+
name: attrs.name || id.replace(/_ssr$/, ""),
|
|
1938
|
+
bundle,
|
|
1939
|
+
route: attrs.route || url.pathname || DEFAULT_ROUTE,
|
|
1940
|
+
runtime: toRuntime(attrs.runtime),
|
|
1941
|
+
id,
|
|
1942
|
+
type: toComponentType(attrs.type)
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
// src/runtime/html/parse-remote-html.ts
|
|
1852
1947
|
init_error();
|
|
1853
1948
|
function validateSingleComponent(doc, name, url) {
|
|
1854
1949
|
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}"]`)) {
|
|
@@ -1868,14 +1963,6 @@ function resolveComponentName(component, nextData, fallbackName) {
|
|
|
1868
1963
|
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
1869
1964
|
return { name, isRemoteComponent };
|
|
1870
1965
|
}
|
|
1871
|
-
function extractComponentMetadata(component, nextData, name, url) {
|
|
1872
|
-
return {
|
|
1873
|
-
name,
|
|
1874
|
-
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
1875
|
-
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
1876
|
-
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
1877
|
-
};
|
|
1878
|
-
}
|
|
1879
1966
|
function extractRemoteShared(doc, name, nextData) {
|
|
1880
1967
|
const remoteSharedEl = doc.querySelector(
|
|
1881
1968
|
`#${name}_shared[data-remote-components-shared]`
|
|
@@ -1887,7 +1974,7 @@ function extractRemoteShared(doc, name, nextData) {
|
|
|
1887
1974
|
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
1888
1975
|
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
1889
1976
|
throw new RemoteComponentsError(
|
|
1890
|
-
`Remote Component not found on ${url}.${name !==
|
|
1977
|
+
`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>?`
|
|
1891
1978
|
);
|
|
1892
1979
|
}
|
|
1893
1980
|
}
|
|
@@ -1913,10 +2000,15 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
1913
2000
|
name
|
|
1914
2001
|
);
|
|
1915
2002
|
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
1916
|
-
const metadata =
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
2003
|
+
const metadata = buildMetadata(
|
|
2004
|
+
{
|
|
2005
|
+
name: resolvedName,
|
|
2006
|
+
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle,
|
|
2007
|
+
route: component?.getAttribute("data-route") ?? nextData?.page,
|
|
2008
|
+
runtime: component?.getAttribute("data-runtime") ?? nextData?.props.__REMOTE_COMPONENT__?.runtime ?? RUNTIME_SCRIPT,
|
|
2009
|
+
id: component?.getAttribute("id"),
|
|
2010
|
+
type: component?.getAttribute("data-type")
|
|
2011
|
+
},
|
|
1920
2012
|
url
|
|
1921
2013
|
);
|
|
1922
2014
|
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
@@ -2132,12 +2224,7 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2132
2224
|
}
|
|
2133
2225
|
if (type === "webpack") {
|
|
2134
2226
|
const { webpackRuntime: webpackRuntime2 } = await Promise.resolve().then(() => (init_webpack(), webpack_exports));
|
|
2135
|
-
return webpackRuntime2(
|
|
2136
|
-
bundle ?? "default",
|
|
2137
|
-
shared,
|
|
2138
|
-
remoteShared,
|
|
2139
|
-
resolveClientUrl
|
|
2140
|
-
);
|
|
2227
|
+
return webpackRuntime2(bundle, shared, remoteShared, resolveClientUrl);
|
|
2141
2228
|
} else if (type === "turbopack") {
|
|
2142
2229
|
const { turbopackRuntime: turbopackRuntime2 } = await Promise.resolve().then(() => (init_turbopack(), turbopack_exports));
|
|
2143
2230
|
return turbopackRuntime2(
|
|
@@ -2160,8 +2247,8 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2160
2247
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2161
2248
|
if (typeof HTMLElement !== "undefined") {
|
|
2162
2249
|
class RemoteComponent extends HTMLElement {
|
|
2163
|
-
name;
|
|
2164
|
-
bundle;
|
|
2250
|
+
name = DEFAULT_COMPONENT_NAME;
|
|
2251
|
+
bundle = DEFAULT_BUNDLE_NAME;
|
|
2165
2252
|
fallbackSlot;
|
|
2166
2253
|
__next = null;
|
|
2167
2254
|
fouc = null;
|
|
@@ -2277,8 +2364,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2277
2364
|
this.fallbackSlot = document.createElement("slot");
|
|
2278
2365
|
this.root.appendChild(this.fallbackSlot);
|
|
2279
2366
|
}
|
|
2280
|
-
this.name = this.getAttribute("name") ||
|
|
2281
|
-
this.bundle = "default";
|
|
2367
|
+
this.name = this.getAttribute("name") || this.name;
|
|
2282
2368
|
this.hostState.stage = "loading";
|
|
2283
2369
|
const src = this.src;
|
|
2284
2370
|
this.hostState.abortController = new AbortController();
|
|
@@ -2298,10 +2384,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2298
2384
|
let html = this.innerHTML;
|
|
2299
2385
|
if (src) {
|
|
2300
2386
|
url = getClientOrServerUrl(src, window.location.href);
|
|
2301
|
-
this.name = resolveNameFromSrc(
|
|
2302
|
-
src,
|
|
2303
|
-
this.name ?? "__vercel_remote_component"
|
|
2304
|
-
);
|
|
2387
|
+
this.name = resolveNameFromSrc(src, this.name);
|
|
2305
2388
|
}
|
|
2306
2389
|
const resolveClientUrl = url ? bindResolveClientUrl(this.resolveClientUrl, url.href) : void 0;
|
|
2307
2390
|
if (!remoteComponentChild && url) {
|
|
@@ -2344,7 +2427,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2344
2427
|
const doc = parser.parseFromString(html, "text/html");
|
|
2345
2428
|
const parsed = parseRemoteComponentDocument(
|
|
2346
2429
|
doc,
|
|
2347
|
-
this.name
|
|
2430
|
+
this.name,
|
|
2348
2431
|
url ?? new URL(window.location.href)
|
|
2349
2432
|
);
|
|
2350
2433
|
const {
|
|
@@ -2368,7 +2451,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2368
2451
|
if (!self2.__remote_bundle_url__) {
|
|
2369
2452
|
self2.__remote_bundle_url__ = {};
|
|
2370
2453
|
}
|
|
2371
|
-
self2.__remote_bundle_url__[this.bundle
|
|
2454
|
+
self2.__remote_bundle_url__[this.bundle] = url;
|
|
2372
2455
|
}
|
|
2373
2456
|
const metadataEl = document.createElement("script");
|
|
2374
2457
|
metadataEl.type = "application/json";
|
|
@@ -2560,12 +2643,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2560
2643
|
window.location.href
|
|
2561
2644
|
);
|
|
2562
2645
|
}
|
|
2563
|
-
await preloadScripts(
|
|
2564
|
-
Array.from(scripts),
|
|
2565
|
-
url,
|
|
2566
|
-
this.bundle ?? "default",
|
|
2567
|
-
this.name ?? "__vercel_remote_component"
|
|
2568
|
-
);
|
|
2646
|
+
await preloadScripts(Array.from(scripts), url, this.bundle, this.name);
|
|
2569
2647
|
if (!isCurrentLoad()) {
|
|
2570
2648
|
return abandonLoad();
|
|
2571
2649
|
}
|
|
@@ -2644,7 +2722,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2644
2722
|
RemoteComponentFromReadableStream,
|
|
2645
2723
|
{
|
|
2646
2724
|
initial: false,
|
|
2647
|
-
name: this.name
|
|
2725
|
+
name: this.name
|
|
2648
2726
|
}
|
|
2649
2727
|
)
|
|
2650
2728
|
);
|
|
@@ -2655,17 +2733,11 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2655
2733
|
// hydrateRoot expects a document or element, but it works for the shadow DOM too
|
|
2656
2734
|
// @ts-expect-error support for shadow DOM
|
|
2657
2735
|
this.root,
|
|
2658
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2659
|
-
RemoteComponentFromReadableStream,
|
|
2660
|
-
{
|
|
2661
|
-
initial: true,
|
|
2662
|
-
name: this.name ?? "__vercel_remote_component"
|
|
2663
|
-
}
|
|
2664
|
-
)
|
|
2736
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RemoteComponentFromReadableStream, { initial: true, name: this.name })
|
|
2665
2737
|
);
|
|
2666
2738
|
} else if (nextData) {
|
|
2667
2739
|
const { Component, App } = nextClientPagesLoader2(
|
|
2668
|
-
this.bundle
|
|
2740
|
+
this.bundle,
|
|
2669
2741
|
nextData.page ?? "/",
|
|
2670
2742
|
this.root
|
|
2671
2743
|
);
|