@ice/mf-runtime 0.0.8-beta.2 → 0.0.8-beta.3
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.
|
@@ -17,9 +17,10 @@ declare global {
|
|
|
17
17
|
__MF_GLOBAL_STORE__: {
|
|
18
18
|
remotes: Map<string, RemoteModuleInfo>;
|
|
19
19
|
hostRemotes: Map<string, HostRemoteInfo>;
|
|
20
|
-
microMods
|
|
20
|
+
microMods?: Map<string, MicroMod[]>;
|
|
21
21
|
currentModuleName?: string;
|
|
22
22
|
};
|
|
23
|
+
getCurrentIceMicroMods?: () => MicroMod[];
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
export declare function getCurrentModuleName(): string;
|
|
@@ -16,15 +16,26 @@ export function initGlobalStore(options, microMods) {
|
|
|
16
16
|
if (!window.__MF_GLOBAL_STORE__) {
|
|
17
17
|
window.__MF_GLOBAL_STORE__ = {
|
|
18
18
|
remotes: new Map(),
|
|
19
|
-
hostRemotes: new Map()
|
|
20
|
-
microMods: new Map(),
|
|
21
|
-
currentModuleName: options.name
|
|
19
|
+
hostRemotes: new Map()
|
|
22
20
|
};
|
|
23
21
|
}
|
|
22
|
+
window.__MF_GLOBAL_STORE__.currentModuleName = options.name;
|
|
24
23
|
if (microMods) {
|
|
24
|
+
if (!window.__MF_GLOBAL_STORE__.microMods) {
|
|
25
|
+
window.__MF_GLOBAL_STORE__.microMods = new Map();
|
|
26
|
+
}
|
|
25
27
|
window.__MF_GLOBAL_STORE__.microMods.set(options.name, microMods);
|
|
26
28
|
}
|
|
27
29
|
const store = window.__MF_GLOBAL_STORE__;
|
|
30
|
+
if (!window.getCurrentIceMicroMods) {
|
|
31
|
+
window.getCurrentIceMicroMods = ()=>{
|
|
32
|
+
const currentModuleName = getCurrentModuleName();
|
|
33
|
+
if (!currentModuleName) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return store.microMods.get(currentModuleName) || [];
|
|
37
|
+
};
|
|
38
|
+
}
|
|
28
39
|
// 获取或创建 hostInfo
|
|
29
40
|
const existingHostInfo = store.hostRemotes.get(options.name);
|
|
30
41
|
const hostInfo = existingHostInfo || {
|
package/esm/mf-global-store.d.ts
CHANGED
|
@@ -17,9 +17,10 @@ declare global {
|
|
|
17
17
|
__MF_GLOBAL_STORE__: {
|
|
18
18
|
remotes: Map<string, RemoteModuleInfo>;
|
|
19
19
|
hostRemotes: Map<string, HostRemoteInfo>;
|
|
20
|
-
microMods
|
|
20
|
+
microMods?: Map<string, MicroMod[]>;
|
|
21
21
|
currentModuleName?: string;
|
|
22
22
|
};
|
|
23
|
+
getCurrentIceMicroMods?: () => MicroMod[];
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
export declare function getCurrentModuleName(): string;
|
package/esm/mf-global-store.js
CHANGED
|
@@ -19,15 +19,26 @@ export function initGlobalStore(options, microMods) {
|
|
|
19
19
|
if (!window.__MF_GLOBAL_STORE__) {
|
|
20
20
|
window.__MF_GLOBAL_STORE__ = {
|
|
21
21
|
remotes: new Map(),
|
|
22
|
-
hostRemotes: new Map()
|
|
23
|
-
microMods: new Map(),
|
|
24
|
-
currentModuleName: options.name
|
|
22
|
+
hostRemotes: new Map()
|
|
25
23
|
};
|
|
26
24
|
}
|
|
25
|
+
window.__MF_GLOBAL_STORE__.currentModuleName = options.name;
|
|
27
26
|
if (microMods) {
|
|
27
|
+
if (!window.__MF_GLOBAL_STORE__.microMods) {
|
|
28
|
+
window.__MF_GLOBAL_STORE__.microMods = new Map();
|
|
29
|
+
}
|
|
28
30
|
window.__MF_GLOBAL_STORE__.microMods.set(options.name, microMods);
|
|
29
31
|
}
|
|
30
32
|
var store = window.__MF_GLOBAL_STORE__;
|
|
33
|
+
if (!window.getCurrentIceMicroMods) {
|
|
34
|
+
window.getCurrentIceMicroMods = function() {
|
|
35
|
+
var currentModuleName = getCurrentModuleName();
|
|
36
|
+
if (!currentModuleName) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
return store.microMods.get(currentModuleName) || [];
|
|
40
|
+
};
|
|
41
|
+
}
|
|
31
42
|
// 获取或创建 hostInfo
|
|
32
43
|
var existingHostInfo = store.hostRemotes.get(options.name);
|
|
33
44
|
var hostInfo = existingHostInfo || {
|