@luzmo/embed 6.13.1 → 6.13.2-es2021

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.
@@ -391,7 +391,7 @@ var createIframeUrl = (dashboardContent) => {
391
391
  searchString.push(`accentColor=${accentColor}`);
392
392
  }
393
393
  if (screenMode && screenMode !== "auto") {
394
- searchString.push(`screenMode=&{screenMode}`);
394
+ searchString.push(`screenMode=${screenMode}`);
395
395
  }
396
396
  if (timezoneId) {
397
397
  searchString.push("timezoneId=" + timezoneId);
@@ -1416,21 +1416,6 @@ function generateSnapshotFromManifest(manifest, options = {}) {
1416
1416
  assets: expose.assets
1417
1417
  }))
1418
1418
  };
1419
- if (manifest.metaData?.prefetchInterface) {
1420
- const prefetchInterface = manifest.metaData.prefetchInterface;
1421
- basicRemoteSnapshot = {
1422
- ...basicRemoteSnapshot,
1423
- prefetchInterface
1424
- };
1425
- }
1426
- if (manifest.metaData?.prefetchEntry) {
1427
- const { path, name, type } = manifest.metaData.prefetchEntry;
1428
- basicRemoteSnapshot = {
1429
- ...basicRemoteSnapshot,
1430
- prefetchEntry: simpleJoinRemoteEntry(path, name),
1431
- prefetchEntryType: type
1432
- };
1433
- }
1434
1419
  if ("publicPath" in manifest.metaData) {
1435
1420
  remoteSnapshot = {
1436
1421
  ...basicRemoteSnapshot,
@@ -1674,6 +1659,8 @@ function createScript(info) {
1674
1659
  function createLink(info) {
1675
1660
  let link = null;
1676
1661
  let needAttach = true;
1662
+ let timeout = 2e4;
1663
+ let timeoutId;
1677
1664
  const links = document.getElementsByTagName("link");
1678
1665
  for (let i7 = 0; i7 < links.length; i7++) {
1679
1666
  const l3 = links[i7];
@@ -1689,19 +1676,42 @@ function createLink(info) {
1689
1676
  link = document.createElement("link");
1690
1677
  link.setAttribute("href", info.url);
1691
1678
  let createLinkRes = void 0;
1679
+ let shouldApplyAttrs = true;
1692
1680
  const attrs = info.attrs;
1693
1681
  if (info.createLinkHook) {
1694
1682
  createLinkRes = info.createLinkHook(info.url, attrs);
1695
- if (createLinkRes instanceof HTMLLinkElement) link = createLinkRes;
1683
+ if (createLinkRes instanceof HTMLLinkElement) {
1684
+ link = createLinkRes;
1685
+ shouldApplyAttrs = false;
1686
+ } else if (typeof createLinkRes === "object") {
1687
+ if ("link" in createLinkRes && createLinkRes.link) {
1688
+ link = createLinkRes.link;
1689
+ shouldApplyAttrs = false;
1690
+ }
1691
+ if ("timeout" in createLinkRes && createLinkRes.timeout) timeout = createLinkRes.timeout;
1692
+ }
1696
1693
  }
1697
- if (attrs && !createLinkRes) Object.keys(attrs).forEach((name) => {
1694
+ if (attrs && shouldApplyAttrs) Object.keys(attrs).forEach((name) => {
1698
1695
  if (link && !link.getAttribute(name)) link.setAttribute(name, attrs[name]);
1699
1696
  });
1700
1697
  }
1698
+ if (!needAttach) {
1699
+ Promise.resolve().then(() => {
1700
+ info?.cb && info?.cb();
1701
+ });
1702
+ return {
1703
+ link,
1704
+ needAttach
1705
+ };
1706
+ }
1701
1707
  const onLinkComplete = (prev, event) => {
1708
+ if (timeoutId) clearTimeout(timeoutId);
1702
1709
  const onLinkCompleteCallback = () => {
1703
- if (event?.type === "error") info?.onErrorCallback && info?.onErrorCallback(event);
1704
- else info?.cb && info?.cb();
1710
+ if (event?.type === "error") {
1711
+ 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.`);
1712
+ linkError.name = "LinkNetworkError";
1713
+ info?.onErrorCallback && info?.onErrorCallback(linkError);
1714
+ } else info?.cb && info?.cb();
1705
1715
  };
1706
1716
  if (link) {
1707
1717
  link.onerror = null;
@@ -1720,6 +1730,12 @@ function createLink(info) {
1720
1730
  };
1721
1731
  link.onerror = onLinkComplete.bind(null, link.onerror);
1722
1732
  link.onload = onLinkComplete.bind(null, link.onload);
1733
+ timeoutId = setTimeout(() => {
1734
+ onLinkComplete(null, {
1735
+ type: "error",
1736
+ isTimeout: true
1737
+ });
1738
+ }, timeout);
1723
1739
  return {
1724
1740
  link,
1725
1741
  needAttach
@@ -2010,7 +2026,7 @@ function getGlobalFederationConstructor() {
2010
2026
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
2011
2027
  if (isDebug) {
2012
2028
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
2013
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.3.3";
2029
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.5.0";
2014
2030
  }
2015
2031
  }
2016
2032
  function getInfoWithoutType(target, key) {
@@ -2594,6 +2610,10 @@ function directShare(shared, useTreesShaking) {
2594
2610
  }
2595
2611
 
2596
2612
  // node_modules/@module-federation/runtime-core/dist/utils/manifest.js
2613
+ function composeRemoteRequestId(remoteName, expose) {
2614
+ if (!expose || expose === ".") return remoteName;
2615
+ return `${remoteName}/${expose.replace(/^\.\//, "")}`;
2616
+ }
2597
2617
  function matchRemoteWithNameAndExpose(remotes, id) {
2598
2618
  for (const remote of remotes) {
2599
2619
  const isNameMatched = id.startsWith(remote.name);
@@ -2652,6 +2672,9 @@ var RUNTIME_009 = "RUNTIME-009";
2652
2672
  var RUNTIME_010 = "RUNTIME-010";
2653
2673
  var RUNTIME_011 = "RUNTIME-011";
2654
2674
  var RUNTIME_012 = "RUNTIME-012";
2675
+ var RUNTIME_013 = "RUNTIME-013";
2676
+ var RUNTIME_014 = "RUNTIME-014";
2677
+ var RUNTIME_015 = "RUNTIME-015";
2655
2678
  var TYPE_001 = "TYPE-001";
2656
2679
  var BUILD_001 = "BUILD-001";
2657
2680
  var BUILD_002 = "BUILD-002";
@@ -2669,7 +2692,10 @@ var runtimeDescMap = {
2669
2692
  [RUNTIME_009]: "Please call createInstance first.",
2670
2693
  [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.',
2671
2694
  [RUNTIME_011]: "The remoteEntry URL is missing from the remote snapshot.",
2672
- [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.'
2695
+ [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_013]: "The manifest is not a valid Module Federation manifest.",
2697
+ [RUNTIME_014]: "The remote does not expose the requested module.",
2698
+ [RUNTIME_015]: "Remote container initialization failed."
2673
2699
  };
2674
2700
  var typeDescMap = { [TYPE_001]: "Failed to generate type declaration. Execute the below cmd to reproduce and fix the error." };
2675
2701
  var buildDescMap = {
@@ -2719,7 +2745,7 @@ function handleRemoteEntryLoaded(name, globalName, entry) {
2719
2745
  });
2720
2746
  return entryExports;
2721
2747
  }
2722
- async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl }) {
2748
+ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl, resourceContext }) {
2723
2749
  const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
2724
2750
  if (remoteEntryExports) return remoteEntryExports;
2725
2751
  const url = getEntryUrl ? getEntryUrl(entry) : entry;
@@ -2729,7 +2755,11 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
2729
2755
  const res = loaderHook.lifecycle.createScript.emit({
2730
2756
  url: url2,
2731
2757
  attrs,
2732
- remoteInfo
2758
+ remoteInfo,
2759
+ resourceContext: resourceContext ? {
2760
+ ...resourceContext,
2761
+ url: url2
2762
+ } : void 0
2733
2763
  });
2734
2764
  if (!res) return;
2735
2765
  if (res instanceof HTMLScriptElement) return res;
@@ -2745,7 +2775,7 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
2745
2775
  }, originalMsg);
2746
2776
  });
2747
2777
  }
2748
- async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl }) {
2778
+ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {
2749
2779
  const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
2750
2780
  switch (type) {
2751
2781
  case "esm":
@@ -2766,11 +2796,12 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEnt
2766
2796
  name,
2767
2797
  remoteInfo,
2768
2798
  loaderHook,
2769
- getEntryUrl
2799
+ getEntryUrl,
2800
+ resourceContext
2770
2801
  });
2771
2802
  }
2772
2803
  }
2773
- async function loadEntryNode({ remoteInfo, loaderHook }) {
2804
+ async function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {
2774
2805
  const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
2775
2806
  const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
2776
2807
  if (remoteEntryExports) return remoteEntryExports;
@@ -2784,7 +2815,11 @@ async function loadEntryNode({ remoteInfo, loaderHook }) {
2784
2815
  const res = loaderHook.lifecycle.createScript.emit({
2785
2816
  url,
2786
2817
  attrs,
2787
- remoteInfo
2818
+ remoteInfo,
2819
+ resourceContext: resourceContext ? {
2820
+ ...resourceContext,
2821
+ url
2822
+ } : void 0
2788
2823
  });
2789
2824
  if (!res) return;
2790
2825
  if ("url" in res) return res;
@@ -2800,13 +2835,14 @@ function getRemoteEntryUniqueKey(remoteInfo) {
2800
2835
  return composeKeyWithSeparator(name, entry);
2801
2836
  }
2802
2837
  async function getRemoteEntry(params) {
2803
- const { origin, remoteEntryExports, remoteInfo, getEntryUrl, _inErrorHandling = false } = params;
2838
+ const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;
2804
2839
  const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
2805
2840
  if (remoteEntryExports) return remoteEntryExports;
2806
2841
  if (!globalLoading[uniqueKey]) {
2807
2842
  const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
2808
2843
  const loaderHook = origin.loaderHook;
2809
2844
  globalLoading[uniqueKey] = loadEntryHook.emit({
2845
+ origin,
2810
2846
  loaderHook,
2811
2847
  remoteInfo,
2812
2848
  remoteEntryExports
@@ -2816,11 +2852,20 @@ async function getRemoteEntry(params) {
2816
2852
  remoteInfo,
2817
2853
  remoteEntryExports,
2818
2854
  loaderHook,
2819
- getEntryUrl
2855
+ getEntryUrl,
2856
+ resourceContext
2820
2857
  }) : loadEntryNode({
2821
2858
  remoteInfo,
2822
- loaderHook
2859
+ loaderHook,
2860
+ resourceContext
2823
2861
  });
2862
+ }).then(async (res) => {
2863
+ await origin.loaderHook.lifecycle.afterLoadEntry.emit({
2864
+ origin,
2865
+ remoteInfo,
2866
+ remoteEntryExports: res
2867
+ });
2868
+ return res;
2824
2869
  }).catch(async (err) => {
2825
2870
  const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
2826
2871
  const isScriptExecutionError = err instanceof Error && err.message.includes("ScriptExecutionError");
@@ -2839,8 +2884,21 @@ async function getRemoteEntry(params) {
2839
2884
  globalLoading,
2840
2885
  uniqueKey: uniqueKey2
2841
2886
  });
2842
- if (RemoteEntryExports) return RemoteEntryExports;
2887
+ if (RemoteEntryExports) {
2888
+ await origin.loaderHook.lifecycle.afterLoadEntry.emit({
2889
+ origin,
2890
+ remoteInfo,
2891
+ remoteEntryExports: RemoteEntryExports,
2892
+ recovered: true
2893
+ });
2894
+ return RemoteEntryExports;
2895
+ }
2843
2896
  }
2897
+ await origin.loaderHook.lifecycle.afterLoadEntry.emit({
2898
+ origin,
2899
+ remoteInfo,
2900
+ error: err
2901
+ });
2844
2902
  throw err;
2845
2903
  });
2846
2904
  }
@@ -2926,7 +2984,6 @@ function defaultPreloadArgs(preloadConfig) {
2926
2984
  resourceCategory: "sync",
2927
2985
  share: true,
2928
2986
  depsRemote: true,
2929
- prefetchInterface: false,
2930
2987
  ...preloadConfig
2931
2988
  };
2932
2989
  }
@@ -2951,22 +3008,113 @@ function normalizePreloadExposes(exposes) {
2951
3008
  return expose;
2952
3009
  });
2953
3010
  }
2954
- function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
3011
+ function isTimeoutError(error3) {
3012
+ if (!(error3 instanceof Error)) return false;
3013
+ return error3.message.includes("timed out") || error3.name.includes("Timeout");
3014
+ }
3015
+ function createAssetResult(context, url, status, error3) {
3016
+ return {
3017
+ url,
3018
+ status,
3019
+ resourceType: context.resourceType,
3020
+ initiator: context.initiator,
3021
+ id: context.id,
3022
+ error: error3
3023
+ };
3024
+ }
3025
+ async function waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, context) {
3026
+ const cachedRemote = host.moduleCache.get(entryRemoteInfo.name);
3027
+ const url = entryRemoteInfo.entry;
3028
+ if (cachedRemote?.remoteEntryExports) return createAssetResult(context, url, "cached");
3029
+ try {
3030
+ if (!await getRemoteEntry({
3031
+ origin: host,
3032
+ remoteInfo: entryRemoteInfo,
3033
+ remoteEntryExports: cachedRemote?.remoteEntryExports,
3034
+ resourceContext: {
3035
+ ...context,
3036
+ url
3037
+ }
3038
+ })) throw new Error(`Failed to load remoteEntry "${url}".`);
3039
+ return createAssetResult(context, url, "success");
3040
+ } catch (error3) {
3041
+ return createAssetResult(context, url, isTimeoutError(error3) ? "timeout" : "error", error3);
3042
+ }
3043
+ }
3044
+ function waitForLinkPreload({ host, remoteInfo, url, attrs, context, needDeleteLink }) {
3045
+ return new Promise((resolve) => {
3046
+ const { link, needAttach } = createLink({
3047
+ url,
3048
+ cb: () => {
3049
+ resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));
3050
+ },
3051
+ onErrorCallback: (error3) => {
3052
+ resolve(createAssetResult(context, url, isTimeoutError(error3) ? "timeout" : "error", error3));
3053
+ },
3054
+ attrs,
3055
+ createLinkHook: (hookUrl, hookAttrs) => {
3056
+ const res = host.loaderHook.lifecycle.createLink.emit({
3057
+ url: hookUrl,
3058
+ attrs: hookAttrs,
3059
+ remoteInfo,
3060
+ resourceContext: {
3061
+ ...context,
3062
+ url: hookUrl
3063
+ }
3064
+ });
3065
+ if (res instanceof HTMLLinkElement) return res;
3066
+ return res;
3067
+ },
3068
+ needDeleteLink
3069
+ });
3070
+ needAttach && document.head.appendChild(link);
3071
+ });
3072
+ }
3073
+ function waitForScriptPreload({ host, remoteInfo, url, attrs, context }) {
3074
+ return new Promise((resolve) => {
3075
+ const { script, needAttach } = createScript({
3076
+ url,
3077
+ cb: () => {
3078
+ resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));
3079
+ },
3080
+ onErrorCallback: (error3) => {
3081
+ resolve(createAssetResult(context, url, isTimeoutError(error3) ? "timeout" : "error", error3));
3082
+ },
3083
+ attrs,
3084
+ createScriptHook: (hookUrl, hookAttrs) => {
3085
+ const res = host.loaderHook.lifecycle.createScript.emit({
3086
+ url: hookUrl,
3087
+ attrs: hookAttrs,
3088
+ remoteInfo,
3089
+ resourceContext: {
3090
+ ...context,
3091
+ url: hookUrl
3092
+ }
3093
+ });
3094
+ if (res instanceof HTMLScriptElement) return res;
3095
+ return res;
3096
+ },
3097
+ needDeleteScript: true
3098
+ });
3099
+ needAttach && document.head.appendChild(script);
3100
+ });
3101
+ }
3102
+ function createResourceContext(baseContext, resourceType) {
3103
+ return {
3104
+ ...baseContext,
3105
+ resourceType
3106
+ };
3107
+ }
3108
+ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseContext = {
3109
+ initiator: "preloadRemote",
3110
+ id: remoteInfo.name
3111
+ }) {
2955
3112
  const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
3113
+ const results = [];
2956
3114
  if (host.options.inBrowser) {
2957
3115
  entryAssets.forEach((asset) => {
2958
- const { moduleInfo } = asset;
2959
- const module2 = host.moduleCache.get(remoteInfo.name);
2960
- if (module2) getRemoteEntry({
2961
- origin: host,
2962
- remoteInfo: moduleInfo,
2963
- remoteEntryExports: module2.remoteEntryExports
2964
- });
2965
- else getRemoteEntry({
2966
- origin: host,
2967
- remoteInfo: moduleInfo,
2968
- remoteEntryExports: void 0
2969
- });
3116
+ const { moduleInfo: entryRemoteInfo } = asset;
3117
+ results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));
2970
3118
  });
2971
3119
  if (useLinkPreload) {
2972
3120
  const defaultAttrs = {
@@ -2974,21 +3122,13 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
2974
3122
  as: "style"
2975
3123
  };
2976
3124
  cssAssets.forEach((cssUrl) => {
2977
- const { link: cssEl, needAttach } = createLink({
3125
+ results.push(waitForLinkPreload({
3126
+ host,
3127
+ remoteInfo,
2978
3128
  url: cssUrl,
2979
- cb: () => {
2980
- },
2981
3129
  attrs: defaultAttrs,
2982
- createLinkHook: (url, attrs) => {
2983
- const res = host.loaderHook.lifecycle.createLink.emit({
2984
- url,
2985
- attrs,
2986
- remoteInfo
2987
- });
2988
- if (res instanceof HTMLLinkElement) return res;
2989
- }
2990
- });
2991
- needAttach && document.head.appendChild(cssEl);
3130
+ context: createResourceContext(baseContext, "css")
3131
+ }));
2992
3132
  });
2993
3133
  } else {
2994
3134
  const defaultAttrs = {
@@ -2996,22 +3136,14 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
2996
3136
  type: "text/css"
2997
3137
  };
2998
3138
  cssAssets.forEach((cssUrl) => {
2999
- const { link: cssEl, needAttach } = createLink({
3139
+ results.push(waitForLinkPreload({
3140
+ host,
3141
+ remoteInfo,
3000
3142
  url: cssUrl,
3001
- cb: () => {
3002
- },
3003
3143
  attrs: defaultAttrs,
3004
- createLinkHook: (url, attrs) => {
3005
- const res = host.loaderHook.lifecycle.createLink.emit({
3006
- url,
3007
- attrs,
3008
- remoteInfo
3009
- });
3010
- if (res instanceof HTMLLinkElement) return res;
3011
- },
3012
- needDeleteLink: false
3013
- });
3014
- needAttach && document.head.appendChild(cssEl);
3144
+ needDeleteLink: false,
3145
+ context: createResourceContext(baseContext, "css")
3146
+ }));
3015
3147
  });
3016
3148
  }
3017
3149
  if (useLinkPreload) {
@@ -3020,21 +3152,13 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
3020
3152
  as: "script"
3021
3153
  };
3022
3154
  jsAssetsWithoutEntry.forEach((jsUrl) => {
3023
- const { link: linkEl, needAttach } = createLink({
3155
+ results.push(waitForLinkPreload({
3156
+ host,
3157
+ remoteInfo,
3024
3158
  url: jsUrl,
3025
- cb: () => {
3026
- },
3027
3159
  attrs: defaultAttrs,
3028
- createLinkHook: (url, attrs) => {
3029
- const res = host.loaderHook.lifecycle.createLink.emit({
3030
- url,
3031
- attrs,
3032
- remoteInfo
3033
- });
3034
- if (res instanceof HTMLLinkElement) return res;
3035
- }
3036
- });
3037
- needAttach && document.head.appendChild(linkEl);
3160
+ context: createResourceContext(baseContext, "js")
3161
+ }));
3038
3162
  });
3039
3163
  } else {
3040
3164
  const defaultAttrs = {
@@ -3042,28 +3166,25 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
3042
3166
  type: remoteInfo?.type === "module" ? "module" : "text/javascript"
3043
3167
  };
3044
3168
  jsAssetsWithoutEntry.forEach((jsUrl) => {
3045
- const { script: scriptEl, needAttach } = createScript({
3169
+ results.push(waitForScriptPreload({
3170
+ host,
3171
+ remoteInfo,
3046
3172
  url: jsUrl,
3047
- cb: () => {
3048
- },
3049
3173
  attrs: defaultAttrs,
3050
- createScriptHook: (url, attrs) => {
3051
- const res = host.loaderHook.lifecycle.createScript.emit({
3052
- url,
3053
- attrs,
3054
- remoteInfo
3055
- });
3056
- if (res instanceof HTMLScriptElement) return res;
3057
- },
3058
- needDeleteScript: true
3059
- });
3060
- needAttach && document.head.appendChild(scriptEl);
3174
+ context: createResourceContext(baseContext, "js")
3175
+ }));
3061
3176
  });
3062
3177
  }
3063
3178
  }
3179
+ return Promise.all(results);
3064
3180
  }
3065
3181
 
3066
3182
  // node_modules/@module-federation/runtime-core/dist/module/index.js
3183
+ function getAvailableExposeNames(remoteSnapshot) {
3184
+ if (!remoteSnapshot || !("modules" in remoteSnapshot) || !Array.isArray(remoteSnapshot.modules)) return;
3185
+ const exposes = remoteSnapshot.modules.map((module2) => module2.moduleName).filter(Boolean);
3186
+ return exposes.length ? exposes.join(",") : void 0;
3187
+ }
3067
3188
  function createRemoteEntryInitOptions(remoteInfo, hostShareScopeMap, rawInitScope) {
3068
3189
  const localShareScopeMap = hostShareScopeMap;
3069
3190
  const shareScopeKeys = Array.isArray(remoteInfo.shareScope) ? remoteInfo.shareScope : [remoteInfo.shareScope];
@@ -3093,27 +3214,69 @@ var Module$1 = class {
3093
3214
  this.remoteInfo = remoteInfo;
3094
3215
  this.host = host;
3095
3216
  }
3096
- async getEntry() {
3217
+ async getEntry(expose) {
3097
3218
  if (this.remoteEntryExports) return this.remoteEntryExports;
3098
3219
  const remoteEntryExports = await getRemoteEntry({
3099
3220
  origin: this.host,
3100
3221
  remoteInfo: this.remoteInfo,
3101
- remoteEntryExports: this.remoteEntryExports
3222
+ remoteEntryExports: this.remoteEntryExports,
3223
+ resourceContext: {
3224
+ initiator: "loadRemote",
3225
+ id: composeRemoteRequestId(this.remoteInfo.name, expose),
3226
+ resourceType: "remoteEntry"
3227
+ }
3102
3228
  });
3103
3229
  assert2(remoteEntryExports, `remoteEntryExports is undefined
3104
3230
  ${safeToString(this.remoteInfo)}`);
3105
3231
  this.remoteEntryExports = remoteEntryExports;
3106
3232
  return this.remoteEntryExports;
3107
3233
  }
3108
- async init(id, remoteSnapshot, rawInitScope) {
3109
- const remoteEntryExports = await this.getEntry();
3110
- if (this.inited) return remoteEntryExports;
3234
+ async init(id, remoteSnapshot, rawInitScope, expose) {
3235
+ const remoteEntryExports = await this.getEntry(expose);
3236
+ if (this.inited) {
3237
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
3238
+ id,
3239
+ remoteInfo: this.remoteInfo,
3240
+ remoteSnapshot,
3241
+ remoteEntryExports,
3242
+ cached: true,
3243
+ origin: this.host
3244
+ });
3245
+ return remoteEntryExports;
3246
+ }
3111
3247
  if (this.initPromise) {
3112
- await this.initPromise;
3248
+ try {
3249
+ await this.initPromise;
3250
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
3251
+ id,
3252
+ remoteInfo: this.remoteInfo,
3253
+ remoteSnapshot,
3254
+ remoteEntryExports,
3255
+ cached: true,
3256
+ origin: this.host
3257
+ });
3258
+ } catch (initError) {
3259
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
3260
+ id,
3261
+ remoteInfo: this.remoteInfo,
3262
+ remoteSnapshot,
3263
+ remoteEntryExports,
3264
+ error: initError,
3265
+ cached: true,
3266
+ origin: this.host
3267
+ });
3268
+ throw initError;
3269
+ }
3113
3270
  return remoteEntryExports;
3114
3271
  }
3115
3272
  this.initing = true;
3116
3273
  this.initPromise = (async () => {
3274
+ await this.host.loaderHook.lifecycle.beforeInitRemote.emit({
3275
+ id,
3276
+ remoteInfo: this.remoteInfo,
3277
+ remoteSnapshot,
3278
+ origin: this.host
3279
+ });
3117
3280
  const { remoteEntryInitOptions, shareScope, initScope } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap, rawInitScope);
3118
3281
  const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({
3119
3282
  shareScope,
@@ -3128,7 +3291,17 @@ var Module$1 = class {
3128
3291
  remoteEntryUrl: this.remoteInfo.entry,
3129
3292
  remoteEntryKey: this.remoteInfo.entryGlobalName
3130
3293
  }, void 0, optionsToMFContext(this.host.options));
3131
- await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
3294
+ try {
3295
+ await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
3296
+ } catch (initError) {
3297
+ error2(RUNTIME_015, runtimeDescMap, {
3298
+ hostName: this.host.name,
3299
+ remoteName: this.remoteInfo.name,
3300
+ remoteEntryUrl: this.remoteInfo.entry,
3301
+ remoteEntryKey: this.remoteInfo.entryGlobalName,
3302
+ shareScope: this.remoteInfo.shareScope
3303
+ }, `${initError}`, optionsToMFContext(this.host.options));
3304
+ }
3132
3305
  await this.host.hooks.lifecycle.initContainer.emit({
3133
3306
  ...initContainerOptions,
3134
3307
  id,
@@ -3139,6 +3312,23 @@ var Module$1 = class {
3139
3312
  })();
3140
3313
  try {
3141
3314
  await this.initPromise;
3315
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
3316
+ id,
3317
+ remoteInfo: this.remoteInfo,
3318
+ remoteSnapshot,
3319
+ remoteEntryExports,
3320
+ origin: this.host
3321
+ });
3322
+ } catch (initError) {
3323
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
3324
+ id,
3325
+ remoteInfo: this.remoteInfo,
3326
+ remoteSnapshot,
3327
+ remoteEntryExports,
3328
+ error: initError,
3329
+ origin: this.host
3330
+ });
3331
+ throw initError;
3142
3332
  } finally {
3143
3333
  this.initing = false;
3144
3334
  this.initPromise = void 0;
@@ -3147,20 +3337,83 @@ var Module$1 = class {
3147
3337
  }
3148
3338
  async get(id, expose, options, remoteSnapshot) {
3149
3339
  const { loadFactory = true } = options || { loadFactory: true };
3150
- const remoteEntryExports = await this.init(id, remoteSnapshot);
3340
+ const remoteEntryExports = await this.init(id, remoteSnapshot, void 0, expose);
3151
3341
  this.lib = remoteEntryExports;
3152
- let moduleFactory;
3153
- moduleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
3154
- remoteEntryExports,
3342
+ await this.host.loaderHook.lifecycle.beforeGetExpose.emit({
3343
+ id,
3155
3344
  expose,
3156
- moduleInfo: this.remoteInfo
3345
+ moduleInfo: this.remoteInfo,
3346
+ remoteEntryExports,
3347
+ origin: this.host
3157
3348
  });
3158
- if (!moduleFactory) moduleFactory = await remoteEntryExports.get(expose);
3159
- assert2(moduleFactory, `${getFMId(this.remoteInfo)} remote don't export ${expose}.`);
3349
+ let moduleFactory;
3350
+ try {
3351
+ const hookModuleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
3352
+ remoteEntryExports,
3353
+ expose,
3354
+ moduleInfo: this.remoteInfo
3355
+ });
3356
+ moduleFactory = typeof hookModuleFactory === "function" ? hookModuleFactory : void 0;
3357
+ if (!moduleFactory) moduleFactory = await remoteEntryExports.get(expose);
3358
+ if (!moduleFactory) error2(RUNTIME_014, runtimeDescMap, {
3359
+ hostName: this.host.name,
3360
+ remoteName: this.remoteInfo.name,
3361
+ remoteEntryUrl: this.remoteInfo.entry,
3362
+ expose,
3363
+ requestId: id,
3364
+ availableExposes: getAvailableExposeNames(remoteSnapshot)
3365
+ }, void 0, optionsToMFContext(this.host.options));
3366
+ await this.host.loaderHook.lifecycle.afterGetExpose.emit({
3367
+ id,
3368
+ expose,
3369
+ moduleInfo: this.remoteInfo,
3370
+ remoteEntryExports,
3371
+ moduleFactory,
3372
+ origin: this.host
3373
+ });
3374
+ } catch (getExposeError) {
3375
+ await this.host.loaderHook.lifecycle.afterGetExpose.emit({
3376
+ id,
3377
+ expose,
3378
+ moduleInfo: this.remoteInfo,
3379
+ remoteEntryExports,
3380
+ error: getExposeError,
3381
+ origin: this.host
3382
+ });
3383
+ throw getExposeError;
3384
+ }
3160
3385
  const symbolName = processModuleAlias(this.remoteInfo.name, expose);
3161
3386
  const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
3162
3387
  if (!loadFactory) return wrapModuleFactory;
3163
- return await wrapModuleFactory();
3388
+ await this.host.loaderHook.lifecycle.beforeExecuteFactory.emit({
3389
+ id,
3390
+ expose,
3391
+ moduleInfo: this.remoteInfo,
3392
+ loadFactory,
3393
+ origin: this.host
3394
+ });
3395
+ try {
3396
+ const exposeContent = await wrapModuleFactory();
3397
+ await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
3398
+ id,
3399
+ expose,
3400
+ moduleInfo: this.remoteInfo,
3401
+ loadFactory,
3402
+ exposeModule: exposeContent,
3403
+ origin: this.host
3404
+ });
3405
+ return exposeContent;
3406
+ } catch (executeFactoryError) {
3407
+ await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
3408
+ id,
3409
+ expose,
3410
+ moduleInfo: this.remoteInfo,
3411
+ loadFactory,
3412
+ error: executeFactoryError,
3413
+ origin: this.host
3414
+ });
3415
+ throw executeFactoryError;
3416
+ }
3164
3417
  }
3165
3418
  wraperFactory(moduleFactory, id) {
3166
3419
  function defineModuleId(res, id2) {
@@ -3169,13 +3422,12 @@ var Module$1 = class {
3169
3422
  enumerable: false
3170
3423
  });
3171
3424
  }
3172
- if (moduleFactory instanceof Promise) return async () => {
3173
- const res = await moduleFactory();
3174
- defineModuleId(res, id);
3175
- return res;
3176
- };
3177
- else return () => {
3425
+ return () => {
3178
3426
  const res = moduleFactory();
3427
+ if (res instanceof Promise) return res.then((asyncRes) => {
3428
+ defineModuleId(asyncRes, id);
3429
+ return asyncRes;
3430
+ });
3179
3431
  defineModuleId(res, id);
3180
3432
  return res;
3181
3433
  };
@@ -3202,7 +3454,8 @@ var SyncHook = class {
3202
3454
  emit(...data) {
3203
3455
  let result;
3204
3456
  if (this.listeners.size > 0) this.listeners.forEach((fn) => {
3205
- result = fn(...data);
3457
+ const nextResult = fn(...data);
3458
+ if (nextResult !== void 0) result = nextResult;
3206
3459
  });
3207
3460
  return result;
3208
3461
  }
@@ -3223,7 +3476,10 @@ var AsyncHook = class extends SyncHook {
3223
3476
  let i7 = 0;
3224
3477
  const call = (prev) => {
3225
3478
  if (prev === false) return false;
3226
- else if (i7 < ls.length) return Promise.resolve(ls[i7++].apply(null, data)).then(call);
3479
+ else if (i7 < ls.length) return Promise.resolve(ls[i7++].apply(null, data)).then((result2) => {
3480
+ if (result2 === void 0 || data.length === 1 && result2 === data[0]) return call(prev);
3481
+ return call(result2);
3482
+ });
3227
3483
  else return prev;
3228
3484
  };
3229
3485
  result = call();
@@ -3250,6 +3506,7 @@ var SyncWaterfallHook = class extends SyncHook {
3250
3506
  if (!isObject2(data)) error2(`The data for the "${this.type}" hook should be an object.`);
3251
3507
  for (const fn of this.listeners) try {
3252
3508
  const tempData = fn(data);
3509
+ if (tempData === void 0) continue;
3253
3510
  if (checkReturnData(data, tempData)) data = tempData;
3254
3511
  else {
3255
3512
  this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
@@ -3281,14 +3538,16 @@ var AsyncWaterfallHook = class extends SyncHook {
3281
3538
  return data;
3282
3539
  };
3283
3540
  const call = (prevData) => {
3284
- if (checkReturnData(data, prevData)) {
3285
- data = prevData;
3286
- if (i7 < ls.length) try {
3287
- return Promise.resolve(ls[i7++](data)).then(call, processError);
3288
- } catch (e7) {
3289
- return processError(e7);
3290
- }
3291
- } else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
3541
+ if (prevData !== void 0 && checkReturnData(data, prevData)) data = prevData;
3542
+ else if (prevData !== void 0) {
3543
+ this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
3544
+ return data;
3545
+ }
3546
+ if (i7 < ls.length) try {
3547
+ return Promise.resolve(ls[i7++](data)).then(call, processError);
3548
+ } catch (e7) {
3549
+ return processError(e7);
3550
+ }
3292
3551
  return data;
3293
3552
  };
3294
3553
  return Promise.resolve(call(data));
@@ -3347,7 +3606,7 @@ function snapshotPlugin() {
3347
3606
  if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
3348
3607
  const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo({
3349
3608
  moduleInfo: remote,
3350
- id
3609
+ id: composeRemoteRequestId(remote.name, expose)
3351
3610
  });
3352
3611
  assignRemoteInfo(remoteInfo, remoteSnapshot);
3353
3612
  const preloadOptions = {
@@ -3368,7 +3627,10 @@ function snapshotPlugin() {
3368
3627
  remoteSnapshot,
3369
3628
  globalSnapshot
3370
3629
  });
3371
- if (assets) preloadAssets(remoteInfo, origin, assets, false);
3630
+ if (assets) preloadAssets(remoteInfo, origin, assets, false, {
3631
+ initiator: "loadRemote",
3632
+ id
3633
+ }).catch(() => void 0);
3372
3634
  return {
3373
3635
  ...args,
3374
3636
  remoteSnapshot
@@ -3588,11 +3850,12 @@ var SnapshotHandler = class {
3588
3850
  this.HostInstance = HostInstance;
3589
3851
  this.loaderHook = HostInstance.loaderHook;
3590
3852
  }
3591
- async loadRemoteSnapshotInfo({ moduleInfo, id, expose }) {
3853
+ async loadRemoteSnapshotInfo({ moduleInfo, id, initiator = "loadRemote" }) {
3592
3854
  const { options } = this.HostInstance;
3593
3855
  await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
3594
3856
  options,
3595
- moduleInfo
3857
+ moduleInfo,
3858
+ origin: this.HostInstance
3596
3859
  });
3597
3860
  let hostSnapshot = getGlobalSnapshotInfoByModuleInfo({
3598
3861
  name: this.HostInstance.options.name,
@@ -3624,7 +3887,10 @@ var SnapshotHandler = class {
3624
3887
  let gSnapshot;
3625
3888
  if (globalRemoteSnapshot) if (isManifestProvider(globalRemoteSnapshot)) {
3626
3889
  const remoteEntry = isBrowserEnvValue ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || "";
3627
- const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
3890
+ const moduleSnapshot = await this.loadManifestSnapshot(remoteEntry, moduleInfo, {}, {
3891
+ initiator,
3892
+ id: id || moduleInfo.name
3893
+ });
3628
3894
  const globalSnapshotRes2 = setGlobalSnapshotInfoByModuleInfo({
3629
3895
  ...moduleInfo,
3630
3896
  entry: remoteEntry
@@ -3642,15 +3908,12 @@ var SnapshotHandler = class {
3642
3908
  gSnapshot = globalSnapshotRes;
3643
3909
  }
3644
3910
  else if (isRemoteInfoWithEntry(moduleInfo)) {
3645
- const moduleSnapshot = await this.getManifestJson(moduleInfo.entry, moduleInfo, {});
3646
- const globalSnapshotRes2 = setGlobalSnapshotInfoByModuleInfo(moduleInfo, moduleSnapshot);
3647
- const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
3648
- options: this.HostInstance.options,
3649
- moduleInfo,
3650
- remoteSnapshot: moduleSnapshot,
3651
- from: "global"
3911
+ const moduleSnapshot = await this.loadManifestSnapshot(moduleInfo.entry, moduleInfo, {}, {
3912
+ initiator,
3913
+ id: id || moduleInfo.name
3652
3914
  });
3653
- mSnapshot = remoteSnapshotRes;
3915
+ const globalSnapshotRes2 = setGlobalSnapshotInfoByModuleInfo(moduleInfo, moduleSnapshot);
3916
+ mSnapshot = moduleSnapshot;
3654
3917
  gSnapshot = globalSnapshotRes2;
3655
3918
  } else error2(RUNTIME_007, runtimeDescMap, {
3656
3919
  remoteName: moduleInfo.name,
@@ -3673,12 +3936,17 @@ var SnapshotHandler = class {
3673
3936
  getGlobalRemoteInfo(moduleInfo) {
3674
3937
  return getGlobalRemoteInfo(moduleInfo, this.HostInstance);
3675
3938
  }
3676
- async getManifestJson(manifestUrl, moduleInfo, extraOptions) {
3939
+ async getManifestJson(manifestUrl, moduleInfo, extraOptions, resourceOptions) {
3677
3940
  const getManifest = async () => {
3941
+ const remoteInfo = getRemoteInfo(moduleInfo);
3678
3942
  let manifestJson = this.manifestCache.get(manifestUrl);
3679
3943
  if (manifestJson) return manifestJson;
3680
3944
  try {
3681
- let res = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {}, getRemoteInfo(moduleInfo));
3945
+ let res = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {}, remoteInfo, resourceOptions ? {
3946
+ ...resourceOptions,
3947
+ url: manifestUrl,
3948
+ resourceType: "manifest"
3949
+ } : void 0);
3682
3950
  if (!res || !(res instanceof Response)) res = await fetch(manifestUrl, {});
3683
3951
  manifestJson = await res.json();
3684
3952
  } catch (err) {
@@ -3687,6 +3955,7 @@ var SnapshotHandler = class {
3687
3955
  error: err,
3688
3956
  from: "runtime",
3689
3957
  lifecycle: "afterResolve",
3958
+ remote: remoteInfo,
3690
3959
  origin: this.HostInstance
3691
3960
  });
3692
3961
  if (!manifestJson) {
@@ -3698,16 +3967,33 @@ var SnapshotHandler = class {
3698
3967
  }, `${err}`, optionsToMFContext(this.HostInstance.options));
3699
3968
  }
3700
3969
  }
3701
- assert2(manifestJson.metaData && manifestJson.exposes && manifestJson.shared, `"${manifestUrl}" is not a valid federation manifest for remote "${moduleInfo.name}". Missing required fields: ${[
3970
+ const missingRequiredFields = [
3702
3971
  !manifestJson.metaData && "metaData",
3703
3972
  !manifestJson.exposes && "exposes",
3704
3973
  !manifestJson.shared && "shared"
3705
- ].filter(Boolean).join(", ")}.`);
3974
+ ].filter(Boolean);
3975
+ if (missingRequiredFields.length > 0) await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
3976
+ id: manifestUrl,
3977
+ error: /* @__PURE__ */ new Error(`"${manifestUrl}" is not a valid federation manifest for remote "${moduleInfo.name}". Missing required fields: ${missingRequiredFields.join(", ")}.`),
3978
+ from: "runtime",
3979
+ lifecycle: "afterResolve",
3980
+ remote: remoteInfo,
3981
+ origin: this.HostInstance
3982
+ });
3983
+ if (missingRequiredFields.length > 0) error2(RUNTIME_013, runtimeDescMap, {
3984
+ manifestUrl,
3985
+ moduleName: moduleInfo.name,
3986
+ hostName: this.HostInstance.options.name,
3987
+ missingFields: missingRequiredFields.join(",")
3988
+ }, void 0, optionsToMFContext(this.HostInstance.options));
3706
3989
  this.manifestCache.set(manifestUrl, manifestJson);
3707
3990
  return manifestJson;
3708
3991
  };
3992
+ return getManifest();
3993
+ }
3994
+ async loadManifestSnapshot(manifestUrl, moduleInfo, extraOptions, resourceOptions) {
3709
3995
  const asyncLoadProcess = async () => {
3710
- const manifestJson = await getManifest();
3996
+ const manifestJson = await this.getManifestJson(manifestUrl, moduleInfo, extraOptions, resourceOptions);
3711
3997
  const remoteSnapshot = generateSnapshotFromManifest(manifestJson, { version: manifestUrl });
3712
3998
  const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
3713
3999
  options: this.HostInstance.options,
@@ -3732,6 +4018,8 @@ var SharedHandler = class {
3732
4018
  afterResolve: new AsyncWaterfallHook("afterResolve"),
3733
4019
  beforeLoadShare: new AsyncWaterfallHook("beforeLoadShare"),
3734
4020
  loadShare: new AsyncHook(),
4021
+ afterLoadShare: new SyncHook("afterLoadShare"),
4022
+ errorLoadShare: new SyncHook("errorLoadShare"),
3735
4023
  resolveShare: new SyncWaterfallHook("resolveShare"),
3736
4024
  initContainerShareScopeMap: new SyncWaterfallHook("initContainerShareScopeMap")
3737
4025
  });
@@ -3740,6 +4028,37 @@ var SharedHandler = class {
3740
4028
  this.initTokens = {};
3741
4029
  this._setGlobalShareScopeMap(host.options);
3742
4030
  }
4031
+ emitAfterLoadShare({ lifecycle, pkgName, shareInfo, selectedShared }) {
4032
+ try {
4033
+ this.hooks.lifecycle.afterLoadShare.emit({
4034
+ pkgName,
4035
+ shareInfo,
4036
+ selectedShared,
4037
+ shared: this.host.options.shared,
4038
+ shareScopeMap: this.shareScopeMap,
4039
+ lifecycle,
4040
+ origin: this.host
4041
+ });
4042
+ } catch (error3) {
4043
+ warn$1(error3);
4044
+ }
4045
+ }
4046
+ emitErrorLoadShare({ lifecycle, pkgName, shareInfo, error: error3, recovered }) {
4047
+ try {
4048
+ this.hooks.lifecycle.errorLoadShare.emit({
4049
+ pkgName,
4050
+ shareInfo,
4051
+ shared: this.host.options.shared,
4052
+ shareScopeMap: this.shareScopeMap,
4053
+ lifecycle,
4054
+ origin: this.host,
4055
+ error: error3,
4056
+ recovered
4057
+ });
4058
+ } catch (hookError) {
4059
+ warn$1(hookError);
4060
+ }
4061
+ }
3743
4062
  registerShared(globalOptions, userOptions) {
3744
4063
  const { newShareInfos, allShareInfos } = formatShareConfigs(globalOptions, userOptions);
3745
4064
  Object.keys(newShareInfos).forEach((sharedKey) => {
@@ -3773,77 +4092,123 @@ var SharedHandler = class {
3773
4092
  extraOptions,
3774
4093
  shareInfos: host.options.shared
3775
4094
  });
3776
- if (shareOptions?.scope) await Promise.all(shareOptions.scope.map(async (shareScope) => {
3777
- await Promise.all(this.initializeSharing(shareScope, { strategy: shareOptions.strategy }));
3778
- }));
3779
- const { shareInfo: shareOptionsRes } = await this.hooks.lifecycle.beforeLoadShare.emit({
3780
- pkgName,
3781
- shareInfo: shareOptions,
3782
- shared: host.options.shared,
3783
- origin: host
3784
- });
3785
- 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.`);
3786
- const { shared: registeredShared, useTreesShaking } = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare) || {};
3787
- if (registeredShared) {
3788
- const targetShared = directShare(registeredShared, useTreesShaking);
3789
- if (targetShared.lib) {
3790
- addUseIn(targetShared, host.options.name);
3791
- return targetShared.lib;
3792
- } else if (targetShared.loading && !targetShared.loaded) {
3793
- const factory = await targetShared.loading;
3794
- targetShared.loaded = true;
3795
- if (!targetShared.lib) targetShared.lib = factory;
3796
- addUseIn(targetShared, host.options.name);
3797
- return factory;
3798
- } else {
3799
- const asyncLoadProcess = async () => {
3800
- const factory = await targetShared.get();
4095
+ let shareOptionsRes = shareOptions;
4096
+ try {
4097
+ if (shareOptions?.scope) await Promise.all(shareOptions.scope.map(async (shareScope) => {
4098
+ await Promise.all(this.initializeSharing(shareScope, { strategy: shareOptions.strategy }));
4099
+ }));
4100
+ shareOptionsRes = (await this.hooks.lifecycle.beforeLoadShare.emit({
4101
+ pkgName,
4102
+ shareInfo: shareOptions,
4103
+ shared: host.options.shared,
4104
+ origin: host
4105
+ })).shareInfo;
4106
+ 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.`);
4107
+ const resolvedShareOptions = shareOptionsRes;
4108
+ const { shared: registeredShared, useTreesShaking } = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare) || {};
4109
+ if (registeredShared) {
4110
+ const targetShared = directShare(registeredShared, useTreesShaking);
4111
+ if (targetShared.lib) {
3801
4112
  addUseIn(targetShared, host.options.name);
4113
+ this.emitAfterLoadShare({
4114
+ lifecycle: "loadShare",
4115
+ pkgName,
4116
+ shareInfo: resolvedShareOptions,
4117
+ selectedShared: registeredShared
4118
+ });
4119
+ return targetShared.lib;
4120
+ } else if (targetShared.loading && !targetShared.loaded) {
4121
+ const factory = await targetShared.loading;
3802
4122
  targetShared.loaded = true;
3803
- targetShared.lib = factory;
4123
+ if (!targetShared.lib) targetShared.lib = factory;
4124
+ addUseIn(targetShared, host.options.name);
4125
+ this.emitAfterLoadShare({
4126
+ lifecycle: "loadShare",
4127
+ pkgName,
4128
+ shareInfo: resolvedShareOptions,
4129
+ selectedShared: registeredShared
4130
+ });
4131
+ return factory;
4132
+ } else {
4133
+ const asyncLoadProcess = async () => {
4134
+ const factory2 = await targetShared.get();
4135
+ addUseIn(targetShared, host.options.name);
4136
+ targetShared.loaded = true;
4137
+ targetShared.lib = factory2;
4138
+ return factory2;
4139
+ };
4140
+ const loading = asyncLoadProcess();
4141
+ this.setShared({
4142
+ pkgName,
4143
+ loaded: false,
4144
+ shared: registeredShared,
4145
+ from: host.options.name,
4146
+ lib: null,
4147
+ loading,
4148
+ treeShaking: useTreesShaking ? targetShared : void 0
4149
+ });
4150
+ const factory = await loading;
4151
+ this.emitAfterLoadShare({
4152
+ lifecycle: "loadShare",
4153
+ pkgName,
4154
+ shareInfo: resolvedShareOptions,
4155
+ selectedShared: registeredShared
4156
+ });
3804
4157
  return factory;
4158
+ }
4159
+ } else {
4160
+ if (extraOptions?.customShareInfo) {
4161
+ this.emitErrorLoadShare({
4162
+ lifecycle: "loadShare",
4163
+ pkgName,
4164
+ shareInfo: resolvedShareOptions,
4165
+ recovered: true
4166
+ });
4167
+ return false;
4168
+ }
4169
+ const _useTreeShaking = shouldUseTreeShaking(resolvedShareOptions.treeShaking);
4170
+ const targetShared = directShare(resolvedShareOptions, _useTreeShaking);
4171
+ const asyncLoadProcess = async () => {
4172
+ const factory2 = await targetShared.get();
4173
+ targetShared.lib = factory2;
4174
+ targetShared.loaded = true;
4175
+ addUseIn(targetShared, host.options.name);
4176
+ const { shared: gShared, useTreesShaking: gUseTreeShaking } = getRegisteredShare(this.shareScopeMap, pkgName, resolvedShareOptions, this.hooks.lifecycle.resolveShare) || {};
4177
+ if (gShared) {
4178
+ const targetGShared = directShare(gShared, gUseTreeShaking);
4179
+ targetGShared.lib = factory2;
4180
+ targetGShared.loaded = true;
4181
+ gShared.from = resolvedShareOptions.from;
4182
+ }
4183
+ return factory2;
3805
4184
  };
3806
4185
  const loading = asyncLoadProcess();
3807
4186
  this.setShared({
3808
4187
  pkgName,
3809
4188
  loaded: false,
3810
- shared: registeredShared,
4189
+ shared: resolvedShareOptions,
3811
4190
  from: host.options.name,
3812
4191
  lib: null,
3813
4192
  loading,
3814
- treeShaking: useTreesShaking ? targetShared : void 0
4193
+ treeShaking: _useTreeShaking ? targetShared : void 0
4194
+ });
4195
+ const factory = await loading;
4196
+ this.emitAfterLoadShare({
4197
+ lifecycle: "loadShare",
4198
+ pkgName,
4199
+ shareInfo: resolvedShareOptions,
4200
+ selectedShared: resolvedShareOptions
3815
4201
  });
3816
- return loading;
3817
- }
3818
- } else {
3819
- if (extraOptions?.customShareInfo) return false;
3820
- const _useTreeShaking = shouldUseTreeShaking(shareOptionsRes.treeShaking);
3821
- const targetShared = directShare(shareOptionsRes, _useTreeShaking);
3822
- const asyncLoadProcess = async () => {
3823
- const factory = await targetShared.get();
3824
- targetShared.lib = factory;
3825
- targetShared.loaded = true;
3826
- addUseIn(targetShared, host.options.name);
3827
- const { shared: gShared, useTreesShaking: gUseTreeShaking } = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare) || {};
3828
- if (gShared) {
3829
- const targetGShared = directShare(gShared, gUseTreeShaking);
3830
- targetGShared.lib = factory;
3831
- targetGShared.loaded = true;
3832
- gShared.from = shareOptionsRes.from;
3833
- }
3834
4202
  return factory;
3835
- };
3836
- const loading = asyncLoadProcess();
3837
- this.setShared({
4203
+ }
4204
+ } catch (shareError) {
4205
+ this.emitErrorLoadShare({
4206
+ lifecycle: "loadShare",
3838
4207
  pkgName,
3839
- loaded: false,
3840
- shared: shareOptionsRes,
3841
- from: host.options.name,
3842
- lib: null,
3843
- loading,
3844
- treeShaking: _useTreeShaking ? targetShared : void 0
4208
+ shareInfo: shareOptionsRes,
4209
+ error: shareError
3845
4210
  });
3846
- return loading;
4211
+ throw shareError;
3847
4212
  }
3848
4213
  }
3849
4214
  /**
@@ -3888,6 +4253,7 @@ var SharedHandler = class {
3888
4253
  error: error3,
3889
4254
  from: "runtime",
3890
4255
  lifecycle: "beforeLoadShare",
4256
+ remote: module2.remoteInfo,
3891
4257
  origin: host
3892
4258
  });
3893
4259
  if (!remoteEntryExports) return;
@@ -3915,58 +4281,92 @@ var SharedHandler = class {
3915
4281
  extraOptions,
3916
4282
  shareInfos: host.options.shared
3917
4283
  });
3918
- if (shareOptions?.scope) shareOptions.scope.forEach((shareScope) => {
3919
- this.initializeSharing(shareScope, { strategy: shareOptions.strategy });
3920
- });
3921
- const { shared: registeredShared, useTreesShaking } = getRegisteredShare(this.shareScopeMap, pkgName, shareOptions, this.hooks.lifecycle.resolveShare) || {};
3922
- if (registeredShared) {
3923
- if (typeof registeredShared.lib === "function") {
3924
- addUseIn(registeredShared, host.options.name);
3925
- if (!registeredShared.loaded) {
3926
- registeredShared.loaded = true;
3927
- if (registeredShared.from === host.options.name) shareOptions.loaded = true;
3928
- }
3929
- return registeredShared.lib;
3930
- }
3931
- if (typeof registeredShared.get === "function") {
3932
- const module2 = registeredShared.get();
3933
- if (!(module2 instanceof Promise)) {
4284
+ try {
4285
+ if (shareOptions?.scope) shareOptions.scope.forEach((shareScope) => {
4286
+ this.initializeSharing(shareScope, { strategy: shareOptions.strategy });
4287
+ });
4288
+ const { shared: registeredShared } = getRegisteredShare(this.shareScopeMap, pkgName, shareOptions, this.hooks.lifecycle.resolveShare) || {};
4289
+ if (registeredShared) {
4290
+ if (typeof registeredShared.lib === "function") {
3934
4291
  addUseIn(registeredShared, host.options.name);
3935
- this.setShared({
4292
+ if (!registeredShared.loaded) {
4293
+ registeredShared.loaded = true;
4294
+ if (registeredShared.from === host.options.name) shareOptions.loaded = true;
4295
+ }
4296
+ this.emitAfterLoadShare({
4297
+ lifecycle: "loadShareSync",
3936
4298
  pkgName,
3937
- loaded: true,
3938
- from: host.options.name,
3939
- lib: module2,
3940
- shared: registeredShared
4299
+ shareInfo: shareOptions,
4300
+ selectedShared: registeredShared
3941
4301
  });
3942
- return module2;
4302
+ return registeredShared.lib;
4303
+ }
4304
+ if (typeof registeredShared.get === "function") {
4305
+ const module2 = registeredShared.get();
4306
+ if (!(module2 instanceof Promise)) {
4307
+ addUseIn(registeredShared, host.options.name);
4308
+ this.setShared({
4309
+ pkgName,
4310
+ loaded: true,
4311
+ from: host.options.name,
4312
+ lib: module2,
4313
+ shared: registeredShared
4314
+ });
4315
+ this.emitAfterLoadShare({
4316
+ lifecycle: "loadShareSync",
4317
+ pkgName,
4318
+ shareInfo: shareOptions,
4319
+ selectedShared: registeredShared
4320
+ });
4321
+ return module2;
4322
+ }
3943
4323
  }
3944
4324
  }
3945
- }
3946
- if (shareOptions.lib) {
3947
- if (!shareOptions.loaded) shareOptions.loaded = true;
3948
- return shareOptions.lib;
3949
- }
3950
- if (shareOptions.get) {
3951
- const module2 = shareOptions.get();
3952
- if (module2 instanceof Promise) error2(extraOptions?.from === "build" ? RUNTIME_005 : RUNTIME_006, runtimeDescMap, {
4325
+ if (shareOptions.lib) {
4326
+ if (!shareOptions.loaded) shareOptions.loaded = true;
4327
+ this.emitAfterLoadShare({
4328
+ lifecycle: "loadShareSync",
4329
+ pkgName,
4330
+ shareInfo: shareOptions,
4331
+ selectedShared: shareOptions
4332
+ });
4333
+ return shareOptions.lib;
4334
+ }
4335
+ if (shareOptions.get) {
4336
+ const module2 = shareOptions.get();
4337
+ if (module2 instanceof Promise) error2(extraOptions?.from === "build" ? RUNTIME_005 : RUNTIME_006, runtimeDescMap, {
4338
+ hostName: host.options.name,
4339
+ sharedPkgName: pkgName
4340
+ }, void 0, optionsToMFContext(host.options));
4341
+ shareOptions.lib = module2;
4342
+ this.setShared({
4343
+ pkgName,
4344
+ loaded: true,
4345
+ from: host.options.name,
4346
+ lib: shareOptions.lib,
4347
+ shared: shareOptions
4348
+ });
4349
+ this.emitAfterLoadShare({
4350
+ lifecycle: "loadShareSync",
4351
+ pkgName,
4352
+ shareInfo: shareOptions,
4353
+ selectedShared: shareOptions
4354
+ });
4355
+ return shareOptions.lib;
4356
+ }
4357
+ error2(RUNTIME_006, runtimeDescMap, {
3953
4358
  hostName: host.options.name,
3954
4359
  sharedPkgName: pkgName
3955
4360
  }, void 0, optionsToMFContext(host.options));
3956
- shareOptions.lib = module2;
3957
- this.setShared({
4361
+ } catch (shareError) {
4362
+ this.emitErrorLoadShare({
4363
+ lifecycle: "loadShareSync",
3958
4364
  pkgName,
3959
- loaded: true,
3960
- from: host.options.name,
3961
- lib: shareOptions.lib,
3962
- shared: shareOptions
4365
+ shareInfo: shareOptions,
4366
+ error: shareError
3963
4367
  });
3964
- return shareOptions.lib;
4368
+ throw shareError;
3965
4369
  }
3966
- error2(RUNTIME_006, runtimeDescMap, {
3967
- hostName: host.options.name,
3968
- sharedPkgName: pkgName
3969
- }, void 0, optionsToMFContext(host.options));
3970
4370
  }
3971
4371
  initShareScopeMap(scopeName, shareScope, extraOptions = {}) {
3972
4372
  const { host } = this;
@@ -4019,12 +4419,14 @@ var RemoteHandler = class {
4019
4419
  beforeRegisterRemote: new SyncWaterfallHook("beforeRegisterRemote"),
4020
4420
  registerRemote: new SyncWaterfallHook("registerRemote"),
4021
4421
  beforeRequest: new AsyncWaterfallHook("beforeRequest"),
4422
+ afterMatchRemote: new AsyncHook("afterMatchRemote"),
4022
4423
  onLoad: new AsyncHook("onLoad"),
4424
+ afterLoadRemote: new AsyncHook("afterLoadRemote"),
4023
4425
  handlePreloadModule: new SyncHook("handlePreloadModule"),
4024
4426
  errorLoadRemote: new AsyncHook("errorLoadRemote"),
4025
4427
  beforePreloadRemote: new AsyncHook("beforePreloadRemote"),
4026
4428
  generatePreloadAssets: new AsyncHook("generatePreloadAssets"),
4027
- afterPreloadRemote: new AsyncHook(),
4429
+ afterPreloadRemote: new AsyncHook("afterPreloadRemote"),
4028
4430
  loadEntry: new AsyncHook()
4029
4431
  });
4030
4432
  this.host = host;
@@ -4061,10 +4463,18 @@ var RemoteHandler = class {
4061
4463
  }
4062
4464
  async loadRemote(id, options) {
4063
4465
  const { host } = this;
4466
+ const startMatchInfo = matchRemoteWithNameAndExpose(host.options.remotes, id);
4467
+ let completeRequestId = id;
4468
+ let completeExpose = startMatchInfo?.expose;
4469
+ let completeRemote = startMatchInfo ? getRemoteInfo(startMatchInfo.remote) : void 0;
4470
+ let afterLoadRemoteArgs;
4064
4471
  try {
4065
4472
  const { loadFactory = true } = options || { loadFactory: true };
4066
4473
  const { module: module2, moduleOptions, remoteMatchInfo } = await this.getRemoteModuleAndOptions({ id });
4067
4474
  const { pkgNameOrAlias, remote, expose, id: idRes, remoteSnapshot } = remoteMatchInfo;
4475
+ completeRequestId = idRes;
4476
+ completeExpose = expose;
4477
+ completeRemote = getRemoteInfo(remote);
4068
4478
  const moduleOrFactory = await module2.get(idRes, expose, options, remoteSnapshot);
4069
4479
  const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
4070
4480
  id: idRes,
@@ -4078,44 +4488,155 @@ var RemoteHandler = class {
4078
4488
  origin: host
4079
4489
  });
4080
4490
  this.setIdToRemoteMap(id, remoteMatchInfo);
4491
+ afterLoadRemoteArgs = {
4492
+ id: completeRequestId,
4493
+ expose: completeExpose,
4494
+ remote: completeRemote,
4495
+ options,
4496
+ origin: host
4497
+ };
4081
4498
  if (typeof moduleWrapper === "function") return moduleWrapper;
4082
4499
  return moduleOrFactory;
4083
4500
  } catch (error3) {
4084
4501
  const { from = "runtime" } = options || { from: "runtime" };
4085
- const failOver = await this.hooks.lifecycle.errorLoadRemote.emit({
4086
- id,
4502
+ let failOver;
4503
+ try {
4504
+ failOver = await this.hooks.lifecycle.errorLoadRemote.emit({
4505
+ id,
4506
+ error: error3,
4507
+ from,
4508
+ lifecycle: "onLoad",
4509
+ expose: completeExpose,
4510
+ remote: completeRemote,
4511
+ origin: host
4512
+ });
4513
+ } catch (hookError) {
4514
+ afterLoadRemoteArgs = {
4515
+ id: completeRequestId,
4516
+ expose: completeExpose,
4517
+ remote: completeRemote,
4518
+ options,
4519
+ error: hookError,
4520
+ origin: host
4521
+ };
4522
+ throw hookError;
4523
+ }
4524
+ if (!failOver) {
4525
+ afterLoadRemoteArgs = {
4526
+ id: completeRequestId,
4527
+ expose: completeExpose,
4528
+ remote: completeRemote,
4529
+ options,
4530
+ error: error3,
4531
+ origin: host
4532
+ };
4533
+ throw error3;
4534
+ }
4535
+ afterLoadRemoteArgs = {
4536
+ id: completeRequestId,
4537
+ expose: completeExpose,
4538
+ remote: completeRemote,
4539
+ options,
4087
4540
  error: error3,
4088
- from,
4089
- lifecycle: "onLoad",
4090
- origin: host
4091
- });
4092
- if (!failOver) throw error3;
4541
+ origin: host,
4542
+ recovered: true
4543
+ };
4093
4544
  return failOver;
4545
+ } finally {
4546
+ if (afterLoadRemoteArgs) await this.hooks.lifecycle.afterLoadRemote.emit(afterLoadRemoteArgs);
4094
4547
  }
4095
4548
  }
4096
4549
  async preloadRemote(preloadOptions) {
4097
4550
  const { host } = this;
4551
+ const preloadResults = [];
4098
4552
  await this.hooks.lifecycle.beforePreloadRemote.emit({
4099
4553
  preloadOps: preloadOptions,
4100
4554
  options: host.options,
4101
4555
  origin: host
4102
4556
  });
4103
4557
  const preloadOps = formatPreloadArgs(host.options.remotes, preloadOptions);
4104
- await Promise.all(preloadOps.map(async (ops) => {
4105
- const { remote } = ops;
4558
+ const createPreloadAssetOps = (ops) => {
4559
+ const { preloadConfig, remote } = ops;
4560
+ const exposes = preloadConfig.exposes || [];
4561
+ if (!exposes.length) return [{
4562
+ ops,
4563
+ id: `${remote.name}/*`
4564
+ }];
4565
+ return exposes.map((expose) => ({
4566
+ ops: {
4567
+ ...ops,
4568
+ preloadConfig: {
4569
+ ...preloadConfig,
4570
+ exposes: [expose]
4571
+ }
4572
+ },
4573
+ id: composeRemoteRequestId(remote.name, expose)
4574
+ }));
4575
+ };
4576
+ let preloadError;
4577
+ await Promise.all(preloadOps.flatMap(createPreloadAssetOps).map(async (assetOps) => {
4578
+ const { ops, id: preloadId } = assetOps;
4579
+ const { remote, preloadConfig } = ops;
4106
4580
  const remoteInfo = getRemoteInfo(remote);
4107
- const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({ moduleInfo: remote });
4108
- const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
4109
- origin: host,
4110
- preloadOptions: ops,
4111
- remote,
4112
- remoteInfo,
4113
- globalSnapshot,
4114
- remoteSnapshot
4115
- });
4116
- if (!assets) return;
4117
- preloadAssets(remoteInfo, host, assets);
4581
+ try {
4582
+ const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({
4583
+ moduleInfo: remote,
4584
+ id: preloadId,
4585
+ initiator: "preloadRemote"
4586
+ });
4587
+ const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
4588
+ origin: host,
4589
+ preloadOptions: ops,
4590
+ remote,
4591
+ remoteInfo,
4592
+ globalSnapshot,
4593
+ remoteSnapshot
4594
+ });
4595
+ if (!assets) return;
4596
+ const results = await preloadAssets(remoteInfo, host, assets, true, {
4597
+ initiator: "preloadRemote",
4598
+ id: preloadId
4599
+ });
4600
+ preloadResults.push({
4601
+ remote,
4602
+ remoteInfo,
4603
+ preloadConfig,
4604
+ id: preloadId,
4605
+ results
4606
+ });
4607
+ } catch (error3) {
4608
+ preloadResults.push({
4609
+ remote,
4610
+ remoteInfo,
4611
+ preloadConfig,
4612
+ id: preloadId,
4613
+ results: [{
4614
+ url: remoteInfo.entry,
4615
+ status: "error",
4616
+ resourceType: /\.json(?:$|[?#])/i.test(remoteInfo.entry) ? "manifest" : "remoteEntry",
4617
+ initiator: "preloadRemote",
4618
+ id: preloadId,
4619
+ error: error3
4620
+ }]
4621
+ });
4622
+ }
4118
4623
  }));
4624
+ const failedResults = preloadResults.flatMap((preloadResult) => preloadResult.results.filter((result) => result.status === "error" || result.status === "timeout"));
4625
+ if (failedResults.length > 0) {
4626
+ preloadError = /* @__PURE__ */ new Error(`preloadRemote failed to load ${failedResults.length} resource(s).`);
4627
+ Object.assign(preloadError, {
4628
+ results: preloadResults,
4629
+ failedResults
4630
+ });
4631
+ }
4632
+ await this.hooks.lifecycle.afterPreloadRemote.emit({
4633
+ preloadOps: preloadOptions,
4634
+ options: host.options,
4635
+ origin: host,
4636
+ results: preloadResults,
4637
+ error: preloadError
4638
+ });
4639
+ if (preloadError) throw preloadError;
4119
4640
  }
4120
4641
  registerRemotes(remotes, options) {
4121
4642
  const { host } = this;
@@ -4146,12 +4667,29 @@ var RemoteHandler = class {
4146
4667
  }
4147
4668
  const { id: idRes } = loadRemoteArgs;
4148
4669
  const remoteSplitInfo = matchRemoteWithNameAndExpose(host.options.remotes, idRes);
4149
- if (!remoteSplitInfo) error2(RUNTIME_004, runtimeDescMap, {
4150
- hostName: host.options.name,
4151
- requestId: idRes
4152
- }, void 0, optionsToMFContext(host.options));
4670
+ if (!remoteSplitInfo) try {
4671
+ error2(RUNTIME_004, runtimeDescMap, {
4672
+ hostName: host.options.name,
4673
+ requestId: idRes
4674
+ }, void 0, optionsToMFContext(host.options));
4675
+ } catch (matchError) {
4676
+ await this.hooks.lifecycle.afterMatchRemote.emit({
4677
+ id: idRes,
4678
+ options: host.options,
4679
+ error: matchError,
4680
+ origin: host
4681
+ });
4682
+ throw matchError;
4683
+ }
4153
4684
  const { remote: rawRemote } = remoteSplitInfo;
4154
4685
  const remoteInfo = getRemoteInfo(rawRemote);
4686
+ await this.hooks.lifecycle.afterMatchRemote.emit({
4687
+ id: idRes,
4688
+ ...remoteSplitInfo,
4689
+ options: host.options,
4690
+ remoteInfo,
4691
+ origin: host
4692
+ });
4155
4693
  const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit({
4156
4694
  id: idRes,
4157
4695
  ...remoteSplitInfo,
@@ -4303,7 +4841,7 @@ var ModuleFederation = class {
4303
4841
  beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
4304
4842
  initContainer: new AsyncWaterfallHook("initContainer")
4305
4843
  });
4306
- this.version = "2.3.3";
4844
+ this.version = "2.5.0";
4307
4845
  this.moduleCache = /* @__PURE__ */ new Map();
4308
4846
  this.loaderHook = new PluginSystem({
4309
4847
  getModuleInfo: new SyncHook(),
@@ -4311,6 +4849,13 @@ var ModuleFederation = class {
4311
4849
  createLink: new SyncHook(),
4312
4850
  fetch: new AsyncHook(),
4313
4851
  loadEntryError: new AsyncHook(),
4852
+ afterLoadEntry: new AsyncHook("afterLoadEntry"),
4853
+ beforeInitRemote: new AsyncHook("beforeInitRemote"),
4854
+ afterInitRemote: new AsyncHook("afterInitRemote"),
4855
+ beforeGetExpose: new AsyncHook("beforeGetExpose"),
4856
+ afterGetExpose: new AsyncHook("afterGetExpose"),
4857
+ beforeExecuteFactory: new AsyncHook("beforeExecuteFactory"),
4858
+ afterExecuteFactory: new AsyncHook("afterExecuteFactory"),
4314
4859
  getModuleFactory: new AsyncHook()
4315
4860
  });
4316
4861
  this.bridgeHook = new PluginSystem({
@@ -4394,7 +4939,8 @@ var ModuleFederation = class {
4394
4939
  ...userOptions,
4395
4940
  plugins,
4396
4941
  remotes,
4397
- shared: allShareInfos
4942
+ shared: allShareInfos,
4943
+ id: userOptionsRes.id || globalOptions.id
4398
4944
  };
4399
4945
  this.hooks.lifecycle.init.emit({
4400
4946
  origin: this,
@@ -4423,7 +4969,10 @@ var ModuleFederation = class {
4423
4969
 
4424
4970
  // node_modules/@module-federation/runtime/dist/index.js
4425
4971
  function createInstance(options) {
4426
- const instance = new (getGlobalFederationConstructor() || ModuleFederation)(options);
4972
+ const instance = new (getGlobalFederationConstructor() || ModuleFederation)({
4973
+ id: `${options.name}@${options.version || Date.now()}`,
4974
+ ...options
4975
+ });
4427
4976
  setGlobalFederationInstance(instance);
4428
4977
  return instance;
4429
4978
  }
@@ -5193,7 +5742,7 @@ var o6 = e6(class extends i5 {
5193
5742
  });
5194
5743
 
5195
5744
  // libs/embed-libs/embed/package.json
5196
- var version = "6.13.1";
5745
+ var version = "6.13.2";
5197
5746
 
5198
5747
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
5199
5748
  var LuzmoDashboardService = class {
@@ -6247,7 +6796,7 @@ if (!customElements.get("luzmo-embed-dashboard")) {
6247
6796
  }
6248
6797
 
6249
6798
  // libs/dashboard-contents-types/src/lib/shared/version.ts
6250
- var CONTENTS_VERSION = "0.1.99";
6799
+ var CONTENTS_VERSION = "0.1.100";
6251
6800
 
6252
6801
  // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
6253
6802
  var dashboardContentsVersion = CONTENTS_VERSION;
@@ -6263,22 +6812,6 @@ var LuzmoBaseVizItem = class extends i4 {
6263
6812
  this.libVersion = version + "-wc-luzmo";
6264
6813
  this.postInitCallQueue = [];
6265
6814
  }
6266
- static {
6267
- // Static styles to set host display to block, else it is not shown at all for some reason.
6268
- this.styles = i`
6269
- :host {
6270
- display: block;
6271
- width: 100%;
6272
- height: 100%;
6273
- }
6274
-
6275
- luzmo-embed-viz-item {
6276
- width: 100%;
6277
- height: 1000%;
6278
- display: block;
6279
- }
6280
- `;
6281
- }
6282
6815
  createRenderRoot() {
6283
6816
  if (!this.style.display) {
6284
6817
  this.style.display = "block";
@@ -6389,6 +6922,20 @@ var LuzmoBaseVizItem = class extends i4 {
6389
6922
  return b2` `;
6390
6923
  }
6391
6924
  };
6925
+ // Static styles to set host display to block, else it is not shown at all for some reason.
6926
+ LuzmoBaseVizItem.styles = i`
6927
+ :host {
6928
+ display: block;
6929
+ width: 100%;
6930
+ height: 100%;
6931
+ }
6932
+
6933
+ luzmo-embed-viz-item {
6934
+ width: 100%;
6935
+ height: 1000%;
6936
+ display: block;
6937
+ }
6938
+ `;
6392
6939
  __decorateClass([
6393
6940
  n4()
6394
6941
  ], LuzmoBaseVizItem.prototype, "appServer", 2);
@@ -6479,16 +7026,6 @@ var LuzmoIQEmbedChatComponent = class extends i4 {
6479
7026
  this.remoteEntryServer = "http://localhost:4202/";
6480
7027
  this.aydHost = "https://ayd.luzmo.com/";
6481
7028
  }
6482
- static {
6483
- // Static styles to set host display to block, else it is not shown at all for some reason.
6484
- this.styles = i`
6485
- :host {
6486
- display: block;
6487
- width: 100%;
6488
- height: 100%;
6489
- }
6490
- `;
6491
- }
6492
7029
  createRenderRoot() {
6493
7030
  return this;
6494
7031
  }
@@ -6557,6 +7094,14 @@ var LuzmoIQEmbedChatComponent = class extends i4 {
6557
7094
  observer.observe(embedChat, { childList: true, subtree: true });
6558
7095
  }
6559
7096
  };
7097
+ // Static styles to set host display to block, else it is not shown at all for some reason.
7098
+ LuzmoIQEmbedChatComponent.styles = i`
7099
+ :host {
7100
+ display: block;
7101
+ width: 100%;
7102
+ height: 100%;
7103
+ }
7104
+ `;
6560
7105
  __decorateClass([
6561
7106
  n4()
6562
7107
  ], LuzmoIQEmbedChatComponent.prototype, "appServer", 2);
@@ -6619,16 +7164,6 @@ var LuzmoIQEmbedAnswerComponent = class extends i4 {
6619
7164
  this.libVersion = version + "-wc-luzmo";
6620
7165
  this.remoteEntryServer = "http://localhost:4202";
6621
7166
  }
6622
- static {
6623
- // Static styles to set host display to block, else it is not shown at all for some reason.
6624
- this.styles = i`
6625
- :host {
6626
- display: block;
6627
- width: 100%;
6628
- height: 100%;
6629
- }
6630
- `;
6631
- }
6632
7167
  createRenderRoot() {
6633
7168
  return this;
6634
7169
  }
@@ -6679,6 +7214,14 @@ var LuzmoIQEmbedAnswerComponent = class extends i4 {
6679
7214
  return b2` `;
6680
7215
  }
6681
7216
  };
7217
+ // Static styles to set host display to block, else it is not shown at all for some reason.
7218
+ LuzmoIQEmbedAnswerComponent.styles = i`
7219
+ :host {
7220
+ display: block;
7221
+ width: 100%;
7222
+ height: 100%;
7223
+ }
7224
+ `;
6682
7225
  __decorateClass([
6683
7226
  n4()
6684
7227
  ], LuzmoIQEmbedAnswerComponent.prototype, "appServer", 2);