remote-components 0.3.4 → 0.3.5
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/host/html.cjs +471 -413
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +471 -413
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +245 -131
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +245 -131
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/nextjs/app.cjs +34 -2
- package/dist/host/nextjs/app.cjs.map +1 -1
- package/dist/host/nextjs/app.js +35 -3
- package/dist/host/nextjs/app.js.map +1 -1
- package/dist/host/react.cjs +245 -131
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +245 -131
- package/dist/host/react.js.map +1 -1
- package/dist/internal/host/nextjs/app-client.cjs +38 -24
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/host/nextjs/app-client.js +38 -24
- package/dist/internal/host/nextjs/app-client.js.map +1 -1
- package/dist/internal/host/nextjs/remote-component-links.cjs +24 -13
- package/dist/internal/host/nextjs/remote-component-links.cjs.map +1 -1
- package/dist/internal/host/nextjs/remote-component-links.d.ts +3 -0
- package/dist/internal/host/nextjs/remote-component-links.js +24 -13
- package/dist/internal/host/nextjs/remote-component-links.js.map +1 -1
- package/dist/internal/host/shared/lifecycle.cjs +69 -0
- package/dist/internal/host/shared/lifecycle.cjs.map +1 -0
- package/dist/internal/host/shared/lifecycle.d.ts +34 -0
- package/dist/internal/host/shared/lifecycle.js +44 -0
- package/dist/internal/host/shared/lifecycle.js.map +1 -0
- package/dist/internal/host/shared/pipeline.cjs +222 -0
- package/dist/internal/host/shared/pipeline.cjs.map +1 -0
- package/dist/internal/host/shared/pipeline.d.ts +153 -0
- package/dist/internal/host/shared/pipeline.js +200 -0
- package/dist/internal/host/shared/pipeline.js.map +1 -0
- package/dist/internal/runtime/turbopack/patterns.cjs +1 -1
- package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.js +1 -1
- package/dist/internal/runtime/turbopack/patterns.js.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope-setup.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope-setup.js.map +1 -1
- package/package.json +2 -2
package/dist/host/html.cjs
CHANGED
|
@@ -386,194 +386,6 @@ var init_remote_scope = __esm({
|
|
|
386
386
|
}
|
|
387
387
|
});
|
|
388
388
|
|
|
389
|
-
// src/config/webpack/apply-shared-modules.ts
|
|
390
|
-
function applySharedModules(bundle, resolve) {
|
|
391
|
-
logDebug(
|
|
392
|
-
"SharedModules",
|
|
393
|
-
`applySharedModules called for bundle: "${bundle}"`
|
|
394
|
-
);
|
|
395
|
-
logDebug(
|
|
396
|
-
"SharedModules",
|
|
397
|
-
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
398
|
-
);
|
|
399
|
-
const self = globalThis;
|
|
400
|
-
const scope = getScope(bundle);
|
|
401
|
-
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
402
|
-
if (webpackBundle) {
|
|
403
|
-
const modulePaths = Object.keys(
|
|
404
|
-
self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {}
|
|
405
|
-
);
|
|
406
|
-
logDebug(
|
|
407
|
-
"SharedModules",
|
|
408
|
-
`Available module paths for bundle "${bundle}": ${modulePaths}`
|
|
409
|
-
);
|
|
410
|
-
for (const [key, value] of Object.entries(resolve)) {
|
|
411
|
-
const exactIds = modulePaths.filter((p) => p === key);
|
|
412
|
-
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
413
|
-
if (ids.length === 0) {
|
|
414
|
-
logDebug(
|
|
415
|
-
"SharedModules",
|
|
416
|
-
`No matching module path found for shared module "${key}"`
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
for (const id of ids) {
|
|
420
|
-
if (webpackBundle.m) {
|
|
421
|
-
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
422
|
-
if (resolvedId !== id) {
|
|
423
|
-
logDebug(
|
|
424
|
-
"SharedModules",
|
|
425
|
-
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
webpackBundle.m[resolvedId] = (module2) => {
|
|
429
|
-
module2.exports = value;
|
|
430
|
-
};
|
|
431
|
-
} else {
|
|
432
|
-
logWarn(
|
|
433
|
-
"SharedModules",
|
|
434
|
-
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
} else {
|
|
440
|
-
logWarn(
|
|
441
|
-
"SharedModules",
|
|
442
|
-
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
443
|
-
);
|
|
444
|
-
logDebug(
|
|
445
|
-
"SharedModules",
|
|
446
|
-
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
var DEDUPLICATION_SKIPPED;
|
|
451
|
-
var init_apply_shared_modules = __esm({
|
|
452
|
-
"src/config/webpack/apply-shared-modules.ts"() {
|
|
453
|
-
"use strict";
|
|
454
|
-
init_remote_scope();
|
|
455
|
-
init_logger();
|
|
456
|
-
DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
// src/config/webpack/next-client-pages-loader.ts
|
|
461
|
-
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
462
|
-
const self = globalThis;
|
|
463
|
-
const nextCssOriginal = document.querySelector(
|
|
464
|
-
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
465
|
-
);
|
|
466
|
-
if (nextCssOriginal) {
|
|
467
|
-
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
468
|
-
}
|
|
469
|
-
const nextCss = document.createElement("noscript");
|
|
470
|
-
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
471
|
-
nextCss.setAttribute("data-bundle", bundle);
|
|
472
|
-
nextCss.setAttribute("data-route", route);
|
|
473
|
-
const nextCssEnd = document.createElement("noscript");
|
|
474
|
-
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
475
|
-
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
476
|
-
nextCssEnd.setAttribute("data-route", route);
|
|
477
|
-
document.head.appendChild(nextCssEnd);
|
|
478
|
-
document.head.appendChild(nextCss);
|
|
479
|
-
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
480
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
481
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
482
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
483
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
484
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
485
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
486
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
487
|
-
) ?? ""] ?? -1;
|
|
488
|
-
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
489
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
490
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
491
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
492
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
493
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
494
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
495
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
496
|
-
) ?? ""] ?? -1;
|
|
497
|
-
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
498
|
-
throw new RemoteComponentsError(
|
|
499
|
-
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
500
|
-
);
|
|
501
|
-
}
|
|
502
|
-
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
503
|
-
const selfOriginal = self;
|
|
504
|
-
delete selfOriginal.__NEXT_P;
|
|
505
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
506
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
507
|
-
);
|
|
508
|
-
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
509
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
510
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
if (self.__NEXT_P) {
|
|
514
|
-
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
515
|
-
void 0,
|
|
516
|
-
() => ({ default: null })
|
|
517
|
-
];
|
|
518
|
-
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
519
|
-
void 0,
|
|
520
|
-
() => ({
|
|
521
|
-
default: null
|
|
522
|
-
})
|
|
523
|
-
];
|
|
524
|
-
const { default: Component } = componentLoader();
|
|
525
|
-
const { default: App } = appLoader();
|
|
526
|
-
const cssCache = getNamespace().cssCache;
|
|
527
|
-
if (!cssCache[bundle]) {
|
|
528
|
-
const cssRE = /\.s?css$/;
|
|
529
|
-
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
530
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
531
|
-
});
|
|
532
|
-
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
533
|
-
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
534
|
-
if (id) {
|
|
535
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
const elements = [];
|
|
539
|
-
let node = nextCss.previousSibling;
|
|
540
|
-
while (node && node !== nextCssEnd) {
|
|
541
|
-
elements.push(node);
|
|
542
|
-
node.remove();
|
|
543
|
-
node = nextCss.previousSibling;
|
|
544
|
-
}
|
|
545
|
-
cssCache[bundle] = elements;
|
|
546
|
-
}
|
|
547
|
-
if (styleContainer) {
|
|
548
|
-
const elements = cssCache[bundle];
|
|
549
|
-
elements.forEach((el) => {
|
|
550
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
551
|
-
});
|
|
552
|
-
} else {
|
|
553
|
-
const elements = cssCache[bundle];
|
|
554
|
-
elements.forEach((el) => {
|
|
555
|
-
document.head.appendChild(el);
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
delete self.__NEXT_P;
|
|
559
|
-
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
560
|
-
if (nextCssOriginal) {
|
|
561
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
562
|
-
}
|
|
563
|
-
nextCss.remove();
|
|
564
|
-
nextCssEnd.remove();
|
|
565
|
-
return { Component, App };
|
|
566
|
-
}
|
|
567
|
-
return { Component: null, App: null };
|
|
568
|
-
}
|
|
569
|
-
var init_next_client_pages_loader = __esm({
|
|
570
|
-
"src/config/webpack/next-client-pages-loader.ts"() {
|
|
571
|
-
"use strict";
|
|
572
|
-
init_namespace();
|
|
573
|
-
init_error();
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
|
|
577
389
|
// src/host/shared/remote-image-loader.ts
|
|
578
390
|
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
579
391
|
const loader = Object.assign(
|
|
@@ -825,137 +637,190 @@ var init_shared_module_resolver = __esm({
|
|
|
825
637
|
}
|
|
826
638
|
});
|
|
827
639
|
|
|
828
|
-
// src/
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
640
|
+
// src/config/webpack/apply-shared-modules.ts
|
|
641
|
+
function applySharedModules(bundle, resolve) {
|
|
642
|
+
logDebug(
|
|
643
|
+
"SharedModules",
|
|
644
|
+
`applySharedModules called for bundle: "${bundle}"`
|
|
645
|
+
);
|
|
646
|
+
logDebug(
|
|
647
|
+
"SharedModules",
|
|
648
|
+
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
649
|
+
);
|
|
650
|
+
const self = globalThis;
|
|
651
|
+
const scope = getScope(bundle);
|
|
652
|
+
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
653
|
+
if (webpackBundle) {
|
|
654
|
+
const modulePaths = Object.keys(
|
|
655
|
+
self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {}
|
|
656
|
+
);
|
|
657
|
+
logDebug(
|
|
658
|
+
"SharedModules",
|
|
659
|
+
`Available module paths for bundle "${bundle}": ${modulePaths}`
|
|
660
|
+
);
|
|
661
|
+
for (const [key, value] of Object.entries(resolve)) {
|
|
662
|
+
const exactIds = modulePaths.filter((p) => p === key);
|
|
663
|
+
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
664
|
+
if (ids.length === 0) {
|
|
665
|
+
logDebug(
|
|
666
|
+
"SharedModules",
|
|
667
|
+
`No matching module path found for shared module "${key}"`
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
for (const id of ids) {
|
|
671
|
+
if (webpackBundle.m) {
|
|
672
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
673
|
+
if (resolvedId !== id) {
|
|
674
|
+
logDebug(
|
|
675
|
+
"SharedModules",
|
|
676
|
+
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
858
677
|
);
|
|
859
678
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
679
|
+
webpackBundle.m[resolvedId] = (module2) => {
|
|
680
|
+
module2.exports = value;
|
|
681
|
+
};
|
|
682
|
+
} else {
|
|
683
|
+
logWarn(
|
|
684
|
+
"SharedModules",
|
|
685
|
+
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
} else {
|
|
691
|
+
logWarn(
|
|
692
|
+
"SharedModules",
|
|
693
|
+
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
694
|
+
);
|
|
695
|
+
logDebug(
|
|
696
|
+
"SharedModules",
|
|
697
|
+
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
698
|
+
);
|
|
699
|
+
}
|
|
867
700
|
}
|
|
868
|
-
var
|
|
869
|
-
|
|
701
|
+
var DEDUPLICATION_SKIPPED;
|
|
702
|
+
var init_apply_shared_modules = __esm({
|
|
703
|
+
"src/config/webpack/apply-shared-modules.ts"() {
|
|
870
704
|
"use strict";
|
|
871
|
-
|
|
872
|
-
init_protected_rc_fallback();
|
|
873
|
-
init_error();
|
|
705
|
+
init_remote_scope();
|
|
874
706
|
init_logger();
|
|
707
|
+
DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
875
708
|
}
|
|
876
709
|
});
|
|
877
710
|
|
|
878
|
-
// src/
|
|
879
|
-
|
|
880
|
-
__export(webpack_exports, {
|
|
881
|
-
webpackRuntime: () => webpackRuntime
|
|
882
|
-
});
|
|
883
|
-
async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
711
|
+
// src/config/webpack/next-client-pages-loader.ts
|
|
712
|
+
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
884
713
|
const self = globalThis;
|
|
885
|
-
|
|
886
|
-
|
|
714
|
+
const nextCssOriginal = document.querySelector(
|
|
715
|
+
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
716
|
+
);
|
|
717
|
+
if (nextCssOriginal) {
|
|
718
|
+
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
887
719
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
720
|
+
const nextCss = document.createElement("noscript");
|
|
721
|
+
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
722
|
+
nextCss.setAttribute("data-bundle", bundle);
|
|
723
|
+
nextCss.setAttribute("data-route", route);
|
|
724
|
+
const nextCssEnd = document.createElement("noscript");
|
|
725
|
+
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
726
|
+
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
727
|
+
nextCssEnd.setAttribute("data-route", route);
|
|
728
|
+
document.head.appendChild(nextCssEnd);
|
|
729
|
+
document.head.appendChild(nextCss);
|
|
730
|
+
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
731
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
732
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
733
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
734
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
735
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
736
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
737
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
738
|
+
) ?? ""] ?? -1;
|
|
739
|
+
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
740
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
741
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
742
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
743
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
744
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
745
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
746
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
747
|
+
) ?? ""] ?? -1;
|
|
748
|
+
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
749
|
+
throw new RemoteComponentsError(
|
|
750
|
+
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
751
|
+
);
|
|
910
752
|
}
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
return [
|
|
921
|
-
{
|
|
922
|
-
src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
923
|
-
}
|
|
924
|
-
];
|
|
925
|
-
});
|
|
926
|
-
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
927
|
-
const hostShared = buildHostShared(shared, resolveClientUrl);
|
|
928
|
-
const resolve = await buildWebpackResolve(
|
|
929
|
-
hostShared,
|
|
930
|
-
remoteShared ?? {},
|
|
931
|
-
remoteBundle,
|
|
932
|
-
{
|
|
933
|
-
"/react/index.js": (await import("react")).default,
|
|
934
|
-
"/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
|
|
935
|
-
"/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
|
|
936
|
-
"/react-dom/index.js": (await import("react-dom")).default,
|
|
937
|
-
"/react-dom/client.js": (await import("react-dom/client")).default
|
|
938
|
-
},
|
|
939
|
-
"WebpackRuntime"
|
|
753
|
+
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
754
|
+
const selfOriginal = self;
|
|
755
|
+
delete selfOriginal.__NEXT_P;
|
|
756
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
757
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
758
|
+
);
|
|
759
|
+
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
760
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
761
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
940
762
|
);
|
|
941
|
-
applySharedModules(remoteBundle, resolve);
|
|
942
763
|
}
|
|
943
|
-
|
|
944
|
-
self
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
764
|
+
if (self.__NEXT_P) {
|
|
765
|
+
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
766
|
+
void 0,
|
|
767
|
+
() => ({ default: null })
|
|
768
|
+
];
|
|
769
|
+
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
770
|
+
void 0,
|
|
771
|
+
() => ({
|
|
772
|
+
default: null
|
|
773
|
+
})
|
|
774
|
+
];
|
|
775
|
+
const { default: Component } = componentLoader();
|
|
776
|
+
const { default: App } = appLoader();
|
|
777
|
+
const cssCache = getNamespace().cssCache;
|
|
778
|
+
if (!cssCache[bundle]) {
|
|
779
|
+
const cssRE = /\.s?css$/;
|
|
780
|
+
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
781
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
782
|
+
});
|
|
783
|
+
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
784
|
+
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
785
|
+
if (id) {
|
|
786
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
const elements = [];
|
|
790
|
+
let node = nextCss.previousSibling;
|
|
791
|
+
while (node && node !== nextCssEnd) {
|
|
792
|
+
elements.push(node);
|
|
793
|
+
node.remove();
|
|
794
|
+
node = nextCss.previousSibling;
|
|
795
|
+
}
|
|
796
|
+
cssCache[bundle] = elements;
|
|
797
|
+
}
|
|
798
|
+
if (styleContainer) {
|
|
799
|
+
const elements = cssCache[bundle];
|
|
800
|
+
elements.forEach((el) => {
|
|
801
|
+
styleContainer.appendChild(el.cloneNode(true));
|
|
802
|
+
});
|
|
803
|
+
} else {
|
|
804
|
+
const elements = cssCache[bundle];
|
|
805
|
+
elements.forEach((el) => {
|
|
806
|
+
document.head.appendChild(el);
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
delete self.__NEXT_P;
|
|
810
|
+
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
811
|
+
if (nextCssOriginal) {
|
|
812
|
+
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
813
|
+
}
|
|
814
|
+
nextCss.remove();
|
|
815
|
+
nextCssEnd.remove();
|
|
816
|
+
return { Component, App };
|
|
817
|
+
}
|
|
818
|
+
return { Component: null, App: null };
|
|
950
819
|
}
|
|
951
|
-
var
|
|
952
|
-
"src/
|
|
820
|
+
var init_next_client_pages_loader = __esm({
|
|
821
|
+
"src/config/webpack/next-client-pages-loader.ts"() {
|
|
953
822
|
"use strict";
|
|
954
|
-
|
|
955
|
-
init_next_client_pages_loader();
|
|
956
|
-
init_shared_module_resolver();
|
|
957
|
-
init_script_loader();
|
|
958
|
-
init_patterns();
|
|
823
|
+
init_namespace();
|
|
959
824
|
init_error();
|
|
960
825
|
}
|
|
961
826
|
});
|
|
@@ -981,7 +846,7 @@ var init_patterns2 = __esm({
|
|
|
981
846
|
`\\.TURBOPACK_REMOTE_SHARED\\s*=\\s*await (?:__turbopack_context__|[a-z])\\.A\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
982
847
|
);
|
|
983
848
|
ASYNC_MODULE_LOADER_RE = new RegExp(
|
|
984
|
-
`(?:__turbopack_context__|
|
|
849
|
+
`(?:__turbopack_context__|[a-z])\\.A\\((?<asyncSharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
985
850
|
);
|
|
986
851
|
ASYNC_MODULE_CALLBACK_RE = new RegExp(
|
|
987
852
|
`(?:parentImport|[a-z])\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
@@ -1689,52 +1554,53 @@ var init_remote_scope_setup = __esm({
|
|
|
1689
1554
|
}
|
|
1690
1555
|
});
|
|
1691
1556
|
|
|
1692
|
-
// src/
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1557
|
+
// src/runtime/loaders/script-loader.ts
|
|
1558
|
+
async function loadScripts(scripts, resolveClientUrl) {
|
|
1559
|
+
await Promise.all(
|
|
1560
|
+
scripts.map((script) => {
|
|
1561
|
+
return new Promise((resolve, reject) => {
|
|
1562
|
+
const newSrc = new URL(
|
|
1563
|
+
// remove the remote component bundle name identifier from the script src
|
|
1564
|
+
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
1565
|
+
location.origin
|
|
1566
|
+
).href;
|
|
1567
|
+
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
1568
|
+
const alreadyLoaded = Array.from(
|
|
1569
|
+
document.querySelectorAll("script[src]")
|
|
1570
|
+
).some((s) => s.src === resolvedSrc);
|
|
1571
|
+
if (alreadyLoaded) {
|
|
1572
|
+
resolve();
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
const newScript = document.createElement("script");
|
|
1576
|
+
newScript.onload = () => resolve();
|
|
1577
|
+
newScript.onerror = () => {
|
|
1578
|
+
const isProxied = isProxiedUrl(resolvedSrc);
|
|
1579
|
+
if (isProxied) {
|
|
1580
|
+
reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
|
|
1581
|
+
} else {
|
|
1582
|
+
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
1583
|
+
reject(
|
|
1584
|
+
new RemoteComponentsError(
|
|
1585
|
+
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
1586
|
+
)
|
|
1587
|
+
);
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1590
|
+
newScript.src = resolvedSrc;
|
|
1591
|
+
newScript.async = true;
|
|
1592
|
+
document.head.appendChild(newScript);
|
|
1593
|
+
});
|
|
1594
|
+
})
|
|
1595
|
+
);
|
|
1729
1596
|
}
|
|
1730
|
-
var
|
|
1731
|
-
"src/
|
|
1597
|
+
var init_script_loader = __esm({
|
|
1598
|
+
"src/runtime/loaders/script-loader.ts"() {
|
|
1732
1599
|
"use strict";
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
init_shared_modules();
|
|
1600
|
+
init_patterns();
|
|
1601
|
+
init_protected_rc_fallback();
|
|
1602
|
+
init_error();
|
|
1603
|
+
init_logger();
|
|
1738
1604
|
}
|
|
1739
1605
|
});
|
|
1740
1606
|
|
|
@@ -1888,6 +1754,140 @@ var init_static_loader = __esm({
|
|
|
1888
1754
|
}
|
|
1889
1755
|
});
|
|
1890
1756
|
|
|
1757
|
+
// src/host/html/runtime/webpack.ts
|
|
1758
|
+
var webpack_exports = {};
|
|
1759
|
+
__export(webpack_exports, {
|
|
1760
|
+
webpackRuntime: () => webpackRuntime
|
|
1761
|
+
});
|
|
1762
|
+
async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
1763
|
+
const self = globalThis;
|
|
1764
|
+
if (!self.__DISABLE_WEBPACK_EXEC__) {
|
|
1765
|
+
self.__DISABLE_WEBPACK_EXEC__ = {};
|
|
1766
|
+
}
|
|
1767
|
+
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
1768
|
+
if (typeof self.__webpack_require__ !== "function" && self.__webpack_require_type__ !== "turbopack") {
|
|
1769
|
+
self.__webpack_require__ = (remoteId) => {
|
|
1770
|
+
const re = /\[(?<bundle>[^\]]+)\] (?<id>.*)/;
|
|
1771
|
+
const match = re.exec(remoteId);
|
|
1772
|
+
const remoteBundle = match?.groups?.bundle;
|
|
1773
|
+
const id = match?.groups?.id;
|
|
1774
|
+
if (!(id && remoteBundle)) {
|
|
1775
|
+
throw new RemoteComponentsError(
|
|
1776
|
+
`Remote Component module "${remoteId}" not found. Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
1777
|
+
);
|
|
1778
|
+
}
|
|
1779
|
+
if (typeof self.__remote_webpack_require__?.[remoteBundle] !== "function") {
|
|
1780
|
+
throw new RemoteComponentsError(
|
|
1781
|
+
`Remote Components are not available in "${remoteBundle}". Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
1782
|
+
);
|
|
1783
|
+
}
|
|
1784
|
+
return self.__remote_webpack_require__[remoteBundle](id);
|
|
1785
|
+
};
|
|
1786
|
+
self.__webpack_chunk_load__ = () => {
|
|
1787
|
+
return Promise.resolve([]);
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
const {
|
|
1791
|
+
default: { createFromReadableStream }
|
|
1792
|
+
} = await import("react-server-dom-webpack/client.browser");
|
|
1793
|
+
async function preloadScripts(scripts, url, remoteBundle, _) {
|
|
1794
|
+
const scriptSrcs = scripts.flatMap((script) => {
|
|
1795
|
+
const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
|
|
1796
|
+
script.parentElement?.removeChild(script);
|
|
1797
|
+
if (!scriptSrc)
|
|
1798
|
+
return [];
|
|
1799
|
+
return [
|
|
1800
|
+
{
|
|
1801
|
+
src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
1802
|
+
}
|
|
1803
|
+
];
|
|
1804
|
+
});
|
|
1805
|
+
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
1806
|
+
const hostShared = buildHostShared(shared, resolveClientUrl);
|
|
1807
|
+
const resolve = await buildWebpackResolve(
|
|
1808
|
+
hostShared,
|
|
1809
|
+
remoteShared ?? {},
|
|
1810
|
+
remoteBundle,
|
|
1811
|
+
{
|
|
1812
|
+
"/react/index.js": (await import("react")).default,
|
|
1813
|
+
"/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
|
|
1814
|
+
"/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
|
|
1815
|
+
"/react-dom/index.js": (await import("react-dom")).default,
|
|
1816
|
+
"/react-dom/client.js": (await import("react-dom/client")).default
|
|
1817
|
+
},
|
|
1818
|
+
"WebpackRuntime"
|
|
1819
|
+
);
|
|
1820
|
+
applySharedModules(remoteBundle, resolve);
|
|
1821
|
+
}
|
|
1822
|
+
return {
|
|
1823
|
+
self,
|
|
1824
|
+
createFromReadableStream,
|
|
1825
|
+
applySharedModules,
|
|
1826
|
+
nextClientPagesLoader,
|
|
1827
|
+
preloadScripts
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
var init_webpack = __esm({
|
|
1831
|
+
"src/host/html/runtime/webpack.ts"() {
|
|
1832
|
+
"use strict";
|
|
1833
|
+
init_apply_shared_modules();
|
|
1834
|
+
init_next_client_pages_loader();
|
|
1835
|
+
init_shared_module_resolver();
|
|
1836
|
+
init_script_loader();
|
|
1837
|
+
init_patterns();
|
|
1838
|
+
init_error();
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
|
|
1842
|
+
// src/host/html/runtime/turbopack.ts
|
|
1843
|
+
var turbopack_exports = {};
|
|
1844
|
+
__export(turbopack_exports, {
|
|
1845
|
+
turbopackRuntime: () => turbopackRuntime
|
|
1846
|
+
});
|
|
1847
|
+
async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
1848
|
+
const self = globalThis;
|
|
1849
|
+
const hostShared = buildHostShared(shared, resolveClientUrl, {
|
|
1850
|
+
includeRemoteComponentShared: true
|
|
1851
|
+
});
|
|
1852
|
+
await setupRemoteScope("turbopack", [], url, bundle, resolveClientUrl);
|
|
1853
|
+
const {
|
|
1854
|
+
default: { createFromReadableStream }
|
|
1855
|
+
} = await import("react-server-dom-webpack/client.browser");
|
|
1856
|
+
async function preloadScripts(scripts, __) {
|
|
1857
|
+
const scope = await setupRemoteScope(
|
|
1858
|
+
"turbopack",
|
|
1859
|
+
scripts.map((script) => ({
|
|
1860
|
+
src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
|
|
1861
|
+
})),
|
|
1862
|
+
url,
|
|
1863
|
+
bundle,
|
|
1864
|
+
resolveClientUrl
|
|
1865
|
+
);
|
|
1866
|
+
await initializeSharedModules(
|
|
1867
|
+
scope,
|
|
1868
|
+
buildCoreShared(hostShared),
|
|
1869
|
+
remoteShared ?? {}
|
|
1870
|
+
);
|
|
1871
|
+
}
|
|
1872
|
+
return {
|
|
1873
|
+
self,
|
|
1874
|
+
createFromReadableStream,
|
|
1875
|
+
applySharedModules,
|
|
1876
|
+
nextClientPagesLoader,
|
|
1877
|
+
preloadScripts
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
var init_turbopack = __esm({
|
|
1881
|
+
"src/host/html/runtime/turbopack.ts"() {
|
|
1882
|
+
"use strict";
|
|
1883
|
+
init_apply_shared_modules();
|
|
1884
|
+
init_next_client_pages_loader();
|
|
1885
|
+
init_shared_module_resolver();
|
|
1886
|
+
init_remote_scope_setup();
|
|
1887
|
+
init_shared_modules();
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
|
|
1891
1891
|
// src/host/html/runtime/script.ts
|
|
1892
1892
|
var script_exports = {};
|
|
1893
1893
|
__export(script_exports, {
|
|
@@ -1980,34 +1980,33 @@ function getClientOrServerUrl(src, serverFallback) {
|
|
|
1980
1980
|
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1981
1981
|
}
|
|
1982
1982
|
|
|
1983
|
-
// src/host/shared/
|
|
1984
|
-
function
|
|
1983
|
+
// src/host/shared/lifecycle.ts
|
|
1984
|
+
function makeEventEmitter(element) {
|
|
1985
|
+
function dispatch(type, detail) {
|
|
1986
|
+
const event = new Event(type, { bubbles: true, composed: true });
|
|
1987
|
+
if (detail) {
|
|
1988
|
+
Object.assign(event, detail);
|
|
1989
|
+
}
|
|
1990
|
+
element.dispatchEvent(event);
|
|
1991
|
+
}
|
|
1985
1992
|
return {
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1993
|
+
beforeLoad(src) {
|
|
1994
|
+
dispatch("beforeload", { src });
|
|
1995
|
+
},
|
|
1996
|
+
load(src) {
|
|
1997
|
+
dispatch("load", { src });
|
|
1998
|
+
},
|
|
1999
|
+
error(error, src) {
|
|
2000
|
+
dispatch("error", src != null ? { error, src } : { error });
|
|
2001
|
+
},
|
|
2002
|
+
change(info) {
|
|
2003
|
+
dispatch("change", info);
|
|
2004
|
+
}
|
|
1992
2005
|
};
|
|
1993
2006
|
}
|
|
1994
2007
|
|
|
1995
|
-
// src/host/
|
|
1996
|
-
|
|
1997
|
-
if (!src) {
|
|
1998
|
-
return defaultName;
|
|
1999
|
-
}
|
|
2000
|
-
const hash = typeof src === "string" ? src : src.hash;
|
|
2001
|
-
const hashIndex = hash.indexOf("#");
|
|
2002
|
-
if (hashIndex < 0) {
|
|
2003
|
-
return defaultName;
|
|
2004
|
-
}
|
|
2005
|
-
const name = hash.slice(hashIndex + 1);
|
|
2006
|
-
return name || defaultName;
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
// src/host/html/index.tsx
|
|
2010
|
-
init_constants2();
|
|
2008
|
+
// src/host/shared/pipeline.ts
|
|
2009
|
+
init_shared_module_resolver();
|
|
2011
2010
|
|
|
2012
2011
|
// src/runtime/html/html-spec.ts
|
|
2013
2012
|
var ORIGIN_REWRITE_TAGS = [
|
|
@@ -2216,8 +2215,15 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
2216
2215
|
};
|
|
2217
2216
|
}
|
|
2218
2217
|
|
|
2219
|
-
// src/
|
|
2220
|
-
|
|
2218
|
+
// src/runtime/loaders/component-loader.ts
|
|
2219
|
+
var React = __toESM(require("react"), 1);
|
|
2220
|
+
var JSXDevRuntime = __toESM(require("react/jsx-dev-runtime"), 1);
|
|
2221
|
+
var JSXRuntime = __toESM(require("react/jsx-runtime"), 1);
|
|
2222
|
+
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
2223
|
+
var ReactDOMClient = __toESM(require("react-dom/client"), 1);
|
|
2224
|
+
init_apply_shared_modules();
|
|
2225
|
+
init_next_client_pages_loader();
|
|
2226
|
+
init_shared_module_resolver();
|
|
2221
2227
|
|
|
2222
2228
|
// src/runtime/rsc.ts
|
|
2223
2229
|
var import_web_streams_polyfill = require("web-streams-polyfill");
|
|
@@ -2292,6 +2298,75 @@ function createRSCStream(rscName, data) {
|
|
|
2292
2298
|
});
|
|
2293
2299
|
}
|
|
2294
2300
|
|
|
2301
|
+
// src/runtime/loaders/component-loader.ts
|
|
2302
|
+
init_remote_scope_setup();
|
|
2303
|
+
init_shared_modules();
|
|
2304
|
+
init_error();
|
|
2305
|
+
init_logger();
|
|
2306
|
+
init_script_loader();
|
|
2307
|
+
|
|
2308
|
+
// src/host/shared/pipeline.ts
|
|
2309
|
+
init_static_loader();
|
|
2310
|
+
init_patterns();
|
|
2311
|
+
init_utils();
|
|
2312
|
+
init_error();
|
|
2313
|
+
function preparePipeline(input) {
|
|
2314
|
+
const parser = new DOMParser();
|
|
2315
|
+
const doc = parser.parseFromString(input.html, "text/html");
|
|
2316
|
+
const parsed = parseRemoteComponentDocument(doc, input.name, input.url);
|
|
2317
|
+
const remoteShared = input.remoteShared ?? parsed.remoteShared;
|
|
2318
|
+
if ("__remote_components_missing_shared__" in remoteShared) {
|
|
2319
|
+
throw new RemoteComponentsError(
|
|
2320
|
+
remoteShared.__remote_components_missing_shared__
|
|
2321
|
+
);
|
|
2322
|
+
}
|
|
2323
|
+
applyOriginToNodes(doc, input.url, input.resolveClientUrl);
|
|
2324
|
+
const scriptDescriptors = buildScriptDescriptors(parsed.scripts, input.url);
|
|
2325
|
+
return { doc, parsed, scriptDescriptors };
|
|
2326
|
+
}
|
|
2327
|
+
function buildScriptDescriptors(scripts, url) {
|
|
2328
|
+
return scripts.map((script) => {
|
|
2329
|
+
const scriptSrc = script.getAttribute("data-src") || script.getAttribute("src") || script.src;
|
|
2330
|
+
const { prefix, id: path } = REMOTE_COMPONENT_REGEX.exec(scriptSrc)?.groups ?? {
|
|
2331
|
+
prefix: void 0,
|
|
2332
|
+
id: scriptSrc
|
|
2333
|
+
};
|
|
2334
|
+
return {
|
|
2335
|
+
src: new URL(collapseDoubleSlashes(`${prefix ?? ""}${path}`), url).href
|
|
2336
|
+
};
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
// src/host/shared/state.ts
|
|
2341
|
+
function createHostState() {
|
|
2342
|
+
return {
|
|
2343
|
+
stage: "idle",
|
|
2344
|
+
prevSrc: void 0,
|
|
2345
|
+
prevUrl: void 0,
|
|
2346
|
+
prevName: void 0,
|
|
2347
|
+
prevIsRemoteComponent: false,
|
|
2348
|
+
abortController: void 0
|
|
2349
|
+
};
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
// src/host/utils/resolve-name-from-src.ts
|
|
2353
|
+
function resolveNameFromSrc(src, defaultName) {
|
|
2354
|
+
if (!src) {
|
|
2355
|
+
return defaultName;
|
|
2356
|
+
}
|
|
2357
|
+
const hash = typeof src === "string" ? src : src.hash;
|
|
2358
|
+
const hashIndex = hash.indexOf("#");
|
|
2359
|
+
if (hashIndex < 0) {
|
|
2360
|
+
return defaultName;
|
|
2361
|
+
}
|
|
2362
|
+
const name = hash.slice(hashIndex + 1);
|
|
2363
|
+
return name || defaultName;
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
// src/host/html/index.tsx
|
|
2367
|
+
init_constants2();
|
|
2368
|
+
init_namespace();
|
|
2369
|
+
|
|
2295
2370
|
// src/runtime/url/resolve-client-url.ts
|
|
2296
2371
|
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
2297
2372
|
const remoteOrigin = parseOrigin(remoteSrc);
|
|
@@ -2446,6 +2521,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2446
2521
|
hostState = createHostState();
|
|
2447
2522
|
root = null;
|
|
2448
2523
|
reactRoot;
|
|
2524
|
+
emitter = makeEventEmitter(this);
|
|
2449
2525
|
onRequest;
|
|
2450
2526
|
onResponse;
|
|
2451
2527
|
resolveClientUrl;
|
|
@@ -2496,13 +2572,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2496
2572
|
static get observedAttributes() {
|
|
2497
2573
|
return ["src", "name", "mode"];
|
|
2498
2574
|
}
|
|
2499
|
-
dispatchLifecycleEvent(type, detail) {
|
|
2500
|
-
const event = new Event(type, { bubbles: true, composed: true });
|
|
2501
|
-
if (detail) {
|
|
2502
|
-
Object.assign(event, detail);
|
|
2503
|
-
}
|
|
2504
|
-
this.dispatchEvent(event);
|
|
2505
|
-
}
|
|
2506
2575
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2507
2576
|
if ((name === "src" || name === "name") && oldValue !== newValue) {
|
|
2508
2577
|
if (this.src) {
|
|
@@ -2511,7 +2580,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2511
2580
|
return;
|
|
2512
2581
|
}
|
|
2513
2582
|
logError("HtmlHost", "Error loading remote component.", e);
|
|
2514
|
-
this.
|
|
2583
|
+
this.emitter.error(e, this.src);
|
|
2515
2584
|
this.hostState.stage = "error";
|
|
2516
2585
|
});
|
|
2517
2586
|
}
|
|
@@ -2528,7 +2597,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2528
2597
|
return;
|
|
2529
2598
|
}
|
|
2530
2599
|
logError("HtmlHost", "Error reloading remote component.", e);
|
|
2531
|
-
this.
|
|
2600
|
+
this.emitter.error(e, this.src);
|
|
2532
2601
|
});
|
|
2533
2602
|
}
|
|
2534
2603
|
}
|
|
@@ -2566,7 +2635,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2566
2635
|
this.hostState.stage = "idle";
|
|
2567
2636
|
}
|
|
2568
2637
|
};
|
|
2569
|
-
this.
|
|
2638
|
+
this.emitter.beforeLoad(src ?? "");
|
|
2570
2639
|
const remoteComponentChild = this.querySelector("div#__REMOTE_COMPONENT__") || this.querySelector("div[data-bundle][data-route]");
|
|
2571
2640
|
if (!src && !remoteComponentChild) {
|
|
2572
2641
|
throw new RemoteComponentsError('"src" attribute is required');
|
|
@@ -2614,13 +2683,14 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2614
2683
|
return abandonLoad();
|
|
2615
2684
|
}
|
|
2616
2685
|
}
|
|
2617
|
-
const
|
|
2618
|
-
const doc =
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2686
|
+
const effectiveUrl = url ?? new URL(window.location.href);
|
|
2687
|
+
const { doc, parsed } = preparePipeline({
|
|
2688
|
+
html,
|
|
2689
|
+
name: this.name,
|
|
2690
|
+
url: effectiveUrl,
|
|
2691
|
+
shared: {},
|
|
2692
|
+
resolveClientUrl
|
|
2693
|
+
});
|
|
2624
2694
|
const {
|
|
2625
2695
|
component,
|
|
2626
2696
|
name: resolvedName,
|
|
@@ -2654,11 +2724,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2654
2724
|
this.previousElementSibling?.remove();
|
|
2655
2725
|
}
|
|
2656
2726
|
this.parentElement?.insertBefore(metadataEl, this);
|
|
2657
|
-
if ("__remote_components_missing_shared__" in remoteShared) {
|
|
2658
|
-
throw new RemoteComponentsError(
|
|
2659
|
-
remoteShared.__remote_components_missing_shared__
|
|
2660
|
-
);
|
|
2661
|
-
}
|
|
2662
2727
|
if (this.hostState.prevIsRemoteComponent) {
|
|
2663
2728
|
if (this.hostState.prevUrl) {
|
|
2664
2729
|
const prevUrl = this.hostState.prevUrl;
|
|
@@ -2687,14 +2752,14 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2687
2752
|
this.root.innerHTML = "";
|
|
2688
2753
|
}
|
|
2689
2754
|
if (this.hostState.prevSrc !== void 0) {
|
|
2690
|
-
this.
|
|
2691
|
-
previousSrc: this.hostState.prevSrc,
|
|
2692
|
-
nextSrc: src,
|
|
2755
|
+
this.emitter.change({
|
|
2756
|
+
previousSrc: this.hostState.prevSrc ?? null,
|
|
2757
|
+
nextSrc: src ?? null,
|
|
2693
2758
|
previousName: this.hostState.prevName,
|
|
2694
2759
|
nextName: this.name
|
|
2695
2760
|
});
|
|
2696
2761
|
}
|
|
2697
|
-
this.hostState.prevUrl =
|
|
2762
|
+
this.hostState.prevUrl = effectiveUrl;
|
|
2698
2763
|
this.hostState.prevIsRemoteComponent = isRemoteComponent;
|
|
2699
2764
|
this.hostState.prevSrc = src;
|
|
2700
2765
|
this.hostState.prevName = this.name;
|
|
@@ -2727,11 +2792,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2727
2792
|
return abandonLoad();
|
|
2728
2793
|
}
|
|
2729
2794
|
}
|
|
2730
|
-
applyOriginToNodes(
|
|
2731
|
-
doc,
|
|
2732
|
-
url ?? new URL(window.location.href),
|
|
2733
|
-
resolveClientUrl
|
|
2734
|
-
);
|
|
2735
2795
|
if (!this.reactRoot) {
|
|
2736
2796
|
Array.from(component.children).forEach((el) => {
|
|
2737
2797
|
if (!isRemoteComponent && el.tagName.toLowerCase() === "script") {
|
|
@@ -2806,7 +2866,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2806
2866
|
preloadScripts
|
|
2807
2867
|
} = await getRuntime(
|
|
2808
2868
|
metadataObj.runtime,
|
|
2809
|
-
|
|
2869
|
+
effectiveUrl,
|
|
2810
2870
|
this.bundle,
|
|
2811
2871
|
{
|
|
2812
2872
|
react: async () => (await import("react")).default,
|
|
@@ -2897,7 +2957,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2897
2957
|
if (isCurrentLoad()) {
|
|
2898
2958
|
this.hostState.stage = "loaded";
|
|
2899
2959
|
}
|
|
2900
|
-
this.
|
|
2960
|
+
this.emitter.load(this.src ?? "");
|
|
2901
2961
|
}, [initial, name]);
|
|
2902
2962
|
return Component;
|
|
2903
2963
|
};
|
|
@@ -2941,9 +3001,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2941
3001
|
if (isCurrentLoad()) {
|
|
2942
3002
|
remoteComponent.hostState.stage = "loaded";
|
|
2943
3003
|
}
|
|
2944
|
-
remoteComponent.
|
|
2945
|
-
src: remoteComponent.src
|
|
2946
|
-
});
|
|
3004
|
+
remoteComponent.emitter.load(remoteComponent.src ?? "");
|
|
2947
3005
|
}, [initial, remoteComponent]);
|
|
2948
3006
|
return NextApp ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NextApp, { Component: NextComponent, ...nextData.props }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NextComponent, { ...nextData.props });
|
|
2949
3007
|
})(App, Component, this);
|
|
@@ -2984,9 +3042,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2984
3042
|
}
|
|
2985
3043
|
)
|
|
2986
3044
|
);
|
|
2987
|
-
this.
|
|
3045
|
+
this.emitter.load(this.src ?? "");
|
|
2988
3046
|
} else {
|
|
2989
|
-
this.
|
|
3047
|
+
this.emitter.load(this.src ?? "");
|
|
2990
3048
|
}
|
|
2991
3049
|
if (isCurrentLoad()) {
|
|
2992
3050
|
this.hostState.stage = "loaded";
|