@ice/mf-runtime 1.0.3-beta.2 → 1.0.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.
- package/README.md +1 -221
- package/es2017/RemoteModule.js +21 -73
- package/es2017/index.d.ts +0 -2
- package/es2017/index.js +3 -5
- package/es2017/runtime-plugin.js +27 -29
- package/es2017/types.d.ts +0 -67
- package/es2017/types.js +1 -18
- package/esm/RemoteModule.js +30 -73
- package/esm/index.d.ts +0 -2
- package/esm/index.js +3 -5
- package/esm/runtime-plugin.js +37 -33
- package/esm/types.d.ts +0 -67
- package/esm/types.js +1 -20
- package/package.json +3 -14
- package/docs/PLUGIN_SYSTEM_GUIDE.md +0 -294
- package/es2017/__tests__/plugin-manager.test.d.ts +0 -1
- package/es2017/__tests__/plugin-manager.test.js +0 -291
- package/es2017/__tests__/setup.d.ts +0 -1
- package/es2017/__tests__/setup.js +0 -28
- package/es2017/plugin-manager.d.ts +0 -74
- package/es2017/plugin-manager.js +0 -128
- package/esm/__tests__/plugin-manager.test.d.ts +0 -1
- package/esm/__tests__/plugin-manager.test.js +0 -343
- package/esm/__tests__/setup.d.ts +0 -1
- package/esm/__tests__/setup.js +0 -43
- package/esm/plugin-manager.d.ts +0 -74
- package/esm/plugin-manager.js +0 -201
package/esm/RemoteModule.js
CHANGED
|
@@ -6,13 +6,10 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
6
6
|
import { loadRemote } from "@module-federation/runtime";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import { useMemo, useState, useLayoutEffect, forwardRef } from "react";
|
|
9
|
-
import * as ReactDOM from "react-dom";
|
|
10
9
|
import { ErrorBoundary } from "react-error-boundary";
|
|
11
10
|
import { FallBack } from "./FallBack";
|
|
12
11
|
import { setFederatedModulePublicPath } from "./set-public-path";
|
|
13
12
|
import { getMicroMod } from "./mf-global-store";
|
|
14
|
-
import { useEnhancedPluginManager } from "./plugin-manager";
|
|
15
|
-
import { isRuntimePluginWrapper } from "./types";
|
|
16
13
|
var useMountNode = function(mountNodeConfig) {
|
|
17
14
|
var _useState = _sliced_to_array(useState(undefined), 2), resolvedNode = _useState[0], setResolvedNode = _useState[1];
|
|
18
15
|
// 解析各种类型的 mountNode
|
|
@@ -43,7 +40,6 @@ var RemoteModuleInner = function(param, ref) {
|
|
|
43
40
|
var _microMod, _runtime, _runtime1;
|
|
44
41
|
var microMod = getMicroMod(scope);
|
|
45
42
|
var resolvedMountNode = useMountNode(mountNode);
|
|
46
|
-
var enhancedPluginManager = useEnhancedPluginManager();
|
|
47
43
|
if ((_microMod = microMod) === null || _microMod === void 0 ? void 0 : _microMod.publicPath) {
|
|
48
44
|
setFederatedModulePublicPath(microMod.moduleFederatedName, microMod.publicPath);
|
|
49
45
|
}
|
|
@@ -53,7 +49,7 @@ var RemoteModuleInner = function(param, ref) {
|
|
|
53
49
|
var Component = useMemo(function() {
|
|
54
50
|
if (!module || !scope) return null;
|
|
55
51
|
return /*#__PURE__*/ React.lazy(/*#__PURE__*/ _async_to_generator(function() {
|
|
56
|
-
var _typedRemoteModule, remoteModule,
|
|
52
|
+
var _typedRemoteModule, remoteModule, ComponentFromPlugin, typedRemoteModule, react, reactDOM;
|
|
57
53
|
return _ts_generator(this, function(_state) {
|
|
58
54
|
switch(_state.label){
|
|
59
55
|
case 0:
|
|
@@ -63,80 +59,48 @@ var RemoteModuleInner = function(param, ref) {
|
|
|
63
59
|
];
|
|
64
60
|
case 1:
|
|
65
61
|
remoteModule = _state.sent();
|
|
66
|
-
//
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
remoteReact = reactInstances.react;
|
|
70
|
-
remoteReactDOM = reactInstances.reactDOM;
|
|
71
|
-
PluginWrappedComponent = enhancedPluginManager.wrapComponent(originalComponent, {
|
|
72
|
-
remoteName: scope,
|
|
73
|
-
moduleName: module,
|
|
74
|
-
props: componentProps || {},
|
|
75
|
-
React: remoteReact,
|
|
76
|
-
ReactDOM: remoteReactDOM
|
|
77
|
-
});
|
|
78
|
-
FinalComponent = FallBack({
|
|
79
|
-
Original: PluginWrappedComponent,
|
|
80
|
-
remoteVersion: runtimeInfo.remoteVersion ? function() {
|
|
81
|
-
return runtimeInfo.remoteVersion;
|
|
82
|
-
} : undefined,
|
|
83
|
-
hostVersion: runtimeInfo.hostVersion ? function() {
|
|
84
|
-
return runtimeInfo.hostVersion;
|
|
85
|
-
} : undefined,
|
|
86
|
-
remoteReactDOM: runtimeInfo.remoteReactDOM,
|
|
87
|
-
remoteReact: runtimeInfo.remoteReact,
|
|
88
|
-
mountNode: resolvedMountNode,
|
|
89
|
-
containerClassName: fallbackContainerClassName
|
|
90
|
-
});
|
|
62
|
+
// 检查是否是来自 runtime plugin 的包装函数(通过标记识别)
|
|
63
|
+
if (typeof remoteModule === "function" && remoteModule.__ICE_MF_RUNTIME_WRAPPER__) {
|
|
64
|
+
ComponentFromPlugin = remoteModule(resolvedMountNode, fallbackContainerClassName);
|
|
91
65
|
return [
|
|
92
66
|
2,
|
|
93
67
|
{
|
|
94
|
-
default:
|
|
68
|
+
default: ComponentFromPlugin
|
|
95
69
|
}
|
|
96
70
|
];
|
|
97
71
|
}
|
|
98
72
|
typedRemoteModule = remoteModule;
|
|
99
73
|
if (!((_typedRemoteModule = typedRemoteModule) === null || _typedRemoteModule === void 0 ? void 0 : _typedRemoteModule.default)) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
74
|
+
return [
|
|
75
|
+
2,
|
|
76
|
+
{
|
|
77
|
+
default: remoteModule
|
|
78
|
+
}
|
|
79
|
+
];
|
|
103
80
|
}
|
|
104
|
-
// 如果需要 runtime 处理(不同 React 版本或 mountNode)
|
|
105
81
|
if (runtime) {
|
|
106
82
|
react = runtime.react, reactDOM = runtime.reactDOM;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
containerClassName: fallbackContainerClassName
|
|
124
|
-
});
|
|
125
|
-
} else {
|
|
126
|
-
// 没有 runtime 需求时,直接应用插件包装器
|
|
127
|
-
FinalComponent1 = enhancedPluginManager.wrapComponent(BaseComponent, {
|
|
128
|
-
remoteName: scope,
|
|
129
|
-
moduleName: module,
|
|
130
|
-
props: componentProps || {},
|
|
131
|
-
React: React,
|
|
132
|
-
ReactDOM: ReactDOM
|
|
133
|
-
});
|
|
83
|
+
return [
|
|
84
|
+
2,
|
|
85
|
+
{
|
|
86
|
+
default: FallBack({
|
|
87
|
+
Original: typedRemoteModule.default,
|
|
88
|
+
remoteReact: function() {
|
|
89
|
+
return react;
|
|
90
|
+
},
|
|
91
|
+
remoteReactDOM: function() {
|
|
92
|
+
return reactDOM;
|
|
93
|
+
},
|
|
94
|
+
mountNode: resolvedMountNode,
|
|
95
|
+
containerClassName: fallbackContainerClassName
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
];
|
|
134
99
|
}
|
|
135
|
-
console.log("FinalComponent", FinalComponent1);
|
|
136
100
|
return [
|
|
137
101
|
2,
|
|
138
102
|
{
|
|
139
|
-
default:
|
|
103
|
+
default: typedRemoteModule.default
|
|
140
104
|
}
|
|
141
105
|
];
|
|
142
106
|
}
|
|
@@ -148,9 +112,7 @@ var RemoteModuleInner = function(param, ref) {
|
|
|
148
112
|
(_runtime = runtime) === null || _runtime === void 0 ? void 0 : _runtime.react,
|
|
149
113
|
(_runtime1 = runtime) === null || _runtime1 === void 0 ? void 0 : _runtime1.reactDOM,
|
|
150
114
|
resolvedMountNode,
|
|
151
|
-
fallbackContainerClassName
|
|
152
|
-
enhancedPluginManager,
|
|
153
|
-
componentProps
|
|
115
|
+
fallbackContainerClassName
|
|
154
116
|
]);
|
|
155
117
|
var Loading = LoadingComponent || /*#__PURE__*/ React.createElement("div", null, "Loading...");
|
|
156
118
|
var ErrorFallback = function(param) {
|
|
@@ -158,11 +120,6 @@ var RemoteModuleInner = function(param, ref) {
|
|
|
158
120
|
return ErrorComponent || /*#__PURE__*/ React.createElement("div", null, "远程模块加载失败: ", error.message);
|
|
159
121
|
};
|
|
160
122
|
if (!Component) return Loading;
|
|
161
|
-
// 应用增强插件的属性注入
|
|
162
|
-
var injectedProps = enhancedPluginManager.injectProps(componentProps || {}, {
|
|
163
|
-
remoteName: scope,
|
|
164
|
-
moduleName: module
|
|
165
|
-
});
|
|
166
123
|
return /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
167
124
|
resetKeys: [
|
|
168
125
|
module,
|
|
@@ -175,7 +132,7 @@ var RemoteModuleInner = function(param, ref) {
|
|
|
175
132
|
fallback: Loading
|
|
176
133
|
}, /*#__PURE__*/ React.createElement(Component, _object_spread({
|
|
177
134
|
ref: ref
|
|
178
|
-
},
|
|
135
|
+
}, componentProps), children)));
|
|
179
136
|
};
|
|
180
137
|
// 使用 forwardRef 包装组件以支持 ref
|
|
181
138
|
export var RemoteModule = /*#__PURE__*/ forwardRef(RemoteModuleInner);
|
package/esm/index.d.ts
CHANGED
|
@@ -2,7 +2,5 @@ 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 * from './types';
|
|
6
|
-
export * from './plugin-manager';
|
|
7
5
|
export declare function init(options: ExtendedUserOptions, microMods?: MicroMod[]): void;
|
|
8
6
|
export declare function initByMicroMods(microMods: MicroMod[], hostName?: string): void;
|
package/esm/index.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { getBasename } from "@ice/stark-app";
|
|
2
|
-
import { registerPlugins
|
|
2
|
+
import { registerPlugins, init as mfInit } from "@module-federation/runtime";
|
|
3
3
|
import { runtimePlugin } from "./runtime-plugin";
|
|
4
4
|
import { initGlobalStore } from "./mf-global-store";
|
|
5
5
|
export { loadRemote, registerPlugins } from "@module-federation/runtime";
|
|
6
6
|
export * from "./FallBack";
|
|
7
7
|
export * from "./RemoteModule";
|
|
8
|
-
export * from "./types";
|
|
9
|
-
export * from "./plugin-manager";
|
|
10
8
|
export function init(options, microMods) {
|
|
11
9
|
initGlobalStore(options, microMods);
|
|
12
10
|
mfInit(options);
|
|
13
|
-
|
|
11
|
+
registerPlugins([
|
|
14
12
|
runtimePlugin()
|
|
15
13
|
]);
|
|
16
14
|
}
|
|
@@ -36,6 +34,6 @@ export function initByMicroMods(microMods, hostName) {
|
|
|
36
34
|
});
|
|
37
35
|
init({
|
|
38
36
|
remotes: remotes,
|
|
39
|
-
name: generateUniqueId()
|
|
37
|
+
name: hostName || generateUniqueId()
|
|
40
38
|
}, microMods);
|
|
41
39
|
}
|
package/esm/runtime-plugin.js
CHANGED
|
@@ -2,10 +2,10 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { getExtraInfo, getRemoteInfoFromStore, hasConflict } from "./mf-global-store";
|
|
5
|
-
import {
|
|
5
|
+
import { FallBack } from "./FallBack";
|
|
6
6
|
var loadRemotePackagedReactAndRender = function() {
|
|
7
7
|
var _ref = _async_to_generator(function(args) {
|
|
8
|
-
var _args_origin_options_shared_reactdom_, _args_origin_options_shared_reactdom, _args_origin_options_shared, _args_origin_options, _remoteInstance_options_shared_reactdom_, _remoteInstance_options_shared_reactdom, _remoteInstance_options_shared, _remoteInstance_options, hostVersion, remoteInstance, remoteVersion, _sharedOptions_find, remoteReactDOM, _sharedOptions_find1, remoteReact;
|
|
8
|
+
var _args_origin_options_shared_reactdom_, _args_origin_options_shared_reactdom, _args_origin_options_shared, _args_origin_options, _remoteInstance_options_shared_reactdom_, _remoteInstance_options_shared_reactdom, _remoteInstance_options_shared, _remoteInstance_options, hostVersion, remoteInstance, remoteVersion, _sharedOptions_find, remoteReactDOM, _sharedOptions_find1, remoteReact, wrappedRender;
|
|
9
9
|
return _ts_generator(this, function(_state) {
|
|
10
10
|
switch(_state.label){
|
|
11
11
|
case 0:
|
|
@@ -23,8 +23,8 @@ var loadRemotePackagedReactAndRender = function() {
|
|
|
23
23
|
4,
|
|
24
24
|
remoteInstance.loadShare("react-dom", {
|
|
25
25
|
resolver: function(sharedOptions) {
|
|
26
|
-
return (_sharedOptions_find = sharedOptions.find(function(
|
|
27
|
-
return
|
|
26
|
+
return (_sharedOptions_find = sharedOptions.find(function(i) {
|
|
27
|
+
return i.version === remoteVersion;
|
|
28
28
|
})) !== null && _sharedOptions_find !== void 0 ? _sharedOptions_find : sharedOptions[0];
|
|
29
29
|
}
|
|
30
30
|
})
|
|
@@ -35,8 +35,8 @@ var loadRemotePackagedReactAndRender = function() {
|
|
|
35
35
|
4,
|
|
36
36
|
remoteInstance.loadShare("react", {
|
|
37
37
|
resolver: function(sharedOptions) {
|
|
38
|
-
return (_sharedOptions_find1 = sharedOptions.find(function(
|
|
39
|
-
return
|
|
38
|
+
return (_sharedOptions_find1 = sharedOptions.find(function(i) {
|
|
39
|
+
return i.version === remoteVersion;
|
|
40
40
|
})) !== null && _sharedOptions_find1 !== void 0 ? _sharedOptions_find1 : sharedOptions[0];
|
|
41
41
|
}
|
|
42
42
|
})
|
|
@@ -49,22 +49,26 @@ var loadRemotePackagedReactAndRender = function() {
|
|
|
49
49
|
null
|
|
50
50
|
];
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
wrappedRender = function(mountNode, containerClassName) {
|
|
53
|
+
return FallBack({
|
|
54
|
+
Original: args.exposeModule.default,
|
|
55
|
+
remoteVersion: function() {
|
|
56
|
+
return remoteVersion;
|
|
57
|
+
},
|
|
58
|
+
hostVersion: function() {
|
|
59
|
+
return hostVersion;
|
|
60
|
+
},
|
|
61
|
+
remoteReactDOM: remoteReactDOM,
|
|
62
|
+
remoteReact: remoteReact,
|
|
63
|
+
mountNode: mountNode,
|
|
64
|
+
containerClassName: containerClassName
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
// 添加标记,用于在 RemoteModule 中识别
|
|
68
|
+
wrappedRender.__ICE_MF_RUNTIME_WRAPPER__ = true;
|
|
54
69
|
return [
|
|
55
70
|
2,
|
|
56
|
-
|
|
57
|
-
args.exposeModule.default, // 运行时信息
|
|
58
|
-
{
|
|
59
|
-
remoteVersion: remoteVersion,
|
|
60
|
-
hostVersion: hostVersion,
|
|
61
|
-
remoteReact: remoteReact,
|
|
62
|
-
remoteReactDOM: remoteReactDOM
|
|
63
|
-
}, // React 实例信息
|
|
64
|
-
{
|
|
65
|
-
react: remoteReact(),
|
|
66
|
-
reactDOM: remoteReactDOM()
|
|
67
|
-
})
|
|
71
|
+
wrappedRender
|
|
68
72
|
];
|
|
69
73
|
case 3:
|
|
70
74
|
return [
|
|
@@ -95,7 +99,7 @@ export var runtimePlugin = function() {
|
|
|
95
99
|
},
|
|
96
100
|
onLoad: function onLoad(args) {
|
|
97
101
|
return _async_to_generator(function() {
|
|
98
|
-
var _args_origin_options_shared_reactdom_, _args_origin_options_shared_reactdom, _args_origin_options_shared, _args_origin_options, _extraInfo, hostName, remoteName, hostVersion, extraInfo, externalReact, externalReactDOM, remoteReact, remoteReactDOM, fallBackRender;
|
|
102
|
+
var _args_origin_options_shared_reactdom_, _args_origin_options_shared_reactdom, _args_origin_options_shared, _args_origin_options, _extraInfo, hostName, remoteName, hostVersion, extraInfo, externalReact, externalReactDOM, remoteReact, remoteReactDOM, wrappedRender, fallBackRender;
|
|
99
103
|
return _ts_generator(this, function(_state) {
|
|
100
104
|
switch(_state.label){
|
|
101
105
|
case 0:
|
|
@@ -120,20 +124,20 @@ export var runtimePlugin = function() {
|
|
|
120
124
|
args
|
|
121
125
|
];
|
|
122
126
|
}
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
wrappedRender = function(mountNode, containerClassName) {
|
|
128
|
+
return FallBack({
|
|
129
|
+
Original: args.exposeModule.default,
|
|
130
|
+
remoteReactDOM: remoteReactDOM,
|
|
131
|
+
remoteReact: remoteReact,
|
|
132
|
+
mountNode: mountNode,
|
|
133
|
+
containerClassName: containerClassName
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
// 添加标记,用于在 RemoteModule 中识别
|
|
137
|
+
wrappedRender.__ICE_MF_RUNTIME_WRAPPER__ = true;
|
|
125
138
|
return [
|
|
126
139
|
2,
|
|
127
|
-
|
|
128
|
-
args.exposeModule.default, // 运行时信息
|
|
129
|
-
{
|
|
130
|
-
remoteReact: remoteReact,
|
|
131
|
-
remoteReactDOM: remoteReactDOM
|
|
132
|
-
}, // React 实例信息
|
|
133
|
-
{
|
|
134
|
-
react: remoteReact(),
|
|
135
|
-
reactDOM: remoteReactDOM()
|
|
136
|
-
})
|
|
140
|
+
wrappedRender
|
|
137
141
|
];
|
|
138
142
|
}
|
|
139
143
|
}
|
package/esm/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { UserOptions } from '@module-federation/runtime-core';
|
|
2
2
|
import type { Remote } from '@module-federation/runtime-core/dist/src/types';
|
|
3
|
-
import * as React from 'react';
|
|
4
3
|
export interface ExtraInfo {
|
|
5
4
|
external?: Record<string, string>;
|
|
6
5
|
legacy?: boolean;
|
|
@@ -19,69 +18,3 @@ export interface MicroMod {
|
|
|
19
18
|
moduleFederatedName: string;
|
|
20
19
|
extraInfo?: ExtraInfo;
|
|
21
20
|
}
|
|
22
|
-
export interface FederationRuntimePlugin {
|
|
23
|
-
name: string;
|
|
24
|
-
afterResolve?: (args: any) => any;
|
|
25
|
-
onLoad?: (args: any) => any;
|
|
26
|
-
beforeRequest?: (args: any) => any;
|
|
27
|
-
}
|
|
28
|
-
export interface WrapperContext {
|
|
29
|
-
remoteName: string;
|
|
30
|
-
moduleName: string;
|
|
31
|
-
props: Record<string, any>;
|
|
32
|
-
React: typeof import('react');
|
|
33
|
-
ReactDOM?: typeof import('react-dom');
|
|
34
|
-
}
|
|
35
|
-
export interface InjectionContext {
|
|
36
|
-
remoteName: string;
|
|
37
|
-
moduleName: string;
|
|
38
|
-
}
|
|
39
|
-
export interface ComponentWrapper {
|
|
40
|
-
(WrappedComponent: React.ComponentType<any>, context: WrapperContext): React.ComponentType<any>;
|
|
41
|
-
}
|
|
42
|
-
export interface PropInjector {
|
|
43
|
-
(props: Record<string, any>, context: InjectionContext): Record<string, any>;
|
|
44
|
-
}
|
|
45
|
-
export interface EnhancedRuntimePlugin {
|
|
46
|
-
name: string;
|
|
47
|
-
wrapComponent?: ComponentWrapper;
|
|
48
|
-
injectProps?: PropInjector;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Runtime Plugin 包装器对象的接口
|
|
52
|
-
* 包含原始组件和运行时信息,让 RemoteModule 控制 HOC 层级顺序
|
|
53
|
-
*/
|
|
54
|
-
export interface RuntimePluginWrapper {
|
|
55
|
-
readonly type: 'runtime-plugin-wrapper';
|
|
56
|
-
readonly originalComponent: React.ComponentType<any>;
|
|
57
|
-
readonly runtimeInfo: {
|
|
58
|
-
readonly remoteVersion?: string;
|
|
59
|
-
readonly hostVersion?: string;
|
|
60
|
-
readonly remoteReact: () => typeof import('react');
|
|
61
|
-
readonly remoteReactDOM: () => typeof import('react-dom');
|
|
62
|
-
readonly mountNode?: HTMLElement;
|
|
63
|
-
readonly containerClassName?: string;
|
|
64
|
-
};
|
|
65
|
-
readonly reactInstances: {
|
|
66
|
-
readonly react: typeof import('react');
|
|
67
|
-
readonly reactDOM?: typeof import('react-dom');
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* 类型守卫:检查是否为 Runtime Plugin 包装器
|
|
72
|
-
*/
|
|
73
|
-
export declare function isRuntimePluginWrapper(value: any): value is () => RuntimePluginWrapper;
|
|
74
|
-
/**
|
|
75
|
-
* 创建 Runtime Plugin 包装器的工厂函数
|
|
76
|
-
*/
|
|
77
|
-
export declare function createRuntimePluginWrapper(originalComponent: React.ComponentType<any>, runtimeInfo: {
|
|
78
|
-
remoteVersion?: string;
|
|
79
|
-
hostVersion?: string;
|
|
80
|
-
remoteReact: () => typeof import('react');
|
|
81
|
-
remoteReactDOM: () => typeof import('react-dom');
|
|
82
|
-
mountNode?: HTMLElement;
|
|
83
|
-
containerClassName?: string;
|
|
84
|
-
}, reactInstances: {
|
|
85
|
-
react: typeof import('react');
|
|
86
|
-
reactDOM?: typeof import('react-dom');
|
|
87
|
-
}): () => RuntimePluginWrapper;
|
package/esm/types.js
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* 类型守卫:检查是否为 Runtime Plugin 包装器
|
|
4
|
-
*/ export function isRuntimePluginWrapper(value) {
|
|
5
|
-
return value && value.__mf_fallback_render;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* 创建 Runtime Plugin 包装器的工厂函数
|
|
9
|
-
*/ export function createRuntimePluginWrapper(originalComponent, runtimeInfo, reactInstances) {
|
|
10
|
-
var wrapper = function() {
|
|
11
|
-
return {
|
|
12
|
-
type: "runtime-plugin-wrapper",
|
|
13
|
-
originalComponent: originalComponent,
|
|
14
|
-
runtimeInfo: runtimeInfo,
|
|
15
|
-
reactInstances: reactInstances
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
wrapper.__mf_fallback_render = true;
|
|
19
|
-
return wrapper;
|
|
20
|
-
} // 不再需要联合类型,两种插件分开管理
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ice/mf-runtime",
|
|
3
|
-
"version": "1.0.3
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "ice mf runtime",
|
|
5
5
|
"files": [
|
|
6
6
|
"esm",
|
|
7
7
|
"es2017",
|
|
8
8
|
"cjs",
|
|
9
|
-
"dist"
|
|
10
|
-
"docs"
|
|
9
|
+
"dist"
|
|
11
10
|
],
|
|
12
11
|
"main": "esm/index.js",
|
|
13
12
|
"module": "esm/index.js",
|
|
@@ -35,9 +34,6 @@
|
|
|
35
34
|
"start": "ice-pkg start",
|
|
36
35
|
"build": "ice-pkg build",
|
|
37
36
|
"prepublishOnly": "npm run build",
|
|
38
|
-
"test": "vitest",
|
|
39
|
-
"test:run": "vitest run",
|
|
40
|
-
"test:coverage": "vitest run --coverage",
|
|
41
37
|
"eslint": "eslint --cache --ext .js,.jsx,.ts,.tsx ./",
|
|
42
38
|
"eslint:fix": "npm run eslint -- --fix",
|
|
43
39
|
"stylelint": "stylelint \"**/*.{css,scss,less}\"",
|
|
@@ -61,19 +57,12 @@
|
|
|
61
57
|
"@applint/spec": "^1.2.3",
|
|
62
58
|
"@ice/pkg": "^1.0.0",
|
|
63
59
|
"@ice/runtime": "^1.0.0",
|
|
64
|
-
"@ice/stark-app": "^1.5.0",
|
|
65
|
-
"@testing-library/jest-dom": "^6.0.0",
|
|
66
|
-
"@testing-library/react": "^14.0.0",
|
|
67
60
|
"@types/react": "^18.0.0",
|
|
68
61
|
"@types/react-dom": "^18.0.0",
|
|
69
|
-
"@vitest/coverage-v8": "^1.0.0",
|
|
70
62
|
"eslint": "^8.0.0",
|
|
71
|
-
"jsdom": "^23.0.0",
|
|
72
63
|
"react": "^18.0.0",
|
|
73
64
|
"react-dom": "^18.0.0",
|
|
74
|
-
"stylelint": "^15.0.0"
|
|
75
|
-
"typescript": "^5.0.0",
|
|
76
|
-
"vitest": "^1.0.0"
|
|
65
|
+
"stylelint": "^15.0.0"
|
|
77
66
|
},
|
|
78
67
|
"publishConfig": {
|
|
79
68
|
"access": "public",
|