@ice/mf-runtime 0.0.8-beta.1 → 0.0.8-beta.2
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/es2017/RemoteModule.js +6 -1
- package/es2017/index.d.ts +2 -2
- package/es2017/index.js +2 -2
- package/es2017/mf-global-store.d.ts +6 -2
- package/es2017/mf-global-store.js +21 -2
- package/es2017/types.d.ts +8 -0
- package/esm/RemoteModule.js +6 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +2 -2
- package/esm/mf-global-store.d.ts +6 -2
- package/esm/mf-global-store.js +23 -2
- package/esm/types.d.ts +8 -0
- package/package.json +2 -2
package/es2017/RemoteModule.js
CHANGED
|
@@ -7,8 +7,13 @@ import { useMemo } from 'react';
|
|
|
7
7
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
8
8
|
import { FallBack } from './FallBack';
|
|
9
9
|
import { setFederatedModulePublicPath } from './set-public-path';
|
|
10
|
+
import { getMicroMod } from './mf-global-store';
|
|
10
11
|
export const RemoteModule = ({ module, scope, runtime, publicPath, LoadingComponent, ErrorComponent, onError, componentProps = {}, children = null })=>{
|
|
11
|
-
var _runtime, _runtime1;
|
|
12
|
+
var _microMod, _runtime, _runtime1;
|
|
13
|
+
const microMod = getMicroMod(scope);
|
|
14
|
+
if ((_microMod = microMod) === null || _microMod === void 0 ? void 0 : _microMod.publicPath) {
|
|
15
|
+
setFederatedModulePublicPath(microMod.moduleFederatedName, microMod.publicPath);
|
|
16
|
+
}
|
|
12
17
|
if (publicPath) {
|
|
13
18
|
setFederatedModulePublicPath(scope, publicPath);
|
|
14
19
|
}
|
package/es2017/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ExtendedUserOptions } from './types';
|
|
1
|
+
import type { ExtendedUserOptions, MicroMod } from './types';
|
|
2
2
|
export { loadRemote, registerPlugins } from '@module-federation/runtime';
|
|
3
3
|
export * from './FallBack';
|
|
4
4
|
export * from './RemoteModule';
|
|
5
|
-
export declare function init(options: ExtendedUserOptions): void;
|
|
5
|
+
export declare function init(options: ExtendedUserOptions, microMods?: MicroMod[]): void;
|
package/es2017/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import { initGlobalStore } from './mf-global-store';
|
|
|
4
4
|
export { loadRemote, registerPlugins } from '@module-federation/runtime';
|
|
5
5
|
export * from './FallBack';
|
|
6
6
|
export * from './RemoteModule';
|
|
7
|
-
export function init(options) {
|
|
8
|
-
initGlobalStore(options);
|
|
7
|
+
export function init(options, microMods) {
|
|
8
|
+
initGlobalStore(options, microMods);
|
|
9
9
|
mfInit(options);
|
|
10
10
|
registerPlugins([
|
|
11
11
|
runtimePlugin()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtraInfo, ExtendedUserOptions } from './types';
|
|
1
|
+
import type { ExtraInfo, ExtendedUserOptions, MicroMod } from './types';
|
|
2
2
|
export interface RemoteModuleInfo {
|
|
3
3
|
key: string;
|
|
4
4
|
name: string;
|
|
@@ -17,10 +17,14 @@ declare global {
|
|
|
17
17
|
__MF_GLOBAL_STORE__: {
|
|
18
18
|
remotes: Map<string, RemoteModuleInfo>;
|
|
19
19
|
hostRemotes: Map<string, HostRemoteInfo>;
|
|
20
|
+
microMods: Map<string, MicroMod[]>;
|
|
21
|
+
currentModuleName?: string;
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
export declare function
|
|
25
|
+
export declare function getCurrentModuleName(): string;
|
|
26
|
+
export declare function getMicroMod(scope: string): MicroMod;
|
|
27
|
+
export declare function initGlobalStore(options: ExtendedUserOptions, microMods?: MicroMod[]): void;
|
|
24
28
|
export declare function generateRemoteKey(name: string, entry: string): string;
|
|
25
29
|
export declare function getRemoteInfoFromStore(hostName: string, remoteName: string): RemoteModuleInfo | undefined;
|
|
26
30
|
export declare function hasConflict(hostName: string, remoteName: string): boolean;
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function getCurrentModuleName() {
|
|
2
|
+
var _window___MF_GLOBAL_STORE__;
|
|
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
|
+
}
|
|
5
|
+
export function getMicroMod(scope) {
|
|
6
|
+
var _microMods;
|
|
7
|
+
const store = window.__MF_GLOBAL_STORE__;
|
|
8
|
+
const currentModuleName = getCurrentModuleName();
|
|
9
|
+
if (!currentModuleName) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const microMods = store.microMods.get(currentModuleName);
|
|
13
|
+
return (_microMods = microMods) === null || _microMods === void 0 ? void 0 : _microMods.find((microMod)=>microMod.appName === scope);
|
|
14
|
+
}
|
|
15
|
+
export function initGlobalStore(options, microMods) {
|
|
2
16
|
if (!window.__MF_GLOBAL_STORE__) {
|
|
3
17
|
window.__MF_GLOBAL_STORE__ = {
|
|
4
18
|
remotes: new Map(),
|
|
5
|
-
hostRemotes: new Map()
|
|
19
|
+
hostRemotes: new Map(),
|
|
20
|
+
microMods: new Map(),
|
|
21
|
+
currentModuleName: options.name
|
|
6
22
|
};
|
|
7
23
|
}
|
|
24
|
+
if (microMods) {
|
|
25
|
+
window.__MF_GLOBAL_STORE__.microMods.set(options.name, microMods);
|
|
26
|
+
}
|
|
8
27
|
const store = window.__MF_GLOBAL_STORE__;
|
|
9
28
|
// 获取或创建 hostInfo
|
|
10
29
|
const existingHostInfo = store.hostRemotes.get(options.name);
|
package/es2017/types.d.ts
CHANGED
|
@@ -10,3 +10,11 @@ export type ExtendedRemote = Remote & {
|
|
|
10
10
|
export interface ExtendedUserOptions extends Omit<UserOptions, 'remotes'> {
|
|
11
11
|
remotes: ExtendedRemote[];
|
|
12
12
|
}
|
|
13
|
+
export interface MicroMod {
|
|
14
|
+
appName: string;
|
|
15
|
+
version: string;
|
|
16
|
+
publicPath: string;
|
|
17
|
+
remoteEntry: string;
|
|
18
|
+
moduleFederatedName: string;
|
|
19
|
+
extraInfo?: ExtraInfo;
|
|
20
|
+
}
|
package/esm/RemoteModule.js
CHANGED
|
@@ -9,9 +9,14 @@ import { useMemo } from "react";
|
|
|
9
9
|
import { ErrorBoundary } from "react-error-boundary";
|
|
10
10
|
import { FallBack } from "./FallBack";
|
|
11
11
|
import { setFederatedModulePublicPath } from "./set-public-path";
|
|
12
|
+
import { getMicroMod } from "./mf-global-store";
|
|
12
13
|
export var RemoteModule = function(param) {
|
|
13
14
|
var module = param.module, scope = param.scope, runtime = param.runtime, publicPath = param.publicPath, LoadingComponent = param.LoadingComponent, ErrorComponent = param.ErrorComponent, onError = param.onError, _param_componentProps = param.componentProps, componentProps = _param_componentProps === void 0 ? {} : _param_componentProps, _param_children = param.children, children = _param_children === void 0 ? null : _param_children;
|
|
14
|
-
var _runtime, _runtime1;
|
|
15
|
+
var _microMod, _runtime, _runtime1;
|
|
16
|
+
var microMod = getMicroMod(scope);
|
|
17
|
+
if ((_microMod = microMod) === null || _microMod === void 0 ? void 0 : _microMod.publicPath) {
|
|
18
|
+
setFederatedModulePublicPath(microMod.moduleFederatedName, microMod.publicPath);
|
|
19
|
+
}
|
|
15
20
|
if (publicPath) {
|
|
16
21
|
setFederatedModulePublicPath(scope, publicPath);
|
|
17
22
|
}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ExtendedUserOptions } from './types';
|
|
1
|
+
import type { ExtendedUserOptions, MicroMod } from './types';
|
|
2
2
|
export { loadRemote, registerPlugins } from '@module-federation/runtime';
|
|
3
3
|
export * from './FallBack';
|
|
4
4
|
export * from './RemoteModule';
|
|
5
|
-
export declare function init(options: ExtendedUserOptions): void;
|
|
5
|
+
export declare function init(options: ExtendedUserOptions, microMods?: MicroMod[]): void;
|
package/esm/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import { initGlobalStore } from "./mf-global-store";
|
|
|
4
4
|
export { loadRemote, registerPlugins } from "@module-federation/runtime";
|
|
5
5
|
export * from "./FallBack";
|
|
6
6
|
export * from "./RemoteModule";
|
|
7
|
-
export function init(options) {
|
|
8
|
-
initGlobalStore(options);
|
|
7
|
+
export function init(options, microMods) {
|
|
8
|
+
initGlobalStore(options, microMods);
|
|
9
9
|
mfInit(options);
|
|
10
10
|
registerPlugins([
|
|
11
11
|
runtimePlugin()
|
package/esm/mf-global-store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtraInfo, ExtendedUserOptions } from './types';
|
|
1
|
+
import type { ExtraInfo, ExtendedUserOptions, MicroMod } from './types';
|
|
2
2
|
export interface RemoteModuleInfo {
|
|
3
3
|
key: string;
|
|
4
4
|
name: string;
|
|
@@ -17,10 +17,14 @@ declare global {
|
|
|
17
17
|
__MF_GLOBAL_STORE__: {
|
|
18
18
|
remotes: Map<string, RemoteModuleInfo>;
|
|
19
19
|
hostRemotes: Map<string, HostRemoteInfo>;
|
|
20
|
+
microMods: Map<string, MicroMod[]>;
|
|
21
|
+
currentModuleName?: string;
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
export declare function
|
|
25
|
+
export declare function getCurrentModuleName(): string;
|
|
26
|
+
export declare function getMicroMod(scope: string): MicroMod;
|
|
27
|
+
export declare function initGlobalStore(options: ExtendedUserOptions, microMods?: MicroMod[]): void;
|
|
24
28
|
export declare function generateRemoteKey(name: string, entry: string): string;
|
|
25
29
|
export declare function getRemoteInfoFromStore(hostName: string, remoteName: string): RemoteModuleInfo | undefined;
|
|
26
30
|
export declare function hasConflict(hostName: string, remoteName: string): boolean;
|
package/esm/mf-global-store.js
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
2
|
-
export function
|
|
2
|
+
export function getCurrentModuleName() {
|
|
3
|
+
var _window___MF_GLOBAL_STORE__;
|
|
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
|
+
}
|
|
6
|
+
export function getMicroMod(scope) {
|
|
7
|
+
var _microMods;
|
|
8
|
+
var store = window.__MF_GLOBAL_STORE__;
|
|
9
|
+
var currentModuleName = getCurrentModuleName();
|
|
10
|
+
if (!currentModuleName) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
var microMods = store.microMods.get(currentModuleName);
|
|
14
|
+
return (_microMods = microMods) === null || _microMods === void 0 ? void 0 : _microMods.find(function(microMod) {
|
|
15
|
+
return microMod.appName === scope;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function initGlobalStore(options, microMods) {
|
|
3
19
|
if (!window.__MF_GLOBAL_STORE__) {
|
|
4
20
|
window.__MF_GLOBAL_STORE__ = {
|
|
5
21
|
remotes: new Map(),
|
|
6
|
-
hostRemotes: new Map()
|
|
22
|
+
hostRemotes: new Map(),
|
|
23
|
+
microMods: new Map(),
|
|
24
|
+
currentModuleName: options.name
|
|
7
25
|
};
|
|
8
26
|
}
|
|
27
|
+
if (microMods) {
|
|
28
|
+
window.__MF_GLOBAL_STORE__.microMods.set(options.name, microMods);
|
|
29
|
+
}
|
|
9
30
|
var store = window.__MF_GLOBAL_STORE__;
|
|
10
31
|
// 获取或创建 hostInfo
|
|
11
32
|
var existingHostInfo = store.hostRemotes.get(options.name);
|
package/esm/types.d.ts
CHANGED
|
@@ -10,3 +10,11 @@ export type ExtendedRemote = Remote & {
|
|
|
10
10
|
export interface ExtendedUserOptions extends Omit<UserOptions, 'remotes'> {
|
|
11
11
|
remotes: ExtendedRemote[];
|
|
12
12
|
}
|
|
13
|
+
export interface MicroMod {
|
|
14
|
+
appName: string;
|
|
15
|
+
version: string;
|
|
16
|
+
publicPath: string;
|
|
17
|
+
remoteEntry: string;
|
|
18
|
+
moduleFederatedName: string;
|
|
19
|
+
extraInfo?: ExtraInfo;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ice/mf-runtime",
|
|
3
|
-
"version": "0.0.8-beta.
|
|
3
|
+
"version": "0.0.8-beta.2",
|
|
4
4
|
"description": "ice mf runtime",
|
|
5
5
|
"files": [
|
|
6
6
|
"esm",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"default": "./esm/index.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"
|
|
25
|
+
"./types": "./esm/types.js"
|
|
26
26
|
},
|
|
27
27
|
"sideEffects": [
|
|
28
28
|
"dist/*",
|