@module-federation/runtime-core 0.0.0-chore-bump-node-22-20260710161714

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.
Files changed (166) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/dist/LICENSE +21 -0
  4. package/dist/_virtual/_rolldown/runtime.cjs +19 -0
  5. package/dist/_virtual/_rolldown/runtime.js +18 -0
  6. package/dist/constant.cjs +9 -0
  7. package/dist/constant.cjs.map +1 -0
  8. package/dist/constant.js +7 -0
  9. package/dist/constant.js.map +1 -0
  10. package/dist/core.cjs +161 -0
  11. package/dist/core.cjs.map +1 -0
  12. package/dist/core.d.ts +197 -0
  13. package/dist/core.js +161 -0
  14. package/dist/core.js.map +1 -0
  15. package/dist/global.cjs +160 -0
  16. package/dist/global.cjs.map +1 -0
  17. package/dist/global.d.ts +45 -0
  18. package/dist/global.js +142 -0
  19. package/dist/global.js.map +1 -0
  20. package/dist/helpers.cjs +44 -0
  21. package/dist/helpers.cjs.map +1 -0
  22. package/dist/helpers.d.ts +30 -0
  23. package/dist/helpers.js +44 -0
  24. package/dist/helpers.js.map +1 -0
  25. package/dist/index.cjs +60 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/index.d.ts +29 -0
  28. package/dist/index.js +20 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/module/index.cjs +266 -0
  31. package/dist/module/index.cjs.map +1 -0
  32. package/dist/module/index.d.ts +32 -0
  33. package/dist/module/index.js +266 -0
  34. package/dist/module/index.js.map +1 -0
  35. package/dist/plugins/generate-preload-assets.cjs +182 -0
  36. package/dist/plugins/generate-preload-assets.cjs.map +1 -0
  37. package/dist/plugins/generate-preload-assets.js +182 -0
  38. package/dist/plugins/generate-preload-assets.js.map +1 -0
  39. package/dist/plugins/snapshot/SnapshotHandler.cjs +215 -0
  40. package/dist/plugins/snapshot/SnapshotHandler.cjs.map +1 -0
  41. package/dist/plugins/snapshot/SnapshotHandler.d.ts +69 -0
  42. package/dist/plugins/snapshot/SnapshotHandler.js +214 -0
  43. package/dist/plugins/snapshot/SnapshotHandler.js.map +1 -0
  44. package/dist/plugins/snapshot/index.cjs +67 -0
  45. package/dist/plugins/snapshot/index.cjs.map +1 -0
  46. package/dist/plugins/snapshot/index.js +66 -0
  47. package/dist/plugins/snapshot/index.js.map +1 -0
  48. package/dist/remote/index.cjs +445 -0
  49. package/dist/remote/index.cjs.map +1 -0
  50. package/dist/remote/index.d.ts +145 -0
  51. package/dist/remote/index.js +445 -0
  52. package/dist/remote/index.js.map +1 -0
  53. package/dist/shared/index.cjs +418 -0
  54. package/dist/shared/index.cjs.map +1 -0
  55. package/dist/shared/index.d.ts +104 -0
  56. package/dist/shared/index.js +418 -0
  57. package/dist/shared/index.js.map +1 -0
  58. package/dist/type/config.d.ts +130 -0
  59. package/dist/type/index.cjs +13 -0
  60. package/dist/type/index.cjs.map +1 -0
  61. package/dist/type/index.d.ts +11 -0
  62. package/dist/type/index.js +8 -0
  63. package/dist/type/index.js.map +1 -0
  64. package/dist/type/plugin.d.ts +27 -0
  65. package/dist/type/preload.d.ts +54 -0
  66. package/dist/types.cjs +0 -0
  67. package/dist/types.d.ts +4 -0
  68. package/dist/types.js +1 -0
  69. package/dist/utils/context.cjs +45 -0
  70. package/dist/utils/context.cjs.map +1 -0
  71. package/dist/utils/context.d.ts +1 -0
  72. package/dist/utils/context.js +44 -0
  73. package/dist/utils/context.js.map +1 -0
  74. package/dist/utils/env.cjs +10 -0
  75. package/dist/utils/env.cjs.map +1 -0
  76. package/dist/utils/env.d.ts +1 -0
  77. package/dist/utils/env.js +10 -0
  78. package/dist/utils/env.js.map +1 -0
  79. package/dist/utils/hooks/asyncHook.cjs +26 -0
  80. package/dist/utils/hooks/asyncHook.cjs.map +1 -0
  81. package/dist/utils/hooks/asyncHook.d.ts +10 -0
  82. package/dist/utils/hooks/asyncHook.js +26 -0
  83. package/dist/utils/hooks/asyncHook.js.map +1 -0
  84. package/dist/utils/hooks/asyncWaterfallHooks.cjs +44 -0
  85. package/dist/utils/hooks/asyncWaterfallHooks.cjs.map +1 -0
  86. package/dist/utils/hooks/asyncWaterfallHooks.d.ts +12 -0
  87. package/dist/utils/hooks/asyncWaterfallHooks.js +44 -0
  88. package/dist/utils/hooks/asyncWaterfallHooks.js.map +1 -0
  89. package/dist/utils/hooks/index.cjs +5 -0
  90. package/dist/utils/hooks/index.d.ts +5 -0
  91. package/dist/utils/hooks/index.js +7 -0
  92. package/dist/utils/hooks/pluginSystem.cjs +37 -0
  93. package/dist/utils/hooks/pluginSystem.cjs.map +1 -0
  94. package/dist/utils/hooks/pluginSystem.d.ts +19 -0
  95. package/dist/utils/hooks/pluginSystem.js +37 -0
  96. package/dist/utils/hooks/pluginSystem.js.map +1 -0
  97. package/dist/utils/hooks/syncHook.cjs +37 -0
  98. package/dist/utils/hooks/syncHook.cjs.map +1 -0
  99. package/dist/utils/hooks/syncHook.d.ts +16 -0
  100. package/dist/utils/hooks/syncHook.js +36 -0
  101. package/dist/utils/hooks/syncHook.js.map +1 -0
  102. package/dist/utils/hooks/syncWaterfallHook.cjs +40 -0
  103. package/dist/utils/hooks/syncWaterfallHook.cjs.map +1 -0
  104. package/dist/utils/hooks/syncWaterfallHook.d.ts +11 -0
  105. package/dist/utils/hooks/syncWaterfallHook.js +39 -0
  106. package/dist/utils/hooks/syncWaterfallHook.js.map +1 -0
  107. package/dist/utils/index.cjs +8 -0
  108. package/dist/utils/index.d.ts +4 -0
  109. package/dist/utils/index.js +9 -0
  110. package/dist/utils/load.cjs +214 -0
  111. package/dist/utils/load.cjs.map +1 -0
  112. package/dist/utils/load.d.ts +16 -0
  113. package/dist/utils/load.js +212 -0
  114. package/dist/utils/load.js.map +1 -0
  115. package/dist/utils/logger.cjs +34 -0
  116. package/dist/utils/logger.cjs.map +1 -0
  117. package/dist/utils/logger.d.ts +10 -0
  118. package/dist/utils/logger.js +31 -0
  119. package/dist/utils/logger.js.map +1 -0
  120. package/dist/utils/manifest.cjs +56 -0
  121. package/dist/utils/manifest.cjs.map +1 -0
  122. package/dist/utils/manifest.d.ts +10 -0
  123. package/dist/utils/manifest.js +53 -0
  124. package/dist/utils/manifest.js.map +1 -0
  125. package/dist/utils/plugin.cjs +27 -0
  126. package/dist/utils/plugin.cjs.map +1 -0
  127. package/dist/utils/plugin.d.ts +1 -0
  128. package/dist/utils/plugin.js +27 -0
  129. package/dist/utils/plugin.js.map +1 -0
  130. package/dist/utils/preload.cjs +212 -0
  131. package/dist/utils/preload.cjs.map +1 -0
  132. package/dist/utils/preload.d.ts +8 -0
  133. package/dist/utils/preload.js +209 -0
  134. package/dist/utils/preload.js.map +1 -0
  135. package/dist/utils/semver/compare.cjs +48 -0
  136. package/dist/utils/semver/compare.cjs.map +1 -0
  137. package/dist/utils/semver/compare.js +47 -0
  138. package/dist/utils/semver/compare.js.map +1 -0
  139. package/dist/utils/semver/constants.cjs +41 -0
  140. package/dist/utils/semver/constants.cjs.map +1 -0
  141. package/dist/utils/semver/constants.js +31 -0
  142. package/dist/utils/semver/constants.js.map +1 -0
  143. package/dist/utils/semver/index.cjs +68 -0
  144. package/dist/utils/semver/index.cjs.map +1 -0
  145. package/dist/utils/semver/index.d.ts +5 -0
  146. package/dist/utils/semver/index.js +68 -0
  147. package/dist/utils/semver/index.js.map +1 -0
  148. package/dist/utils/semver/parser.cjs +104 -0
  149. package/dist/utils/semver/parser.cjs.map +1 -0
  150. package/dist/utils/semver/parser.js +96 -0
  151. package/dist/utils/semver/parser.js.map +1 -0
  152. package/dist/utils/semver/utils.cjs +28 -0
  153. package/dist/utils/semver/utils.cjs.map +1 -0
  154. package/dist/utils/semver/utils.js +24 -0
  155. package/dist/utils/semver/utils.js.map +1 -0
  156. package/dist/utils/share.cjs +284 -0
  157. package/dist/utils/share.cjs.map +1 -0
  158. package/dist/utils/share.d.ts +23 -0
  159. package/dist/utils/share.js +278 -0
  160. package/dist/utils/share.js.map +1 -0
  161. package/dist/utils/tool.cjs +82 -0
  162. package/dist/utils/tool.cjs.map +1 -0
  163. package/dist/utils/tool.d.ts +8 -0
  164. package/dist/utils/tool.js +71 -0
  165. package/dist/utils/tool.js.map +1 -0
  166. package/package.json +65 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.cjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import {\n nativeGlobal,\n resetFederationGlobalInfo,\n setGlobalFederationInstance,\n getGlobalFederationConstructor,\n setGlobalFederationConstructor,\n getInfoWithoutType,\n getGlobalSnapshot,\n getTargetSnapshotInfoByModuleInfo,\n getGlobalSnapshotInfoByModuleInfo,\n setGlobalSnapshotInfoByModuleInfo,\n addGlobalSnapshot,\n getRemoteEntryExports,\n registerGlobalPlugins,\n getGlobalHostPlugins,\n getPreloaded,\n setPreloaded,\n Global,\n} from './global';\nimport { getRegisteredShare, getGlobalShareScope } from './utils/share';\nimport { getRemoteInfo, matchRemoteWithNameAndExpose } from './utils';\nimport { preloadAssets } from './utils/preload';\ninterface IShareUtils {\n getRegisteredShare: typeof getRegisteredShare;\n getGlobalShareScope: typeof getGlobalShareScope;\n}\nconst ShareUtils: IShareUtils = {\n getRegisteredShare,\n getGlobalShareScope,\n};\n\ninterface IGlobalUtils {\n Global: typeof Global;\n nativeGlobal: typeof global;\n resetFederationGlobalInfo: typeof resetFederationGlobalInfo;\n setGlobalFederationInstance: typeof setGlobalFederationInstance;\n getGlobalFederationConstructor: typeof getGlobalFederationConstructor;\n setGlobalFederationConstructor: typeof setGlobalFederationConstructor;\n getInfoWithoutType: typeof getInfoWithoutType;\n getGlobalSnapshot: typeof getGlobalSnapshot;\n getTargetSnapshotInfoByModuleInfo: typeof getTargetSnapshotInfoByModuleInfo;\n getGlobalSnapshotInfoByModuleInfo: typeof getGlobalSnapshotInfoByModuleInfo;\n setGlobalSnapshotInfoByModuleInfo: typeof setGlobalSnapshotInfoByModuleInfo;\n addGlobalSnapshot: typeof addGlobalSnapshot;\n getRemoteEntryExports: typeof getRemoteEntryExports;\n registerGlobalPlugins: typeof registerGlobalPlugins;\n getGlobalHostPlugins: typeof getGlobalHostPlugins;\n getPreloaded: typeof getPreloaded;\n setPreloaded: typeof setPreloaded;\n}\n\nconst GlobalUtils: IGlobalUtils = {\n Global,\n nativeGlobal,\n resetFederationGlobalInfo,\n setGlobalFederationInstance,\n getGlobalFederationConstructor,\n setGlobalFederationConstructor,\n getInfoWithoutType,\n getGlobalSnapshot,\n getTargetSnapshotInfoByModuleInfo,\n getGlobalSnapshotInfoByModuleInfo,\n setGlobalSnapshotInfoByModuleInfo,\n addGlobalSnapshot,\n getRemoteEntryExports,\n registerGlobalPlugins,\n getGlobalHostPlugins,\n getPreloaded,\n setPreloaded,\n};\n\nexport default {\n global: GlobalUtils,\n share: ShareUtils,\n utils: {\n matchRemoteWithNameAndExpose,\n preloadAssets,\n getRemoteInfo,\n },\n};\n\nexport type { IGlobalUtils, IShareUtils };\n"],"mappings":";;;;;;;;AA0BA,MAAM,aAA0B;CAC9B;CACA;CACD;AAsBD,MAAM,cAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,sBAAe;CACb,QAAQ;CACR,OAAO;CACP,OAAO;EACL;EACA;EACA;EACD;CACF"}
@@ -0,0 +1,30 @@
1
+ import { Global, addGlobalSnapshot, getGlobalFederationConstructor, getGlobalHostPlugins, getGlobalSnapshot, getGlobalSnapshotInfoByModuleInfo, getInfoWithoutType, getPreloaded, getRemoteEntryExports, getTargetSnapshotInfoByModuleInfo, registerGlobalPlugins, resetFederationGlobalInfo, setGlobalFederationConstructor, setGlobalFederationInstance, setGlobalSnapshotInfoByModuleInfo, setPreloaded } from "./global.js";
2
+ import { getGlobalShareScope, getRegisteredShare } from "./utils/share.js";
3
+
4
+ //#region src/helpers.d.ts
5
+ interface IShareUtils {
6
+ getRegisteredShare: typeof getRegisteredShare;
7
+ getGlobalShareScope: typeof getGlobalShareScope;
8
+ }
9
+ interface IGlobalUtils {
10
+ Global: typeof Global;
11
+ nativeGlobal: typeof global;
12
+ resetFederationGlobalInfo: typeof resetFederationGlobalInfo;
13
+ setGlobalFederationInstance: typeof setGlobalFederationInstance;
14
+ getGlobalFederationConstructor: typeof getGlobalFederationConstructor;
15
+ setGlobalFederationConstructor: typeof setGlobalFederationConstructor;
16
+ getInfoWithoutType: typeof getInfoWithoutType;
17
+ getGlobalSnapshot: typeof getGlobalSnapshot;
18
+ getTargetSnapshotInfoByModuleInfo: typeof getTargetSnapshotInfoByModuleInfo;
19
+ getGlobalSnapshotInfoByModuleInfo: typeof getGlobalSnapshotInfoByModuleInfo;
20
+ setGlobalSnapshotInfoByModuleInfo: typeof setGlobalSnapshotInfoByModuleInfo;
21
+ addGlobalSnapshot: typeof addGlobalSnapshot;
22
+ getRemoteEntryExports: typeof getRemoteEntryExports;
23
+ registerGlobalPlugins: typeof registerGlobalPlugins;
24
+ getGlobalHostPlugins: typeof getGlobalHostPlugins;
25
+ getPreloaded: typeof getPreloaded;
26
+ setPreloaded: typeof setPreloaded;
27
+ }
28
+ //#endregion
29
+ export { type IGlobalUtils, type IShareUtils };
30
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1,44 @@
1
+ import { Global, addGlobalSnapshot, getGlobalFederationConstructor, getGlobalHostPlugins, getGlobalSnapshot, getGlobalSnapshotInfoByModuleInfo, getInfoWithoutType, getPreloaded, getRemoteEntryExports, getTargetSnapshotInfoByModuleInfo, nativeGlobal, registerGlobalPlugins, resetFederationGlobalInfo, setGlobalFederationConstructor, setGlobalFederationInstance, setGlobalSnapshotInfoByModuleInfo, setPreloaded } from "./global.js";
2
+ import { getGlobalShareScope, getRegisteredShare } from "./utils/share.js";
3
+ import { matchRemoteWithNameAndExpose } from "./utils/manifest.js";
4
+ import { getRemoteInfo } from "./utils/load.js";
5
+ import "./utils/index.js";
6
+ import { preloadAssets } from "./utils/preload.js";
7
+
8
+ //#region src/helpers.ts
9
+ const ShareUtils = {
10
+ getRegisteredShare,
11
+ getGlobalShareScope
12
+ };
13
+ const GlobalUtils = {
14
+ Global,
15
+ nativeGlobal,
16
+ resetFederationGlobalInfo,
17
+ setGlobalFederationInstance,
18
+ getGlobalFederationConstructor,
19
+ setGlobalFederationConstructor,
20
+ getInfoWithoutType,
21
+ getGlobalSnapshot,
22
+ getTargetSnapshotInfoByModuleInfo,
23
+ getGlobalSnapshotInfoByModuleInfo,
24
+ setGlobalSnapshotInfoByModuleInfo,
25
+ addGlobalSnapshot,
26
+ getRemoteEntryExports,
27
+ registerGlobalPlugins,
28
+ getGlobalHostPlugins,
29
+ getPreloaded,
30
+ setPreloaded
31
+ };
32
+ var helpers_default = {
33
+ global: GlobalUtils,
34
+ share: ShareUtils,
35
+ utils: {
36
+ matchRemoteWithNameAndExpose,
37
+ preloadAssets,
38
+ getRemoteInfo
39
+ }
40
+ };
41
+
42
+ //#endregion
43
+ export { helpers_default as default };
44
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import {\n nativeGlobal,\n resetFederationGlobalInfo,\n setGlobalFederationInstance,\n getGlobalFederationConstructor,\n setGlobalFederationConstructor,\n getInfoWithoutType,\n getGlobalSnapshot,\n getTargetSnapshotInfoByModuleInfo,\n getGlobalSnapshotInfoByModuleInfo,\n setGlobalSnapshotInfoByModuleInfo,\n addGlobalSnapshot,\n getRemoteEntryExports,\n registerGlobalPlugins,\n getGlobalHostPlugins,\n getPreloaded,\n setPreloaded,\n Global,\n} from './global';\nimport { getRegisteredShare, getGlobalShareScope } from './utils/share';\nimport { getRemoteInfo, matchRemoteWithNameAndExpose } from './utils';\nimport { preloadAssets } from './utils/preload';\ninterface IShareUtils {\n getRegisteredShare: typeof getRegisteredShare;\n getGlobalShareScope: typeof getGlobalShareScope;\n}\nconst ShareUtils: IShareUtils = {\n getRegisteredShare,\n getGlobalShareScope,\n};\n\ninterface IGlobalUtils {\n Global: typeof Global;\n nativeGlobal: typeof global;\n resetFederationGlobalInfo: typeof resetFederationGlobalInfo;\n setGlobalFederationInstance: typeof setGlobalFederationInstance;\n getGlobalFederationConstructor: typeof getGlobalFederationConstructor;\n setGlobalFederationConstructor: typeof setGlobalFederationConstructor;\n getInfoWithoutType: typeof getInfoWithoutType;\n getGlobalSnapshot: typeof getGlobalSnapshot;\n getTargetSnapshotInfoByModuleInfo: typeof getTargetSnapshotInfoByModuleInfo;\n getGlobalSnapshotInfoByModuleInfo: typeof getGlobalSnapshotInfoByModuleInfo;\n setGlobalSnapshotInfoByModuleInfo: typeof setGlobalSnapshotInfoByModuleInfo;\n addGlobalSnapshot: typeof addGlobalSnapshot;\n getRemoteEntryExports: typeof getRemoteEntryExports;\n registerGlobalPlugins: typeof registerGlobalPlugins;\n getGlobalHostPlugins: typeof getGlobalHostPlugins;\n getPreloaded: typeof getPreloaded;\n setPreloaded: typeof setPreloaded;\n}\n\nconst GlobalUtils: IGlobalUtils = {\n Global,\n nativeGlobal,\n resetFederationGlobalInfo,\n setGlobalFederationInstance,\n getGlobalFederationConstructor,\n setGlobalFederationConstructor,\n getInfoWithoutType,\n getGlobalSnapshot,\n getTargetSnapshotInfoByModuleInfo,\n getGlobalSnapshotInfoByModuleInfo,\n setGlobalSnapshotInfoByModuleInfo,\n addGlobalSnapshot,\n getRemoteEntryExports,\n registerGlobalPlugins,\n getGlobalHostPlugins,\n getPreloaded,\n setPreloaded,\n};\n\nexport default {\n global: GlobalUtils,\n share: ShareUtils,\n utils: {\n matchRemoteWithNameAndExpose,\n preloadAssets,\n getRemoteInfo,\n },\n};\n\nexport type { IGlobalUtils, IShareUtils };\n"],"mappings":";;;;;;;;AA0BA,MAAM,aAA0B;CAC9B;CACA;CACD;AAsBD,MAAM,cAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,sBAAe;CACb,QAAQ;CACR,OAAO;CACP,OAAO;EACL;EACA;EACA;EACD;CACF"}
package/dist/index.cjs ADDED
@@ -0,0 +1,60 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_logger = require('./utils/logger.cjs');
3
+ const require_tool = require('./utils/tool.cjs');
4
+ const require_global = require('./global.cjs');
5
+ const require_index = require('./utils/semver/index.cjs');
6
+ const require_share = require('./utils/share.cjs');
7
+ const require_manifest = require('./utils/manifest.cjs');
8
+ const require_load = require('./utils/load.cjs');
9
+ require('./utils/index.cjs');
10
+ const require_helpers = require('./helpers.cjs');
11
+ const require_index$2 = require('./module/index.cjs');
12
+ const require_core = require('./core.cjs');
13
+ const require_index$3 = require('./type/index.cjs');
14
+ let _module_federation_sdk = require("@module-federation/sdk");
15
+
16
+ //#region src/index.ts
17
+ const helpers = require_helpers.default;
18
+
19
+ //#endregion
20
+ exports.CurrentGlobal = require_global.CurrentGlobal;
21
+ exports.Global = require_global.Global;
22
+ exports.Module = require_index$2.Module;
23
+ exports.ModuleFederation = require_core.ModuleFederation;
24
+ exports.addGlobalSnapshot = require_global.addGlobalSnapshot;
25
+ exports.assert = require_logger.assert;
26
+ exports.error = require_logger.error;
27
+ exports.getGlobalFederationConstructor = require_global.getGlobalFederationConstructor;
28
+ exports.getGlobalSnapshot = require_global.getGlobalSnapshot;
29
+ exports.getInfoWithoutType = require_global.getInfoWithoutType;
30
+ exports.getRegisteredShare = require_share.getRegisteredShare;
31
+ exports.getRemoteEntry = require_load.getRemoteEntry;
32
+ exports.getRemoteInfo = require_load.getRemoteInfo;
33
+ exports.helpers = helpers;
34
+ exports.isStaticResourcesEqual = require_tool.isStaticResourcesEqual;
35
+ Object.defineProperty(exports, 'loadScript', {
36
+ enumerable: true,
37
+ get: function () {
38
+ return _module_federation_sdk.loadScript;
39
+ }
40
+ });
41
+ Object.defineProperty(exports, 'loadScriptNode', {
42
+ enumerable: true,
43
+ get: function () {
44
+ return _module_federation_sdk.loadScriptNode;
45
+ }
46
+ });
47
+ exports.matchRemoteWithNameAndExpose = require_manifest.matchRemoteWithNameAndExpose;
48
+ exports.registerGlobalPlugins = require_global.registerGlobalPlugins;
49
+ exports.resetFederationGlobalInfo = require_global.resetFederationGlobalInfo;
50
+ exports.safeWrapper = require_tool.safeWrapper;
51
+ exports.satisfy = require_index.satisfy;
52
+ exports.setGlobalFederationConstructor = require_global.setGlobalFederationConstructor;
53
+ exports.setGlobalFederationInstance = require_global.setGlobalFederationInstance;
54
+ Object.defineProperty(exports, 'types', {
55
+ enumerable: true,
56
+ get: function () {
57
+ return require_index$3.type_exports;
58
+ }
59
+ });
60
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["helpersDefault"],"sources":["../src/index.ts"],"sourcesContent":["import helpersDefault, { type IGlobalUtils, type IShareUtils } from './helpers';\n\nconst helpers = helpersDefault;\n\nexport { ModuleFederation } from './core';\nexport {\n type Federation,\n CurrentGlobal,\n Global,\n getGlobalFederationConstructor,\n setGlobalFederationInstance,\n setGlobalFederationConstructor,\n resetFederationGlobalInfo,\n addGlobalSnapshot,\n getGlobalSnapshot,\n getInfoWithoutType,\n} from './global';\nexport type { UserOptions, ModuleFederationRuntimePlugin } from './type';\nexport { assert, error } from './utils/logger';\nexport { registerGlobalPlugins } from './global';\nexport {\n getRemoteEntry,\n getRemoteInfo,\n isStaticResourcesEqual,\n matchRemoteWithNameAndExpose,\n safeWrapper,\n} from './utils';\nexport { getRegisteredShare } from '../src/utils/share';\nexport { loadScript, loadScriptNode } from '@module-federation/sdk';\nexport { Module } from './module';\nexport * as types from './type';\nexport { helpers };\nexport { satisfy } from '../src/utils/semver';\nexport type { IGlobalUtils, IShareUtils };\n"],"mappings":";;;;;;;;;;;;;;;;AAEA,MAAM,UAAUA"}
@@ -0,0 +1,29 @@
1
+ import { Module } from "./module/index.js";
2
+ import { CurrentGlobal, Federation, Global, addGlobalSnapshot, getGlobalFederationConstructor, getGlobalSnapshot, getInfoWithoutType, registerGlobalPlugins, resetFederationGlobalInfo, setGlobalFederationConstructor, setGlobalFederationInstance } from "./global.js";
3
+ import { ModuleFederation } from "./core.js";
4
+ import { ModuleFederationRuntimePlugin } from "./type/plugin.js";
5
+ import { UserOptions } from "./type/config.js";
6
+ import { index_d_exports } from "./type/index.js";
7
+ import { isStaticResourcesEqual, safeWrapper } from "./utils/tool.js";
8
+ import { matchRemoteWithNameAndExpose } from "./utils/manifest.js";
9
+ import { assert, error } from "./utils/logger.js";
10
+ import { getRemoteEntry, getRemoteInfo } from "./utils/load.js";
11
+ import { preloadAssets } from "./utils/preload.js";
12
+ import { getRegisteredShare } from "./utils/share.js";
13
+ import { IGlobalUtils, IShareUtils } from "./helpers.js";
14
+ import { satisfy } from "./utils/semver/index.js";
15
+ import { loadScript, loadScriptNode } from "@module-federation/sdk";
16
+
17
+ //#region src/index.d.ts
18
+ declare const helpers: {
19
+ global: IGlobalUtils;
20
+ share: IShareUtils;
21
+ utils: {
22
+ matchRemoteWithNameAndExpose: typeof matchRemoteWithNameAndExpose;
23
+ preloadAssets: typeof preloadAssets;
24
+ getRemoteInfo: typeof getRemoteInfo;
25
+ };
26
+ };
27
+ //#endregion
28
+ export { CurrentGlobal, type Federation, Global, type IGlobalUtils, type IShareUtils, Module, ModuleFederation, type ModuleFederationRuntimePlugin, type UserOptions, addGlobalSnapshot, assert, error, getGlobalFederationConstructor, getGlobalSnapshot, getInfoWithoutType, getRegisteredShare, getRemoteEntry, getRemoteInfo, helpers, isStaticResourcesEqual, loadScript, loadScriptNode, matchRemoteWithNameAndExpose, registerGlobalPlugins, resetFederationGlobalInfo, safeWrapper, satisfy, setGlobalFederationConstructor, setGlobalFederationInstance, index_d_exports as types };
29
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ import { assert, error } from "./utils/logger.js";
2
+ import { isStaticResourcesEqual, safeWrapper } from "./utils/tool.js";
3
+ import { CurrentGlobal, Global, addGlobalSnapshot, getGlobalFederationConstructor, getGlobalSnapshot, getInfoWithoutType, registerGlobalPlugins, resetFederationGlobalInfo, setGlobalFederationConstructor, setGlobalFederationInstance } from "./global.js";
4
+ import { satisfy } from "./utils/semver/index.js";
5
+ import { getRegisteredShare } from "./utils/share.js";
6
+ import { matchRemoteWithNameAndExpose } from "./utils/manifest.js";
7
+ import { getRemoteEntry, getRemoteInfo } from "./utils/load.js";
8
+ import "./utils/index.js";
9
+ import helpers_default from "./helpers.js";
10
+ import { Module } from "./module/index.js";
11
+ import { ModuleFederation } from "./core.js";
12
+ import { type_exports } from "./type/index.js";
13
+ import { loadScript, loadScriptNode } from "@module-federation/sdk";
14
+
15
+ //#region src/index.ts
16
+ const helpers = helpers_default;
17
+
18
+ //#endregion
19
+ export { CurrentGlobal, Global, Module, ModuleFederation, addGlobalSnapshot, assert, error, getGlobalFederationConstructor, getGlobalSnapshot, getInfoWithoutType, getRegisteredShare, getRemoteEntry, getRemoteInfo, helpers, isStaticResourcesEqual, loadScript, loadScriptNode, matchRemoteWithNameAndExpose, registerGlobalPlugins, resetFederationGlobalInfo, safeWrapper, satisfy, setGlobalFederationConstructor, setGlobalFederationInstance, type_exports as types };
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["helpersDefault"],"sources":["../src/index.ts"],"sourcesContent":["import helpersDefault, { type IGlobalUtils, type IShareUtils } from './helpers';\n\nconst helpers = helpersDefault;\n\nexport { ModuleFederation } from './core';\nexport {\n type Federation,\n CurrentGlobal,\n Global,\n getGlobalFederationConstructor,\n setGlobalFederationInstance,\n setGlobalFederationConstructor,\n resetFederationGlobalInfo,\n addGlobalSnapshot,\n getGlobalSnapshot,\n getInfoWithoutType,\n} from './global';\nexport type { UserOptions, ModuleFederationRuntimePlugin } from './type';\nexport { assert, error } from './utils/logger';\nexport { registerGlobalPlugins } from './global';\nexport {\n getRemoteEntry,\n getRemoteInfo,\n isStaticResourcesEqual,\n matchRemoteWithNameAndExpose,\n safeWrapper,\n} from './utils';\nexport { getRegisteredShare } from '../src/utils/share';\nexport { loadScript, loadScriptNode } from '@module-federation/sdk';\nexport { Module } from './module';\nexport * as types from './type';\nexport { helpers };\nexport { satisfy } from '../src/utils/semver';\nexport type { IGlobalUtils, IShareUtils };\n"],"mappings":";;;;;;;;;;;;;;;AAEA,MAAM,UAAUA"}
@@ -0,0 +1,266 @@
1
+ const require_logger = require('../utils/logger.cjs');
2
+ const require_tool = require('../utils/tool.cjs');
3
+ const require_manifest = require('../utils/manifest.cjs');
4
+ const require_load = require('../utils/load.cjs');
5
+ const require_context = require('../utils/context.cjs');
6
+ require('../utils/index.cjs');
7
+ let _module_federation_sdk = require("@module-federation/sdk");
8
+ let _module_federation_error_codes = require("@module-federation/error-codes");
9
+
10
+ //#region src/module/index.ts
11
+ function getAvailableExposeNames(remoteSnapshot) {
12
+ if (!remoteSnapshot || !("modules" in remoteSnapshot) || !Array.isArray(remoteSnapshot.modules)) return;
13
+ const exposes = remoteSnapshot.modules.map((module) => module.moduleName).filter(Boolean);
14
+ return exposes.length ? exposes.join(",") : void 0;
15
+ }
16
+ function createRemoteEntryInitOptions(remoteInfo, hostShareScopeMap, rawInitScope) {
17
+ const localShareScopeMap = hostShareScopeMap;
18
+ const shareScopeKeys = Array.isArray(remoteInfo.shareScope) ? remoteInfo.shareScope : [remoteInfo.shareScope];
19
+ if (!shareScopeKeys.length) shareScopeKeys.push("default");
20
+ shareScopeKeys.forEach((shareScopeKey) => {
21
+ if (!localShareScopeMap[shareScopeKey]) localShareScopeMap[shareScopeKey] = {};
22
+ });
23
+ const remoteEntryInitOptions = {
24
+ version: remoteInfo.version || "",
25
+ shareScopeKeys: Array.isArray(remoteInfo.shareScope) ? shareScopeKeys : remoteInfo.shareScope || "default"
26
+ };
27
+ Object.defineProperty(remoteEntryInitOptions, "shareScopeMap", {
28
+ value: localShareScopeMap,
29
+ enumerable: false
30
+ });
31
+ return {
32
+ remoteEntryInitOptions,
33
+ shareScope: localShareScopeMap[shareScopeKeys[0]],
34
+ initScope: rawInitScope ?? []
35
+ };
36
+ }
37
+ var Module = class {
38
+ constructor({ remoteInfo, host }) {
39
+ this.inited = false;
40
+ this.initing = false;
41
+ this.lib = void 0;
42
+ this.remoteInfo = remoteInfo;
43
+ this.host = host;
44
+ }
45
+ async getEntry(expose) {
46
+ if (this.remoteEntryExports) return this.remoteEntryExports;
47
+ const remoteEntryExports = await require_load.getRemoteEntry({
48
+ origin: this.host,
49
+ remoteInfo: this.remoteInfo,
50
+ remoteEntryExports: this.remoteEntryExports,
51
+ resourceContext: {
52
+ initiator: "loadRemote",
53
+ id: require_manifest.composeRemoteRequestId(this.remoteInfo.name, expose),
54
+ resourceType: "remoteEntry"
55
+ }
56
+ });
57
+ require_logger.assert(remoteEntryExports, `remoteEntryExports is undefined \n ${(0, _module_federation_sdk.safeToString)(this.remoteInfo)}`);
58
+ this.remoteEntryExports = remoteEntryExports;
59
+ return this.remoteEntryExports;
60
+ }
61
+ async init(id, remoteSnapshot, rawInitScope, expose) {
62
+ const remoteEntryExports = await this.getEntry(expose);
63
+ if (this.inited) {
64
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
65
+ id,
66
+ remoteInfo: this.remoteInfo,
67
+ remoteSnapshot,
68
+ remoteEntryExports,
69
+ cached: true,
70
+ origin: this.host
71
+ });
72
+ return remoteEntryExports;
73
+ }
74
+ if (this.initPromise) {
75
+ try {
76
+ await this.initPromise;
77
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
78
+ id,
79
+ remoteInfo: this.remoteInfo,
80
+ remoteSnapshot,
81
+ remoteEntryExports,
82
+ cached: true,
83
+ origin: this.host
84
+ });
85
+ } catch (initError) {
86
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
87
+ id,
88
+ remoteInfo: this.remoteInfo,
89
+ remoteSnapshot,
90
+ remoteEntryExports,
91
+ error: initError,
92
+ cached: true,
93
+ origin: this.host
94
+ });
95
+ throw initError;
96
+ }
97
+ return remoteEntryExports;
98
+ }
99
+ this.initing = true;
100
+ this.initPromise = (async () => {
101
+ await this.host.loaderHook.lifecycle.beforeInitRemote.emit({
102
+ id,
103
+ remoteInfo: this.remoteInfo,
104
+ remoteSnapshot,
105
+ origin: this.host
106
+ });
107
+ const { remoteEntryInitOptions, shareScope, initScope } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap, rawInitScope);
108
+ const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({
109
+ shareScope,
110
+ remoteEntryInitOptions,
111
+ initScope,
112
+ remoteInfo: this.remoteInfo,
113
+ origin: this.host
114
+ });
115
+ if (typeof remoteEntryExports?.init === "undefined") require_logger.error(_module_federation_error_codes.RUNTIME_002, _module_federation_error_codes.runtimeDescMap, {
116
+ hostName: this.host.name,
117
+ remoteName: this.remoteInfo.name,
118
+ remoteEntryUrl: this.remoteInfo.entry,
119
+ remoteEntryKey: this.remoteInfo.entryGlobalName
120
+ }, void 0, require_context.optionsToMFContext(this.host.options));
121
+ try {
122
+ await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
123
+ } catch (initError) {
124
+ require_logger.error(_module_federation_error_codes.RUNTIME_015, _module_federation_error_codes.runtimeDescMap, {
125
+ hostName: this.host.name,
126
+ remoteName: this.remoteInfo.name,
127
+ remoteEntryUrl: this.remoteInfo.entry,
128
+ remoteEntryKey: this.remoteInfo.entryGlobalName,
129
+ shareScope: this.remoteInfo.shareScope
130
+ }, `${initError}`, require_context.optionsToMFContext(this.host.options));
131
+ }
132
+ await this.host.hooks.lifecycle.initContainer.emit({
133
+ ...initContainerOptions,
134
+ id,
135
+ remoteSnapshot,
136
+ remoteEntryExports
137
+ });
138
+ this.inited = true;
139
+ })();
140
+ try {
141
+ await this.initPromise;
142
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
143
+ id,
144
+ remoteInfo: this.remoteInfo,
145
+ remoteSnapshot,
146
+ remoteEntryExports,
147
+ origin: this.host
148
+ });
149
+ } catch (initError) {
150
+ await this.host.loaderHook.lifecycle.afterInitRemote.emit({
151
+ id,
152
+ remoteInfo: this.remoteInfo,
153
+ remoteSnapshot,
154
+ remoteEntryExports,
155
+ error: initError,
156
+ origin: this.host
157
+ });
158
+ throw initError;
159
+ } finally {
160
+ this.initing = false;
161
+ this.initPromise = void 0;
162
+ }
163
+ return remoteEntryExports;
164
+ }
165
+ async get(id, expose, options, remoteSnapshot) {
166
+ const { loadFactory = true } = options || { loadFactory: true };
167
+ const remoteEntryExports = await this.init(id, remoteSnapshot, void 0, expose);
168
+ this.lib = remoteEntryExports;
169
+ await this.host.loaderHook.lifecycle.beforeGetExpose.emit({
170
+ id,
171
+ expose,
172
+ moduleInfo: this.remoteInfo,
173
+ remoteEntryExports,
174
+ origin: this.host
175
+ });
176
+ let moduleFactory;
177
+ try {
178
+ const hookModuleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
179
+ remoteEntryExports,
180
+ expose,
181
+ moduleInfo: this.remoteInfo
182
+ });
183
+ moduleFactory = typeof hookModuleFactory === "function" ? hookModuleFactory : void 0;
184
+ if (!moduleFactory) moduleFactory = await remoteEntryExports.get(expose);
185
+ if (!moduleFactory) require_logger.error(_module_federation_error_codes.RUNTIME_014, _module_federation_error_codes.runtimeDescMap, {
186
+ hostName: this.host.name,
187
+ remoteName: this.remoteInfo.name,
188
+ remoteEntryUrl: this.remoteInfo.entry,
189
+ expose,
190
+ requestId: id,
191
+ availableExposes: getAvailableExposeNames(remoteSnapshot)
192
+ }, void 0, require_context.optionsToMFContext(this.host.options));
193
+ await this.host.loaderHook.lifecycle.afterGetExpose.emit({
194
+ id,
195
+ expose,
196
+ moduleInfo: this.remoteInfo,
197
+ remoteEntryExports,
198
+ moduleFactory,
199
+ origin: this.host
200
+ });
201
+ } catch (getExposeError) {
202
+ await this.host.loaderHook.lifecycle.afterGetExpose.emit({
203
+ id,
204
+ expose,
205
+ moduleInfo: this.remoteInfo,
206
+ remoteEntryExports,
207
+ error: getExposeError,
208
+ origin: this.host
209
+ });
210
+ throw getExposeError;
211
+ }
212
+ const symbolName = require_tool.processModuleAlias(this.remoteInfo.name, expose);
213
+ const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
214
+ if (!loadFactory) return wrapModuleFactory;
215
+ await this.host.loaderHook.lifecycle.beforeExecuteFactory.emit({
216
+ id,
217
+ expose,
218
+ moduleInfo: this.remoteInfo,
219
+ loadFactory,
220
+ origin: this.host
221
+ });
222
+ try {
223
+ const exposeContent = await wrapModuleFactory();
224
+ await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
225
+ id,
226
+ expose,
227
+ moduleInfo: this.remoteInfo,
228
+ loadFactory,
229
+ exposeModule: exposeContent,
230
+ origin: this.host
231
+ });
232
+ return exposeContent;
233
+ } catch (executeFactoryError) {
234
+ await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
235
+ id,
236
+ expose,
237
+ moduleInfo: this.remoteInfo,
238
+ loadFactory,
239
+ error: executeFactoryError,
240
+ origin: this.host
241
+ });
242
+ throw executeFactoryError;
243
+ }
244
+ }
245
+ wraperFactory(moduleFactory, id) {
246
+ function defineModuleId(res, id) {
247
+ if (res && typeof res === "object" && Object.isExtensible(res) && !Object.getOwnPropertyDescriptor(res, Symbol.for("mf_module_id"))) Object.defineProperty(res, Symbol.for("mf_module_id"), {
248
+ value: id,
249
+ enumerable: false
250
+ });
251
+ }
252
+ return () => {
253
+ const res = moduleFactory();
254
+ if (res instanceof Promise) return res.then((asyncRes) => {
255
+ defineModuleId(asyncRes, id);
256
+ return asyncRes;
257
+ });
258
+ defineModuleId(res, id);
259
+ return res;
260
+ };
261
+ }
262
+ };
263
+
264
+ //#endregion
265
+ exports.Module = Module;
266
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["getRemoteEntry","composeRemoteRequestId","RUNTIME_002","runtimeDescMap","optionsToMFContext","RUNTIME_015","RUNTIME_014","processModuleAlias"],"sources":["../../src/module/index.ts"],"sourcesContent":["import {\n assert,\n error,\n processModuleAlias,\n optionsToMFContext,\n composeRemoteRequestId,\n} from '../utils';\nimport { safeToString, ModuleInfo } from '@module-federation/sdk';\nimport {\n RUNTIME_002,\n RUNTIME_014,\n RUNTIME_015,\n runtimeDescMap,\n} from '@module-federation/error-codes';\nimport { getRemoteEntry } from '../utils/load';\nimport { ModuleFederation } from '../core';\nimport {\n RemoteEntryExports,\n RemoteInfo,\n InitScope,\n ShareScopeMap,\n} from '../type';\n\nexport type ModuleOptions = ConstructorParameters<typeof Module>[0];\nexport type RemoteModuleFactory = () => unknown | Promise<unknown>;\n\nfunction getAvailableExposeNames(\n remoteSnapshot?: ModuleInfo,\n): string | undefined {\n if (\n !remoteSnapshot ||\n !('modules' in remoteSnapshot) ||\n !Array.isArray(remoteSnapshot.modules)\n ) {\n return undefined;\n }\n\n const exposes = remoteSnapshot.modules\n .map((module) => module.moduleName)\n .filter(Boolean);\n\n return exposes.length ? exposes.join(',') : undefined;\n}\n\nexport function createRemoteEntryInitOptions(\n remoteInfo: RemoteInfo,\n hostShareScopeMap: ShareScopeMap,\n rawInitScope?: InitScope,\n): Record<string, any> {\n const localShareScopeMap = hostShareScopeMap;\n\n const shareScopeKeys = Array.isArray(remoteInfo.shareScope)\n ? remoteInfo.shareScope\n : [remoteInfo.shareScope];\n\n if (!shareScopeKeys.length) {\n shareScopeKeys.push('default');\n }\n shareScopeKeys.forEach((shareScopeKey) => {\n if (!localShareScopeMap[shareScopeKey]) {\n localShareScopeMap[shareScopeKey] = {};\n }\n });\n\n const remoteEntryInitOptions = {\n version: remoteInfo.version || '',\n shareScopeKeys: Array.isArray(remoteInfo.shareScope)\n ? shareScopeKeys\n : remoteInfo.shareScope || 'default',\n };\n\n // Help to find host instance\n Object.defineProperty(remoteEntryInitOptions, 'shareScopeMap', {\n value: localShareScopeMap,\n // remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed\n enumerable: false,\n });\n\n // TODO: compate legacy init params, should use shareScopeMap if exist\n const shareScope = localShareScopeMap[shareScopeKeys[0]];\n const initScope: InitScope = rawInitScope ?? [];\n\n return {\n remoteEntryInitOptions,\n shareScope,\n initScope,\n };\n}\n\nclass Module {\n remoteInfo: RemoteInfo;\n inited = false;\n initing = false;\n initPromise?: Promise<void>;\n remoteEntryExports?: RemoteEntryExports;\n lib: RemoteEntryExports | undefined = undefined;\n host: ModuleFederation;\n\n constructor({\n remoteInfo,\n host,\n }: {\n remoteInfo: RemoteInfo;\n host: ModuleFederation;\n }) {\n this.remoteInfo = remoteInfo;\n this.host = host;\n }\n\n async getEntry(expose?: string): Promise<RemoteEntryExports> {\n if (this.remoteEntryExports) {\n return this.remoteEntryExports;\n }\n\n const remoteEntryExports = await getRemoteEntry({\n origin: this.host,\n remoteInfo: this.remoteInfo,\n remoteEntryExports: this.remoteEntryExports,\n resourceContext: {\n initiator: 'loadRemote',\n id: composeRemoteRequestId(this.remoteInfo.name, expose),\n resourceType: 'remoteEntry',\n },\n });\n\n assert(\n remoteEntryExports,\n `remoteEntryExports is undefined \\n ${safeToString(this.remoteInfo)}`,\n );\n\n this.remoteEntryExports = remoteEntryExports;\n return this.remoteEntryExports;\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n\n async init(\n id?: string,\n remoteSnapshot?: ModuleInfo,\n rawInitScope?: InitScope,\n expose?: string,\n ) {\n // Get remoteEntry.js\n const remoteEntryExports = await this.getEntry(expose);\n\n if (this.inited) {\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n cached: true,\n origin: this.host,\n });\n return remoteEntryExports;\n }\n\n if (this.initPromise) {\n try {\n await this.initPromise;\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n cached: true,\n origin: this.host,\n });\n } catch (initError) {\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n error: initError,\n cached: true,\n origin: this.host,\n });\n throw initError;\n }\n return remoteEntryExports;\n }\n\n this.initing = true;\n this.initPromise = (async () => {\n await this.host.loaderHook.lifecycle.beforeInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n origin: this.host,\n });\n\n const { remoteEntryInitOptions, shareScope, initScope } =\n createRemoteEntryInitOptions(\n this.remoteInfo,\n this.host.shareScopeMap,\n rawInitScope,\n );\n\n const initContainerOptions =\n await this.host.hooks.lifecycle.beforeInitContainer.emit({\n shareScope,\n // @ts-ignore shareScopeMap will be set by Object.defineProperty\n remoteEntryInitOptions,\n initScope,\n remoteInfo: this.remoteInfo,\n origin: this.host,\n });\n\n if (typeof remoteEntryExports?.init === 'undefined') {\n error(\n RUNTIME_002,\n runtimeDescMap,\n {\n hostName: this.host.name,\n remoteName: this.remoteInfo.name,\n remoteEntryUrl: this.remoteInfo.entry,\n remoteEntryKey: this.remoteInfo.entryGlobalName,\n },\n undefined,\n optionsToMFContext(this.host.options),\n );\n }\n\n try {\n await remoteEntryExports.init(\n initContainerOptions.shareScope,\n initContainerOptions.initScope,\n initContainerOptions.remoteEntryInitOptions,\n );\n } catch (initError) {\n error(\n RUNTIME_015,\n runtimeDescMap,\n {\n hostName: this.host.name,\n remoteName: this.remoteInfo.name,\n remoteEntryUrl: this.remoteInfo.entry,\n remoteEntryKey: this.remoteInfo.entryGlobalName,\n shareScope: this.remoteInfo.shareScope,\n },\n `${initError}`,\n optionsToMFContext(this.host.options),\n );\n }\n\n await this.host.hooks.lifecycle.initContainer.emit({\n ...initContainerOptions,\n id,\n remoteSnapshot,\n remoteEntryExports,\n });\n this.inited = true;\n })();\n\n try {\n await this.initPromise;\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n origin: this.host,\n });\n } catch (initError) {\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n error: initError,\n origin: this.host,\n });\n throw initError;\n } finally {\n this.initing = false;\n this.initPromise = undefined;\n }\n\n return remoteEntryExports;\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n async get(\n id: string,\n expose: string,\n options?: { loadFactory?: boolean },\n remoteSnapshot?: ModuleInfo,\n ) {\n const { loadFactory = true } = options || { loadFactory: true };\n\n const remoteEntryExports = await this.init(\n id,\n remoteSnapshot,\n undefined,\n expose,\n );\n this.lib = remoteEntryExports;\n\n await this.host.loaderHook.lifecycle.beforeGetExpose.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n remoteEntryExports,\n origin: this.host,\n });\n\n let moduleFactory: RemoteModuleFactory | undefined;\n try {\n const hookModuleFactory =\n await this.host.loaderHook.lifecycle.getModuleFactory.emit({\n remoteEntryExports,\n expose,\n moduleInfo: this.remoteInfo,\n });\n moduleFactory =\n typeof hookModuleFactory === 'function' ? hookModuleFactory : undefined;\n\n // get exposeGetter\n if (!moduleFactory) {\n moduleFactory = await remoteEntryExports.get(expose);\n }\n\n if (!moduleFactory) {\n error(\n RUNTIME_014,\n runtimeDescMap,\n {\n hostName: this.host.name,\n remoteName: this.remoteInfo.name,\n remoteEntryUrl: this.remoteInfo.entry,\n expose,\n requestId: id,\n availableExposes: getAvailableExposeNames(remoteSnapshot),\n },\n undefined,\n optionsToMFContext(this.host.options),\n );\n }\n\n await this.host.loaderHook.lifecycle.afterGetExpose.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n remoteEntryExports,\n moduleFactory,\n origin: this.host,\n });\n } catch (getExposeError) {\n await this.host.loaderHook.lifecycle.afterGetExpose.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n remoteEntryExports,\n error: getExposeError,\n origin: this.host,\n });\n throw getExposeError;\n }\n\n // keep symbol for module name always one format\n const symbolName = processModuleAlias(this.remoteInfo.name, expose);\n const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);\n\n if (!loadFactory) {\n return wrapModuleFactory;\n }\n\n await this.host.loaderHook.lifecycle.beforeExecuteFactory.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n loadFactory,\n origin: this.host,\n });\n\n try {\n const exposeContent = await wrapModuleFactory();\n\n await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n loadFactory,\n exposeModule: exposeContent,\n origin: this.host,\n });\n\n return exposeContent;\n } catch (executeFactoryError) {\n await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n loadFactory,\n error: executeFactoryError,\n origin: this.host,\n });\n throw executeFactoryError;\n }\n }\n\n private wraperFactory(moduleFactory: RemoteModuleFactory, id: string) {\n function defineModuleId(res: unknown, id: string) {\n if (\n res &&\n typeof res === 'object' &&\n Object.isExtensible(res) &&\n !Object.getOwnPropertyDescriptor(res, Symbol.for('mf_module_id'))\n ) {\n Object.defineProperty(res, Symbol.for('mf_module_id'), {\n value: id,\n enumerable: false,\n });\n }\n }\n\n return () => {\n const res = moduleFactory();\n\n if (res instanceof Promise) {\n return res.then((asyncRes) => {\n // This parameter is used for bridge debugging\n defineModuleId(asyncRes, id);\n return asyncRes;\n });\n }\n\n // This parameter is used for bridge debugging\n defineModuleId(res, id);\n return res;\n };\n }\n}\n\nexport { Module };\n"],"mappings":";;;;;;;;;;AA0BA,SAAS,wBACP,gBACoB;AACpB,KACE,CAAC,kBACD,EAAE,aAAa,mBACf,CAAC,MAAM,QAAQ,eAAe,QAAQ,CAEtC;CAGF,MAAM,UAAU,eAAe,QAC5B,KAAK,WAAW,OAAO,WAAW,CAClC,OAAO,QAAQ;AAElB,QAAO,QAAQ,SAAS,QAAQ,KAAK,IAAI,GAAG;;AAG9C,SAAgB,6BACd,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{ InitScope, RemoteEntryExports, RemoteInfo } from "../type/config.js";
3
+ import { ModuleInfo } from "@module-federation/sdk";
4
+
5
+ //#region src/module/index.d.ts
6
+ type ModuleOptions = ConstructorParameters<typeof Module$1>[0];
7
+ type RemoteModuleFactory = () => unknown | Promise<unknown>;
8
+ declare class Module$1 {
9
+ remoteInfo: RemoteInfo;
10
+ inited: boolean;
11
+ initing: boolean;
12
+ initPromise?: Promise<void>;
13
+ remoteEntryExports?: RemoteEntryExports;
14
+ lib: RemoteEntryExports | undefined;
15
+ host: ModuleFederation;
16
+ constructor({
17
+ remoteInfo,
18
+ host
19
+ }: {
20
+ remoteInfo: RemoteInfo;
21
+ host: ModuleFederation;
22
+ });
23
+ getEntry(expose?: string): Promise<RemoteEntryExports>;
24
+ init(id?: string, remoteSnapshot?: ModuleInfo, rawInitScope?: InitScope, expose?: string): Promise<RemoteEntryExports>;
25
+ get(id: string, expose: string, options?: {
26
+ loadFactory?: boolean;
27
+ }, remoteSnapshot?: ModuleInfo): Promise<unknown>;
28
+ private wraperFactory;
29
+ }
30
+ //#endregion
31
+ export { Module$1 as Module, ModuleOptions, RemoteModuleFactory };
32
+ //# sourceMappingURL=index.d.ts.map