@luzmo/embed 6.13.2 → 6.13.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/CHANGELOG.md +15 -0
- package/index.cjs +77 -2
- package/index.js +77 -2
- package/luzmo-embed.min.js +902 -277
- package/package.json +2 -2
- package/src/lib/dashboard/dashboard-base.d.ts +5 -0
- package/src/lib/iq-components/luzmo-iq-chat.d.ts +12 -0
- package/src/lib/viz-item/viz-item.base.d.ts +2 -0
package/luzmo-embed.min.js
CHANGED
|
@@ -1255,6 +1255,7 @@ var libraryTypeToWebComponentTypeMapping = {
|
|
|
1255
1255
|
filters: "filters",
|
|
1256
1256
|
dashboardId: "dashboard-id",
|
|
1257
1257
|
itemId: "item-id",
|
|
1258
|
+
aiMessageAssetId: "ai-message-asset-id",
|
|
1258
1259
|
dashboardContentsVersion: "dashboard-contents-version",
|
|
1259
1260
|
libVersion: "lib-version"
|
|
1260
1261
|
};
|
|
@@ -1659,6 +1660,8 @@ function createScript(info) {
|
|
|
1659
1660
|
function createLink(info) {
|
|
1660
1661
|
let link = null;
|
|
1661
1662
|
let needAttach = true;
|
|
1663
|
+
let timeout = 2e4;
|
|
1664
|
+
let timeoutId;
|
|
1662
1665
|
const links = document.getElementsByTagName("link");
|
|
1663
1666
|
for (let i7 = 0; i7 < links.length; i7++) {
|
|
1664
1667
|
const l3 = links[i7];
|
|
@@ -1674,19 +1677,42 @@ function createLink(info) {
|
|
|
1674
1677
|
link = document.createElement("link");
|
|
1675
1678
|
link.setAttribute("href", info.url);
|
|
1676
1679
|
let createLinkRes = void 0;
|
|
1680
|
+
let shouldApplyAttrs = true;
|
|
1677
1681
|
const attrs = info.attrs;
|
|
1678
1682
|
if (info.createLinkHook) {
|
|
1679
1683
|
createLinkRes = info.createLinkHook(info.url, attrs);
|
|
1680
|
-
if (createLinkRes instanceof HTMLLinkElement)
|
|
1684
|
+
if (createLinkRes instanceof HTMLLinkElement) {
|
|
1685
|
+
link = createLinkRes;
|
|
1686
|
+
shouldApplyAttrs = false;
|
|
1687
|
+
} else if (typeof createLinkRes === "object") {
|
|
1688
|
+
if ("link" in createLinkRes && createLinkRes.link) {
|
|
1689
|
+
link = createLinkRes.link;
|
|
1690
|
+
shouldApplyAttrs = false;
|
|
1691
|
+
}
|
|
1692
|
+
if ("timeout" in createLinkRes && createLinkRes.timeout) timeout = createLinkRes.timeout;
|
|
1693
|
+
}
|
|
1681
1694
|
}
|
|
1682
|
-
if (attrs &&
|
|
1695
|
+
if (attrs && shouldApplyAttrs) Object.keys(attrs).forEach((name) => {
|
|
1683
1696
|
if (link && !link.getAttribute(name)) link.setAttribute(name, attrs[name]);
|
|
1684
1697
|
});
|
|
1685
1698
|
}
|
|
1699
|
+
if (!needAttach) {
|
|
1700
|
+
Promise.resolve().then(() => {
|
|
1701
|
+
info?.cb && info?.cb();
|
|
1702
|
+
});
|
|
1703
|
+
return {
|
|
1704
|
+
link,
|
|
1705
|
+
needAttach
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1686
1708
|
const onLinkComplete = (prev, event) => {
|
|
1709
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
1687
1710
|
const onLinkCompleteCallback = () => {
|
|
1688
|
-
if (event?.type === "error")
|
|
1689
|
-
|
|
1711
|
+
if (event?.type === "error") {
|
|
1712
|
+
const linkError = /* @__PURE__ */ new Error(event?.isTimeout ? `LinkNetworkError: Link "${info.url}" timed out.` : `LinkNetworkError: Failed to load link "${info.url}" - the URL is unreachable or the server returned an error.`);
|
|
1713
|
+
linkError.name = "LinkNetworkError";
|
|
1714
|
+
info?.onErrorCallback && info?.onErrorCallback(linkError);
|
|
1715
|
+
} else info?.cb && info?.cb();
|
|
1690
1716
|
};
|
|
1691
1717
|
if (link) {
|
|
1692
1718
|
link.onerror = null;
|
|
@@ -1705,6 +1731,12 @@ function createLink(info) {
|
|
|
1705
1731
|
};
|
|
1706
1732
|
link.onerror = onLinkComplete.bind(null, link.onerror);
|
|
1707
1733
|
link.onload = onLinkComplete.bind(null, link.onload);
|
|
1734
|
+
timeoutId = setTimeout(() => {
|
|
1735
|
+
onLinkComplete(null, {
|
|
1736
|
+
type: "error",
|
|
1737
|
+
isTimeout: true
|
|
1738
|
+
});
|
|
1739
|
+
}, timeout);
|
|
1708
1740
|
return {
|
|
1709
1741
|
link,
|
|
1710
1742
|
needAttach
|
|
@@ -1986,8 +2018,8 @@ function setGlobalDefaultVal(target) {
|
|
|
1986
2018
|
}
|
|
1987
2019
|
setGlobalDefaultVal(CurrentGlobal);
|
|
1988
2020
|
setGlobalDefaultVal(nativeGlobal);
|
|
1989
|
-
function setGlobalFederationInstance(
|
|
1990
|
-
CurrentGlobal.__FEDERATION__.__INSTANCES__.push(
|
|
2021
|
+
function setGlobalFederationInstance(FederationInstance) {
|
|
2022
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance);
|
|
1991
2023
|
}
|
|
1992
2024
|
function getGlobalFederationConstructor() {
|
|
1993
2025
|
return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
|
|
@@ -1995,7 +2027,7 @@ function getGlobalFederationConstructor() {
|
|
|
1995
2027
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
1996
2028
|
if (isDebug) {
|
|
1997
2029
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
1998
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.
|
|
2030
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.5.1";
|
|
1999
2031
|
}
|
|
2000
2032
|
}
|
|
2001
2033
|
function getInfoWithoutType(target, key) {
|
|
@@ -2579,6 +2611,10 @@ function directShare(shared, useTreesShaking) {
|
|
|
2579
2611
|
}
|
|
2580
2612
|
|
|
2581
2613
|
// node_modules/@module-federation/runtime-core/dist/utils/manifest.js
|
|
2614
|
+
function composeRemoteRequestId(remoteName, expose) {
|
|
2615
|
+
if (!expose || expose === ".") return remoteName;
|
|
2616
|
+
return `${remoteName}/${expose.replace(/^\.\//, "")}`;
|
|
2617
|
+
}
|
|
2582
2618
|
function matchRemoteWithNameAndExpose(remotes, id) {
|
|
2583
2619
|
for (const remote of remotes) {
|
|
2584
2620
|
const isNameMatched = id.startsWith(remote.name);
|
|
@@ -2637,6 +2673,9 @@ var RUNTIME_009 = "RUNTIME-009";
|
|
|
2637
2673
|
var RUNTIME_010 = "RUNTIME-010";
|
|
2638
2674
|
var RUNTIME_011 = "RUNTIME-011";
|
|
2639
2675
|
var RUNTIME_012 = "RUNTIME-012";
|
|
2676
|
+
var RUNTIME_013 = "RUNTIME-013";
|
|
2677
|
+
var RUNTIME_014 = "RUNTIME-014";
|
|
2678
|
+
var RUNTIME_015 = "RUNTIME-015";
|
|
2640
2679
|
var TYPE_001 = "TYPE-001";
|
|
2641
2680
|
var BUILD_001 = "BUILD-001";
|
|
2642
2681
|
var BUILD_002 = "BUILD-002";
|
|
@@ -2654,7 +2693,10 @@ var runtimeDescMap = {
|
|
|
2654
2693
|
[RUNTIME_009]: "Please call createInstance first.",
|
|
2655
2694
|
[RUNTIME_010]: 'The name option cannot be changed after initialization. If you want to create a new instance with a different name, please use "createInstance" api.',
|
|
2656
2695
|
[RUNTIME_011]: "The remoteEntry URL is missing from the remote snapshot.",
|
|
2657
|
-
[RUNTIME_012]: 'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.'
|
|
2696
|
+
[RUNTIME_012]: 'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.',
|
|
2697
|
+
[RUNTIME_013]: "The manifest is not a valid Module Federation manifest.",
|
|
2698
|
+
[RUNTIME_014]: "The remote does not expose the requested module.",
|
|
2699
|
+
[RUNTIME_015]: "Remote container initialization failed."
|
|
2658
2700
|
};
|
|
2659
2701
|
var typeDescMap = { [TYPE_001]: "Failed to generate type declaration. Execute the below cmd to reproduce and fix the error." };
|
|
2660
2702
|
var buildDescMap = {
|
|
@@ -2704,7 +2746,7 @@ function handleRemoteEntryLoaded(name, globalName, entry) {
|
|
|
2704
2746
|
});
|
|
2705
2747
|
return entryExports;
|
|
2706
2748
|
}
|
|
2707
|
-
async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl }) {
|
|
2749
|
+
async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl, resourceContext }) {
|
|
2708
2750
|
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
2709
2751
|
if (remoteEntryExports) return remoteEntryExports;
|
|
2710
2752
|
const url = getEntryUrl ? getEntryUrl(entry) : entry;
|
|
@@ -2714,7 +2756,11 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
2714
2756
|
const res = loaderHook.lifecycle.createScript.emit({
|
|
2715
2757
|
url: url2,
|
|
2716
2758
|
attrs,
|
|
2717
|
-
remoteInfo
|
|
2759
|
+
remoteInfo,
|
|
2760
|
+
resourceContext: resourceContext ? {
|
|
2761
|
+
...resourceContext,
|
|
2762
|
+
url: url2
|
|
2763
|
+
} : void 0
|
|
2718
2764
|
});
|
|
2719
2765
|
if (!res) return;
|
|
2720
2766
|
if (res instanceof HTMLScriptElement) return res;
|
|
@@ -2730,7 +2776,7 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
2730
2776
|
}, originalMsg);
|
|
2731
2777
|
});
|
|
2732
2778
|
}
|
|
2733
|
-
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl }) {
|
|
2779
|
+
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {
|
|
2734
2780
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
2735
2781
|
switch (type) {
|
|
2736
2782
|
case "esm":
|
|
@@ -2751,11 +2797,12 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEnt
|
|
|
2751
2797
|
name,
|
|
2752
2798
|
remoteInfo,
|
|
2753
2799
|
loaderHook,
|
|
2754
|
-
getEntryUrl
|
|
2800
|
+
getEntryUrl,
|
|
2801
|
+
resourceContext
|
|
2755
2802
|
});
|
|
2756
2803
|
}
|
|
2757
2804
|
}
|
|
2758
|
-
async function loadEntryNode({ remoteInfo, loaderHook }) {
|
|
2805
|
+
async function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {
|
|
2759
2806
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
2760
2807
|
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
2761
2808
|
if (remoteEntryExports) return remoteEntryExports;
|
|
@@ -2769,7 +2816,11 @@ async function loadEntryNode({ remoteInfo, loaderHook }) {
|
|
|
2769
2816
|
const res = loaderHook.lifecycle.createScript.emit({
|
|
2770
2817
|
url,
|
|
2771
2818
|
attrs,
|
|
2772
|
-
remoteInfo
|
|
2819
|
+
remoteInfo,
|
|
2820
|
+
resourceContext: resourceContext ? {
|
|
2821
|
+
...resourceContext,
|
|
2822
|
+
url
|
|
2823
|
+
} : void 0
|
|
2773
2824
|
});
|
|
2774
2825
|
if (!res) return;
|
|
2775
2826
|
if ("url" in res) return res;
|
|
@@ -2785,13 +2836,14 @@ function getRemoteEntryUniqueKey(remoteInfo) {
|
|
|
2785
2836
|
return composeKeyWithSeparator(name, entry);
|
|
2786
2837
|
}
|
|
2787
2838
|
async function getRemoteEntry(params) {
|
|
2788
|
-
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, _inErrorHandling = false } = params;
|
|
2839
|
+
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;
|
|
2789
2840
|
const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
2790
2841
|
if (remoteEntryExports) return remoteEntryExports;
|
|
2791
2842
|
if (!globalLoading[uniqueKey]) {
|
|
2792
2843
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
2793
2844
|
const loaderHook = origin.loaderHook;
|
|
2794
2845
|
globalLoading[uniqueKey] = loadEntryHook.emit({
|
|
2846
|
+
origin,
|
|
2795
2847
|
loaderHook,
|
|
2796
2848
|
remoteInfo,
|
|
2797
2849
|
remoteEntryExports
|
|
@@ -2801,11 +2853,20 @@ async function getRemoteEntry(params) {
|
|
|
2801
2853
|
remoteInfo,
|
|
2802
2854
|
remoteEntryExports,
|
|
2803
2855
|
loaderHook,
|
|
2804
|
-
getEntryUrl
|
|
2856
|
+
getEntryUrl,
|
|
2857
|
+
resourceContext
|
|
2805
2858
|
}) : loadEntryNode({
|
|
2806
2859
|
remoteInfo,
|
|
2807
|
-
loaderHook
|
|
2860
|
+
loaderHook,
|
|
2861
|
+
resourceContext
|
|
2862
|
+
});
|
|
2863
|
+
}).then(async (res) => {
|
|
2864
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
2865
|
+
origin,
|
|
2866
|
+
remoteInfo,
|
|
2867
|
+
remoteEntryExports: res
|
|
2808
2868
|
});
|
|
2869
|
+
return res;
|
|
2809
2870
|
}).catch(async (err) => {
|
|
2810
2871
|
const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
|
|
2811
2872
|
const isScriptExecutionError = err instanceof Error && err.message.includes("ScriptExecutionError");
|
|
@@ -2824,8 +2885,21 @@ async function getRemoteEntry(params) {
|
|
|
2824
2885
|
globalLoading,
|
|
2825
2886
|
uniqueKey: uniqueKey2
|
|
2826
2887
|
});
|
|
2827
|
-
if (RemoteEntryExports)
|
|
2888
|
+
if (RemoteEntryExports) {
|
|
2889
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
2890
|
+
origin,
|
|
2891
|
+
remoteInfo,
|
|
2892
|
+
remoteEntryExports: RemoteEntryExports,
|
|
2893
|
+
recovered: true
|
|
2894
|
+
});
|
|
2895
|
+
return RemoteEntryExports;
|
|
2896
|
+
}
|
|
2828
2897
|
}
|
|
2898
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
2899
|
+
origin,
|
|
2900
|
+
remoteInfo,
|
|
2901
|
+
error: err
|
|
2902
|
+
});
|
|
2829
2903
|
throw err;
|
|
2830
2904
|
});
|
|
2831
2905
|
}
|
|
@@ -2935,22 +3009,113 @@ function normalizePreloadExposes(exposes) {
|
|
|
2935
3009
|
return expose;
|
|
2936
3010
|
});
|
|
2937
3011
|
}
|
|
2938
|
-
function
|
|
3012
|
+
function isTimeoutError(error3) {
|
|
3013
|
+
if (!(error3 instanceof Error)) return false;
|
|
3014
|
+
return error3.message.includes("timed out") || error3.name.includes("Timeout");
|
|
3015
|
+
}
|
|
3016
|
+
function createAssetResult(context, url, status, error3) {
|
|
3017
|
+
return {
|
|
3018
|
+
url,
|
|
3019
|
+
status,
|
|
3020
|
+
resourceType: context.resourceType,
|
|
3021
|
+
initiator: context.initiator,
|
|
3022
|
+
id: context.id,
|
|
3023
|
+
error: error3
|
|
3024
|
+
};
|
|
3025
|
+
}
|
|
3026
|
+
async function waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, context) {
|
|
3027
|
+
const cachedRemote = host.moduleCache.get(entryRemoteInfo.name);
|
|
3028
|
+
const url = entryRemoteInfo.entry;
|
|
3029
|
+
if (cachedRemote?.remoteEntryExports) return createAssetResult(context, url, "cached");
|
|
3030
|
+
try {
|
|
3031
|
+
if (!await getRemoteEntry({
|
|
3032
|
+
origin: host,
|
|
3033
|
+
remoteInfo: entryRemoteInfo,
|
|
3034
|
+
remoteEntryExports: cachedRemote?.remoteEntryExports,
|
|
3035
|
+
resourceContext: {
|
|
3036
|
+
...context,
|
|
3037
|
+
url
|
|
3038
|
+
}
|
|
3039
|
+
})) throw new Error(`Failed to load remoteEntry "${url}".`);
|
|
3040
|
+
return createAssetResult(context, url, "success");
|
|
3041
|
+
} catch (error3) {
|
|
3042
|
+
return createAssetResult(context, url, isTimeoutError(error3) ? "timeout" : "error", error3);
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
function waitForLinkPreload({ host, remoteInfo, url, attrs, context, needDeleteLink }) {
|
|
3046
|
+
return new Promise((resolve) => {
|
|
3047
|
+
const { link, needAttach } = createLink({
|
|
3048
|
+
url,
|
|
3049
|
+
cb: () => {
|
|
3050
|
+
resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));
|
|
3051
|
+
},
|
|
3052
|
+
onErrorCallback: (error3) => {
|
|
3053
|
+
resolve(createAssetResult(context, url, isTimeoutError(error3) ? "timeout" : "error", error3));
|
|
3054
|
+
},
|
|
3055
|
+
attrs,
|
|
3056
|
+
createLinkHook: (hookUrl, hookAttrs) => {
|
|
3057
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
3058
|
+
url: hookUrl,
|
|
3059
|
+
attrs: hookAttrs,
|
|
3060
|
+
remoteInfo,
|
|
3061
|
+
resourceContext: {
|
|
3062
|
+
...context,
|
|
3063
|
+
url: hookUrl
|
|
3064
|
+
}
|
|
3065
|
+
});
|
|
3066
|
+
if (res instanceof HTMLLinkElement) return res;
|
|
3067
|
+
return res;
|
|
3068
|
+
},
|
|
3069
|
+
needDeleteLink
|
|
3070
|
+
});
|
|
3071
|
+
needAttach && document.head.appendChild(link);
|
|
3072
|
+
});
|
|
3073
|
+
}
|
|
3074
|
+
function waitForScriptPreload({ host, remoteInfo, url, attrs, context }) {
|
|
3075
|
+
return new Promise((resolve) => {
|
|
3076
|
+
const { script, needAttach } = createScript({
|
|
3077
|
+
url,
|
|
3078
|
+
cb: () => {
|
|
3079
|
+
resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));
|
|
3080
|
+
},
|
|
3081
|
+
onErrorCallback: (error3) => {
|
|
3082
|
+
resolve(createAssetResult(context, url, isTimeoutError(error3) ? "timeout" : "error", error3));
|
|
3083
|
+
},
|
|
3084
|
+
attrs,
|
|
3085
|
+
createScriptHook: (hookUrl, hookAttrs) => {
|
|
3086
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
3087
|
+
url: hookUrl,
|
|
3088
|
+
attrs: hookAttrs,
|
|
3089
|
+
remoteInfo,
|
|
3090
|
+
resourceContext: {
|
|
3091
|
+
...context,
|
|
3092
|
+
url: hookUrl
|
|
3093
|
+
}
|
|
3094
|
+
});
|
|
3095
|
+
if (res instanceof HTMLScriptElement) return res;
|
|
3096
|
+
return res;
|
|
3097
|
+
},
|
|
3098
|
+
needDeleteScript: true
|
|
3099
|
+
});
|
|
3100
|
+
needAttach && document.head.appendChild(script);
|
|
3101
|
+
});
|
|
3102
|
+
}
|
|
3103
|
+
function createResourceContext(baseContext, resourceType) {
|
|
3104
|
+
return {
|
|
3105
|
+
...baseContext,
|
|
3106
|
+
resourceType
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseContext = {
|
|
3110
|
+
initiator: "preloadRemote",
|
|
3111
|
+
id: remoteInfo.name
|
|
3112
|
+
}) {
|
|
2939
3113
|
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
3114
|
+
const results = [];
|
|
2940
3115
|
if (host.options.inBrowser) {
|
|
2941
3116
|
entryAssets.forEach((asset) => {
|
|
2942
|
-
const { moduleInfo } = asset;
|
|
2943
|
-
|
|
2944
|
-
if (module2) getRemoteEntry({
|
|
2945
|
-
origin: host,
|
|
2946
|
-
remoteInfo: moduleInfo,
|
|
2947
|
-
remoteEntryExports: module2.remoteEntryExports
|
|
2948
|
-
});
|
|
2949
|
-
else getRemoteEntry({
|
|
2950
|
-
origin: host,
|
|
2951
|
-
remoteInfo: moduleInfo,
|
|
2952
|
-
remoteEntryExports: void 0
|
|
2953
|
-
});
|
|
3117
|
+
const { moduleInfo: entryRemoteInfo } = asset;
|
|
3118
|
+
results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));
|
|
2954
3119
|
});
|
|
2955
3120
|
if (useLinkPreload) {
|
|
2956
3121
|
const defaultAttrs = {
|
|
@@ -2958,21 +3123,13 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
2958
3123
|
as: "style"
|
|
2959
3124
|
};
|
|
2960
3125
|
cssAssets.forEach((cssUrl) => {
|
|
2961
|
-
|
|
3126
|
+
results.push(waitForLinkPreload({
|
|
3127
|
+
host,
|
|
3128
|
+
remoteInfo,
|
|
2962
3129
|
url: cssUrl,
|
|
2963
|
-
cb: () => {
|
|
2964
|
-
},
|
|
2965
3130
|
attrs: defaultAttrs,
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
url,
|
|
2969
|
-
attrs,
|
|
2970
|
-
remoteInfo
|
|
2971
|
-
});
|
|
2972
|
-
if (res instanceof HTMLLinkElement) return res;
|
|
2973
|
-
}
|
|
2974
|
-
});
|
|
2975
|
-
needAttach && document.head.appendChild(cssEl);
|
|
3131
|
+
context: createResourceContext(baseContext, "css")
|
|
3132
|
+
}));
|
|
2976
3133
|
});
|
|
2977
3134
|
} else {
|
|
2978
3135
|
const defaultAttrs = {
|
|
@@ -2980,22 +3137,14 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
2980
3137
|
type: "text/css"
|
|
2981
3138
|
};
|
|
2982
3139
|
cssAssets.forEach((cssUrl) => {
|
|
2983
|
-
|
|
3140
|
+
results.push(waitForLinkPreload({
|
|
3141
|
+
host,
|
|
3142
|
+
remoteInfo,
|
|
2984
3143
|
url: cssUrl,
|
|
2985
|
-
cb: () => {
|
|
2986
|
-
},
|
|
2987
3144
|
attrs: defaultAttrs,
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
attrs,
|
|
2992
|
-
remoteInfo
|
|
2993
|
-
});
|
|
2994
|
-
if (res instanceof HTMLLinkElement) return res;
|
|
2995
|
-
},
|
|
2996
|
-
needDeleteLink: false
|
|
2997
|
-
});
|
|
2998
|
-
needAttach && document.head.appendChild(cssEl);
|
|
3145
|
+
needDeleteLink: false,
|
|
3146
|
+
context: createResourceContext(baseContext, "css")
|
|
3147
|
+
}));
|
|
2999
3148
|
});
|
|
3000
3149
|
}
|
|
3001
3150
|
if (useLinkPreload) {
|
|
@@ -3004,21 +3153,13 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
3004
3153
|
as: "script"
|
|
3005
3154
|
};
|
|
3006
3155
|
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
3007
|
-
|
|
3156
|
+
results.push(waitForLinkPreload({
|
|
3157
|
+
host,
|
|
3158
|
+
remoteInfo,
|
|
3008
3159
|
url: jsUrl,
|
|
3009
|
-
cb: () => {
|
|
3010
|
-
},
|
|
3011
3160
|
attrs: defaultAttrs,
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
url,
|
|
3015
|
-
attrs,
|
|
3016
|
-
remoteInfo
|
|
3017
|
-
});
|
|
3018
|
-
if (res instanceof HTMLLinkElement) return res;
|
|
3019
|
-
}
|
|
3020
|
-
});
|
|
3021
|
-
needAttach && document.head.appendChild(linkEl);
|
|
3161
|
+
context: createResourceContext(baseContext, "js")
|
|
3162
|
+
}));
|
|
3022
3163
|
});
|
|
3023
3164
|
} else {
|
|
3024
3165
|
const defaultAttrs = {
|
|
@@ -3026,28 +3167,25 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
3026
3167
|
type: remoteInfo?.type === "module" ? "module" : "text/javascript"
|
|
3027
3168
|
};
|
|
3028
3169
|
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
3029
|
-
|
|
3170
|
+
results.push(waitForScriptPreload({
|
|
3171
|
+
host,
|
|
3172
|
+
remoteInfo,
|
|
3030
3173
|
url: jsUrl,
|
|
3031
|
-
cb: () => {
|
|
3032
|
-
},
|
|
3033
3174
|
attrs: defaultAttrs,
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
url,
|
|
3037
|
-
attrs,
|
|
3038
|
-
remoteInfo
|
|
3039
|
-
});
|
|
3040
|
-
if (res instanceof HTMLScriptElement) return res;
|
|
3041
|
-
},
|
|
3042
|
-
needDeleteScript: true
|
|
3043
|
-
});
|
|
3044
|
-
needAttach && document.head.appendChild(scriptEl);
|
|
3175
|
+
context: createResourceContext(baseContext, "js")
|
|
3176
|
+
}));
|
|
3045
3177
|
});
|
|
3046
3178
|
}
|
|
3047
3179
|
}
|
|
3180
|
+
return Promise.all(results);
|
|
3048
3181
|
}
|
|
3049
3182
|
|
|
3050
3183
|
// node_modules/@module-federation/runtime-core/dist/module/index.js
|
|
3184
|
+
function getAvailableExposeNames(remoteSnapshot) {
|
|
3185
|
+
if (!remoteSnapshot || !("modules" in remoteSnapshot) || !Array.isArray(remoteSnapshot.modules)) return;
|
|
3186
|
+
const exposes = remoteSnapshot.modules.map((module2) => module2.moduleName).filter(Boolean);
|
|
3187
|
+
return exposes.length ? exposes.join(",") : void 0;
|
|
3188
|
+
}
|
|
3051
3189
|
function createRemoteEntryInitOptions(remoteInfo, hostShareScopeMap, rawInitScope) {
|
|
3052
3190
|
const localShareScopeMap = hostShareScopeMap;
|
|
3053
3191
|
const shareScopeKeys = Array.isArray(remoteInfo.shareScope) ? remoteInfo.shareScope : [remoteInfo.shareScope];
|
|
@@ -3077,27 +3215,69 @@ var Module$1 = class {
|
|
|
3077
3215
|
this.remoteInfo = remoteInfo;
|
|
3078
3216
|
this.host = host;
|
|
3079
3217
|
}
|
|
3080
|
-
async getEntry() {
|
|
3218
|
+
async getEntry(expose) {
|
|
3081
3219
|
if (this.remoteEntryExports) return this.remoteEntryExports;
|
|
3082
3220
|
const remoteEntryExports = await getRemoteEntry({
|
|
3083
3221
|
origin: this.host,
|
|
3084
3222
|
remoteInfo: this.remoteInfo,
|
|
3085
|
-
remoteEntryExports: this.remoteEntryExports
|
|
3223
|
+
remoteEntryExports: this.remoteEntryExports,
|
|
3224
|
+
resourceContext: {
|
|
3225
|
+
initiator: "loadRemote",
|
|
3226
|
+
id: composeRemoteRequestId(this.remoteInfo.name, expose),
|
|
3227
|
+
resourceType: "remoteEntry"
|
|
3228
|
+
}
|
|
3086
3229
|
});
|
|
3087
3230
|
assert2(remoteEntryExports, `remoteEntryExports is undefined
|
|
3088
3231
|
${safeToString(this.remoteInfo)}`);
|
|
3089
3232
|
this.remoteEntryExports = remoteEntryExports;
|
|
3090
3233
|
return this.remoteEntryExports;
|
|
3091
3234
|
}
|
|
3092
|
-
async init(id, remoteSnapshot, rawInitScope) {
|
|
3093
|
-
const remoteEntryExports = await this.getEntry();
|
|
3094
|
-
if (this.inited)
|
|
3235
|
+
async init(id, remoteSnapshot, rawInitScope, expose) {
|
|
3236
|
+
const remoteEntryExports = await this.getEntry(expose);
|
|
3237
|
+
if (this.inited) {
|
|
3238
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
3239
|
+
id,
|
|
3240
|
+
remoteInfo: this.remoteInfo,
|
|
3241
|
+
remoteSnapshot,
|
|
3242
|
+
remoteEntryExports,
|
|
3243
|
+
cached: true,
|
|
3244
|
+
origin: this.host
|
|
3245
|
+
});
|
|
3246
|
+
return remoteEntryExports;
|
|
3247
|
+
}
|
|
3095
3248
|
if (this.initPromise) {
|
|
3096
|
-
|
|
3249
|
+
try {
|
|
3250
|
+
await this.initPromise;
|
|
3251
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
3252
|
+
id,
|
|
3253
|
+
remoteInfo: this.remoteInfo,
|
|
3254
|
+
remoteSnapshot,
|
|
3255
|
+
remoteEntryExports,
|
|
3256
|
+
cached: true,
|
|
3257
|
+
origin: this.host
|
|
3258
|
+
});
|
|
3259
|
+
} catch (initError) {
|
|
3260
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
3261
|
+
id,
|
|
3262
|
+
remoteInfo: this.remoteInfo,
|
|
3263
|
+
remoteSnapshot,
|
|
3264
|
+
remoteEntryExports,
|
|
3265
|
+
error: initError,
|
|
3266
|
+
cached: true,
|
|
3267
|
+
origin: this.host
|
|
3268
|
+
});
|
|
3269
|
+
throw initError;
|
|
3270
|
+
}
|
|
3097
3271
|
return remoteEntryExports;
|
|
3098
3272
|
}
|
|
3099
3273
|
this.initing = true;
|
|
3100
3274
|
this.initPromise = (async () => {
|
|
3275
|
+
await this.host.loaderHook.lifecycle.beforeInitRemote.emit({
|
|
3276
|
+
id,
|
|
3277
|
+
remoteInfo: this.remoteInfo,
|
|
3278
|
+
remoteSnapshot,
|
|
3279
|
+
origin: this.host
|
|
3280
|
+
});
|
|
3101
3281
|
const { remoteEntryInitOptions, shareScope, initScope } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap, rawInitScope);
|
|
3102
3282
|
const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
3103
3283
|
shareScope,
|
|
@@ -3112,7 +3292,17 @@ var Module$1 = class {
|
|
|
3112
3292
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
3113
3293
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
3114
3294
|
}, void 0, optionsToMFContext(this.host.options));
|
|
3115
|
-
|
|
3295
|
+
try {
|
|
3296
|
+
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
3297
|
+
} catch (initError) {
|
|
3298
|
+
error2(RUNTIME_015, runtimeDescMap, {
|
|
3299
|
+
hostName: this.host.name,
|
|
3300
|
+
remoteName: this.remoteInfo.name,
|
|
3301
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
3302
|
+
remoteEntryKey: this.remoteInfo.entryGlobalName,
|
|
3303
|
+
shareScope: this.remoteInfo.shareScope
|
|
3304
|
+
}, `${initError}`, optionsToMFContext(this.host.options));
|
|
3305
|
+
}
|
|
3116
3306
|
await this.host.hooks.lifecycle.initContainer.emit({
|
|
3117
3307
|
...initContainerOptions,
|
|
3118
3308
|
id,
|
|
@@ -3123,6 +3313,23 @@ var Module$1 = class {
|
|
|
3123
3313
|
})();
|
|
3124
3314
|
try {
|
|
3125
3315
|
await this.initPromise;
|
|
3316
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
3317
|
+
id,
|
|
3318
|
+
remoteInfo: this.remoteInfo,
|
|
3319
|
+
remoteSnapshot,
|
|
3320
|
+
remoteEntryExports,
|
|
3321
|
+
origin: this.host
|
|
3322
|
+
});
|
|
3323
|
+
} catch (initError) {
|
|
3324
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
3325
|
+
id,
|
|
3326
|
+
remoteInfo: this.remoteInfo,
|
|
3327
|
+
remoteSnapshot,
|
|
3328
|
+
remoteEntryExports,
|
|
3329
|
+
error: initError,
|
|
3330
|
+
origin: this.host
|
|
3331
|
+
});
|
|
3332
|
+
throw initError;
|
|
3126
3333
|
} finally {
|
|
3127
3334
|
this.initing = false;
|
|
3128
3335
|
this.initPromise = void 0;
|
|
@@ -3131,20 +3338,83 @@ var Module$1 = class {
|
|
|
3131
3338
|
}
|
|
3132
3339
|
async get(id, expose, options, remoteSnapshot) {
|
|
3133
3340
|
const { loadFactory = true } = options || { loadFactory: true };
|
|
3134
|
-
const remoteEntryExports = await this.init(id, remoteSnapshot);
|
|
3341
|
+
const remoteEntryExports = await this.init(id, remoteSnapshot, void 0, expose);
|
|
3135
3342
|
this.lib = remoteEntryExports;
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
remoteEntryExports,
|
|
3343
|
+
await this.host.loaderHook.lifecycle.beforeGetExpose.emit({
|
|
3344
|
+
id,
|
|
3139
3345
|
expose,
|
|
3140
|
-
moduleInfo: this.remoteInfo
|
|
3346
|
+
moduleInfo: this.remoteInfo,
|
|
3347
|
+
remoteEntryExports,
|
|
3348
|
+
origin: this.host
|
|
3141
3349
|
});
|
|
3142
|
-
|
|
3143
|
-
|
|
3350
|
+
let moduleFactory;
|
|
3351
|
+
try {
|
|
3352
|
+
const hookModuleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
3353
|
+
remoteEntryExports,
|
|
3354
|
+
expose,
|
|
3355
|
+
moduleInfo: this.remoteInfo
|
|
3356
|
+
});
|
|
3357
|
+
moduleFactory = typeof hookModuleFactory === "function" ? hookModuleFactory : void 0;
|
|
3358
|
+
if (!moduleFactory) moduleFactory = await remoteEntryExports.get(expose);
|
|
3359
|
+
if (!moduleFactory) error2(RUNTIME_014, runtimeDescMap, {
|
|
3360
|
+
hostName: this.host.name,
|
|
3361
|
+
remoteName: this.remoteInfo.name,
|
|
3362
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
3363
|
+
expose,
|
|
3364
|
+
requestId: id,
|
|
3365
|
+
availableExposes: getAvailableExposeNames(remoteSnapshot)
|
|
3366
|
+
}, void 0, optionsToMFContext(this.host.options));
|
|
3367
|
+
await this.host.loaderHook.lifecycle.afterGetExpose.emit({
|
|
3368
|
+
id,
|
|
3369
|
+
expose,
|
|
3370
|
+
moduleInfo: this.remoteInfo,
|
|
3371
|
+
remoteEntryExports,
|
|
3372
|
+
moduleFactory,
|
|
3373
|
+
origin: this.host
|
|
3374
|
+
});
|
|
3375
|
+
} catch (getExposeError) {
|
|
3376
|
+
await this.host.loaderHook.lifecycle.afterGetExpose.emit({
|
|
3377
|
+
id,
|
|
3378
|
+
expose,
|
|
3379
|
+
moduleInfo: this.remoteInfo,
|
|
3380
|
+
remoteEntryExports,
|
|
3381
|
+
error: getExposeError,
|
|
3382
|
+
origin: this.host
|
|
3383
|
+
});
|
|
3384
|
+
throw getExposeError;
|
|
3385
|
+
}
|
|
3144
3386
|
const symbolName = processModuleAlias(this.remoteInfo.name, expose);
|
|
3145
3387
|
const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
|
|
3146
3388
|
if (!loadFactory) return wrapModuleFactory;
|
|
3147
|
-
|
|
3389
|
+
await this.host.loaderHook.lifecycle.beforeExecuteFactory.emit({
|
|
3390
|
+
id,
|
|
3391
|
+
expose,
|
|
3392
|
+
moduleInfo: this.remoteInfo,
|
|
3393
|
+
loadFactory,
|
|
3394
|
+
origin: this.host
|
|
3395
|
+
});
|
|
3396
|
+
try {
|
|
3397
|
+
const exposeContent = await wrapModuleFactory();
|
|
3398
|
+
await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
|
|
3399
|
+
id,
|
|
3400
|
+
expose,
|
|
3401
|
+
moduleInfo: this.remoteInfo,
|
|
3402
|
+
loadFactory,
|
|
3403
|
+
exposeModule: exposeContent,
|
|
3404
|
+
origin: this.host
|
|
3405
|
+
});
|
|
3406
|
+
return exposeContent;
|
|
3407
|
+
} catch (executeFactoryError) {
|
|
3408
|
+
await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
|
|
3409
|
+
id,
|
|
3410
|
+
expose,
|
|
3411
|
+
moduleInfo: this.remoteInfo,
|
|
3412
|
+
loadFactory,
|
|
3413
|
+
error: executeFactoryError,
|
|
3414
|
+
origin: this.host
|
|
3415
|
+
});
|
|
3416
|
+
throw executeFactoryError;
|
|
3417
|
+
}
|
|
3148
3418
|
}
|
|
3149
3419
|
wraperFactory(moduleFactory, id) {
|
|
3150
3420
|
function defineModuleId(res, id2) {
|
|
@@ -3153,13 +3423,12 @@ var Module$1 = class {
|
|
|
3153
3423
|
enumerable: false
|
|
3154
3424
|
});
|
|
3155
3425
|
}
|
|
3156
|
-
|
|
3157
|
-
const res = await moduleFactory();
|
|
3158
|
-
defineModuleId(res, id);
|
|
3159
|
-
return res;
|
|
3160
|
-
};
|
|
3161
|
-
else return () => {
|
|
3426
|
+
return () => {
|
|
3162
3427
|
const res = moduleFactory();
|
|
3428
|
+
if (res instanceof Promise) return res.then((asyncRes) => {
|
|
3429
|
+
defineModuleId(asyncRes, id);
|
|
3430
|
+
return asyncRes;
|
|
3431
|
+
});
|
|
3163
3432
|
defineModuleId(res, id);
|
|
3164
3433
|
return res;
|
|
3165
3434
|
};
|
|
@@ -3186,7 +3455,8 @@ var SyncHook = class {
|
|
|
3186
3455
|
emit(...data) {
|
|
3187
3456
|
let result;
|
|
3188
3457
|
if (this.listeners.size > 0) this.listeners.forEach((fn) => {
|
|
3189
|
-
|
|
3458
|
+
const nextResult = fn(...data);
|
|
3459
|
+
if (nextResult !== void 0) result = nextResult;
|
|
3190
3460
|
});
|
|
3191
3461
|
return result;
|
|
3192
3462
|
}
|
|
@@ -3207,7 +3477,10 @@ var AsyncHook = class extends SyncHook {
|
|
|
3207
3477
|
let i7 = 0;
|
|
3208
3478
|
const call = (prev) => {
|
|
3209
3479
|
if (prev === false) return false;
|
|
3210
|
-
else if (i7 < ls.length) return Promise.resolve(ls[i7++].apply(null, data)).then(
|
|
3480
|
+
else if (i7 < ls.length) return Promise.resolve(ls[i7++].apply(null, data)).then((result2) => {
|
|
3481
|
+
if (result2 === void 0 || data.length === 1 && result2 === data[0]) return call(prev);
|
|
3482
|
+
return call(result2);
|
|
3483
|
+
});
|
|
3211
3484
|
else return prev;
|
|
3212
3485
|
};
|
|
3213
3486
|
result = call();
|
|
@@ -3234,6 +3507,7 @@ var SyncWaterfallHook = class extends SyncHook {
|
|
|
3234
3507
|
if (!isObject2(data)) error2(`The data for the "${this.type}" hook should be an object.`);
|
|
3235
3508
|
for (const fn of this.listeners) try {
|
|
3236
3509
|
const tempData = fn(data);
|
|
3510
|
+
if (tempData === void 0) continue;
|
|
3237
3511
|
if (checkReturnData(data, tempData)) data = tempData;
|
|
3238
3512
|
else {
|
|
3239
3513
|
this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
|
|
@@ -3265,14 +3539,16 @@ var AsyncWaterfallHook = class extends SyncHook {
|
|
|
3265
3539
|
return data;
|
|
3266
3540
|
};
|
|
3267
3541
|
const call = (prevData) => {
|
|
3268
|
-
if (checkReturnData(data, prevData))
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
}
|
|
3542
|
+
if (prevData !== void 0 && checkReturnData(data, prevData)) data = prevData;
|
|
3543
|
+
else if (prevData !== void 0) {
|
|
3544
|
+
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
3545
|
+
return data;
|
|
3546
|
+
}
|
|
3547
|
+
if (i7 < ls.length) try {
|
|
3548
|
+
return Promise.resolve(ls[i7++](data)).then(call, processError);
|
|
3549
|
+
} catch (e7) {
|
|
3550
|
+
return processError(e7);
|
|
3551
|
+
}
|
|
3276
3552
|
return data;
|
|
3277
3553
|
};
|
|
3278
3554
|
return Promise.resolve(call(data));
|
|
@@ -3331,7 +3607,7 @@ function snapshotPlugin() {
|
|
|
3331
3607
|
if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
|
|
3332
3608
|
const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo({
|
|
3333
3609
|
moduleInfo: remote,
|
|
3334
|
-
id
|
|
3610
|
+
id: composeRemoteRequestId(remote.name, expose)
|
|
3335
3611
|
});
|
|
3336
3612
|
assignRemoteInfo(remoteInfo, remoteSnapshot);
|
|
3337
3613
|
const preloadOptions = {
|
|
@@ -3352,7 +3628,10 @@ function snapshotPlugin() {
|
|
|
3352
3628
|
remoteSnapshot,
|
|
3353
3629
|
globalSnapshot
|
|
3354
3630
|
});
|
|
3355
|
-
if (assets) preloadAssets(remoteInfo, origin, assets, false
|
|
3631
|
+
if (assets) preloadAssets(remoteInfo, origin, assets, false, {
|
|
3632
|
+
initiator: "loadRemote",
|
|
3633
|
+
id
|
|
3634
|
+
}).catch(() => void 0);
|
|
3356
3635
|
return {
|
|
3357
3636
|
...args,
|
|
3358
3637
|
remoteSnapshot
|
|
@@ -3572,11 +3851,12 @@ var SnapshotHandler = class {
|
|
|
3572
3851
|
this.HostInstance = HostInstance;
|
|
3573
3852
|
this.loaderHook = HostInstance.loaderHook;
|
|
3574
3853
|
}
|
|
3575
|
-
async loadRemoteSnapshotInfo({ moduleInfo, id,
|
|
3854
|
+
async loadRemoteSnapshotInfo({ moduleInfo, id, initiator = "loadRemote" }) {
|
|
3576
3855
|
const { options } = this.HostInstance;
|
|
3577
3856
|
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
3578
3857
|
options,
|
|
3579
|
-
moduleInfo
|
|
3858
|
+
moduleInfo,
|
|
3859
|
+
origin: this.HostInstance
|
|
3580
3860
|
});
|
|
3581
3861
|
let hostSnapshot = getGlobalSnapshotInfoByModuleInfo({
|
|
3582
3862
|
name: this.HostInstance.options.name,
|
|
@@ -3608,7 +3888,10 @@ var SnapshotHandler = class {
|
|
|
3608
3888
|
let gSnapshot;
|
|
3609
3889
|
if (globalRemoteSnapshot) if (isManifestProvider(globalRemoteSnapshot)) {
|
|
3610
3890
|
const remoteEntry = isBrowserEnvValue ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || "";
|
|
3611
|
-
const moduleSnapshot = await this.
|
|
3891
|
+
const moduleSnapshot = await this.loadManifestSnapshot(remoteEntry, moduleInfo, {}, {
|
|
3892
|
+
initiator,
|
|
3893
|
+
id: id || moduleInfo.name
|
|
3894
|
+
});
|
|
3612
3895
|
const globalSnapshotRes2 = setGlobalSnapshotInfoByModuleInfo({
|
|
3613
3896
|
...moduleInfo,
|
|
3614
3897
|
entry: remoteEntry
|
|
@@ -3626,15 +3909,12 @@ var SnapshotHandler = class {
|
|
|
3626
3909
|
gSnapshot = globalSnapshotRes;
|
|
3627
3910
|
}
|
|
3628
3911
|
else if (isRemoteInfoWithEntry(moduleInfo)) {
|
|
3629
|
-
const moduleSnapshot = await this.
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
options: this.HostInstance.options,
|
|
3633
|
-
moduleInfo,
|
|
3634
|
-
remoteSnapshot: moduleSnapshot,
|
|
3635
|
-
from: "global"
|
|
3912
|
+
const moduleSnapshot = await this.loadManifestSnapshot(moduleInfo.entry, moduleInfo, {}, {
|
|
3913
|
+
initiator,
|
|
3914
|
+
id: id || moduleInfo.name
|
|
3636
3915
|
});
|
|
3637
|
-
|
|
3916
|
+
const globalSnapshotRes2 = setGlobalSnapshotInfoByModuleInfo(moduleInfo, moduleSnapshot);
|
|
3917
|
+
mSnapshot = moduleSnapshot;
|
|
3638
3918
|
gSnapshot = globalSnapshotRes2;
|
|
3639
3919
|
} else error2(RUNTIME_007, runtimeDescMap, {
|
|
3640
3920
|
remoteName: moduleInfo.name,
|
|
@@ -3657,12 +3937,17 @@ var SnapshotHandler = class {
|
|
|
3657
3937
|
getGlobalRemoteInfo(moduleInfo) {
|
|
3658
3938
|
return getGlobalRemoteInfo(moduleInfo, this.HostInstance);
|
|
3659
3939
|
}
|
|
3660
|
-
async getManifestJson(manifestUrl, moduleInfo, extraOptions) {
|
|
3940
|
+
async getManifestJson(manifestUrl, moduleInfo, extraOptions, resourceOptions) {
|
|
3661
3941
|
const getManifest = async () => {
|
|
3942
|
+
const remoteInfo = getRemoteInfo(moduleInfo);
|
|
3662
3943
|
let manifestJson = this.manifestCache.get(manifestUrl);
|
|
3663
3944
|
if (manifestJson) return manifestJson;
|
|
3664
3945
|
try {
|
|
3665
|
-
let res = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {},
|
|
3946
|
+
let res = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {}, remoteInfo, resourceOptions ? {
|
|
3947
|
+
...resourceOptions,
|
|
3948
|
+
url: manifestUrl,
|
|
3949
|
+
resourceType: "manifest"
|
|
3950
|
+
} : void 0);
|
|
3666
3951
|
if (!res || !(res instanceof Response)) res = await fetch(manifestUrl, {});
|
|
3667
3952
|
manifestJson = await res.json();
|
|
3668
3953
|
} catch (err) {
|
|
@@ -3671,6 +3956,7 @@ var SnapshotHandler = class {
|
|
|
3671
3956
|
error: err,
|
|
3672
3957
|
from: "runtime",
|
|
3673
3958
|
lifecycle: "afterResolve",
|
|
3959
|
+
remote: remoteInfo,
|
|
3674
3960
|
origin: this.HostInstance
|
|
3675
3961
|
});
|
|
3676
3962
|
if (!manifestJson) {
|
|
@@ -3682,16 +3968,33 @@ var SnapshotHandler = class {
|
|
|
3682
3968
|
}, `${err}`, optionsToMFContext(this.HostInstance.options));
|
|
3683
3969
|
}
|
|
3684
3970
|
}
|
|
3685
|
-
|
|
3971
|
+
const missingRequiredFields = [
|
|
3686
3972
|
!manifestJson.metaData && "metaData",
|
|
3687
3973
|
!manifestJson.exposes && "exposes",
|
|
3688
3974
|
!manifestJson.shared && "shared"
|
|
3689
|
-
].filter(Boolean)
|
|
3975
|
+
].filter(Boolean);
|
|
3976
|
+
if (missingRequiredFields.length > 0) await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
3977
|
+
id: manifestUrl,
|
|
3978
|
+
error: /* @__PURE__ */ new Error(`"${manifestUrl}" is not a valid federation manifest for remote "${moduleInfo.name}". Missing required fields: ${missingRequiredFields.join(", ")}.`),
|
|
3979
|
+
from: "runtime",
|
|
3980
|
+
lifecycle: "afterResolve",
|
|
3981
|
+
remote: remoteInfo,
|
|
3982
|
+
origin: this.HostInstance
|
|
3983
|
+
});
|
|
3984
|
+
if (missingRequiredFields.length > 0) error2(RUNTIME_013, runtimeDescMap, {
|
|
3985
|
+
manifestUrl,
|
|
3986
|
+
moduleName: moduleInfo.name,
|
|
3987
|
+
hostName: this.HostInstance.options.name,
|
|
3988
|
+
missingFields: missingRequiredFields.join(",")
|
|
3989
|
+
}, void 0, optionsToMFContext(this.HostInstance.options));
|
|
3690
3990
|
this.manifestCache.set(manifestUrl, manifestJson);
|
|
3691
3991
|
return manifestJson;
|
|
3692
3992
|
};
|
|
3993
|
+
return getManifest();
|
|
3994
|
+
}
|
|
3995
|
+
async loadManifestSnapshot(manifestUrl, moduleInfo, extraOptions, resourceOptions) {
|
|
3693
3996
|
const asyncLoadProcess = async () => {
|
|
3694
|
-
const manifestJson = await
|
|
3997
|
+
const manifestJson = await this.getManifestJson(manifestUrl, moduleInfo, extraOptions, resourceOptions);
|
|
3695
3998
|
const remoteSnapshot = generateSnapshotFromManifest(manifestJson, { version: manifestUrl });
|
|
3696
3999
|
const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
3697
4000
|
options: this.HostInstance.options,
|
|
@@ -3716,6 +4019,8 @@ var SharedHandler = class {
|
|
|
3716
4019
|
afterResolve: new AsyncWaterfallHook("afterResolve"),
|
|
3717
4020
|
beforeLoadShare: new AsyncWaterfallHook("beforeLoadShare"),
|
|
3718
4021
|
loadShare: new AsyncHook(),
|
|
4022
|
+
afterLoadShare: new SyncHook("afterLoadShare"),
|
|
4023
|
+
errorLoadShare: new SyncHook("errorLoadShare"),
|
|
3719
4024
|
resolveShare: new SyncWaterfallHook("resolveShare"),
|
|
3720
4025
|
initContainerShareScopeMap: new SyncWaterfallHook("initContainerShareScopeMap")
|
|
3721
4026
|
});
|
|
@@ -3724,6 +4029,37 @@ var SharedHandler = class {
|
|
|
3724
4029
|
this.initTokens = {};
|
|
3725
4030
|
this._setGlobalShareScopeMap(host.options);
|
|
3726
4031
|
}
|
|
4032
|
+
emitAfterLoadShare({ lifecycle, pkgName, shareInfo, selectedShared }) {
|
|
4033
|
+
try {
|
|
4034
|
+
this.hooks.lifecycle.afterLoadShare.emit({
|
|
4035
|
+
pkgName,
|
|
4036
|
+
shareInfo,
|
|
4037
|
+
selectedShared,
|
|
4038
|
+
shared: this.host.options.shared,
|
|
4039
|
+
shareScopeMap: this.shareScopeMap,
|
|
4040
|
+
lifecycle,
|
|
4041
|
+
origin: this.host
|
|
4042
|
+
});
|
|
4043
|
+
} catch (error3) {
|
|
4044
|
+
warn$1(error3);
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
emitErrorLoadShare({ lifecycle, pkgName, shareInfo, error: error3, recovered }) {
|
|
4048
|
+
try {
|
|
4049
|
+
this.hooks.lifecycle.errorLoadShare.emit({
|
|
4050
|
+
pkgName,
|
|
4051
|
+
shareInfo,
|
|
4052
|
+
shared: this.host.options.shared,
|
|
4053
|
+
shareScopeMap: this.shareScopeMap,
|
|
4054
|
+
lifecycle,
|
|
4055
|
+
origin: this.host,
|
|
4056
|
+
error: error3,
|
|
4057
|
+
recovered
|
|
4058
|
+
});
|
|
4059
|
+
} catch (hookError) {
|
|
4060
|
+
warn$1(hookError);
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
3727
4063
|
registerShared(globalOptions, userOptions) {
|
|
3728
4064
|
const { newShareInfos, allShareInfos } = formatShareConfigs(globalOptions, userOptions);
|
|
3729
4065
|
Object.keys(newShareInfos).forEach((sharedKey) => {
|
|
@@ -3757,77 +4093,123 @@ var SharedHandler = class {
|
|
|
3757
4093
|
extraOptions,
|
|
3758
4094
|
shareInfos: host.options.shared
|
|
3759
4095
|
});
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
const
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
const factory = await targetShared.loading;
|
|
3778
|
-
targetShared.loaded = true;
|
|
3779
|
-
if (!targetShared.lib) targetShared.lib = factory;
|
|
3780
|
-
addUseIn(targetShared, host.options.name);
|
|
3781
|
-
return factory;
|
|
3782
|
-
} else {
|
|
3783
|
-
const asyncLoadProcess = async () => {
|
|
3784
|
-
const factory = await targetShared.get();
|
|
4096
|
+
let shareOptionsRes = shareOptions;
|
|
4097
|
+
try {
|
|
4098
|
+
if (shareOptions?.scope) await Promise.all(shareOptions.scope.map(async (shareScope) => {
|
|
4099
|
+
await Promise.all(this.initializeSharing(shareScope, { strategy: shareOptions.strategy }));
|
|
4100
|
+
}));
|
|
4101
|
+
shareOptionsRes = (await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
4102
|
+
pkgName,
|
|
4103
|
+
shareInfo: shareOptions,
|
|
4104
|
+
shared: host.options.shared,
|
|
4105
|
+
origin: host
|
|
4106
|
+
})).shareInfo;
|
|
4107
|
+
assert2(shareOptionsRes, `Cannot find shared "${pkgName}" in host "${host.options.name}". Ensure the shared config for "${pkgName}" is declared in the federation plugin options and the host has been initialized before loading shares.`);
|
|
4108
|
+
const resolvedShareOptions = shareOptionsRes;
|
|
4109
|
+
const { shared: registeredShared, useTreesShaking } = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare) || {};
|
|
4110
|
+
if (registeredShared) {
|
|
4111
|
+
const targetShared = directShare(registeredShared, useTreesShaking);
|
|
4112
|
+
if (targetShared.lib) {
|
|
3785
4113
|
addUseIn(targetShared, host.options.name);
|
|
4114
|
+
this.emitAfterLoadShare({
|
|
4115
|
+
lifecycle: "loadShare",
|
|
4116
|
+
pkgName,
|
|
4117
|
+
shareInfo: resolvedShareOptions,
|
|
4118
|
+
selectedShared: registeredShared
|
|
4119
|
+
});
|
|
4120
|
+
return targetShared.lib;
|
|
4121
|
+
} else if (targetShared.loading && !targetShared.loaded) {
|
|
4122
|
+
const factory = await targetShared.loading;
|
|
3786
4123
|
targetShared.loaded = true;
|
|
3787
|
-
targetShared.lib = factory;
|
|
4124
|
+
if (!targetShared.lib) targetShared.lib = factory;
|
|
4125
|
+
addUseIn(targetShared, host.options.name);
|
|
4126
|
+
this.emitAfterLoadShare({
|
|
4127
|
+
lifecycle: "loadShare",
|
|
4128
|
+
pkgName,
|
|
4129
|
+
shareInfo: resolvedShareOptions,
|
|
4130
|
+
selectedShared: registeredShared
|
|
4131
|
+
});
|
|
4132
|
+
return factory;
|
|
4133
|
+
} else {
|
|
4134
|
+
const asyncLoadProcess = async () => {
|
|
4135
|
+
const factory2 = await targetShared.get();
|
|
4136
|
+
addUseIn(targetShared, host.options.name);
|
|
4137
|
+
targetShared.loaded = true;
|
|
4138
|
+
targetShared.lib = factory2;
|
|
4139
|
+
return factory2;
|
|
4140
|
+
};
|
|
4141
|
+
const loading = asyncLoadProcess();
|
|
4142
|
+
this.setShared({
|
|
4143
|
+
pkgName,
|
|
4144
|
+
loaded: false,
|
|
4145
|
+
shared: registeredShared,
|
|
4146
|
+
from: host.options.name,
|
|
4147
|
+
lib: null,
|
|
4148
|
+
loading,
|
|
4149
|
+
treeShaking: useTreesShaking ? targetShared : void 0
|
|
4150
|
+
});
|
|
4151
|
+
const factory = await loading;
|
|
4152
|
+
this.emitAfterLoadShare({
|
|
4153
|
+
lifecycle: "loadShare",
|
|
4154
|
+
pkgName,
|
|
4155
|
+
shareInfo: resolvedShareOptions,
|
|
4156
|
+
selectedShared: registeredShared
|
|
4157
|
+
});
|
|
3788
4158
|
return factory;
|
|
4159
|
+
}
|
|
4160
|
+
} else {
|
|
4161
|
+
if (extraOptions?.customShareInfo) {
|
|
4162
|
+
this.emitErrorLoadShare({
|
|
4163
|
+
lifecycle: "loadShare",
|
|
4164
|
+
pkgName,
|
|
4165
|
+
shareInfo: resolvedShareOptions,
|
|
4166
|
+
recovered: true
|
|
4167
|
+
});
|
|
4168
|
+
return false;
|
|
4169
|
+
}
|
|
4170
|
+
const _useTreeShaking = shouldUseTreeShaking(resolvedShareOptions.treeShaking);
|
|
4171
|
+
const targetShared = directShare(resolvedShareOptions, _useTreeShaking);
|
|
4172
|
+
const asyncLoadProcess = async () => {
|
|
4173
|
+
const factory2 = await targetShared.get();
|
|
4174
|
+
targetShared.lib = factory2;
|
|
4175
|
+
targetShared.loaded = true;
|
|
4176
|
+
addUseIn(targetShared, host.options.name);
|
|
4177
|
+
const { shared: gShared, useTreesShaking: gUseTreeShaking } = getRegisteredShare(this.shareScopeMap, pkgName, resolvedShareOptions, this.hooks.lifecycle.resolveShare) || {};
|
|
4178
|
+
if (gShared) {
|
|
4179
|
+
const targetGShared = directShare(gShared, gUseTreeShaking);
|
|
4180
|
+
targetGShared.lib = factory2;
|
|
4181
|
+
targetGShared.loaded = true;
|
|
4182
|
+
gShared.from = resolvedShareOptions.from;
|
|
4183
|
+
}
|
|
4184
|
+
return factory2;
|
|
3789
4185
|
};
|
|
3790
4186
|
const loading = asyncLoadProcess();
|
|
3791
4187
|
this.setShared({
|
|
3792
4188
|
pkgName,
|
|
3793
4189
|
loaded: false,
|
|
3794
|
-
shared:
|
|
4190
|
+
shared: resolvedShareOptions,
|
|
3795
4191
|
from: host.options.name,
|
|
3796
4192
|
lib: null,
|
|
3797
4193
|
loading,
|
|
3798
|
-
treeShaking:
|
|
4194
|
+
treeShaking: _useTreeShaking ? targetShared : void 0
|
|
4195
|
+
});
|
|
4196
|
+
const factory = await loading;
|
|
4197
|
+
this.emitAfterLoadShare({
|
|
4198
|
+
lifecycle: "loadShare",
|
|
4199
|
+
pkgName,
|
|
4200
|
+
shareInfo: resolvedShareOptions,
|
|
4201
|
+
selectedShared: resolvedShareOptions
|
|
3799
4202
|
});
|
|
3800
|
-
return loading;
|
|
3801
|
-
}
|
|
3802
|
-
} else {
|
|
3803
|
-
if (extraOptions?.customShareInfo) return false;
|
|
3804
|
-
const _useTreeShaking = shouldUseTreeShaking(shareOptionsRes.treeShaking);
|
|
3805
|
-
const targetShared = directShare(shareOptionsRes, _useTreeShaking);
|
|
3806
|
-
const asyncLoadProcess = async () => {
|
|
3807
|
-
const factory = await targetShared.get();
|
|
3808
|
-
targetShared.lib = factory;
|
|
3809
|
-
targetShared.loaded = true;
|
|
3810
|
-
addUseIn(targetShared, host.options.name);
|
|
3811
|
-
const { shared: gShared, useTreesShaking: gUseTreeShaking } = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare) || {};
|
|
3812
|
-
if (gShared) {
|
|
3813
|
-
const targetGShared = directShare(gShared, gUseTreeShaking);
|
|
3814
|
-
targetGShared.lib = factory;
|
|
3815
|
-
targetGShared.loaded = true;
|
|
3816
|
-
gShared.from = shareOptionsRes.from;
|
|
3817
|
-
}
|
|
3818
4203
|
return factory;
|
|
3819
|
-
}
|
|
3820
|
-
|
|
3821
|
-
this.
|
|
4204
|
+
}
|
|
4205
|
+
} catch (shareError) {
|
|
4206
|
+
this.emitErrorLoadShare({
|
|
4207
|
+
lifecycle: "loadShare",
|
|
3822
4208
|
pkgName,
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
from: host.options.name,
|
|
3826
|
-
lib: null,
|
|
3827
|
-
loading,
|
|
3828
|
-
treeShaking: _useTreeShaking ? targetShared : void 0
|
|
4209
|
+
shareInfo: shareOptionsRes,
|
|
4210
|
+
error: shareError
|
|
3829
4211
|
});
|
|
3830
|
-
|
|
4212
|
+
throw shareError;
|
|
3831
4213
|
}
|
|
3832
4214
|
}
|
|
3833
4215
|
/**
|
|
@@ -3872,6 +4254,7 @@ var SharedHandler = class {
|
|
|
3872
4254
|
error: error3,
|
|
3873
4255
|
from: "runtime",
|
|
3874
4256
|
lifecycle: "beforeLoadShare",
|
|
4257
|
+
remote: module2.remoteInfo,
|
|
3875
4258
|
origin: host
|
|
3876
4259
|
});
|
|
3877
4260
|
if (!remoteEntryExports) return;
|
|
@@ -3899,58 +4282,92 @@ var SharedHandler = class {
|
|
|
3899
4282
|
extraOptions,
|
|
3900
4283
|
shareInfos: host.options.shared
|
|
3901
4284
|
});
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
if (
|
|
3908
|
-
|
|
3909
|
-
if (!registeredShared.loaded) {
|
|
3910
|
-
registeredShared.loaded = true;
|
|
3911
|
-
if (registeredShared.from === host.options.name) shareOptions.loaded = true;
|
|
3912
|
-
}
|
|
3913
|
-
return registeredShared.lib;
|
|
3914
|
-
}
|
|
3915
|
-
if (typeof registeredShared.get === "function") {
|
|
3916
|
-
const module2 = registeredShared.get();
|
|
3917
|
-
if (!(module2 instanceof Promise)) {
|
|
4285
|
+
try {
|
|
4286
|
+
if (shareOptions?.scope) shareOptions.scope.forEach((shareScope) => {
|
|
4287
|
+
this.initializeSharing(shareScope, { strategy: shareOptions.strategy });
|
|
4288
|
+
});
|
|
4289
|
+
const { shared: registeredShared } = getRegisteredShare(this.shareScopeMap, pkgName, shareOptions, this.hooks.lifecycle.resolveShare) || {};
|
|
4290
|
+
if (registeredShared) {
|
|
4291
|
+
if (typeof registeredShared.lib === "function") {
|
|
3918
4292
|
addUseIn(registeredShared, host.options.name);
|
|
3919
|
-
|
|
4293
|
+
if (!registeredShared.loaded) {
|
|
4294
|
+
registeredShared.loaded = true;
|
|
4295
|
+
if (registeredShared.from === host.options.name) shareOptions.loaded = true;
|
|
4296
|
+
}
|
|
4297
|
+
this.emitAfterLoadShare({
|
|
4298
|
+
lifecycle: "loadShareSync",
|
|
3920
4299
|
pkgName,
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
lib: module2,
|
|
3924
|
-
shared: registeredShared
|
|
4300
|
+
shareInfo: shareOptions,
|
|
4301
|
+
selectedShared: registeredShared
|
|
3925
4302
|
});
|
|
3926
|
-
return
|
|
4303
|
+
return registeredShared.lib;
|
|
4304
|
+
}
|
|
4305
|
+
if (typeof registeredShared.get === "function") {
|
|
4306
|
+
const module2 = registeredShared.get();
|
|
4307
|
+
if (!(module2 instanceof Promise)) {
|
|
4308
|
+
addUseIn(registeredShared, host.options.name);
|
|
4309
|
+
this.setShared({
|
|
4310
|
+
pkgName,
|
|
4311
|
+
loaded: true,
|
|
4312
|
+
from: host.options.name,
|
|
4313
|
+
lib: module2,
|
|
4314
|
+
shared: registeredShared
|
|
4315
|
+
});
|
|
4316
|
+
this.emitAfterLoadShare({
|
|
4317
|
+
lifecycle: "loadShareSync",
|
|
4318
|
+
pkgName,
|
|
4319
|
+
shareInfo: shareOptions,
|
|
4320
|
+
selectedShared: registeredShared
|
|
4321
|
+
});
|
|
4322
|
+
return module2;
|
|
4323
|
+
}
|
|
3927
4324
|
}
|
|
3928
4325
|
}
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
4326
|
+
if (shareOptions.lib) {
|
|
4327
|
+
if (!shareOptions.loaded) shareOptions.loaded = true;
|
|
4328
|
+
this.emitAfterLoadShare({
|
|
4329
|
+
lifecycle: "loadShareSync",
|
|
4330
|
+
pkgName,
|
|
4331
|
+
shareInfo: shareOptions,
|
|
4332
|
+
selectedShared: shareOptions
|
|
4333
|
+
});
|
|
4334
|
+
return shareOptions.lib;
|
|
4335
|
+
}
|
|
4336
|
+
if (shareOptions.get) {
|
|
4337
|
+
const module2 = shareOptions.get();
|
|
4338
|
+
if (module2 instanceof Promise) error2(extraOptions?.from === "build" ? RUNTIME_005 : RUNTIME_006, runtimeDescMap, {
|
|
4339
|
+
hostName: host.options.name,
|
|
4340
|
+
sharedPkgName: pkgName
|
|
4341
|
+
}, void 0, optionsToMFContext(host.options));
|
|
4342
|
+
shareOptions.lib = module2;
|
|
4343
|
+
this.setShared({
|
|
4344
|
+
pkgName,
|
|
4345
|
+
loaded: true,
|
|
4346
|
+
from: host.options.name,
|
|
4347
|
+
lib: shareOptions.lib,
|
|
4348
|
+
shared: shareOptions
|
|
4349
|
+
});
|
|
4350
|
+
this.emitAfterLoadShare({
|
|
4351
|
+
lifecycle: "loadShareSync",
|
|
4352
|
+
pkgName,
|
|
4353
|
+
shareInfo: shareOptions,
|
|
4354
|
+
selectedShared: shareOptions
|
|
4355
|
+
});
|
|
4356
|
+
return shareOptions.lib;
|
|
4357
|
+
}
|
|
4358
|
+
error2(RUNTIME_006, runtimeDescMap, {
|
|
3937
4359
|
hostName: host.options.name,
|
|
3938
4360
|
sharedPkgName: pkgName
|
|
3939
4361
|
}, void 0, optionsToMFContext(host.options));
|
|
3940
|
-
|
|
3941
|
-
this.
|
|
4362
|
+
} catch (shareError) {
|
|
4363
|
+
this.emitErrorLoadShare({
|
|
4364
|
+
lifecycle: "loadShareSync",
|
|
3942
4365
|
pkgName,
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
lib: shareOptions.lib,
|
|
3946
|
-
shared: shareOptions
|
|
4366
|
+
shareInfo: shareOptions,
|
|
4367
|
+
error: shareError
|
|
3947
4368
|
});
|
|
3948
|
-
|
|
4369
|
+
throw shareError;
|
|
3949
4370
|
}
|
|
3950
|
-
error2(RUNTIME_006, runtimeDescMap, {
|
|
3951
|
-
hostName: host.options.name,
|
|
3952
|
-
sharedPkgName: pkgName
|
|
3953
|
-
}, void 0, optionsToMFContext(host.options));
|
|
3954
4371
|
}
|
|
3955
4372
|
initShareScopeMap(scopeName, shareScope, extraOptions = {}) {
|
|
3956
4373
|
const { host } = this;
|
|
@@ -4003,12 +4420,14 @@ var RemoteHandler = class {
|
|
|
4003
4420
|
beforeRegisterRemote: new SyncWaterfallHook("beforeRegisterRemote"),
|
|
4004
4421
|
registerRemote: new SyncWaterfallHook("registerRemote"),
|
|
4005
4422
|
beforeRequest: new AsyncWaterfallHook("beforeRequest"),
|
|
4423
|
+
afterMatchRemote: new AsyncHook("afterMatchRemote"),
|
|
4006
4424
|
onLoad: new AsyncHook("onLoad"),
|
|
4425
|
+
afterLoadRemote: new AsyncHook("afterLoadRemote"),
|
|
4007
4426
|
handlePreloadModule: new SyncHook("handlePreloadModule"),
|
|
4008
4427
|
errorLoadRemote: new AsyncHook("errorLoadRemote"),
|
|
4009
4428
|
beforePreloadRemote: new AsyncHook("beforePreloadRemote"),
|
|
4010
4429
|
generatePreloadAssets: new AsyncHook("generatePreloadAssets"),
|
|
4011
|
-
afterPreloadRemote: new AsyncHook(),
|
|
4430
|
+
afterPreloadRemote: new AsyncHook("afterPreloadRemote"),
|
|
4012
4431
|
loadEntry: new AsyncHook()
|
|
4013
4432
|
});
|
|
4014
4433
|
this.host = host;
|
|
@@ -4045,10 +4464,18 @@ var RemoteHandler = class {
|
|
|
4045
4464
|
}
|
|
4046
4465
|
async loadRemote(id, options) {
|
|
4047
4466
|
const { host } = this;
|
|
4467
|
+
const startMatchInfo = matchRemoteWithNameAndExpose(host.options.remotes, id);
|
|
4468
|
+
let completeRequestId = id;
|
|
4469
|
+
let completeExpose = startMatchInfo?.expose;
|
|
4470
|
+
let completeRemote = startMatchInfo ? getRemoteInfo(startMatchInfo.remote) : void 0;
|
|
4471
|
+
let afterLoadRemoteArgs;
|
|
4048
4472
|
try {
|
|
4049
4473
|
const { loadFactory = true } = options || { loadFactory: true };
|
|
4050
4474
|
const { module: module2, moduleOptions, remoteMatchInfo } = await this.getRemoteModuleAndOptions({ id });
|
|
4051
4475
|
const { pkgNameOrAlias, remote, expose, id: idRes, remoteSnapshot } = remoteMatchInfo;
|
|
4476
|
+
completeRequestId = idRes;
|
|
4477
|
+
completeExpose = expose;
|
|
4478
|
+
completeRemote = getRemoteInfo(remote);
|
|
4052
4479
|
const moduleOrFactory = await module2.get(idRes, expose, options, remoteSnapshot);
|
|
4053
4480
|
const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
|
|
4054
4481
|
id: idRes,
|
|
@@ -4062,44 +4489,155 @@ var RemoteHandler = class {
|
|
|
4062
4489
|
origin: host
|
|
4063
4490
|
});
|
|
4064
4491
|
this.setIdToRemoteMap(id, remoteMatchInfo);
|
|
4492
|
+
afterLoadRemoteArgs = {
|
|
4493
|
+
id: completeRequestId,
|
|
4494
|
+
expose: completeExpose,
|
|
4495
|
+
remote: completeRemote,
|
|
4496
|
+
options,
|
|
4497
|
+
origin: host
|
|
4498
|
+
};
|
|
4065
4499
|
if (typeof moduleWrapper === "function") return moduleWrapper;
|
|
4066
4500
|
return moduleOrFactory;
|
|
4067
4501
|
} catch (error3) {
|
|
4068
4502
|
const { from = "runtime" } = options || { from: "runtime" };
|
|
4069
|
-
|
|
4070
|
-
|
|
4503
|
+
let failOver;
|
|
4504
|
+
try {
|
|
4505
|
+
failOver = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
4506
|
+
id,
|
|
4507
|
+
error: error3,
|
|
4508
|
+
from,
|
|
4509
|
+
lifecycle: "onLoad",
|
|
4510
|
+
expose: completeExpose,
|
|
4511
|
+
remote: completeRemote,
|
|
4512
|
+
origin: host
|
|
4513
|
+
});
|
|
4514
|
+
} catch (hookError) {
|
|
4515
|
+
afterLoadRemoteArgs = {
|
|
4516
|
+
id: completeRequestId,
|
|
4517
|
+
expose: completeExpose,
|
|
4518
|
+
remote: completeRemote,
|
|
4519
|
+
options,
|
|
4520
|
+
error: hookError,
|
|
4521
|
+
origin: host
|
|
4522
|
+
};
|
|
4523
|
+
throw hookError;
|
|
4524
|
+
}
|
|
4525
|
+
if (!failOver) {
|
|
4526
|
+
afterLoadRemoteArgs = {
|
|
4527
|
+
id: completeRequestId,
|
|
4528
|
+
expose: completeExpose,
|
|
4529
|
+
remote: completeRemote,
|
|
4530
|
+
options,
|
|
4531
|
+
error: error3,
|
|
4532
|
+
origin: host
|
|
4533
|
+
};
|
|
4534
|
+
throw error3;
|
|
4535
|
+
}
|
|
4536
|
+
afterLoadRemoteArgs = {
|
|
4537
|
+
id: completeRequestId,
|
|
4538
|
+
expose: completeExpose,
|
|
4539
|
+
remote: completeRemote,
|
|
4540
|
+
options,
|
|
4071
4541
|
error: error3,
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
});
|
|
4076
|
-
if (!failOver) throw error3;
|
|
4542
|
+
origin: host,
|
|
4543
|
+
recovered: true
|
|
4544
|
+
};
|
|
4077
4545
|
return failOver;
|
|
4546
|
+
} finally {
|
|
4547
|
+
if (afterLoadRemoteArgs) await this.hooks.lifecycle.afterLoadRemote.emit(afterLoadRemoteArgs);
|
|
4078
4548
|
}
|
|
4079
4549
|
}
|
|
4080
4550
|
async preloadRemote(preloadOptions) {
|
|
4081
4551
|
const { host } = this;
|
|
4552
|
+
const preloadResults = [];
|
|
4082
4553
|
await this.hooks.lifecycle.beforePreloadRemote.emit({
|
|
4083
4554
|
preloadOps: preloadOptions,
|
|
4084
4555
|
options: host.options,
|
|
4085
4556
|
origin: host
|
|
4086
4557
|
});
|
|
4087
4558
|
const preloadOps = formatPreloadArgs(host.options.remotes, preloadOptions);
|
|
4088
|
-
|
|
4089
|
-
const { remote } = ops;
|
|
4559
|
+
const createPreloadAssetOps = (ops) => {
|
|
4560
|
+
const { preloadConfig, remote } = ops;
|
|
4561
|
+
const exposes = preloadConfig.exposes || [];
|
|
4562
|
+
if (!exposes.length) return [{
|
|
4563
|
+
ops,
|
|
4564
|
+
id: `${remote.name}/*`
|
|
4565
|
+
}];
|
|
4566
|
+
return exposes.map((expose) => ({
|
|
4567
|
+
ops: {
|
|
4568
|
+
...ops,
|
|
4569
|
+
preloadConfig: {
|
|
4570
|
+
...preloadConfig,
|
|
4571
|
+
exposes: [expose]
|
|
4572
|
+
}
|
|
4573
|
+
},
|
|
4574
|
+
id: composeRemoteRequestId(remote.name, expose)
|
|
4575
|
+
}));
|
|
4576
|
+
};
|
|
4577
|
+
let preloadError;
|
|
4578
|
+
await Promise.all(preloadOps.flatMap(createPreloadAssetOps).map(async (assetOps) => {
|
|
4579
|
+
const { ops, id: preloadId } = assetOps;
|
|
4580
|
+
const { remote, preloadConfig } = ops;
|
|
4090
4581
|
const remoteInfo = getRemoteInfo(remote);
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4582
|
+
try {
|
|
4583
|
+
const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({
|
|
4584
|
+
moduleInfo: remote,
|
|
4585
|
+
id: preloadId,
|
|
4586
|
+
initiator: "preloadRemote"
|
|
4587
|
+
});
|
|
4588
|
+
const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
4589
|
+
origin: host,
|
|
4590
|
+
preloadOptions: ops,
|
|
4591
|
+
remote,
|
|
4592
|
+
remoteInfo,
|
|
4593
|
+
globalSnapshot,
|
|
4594
|
+
remoteSnapshot
|
|
4595
|
+
});
|
|
4596
|
+
if (!assets) return;
|
|
4597
|
+
const results = await preloadAssets(remoteInfo, host, assets, true, {
|
|
4598
|
+
initiator: "preloadRemote",
|
|
4599
|
+
id: preloadId
|
|
4600
|
+
});
|
|
4601
|
+
preloadResults.push({
|
|
4602
|
+
remote,
|
|
4603
|
+
remoteInfo,
|
|
4604
|
+
preloadConfig,
|
|
4605
|
+
id: preloadId,
|
|
4606
|
+
results
|
|
4607
|
+
});
|
|
4608
|
+
} catch (error3) {
|
|
4609
|
+
preloadResults.push({
|
|
4610
|
+
remote,
|
|
4611
|
+
remoteInfo,
|
|
4612
|
+
preloadConfig,
|
|
4613
|
+
id: preloadId,
|
|
4614
|
+
results: [{
|
|
4615
|
+
url: remoteInfo.entry,
|
|
4616
|
+
status: "error",
|
|
4617
|
+
resourceType: /\.json(?:$|[?#])/i.test(remoteInfo.entry) ? "manifest" : "remoteEntry",
|
|
4618
|
+
initiator: "preloadRemote",
|
|
4619
|
+
id: preloadId,
|
|
4620
|
+
error: error3
|
|
4621
|
+
}]
|
|
4622
|
+
});
|
|
4623
|
+
}
|
|
4102
4624
|
}));
|
|
4625
|
+
const failedResults = preloadResults.flatMap((preloadResult) => preloadResult.results.filter((result) => result.status === "error" || result.status === "timeout"));
|
|
4626
|
+
if (failedResults.length > 0) {
|
|
4627
|
+
preloadError = /* @__PURE__ */ new Error(`preloadRemote failed to load ${failedResults.length} resource(s).`);
|
|
4628
|
+
Object.assign(preloadError, {
|
|
4629
|
+
results: preloadResults,
|
|
4630
|
+
failedResults
|
|
4631
|
+
});
|
|
4632
|
+
}
|
|
4633
|
+
await this.hooks.lifecycle.afterPreloadRemote.emit({
|
|
4634
|
+
preloadOps: preloadOptions,
|
|
4635
|
+
options: host.options,
|
|
4636
|
+
origin: host,
|
|
4637
|
+
results: preloadResults,
|
|
4638
|
+
error: preloadError
|
|
4639
|
+
});
|
|
4640
|
+
if (preloadError) throw preloadError;
|
|
4103
4641
|
}
|
|
4104
4642
|
registerRemotes(remotes, options) {
|
|
4105
4643
|
const { host } = this;
|
|
@@ -4130,12 +4668,29 @@ var RemoteHandler = class {
|
|
|
4130
4668
|
}
|
|
4131
4669
|
const { id: idRes } = loadRemoteArgs;
|
|
4132
4670
|
const remoteSplitInfo = matchRemoteWithNameAndExpose(host.options.remotes, idRes);
|
|
4133
|
-
if (!remoteSplitInfo)
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4671
|
+
if (!remoteSplitInfo) try {
|
|
4672
|
+
error2(RUNTIME_004, runtimeDescMap, {
|
|
4673
|
+
hostName: host.options.name,
|
|
4674
|
+
requestId: idRes
|
|
4675
|
+
}, void 0, optionsToMFContext(host.options));
|
|
4676
|
+
} catch (matchError) {
|
|
4677
|
+
await this.hooks.lifecycle.afterMatchRemote.emit({
|
|
4678
|
+
id: idRes,
|
|
4679
|
+
options: host.options,
|
|
4680
|
+
error: matchError,
|
|
4681
|
+
origin: host
|
|
4682
|
+
});
|
|
4683
|
+
throw matchError;
|
|
4684
|
+
}
|
|
4137
4685
|
const { remote: rawRemote } = remoteSplitInfo;
|
|
4138
4686
|
const remoteInfo = getRemoteInfo(rawRemote);
|
|
4687
|
+
await this.hooks.lifecycle.afterMatchRemote.emit({
|
|
4688
|
+
id: idRes,
|
|
4689
|
+
...remoteSplitInfo,
|
|
4690
|
+
options: host.options,
|
|
4691
|
+
remoteInfo,
|
|
4692
|
+
origin: host
|
|
4693
|
+
});
|
|
4139
4694
|
const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit({
|
|
4140
4695
|
id: idRes,
|
|
4141
4696
|
...remoteSplitInfo,
|
|
@@ -4287,7 +4842,7 @@ var ModuleFederation = class {
|
|
|
4287
4842
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
4288
4843
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
4289
4844
|
});
|
|
4290
|
-
this.version = "2.
|
|
4845
|
+
this.version = "2.5.1";
|
|
4291
4846
|
this.moduleCache = /* @__PURE__ */ new Map();
|
|
4292
4847
|
this.loaderHook = new PluginSystem({
|
|
4293
4848
|
getModuleInfo: new SyncHook(),
|
|
@@ -4295,6 +4850,13 @@ var ModuleFederation = class {
|
|
|
4295
4850
|
createLink: new SyncHook(),
|
|
4296
4851
|
fetch: new AsyncHook(),
|
|
4297
4852
|
loadEntryError: new AsyncHook(),
|
|
4853
|
+
afterLoadEntry: new AsyncHook("afterLoadEntry"),
|
|
4854
|
+
beforeInitRemote: new AsyncHook("beforeInitRemote"),
|
|
4855
|
+
afterInitRemote: new AsyncHook("afterInitRemote"),
|
|
4856
|
+
beforeGetExpose: new AsyncHook("beforeGetExpose"),
|
|
4857
|
+
afterGetExpose: new AsyncHook("afterGetExpose"),
|
|
4858
|
+
beforeExecuteFactory: new AsyncHook("beforeExecuteFactory"),
|
|
4859
|
+
afterExecuteFactory: new AsyncHook("afterExecuteFactory"),
|
|
4298
4860
|
getModuleFactory: new AsyncHook()
|
|
4299
4861
|
});
|
|
4300
4862
|
this.bridgeHook = new PluginSystem({
|
|
@@ -4415,24 +4977,13 @@ function createInstance(options) {
|
|
|
4415
4977
|
setGlobalFederationInstance(instance);
|
|
4416
4978
|
return instance;
|
|
4417
4979
|
}
|
|
4418
|
-
var FederationInstance = null;
|
|
4419
|
-
function getInstance() {
|
|
4420
|
-
return FederationInstance;
|
|
4421
|
-
}
|
|
4422
4980
|
setGlobalFederationConstructor(ModuleFederation);
|
|
4423
4981
|
|
|
4424
4982
|
// libs/embed-libs/shared-embed/src/lib/helpers/remote-federation.ts
|
|
4425
|
-
var
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
}
|
|
4430
|
-
resolvedFederationRuntime = getInstance() ?? createInstance({
|
|
4431
|
-
name: "luzmo-embed-runtime",
|
|
4432
|
-
remotes: []
|
|
4433
|
-
});
|
|
4434
|
-
return resolvedFederationRuntime;
|
|
4435
|
-
}
|
|
4983
|
+
var federationRuntime = createInstance({
|
|
4984
|
+
name: "luzmo-embed-runtime",
|
|
4985
|
+
remotes: []
|
|
4986
|
+
});
|
|
4436
4987
|
var remoteCache = /* @__PURE__ */ new Map();
|
|
4437
4988
|
var remoteCounter = 0;
|
|
4438
4989
|
var preconnectedOrigins = /* @__PURE__ */ new Set();
|
|
@@ -4497,9 +5048,8 @@ function loadLibrary(appServer, componentName = "DashboardApp") {
|
|
|
4497
5048
|
if (remote.loadPromise) {
|
|
4498
5049
|
return remote.loadPromise;
|
|
4499
5050
|
}
|
|
4500
|
-
const runtime = getFederationRuntime();
|
|
4501
5051
|
if (!remote.registered) {
|
|
4502
|
-
|
|
5052
|
+
federationRuntime.registerRemotes([
|
|
4503
5053
|
{
|
|
4504
5054
|
name: remote.remoteName,
|
|
4505
5055
|
entry: remote.entry
|
|
@@ -4507,7 +5057,7 @@ function loadLibrary(appServer, componentName = "DashboardApp") {
|
|
|
4507
5057
|
]);
|
|
4508
5058
|
remote.registered = true;
|
|
4509
5059
|
}
|
|
4510
|
-
remote.loadPromise =
|
|
5060
|
+
remote.loadPromise = federationRuntime.loadRemote(`${remote.remoteName}/${componentName}`).then((module2) => {
|
|
4511
5061
|
if (!module2) {
|
|
4512
5062
|
throw new Error(`Failed to load "${componentName}" from "${remote.entry}".`);
|
|
4513
5063
|
}
|
|
@@ -5193,7 +5743,7 @@ var o6 = e6(class extends i5 {
|
|
|
5193
5743
|
});
|
|
5194
5744
|
|
|
5195
5745
|
// libs/embed-libs/embed/package.json
|
|
5196
|
-
var version = "6.13.
|
|
5746
|
+
var version = "6.13.5";
|
|
5197
5747
|
|
|
5198
5748
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
5199
5749
|
var LuzmoDashboardService = class {
|
|
@@ -5336,6 +5886,14 @@ var _setEventHandler = () => {
|
|
|
5336
5886
|
_setCalculatedDimensions(dashboardComponent);
|
|
5337
5887
|
break;
|
|
5338
5888
|
}
|
|
5889
|
+
case "trackViewport": {
|
|
5890
|
+
if (event.data.enabled) {
|
|
5891
|
+
dashboardComponent._startViewportTracking();
|
|
5892
|
+
} else {
|
|
5893
|
+
dashboardComponent._stopViewportTracking();
|
|
5894
|
+
}
|
|
5895
|
+
break;
|
|
5896
|
+
}
|
|
5339
5897
|
case "setSelectedData":
|
|
5340
5898
|
case "setFilters": {
|
|
5341
5899
|
if (event.data.error) {
|
|
@@ -5421,6 +5979,24 @@ var dashboardStyles = i`
|
|
|
5421
5979
|
height: 100%;
|
|
5422
5980
|
}
|
|
5423
5981
|
|
|
5982
|
+
/*
|
|
5983
|
+
* Web component mode: the dashboard app renders directly (no iframe). Make its host fill the
|
|
5984
|
+
* sized .dashboard-container so the app's internal height:100% chain resolves to the calculated
|
|
5985
|
+
* dashboard height - exactly like the iframe gets its height. Without this the app collapses to
|
|
5986
|
+
* its intrinsic size and its inner scroll container produces a second scrollbar, and content can
|
|
5987
|
+
* spill outside the container.
|
|
5988
|
+
*/
|
|
5989
|
+
#dashboard-wc-container {
|
|
5990
|
+
width: 100%;
|
|
5991
|
+
height: 100%;
|
|
5992
|
+
}
|
|
5993
|
+
|
|
5994
|
+
#dashboard-wc-container dashboard-component {
|
|
5995
|
+
display: block;
|
|
5996
|
+
width: 100%;
|
|
5997
|
+
height: 100%;
|
|
5998
|
+
}
|
|
5999
|
+
|
|
5424
6000
|
.luzmo-container-loader {
|
|
5425
6001
|
width: 100%;
|
|
5426
6002
|
position: relative;
|
|
@@ -5545,6 +6121,12 @@ var LuzmoDashboard = class extends i4 {
|
|
|
5545
6121
|
this.loaderSize = 32;
|
|
5546
6122
|
this.borderWidth = 3;
|
|
5547
6123
|
this.minHeight = 400;
|
|
6124
|
+
this._viewportTrackingActive = false;
|
|
6125
|
+
// Post synchronously on scroll/resize (not via requestAnimationFrame) so the iframe receives the
|
|
6126
|
+
// new slice as early as possible in the frame, minimizing the lag of the pinned analyst panel.
|
|
6127
|
+
this._onViewportChange = () => {
|
|
6128
|
+
this._postViewport();
|
|
6129
|
+
};
|
|
5548
6130
|
this._containerId = uuidv4();
|
|
5549
6131
|
this._iframeId = `luzmo-dashboard-${this._containerId}`;
|
|
5550
6132
|
this.iframeLoaded = false;
|
|
@@ -5587,12 +6169,48 @@ var LuzmoDashboard = class extends i4 {
|
|
|
5587
6169
|
disconnectedCallback() {
|
|
5588
6170
|
super.disconnectedCallback();
|
|
5589
6171
|
this._resizeObserver.disconnect();
|
|
6172
|
+
this._stopViewportTracking();
|
|
5590
6173
|
for (const promiseKey of Object.keys(this.promises)) {
|
|
5591
6174
|
this.promises[promiseKey].reject(
|
|
5592
6175
|
new Error("Dashboard component was removed")
|
|
5593
6176
|
);
|
|
5594
6177
|
}
|
|
5595
6178
|
}
|
|
6179
|
+
// Relay the iframe's visible slice within the host viewport to the dashboard app, so embedded
|
|
6180
|
+
// overlays (e.g. the IQ analyst) can pin themselves to the visible area while the host page
|
|
6181
|
+
// scrolls the full-height iframe. Opt-in: started when the iframe requests it via 'trackViewport'.
|
|
6182
|
+
_startViewportTracking() {
|
|
6183
|
+
if (this.embedMode !== "iframe") {
|
|
6184
|
+
return;
|
|
6185
|
+
}
|
|
6186
|
+
if (!this._viewportTrackingActive) {
|
|
6187
|
+
this._viewportTrackingActive = true;
|
|
6188
|
+
window.addEventListener("scroll", this._onViewportChange, { passive: true, capture: true });
|
|
6189
|
+
window.addEventListener("resize", this._onViewportChange, { passive: true });
|
|
6190
|
+
}
|
|
6191
|
+
this._postViewport();
|
|
6192
|
+
}
|
|
6193
|
+
_stopViewportTracking() {
|
|
6194
|
+
if (!this._viewportTrackingActive) {
|
|
6195
|
+
return;
|
|
6196
|
+
}
|
|
6197
|
+
this._viewportTrackingActive = false;
|
|
6198
|
+
window.removeEventListener("scroll", this._onViewportChange, { capture: true });
|
|
6199
|
+
window.removeEventListener("resize", this._onViewportChange);
|
|
6200
|
+
}
|
|
6201
|
+
_postViewport() {
|
|
6202
|
+
const contentWindow = this.iframe?.contentWindow;
|
|
6203
|
+
if (!contentWindow) {
|
|
6204
|
+
return;
|
|
6205
|
+
}
|
|
6206
|
+
const rect = this.iframe.getBoundingClientRect();
|
|
6207
|
+
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
6208
|
+
const visibleTop = Math.max(rect.top, 0);
|
|
6209
|
+
const visibleBottom = Math.min(rect.bottom, viewportHeight);
|
|
6210
|
+
const visibleHeight = Math.max(visibleBottom - visibleTop, 0);
|
|
6211
|
+
const offsetTop = Math.min(Math.max(-rect.top, 0), rect.height);
|
|
6212
|
+
contentWindow.postMessage({ action: "setViewport", offsetTop, visibleHeight }, "*");
|
|
6213
|
+
}
|
|
5596
6214
|
firstUpdated() {
|
|
5597
6215
|
this._loaderMsg = getLoader(this)?.loadingMsg;
|
|
5598
6216
|
this._loaderStyles();
|
|
@@ -6436,6 +7054,9 @@ __decorateClass([
|
|
|
6436
7054
|
__decorateClass([
|
|
6437
7055
|
n4()
|
|
6438
7056
|
], LuzmoBaseVizItem.prototype, "itemId", 2);
|
|
7057
|
+
__decorateClass([
|
|
7058
|
+
n4({ attribute: "ai-message-asset-id" })
|
|
7059
|
+
], LuzmoBaseVizItem.prototype, "aiMessageAssetId", 2);
|
|
6439
7060
|
__decorateClass([
|
|
6440
7061
|
n4({ type: Object })
|
|
6441
7062
|
], LuzmoBaseVizItem.prototype, "selectedData", 2);
|
|
@@ -6465,7 +7086,8 @@ var inputMap = {
|
|
|
6465
7086
|
version: "version",
|
|
6466
7087
|
libVersion: "lib-version",
|
|
6467
7088
|
aydHost: "ayd-host",
|
|
6468
|
-
availableDatasets: "available-datasets"
|
|
7089
|
+
availableDatasets: "available-datasets",
|
|
7090
|
+
dashboardContext: "dashboard-context"
|
|
6469
7091
|
};
|
|
6470
7092
|
var embedChatTag = "luzmo-iq-embed-chat";
|
|
6471
7093
|
var chatComponentTag = "luzmo-iq-chat-component";
|
|
@@ -6593,6 +7215,9 @@ __decorateClass([
|
|
|
6593
7215
|
__decorateClass([
|
|
6594
7216
|
n4({ type: Array })
|
|
6595
7217
|
], LuzmoIQEmbedChatComponent.prototype, "availableDatasets", 2);
|
|
7218
|
+
__decorateClass([
|
|
7219
|
+
n4({ type: Object })
|
|
7220
|
+
], LuzmoIQEmbedChatComponent.prototype, "dashboardContext", 2);
|
|
6596
7221
|
if (!customElements.get(embedChatTag)) {
|
|
6597
7222
|
customElements.define(embedChatTag, LuzmoIQEmbedChatComponent);
|
|
6598
7223
|
}
|