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.js
CHANGED
|
@@ -364,194 +364,6 @@ var init_remote_scope = __esm({
|
|
|
364
364
|
}
|
|
365
365
|
});
|
|
366
366
|
|
|
367
|
-
// src/config/webpack/apply-shared-modules.ts
|
|
368
|
-
function applySharedModules(bundle, resolve) {
|
|
369
|
-
logDebug(
|
|
370
|
-
"SharedModules",
|
|
371
|
-
`applySharedModules called for bundle: "${bundle}"`
|
|
372
|
-
);
|
|
373
|
-
logDebug(
|
|
374
|
-
"SharedModules",
|
|
375
|
-
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
376
|
-
);
|
|
377
|
-
const self = globalThis;
|
|
378
|
-
const scope = getScope(bundle);
|
|
379
|
-
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
380
|
-
if (webpackBundle) {
|
|
381
|
-
const modulePaths = Object.keys(
|
|
382
|
-
self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {}
|
|
383
|
-
);
|
|
384
|
-
logDebug(
|
|
385
|
-
"SharedModules",
|
|
386
|
-
`Available module paths for bundle "${bundle}": ${modulePaths}`
|
|
387
|
-
);
|
|
388
|
-
for (const [key, value] of Object.entries(resolve)) {
|
|
389
|
-
const exactIds = modulePaths.filter((p) => p === key);
|
|
390
|
-
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
391
|
-
if (ids.length === 0) {
|
|
392
|
-
logDebug(
|
|
393
|
-
"SharedModules",
|
|
394
|
-
`No matching module path found for shared module "${key}"`
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
for (const id of ids) {
|
|
398
|
-
if (webpackBundle.m) {
|
|
399
|
-
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
400
|
-
if (resolvedId !== id) {
|
|
401
|
-
logDebug(
|
|
402
|
-
"SharedModules",
|
|
403
|
-
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
404
|
-
);
|
|
405
|
-
}
|
|
406
|
-
webpackBundle.m[resolvedId] = (module) => {
|
|
407
|
-
module.exports = value;
|
|
408
|
-
};
|
|
409
|
-
} else {
|
|
410
|
-
logWarn(
|
|
411
|
-
"SharedModules",
|
|
412
|
-
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
} else {
|
|
418
|
-
logWarn(
|
|
419
|
-
"SharedModules",
|
|
420
|
-
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
421
|
-
);
|
|
422
|
-
logDebug(
|
|
423
|
-
"SharedModules",
|
|
424
|
-
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
var DEDUPLICATION_SKIPPED;
|
|
429
|
-
var init_apply_shared_modules = __esm({
|
|
430
|
-
"src/config/webpack/apply-shared-modules.ts"() {
|
|
431
|
-
"use strict";
|
|
432
|
-
init_remote_scope();
|
|
433
|
-
init_logger();
|
|
434
|
-
DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
// src/config/webpack/next-client-pages-loader.ts
|
|
439
|
-
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
440
|
-
const self = globalThis;
|
|
441
|
-
const nextCssOriginal = document.querySelector(
|
|
442
|
-
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
443
|
-
);
|
|
444
|
-
if (nextCssOriginal) {
|
|
445
|
-
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
446
|
-
}
|
|
447
|
-
const nextCss = document.createElement("noscript");
|
|
448
|
-
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
449
|
-
nextCss.setAttribute("data-bundle", bundle);
|
|
450
|
-
nextCss.setAttribute("data-route", route);
|
|
451
|
-
const nextCssEnd = document.createElement("noscript");
|
|
452
|
-
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
453
|
-
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
454
|
-
nextCssEnd.setAttribute("data-route", route);
|
|
455
|
-
document.head.appendChild(nextCssEnd);
|
|
456
|
-
document.head.appendChild(nextCss);
|
|
457
|
-
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
458
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
459
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
460
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
461
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
462
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
463
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
464
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
465
|
-
) ?? ""] ?? -1;
|
|
466
|
-
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
467
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
468
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
469
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
470
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
471
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
472
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
473
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
474
|
-
) ?? ""] ?? -1;
|
|
475
|
-
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
476
|
-
throw new RemoteComponentsError(
|
|
477
|
-
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
481
|
-
const selfOriginal = self;
|
|
482
|
-
delete selfOriginal.__NEXT_P;
|
|
483
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
484
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
485
|
-
);
|
|
486
|
-
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
487
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
488
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
489
|
-
);
|
|
490
|
-
}
|
|
491
|
-
if (self.__NEXT_P) {
|
|
492
|
-
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
493
|
-
void 0,
|
|
494
|
-
() => ({ default: null })
|
|
495
|
-
];
|
|
496
|
-
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
497
|
-
void 0,
|
|
498
|
-
() => ({
|
|
499
|
-
default: null
|
|
500
|
-
})
|
|
501
|
-
];
|
|
502
|
-
const { default: Component } = componentLoader();
|
|
503
|
-
const { default: App } = appLoader();
|
|
504
|
-
const cssCache = getNamespace().cssCache;
|
|
505
|
-
if (!cssCache[bundle]) {
|
|
506
|
-
const cssRE = /\.s?css$/;
|
|
507
|
-
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
508
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
509
|
-
});
|
|
510
|
-
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
511
|
-
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
512
|
-
if (id) {
|
|
513
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
const elements = [];
|
|
517
|
-
let node = nextCss.previousSibling;
|
|
518
|
-
while (node && node !== nextCssEnd) {
|
|
519
|
-
elements.push(node);
|
|
520
|
-
node.remove();
|
|
521
|
-
node = nextCss.previousSibling;
|
|
522
|
-
}
|
|
523
|
-
cssCache[bundle] = elements;
|
|
524
|
-
}
|
|
525
|
-
if (styleContainer) {
|
|
526
|
-
const elements = cssCache[bundle];
|
|
527
|
-
elements.forEach((el) => {
|
|
528
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
529
|
-
});
|
|
530
|
-
} else {
|
|
531
|
-
const elements = cssCache[bundle];
|
|
532
|
-
elements.forEach((el) => {
|
|
533
|
-
document.head.appendChild(el);
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
delete self.__NEXT_P;
|
|
537
|
-
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
538
|
-
if (nextCssOriginal) {
|
|
539
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
540
|
-
}
|
|
541
|
-
nextCss.remove();
|
|
542
|
-
nextCssEnd.remove();
|
|
543
|
-
return { Component, App };
|
|
544
|
-
}
|
|
545
|
-
return { Component: null, App: null };
|
|
546
|
-
}
|
|
547
|
-
var init_next_client_pages_loader = __esm({
|
|
548
|
-
"src/config/webpack/next-client-pages-loader.ts"() {
|
|
549
|
-
"use strict";
|
|
550
|
-
init_namespace();
|
|
551
|
-
init_error();
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
|
|
555
367
|
// src/host/shared/remote-image-loader.ts
|
|
556
368
|
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
557
369
|
const loader = Object.assign(
|
|
@@ -802,137 +614,190 @@ var init_shared_module_resolver = __esm({
|
|
|
802
614
|
}
|
|
803
615
|
});
|
|
804
616
|
|
|
805
|
-
// src/
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
617
|
+
// src/config/webpack/apply-shared-modules.ts
|
|
618
|
+
function applySharedModules(bundle, resolve) {
|
|
619
|
+
logDebug(
|
|
620
|
+
"SharedModules",
|
|
621
|
+
`applySharedModules called for bundle: "${bundle}"`
|
|
622
|
+
);
|
|
623
|
+
logDebug(
|
|
624
|
+
"SharedModules",
|
|
625
|
+
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
626
|
+
);
|
|
627
|
+
const self = globalThis;
|
|
628
|
+
const scope = getScope(bundle);
|
|
629
|
+
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
630
|
+
if (webpackBundle) {
|
|
631
|
+
const modulePaths = Object.keys(
|
|
632
|
+
self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {}
|
|
633
|
+
);
|
|
634
|
+
logDebug(
|
|
635
|
+
"SharedModules",
|
|
636
|
+
`Available module paths for bundle "${bundle}": ${modulePaths}`
|
|
637
|
+
);
|
|
638
|
+
for (const [key, value] of Object.entries(resolve)) {
|
|
639
|
+
const exactIds = modulePaths.filter((p) => p === key);
|
|
640
|
+
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
641
|
+
if (ids.length === 0) {
|
|
642
|
+
logDebug(
|
|
643
|
+
"SharedModules",
|
|
644
|
+
`No matching module path found for shared module "${key}"`
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
for (const id of ids) {
|
|
648
|
+
if (webpackBundle.m) {
|
|
649
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
650
|
+
if (resolvedId !== id) {
|
|
651
|
+
logDebug(
|
|
652
|
+
"SharedModules",
|
|
653
|
+
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
835
654
|
);
|
|
836
655
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
656
|
+
webpackBundle.m[resolvedId] = (module) => {
|
|
657
|
+
module.exports = value;
|
|
658
|
+
};
|
|
659
|
+
} else {
|
|
660
|
+
logWarn(
|
|
661
|
+
"SharedModules",
|
|
662
|
+
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
} else {
|
|
668
|
+
logWarn(
|
|
669
|
+
"SharedModules",
|
|
670
|
+
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
671
|
+
);
|
|
672
|
+
logDebug(
|
|
673
|
+
"SharedModules",
|
|
674
|
+
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
675
|
+
);
|
|
676
|
+
}
|
|
844
677
|
}
|
|
845
|
-
var
|
|
846
|
-
|
|
678
|
+
var DEDUPLICATION_SKIPPED;
|
|
679
|
+
var init_apply_shared_modules = __esm({
|
|
680
|
+
"src/config/webpack/apply-shared-modules.ts"() {
|
|
847
681
|
"use strict";
|
|
848
|
-
|
|
849
|
-
init_protected_rc_fallback();
|
|
850
|
-
init_error();
|
|
682
|
+
init_remote_scope();
|
|
851
683
|
init_logger();
|
|
684
|
+
DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
852
685
|
}
|
|
853
686
|
});
|
|
854
687
|
|
|
855
|
-
// src/
|
|
856
|
-
|
|
857
|
-
__export(webpack_exports, {
|
|
858
|
-
webpackRuntime: () => webpackRuntime
|
|
859
|
-
});
|
|
860
|
-
async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
688
|
+
// src/config/webpack/next-client-pages-loader.ts
|
|
689
|
+
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
861
690
|
const self = globalThis;
|
|
862
|
-
|
|
863
|
-
|
|
691
|
+
const nextCssOriginal = document.querySelector(
|
|
692
|
+
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
693
|
+
);
|
|
694
|
+
if (nextCssOriginal) {
|
|
695
|
+
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
864
696
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
697
|
+
const nextCss = document.createElement("noscript");
|
|
698
|
+
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
699
|
+
nextCss.setAttribute("data-bundle", bundle);
|
|
700
|
+
nextCss.setAttribute("data-route", route);
|
|
701
|
+
const nextCssEnd = document.createElement("noscript");
|
|
702
|
+
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
703
|
+
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
704
|
+
nextCssEnd.setAttribute("data-route", route);
|
|
705
|
+
document.head.appendChild(nextCssEnd);
|
|
706
|
+
document.head.appendChild(nextCss);
|
|
707
|
+
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
708
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
709
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
710
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
711
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
712
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
713
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
714
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
715
|
+
) ?? ""] ?? -1;
|
|
716
|
+
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
717
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
718
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
719
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
720
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
721
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
722
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
723
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
724
|
+
) ?? ""] ?? -1;
|
|
725
|
+
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
726
|
+
throw new RemoteComponentsError(
|
|
727
|
+
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
728
|
+
);
|
|
887
729
|
}
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
return [
|
|
898
|
-
{
|
|
899
|
-
src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
900
|
-
}
|
|
901
|
-
];
|
|
902
|
-
});
|
|
903
|
-
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
904
|
-
const hostShared = buildHostShared(shared, resolveClientUrl);
|
|
905
|
-
const resolve = await buildWebpackResolve(
|
|
906
|
-
hostShared,
|
|
907
|
-
remoteShared ?? {},
|
|
908
|
-
remoteBundle,
|
|
909
|
-
{
|
|
910
|
-
"/react/index.js": (await import("react")).default,
|
|
911
|
-
"/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
|
|
912
|
-
"/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
|
|
913
|
-
"/react-dom/index.js": (await import("react-dom")).default,
|
|
914
|
-
"/react-dom/client.js": (await import("react-dom/client")).default
|
|
915
|
-
},
|
|
916
|
-
"WebpackRuntime"
|
|
730
|
+
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
731
|
+
const selfOriginal = self;
|
|
732
|
+
delete selfOriginal.__NEXT_P;
|
|
733
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
734
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
735
|
+
);
|
|
736
|
+
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
737
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
738
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
917
739
|
);
|
|
918
|
-
applySharedModules(remoteBundle, resolve);
|
|
919
740
|
}
|
|
920
|
-
|
|
921
|
-
self
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
741
|
+
if (self.__NEXT_P) {
|
|
742
|
+
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
743
|
+
void 0,
|
|
744
|
+
() => ({ default: null })
|
|
745
|
+
];
|
|
746
|
+
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
747
|
+
void 0,
|
|
748
|
+
() => ({
|
|
749
|
+
default: null
|
|
750
|
+
})
|
|
751
|
+
];
|
|
752
|
+
const { default: Component } = componentLoader();
|
|
753
|
+
const { default: App } = appLoader();
|
|
754
|
+
const cssCache = getNamespace().cssCache;
|
|
755
|
+
if (!cssCache[bundle]) {
|
|
756
|
+
const cssRE = /\.s?css$/;
|
|
757
|
+
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
758
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
759
|
+
});
|
|
760
|
+
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
761
|
+
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
762
|
+
if (id) {
|
|
763
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
const elements = [];
|
|
767
|
+
let node = nextCss.previousSibling;
|
|
768
|
+
while (node && node !== nextCssEnd) {
|
|
769
|
+
elements.push(node);
|
|
770
|
+
node.remove();
|
|
771
|
+
node = nextCss.previousSibling;
|
|
772
|
+
}
|
|
773
|
+
cssCache[bundle] = elements;
|
|
774
|
+
}
|
|
775
|
+
if (styleContainer) {
|
|
776
|
+
const elements = cssCache[bundle];
|
|
777
|
+
elements.forEach((el) => {
|
|
778
|
+
styleContainer.appendChild(el.cloneNode(true));
|
|
779
|
+
});
|
|
780
|
+
} else {
|
|
781
|
+
const elements = cssCache[bundle];
|
|
782
|
+
elements.forEach((el) => {
|
|
783
|
+
document.head.appendChild(el);
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
delete self.__NEXT_P;
|
|
787
|
+
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
788
|
+
if (nextCssOriginal) {
|
|
789
|
+
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
790
|
+
}
|
|
791
|
+
nextCss.remove();
|
|
792
|
+
nextCssEnd.remove();
|
|
793
|
+
return { Component, App };
|
|
794
|
+
}
|
|
795
|
+
return { Component: null, App: null };
|
|
927
796
|
}
|
|
928
|
-
var
|
|
929
|
-
"src/
|
|
797
|
+
var init_next_client_pages_loader = __esm({
|
|
798
|
+
"src/config/webpack/next-client-pages-loader.ts"() {
|
|
930
799
|
"use strict";
|
|
931
|
-
|
|
932
|
-
init_next_client_pages_loader();
|
|
933
|
-
init_shared_module_resolver();
|
|
934
|
-
init_script_loader();
|
|
935
|
-
init_patterns();
|
|
800
|
+
init_namespace();
|
|
936
801
|
init_error();
|
|
937
802
|
}
|
|
938
803
|
});
|
|
@@ -958,7 +823,7 @@ var init_patterns2 = __esm({
|
|
|
958
823
|
`\\.TURBOPACK_REMOTE_SHARED\\s*=\\s*await (?:__turbopack_context__|[a-z])\\.A\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
959
824
|
);
|
|
960
825
|
ASYNC_MODULE_LOADER_RE = new RegExp(
|
|
961
|
-
`(?:__turbopack_context__|
|
|
826
|
+
`(?:__turbopack_context__|[a-z])\\.A\\((?<asyncSharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
962
827
|
);
|
|
963
828
|
ASYNC_MODULE_CALLBACK_RE = new RegExp(
|
|
964
829
|
`(?:parentImport|[a-z])\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
@@ -1666,52 +1531,53 @@ var init_remote_scope_setup = __esm({
|
|
|
1666
1531
|
}
|
|
1667
1532
|
});
|
|
1668
1533
|
|
|
1669
|
-
// src/
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1534
|
+
// src/runtime/loaders/script-loader.ts
|
|
1535
|
+
async function loadScripts(scripts, resolveClientUrl) {
|
|
1536
|
+
await Promise.all(
|
|
1537
|
+
scripts.map((script) => {
|
|
1538
|
+
return new Promise((resolve, reject) => {
|
|
1539
|
+
const newSrc = new URL(
|
|
1540
|
+
// remove the remote component bundle name identifier from the script src
|
|
1541
|
+
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
1542
|
+
location.origin
|
|
1543
|
+
).href;
|
|
1544
|
+
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
1545
|
+
const alreadyLoaded = Array.from(
|
|
1546
|
+
document.querySelectorAll("script[src]")
|
|
1547
|
+
).some((s) => s.src === resolvedSrc);
|
|
1548
|
+
if (alreadyLoaded) {
|
|
1549
|
+
resolve();
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
const newScript = document.createElement("script");
|
|
1553
|
+
newScript.onload = () => resolve();
|
|
1554
|
+
newScript.onerror = () => {
|
|
1555
|
+
const isProxied = isProxiedUrl(resolvedSrc);
|
|
1556
|
+
if (isProxied) {
|
|
1557
|
+
reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
|
|
1558
|
+
} else {
|
|
1559
|
+
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
1560
|
+
reject(
|
|
1561
|
+
new RemoteComponentsError(
|
|
1562
|
+
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
1563
|
+
)
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
newScript.src = resolvedSrc;
|
|
1568
|
+
newScript.async = true;
|
|
1569
|
+
document.head.appendChild(newScript);
|
|
1570
|
+
});
|
|
1571
|
+
})
|
|
1572
|
+
);
|
|
1706
1573
|
}
|
|
1707
|
-
var
|
|
1708
|
-
"src/
|
|
1574
|
+
var init_script_loader = __esm({
|
|
1575
|
+
"src/runtime/loaders/script-loader.ts"() {
|
|
1709
1576
|
"use strict";
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
init_shared_modules();
|
|
1577
|
+
init_patterns();
|
|
1578
|
+
init_protected_rc_fallback();
|
|
1579
|
+
init_error();
|
|
1580
|
+
init_logger();
|
|
1715
1581
|
}
|
|
1716
1582
|
});
|
|
1717
1583
|
|
|
@@ -1865,6 +1731,140 @@ var init_static_loader = __esm({
|
|
|
1865
1731
|
}
|
|
1866
1732
|
});
|
|
1867
1733
|
|
|
1734
|
+
// src/host/html/runtime/webpack.ts
|
|
1735
|
+
var webpack_exports = {};
|
|
1736
|
+
__export(webpack_exports, {
|
|
1737
|
+
webpackRuntime: () => webpackRuntime
|
|
1738
|
+
});
|
|
1739
|
+
async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
1740
|
+
const self = globalThis;
|
|
1741
|
+
if (!self.__DISABLE_WEBPACK_EXEC__) {
|
|
1742
|
+
self.__DISABLE_WEBPACK_EXEC__ = {};
|
|
1743
|
+
}
|
|
1744
|
+
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
1745
|
+
if (typeof self.__webpack_require__ !== "function" && self.__webpack_require_type__ !== "turbopack") {
|
|
1746
|
+
self.__webpack_require__ = (remoteId) => {
|
|
1747
|
+
const re = /\[(?<bundle>[^\]]+)\] (?<id>.*)/;
|
|
1748
|
+
const match = re.exec(remoteId);
|
|
1749
|
+
const remoteBundle = match?.groups?.bundle;
|
|
1750
|
+
const id = match?.groups?.id;
|
|
1751
|
+
if (!(id && remoteBundle)) {
|
|
1752
|
+
throw new RemoteComponentsError(
|
|
1753
|
+
`Remote Component module "${remoteId}" not found. Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
1754
|
+
);
|
|
1755
|
+
}
|
|
1756
|
+
if (typeof self.__remote_webpack_require__?.[remoteBundle] !== "function") {
|
|
1757
|
+
throw new RemoteComponentsError(
|
|
1758
|
+
`Remote Components are not available in "${remoteBundle}". Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1761
|
+
return self.__remote_webpack_require__[remoteBundle](id);
|
|
1762
|
+
};
|
|
1763
|
+
self.__webpack_chunk_load__ = () => {
|
|
1764
|
+
return Promise.resolve([]);
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
const {
|
|
1768
|
+
default: { createFromReadableStream }
|
|
1769
|
+
} = await import("react-server-dom-webpack/client.browser");
|
|
1770
|
+
async function preloadScripts(scripts, url, remoteBundle, _) {
|
|
1771
|
+
const scriptSrcs = scripts.flatMap((script) => {
|
|
1772
|
+
const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
|
|
1773
|
+
script.parentElement?.removeChild(script);
|
|
1774
|
+
if (!scriptSrc)
|
|
1775
|
+
return [];
|
|
1776
|
+
return [
|
|
1777
|
+
{
|
|
1778
|
+
src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
1779
|
+
}
|
|
1780
|
+
];
|
|
1781
|
+
});
|
|
1782
|
+
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
1783
|
+
const hostShared = buildHostShared(shared, resolveClientUrl);
|
|
1784
|
+
const resolve = await buildWebpackResolve(
|
|
1785
|
+
hostShared,
|
|
1786
|
+
remoteShared ?? {},
|
|
1787
|
+
remoteBundle,
|
|
1788
|
+
{
|
|
1789
|
+
"/react/index.js": (await import("react")).default,
|
|
1790
|
+
"/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
|
|
1791
|
+
"/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
|
|
1792
|
+
"/react-dom/index.js": (await import("react-dom")).default,
|
|
1793
|
+
"/react-dom/client.js": (await import("react-dom/client")).default
|
|
1794
|
+
},
|
|
1795
|
+
"WebpackRuntime"
|
|
1796
|
+
);
|
|
1797
|
+
applySharedModules(remoteBundle, resolve);
|
|
1798
|
+
}
|
|
1799
|
+
return {
|
|
1800
|
+
self,
|
|
1801
|
+
createFromReadableStream,
|
|
1802
|
+
applySharedModules,
|
|
1803
|
+
nextClientPagesLoader,
|
|
1804
|
+
preloadScripts
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
var init_webpack = __esm({
|
|
1808
|
+
"src/host/html/runtime/webpack.ts"() {
|
|
1809
|
+
"use strict";
|
|
1810
|
+
init_apply_shared_modules();
|
|
1811
|
+
init_next_client_pages_loader();
|
|
1812
|
+
init_shared_module_resolver();
|
|
1813
|
+
init_script_loader();
|
|
1814
|
+
init_patterns();
|
|
1815
|
+
init_error();
|
|
1816
|
+
}
|
|
1817
|
+
});
|
|
1818
|
+
|
|
1819
|
+
// src/host/html/runtime/turbopack.ts
|
|
1820
|
+
var turbopack_exports = {};
|
|
1821
|
+
__export(turbopack_exports, {
|
|
1822
|
+
turbopackRuntime: () => turbopackRuntime
|
|
1823
|
+
});
|
|
1824
|
+
async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
1825
|
+
const self = globalThis;
|
|
1826
|
+
const hostShared = buildHostShared(shared, resolveClientUrl, {
|
|
1827
|
+
includeRemoteComponentShared: true
|
|
1828
|
+
});
|
|
1829
|
+
await setupRemoteScope("turbopack", [], url, bundle, resolveClientUrl);
|
|
1830
|
+
const {
|
|
1831
|
+
default: { createFromReadableStream }
|
|
1832
|
+
} = await import("react-server-dom-webpack/client.browser");
|
|
1833
|
+
async function preloadScripts(scripts, __) {
|
|
1834
|
+
const scope = await setupRemoteScope(
|
|
1835
|
+
"turbopack",
|
|
1836
|
+
scripts.map((script) => ({
|
|
1837
|
+
src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
|
|
1838
|
+
})),
|
|
1839
|
+
url,
|
|
1840
|
+
bundle,
|
|
1841
|
+
resolveClientUrl
|
|
1842
|
+
);
|
|
1843
|
+
await initializeSharedModules(
|
|
1844
|
+
scope,
|
|
1845
|
+
buildCoreShared(hostShared),
|
|
1846
|
+
remoteShared ?? {}
|
|
1847
|
+
);
|
|
1848
|
+
}
|
|
1849
|
+
return {
|
|
1850
|
+
self,
|
|
1851
|
+
createFromReadableStream,
|
|
1852
|
+
applySharedModules,
|
|
1853
|
+
nextClientPagesLoader,
|
|
1854
|
+
preloadScripts
|
|
1855
|
+
};
|
|
1856
|
+
}
|
|
1857
|
+
var init_turbopack = __esm({
|
|
1858
|
+
"src/host/html/runtime/turbopack.ts"() {
|
|
1859
|
+
"use strict";
|
|
1860
|
+
init_apply_shared_modules();
|
|
1861
|
+
init_next_client_pages_loader();
|
|
1862
|
+
init_shared_module_resolver();
|
|
1863
|
+
init_remote_scope_setup();
|
|
1864
|
+
init_shared_modules();
|
|
1865
|
+
}
|
|
1866
|
+
});
|
|
1867
|
+
|
|
1868
1868
|
// src/host/html/runtime/script.ts
|
|
1869
1869
|
var script_exports = {};
|
|
1870
1870
|
__export(script_exports, {
|
|
@@ -1952,34 +1952,33 @@ function getClientOrServerUrl(src, serverFallback) {
|
|
|
1952
1952
|
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1953
1953
|
}
|
|
1954
1954
|
|
|
1955
|
-
// src/host/shared/
|
|
1956
|
-
function
|
|
1955
|
+
// src/host/shared/lifecycle.ts
|
|
1956
|
+
function makeEventEmitter(element) {
|
|
1957
|
+
function dispatch(type, detail) {
|
|
1958
|
+
const event = new Event(type, { bubbles: true, composed: true });
|
|
1959
|
+
if (detail) {
|
|
1960
|
+
Object.assign(event, detail);
|
|
1961
|
+
}
|
|
1962
|
+
element.dispatchEvent(event);
|
|
1963
|
+
}
|
|
1957
1964
|
return {
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1965
|
+
beforeLoad(src) {
|
|
1966
|
+
dispatch("beforeload", { src });
|
|
1967
|
+
},
|
|
1968
|
+
load(src) {
|
|
1969
|
+
dispatch("load", { src });
|
|
1970
|
+
},
|
|
1971
|
+
error(error, src) {
|
|
1972
|
+
dispatch("error", src != null ? { error, src } : { error });
|
|
1973
|
+
},
|
|
1974
|
+
change(info) {
|
|
1975
|
+
dispatch("change", info);
|
|
1976
|
+
}
|
|
1964
1977
|
};
|
|
1965
1978
|
}
|
|
1966
1979
|
|
|
1967
|
-
// src/host/
|
|
1968
|
-
|
|
1969
|
-
if (!src) {
|
|
1970
|
-
return defaultName;
|
|
1971
|
-
}
|
|
1972
|
-
const hash = typeof src === "string" ? src : src.hash;
|
|
1973
|
-
const hashIndex = hash.indexOf("#");
|
|
1974
|
-
if (hashIndex < 0) {
|
|
1975
|
-
return defaultName;
|
|
1976
|
-
}
|
|
1977
|
-
const name = hash.slice(hashIndex + 1);
|
|
1978
|
-
return name || defaultName;
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
// src/host/html/index.tsx
|
|
1982
|
-
init_constants2();
|
|
1980
|
+
// src/host/shared/pipeline.ts
|
|
1981
|
+
init_shared_module_resolver();
|
|
1983
1982
|
|
|
1984
1983
|
// src/runtime/html/html-spec.ts
|
|
1985
1984
|
var ORIGIN_REWRITE_TAGS = [
|
|
@@ -2188,8 +2187,15 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
2188
2187
|
};
|
|
2189
2188
|
}
|
|
2190
2189
|
|
|
2191
|
-
// src/
|
|
2192
|
-
|
|
2190
|
+
// src/runtime/loaders/component-loader.ts
|
|
2191
|
+
init_apply_shared_modules();
|
|
2192
|
+
init_next_client_pages_loader();
|
|
2193
|
+
init_shared_module_resolver();
|
|
2194
|
+
import * as React from "react";
|
|
2195
|
+
import * as JSXDevRuntime from "react/jsx-dev-runtime";
|
|
2196
|
+
import * as JSXRuntime from "react/jsx-runtime";
|
|
2197
|
+
import * as ReactDOM from "react-dom";
|
|
2198
|
+
import * as ReactDOMClient from "react-dom/client";
|
|
2193
2199
|
|
|
2194
2200
|
// src/runtime/rsc.ts
|
|
2195
2201
|
import { ReadableStream } from "web-streams-polyfill";
|
|
@@ -2264,6 +2270,75 @@ function createRSCStream(rscName, data) {
|
|
|
2264
2270
|
});
|
|
2265
2271
|
}
|
|
2266
2272
|
|
|
2273
|
+
// src/runtime/loaders/component-loader.ts
|
|
2274
|
+
init_remote_scope_setup();
|
|
2275
|
+
init_shared_modules();
|
|
2276
|
+
init_error();
|
|
2277
|
+
init_logger();
|
|
2278
|
+
init_script_loader();
|
|
2279
|
+
|
|
2280
|
+
// src/host/shared/pipeline.ts
|
|
2281
|
+
init_static_loader();
|
|
2282
|
+
init_patterns();
|
|
2283
|
+
init_utils();
|
|
2284
|
+
init_error();
|
|
2285
|
+
function preparePipeline(input) {
|
|
2286
|
+
const parser = new DOMParser();
|
|
2287
|
+
const doc = parser.parseFromString(input.html, "text/html");
|
|
2288
|
+
const parsed = parseRemoteComponentDocument(doc, input.name, input.url);
|
|
2289
|
+
const remoteShared = input.remoteShared ?? parsed.remoteShared;
|
|
2290
|
+
if ("__remote_components_missing_shared__" in remoteShared) {
|
|
2291
|
+
throw new RemoteComponentsError(
|
|
2292
|
+
remoteShared.__remote_components_missing_shared__
|
|
2293
|
+
);
|
|
2294
|
+
}
|
|
2295
|
+
applyOriginToNodes(doc, input.url, input.resolveClientUrl);
|
|
2296
|
+
const scriptDescriptors = buildScriptDescriptors(parsed.scripts, input.url);
|
|
2297
|
+
return { doc, parsed, scriptDescriptors };
|
|
2298
|
+
}
|
|
2299
|
+
function buildScriptDescriptors(scripts, url) {
|
|
2300
|
+
return scripts.map((script) => {
|
|
2301
|
+
const scriptSrc = script.getAttribute("data-src") || script.getAttribute("src") || script.src;
|
|
2302
|
+
const { prefix, id: path } = REMOTE_COMPONENT_REGEX.exec(scriptSrc)?.groups ?? {
|
|
2303
|
+
prefix: void 0,
|
|
2304
|
+
id: scriptSrc
|
|
2305
|
+
};
|
|
2306
|
+
return {
|
|
2307
|
+
src: new URL(collapseDoubleSlashes(`${prefix ?? ""}${path}`), url).href
|
|
2308
|
+
};
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
// src/host/shared/state.ts
|
|
2313
|
+
function createHostState() {
|
|
2314
|
+
return {
|
|
2315
|
+
stage: "idle",
|
|
2316
|
+
prevSrc: void 0,
|
|
2317
|
+
prevUrl: void 0,
|
|
2318
|
+
prevName: void 0,
|
|
2319
|
+
prevIsRemoteComponent: false,
|
|
2320
|
+
abortController: void 0
|
|
2321
|
+
};
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
// src/host/utils/resolve-name-from-src.ts
|
|
2325
|
+
function resolveNameFromSrc(src, defaultName) {
|
|
2326
|
+
if (!src) {
|
|
2327
|
+
return defaultName;
|
|
2328
|
+
}
|
|
2329
|
+
const hash = typeof src === "string" ? src : src.hash;
|
|
2330
|
+
const hashIndex = hash.indexOf("#");
|
|
2331
|
+
if (hashIndex < 0) {
|
|
2332
|
+
return defaultName;
|
|
2333
|
+
}
|
|
2334
|
+
const name = hash.slice(hashIndex + 1);
|
|
2335
|
+
return name || defaultName;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
// src/host/html/index.tsx
|
|
2339
|
+
init_constants2();
|
|
2340
|
+
init_namespace();
|
|
2341
|
+
|
|
2267
2342
|
// src/runtime/url/resolve-client-url.ts
|
|
2268
2343
|
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
2269
2344
|
const remoteOrigin = parseOrigin(remoteSrc);
|
|
@@ -2418,6 +2493,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2418
2493
|
hostState = createHostState();
|
|
2419
2494
|
root = null;
|
|
2420
2495
|
reactRoot;
|
|
2496
|
+
emitter = makeEventEmitter(this);
|
|
2421
2497
|
onRequest;
|
|
2422
2498
|
onResponse;
|
|
2423
2499
|
resolveClientUrl;
|
|
@@ -2468,13 +2544,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2468
2544
|
static get observedAttributes() {
|
|
2469
2545
|
return ["src", "name", "mode"];
|
|
2470
2546
|
}
|
|
2471
|
-
dispatchLifecycleEvent(type, detail) {
|
|
2472
|
-
const event = new Event(type, { bubbles: true, composed: true });
|
|
2473
|
-
if (detail) {
|
|
2474
|
-
Object.assign(event, detail);
|
|
2475
|
-
}
|
|
2476
|
-
this.dispatchEvent(event);
|
|
2477
|
-
}
|
|
2478
2547
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2479
2548
|
if ((name === "src" || name === "name") && oldValue !== newValue) {
|
|
2480
2549
|
if (this.src) {
|
|
@@ -2483,7 +2552,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2483
2552
|
return;
|
|
2484
2553
|
}
|
|
2485
2554
|
logError("HtmlHost", "Error loading remote component.", e);
|
|
2486
|
-
this.
|
|
2555
|
+
this.emitter.error(e, this.src);
|
|
2487
2556
|
this.hostState.stage = "error";
|
|
2488
2557
|
});
|
|
2489
2558
|
}
|
|
@@ -2500,7 +2569,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2500
2569
|
return;
|
|
2501
2570
|
}
|
|
2502
2571
|
logError("HtmlHost", "Error reloading remote component.", e);
|
|
2503
|
-
this.
|
|
2572
|
+
this.emitter.error(e, this.src);
|
|
2504
2573
|
});
|
|
2505
2574
|
}
|
|
2506
2575
|
}
|
|
@@ -2538,7 +2607,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2538
2607
|
this.hostState.stage = "idle";
|
|
2539
2608
|
}
|
|
2540
2609
|
};
|
|
2541
|
-
this.
|
|
2610
|
+
this.emitter.beforeLoad(src ?? "");
|
|
2542
2611
|
const remoteComponentChild = this.querySelector("div#__REMOTE_COMPONENT__") || this.querySelector("div[data-bundle][data-route]");
|
|
2543
2612
|
if (!src && !remoteComponentChild) {
|
|
2544
2613
|
throw new RemoteComponentsError('"src" attribute is required');
|
|
@@ -2586,13 +2655,14 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2586
2655
|
return abandonLoad();
|
|
2587
2656
|
}
|
|
2588
2657
|
}
|
|
2589
|
-
const
|
|
2590
|
-
const doc =
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2658
|
+
const effectiveUrl = url ?? new URL(window.location.href);
|
|
2659
|
+
const { doc, parsed } = preparePipeline({
|
|
2660
|
+
html,
|
|
2661
|
+
name: this.name,
|
|
2662
|
+
url: effectiveUrl,
|
|
2663
|
+
shared: {},
|
|
2664
|
+
resolveClientUrl
|
|
2665
|
+
});
|
|
2596
2666
|
const {
|
|
2597
2667
|
component,
|
|
2598
2668
|
name: resolvedName,
|
|
@@ -2626,11 +2696,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2626
2696
|
this.previousElementSibling?.remove();
|
|
2627
2697
|
}
|
|
2628
2698
|
this.parentElement?.insertBefore(metadataEl, this);
|
|
2629
|
-
if ("__remote_components_missing_shared__" in remoteShared) {
|
|
2630
|
-
throw new RemoteComponentsError(
|
|
2631
|
-
remoteShared.__remote_components_missing_shared__
|
|
2632
|
-
);
|
|
2633
|
-
}
|
|
2634
2699
|
if (this.hostState.prevIsRemoteComponent) {
|
|
2635
2700
|
if (this.hostState.prevUrl) {
|
|
2636
2701
|
const prevUrl = this.hostState.prevUrl;
|
|
@@ -2659,14 +2724,14 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2659
2724
|
this.root.innerHTML = "";
|
|
2660
2725
|
}
|
|
2661
2726
|
if (this.hostState.prevSrc !== void 0) {
|
|
2662
|
-
this.
|
|
2663
|
-
previousSrc: this.hostState.prevSrc,
|
|
2664
|
-
nextSrc: src,
|
|
2727
|
+
this.emitter.change({
|
|
2728
|
+
previousSrc: this.hostState.prevSrc ?? null,
|
|
2729
|
+
nextSrc: src ?? null,
|
|
2665
2730
|
previousName: this.hostState.prevName,
|
|
2666
2731
|
nextName: this.name
|
|
2667
2732
|
});
|
|
2668
2733
|
}
|
|
2669
|
-
this.hostState.prevUrl =
|
|
2734
|
+
this.hostState.prevUrl = effectiveUrl;
|
|
2670
2735
|
this.hostState.prevIsRemoteComponent = isRemoteComponent;
|
|
2671
2736
|
this.hostState.prevSrc = src;
|
|
2672
2737
|
this.hostState.prevName = this.name;
|
|
@@ -2699,11 +2764,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2699
2764
|
return abandonLoad();
|
|
2700
2765
|
}
|
|
2701
2766
|
}
|
|
2702
|
-
applyOriginToNodes(
|
|
2703
|
-
doc,
|
|
2704
|
-
url ?? new URL(window.location.href),
|
|
2705
|
-
resolveClientUrl
|
|
2706
|
-
);
|
|
2707
2767
|
if (!this.reactRoot) {
|
|
2708
2768
|
Array.from(component.children).forEach((el) => {
|
|
2709
2769
|
if (!isRemoteComponent && el.tagName.toLowerCase() === "script") {
|
|
@@ -2778,7 +2838,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2778
2838
|
preloadScripts
|
|
2779
2839
|
} = await getRuntime(
|
|
2780
2840
|
metadataObj.runtime,
|
|
2781
|
-
|
|
2841
|
+
effectiveUrl,
|
|
2782
2842
|
this.bundle,
|
|
2783
2843
|
{
|
|
2784
2844
|
react: async () => (await import("react")).default,
|
|
@@ -2869,7 +2929,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2869
2929
|
if (isCurrentLoad()) {
|
|
2870
2930
|
this.hostState.stage = "loaded";
|
|
2871
2931
|
}
|
|
2872
|
-
this.
|
|
2932
|
+
this.emitter.load(this.src ?? "");
|
|
2873
2933
|
}, [initial, name]);
|
|
2874
2934
|
return Component;
|
|
2875
2935
|
};
|
|
@@ -2913,9 +2973,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2913
2973
|
if (isCurrentLoad()) {
|
|
2914
2974
|
remoteComponent.hostState.stage = "loaded";
|
|
2915
2975
|
}
|
|
2916
|
-
remoteComponent.
|
|
2917
|
-
src: remoteComponent.src
|
|
2918
|
-
});
|
|
2976
|
+
remoteComponent.emitter.load(remoteComponent.src ?? "");
|
|
2919
2977
|
}, [initial, remoteComponent]);
|
|
2920
2978
|
return NextApp ? /* @__PURE__ */ jsx2(NextApp, { Component: NextComponent, ...nextData.props }) : /* @__PURE__ */ jsx2(NextComponent, { ...nextData.props });
|
|
2921
2979
|
})(App, Component, this);
|
|
@@ -2956,9 +3014,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2956
3014
|
}
|
|
2957
3015
|
)
|
|
2958
3016
|
);
|
|
2959
|
-
this.
|
|
3017
|
+
this.emitter.load(this.src ?? "");
|
|
2960
3018
|
} else {
|
|
2961
|
-
this.
|
|
3019
|
+
this.emitter.load(this.src ?? "");
|
|
2962
3020
|
}
|
|
2963
3021
|
if (isCurrentLoad()) {
|
|
2964
3022
|
this.hostState.stage = "loaded";
|