@ice/mf-runtime 0.0.8-beta.2 → 0.0.8-beta.4

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: Map<string, MicroMod[]>;
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;
@@ -3,28 +3,40 @@ export function getCurrentModuleName() {
3
3
  return (_window___MF_GLOBAL_STORE__ = window.__MF_GLOBAL_STORE__) === null || _window___MF_GLOBAL_STORE__ === void 0 ? void 0 : _window___MF_GLOBAL_STORE__.currentModuleName;
4
4
  }
5
5
  export function getMicroMod(scope) {
6
- var _microMods;
6
+ var _store_microMods, _microMods;
7
7
  const store = window.__MF_GLOBAL_STORE__;
8
8
  const currentModuleName = getCurrentModuleName();
9
9
  if (!currentModuleName) {
10
10
  return undefined;
11
11
  }
12
- const microMods = store.microMods.get(currentModuleName);
12
+ const microMods = (_store_microMods = store.microMods) === null || _store_microMods === void 0 ? void 0 : _store_microMods.get(currentModuleName);
13
13
  return (_microMods = microMods) === null || _microMods === void 0 ? void 0 : _microMods.find((microMod)=>microMod.appName === scope);
14
14
  }
15
15
  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
+ var _store_microMods;
33
+ const currentModuleName = getCurrentModuleName();
34
+ if (!currentModuleName) {
35
+ return [];
36
+ }
37
+ return ((_store_microMods = store.microMods) === null || _store_microMods === void 0 ? void 0 : _store_microMods.get(currentModuleName)) || [];
38
+ };
39
+ }
28
40
  // 获取或创建 hostInfo
29
41
  const existingHostInfo = store.hostRemotes.get(options.name);
30
42
  const hostInfo = existingHostInfo || {
@@ -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: Map<string, MicroMod[]>;
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;
@@ -4,13 +4,13 @@ export function getCurrentModuleName() {
4
4
  return (_window___MF_GLOBAL_STORE__ = window.__MF_GLOBAL_STORE__) === null || _window___MF_GLOBAL_STORE__ === void 0 ? void 0 : _window___MF_GLOBAL_STORE__.currentModuleName;
5
5
  }
6
6
  export function getMicroMod(scope) {
7
- var _microMods;
7
+ var _store_microMods, _microMods;
8
8
  var store = window.__MF_GLOBAL_STORE__;
9
9
  var currentModuleName = getCurrentModuleName();
10
10
  if (!currentModuleName) {
11
11
  return undefined;
12
12
  }
13
- var microMods = store.microMods.get(currentModuleName);
13
+ var microMods = (_store_microMods = store.microMods) === null || _store_microMods === void 0 ? void 0 : _store_microMods.get(currentModuleName);
14
14
  return (_microMods = microMods) === null || _microMods === void 0 ? void 0 : _microMods.find(function(microMod) {
15
15
  return microMod.appName === scope;
16
16
  });
@@ -19,15 +19,27 @@ 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 _store_microMods;
36
+ var currentModuleName = getCurrentModuleName();
37
+ if (!currentModuleName) {
38
+ return [];
39
+ }
40
+ return ((_store_microMods = store.microMods) === null || _store_microMods === void 0 ? void 0 : _store_microMods.get(currentModuleName)) || [];
41
+ };
42
+ }
31
43
  // 获取或创建 hostInfo
32
44
  var existingHostInfo = store.hostRemotes.get(options.name);
33
45
  var hostInfo = existingHostInfo || {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ice/mf-runtime",
3
- "version": "0.0.8-beta.2",
3
+ "version": "0.0.8-beta.4",
4
4
  "description": "ice mf runtime",
5
5
  "files": [
6
6
  "esm",