@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.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/LICENSE +21 -0
- package/dist/_virtual/_rolldown/runtime.cjs +19 -0
- package/dist/_virtual/_rolldown/runtime.js +18 -0
- package/dist/constant.cjs +9 -0
- package/dist/constant.cjs.map +1 -0
- package/dist/constant.js +7 -0
- package/dist/constant.js.map +1 -0
- package/dist/core.cjs +161 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.ts +197 -0
- package/dist/core.js +161 -0
- package/dist/core.js.map +1 -0
- package/dist/global.cjs +160 -0
- package/dist/global.cjs.map +1 -0
- package/dist/global.d.ts +45 -0
- package/dist/global.js +142 -0
- package/dist/global.js.map +1 -0
- package/dist/helpers.cjs +44 -0
- package/dist/helpers.cjs.map +1 -0
- package/dist/helpers.d.ts +30 -0
- package/dist/helpers.js +44 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.cjs +60 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/module/index.cjs +266 -0
- package/dist/module/index.cjs.map +1 -0
- package/dist/module/index.d.ts +32 -0
- package/dist/module/index.js +266 -0
- package/dist/module/index.js.map +1 -0
- package/dist/plugins/generate-preload-assets.cjs +182 -0
- package/dist/plugins/generate-preload-assets.cjs.map +1 -0
- package/dist/plugins/generate-preload-assets.js +182 -0
- package/dist/plugins/generate-preload-assets.js.map +1 -0
- package/dist/plugins/snapshot/SnapshotHandler.cjs +215 -0
- package/dist/plugins/snapshot/SnapshotHandler.cjs.map +1 -0
- package/dist/plugins/snapshot/SnapshotHandler.d.ts +69 -0
- package/dist/plugins/snapshot/SnapshotHandler.js +214 -0
- package/dist/plugins/snapshot/SnapshotHandler.js.map +1 -0
- package/dist/plugins/snapshot/index.cjs +67 -0
- package/dist/plugins/snapshot/index.cjs.map +1 -0
- package/dist/plugins/snapshot/index.js +66 -0
- package/dist/plugins/snapshot/index.js.map +1 -0
- package/dist/remote/index.cjs +445 -0
- package/dist/remote/index.cjs.map +1 -0
- package/dist/remote/index.d.ts +145 -0
- package/dist/remote/index.js +445 -0
- package/dist/remote/index.js.map +1 -0
- package/dist/shared/index.cjs +418 -0
- package/dist/shared/index.cjs.map +1 -0
- package/dist/shared/index.d.ts +104 -0
- package/dist/shared/index.js +418 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/type/config.d.ts +130 -0
- package/dist/type/index.cjs +13 -0
- package/dist/type/index.cjs.map +1 -0
- package/dist/type/index.d.ts +11 -0
- package/dist/type/index.js +8 -0
- package/dist/type/index.js.map +1 -0
- package/dist/type/plugin.d.ts +27 -0
- package/dist/type/preload.d.ts +54 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -0
- package/dist/utils/context.cjs +45 -0
- package/dist/utils/context.cjs.map +1 -0
- package/dist/utils/context.d.ts +1 -0
- package/dist/utils/context.js +44 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/env.cjs +10 -0
- package/dist/utils/env.cjs.map +1 -0
- package/dist/utils/env.d.ts +1 -0
- package/dist/utils/env.js +10 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/hooks/asyncHook.cjs +26 -0
- package/dist/utils/hooks/asyncHook.cjs.map +1 -0
- package/dist/utils/hooks/asyncHook.d.ts +10 -0
- package/dist/utils/hooks/asyncHook.js +26 -0
- package/dist/utils/hooks/asyncHook.js.map +1 -0
- package/dist/utils/hooks/asyncWaterfallHooks.cjs +44 -0
- package/dist/utils/hooks/asyncWaterfallHooks.cjs.map +1 -0
- package/dist/utils/hooks/asyncWaterfallHooks.d.ts +12 -0
- package/dist/utils/hooks/asyncWaterfallHooks.js +44 -0
- package/dist/utils/hooks/asyncWaterfallHooks.js.map +1 -0
- package/dist/utils/hooks/index.cjs +5 -0
- package/dist/utils/hooks/index.d.ts +5 -0
- package/dist/utils/hooks/index.js +7 -0
- package/dist/utils/hooks/pluginSystem.cjs +37 -0
- package/dist/utils/hooks/pluginSystem.cjs.map +1 -0
- package/dist/utils/hooks/pluginSystem.d.ts +19 -0
- package/dist/utils/hooks/pluginSystem.js +37 -0
- package/dist/utils/hooks/pluginSystem.js.map +1 -0
- package/dist/utils/hooks/syncHook.cjs +37 -0
- package/dist/utils/hooks/syncHook.cjs.map +1 -0
- package/dist/utils/hooks/syncHook.d.ts +16 -0
- package/dist/utils/hooks/syncHook.js +36 -0
- package/dist/utils/hooks/syncHook.js.map +1 -0
- package/dist/utils/hooks/syncWaterfallHook.cjs +40 -0
- package/dist/utils/hooks/syncWaterfallHook.cjs.map +1 -0
- package/dist/utils/hooks/syncWaterfallHook.d.ts +11 -0
- package/dist/utils/hooks/syncWaterfallHook.js +39 -0
- package/dist/utils/hooks/syncWaterfallHook.js.map +1 -0
- package/dist/utils/index.cjs +8 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/load.cjs +214 -0
- package/dist/utils/load.cjs.map +1 -0
- package/dist/utils/load.d.ts +16 -0
- package/dist/utils/load.js +212 -0
- package/dist/utils/load.js.map +1 -0
- package/dist/utils/logger.cjs +34 -0
- package/dist/utils/logger.cjs.map +1 -0
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.js +31 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/manifest.cjs +56 -0
- package/dist/utils/manifest.cjs.map +1 -0
- package/dist/utils/manifest.d.ts +10 -0
- package/dist/utils/manifest.js +53 -0
- package/dist/utils/manifest.js.map +1 -0
- package/dist/utils/plugin.cjs +27 -0
- package/dist/utils/plugin.cjs.map +1 -0
- package/dist/utils/plugin.d.ts +1 -0
- package/dist/utils/plugin.js +27 -0
- package/dist/utils/plugin.js.map +1 -0
- package/dist/utils/preload.cjs +212 -0
- package/dist/utils/preload.cjs.map +1 -0
- package/dist/utils/preload.d.ts +8 -0
- package/dist/utils/preload.js +209 -0
- package/dist/utils/preload.js.map +1 -0
- package/dist/utils/semver/compare.cjs +48 -0
- package/dist/utils/semver/compare.cjs.map +1 -0
- package/dist/utils/semver/compare.js +47 -0
- package/dist/utils/semver/compare.js.map +1 -0
- package/dist/utils/semver/constants.cjs +41 -0
- package/dist/utils/semver/constants.cjs.map +1 -0
- package/dist/utils/semver/constants.js +31 -0
- package/dist/utils/semver/constants.js.map +1 -0
- package/dist/utils/semver/index.cjs +68 -0
- package/dist/utils/semver/index.cjs.map +1 -0
- package/dist/utils/semver/index.d.ts +5 -0
- package/dist/utils/semver/index.js +68 -0
- package/dist/utils/semver/index.js.map +1 -0
- package/dist/utils/semver/parser.cjs +104 -0
- package/dist/utils/semver/parser.cjs.map +1 -0
- package/dist/utils/semver/parser.js +96 -0
- package/dist/utils/semver/parser.js.map +1 -0
- package/dist/utils/semver/utils.cjs +28 -0
- package/dist/utils/semver/utils.cjs.map +1 -0
- package/dist/utils/semver/utils.js +24 -0
- package/dist/utils/semver/utils.js.map +1 -0
- package/dist/utils/share.cjs +284 -0
- package/dist/utils/share.cjs.map +1 -0
- package/dist/utils/share.d.ts +23 -0
- package/dist/utils/share.js +278 -0
- package/dist/utils/share.js.map +1 -0
- package/dist/utils/tool.cjs +82 -0
- package/dist/utils/tool.cjs.map +1 -0
- package/dist/utils/tool.d.ts +8 -0
- package/dist/utils/tool.js +71 -0
- package/dist/utils/tool.js.map +1 -0
- package/package.json +65 -0
package/dist/core.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { error } from "./utils/logger.js";
|
|
2
|
+
import { DEFAULT_SCOPE } from "./constant.js";
|
|
3
|
+
import { formatShareConfigs } from "./utils/share.js";
|
|
4
|
+
import { getBuilderId } from "./utils/env.js";
|
|
5
|
+
import { registerPlugins } from "./utils/plugin.js";
|
|
6
|
+
import { getRemoteInfo } from "./utils/load.js";
|
|
7
|
+
import "./utils/index.js";
|
|
8
|
+
import { Module as Module$1 } from "./module/index.js";
|
|
9
|
+
import { SyncHook } from "./utils/hooks/syncHook.js";
|
|
10
|
+
import { AsyncHook } from "./utils/hooks/asyncHook.js";
|
|
11
|
+
import { SyncWaterfallHook } from "./utils/hooks/syncWaterfallHook.js";
|
|
12
|
+
import { AsyncWaterfallHook } from "./utils/hooks/asyncWaterfallHooks.js";
|
|
13
|
+
import { PluginSystem } from "./utils/hooks/pluginSystem.js";
|
|
14
|
+
import "./utils/hooks/index.js";
|
|
15
|
+
import { snapshotPlugin } from "./plugins/snapshot/index.js";
|
|
16
|
+
import { generatePreloadAssetsPlugin } from "./plugins/generate-preload-assets.js";
|
|
17
|
+
import { SnapshotHandler } from "./plugins/snapshot/SnapshotHandler.js";
|
|
18
|
+
import { SharedHandler } from "./shared/index.js";
|
|
19
|
+
import { RemoteHandler } from "./remote/index.js";
|
|
20
|
+
import { isBrowserEnvValue } from "@module-federation/sdk";
|
|
21
|
+
import { RUNTIME_010, getShortErrorMsg, runtimeDescMap } from "@module-federation/error-codes";
|
|
22
|
+
|
|
23
|
+
//#region src/core.ts
|
|
24
|
+
const USE_SNAPSHOT = typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;
|
|
25
|
+
var ModuleFederation = class {
|
|
26
|
+
constructor(userOptions) {
|
|
27
|
+
this.hooks = new PluginSystem({
|
|
28
|
+
beforeInit: new SyncWaterfallHook("beforeInit"),
|
|
29
|
+
init: new SyncHook(),
|
|
30
|
+
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
31
|
+
initContainer: new AsyncWaterfallHook("initContainer")
|
|
32
|
+
});
|
|
33
|
+
this.version = "0.0.0-chore-bump-node-22-20260710161714";
|
|
34
|
+
this.moduleCache = /* @__PURE__ */ new Map();
|
|
35
|
+
this.loaderHook = new PluginSystem({
|
|
36
|
+
getModuleInfo: new SyncHook(),
|
|
37
|
+
createScript: new SyncHook(),
|
|
38
|
+
createLink: new SyncHook(),
|
|
39
|
+
fetch: new AsyncHook(),
|
|
40
|
+
loadEntryError: new AsyncHook(),
|
|
41
|
+
afterLoadEntry: new AsyncHook("afterLoadEntry"),
|
|
42
|
+
beforeInitRemote: new AsyncHook("beforeInitRemote"),
|
|
43
|
+
afterInitRemote: new AsyncHook("afterInitRemote"),
|
|
44
|
+
beforeGetExpose: new AsyncHook("beforeGetExpose"),
|
|
45
|
+
afterGetExpose: new AsyncHook("afterGetExpose"),
|
|
46
|
+
beforeExecuteFactory: new AsyncHook("beforeExecuteFactory"),
|
|
47
|
+
afterExecuteFactory: new AsyncHook("afterExecuteFactory"),
|
|
48
|
+
getModuleFactory: new AsyncHook()
|
|
49
|
+
});
|
|
50
|
+
this.bridgeHook = new PluginSystem({
|
|
51
|
+
beforeBridgeRender: new SyncHook(),
|
|
52
|
+
afterBridgeRender: new SyncHook(),
|
|
53
|
+
beforeBridgeDestroy: new SyncHook(),
|
|
54
|
+
afterBridgeDestroy: new SyncHook()
|
|
55
|
+
});
|
|
56
|
+
const plugins = USE_SNAPSHOT ? [snapshotPlugin(), generatePreloadAssetsPlugin()] : [];
|
|
57
|
+
const defaultOptions = {
|
|
58
|
+
id: getBuilderId(),
|
|
59
|
+
name: userOptions.name,
|
|
60
|
+
plugins,
|
|
61
|
+
remotes: [],
|
|
62
|
+
shared: {},
|
|
63
|
+
inBrowser: isBrowserEnvValue
|
|
64
|
+
};
|
|
65
|
+
this.name = userOptions.name;
|
|
66
|
+
this.options = defaultOptions;
|
|
67
|
+
this.snapshotHandler = new SnapshotHandler(this);
|
|
68
|
+
this.sharedHandler = new SharedHandler(this);
|
|
69
|
+
this.remoteHandler = new RemoteHandler(this);
|
|
70
|
+
this.shareScopeMap = this.sharedHandler.shareScopeMap;
|
|
71
|
+
this.registerPlugins([...defaultOptions.plugins, ...userOptions.plugins || []]);
|
|
72
|
+
this.options = this.formatOptions(defaultOptions, userOptions);
|
|
73
|
+
}
|
|
74
|
+
initOptions(userOptions) {
|
|
75
|
+
if (userOptions.name && userOptions.name !== this.options.name) error(getShortErrorMsg(RUNTIME_010, runtimeDescMap));
|
|
76
|
+
this.registerPlugins(userOptions.plugins);
|
|
77
|
+
const options = this.formatOptions(this.options, userOptions);
|
|
78
|
+
this.options = options;
|
|
79
|
+
return options;
|
|
80
|
+
}
|
|
81
|
+
async loadShare(pkgName, extraOptions) {
|
|
82
|
+
return this.sharedHandler.loadShare(pkgName, extraOptions);
|
|
83
|
+
}
|
|
84
|
+
loadShareSync(pkgName, extraOptions) {
|
|
85
|
+
return this.sharedHandler.loadShareSync(pkgName, extraOptions);
|
|
86
|
+
}
|
|
87
|
+
initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
|
|
88
|
+
return this.sharedHandler.initializeSharing(shareScopeName, extraOptions);
|
|
89
|
+
}
|
|
90
|
+
initRawContainer(name, url, container) {
|
|
91
|
+
const remoteInfo = getRemoteInfo({
|
|
92
|
+
name,
|
|
93
|
+
entry: url
|
|
94
|
+
});
|
|
95
|
+
const module = new Module$1({
|
|
96
|
+
host: this,
|
|
97
|
+
remoteInfo
|
|
98
|
+
});
|
|
99
|
+
module.remoteEntryExports = container;
|
|
100
|
+
this.moduleCache.set(name, module);
|
|
101
|
+
return module;
|
|
102
|
+
}
|
|
103
|
+
async loadRemote(id, options) {
|
|
104
|
+
return this.remoteHandler.loadRemote(id, options);
|
|
105
|
+
}
|
|
106
|
+
async preloadRemote(preloadOptions) {
|
|
107
|
+
return this.remoteHandler.preloadRemote(preloadOptions);
|
|
108
|
+
}
|
|
109
|
+
initShareScopeMap(scopeName, shareScope, extraOptions = {}) {
|
|
110
|
+
this.sharedHandler.initShareScopeMap(scopeName, shareScope, extraOptions);
|
|
111
|
+
}
|
|
112
|
+
formatOptions(globalOptions, userOptions) {
|
|
113
|
+
const { allShareInfos: shared } = formatShareConfigs(globalOptions, userOptions);
|
|
114
|
+
const { userOptions: userOptionsRes, options: globalOptionsRes } = this.hooks.lifecycle.beforeInit.emit({
|
|
115
|
+
origin: this,
|
|
116
|
+
userOptions,
|
|
117
|
+
options: globalOptions,
|
|
118
|
+
shareInfo: shared
|
|
119
|
+
});
|
|
120
|
+
const remotes = this.remoteHandler.formatAndRegisterRemote(globalOptionsRes, userOptionsRes);
|
|
121
|
+
const { allShareInfos } = this.sharedHandler.registerShared(globalOptionsRes, userOptionsRes);
|
|
122
|
+
const plugins = [...globalOptionsRes.plugins];
|
|
123
|
+
if (userOptionsRes.plugins) userOptionsRes.plugins.forEach((plugin) => {
|
|
124
|
+
if (!plugins.includes(plugin)) plugins.push(plugin);
|
|
125
|
+
});
|
|
126
|
+
const optionsRes = {
|
|
127
|
+
...globalOptions,
|
|
128
|
+
...userOptions,
|
|
129
|
+
plugins,
|
|
130
|
+
remotes,
|
|
131
|
+
shared: allShareInfos,
|
|
132
|
+
id: userOptionsRes.id || globalOptions.id
|
|
133
|
+
};
|
|
134
|
+
this.hooks.lifecycle.init.emit({
|
|
135
|
+
origin: this,
|
|
136
|
+
options: optionsRes
|
|
137
|
+
});
|
|
138
|
+
return optionsRes;
|
|
139
|
+
}
|
|
140
|
+
registerPlugins(plugins) {
|
|
141
|
+
const pluginRes = registerPlugins(plugins, this);
|
|
142
|
+
this.options.plugins = this.options.plugins.reduce((res, plugin) => {
|
|
143
|
+
if (!plugin) return res;
|
|
144
|
+
if (res && !res.find((item) => item.name === plugin.name)) res.push(plugin);
|
|
145
|
+
return res;
|
|
146
|
+
}, pluginRes || []);
|
|
147
|
+
}
|
|
148
|
+
registerRemotes(remotes, options) {
|
|
149
|
+
return this.remoteHandler.registerRemotes(remotes, options);
|
|
150
|
+
}
|
|
151
|
+
registerShared(shared) {
|
|
152
|
+
this.sharedHandler.registerShared(this.options, {
|
|
153
|
+
...this.options,
|
|
154
|
+
shared
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
export { ModuleFederation };
|
|
161
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","names":["Module"],"sources":["../src/core.ts"],"sourcesContent":["import { isBrowserEnvValue } from '@module-federation/sdk';\nimport type {\n CreateLinkHookReturnDom,\n CreateScriptHookReturn,\n GlobalModuleInfo,\n ModuleInfo,\n} from '@module-federation/sdk';\nimport {\n Options,\n PreloadRemoteArgs,\n RemoteEntryExports,\n Remote,\n Shared,\n ShareInfos,\n UserOptions,\n RemoteInfo,\n ShareScopeMap,\n InitScope,\n RemoteEntryInitOptions,\n CallFrom,\n ResourceLoadContext,\n} from './type';\nimport { getBuilderId, registerPlugins, getRemoteEntry, error } from './utils';\nimport {\n getShortErrorMsg,\n RUNTIME_010,\n runtimeDescMap,\n} from '@module-federation/error-codes';\nimport { Module, type RemoteModuleFactory } from './module';\nimport {\n AsyncHook,\n AsyncWaterfallHook,\n PluginSystem,\n SyncHook,\n SyncWaterfallHook,\n} from './utils/hooks';\nimport { generatePreloadAssetsPlugin } from './plugins/generate-preload-assets';\nimport { snapshotPlugin } from './plugins/snapshot';\nimport { getRemoteInfo } from './utils/load';\nimport { DEFAULT_SCOPE } from './constant';\nimport { SnapshotHandler } from './plugins/snapshot/SnapshotHandler';\nimport { SharedHandler } from './shared';\nimport { RemoteHandler } from './remote';\nimport { formatShareConfigs } from './utils/share';\n\n// Declare the global constant that will be defined by DefinePlugin\n// Default to true if not defined (e.g., when runtime-core is used outside of webpack)\n// so that snapshot functionality is included by default.\ndeclare const FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN: boolean;\nconst USE_SNAPSHOT =\n typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === 'boolean'\n ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN\n : true; // Default to true (use snapshot) when not explicitly defined\n\nexport class ModuleFederation {\n options: Options;\n hooks = new PluginSystem({\n beforeInit: new SyncWaterfallHook<{\n userOptions: UserOptions;\n options: Options;\n origin: ModuleFederation;\n /**\n * @deprecated shareInfo will be removed soon, please use userOptions directly!\n */\n shareInfo: ShareInfos;\n }>('beforeInit'),\n init: new SyncHook<\n [\n {\n options: Options;\n origin: ModuleFederation;\n },\n ],\n void\n >(),\n // maybe will change, temporarily for internal use only\n beforeInitContainer: new AsyncWaterfallHook<{\n shareScope: ShareScopeMap[string];\n initScope: InitScope;\n remoteEntryInitOptions: RemoteEntryInitOptions;\n remoteInfo: RemoteInfo;\n origin: ModuleFederation;\n }>('beforeInitContainer'),\n // maybe will change, temporarily for internal use only\n initContainer: new AsyncWaterfallHook<{\n shareScope: ShareScopeMap[string];\n initScope: InitScope;\n remoteEntryInitOptions: RemoteEntryInitOptions;\n remoteInfo: RemoteInfo;\n remoteEntryExports: RemoteEntryExports;\n origin: ModuleFederation;\n id?: string;\n remoteSnapshot?: ModuleInfo;\n }>('initContainer'),\n });\n version: string = __VERSION__;\n name: string;\n moduleCache: Map<string, Module> = new Map();\n snapshotHandler: SnapshotHandler;\n sharedHandler: SharedHandler;\n remoteHandler: RemoteHandler;\n shareScopeMap: ShareScopeMap;\n loaderHook = new PluginSystem({\n // FIXME: may not be suitable , not open to the public yet\n getModuleInfo: new SyncHook<\n [\n {\n target: Record<string, any>;\n key: any;\n },\n ],\n { value: any | undefined; key: string } | void\n >(),\n createScript: new SyncHook<\n [\n {\n url: string;\n attrs?: Record<string, any>;\n /**\n * The producer(remote) info bound to this resource.\n * Only present when the loader is invoked in a remote-related context\n * (e.g. preloadRemote / loading remoteEntry).\n */\n remoteInfo?: RemoteInfo;\n resourceContext?: ResourceLoadContext;\n },\n ],\n CreateScriptHookReturn\n >(),\n createLink: new SyncHook<\n [\n {\n url: string;\n attrs?: Record<string, any>;\n /**\n * The producer(remote) info bound to this resource.\n * Only present when the loader is invoked in a remote-related context\n * (e.g. preloadRemote / loading remoteEntry).\n */\n remoteInfo?: RemoteInfo;\n resourceContext?: ResourceLoadContext;\n },\n ],\n CreateLinkHookReturnDom\n >(),\n fetch: new AsyncHook<\n [string, RequestInit, RemoteInfo?, ResourceLoadContext?],\n Promise<Response> | void | false\n >(),\n loadEntryError: new AsyncHook<\n [\n {\n getRemoteEntry: typeof getRemoteEntry;\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports | undefined;\n globalLoading: Record<\n string,\n Promise<void | RemoteEntryExports> | undefined\n >;\n uniqueKey: string;\n },\n ],\n Promise<Promise<RemoteEntryExports | undefined> | undefined>\n >(),\n afterLoadEntry: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports | false | void;\n error?: unknown;\n recovered?: boolean;\n },\n ],\n void\n >('afterLoadEntry'),\n beforeInitRemote: new AsyncHook<\n [\n {\n id?: string;\n remoteInfo: RemoteInfo;\n remoteSnapshot?: ModuleInfo;\n origin: ModuleFederation;\n },\n ],\n void\n >('beforeInitRemote'),\n afterInitRemote: new AsyncHook<\n [\n {\n id?: string;\n remoteInfo: RemoteInfo;\n remoteSnapshot?: ModuleInfo;\n remoteEntryExports?: RemoteEntryExports;\n error?: unknown;\n cached?: boolean;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterInitRemote'),\n beforeGetExpose: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n moduleInfo: RemoteInfo;\n remoteEntryExports: RemoteEntryExports;\n origin: ModuleFederation;\n },\n ],\n void\n >('beforeGetExpose'),\n afterGetExpose: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n moduleInfo: RemoteInfo;\n remoteEntryExports: RemoteEntryExports;\n moduleFactory?: RemoteModuleFactory;\n error?: unknown;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterGetExpose'),\n beforeExecuteFactory: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n moduleInfo: RemoteInfo;\n loadFactory: boolean;\n origin: ModuleFederation;\n },\n ],\n void\n >('beforeExecuteFactory'),\n afterExecuteFactory: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n moduleInfo: RemoteInfo;\n loadFactory: boolean;\n exposeModule?: unknown;\n error?: unknown;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterExecuteFactory'),\n getModuleFactory: new AsyncHook<\n [\n {\n remoteEntryExports: RemoteEntryExports;\n expose: string;\n moduleInfo: RemoteInfo;\n },\n ],\n RemoteModuleFactory | Promise<RemoteModuleFactory | undefined> | undefined\n >(),\n });\n bridgeHook = new PluginSystem({\n beforeBridgeRender: new SyncHook<\n [Record<string, any>],\n void | Record<string, any>\n >(),\n afterBridgeRender: new SyncHook<\n [Record<string, any>],\n void | Record<string, any>\n >(),\n beforeBridgeDestroy: new SyncHook<\n [Record<string, any>],\n void | Record<string, any>\n >(),\n afterBridgeDestroy: new SyncHook<\n [Record<string, any>],\n void | Record<string, any>\n >(),\n });\n moduleInfo?: GlobalModuleInfo[string];\n\n constructor(userOptions: UserOptions) {\n const plugins = USE_SNAPSHOT\n ? [snapshotPlugin(), generatePreloadAssetsPlugin()]\n : [];\n // TODO: Validate the details of the options\n // Initialize options with default values\n const defaultOptions: Options = {\n id: getBuilderId(),\n name: userOptions.name,\n plugins,\n remotes: [],\n shared: {},\n inBrowser: isBrowserEnvValue,\n };\n\n this.name = userOptions.name;\n this.options = defaultOptions;\n this.snapshotHandler = new SnapshotHandler(this);\n this.sharedHandler = new SharedHandler(this);\n this.remoteHandler = new RemoteHandler(this);\n this.shareScopeMap = this.sharedHandler.shareScopeMap;\n this.registerPlugins([\n ...defaultOptions.plugins,\n ...(userOptions.plugins || []),\n ]);\n this.options = this.formatOptions(defaultOptions, userOptions);\n }\n\n initOptions(userOptions: UserOptions): Options {\n if (userOptions.name && userOptions.name !== this.options.name) {\n error(getShortErrorMsg(RUNTIME_010, runtimeDescMap));\n }\n this.registerPlugins(userOptions.plugins);\n const options = this.formatOptions(this.options, userOptions);\n\n this.options = options;\n\n return options;\n }\n\n async loadShare<T>(\n pkgName: string,\n extraOptions?: {\n customShareInfo?: Partial<Shared>;\n resolver?: (sharedOptions: ShareInfos[string]) => Shared;\n },\n ): Promise<false | (() => T | undefined)> {\n return this.sharedHandler.loadShare(pkgName, extraOptions);\n }\n\n // The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.\n // 1. If the loaded shared already exists globally, then it will be reused\n // 2. If lib exists in local shared, it will be used directly\n // 3. If the local get returns something other than Promise, then it will be used directly\n loadShareSync<T>(\n pkgName: string,\n extraOptions?: {\n customShareInfo?: Partial<Shared>;\n from?: 'build' | 'runtime';\n resolver?: (sharedOptions: ShareInfos[string]) => Shared;\n },\n ): () => T | never {\n return this.sharedHandler.loadShareSync(pkgName, extraOptions);\n }\n\n initializeSharing(\n shareScopeName = DEFAULT_SCOPE,\n extraOptions?: {\n initScope?: InitScope;\n from?: CallFrom;\n strategy?: Shared['strategy'];\n },\n ): Array<Promise<void>> {\n return this.sharedHandler.initializeSharing(shareScopeName, extraOptions);\n }\n\n initRawContainer(\n name: string,\n url: string,\n container: RemoteEntryExports,\n ): Module {\n const remoteInfo = getRemoteInfo({ name, entry: url });\n const module = new Module({ host: this, remoteInfo });\n\n module.remoteEntryExports = container;\n this.moduleCache.set(name, module);\n\n return module;\n }\n\n // eslint-disable-next-line max-lines-per-function\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async loadRemote<T>(\n id: string,\n options?: { loadFactory?: boolean; from: CallFrom },\n ): Promise<T | null> {\n return this.remoteHandler.loadRemote(id, options);\n }\n\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void> {\n return this.remoteHandler.preloadRemote(preloadOptions);\n }\n\n initShareScopeMap(\n scopeName: string,\n shareScope: ShareScopeMap[string],\n extraOptions: { hostShareScopeMap?: ShareScopeMap } = {},\n ): void {\n this.sharedHandler.initShareScopeMap(scopeName, shareScope, extraOptions);\n }\n\n formatOptions(globalOptions: Options, userOptions: UserOptions): Options {\n const { allShareInfos: shared } = formatShareConfigs(\n globalOptions,\n userOptions,\n );\n const { userOptions: userOptionsRes, options: globalOptionsRes } =\n this.hooks.lifecycle.beforeInit.emit({\n origin: this,\n userOptions,\n options: globalOptions,\n shareInfo: shared,\n });\n\n const remotes = this.remoteHandler.formatAndRegisterRemote(\n globalOptionsRes,\n userOptionsRes,\n );\n\n const { allShareInfos } = this.sharedHandler.registerShared(\n globalOptionsRes,\n userOptionsRes,\n );\n\n const plugins = [...globalOptionsRes.plugins];\n\n if (userOptionsRes.plugins) {\n userOptionsRes.plugins.forEach((plugin) => {\n if (!plugins.includes(plugin)) {\n plugins.push(plugin);\n }\n });\n }\n\n const optionsRes: Options = {\n ...globalOptions,\n ...userOptions,\n plugins,\n remotes,\n shared: allShareInfos,\n id: userOptionsRes.id || globalOptions.id,\n };\n\n this.hooks.lifecycle.init.emit({\n origin: this,\n options: optionsRes,\n });\n return optionsRes;\n }\n\n registerPlugins(plugins: UserOptions['plugins']) {\n const pluginRes = registerPlugins(plugins, this);\n // Merge plugin\n this.options.plugins = this.options.plugins.reduce((res, plugin) => {\n if (!plugin) return res;\n if (res && !res.find((item) => item.name === plugin.name)) {\n res.push(plugin);\n }\n return res;\n }, pluginRes || []);\n }\n registerRemotes(remotes: Remote[], options?: { force?: boolean }): void {\n return this.remoteHandler.registerRemotes(remotes, options);\n }\n\n registerShared(shared: UserOptions['shared']) {\n this.sharedHandler.registerShared(this.options, {\n ...this.options,\n shared,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAM,eACJ,OAAO,2CAA2C,YAC9C,CAAC,yCACD;AAEN,IAAa,mBAAb,MAA8B;CAuO5B,YAAY,aAA0B;eArO9B,IAAI,aAAa;GACvB,YAAY,IAAI,kBAQb,aAAa;GAChB,MAAM,IAAI,UAQP;GAEH,qBAAqB,IAAI,mBAMtB,sBAAsB;GAEzB,eAAe,IAAI,mBAShB,gBAAgB;GACpB,CAAC;;q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,aAAsB;GAC1B,GAAG;GACH,GAAG;GACH;GACA;GACA,QAAQ;GACR,IAAI,eAAe,MAAM,cAAc;GACxC;AAED,OAAK,MAAM,UAAU,KAAK,KAAK;GAC7B,QAAQ;GACR,SAAS;GACV,CAAC;AACF,SAAO;;CAGT,gBAAgB,SAAiC;EAC/C,MAAM,YAAY,gBAAgB,SAAS,KAAK;AAEhD,OAAK,QAAQ,UAAU,KAAK,QAAQ,QAAQ,QAAQ,KAAK,WAAW;AAClE,OAAI,CAAC,OAAQ,QAAO;AACpB,OAAI,OAAO,CAAC,IAAI,MAAM,SAAS,KAAK,SAAS,OAAO,KAAK,CACvD,KAAI,KAAK,OAAO;AAElB,UAAO;KACN,aAAa,EAAE,CAAC;;CAErB,gBAAgB,SAAmB,SAAqC;AACtE,SAAO,KAAK,cAAc,gBAAgB,SAAS,QAAQ;;CAG7D,eAAe,QAA+B;AAC5C,OAAK,cAAc,eAAe,KAAK,SAAS;GAC9C,GAAG,KAAK;GACR;GACD,CAAC"}
|
package/dist/global.cjs
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
const require_logger = require('./utils/logger.cjs');
|
|
2
|
+
const require_tool = require('./utils/tool.cjs');
|
|
3
|
+
let _module_federation_sdk = require("@module-federation/sdk");
|
|
4
|
+
|
|
5
|
+
//#region src/global.ts
|
|
6
|
+
const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
|
|
7
|
+
const nativeGlobal = (() => {
|
|
8
|
+
try {
|
|
9
|
+
return document.defaultView;
|
|
10
|
+
} catch {
|
|
11
|
+
return CurrentGlobal;
|
|
12
|
+
}
|
|
13
|
+
})();
|
|
14
|
+
const Global = nativeGlobal;
|
|
15
|
+
function definePropertyGlobalVal(target, key, val) {
|
|
16
|
+
Object.defineProperty(target, key, {
|
|
17
|
+
value: val,
|
|
18
|
+
configurable: false,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function includeOwnProperty(target, key) {
|
|
23
|
+
return Object.hasOwnProperty.call(target, key);
|
|
24
|
+
}
|
|
25
|
+
if (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
26
|
+
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
27
|
+
function setGlobalDefaultVal(target) {
|
|
28
|
+
if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);
|
|
29
|
+
if (!includeOwnProperty(target, "__FEDERATION__")) {
|
|
30
|
+
definePropertyGlobalVal(target, "__FEDERATION__", {
|
|
31
|
+
__GLOBAL_PLUGIN__: [],
|
|
32
|
+
__INSTANCES__: [],
|
|
33
|
+
moduleInfo: {},
|
|
34
|
+
__SHARE__: {},
|
|
35
|
+
__MANIFEST_LOADING__: {},
|
|
36
|
+
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
37
|
+
});
|
|
38
|
+
definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);
|
|
39
|
+
}
|
|
40
|
+
target.__FEDERATION__.__GLOBAL_PLUGIN__ ??= [];
|
|
41
|
+
target.__FEDERATION__.__INSTANCES__ ??= [];
|
|
42
|
+
target.__FEDERATION__.moduleInfo ??= {};
|
|
43
|
+
target.__FEDERATION__.__SHARE__ ??= {};
|
|
44
|
+
target.__FEDERATION__.__MANIFEST_LOADING__ ??= {};
|
|
45
|
+
target.__FEDERATION__.__PRELOADED_MAP__ ??= /* @__PURE__ */ new Map();
|
|
46
|
+
}
|
|
47
|
+
setGlobalDefaultVal(CurrentGlobal);
|
|
48
|
+
setGlobalDefaultVal(nativeGlobal);
|
|
49
|
+
function resetFederationGlobalInfo() {
|
|
50
|
+
CurrentGlobal.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
51
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__ = [];
|
|
52
|
+
CurrentGlobal.__FEDERATION__.moduleInfo = {};
|
|
53
|
+
CurrentGlobal.__FEDERATION__.__SHARE__ = {};
|
|
54
|
+
CurrentGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {};
|
|
55
|
+
Object.keys(globalLoading).forEach((key) => {
|
|
56
|
+
delete globalLoading[key];
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function setGlobalFederationInstance(FederationInstance) {
|
|
60
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance);
|
|
61
|
+
}
|
|
62
|
+
function getGlobalFederationConstructor() {
|
|
63
|
+
return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
|
|
64
|
+
}
|
|
65
|
+
function setGlobalFederationConstructor(FederationConstructor, isDebug = (0, _module_federation_sdk.isDebugMode)()) {
|
|
66
|
+
if (isDebug) {
|
|
67
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
68
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.0-chore-bump-node-22-20260710161714";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function getInfoWithoutType(target, key) {
|
|
72
|
+
if (typeof key === "string") if (target[key]) return {
|
|
73
|
+
value: target[key],
|
|
74
|
+
key
|
|
75
|
+
};
|
|
76
|
+
else {
|
|
77
|
+
const targetKeys = Object.keys(target);
|
|
78
|
+
for (const targetKey of targetKeys) {
|
|
79
|
+
const [targetTypeOrName, _] = targetKey.split(":");
|
|
80
|
+
const nKey = `${targetTypeOrName}:${key}`;
|
|
81
|
+
const typeWithKeyRes = target[nKey];
|
|
82
|
+
if (typeWithKeyRes) return {
|
|
83
|
+
value: typeWithKeyRes,
|
|
84
|
+
key: nKey
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
value: void 0,
|
|
89
|
+
key
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
else require_logger.error(`getInfoWithoutType: "key" must be a string, got ${typeof key} (${JSON.stringify(key)}).`);
|
|
93
|
+
}
|
|
94
|
+
const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo;
|
|
95
|
+
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot) => {
|
|
96
|
+
const getModuleInfo = getInfoWithoutType(snapshot, require_tool.getFMId(moduleInfo)).value;
|
|
97
|
+
if (getModuleInfo && !getModuleInfo.version && "version" in moduleInfo && moduleInfo["version"]) getModuleInfo.version = moduleInfo["version"];
|
|
98
|
+
if (getModuleInfo) return getModuleInfo;
|
|
99
|
+
if ("version" in moduleInfo && moduleInfo["version"]) {
|
|
100
|
+
const { version, ...resModuleInfo } = moduleInfo;
|
|
101
|
+
const moduleKeyWithoutVersion = require_tool.getFMId(resModuleInfo);
|
|
102
|
+
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
|
|
103
|
+
if (getModuleInfoWithoutVersion?.version === version) return getModuleInfoWithoutVersion;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo) => getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
|
|
107
|
+
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo) => {
|
|
108
|
+
const moduleKey = require_tool.getFMId(remoteInfo);
|
|
109
|
+
nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;
|
|
110
|
+
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
111
|
+
};
|
|
112
|
+
const addGlobalSnapshot = (moduleInfos) => {
|
|
113
|
+
nativeGlobal.__FEDERATION__.moduleInfo = {
|
|
114
|
+
...nativeGlobal.__FEDERATION__.moduleInfo,
|
|
115
|
+
...moduleInfos
|
|
116
|
+
};
|
|
117
|
+
return () => {
|
|
118
|
+
const keys = Object.keys(moduleInfos);
|
|
119
|
+
for (const key of keys) delete nativeGlobal.__FEDERATION__.moduleInfo[key];
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
const getRemoteEntryExports = (name, globalName) => {
|
|
123
|
+
const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;
|
|
124
|
+
return {
|
|
125
|
+
remoteEntryKey,
|
|
126
|
+
entryExports: CurrentGlobal[remoteEntryKey]
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
const registerGlobalPlugins = (plugins) => {
|
|
130
|
+
const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;
|
|
131
|
+
plugins.forEach((plugin) => {
|
|
132
|
+
if (__GLOBAL_PLUGIN__.findIndex((p) => p.name === plugin.name) === -1) __GLOBAL_PLUGIN__.push(plugin);
|
|
133
|
+
else require_logger.warn(`The plugin ${plugin.name} has been registered.`);
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
const getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;
|
|
137
|
+
const getPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(id);
|
|
138
|
+
const setPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(id, true);
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
exports.CurrentGlobal = CurrentGlobal;
|
|
142
|
+
exports.Global = Global;
|
|
143
|
+
exports.addGlobalSnapshot = addGlobalSnapshot;
|
|
144
|
+
exports.getGlobalFederationConstructor = getGlobalFederationConstructor;
|
|
145
|
+
exports.getGlobalHostPlugins = getGlobalHostPlugins;
|
|
146
|
+
exports.getGlobalSnapshot = getGlobalSnapshot;
|
|
147
|
+
exports.getGlobalSnapshotInfoByModuleInfo = getGlobalSnapshotInfoByModuleInfo;
|
|
148
|
+
exports.getInfoWithoutType = getInfoWithoutType;
|
|
149
|
+
exports.getPreloaded = getPreloaded;
|
|
150
|
+
exports.getRemoteEntryExports = getRemoteEntryExports;
|
|
151
|
+
exports.getTargetSnapshotInfoByModuleInfo = getTargetSnapshotInfoByModuleInfo;
|
|
152
|
+
exports.globalLoading = globalLoading;
|
|
153
|
+
exports.nativeGlobal = nativeGlobal;
|
|
154
|
+
exports.registerGlobalPlugins = registerGlobalPlugins;
|
|
155
|
+
exports.resetFederationGlobalInfo = resetFederationGlobalInfo;
|
|
156
|
+
exports.setGlobalFederationConstructor = setGlobalFederationConstructor;
|
|
157
|
+
exports.setGlobalFederationInstance = setGlobalFederationInstance;
|
|
158
|
+
exports.setGlobalSnapshotInfoByModuleInfo = setGlobalSnapshotInfoByModuleInfo;
|
|
159
|
+
exports.setPreloaded = setPreloaded;
|
|
160
|
+
//# sourceMappingURL=global.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.cjs","names":["getFMId"],"sources":["../src/global.ts"],"sourcesContent":["import { ModuleFederation } from './core';\nimport {\n RemoteEntryExports,\n GlobalShareScopeMap,\n Remote,\n Optional,\n} from './type';\nimport { getFMId } from './utils/tool';\nimport {\n GlobalModuleInfo,\n ModuleInfo,\n isDebugMode,\n} from '@module-federation/sdk';\nimport { warn, error } from './utils/logger';\nimport { ModuleFederationRuntimePlugin } from './type/plugin';\n\nexport interface Federation {\n __GLOBAL_PLUGIN__: Array<ModuleFederationRuntimePlugin>;\n __DEBUG_CONSTRUCTOR_VERSION__?: string;\n moduleInfo: GlobalModuleInfo;\n __DEBUG_CONSTRUCTOR__?: typeof ModuleFederation;\n __INSTANCES__: Array<ModuleFederation>;\n __SHARE__: GlobalShareScopeMap;\n __MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;\n __PRELOADED_MAP__: Map<string, boolean>;\n}\nexport const CurrentGlobal =\n typeof globalThis === 'object' ? globalThis : window;\nexport const nativeGlobal: typeof global = (() => {\n try {\n // get real window (incase of sandbox)\n return document.defaultView;\n } catch {\n // node env\n return CurrentGlobal;\n }\n})() as typeof global;\n\nexport const Global = nativeGlobal;\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __FEDERATION__: Federation,\n __VMOK__: Federation,\n // eslint-disable-next-line no-var\n __GLOBAL_LOADING_REMOTE_ENTRY__: Record<\n string,\n undefined | Promise<RemoteEntryExports | void>\n >;\n}\n\nfunction definePropertyGlobalVal(\n target: typeof CurrentGlobal,\n key: string,\n val: any,\n) {\n Object.defineProperty(target, key, {\n value: val,\n configurable: false,\n writable: true,\n });\n}\n\nfunction includeOwnProperty(target: typeof CurrentGlobal, key: string) {\n return Object.hasOwnProperty.call(target, key);\n}\n\n// This section is to prevent encapsulation by certain microfrontend frameworks. Due to reuse policies, sandbox escapes.\n// The sandbox in the microfrontend does not replicate the value of 'configurable'.\n// If there is no loading content on the global object, this section defines the loading object.\nif (!includeOwnProperty(CurrentGlobal, '__GLOBAL_LOADING_REMOTE_ENTRY__')) {\n definePropertyGlobalVal(CurrentGlobal, '__GLOBAL_LOADING_REMOTE_ENTRY__', {});\n}\n\nexport const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;\n\nfunction setGlobalDefaultVal(target: typeof CurrentGlobal) {\n if (\n includeOwnProperty(target, '__VMOK__') &&\n !includeOwnProperty(target, '__FEDERATION__')\n ) {\n definePropertyGlobalVal(target, '__FEDERATION__', target.__VMOK__);\n }\n\n if (!includeOwnProperty(target, '__FEDERATION__')) {\n definePropertyGlobalVal(target, '__FEDERATION__', {\n __GLOBAL_PLUGIN__: [],\n __INSTANCES__: [],\n moduleInfo: {},\n __SHARE__: {},\n __MANIFEST_LOADING__: {},\n __PRELOADED_MAP__: new Map(),\n });\n\n definePropertyGlobalVal(target, '__VMOK__', target.__FEDERATION__);\n }\n\n target.__FEDERATION__.__GLOBAL_PLUGIN__ ??= [];\n target.__FEDERATION__.__INSTANCES__ ??= [];\n target.__FEDERATION__.moduleInfo ??= {};\n target.__FEDERATION__.__SHARE__ ??= {};\n target.__FEDERATION__.__MANIFEST_LOADING__ ??= {};\n target.__FEDERATION__.__PRELOADED_MAP__ ??= new Map();\n}\n\nsetGlobalDefaultVal(CurrentGlobal);\nsetGlobalDefaultVal(nativeGlobal);\n\nexport function resetFederationGlobalInfo(): void {\n CurrentGlobal.__FEDERATION__.__GLOBAL_PLUGIN__ = [];\n CurrentGlobal.__FEDERATION__.__INSTANCES__ = [];\n CurrentGlobal.__FEDERATION__.moduleInfo = {};\n CurrentGlobal.__FEDERATION__.__SHARE__ = {};\n CurrentGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {};\n\n Object.keys(globalLoading).forEach((key) => {\n delete globalLoading[key];\n });\n}\n\nexport function setGlobalFederationInstance(\n FederationInstance: ModuleFederation,\n): void {\n CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance);\n}\n\nexport function getGlobalFederationConstructor():\n | typeof ModuleFederation\n | undefined {\n return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__;\n}\n\nexport function setGlobalFederationConstructor(\n FederationConstructor: typeof ModuleFederation | undefined,\n isDebug = isDebugMode(),\n): void {\n if (isDebug) {\n CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;\n CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = __VERSION__;\n }\n}\n\nexport function getInfoWithoutType<T extends object>(\n target: T,\n key: keyof T,\n): { value: T[keyof T] | undefined; key: string } {\n if (typeof key === 'string') {\n const keyRes = target[key];\n if (keyRes) {\n return {\n value: target[key],\n key: key as string,\n };\n } else {\n const targetKeys = Object.keys(target);\n for (const targetKey of targetKeys) {\n const [targetTypeOrName, _] = targetKey.split(':');\n const nKey = `${targetTypeOrName}:${key}` as unknown as keyof T;\n const typeWithKeyRes = target[nKey];\n if (typeWithKeyRes) {\n return {\n value: typeWithKeyRes,\n key: nKey as string,\n };\n }\n }\n return {\n value: undefined,\n key: key as string,\n };\n }\n } else {\n error(\n `getInfoWithoutType: \"key\" must be a string, got ${typeof key} (${JSON.stringify(key)}).`,\n );\n }\n}\n\nexport const getGlobalSnapshot = (): GlobalModuleInfo =>\n nativeGlobal.__FEDERATION__.moduleInfo;\n\nexport const getTargetSnapshotInfoByModuleInfo = (\n moduleInfo: Optional<Remote, 'alias'>,\n snapshot: GlobalModuleInfo,\n): GlobalModuleInfo[string] | undefined => {\n // Check if the remote is included in the hostSnapshot\n const moduleKey = getFMId(moduleInfo);\n const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value;\n\n // The remoteSnapshot might not include a version\n if (\n getModuleInfo &&\n !getModuleInfo.version &&\n 'version' in moduleInfo &&\n moduleInfo['version']\n ) {\n getModuleInfo.version = moduleInfo['version'];\n }\n\n if (getModuleInfo) {\n return getModuleInfo;\n }\n\n // If the remote is not included in the hostSnapshot, deploy a micro app snapshot\n if ('version' in moduleInfo && moduleInfo['version']) {\n const { version, ...resModuleInfo } = moduleInfo;\n const moduleKeyWithoutVersion = getFMId(resModuleInfo);\n const getModuleInfoWithoutVersion = getInfoWithoutType(\n nativeGlobal.__FEDERATION__.moduleInfo,\n moduleKeyWithoutVersion,\n ).value;\n\n if (getModuleInfoWithoutVersion?.version === version) {\n return getModuleInfoWithoutVersion;\n }\n }\n\n return;\n};\n\nexport const getGlobalSnapshotInfoByModuleInfo = (\n moduleInfo: Optional<Remote, 'alias'>,\n): GlobalModuleInfo[string] | undefined =>\n getTargetSnapshotInfoByModuleInfo(\n moduleInfo,\n nativeGlobal.__FEDERATION__.moduleInfo,\n );\n\nexport const setGlobalSnapshotInfoByModuleInfo = (\n remoteInfo: Remote,\n moduleDetailInfo: GlobalModuleInfo[string],\n): GlobalModuleInfo => {\n const moduleKey = getFMId(remoteInfo);\n nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;\n return nativeGlobal.__FEDERATION__.moduleInfo;\n};\n\nexport const addGlobalSnapshot = (\n moduleInfos: GlobalModuleInfo,\n): (() => void) => {\n nativeGlobal.__FEDERATION__.moduleInfo = {\n ...nativeGlobal.__FEDERATION__.moduleInfo,\n ...moduleInfos,\n };\n return () => {\n const keys = Object.keys(moduleInfos);\n for (const key of keys) {\n delete nativeGlobal.__FEDERATION__.moduleInfo[key];\n }\n };\n};\n\nexport const getRemoteEntryExports = (\n name: string,\n globalName: string | undefined,\n): {\n remoteEntryKey: string;\n entryExports: RemoteEntryExports | undefined;\n} => {\n const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;\n const entryExports = (CurrentGlobal as any)[remoteEntryKey];\n return {\n remoteEntryKey,\n entryExports,\n };\n};\n\n// This function is used to register global plugins.\n// It iterates over the provided plugins and checks if they are already registered.\n// If a plugin is not registered, it is added to the global plugins.\n// If a plugin is already registered, a warning message is logged.\nexport const registerGlobalPlugins = (\n plugins: Array<ModuleFederationRuntimePlugin>,\n): void => {\n const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;\n\n plugins.forEach((plugin) => {\n if (__GLOBAL_PLUGIN__.findIndex((p) => p.name === plugin.name) === -1) {\n __GLOBAL_PLUGIN__.push(plugin);\n } else {\n warn(`The plugin ${plugin.name} has been registered.`);\n }\n });\n};\n\nexport const getGlobalHostPlugins = (): Array<ModuleFederationRuntimePlugin> =>\n nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;\n\nexport const getPreloaded = (id: string) =>\n CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(id);\n\nexport const setPreloaded = (id: string) =>\n CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(id, true);\n"],"mappings":";;;;;AA0BA,MAAa,gBACX,OAAO,eAAe,WAAW,aAAa;AAChD,MAAa,sBAAqC;AAChD,KAAI;AAEF,SAAO,SAAS;SACV;AAEN,SAAO;;IAEP;AAEJ,MAAa,SAAS;AAatB,SAAS,wBACP,QACA,KACA,KACA;AACA,QAAO,eAAe,QAAQ,KAAK;EACjC,OAAO;EACP,cAAc;EACd,UAAU;EACX,CAAC;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AAa;EACX,MAAM,OAAO,OAAO,KAAK,YAAY;AACrC,OAAK,MAAM,OAAO,KAChB,QAAO,aAAa,eAAe,WAAW;;;AAKpD,MAAa,yBACX,MACA,eAIG;CACH,MAAM,iBAAiB,cAAc,gBAAgB,KAAK;AAE1D,QAAO;EACL;EACA,cAHoB,cAAsB;EAI3C;;AAOH,MAAa,yBACX,YACS;CACT,MAAM,EAAE,sBAAsB,aAAa;AAE3C,SAAQ,SAAS,WAAW;AAC1B,MAAI,kBAAkB,WAAW,MAAM,EAAE,SAAS,OAAO,KAAK,KAAK,GACjE,mBAAkB,KAAK,OAAO;MAE9B,qBAAK,cAAc,OAAO,KAAK,uBAAuB;GAExD;;AAGJ,MAAa,6BACX,aAAa,eAAe;AAE9B,MAAa,gBAAgB,OAC3B,cAAc,eAAe,kBAAkB,IAAI,GAAG;AAExD,MAAa,gBAAgB,OAC3B,cAAc,eAAe,kBAAkB,IAAI,IAAI,KAAK"}
|
package/dist/global.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ModuleFederation } from "./core.js";
|
|
2
|
+
import { ModuleFederationRuntimePlugin } from "./type/plugin.js";
|
|
3
|
+
import { GlobalShareScopeMap, Optional, Remote, RemoteEntryExports } from "./type/config.js";
|
|
4
|
+
import { GlobalModuleInfo, ModuleInfo } from "@module-federation/sdk";
|
|
5
|
+
|
|
6
|
+
//#region src/global.d.ts
|
|
7
|
+
interface Federation {
|
|
8
|
+
__GLOBAL_PLUGIN__: Array<ModuleFederationRuntimePlugin>;
|
|
9
|
+
__DEBUG_CONSTRUCTOR_VERSION__?: string;
|
|
10
|
+
moduleInfo: GlobalModuleInfo;
|
|
11
|
+
__DEBUG_CONSTRUCTOR__?: typeof ModuleFederation;
|
|
12
|
+
__INSTANCES__: Array<ModuleFederation>;
|
|
13
|
+
__SHARE__: GlobalShareScopeMap;
|
|
14
|
+
__MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;
|
|
15
|
+
__PRELOADED_MAP__: Map<string, boolean>;
|
|
16
|
+
}
|
|
17
|
+
declare const CurrentGlobal: typeof globalThis;
|
|
18
|
+
declare const Global: typeof globalThis;
|
|
19
|
+
declare global {
|
|
20
|
+
var __FEDERATION__: Federation, __VMOK__: Federation, __GLOBAL_LOADING_REMOTE_ENTRY__: Record<string, undefined | Promise<RemoteEntryExports | void>>;
|
|
21
|
+
}
|
|
22
|
+
declare function resetFederationGlobalInfo(): void;
|
|
23
|
+
declare function setGlobalFederationInstance(FederationInstance: ModuleFederation): void;
|
|
24
|
+
declare function getGlobalFederationConstructor(): typeof ModuleFederation | undefined;
|
|
25
|
+
declare function setGlobalFederationConstructor(FederationConstructor: typeof ModuleFederation | undefined, isDebug?: boolean): void;
|
|
26
|
+
declare function getInfoWithoutType<T extends object>(target: T, key: keyof T): {
|
|
27
|
+
value: T[keyof T] | undefined;
|
|
28
|
+
key: string;
|
|
29
|
+
};
|
|
30
|
+
declare const getGlobalSnapshot: () => GlobalModuleInfo;
|
|
31
|
+
declare const getTargetSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, "alias">, snapshot: GlobalModuleInfo) => GlobalModuleInfo[string] | undefined;
|
|
32
|
+
declare const getGlobalSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, "alias">) => GlobalModuleInfo[string] | undefined;
|
|
33
|
+
declare const setGlobalSnapshotInfoByModuleInfo: (remoteInfo: Remote, moduleDetailInfo: GlobalModuleInfo[string]) => GlobalModuleInfo;
|
|
34
|
+
declare const addGlobalSnapshot: (moduleInfos: GlobalModuleInfo) => (() => void);
|
|
35
|
+
declare const getRemoteEntryExports: (name: string, globalName: string | undefined) => {
|
|
36
|
+
remoteEntryKey: string;
|
|
37
|
+
entryExports: RemoteEntryExports | undefined;
|
|
38
|
+
};
|
|
39
|
+
declare const registerGlobalPlugins: (plugins: Array<ModuleFederationRuntimePlugin>) => void;
|
|
40
|
+
declare const getGlobalHostPlugins: () => Array<ModuleFederationRuntimePlugin>;
|
|
41
|
+
declare const getPreloaded: (id: string) => boolean | undefined;
|
|
42
|
+
declare const setPreloaded: (id: string) => Map<string, boolean>;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { CurrentGlobal, Federation, Global, addGlobalSnapshot, getGlobalFederationConstructor, getGlobalHostPlugins, getGlobalSnapshot, getGlobalSnapshotInfoByModuleInfo, getInfoWithoutType, getPreloaded, getRemoteEntryExports, getTargetSnapshotInfoByModuleInfo, registerGlobalPlugins, resetFederationGlobalInfo, setGlobalFederationConstructor, setGlobalFederationInstance, setGlobalSnapshotInfoByModuleInfo, setPreloaded };
|
|
45
|
+
//# sourceMappingURL=global.d.ts.map
|
package/dist/global.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { error, warn as warn$1 } from "./utils/logger.js";
|
|
2
|
+
import { getFMId } from "./utils/tool.js";
|
|
3
|
+
import { isDebugMode } from "@module-federation/sdk";
|
|
4
|
+
|
|
5
|
+
//#region src/global.ts
|
|
6
|
+
const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
|
|
7
|
+
const nativeGlobal = (() => {
|
|
8
|
+
try {
|
|
9
|
+
return document.defaultView;
|
|
10
|
+
} catch {
|
|
11
|
+
return CurrentGlobal;
|
|
12
|
+
}
|
|
13
|
+
})();
|
|
14
|
+
const Global = nativeGlobal;
|
|
15
|
+
function definePropertyGlobalVal(target, key, val) {
|
|
16
|
+
Object.defineProperty(target, key, {
|
|
17
|
+
value: val,
|
|
18
|
+
configurable: false,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function includeOwnProperty(target, key) {
|
|
23
|
+
return Object.hasOwnProperty.call(target, key);
|
|
24
|
+
}
|
|
25
|
+
if (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
26
|
+
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
27
|
+
function setGlobalDefaultVal(target) {
|
|
28
|
+
if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);
|
|
29
|
+
if (!includeOwnProperty(target, "__FEDERATION__")) {
|
|
30
|
+
definePropertyGlobalVal(target, "__FEDERATION__", {
|
|
31
|
+
__GLOBAL_PLUGIN__: [],
|
|
32
|
+
__INSTANCES__: [],
|
|
33
|
+
moduleInfo: {},
|
|
34
|
+
__SHARE__: {},
|
|
35
|
+
__MANIFEST_LOADING__: {},
|
|
36
|
+
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
37
|
+
});
|
|
38
|
+
definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);
|
|
39
|
+
}
|
|
40
|
+
target.__FEDERATION__.__GLOBAL_PLUGIN__ ??= [];
|
|
41
|
+
target.__FEDERATION__.__INSTANCES__ ??= [];
|
|
42
|
+
target.__FEDERATION__.moduleInfo ??= {};
|
|
43
|
+
target.__FEDERATION__.__SHARE__ ??= {};
|
|
44
|
+
target.__FEDERATION__.__MANIFEST_LOADING__ ??= {};
|
|
45
|
+
target.__FEDERATION__.__PRELOADED_MAP__ ??= /* @__PURE__ */ new Map();
|
|
46
|
+
}
|
|
47
|
+
setGlobalDefaultVal(CurrentGlobal);
|
|
48
|
+
setGlobalDefaultVal(nativeGlobal);
|
|
49
|
+
function resetFederationGlobalInfo() {
|
|
50
|
+
CurrentGlobal.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
51
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__ = [];
|
|
52
|
+
CurrentGlobal.__FEDERATION__.moduleInfo = {};
|
|
53
|
+
CurrentGlobal.__FEDERATION__.__SHARE__ = {};
|
|
54
|
+
CurrentGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {};
|
|
55
|
+
Object.keys(globalLoading).forEach((key) => {
|
|
56
|
+
delete globalLoading[key];
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function setGlobalFederationInstance(FederationInstance) {
|
|
60
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance);
|
|
61
|
+
}
|
|
62
|
+
function getGlobalFederationConstructor() {
|
|
63
|
+
return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
|
|
64
|
+
}
|
|
65
|
+
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
66
|
+
if (isDebug) {
|
|
67
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
68
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.0-chore-bump-node-22-20260710161714";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function getInfoWithoutType(target, key) {
|
|
72
|
+
if (typeof key === "string") if (target[key]) return {
|
|
73
|
+
value: target[key],
|
|
74
|
+
key
|
|
75
|
+
};
|
|
76
|
+
else {
|
|
77
|
+
const targetKeys = Object.keys(target);
|
|
78
|
+
for (const targetKey of targetKeys) {
|
|
79
|
+
const [targetTypeOrName, _] = targetKey.split(":");
|
|
80
|
+
const nKey = `${targetTypeOrName}:${key}`;
|
|
81
|
+
const typeWithKeyRes = target[nKey];
|
|
82
|
+
if (typeWithKeyRes) return {
|
|
83
|
+
value: typeWithKeyRes,
|
|
84
|
+
key: nKey
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
value: void 0,
|
|
89
|
+
key
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
else error(`getInfoWithoutType: "key" must be a string, got ${typeof key} (${JSON.stringify(key)}).`);
|
|
93
|
+
}
|
|
94
|
+
const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo;
|
|
95
|
+
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot) => {
|
|
96
|
+
const getModuleInfo = getInfoWithoutType(snapshot, getFMId(moduleInfo)).value;
|
|
97
|
+
if (getModuleInfo && !getModuleInfo.version && "version" in moduleInfo && moduleInfo["version"]) getModuleInfo.version = moduleInfo["version"];
|
|
98
|
+
if (getModuleInfo) return getModuleInfo;
|
|
99
|
+
if ("version" in moduleInfo && moduleInfo["version"]) {
|
|
100
|
+
const { version, ...resModuleInfo } = moduleInfo;
|
|
101
|
+
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
102
|
+
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
|
|
103
|
+
if (getModuleInfoWithoutVersion?.version === version) return getModuleInfoWithoutVersion;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo) => getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
|
|
107
|
+
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo) => {
|
|
108
|
+
const moduleKey = getFMId(remoteInfo);
|
|
109
|
+
nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;
|
|
110
|
+
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
111
|
+
};
|
|
112
|
+
const addGlobalSnapshot = (moduleInfos) => {
|
|
113
|
+
nativeGlobal.__FEDERATION__.moduleInfo = {
|
|
114
|
+
...nativeGlobal.__FEDERATION__.moduleInfo,
|
|
115
|
+
...moduleInfos
|
|
116
|
+
};
|
|
117
|
+
return () => {
|
|
118
|
+
const keys = Object.keys(moduleInfos);
|
|
119
|
+
for (const key of keys) delete nativeGlobal.__FEDERATION__.moduleInfo[key];
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
const getRemoteEntryExports = (name, globalName) => {
|
|
123
|
+
const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;
|
|
124
|
+
return {
|
|
125
|
+
remoteEntryKey,
|
|
126
|
+
entryExports: CurrentGlobal[remoteEntryKey]
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
const registerGlobalPlugins = (plugins) => {
|
|
130
|
+
const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;
|
|
131
|
+
plugins.forEach((plugin) => {
|
|
132
|
+
if (__GLOBAL_PLUGIN__.findIndex((p) => p.name === plugin.name) === -1) __GLOBAL_PLUGIN__.push(plugin);
|
|
133
|
+
else warn$1(`The plugin ${plugin.name} has been registered.`);
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
const getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;
|
|
137
|
+
const getPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(id);
|
|
138
|
+
const setPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(id, true);
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { CurrentGlobal, Global, addGlobalSnapshot, getGlobalFederationConstructor, getGlobalHostPlugins, getGlobalSnapshot, getGlobalSnapshotInfoByModuleInfo, getInfoWithoutType, getPreloaded, getRemoteEntryExports, getTargetSnapshotInfoByModuleInfo, globalLoading, nativeGlobal, registerGlobalPlugins, resetFederationGlobalInfo, setGlobalFederationConstructor, setGlobalFederationInstance, setGlobalSnapshotInfoByModuleInfo, setPreloaded };
|
|
142
|
+
//# sourceMappingURL=global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","names":[],"sources":["../src/global.ts"],"sourcesContent":["import { ModuleFederation } from './core';\nimport {\n RemoteEntryExports,\n GlobalShareScopeMap,\n Remote,\n Optional,\n} from './type';\nimport { getFMId } from './utils/tool';\nimport {\n GlobalModuleInfo,\n ModuleInfo,\n isDebugMode,\n} from '@module-federation/sdk';\nimport { warn, error } from './utils/logger';\nimport { ModuleFederationRuntimePlugin } from './type/plugin';\n\nexport interface Federation {\n __GLOBAL_PLUGIN__: Array<ModuleFederationRuntimePlugin>;\n __DEBUG_CONSTRUCTOR_VERSION__?: string;\n moduleInfo: GlobalModuleInfo;\n __DEBUG_CONSTRUCTOR__?: typeof ModuleFederation;\n __INSTANCES__: Array<ModuleFederation>;\n __SHARE__: GlobalShareScopeMap;\n __MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;\n __PRELOADED_MAP__: Map<string, boolean>;\n}\nexport const CurrentGlobal =\n typeof globalThis === 'object' ? globalThis : window;\nexport const nativeGlobal: typeof global = (() => {\n try {\n // get real window (incase of sandbox)\n return document.defaultView;\n } catch {\n // node env\n return CurrentGlobal;\n }\n})() as typeof global;\n\nexport const Global = nativeGlobal;\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __FEDERATION__: Federation,\n __VMOK__: Federation,\n // eslint-disable-next-line no-var\n __GLOBAL_LOADING_REMOTE_ENTRY__: Record<\n string,\n undefined | Promise<RemoteEntryExports | void>\n >;\n}\n\nfunction definePropertyGlobalVal(\n target: typeof CurrentGlobal,\n key: string,\n val: any,\n) {\n Object.defineProperty(target, key, {\n value: val,\n configurable: false,\n writable: true,\n });\n}\n\nfunction includeOwnProperty(target: typeof CurrentGlobal, key: string) {\n return Object.hasOwnProperty.call(target, key);\n}\n\n// This section is to prevent encapsulation by certain microfrontend frameworks. Due to reuse policies, sandbox escapes.\n// The sandbox in the microfrontend does not replicate the value of 'configurable'.\n// If there is no loading content on the global object, this section defines the loading object.\nif (!includeOwnProperty(CurrentGlobal, '__GLOBAL_LOADING_REMOTE_ENTRY__')) {\n definePropertyGlobalVal(CurrentGlobal, '__GLOBAL_LOADING_REMOTE_ENTRY__', {});\n}\n\nexport const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;\n\nfunction setGlobalDefaultVal(target: typeof CurrentGlobal) {\n if (\n includeOwnProperty(target, '__VMOK__') &&\n !includeOwnProperty(target, '__FEDERATION__')\n ) {\n definePropertyGlobalVal(target, '__FEDERATION__', target.__VMOK__);\n }\n\n if (!includeOwnProperty(target, '__FEDERATION__')) {\n definePropertyGlobalVal(target, '__FEDERATION__', {\n __GLOBAL_PLUGIN__: [],\n __INSTANCES__: [],\n moduleInfo: {},\n __SHARE__: {},\n __MANIFEST_LOADING__: {},\n __PRELOADED_MAP__: new Map(),\n });\n\n definePropertyGlobalVal(target, '__VMOK__', target.__FEDERATION__);\n }\n\n target.__FEDERATION__.__GLOBAL_PLUGIN__ ??= [];\n target.__FEDERATION__.__INSTANCES__ ??= [];\n target.__FEDERATION__.moduleInfo ??= {};\n target.__FEDERATION__.__SHARE__ ??= {};\n target.__FEDERATION__.__MANIFEST_LOADING__ ??= {};\n target.__FEDERATION__.__PRELOADED_MAP__ ??= new Map();\n}\n\nsetGlobalDefaultVal(CurrentGlobal);\nsetGlobalDefaultVal(nativeGlobal);\n\nexport function resetFederationGlobalInfo(): void {\n CurrentGlobal.__FEDERATION__.__GLOBAL_PLUGIN__ = [];\n CurrentGlobal.__FEDERATION__.__INSTANCES__ = [];\n CurrentGlobal.__FEDERATION__.moduleInfo = {};\n CurrentGlobal.__FEDERATION__.__SHARE__ = {};\n CurrentGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {};\n\n Object.keys(globalLoading).forEach((key) => {\n delete globalLoading[key];\n });\n}\n\nexport function setGlobalFederationInstance(\n FederationInstance: ModuleFederation,\n): void {\n CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance);\n}\n\nexport function getGlobalFederationConstructor():\n | typeof ModuleFederation\n | undefined {\n return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__;\n}\n\nexport function setGlobalFederationConstructor(\n FederationConstructor: typeof ModuleFederation | undefined,\n isDebug = isDebugMode(),\n): void {\n if (isDebug) {\n CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;\n CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = __VERSION__;\n }\n}\n\nexport function getInfoWithoutType<T extends object>(\n target: T,\n key: keyof T,\n): { value: T[keyof T] | undefined; key: string } {\n if (typeof key === 'string') {\n const keyRes = target[key];\n if (keyRes) {\n return {\n value: target[key],\n key: key as string,\n };\n } else {\n const targetKeys = Object.keys(target);\n for (const targetKey of targetKeys) {\n const [targetTypeOrName, _] = targetKey.split(':');\n const nKey = `${targetTypeOrName}:${key}` as unknown as keyof T;\n const typeWithKeyRes = target[nKey];\n if (typeWithKeyRes) {\n return {\n value: typeWithKeyRes,\n key: nKey as string,\n };\n }\n }\n return {\n value: undefined,\n key: key as string,\n };\n }\n } else {\n error(\n `getInfoWithoutType: \"key\" must be a string, got ${typeof key} (${JSON.stringify(key)}).`,\n );\n }\n}\n\nexport const getGlobalSnapshot = (): GlobalModuleInfo =>\n nativeGlobal.__FEDERATION__.moduleInfo;\n\nexport const getTargetSnapshotInfoByModuleInfo = (\n moduleInfo: Optional<Remote, 'alias'>,\n snapshot: GlobalModuleInfo,\n): GlobalModuleInfo[string] | undefined => {\n // Check if the remote is included in the hostSnapshot\n const moduleKey = getFMId(moduleInfo);\n const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value;\n\n // The remoteSnapshot might not include a version\n if (\n getModuleInfo &&\n !getModuleInfo.version &&\n 'version' in moduleInfo &&\n moduleInfo['version']\n ) {\n getModuleInfo.version = moduleInfo['version'];\n }\n\n if (getModuleInfo) {\n return getModuleInfo;\n }\n\n // If the remote is not included in the hostSnapshot, deploy a micro app snapshot\n if ('version' in moduleInfo && moduleInfo['version']) {\n const { version, ...resModuleInfo } = moduleInfo;\n const moduleKeyWithoutVersion = getFMId(resModuleInfo);\n const getModuleInfoWithoutVersion = getInfoWithoutType(\n nativeGlobal.__FEDERATION__.moduleInfo,\n moduleKeyWithoutVersion,\n ).value;\n\n if (getModuleInfoWithoutVersion?.version === version) {\n return getModuleInfoWithoutVersion;\n }\n }\n\n return;\n};\n\nexport const getGlobalSnapshotInfoByModuleInfo = (\n moduleInfo: Optional<Remote, 'alias'>,\n): GlobalModuleInfo[string] | undefined =>\n getTargetSnapshotInfoByModuleInfo(\n moduleInfo,\n nativeGlobal.__FEDERATION__.moduleInfo,\n );\n\nexport const setGlobalSnapshotInfoByModuleInfo = (\n remoteInfo: Remote,\n moduleDetailInfo: GlobalModuleInfo[string],\n): GlobalModuleInfo => {\n const moduleKey = getFMId(remoteInfo);\n nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;\n return nativeGlobal.__FEDERATION__.moduleInfo;\n};\n\nexport const addGlobalSnapshot = (\n moduleInfos: GlobalModuleInfo,\n): (() => void) => {\n nativeGlobal.__FEDERATION__.moduleInfo = {\n ...nativeGlobal.__FEDERATION__.moduleInfo,\n ...moduleInfos,\n };\n return () => {\n const keys = Object.keys(moduleInfos);\n for (const key of keys) {\n delete nativeGlobal.__FEDERATION__.moduleInfo[key];\n }\n };\n};\n\nexport const getRemoteEntryExports = (\n name: string,\n globalName: string | undefined,\n): {\n remoteEntryKey: string;\n entryExports: RemoteEntryExports | undefined;\n} => {\n const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;\n const entryExports = (CurrentGlobal as any)[remoteEntryKey];\n return {\n remoteEntryKey,\n entryExports,\n };\n};\n\n// This function is used to register global plugins.\n// It iterates over the provided plugins and checks if they are already registered.\n// If a plugin is not registered, it is added to the global plugins.\n// If a plugin is already registered, a warning message is logged.\nexport const registerGlobalPlugins = (\n plugins: Array<ModuleFederationRuntimePlugin>,\n): void => {\n const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;\n\n plugins.forEach((plugin) => {\n if (__GLOBAL_PLUGIN__.findIndex((p) => p.name === plugin.name) === -1) {\n __GLOBAL_PLUGIN__.push(plugin);\n } else {\n warn(`The plugin ${plugin.name} has been registered.`);\n }\n });\n};\n\nexport const getGlobalHostPlugins = (): Array<ModuleFederationRuntimePlugin> =>\n nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;\n\nexport const getPreloaded = (id: string) =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c;EACtD,MAAM,8BAA8B,mBAClC,aAAa,eAAe,YAC5B,wBACD,CAAC;AAEF,MAAI,6BAA6B,YAAY,QAC3C,QAAO;;;AAOb,MAAa,qCACX,eAEA,kCACE,YACA,aAAa,eAAe,WAC7B;AAEH,MAAa,qCACX,YACA,qBACqB;CACrB,MAAM,YAAY,QAAQ,WAAW;AACrC,cAAa,eAAe,WAAW,aAAa;AACpD,QAAO,aAAa,eAAe;;AAGrC,MAAa,qBACX,gBACiB;AACjB,cAAa,eAAe,aAAa;EACvC,GAAG,aAAa,eAAe;EAC/B,GAAG;EACJ;AACD,cAAa;EACX,MAAM,OAAO,OAAO,KAAK,YAAY;AACrC,OAAK,MAAM,OAAO,KAChB,QAAO,aAAa,eAAe,WAAW;;;AAKpD,MAAa,yBACX,MACA,eAIG;CACH,MAAM,iBAAiB,cAAc,gBAAgB,KAAK;AAE1D,QAAO;EACL;EACA,cAHoB,cAAsB;EAI3C;;AAOH,MAAa,yBACX,YACS;CACT,MAAM,EAAE,sBAAsB,aAAa;AAE3C,SAAQ,SAAS,WAAW;AAC1B,MAAI,kBAAkB,WAAW,MAAM,EAAE,SAAS,OAAO,KAAK,KAAK,GACjE,mBAAkB,KAAK,OAAO;MAE9B,QAAK,cAAc,OAAO,KAAK,uBAAuB;GAExD;;AAGJ,MAAa,6BACX,aAAa,eAAe;AAE9B,MAAa,gBAAgB,OAC3B,cAAc,eAAe,kBAAkB,IAAI,GAAG;AAExD,MAAa,gBAAgB,OAC3B,cAAc,eAAe,kBAAkB,IAAI,IAAI,KAAK"}
|
package/dist/helpers.cjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const require_global = require('./global.cjs');
|
|
2
|
+
const require_share = require('./utils/share.cjs');
|
|
3
|
+
const require_manifest = require('./utils/manifest.cjs');
|
|
4
|
+
const require_load = require('./utils/load.cjs');
|
|
5
|
+
require('./utils/index.cjs');
|
|
6
|
+
const require_preload = require('./utils/preload.cjs');
|
|
7
|
+
|
|
8
|
+
//#region src/helpers.ts
|
|
9
|
+
const ShareUtils = {
|
|
10
|
+
getRegisteredShare: require_share.getRegisteredShare,
|
|
11
|
+
getGlobalShareScope: require_share.getGlobalShareScope
|
|
12
|
+
};
|
|
13
|
+
const GlobalUtils = {
|
|
14
|
+
Global: require_global.Global,
|
|
15
|
+
nativeGlobal: require_global.nativeGlobal,
|
|
16
|
+
resetFederationGlobalInfo: require_global.resetFederationGlobalInfo,
|
|
17
|
+
setGlobalFederationInstance: require_global.setGlobalFederationInstance,
|
|
18
|
+
getGlobalFederationConstructor: require_global.getGlobalFederationConstructor,
|
|
19
|
+
setGlobalFederationConstructor: require_global.setGlobalFederationConstructor,
|
|
20
|
+
getInfoWithoutType: require_global.getInfoWithoutType,
|
|
21
|
+
getGlobalSnapshot: require_global.getGlobalSnapshot,
|
|
22
|
+
getTargetSnapshotInfoByModuleInfo: require_global.getTargetSnapshotInfoByModuleInfo,
|
|
23
|
+
getGlobalSnapshotInfoByModuleInfo: require_global.getGlobalSnapshotInfoByModuleInfo,
|
|
24
|
+
setGlobalSnapshotInfoByModuleInfo: require_global.setGlobalSnapshotInfoByModuleInfo,
|
|
25
|
+
addGlobalSnapshot: require_global.addGlobalSnapshot,
|
|
26
|
+
getRemoteEntryExports: require_global.getRemoteEntryExports,
|
|
27
|
+
registerGlobalPlugins: require_global.registerGlobalPlugins,
|
|
28
|
+
getGlobalHostPlugins: require_global.getGlobalHostPlugins,
|
|
29
|
+
getPreloaded: require_global.getPreloaded,
|
|
30
|
+
setPreloaded: require_global.setPreloaded
|
|
31
|
+
};
|
|
32
|
+
var helpers_default = {
|
|
33
|
+
global: GlobalUtils,
|
|
34
|
+
share: ShareUtils,
|
|
35
|
+
utils: {
|
|
36
|
+
matchRemoteWithNameAndExpose: require_manifest.matchRemoteWithNameAndExpose,
|
|
37
|
+
preloadAssets: require_preload.preloadAssets,
|
|
38
|
+
getRemoteInfo: require_load.getRemoteInfo
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.default = helpers_default;
|
|
44
|
+
//# sourceMappingURL=helpers.cjs.map
|