@module-federation/runtime 0.6.6 → 0.6.8
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/dist/embedded.cjs.js +263 -3
- package/dist/embedded.esm.d.ts +1 -0
- package/dist/embedded.esm.js +263 -2
- package/dist/helpers.esm.d.ts +2 -0
- package/dist/helpers.esm.js +1 -1
- package/dist/index.cjs.js +37 -30
- package/dist/index.esm.d.ts +1 -0
- package/dist/index.esm.js +38 -29
- package/dist/package.json +2 -2
- package/dist/polyfills.esm.js +1 -1
- package/dist/share.cjs.js +22 -1
- package/dist/share.esm.js +24 -3
- package/dist/src/core.d.ts +1 -1
- package/dist/src/embedded.d.ts +112 -2
- package/dist/src/remote/index.d.ts +1 -1
- package/dist/types.esm.d.ts +1 -0
- package/package.json +2 -2
package/dist/embedded.cjs.js
CHANGED
|
@@ -1,10 +1,270 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
3
|
+
function getRuntime() {
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
const runtime = __webpack_require__.federation.runtime;
|
|
6
|
+
if (!runtime) {
|
|
7
|
+
throw new Error('Federation runtime accessed before instantiation or installation');
|
|
8
|
+
}
|
|
9
|
+
return runtime;
|
|
10
|
+
}
|
|
11
|
+
const registerGlobalPlugins = (...args)=>{
|
|
12
|
+
return getRuntime().registerGlobalPlugins(...args);
|
|
13
|
+
};
|
|
14
|
+
const getRemoteEntry = (...args)=>{
|
|
15
|
+
return getRuntime().getRemoteEntry(...args);
|
|
16
|
+
};
|
|
17
|
+
const getRemoteInfo = (...args)=>{
|
|
18
|
+
return getRuntime().getRemoteInfo(...args);
|
|
19
|
+
};
|
|
20
|
+
const loadScript = (...args)=>{
|
|
21
|
+
return getRuntime().loadScript(...args);
|
|
22
|
+
};
|
|
23
|
+
const loadScriptNode = (...args)=>{
|
|
24
|
+
return getRuntime().loadScriptNode(...args);
|
|
25
|
+
};
|
|
26
|
+
const init = (...args)=>{
|
|
27
|
+
return getRuntime().init(...args);
|
|
28
|
+
};
|
|
29
|
+
const loadRemote = (...args)=>{
|
|
30
|
+
return getRuntime().loadRemote(...args);
|
|
31
|
+
};
|
|
32
|
+
const loadShare = (...args)=>{
|
|
33
|
+
return getRuntime().loadShare(...args);
|
|
34
|
+
};
|
|
35
|
+
const loadShareSync = (...args)=>{
|
|
36
|
+
return getRuntime().loadShareSync(...args);
|
|
37
|
+
};
|
|
38
|
+
const preloadRemote = (...args)=>{
|
|
39
|
+
return getRuntime().preloadRemote(...args);
|
|
40
|
+
};
|
|
41
|
+
const registerRemotes = (...args)=>{
|
|
42
|
+
return getRuntime().registerRemotes(...args);
|
|
43
|
+
};
|
|
44
|
+
const registerPlugins = (...args)=>{
|
|
45
|
+
return getRuntime().registerPlugins(...args);
|
|
46
|
+
};
|
|
47
|
+
const getInstance = (...args)=>{
|
|
48
|
+
return getRuntime().getInstance(...args);
|
|
49
|
+
};
|
|
50
|
+
class FederationHost {
|
|
51
|
+
_getInstance() {
|
|
52
|
+
if (!this._instance) {
|
|
53
|
+
const RealFederationHost = getRuntime().FederationHost;
|
|
54
|
+
this._instance = new RealFederationHost(...this._args);
|
|
55
|
+
}
|
|
56
|
+
return this._instance;
|
|
57
|
+
}
|
|
58
|
+
get options() {
|
|
59
|
+
return this._getInstance().options;
|
|
60
|
+
}
|
|
61
|
+
set options(value) {
|
|
62
|
+
this._getInstance().options = value;
|
|
63
|
+
}
|
|
64
|
+
get hooks() {
|
|
65
|
+
return this._getInstance().hooks;
|
|
66
|
+
}
|
|
67
|
+
get version() {
|
|
68
|
+
return this._getInstance().version;
|
|
69
|
+
}
|
|
70
|
+
get name() {
|
|
71
|
+
return this._getInstance().name;
|
|
72
|
+
}
|
|
73
|
+
get moduleCache() {
|
|
74
|
+
return this._getInstance().moduleCache;
|
|
75
|
+
}
|
|
76
|
+
get snapshotHandler() {
|
|
77
|
+
return this._getInstance().snapshotHandler;
|
|
78
|
+
}
|
|
79
|
+
get sharedHandler() {
|
|
80
|
+
return this._getInstance().sharedHandler;
|
|
81
|
+
}
|
|
82
|
+
get remoteHandler() {
|
|
83
|
+
return this._getInstance().remoteHandler;
|
|
84
|
+
}
|
|
85
|
+
get shareScopeMap() {
|
|
86
|
+
return this._getInstance().shareScopeMap;
|
|
87
|
+
}
|
|
88
|
+
get loaderHook() {
|
|
89
|
+
return this._getInstance().loaderHook;
|
|
90
|
+
}
|
|
91
|
+
initOptions(...args) {
|
|
92
|
+
return this._getInstance().initOptions(...args);
|
|
93
|
+
}
|
|
94
|
+
loadShare(...args) {
|
|
95
|
+
return this._getInstance().loadShare(...args);
|
|
96
|
+
}
|
|
97
|
+
loadShareSync(...args) {
|
|
98
|
+
return this._getInstance().loadShareSync(...args);
|
|
99
|
+
}
|
|
100
|
+
initializeSharing(...args) {
|
|
101
|
+
return this._getInstance().initializeSharing(...args);
|
|
102
|
+
}
|
|
103
|
+
initRawContainer(...args) {
|
|
104
|
+
return this._getInstance().initRawContainer(...args);
|
|
105
|
+
}
|
|
106
|
+
loadRemote(...args) {
|
|
107
|
+
return this._getInstance().loadRemote(...args);
|
|
108
|
+
}
|
|
109
|
+
preloadRemote(...args) {
|
|
110
|
+
return this._getInstance().preloadRemote(...args);
|
|
111
|
+
}
|
|
112
|
+
initShareScopeMap(...args) {
|
|
113
|
+
return this._getInstance().initShareScopeMap(...args);
|
|
114
|
+
}
|
|
115
|
+
registerPlugins(...args) {
|
|
116
|
+
return this._getInstance().registerPlugins(...args);
|
|
117
|
+
}
|
|
118
|
+
registerRemotes(...args) {
|
|
119
|
+
return this._getInstance().registerRemotes(...args);
|
|
120
|
+
}
|
|
121
|
+
formatOptions(...args) {
|
|
122
|
+
//@ts-ignore
|
|
123
|
+
return this._getInstance().formatOptions(...args);
|
|
124
|
+
}
|
|
125
|
+
constructor(...args){
|
|
126
|
+
this._instance = null;
|
|
127
|
+
this._args = args;
|
|
128
|
+
const RealFederationHost = getRuntime().FederationHost;
|
|
129
|
+
this._instance = new RealFederationHost(...this._args);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
class Module {
|
|
133
|
+
_getInstance() {
|
|
134
|
+
if (!this._instance) {
|
|
135
|
+
const RealModule = getRuntime().Module;
|
|
136
|
+
this._instance = new RealModule(...this._args);
|
|
137
|
+
}
|
|
138
|
+
return this._instance;
|
|
139
|
+
}
|
|
140
|
+
get remoteInfo() {
|
|
141
|
+
return this._getInstance().remoteInfo;
|
|
142
|
+
}
|
|
143
|
+
set remoteInfo(value) {
|
|
144
|
+
this._getInstance().remoteInfo = value;
|
|
145
|
+
}
|
|
146
|
+
get inited() {
|
|
147
|
+
return this._getInstance().inited;
|
|
148
|
+
}
|
|
149
|
+
set inited(value) {
|
|
150
|
+
this._getInstance().inited = value;
|
|
151
|
+
}
|
|
152
|
+
get lib() {
|
|
153
|
+
return this._getInstance().lib;
|
|
154
|
+
}
|
|
155
|
+
set lib(value) {
|
|
156
|
+
this._getInstance().lib = value;
|
|
157
|
+
}
|
|
158
|
+
get host() {
|
|
159
|
+
return this._getInstance().host;
|
|
160
|
+
}
|
|
161
|
+
set host(value) {
|
|
162
|
+
this._getInstance().host = value;
|
|
163
|
+
}
|
|
164
|
+
async getEntry(...args) {
|
|
165
|
+
return this._getInstance().getEntry(...args);
|
|
166
|
+
}
|
|
167
|
+
async get(...args) {
|
|
168
|
+
return this._getInstance().get(...args);
|
|
169
|
+
}
|
|
170
|
+
wraperFactory(...args) {
|
|
171
|
+
//@ts-ignore
|
|
172
|
+
return this._getInstance().wraperFactory(...args);
|
|
173
|
+
}
|
|
174
|
+
constructor(...args){
|
|
175
|
+
this._instance = null;
|
|
176
|
+
this._args = args;
|
|
177
|
+
}
|
|
178
|
+
} //maybe use proxy?
|
|
179
|
+
//export class Module implements ModuleInterface {
|
|
180
|
+
// private _instance: IndexModule.Module | null = null;
|
|
181
|
+
// private _args: ConstructorParameters<typeof IndexModule.Module>;
|
|
182
|
+
// constructor(...args: ConstructorParameters<typeof IndexModule.Module>) {
|
|
183
|
+
// this._args = args;
|
|
184
|
+
// return new Proxy(this, {
|
|
185
|
+
// get(target, prop) {
|
|
186
|
+
// if (prop in target) {
|
|
187
|
+
// return target[prop as keyof Module];
|
|
188
|
+
// }
|
|
189
|
+
// const instance = target._getInstance();
|
|
190
|
+
// const value = instance[prop as keyof IndexModule.Module];
|
|
191
|
+
// return typeof value === 'function' ? value.bind(instance) : value;
|
|
192
|
+
// },
|
|
193
|
+
// set(target, prop, value) {
|
|
194
|
+
// const instance = target._getInstance();
|
|
195
|
+
// instance[prop as keyof IndexModule.Module] = value;
|
|
196
|
+
// return true;
|
|
197
|
+
// },
|
|
198
|
+
// });
|
|
199
|
+
// }
|
|
200
|
+
// private _getInstance(): IndexModule.Module {
|
|
201
|
+
// if (!this._instance) {
|
|
202
|
+
// const RealModule = getRuntime().Module;
|
|
203
|
+
// this._instance = new RealModule(...this._args);
|
|
204
|
+
// }
|
|
205
|
+
// return this._instance;
|
|
206
|
+
// }
|
|
207
|
+
// // Keep only the methods that have custom logic
|
|
208
|
+
// private wraperFactory(...args: Parameters<IndexModule.Module['wraperFactory']>) {
|
|
209
|
+
// return this._getInstance().wraperFactory(...args);
|
|
210
|
+
// }
|
|
211
|
+
// }
|
|
212
|
+
//export class FederationHost implements IndexModule.FederationHost {
|
|
213
|
+
// private _instance: IndexModule.FederationHost | null = null;
|
|
214
|
+
// private _args: ConstructorParameters<typeof IndexModule.FederationHost>;
|
|
215
|
+
// constructor(...args: ConstructorParameters<typeof IndexModule.FederationHost>) {
|
|
216
|
+
// this._args = args;
|
|
217
|
+
// return new Proxy(this, {
|
|
218
|
+
// get(target, prop) {
|
|
219
|
+
// if (prop in target) {
|
|
220
|
+
// return target[prop as keyof FederationHost];
|
|
221
|
+
// }
|
|
222
|
+
// const instance = target._getInstance();
|
|
223
|
+
// const value = instance[prop as keyof IndexModule.FederationHost];
|
|
224
|
+
// return typeof value === 'function' ? value.bind(instance) : value;
|
|
225
|
+
// },
|
|
226
|
+
// set(target, prop, value) {
|
|
227
|
+
// const instance = target._getInstance();
|
|
228
|
+
// instance[prop as keyof IndexModule.FederationHost] = value;
|
|
229
|
+
// return true;
|
|
230
|
+
// },
|
|
231
|
+
// });
|
|
232
|
+
// }
|
|
233
|
+
// private _getInstance(): IndexModule.FederationHost {
|
|
234
|
+
// if (!this._instance) {
|
|
235
|
+
// const RealFederationHost = getRuntime().FederationHost;
|
|
236
|
+
// this._instance = new RealFederationHost(...this._args);
|
|
237
|
+
// }
|
|
238
|
+
// return this._instance;
|
|
239
|
+
// }
|
|
240
|
+
// // Keep only the methods that have custom logic
|
|
241
|
+
// formatOptions(...args: Parameters<IndexModule.FederationHost['formatOptions']>) {
|
|
242
|
+
// return this._getInstance().formatOptions(...args);
|
|
243
|
+
// }
|
|
244
|
+
// }
|
|
245
|
+
//function createRuntimeFunction<T extends keyof typeof IndexModule>(
|
|
246
|
+
// name: T
|
|
247
|
+
// ): typeof IndexModule[T] {
|
|
248
|
+
// return (...args: any[]) => {
|
|
249
|
+
// return getRuntime()[name](...args);
|
|
250
|
+
// };
|
|
251
|
+
// }
|
|
252
|
+
// export const registerGlobalPlugins = createRuntimeFunction('registerGlobalPlugins');
|
|
253
|
+
// export const getRemoteEntry = createRuntimeFunction('getRemoteEntry');
|
|
254
|
+
// export const getRemoteInfo = createRuntimeFunction('getRemoteInfo');
|
|
255
|
+
// export const loadScript = createRuntimeFunction('loadScript');
|
|
256
|
+
// export const loadScriptNode = createRuntimeFunction('loadScriptNode');
|
|
257
|
+
// export const init = createRuntimeFunction('init');
|
|
258
|
+
// export const loadRemote = createRuntimeFunction('loadRemote');
|
|
259
|
+
// export const loadShare = createRuntimeFunction('loadShare');
|
|
260
|
+
// export const loadShareSync = createRuntimeFunction('loadShareSync');
|
|
261
|
+
// export const preloadRemote = createRuntimeFunction('preloadRemote');
|
|
262
|
+
// export const registerRemotes = createRuntimeFunction('registerRemotes');
|
|
263
|
+
// export const registerPlugins = createRuntimeFunction('registerPlugins');
|
|
264
|
+
// export const getInstance = createRuntimeFunction('getInstance');
|
|
6
265
|
|
|
7
266
|
exports.FederationHost = FederationHost;
|
|
267
|
+
exports.Module = Module;
|
|
8
268
|
exports.getInstance = getInstance;
|
|
9
269
|
exports.getRemoteEntry = getRemoteEntry;
|
|
10
270
|
exports.getRemoteInfo = getRemoteInfo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/embedded";
|
package/dist/embedded.esm.js
CHANGED
|
@@ -1,3 +1,264 @@
|
|
|
1
|
-
|
|
1
|
+
function getRuntime() {
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
const runtime = __webpack_require__.federation.runtime;
|
|
4
|
+
if (!runtime) {
|
|
5
|
+
throw new Error('Federation runtime accessed before instantiation or installation');
|
|
6
|
+
}
|
|
7
|
+
return runtime;
|
|
8
|
+
}
|
|
9
|
+
const registerGlobalPlugins = (...args)=>{
|
|
10
|
+
return getRuntime().registerGlobalPlugins(...args);
|
|
11
|
+
};
|
|
12
|
+
const getRemoteEntry = (...args)=>{
|
|
13
|
+
return getRuntime().getRemoteEntry(...args);
|
|
14
|
+
};
|
|
15
|
+
const getRemoteInfo = (...args)=>{
|
|
16
|
+
return getRuntime().getRemoteInfo(...args);
|
|
17
|
+
};
|
|
18
|
+
const loadScript = (...args)=>{
|
|
19
|
+
return getRuntime().loadScript(...args);
|
|
20
|
+
};
|
|
21
|
+
const loadScriptNode = (...args)=>{
|
|
22
|
+
return getRuntime().loadScriptNode(...args);
|
|
23
|
+
};
|
|
24
|
+
const init = (...args)=>{
|
|
25
|
+
return getRuntime().init(...args);
|
|
26
|
+
};
|
|
27
|
+
const loadRemote = (...args)=>{
|
|
28
|
+
return getRuntime().loadRemote(...args);
|
|
29
|
+
};
|
|
30
|
+
const loadShare = (...args)=>{
|
|
31
|
+
return getRuntime().loadShare(...args);
|
|
32
|
+
};
|
|
33
|
+
const loadShareSync = (...args)=>{
|
|
34
|
+
return getRuntime().loadShareSync(...args);
|
|
35
|
+
};
|
|
36
|
+
const preloadRemote = (...args)=>{
|
|
37
|
+
return getRuntime().preloadRemote(...args);
|
|
38
|
+
};
|
|
39
|
+
const registerRemotes = (...args)=>{
|
|
40
|
+
return getRuntime().registerRemotes(...args);
|
|
41
|
+
};
|
|
42
|
+
const registerPlugins = (...args)=>{
|
|
43
|
+
return getRuntime().registerPlugins(...args);
|
|
44
|
+
};
|
|
45
|
+
const getInstance = (...args)=>{
|
|
46
|
+
return getRuntime().getInstance(...args);
|
|
47
|
+
};
|
|
48
|
+
class FederationHost {
|
|
49
|
+
_getInstance() {
|
|
50
|
+
if (!this._instance) {
|
|
51
|
+
const RealFederationHost = getRuntime().FederationHost;
|
|
52
|
+
this._instance = new RealFederationHost(...this._args);
|
|
53
|
+
}
|
|
54
|
+
return this._instance;
|
|
55
|
+
}
|
|
56
|
+
get options() {
|
|
57
|
+
return this._getInstance().options;
|
|
58
|
+
}
|
|
59
|
+
set options(value) {
|
|
60
|
+
this._getInstance().options = value;
|
|
61
|
+
}
|
|
62
|
+
get hooks() {
|
|
63
|
+
return this._getInstance().hooks;
|
|
64
|
+
}
|
|
65
|
+
get version() {
|
|
66
|
+
return this._getInstance().version;
|
|
67
|
+
}
|
|
68
|
+
get name() {
|
|
69
|
+
return this._getInstance().name;
|
|
70
|
+
}
|
|
71
|
+
get moduleCache() {
|
|
72
|
+
return this._getInstance().moduleCache;
|
|
73
|
+
}
|
|
74
|
+
get snapshotHandler() {
|
|
75
|
+
return this._getInstance().snapshotHandler;
|
|
76
|
+
}
|
|
77
|
+
get sharedHandler() {
|
|
78
|
+
return this._getInstance().sharedHandler;
|
|
79
|
+
}
|
|
80
|
+
get remoteHandler() {
|
|
81
|
+
return this._getInstance().remoteHandler;
|
|
82
|
+
}
|
|
83
|
+
get shareScopeMap() {
|
|
84
|
+
return this._getInstance().shareScopeMap;
|
|
85
|
+
}
|
|
86
|
+
get loaderHook() {
|
|
87
|
+
return this._getInstance().loaderHook;
|
|
88
|
+
}
|
|
89
|
+
initOptions(...args) {
|
|
90
|
+
return this._getInstance().initOptions(...args);
|
|
91
|
+
}
|
|
92
|
+
loadShare(...args) {
|
|
93
|
+
return this._getInstance().loadShare(...args);
|
|
94
|
+
}
|
|
95
|
+
loadShareSync(...args) {
|
|
96
|
+
return this._getInstance().loadShareSync(...args);
|
|
97
|
+
}
|
|
98
|
+
initializeSharing(...args) {
|
|
99
|
+
return this._getInstance().initializeSharing(...args);
|
|
100
|
+
}
|
|
101
|
+
initRawContainer(...args) {
|
|
102
|
+
return this._getInstance().initRawContainer(...args);
|
|
103
|
+
}
|
|
104
|
+
loadRemote(...args) {
|
|
105
|
+
return this._getInstance().loadRemote(...args);
|
|
106
|
+
}
|
|
107
|
+
preloadRemote(...args) {
|
|
108
|
+
return this._getInstance().preloadRemote(...args);
|
|
109
|
+
}
|
|
110
|
+
initShareScopeMap(...args) {
|
|
111
|
+
return this._getInstance().initShareScopeMap(...args);
|
|
112
|
+
}
|
|
113
|
+
registerPlugins(...args) {
|
|
114
|
+
return this._getInstance().registerPlugins(...args);
|
|
115
|
+
}
|
|
116
|
+
registerRemotes(...args) {
|
|
117
|
+
return this._getInstance().registerRemotes(...args);
|
|
118
|
+
}
|
|
119
|
+
formatOptions(...args) {
|
|
120
|
+
//@ts-ignore
|
|
121
|
+
return this._getInstance().formatOptions(...args);
|
|
122
|
+
}
|
|
123
|
+
constructor(...args){
|
|
124
|
+
this._instance = null;
|
|
125
|
+
this._args = args;
|
|
126
|
+
const RealFederationHost = getRuntime().FederationHost;
|
|
127
|
+
this._instance = new RealFederationHost(...this._args);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
class Module {
|
|
131
|
+
_getInstance() {
|
|
132
|
+
if (!this._instance) {
|
|
133
|
+
const RealModule = getRuntime().Module;
|
|
134
|
+
this._instance = new RealModule(...this._args);
|
|
135
|
+
}
|
|
136
|
+
return this._instance;
|
|
137
|
+
}
|
|
138
|
+
get remoteInfo() {
|
|
139
|
+
return this._getInstance().remoteInfo;
|
|
140
|
+
}
|
|
141
|
+
set remoteInfo(value) {
|
|
142
|
+
this._getInstance().remoteInfo = value;
|
|
143
|
+
}
|
|
144
|
+
get inited() {
|
|
145
|
+
return this._getInstance().inited;
|
|
146
|
+
}
|
|
147
|
+
set inited(value) {
|
|
148
|
+
this._getInstance().inited = value;
|
|
149
|
+
}
|
|
150
|
+
get lib() {
|
|
151
|
+
return this._getInstance().lib;
|
|
152
|
+
}
|
|
153
|
+
set lib(value) {
|
|
154
|
+
this._getInstance().lib = value;
|
|
155
|
+
}
|
|
156
|
+
get host() {
|
|
157
|
+
return this._getInstance().host;
|
|
158
|
+
}
|
|
159
|
+
set host(value) {
|
|
160
|
+
this._getInstance().host = value;
|
|
161
|
+
}
|
|
162
|
+
async getEntry(...args) {
|
|
163
|
+
return this._getInstance().getEntry(...args);
|
|
164
|
+
}
|
|
165
|
+
async get(...args) {
|
|
166
|
+
return this._getInstance().get(...args);
|
|
167
|
+
}
|
|
168
|
+
wraperFactory(...args) {
|
|
169
|
+
//@ts-ignore
|
|
170
|
+
return this._getInstance().wraperFactory(...args);
|
|
171
|
+
}
|
|
172
|
+
constructor(...args){
|
|
173
|
+
this._instance = null;
|
|
174
|
+
this._args = args;
|
|
175
|
+
}
|
|
176
|
+
} //maybe use proxy?
|
|
177
|
+
//export class Module implements ModuleInterface {
|
|
178
|
+
// private _instance: IndexModule.Module | null = null;
|
|
179
|
+
// private _args: ConstructorParameters<typeof IndexModule.Module>;
|
|
180
|
+
// constructor(...args: ConstructorParameters<typeof IndexModule.Module>) {
|
|
181
|
+
// this._args = args;
|
|
182
|
+
// return new Proxy(this, {
|
|
183
|
+
// get(target, prop) {
|
|
184
|
+
// if (prop in target) {
|
|
185
|
+
// return target[prop as keyof Module];
|
|
186
|
+
// }
|
|
187
|
+
// const instance = target._getInstance();
|
|
188
|
+
// const value = instance[prop as keyof IndexModule.Module];
|
|
189
|
+
// return typeof value === 'function' ? value.bind(instance) : value;
|
|
190
|
+
// },
|
|
191
|
+
// set(target, prop, value) {
|
|
192
|
+
// const instance = target._getInstance();
|
|
193
|
+
// instance[prop as keyof IndexModule.Module] = value;
|
|
194
|
+
// return true;
|
|
195
|
+
// },
|
|
196
|
+
// });
|
|
197
|
+
// }
|
|
198
|
+
// private _getInstance(): IndexModule.Module {
|
|
199
|
+
// if (!this._instance) {
|
|
200
|
+
// const RealModule = getRuntime().Module;
|
|
201
|
+
// this._instance = new RealModule(...this._args);
|
|
202
|
+
// }
|
|
203
|
+
// return this._instance;
|
|
204
|
+
// }
|
|
205
|
+
// // Keep only the methods that have custom logic
|
|
206
|
+
// private wraperFactory(...args: Parameters<IndexModule.Module['wraperFactory']>) {
|
|
207
|
+
// return this._getInstance().wraperFactory(...args);
|
|
208
|
+
// }
|
|
209
|
+
// }
|
|
210
|
+
//export class FederationHost implements IndexModule.FederationHost {
|
|
211
|
+
// private _instance: IndexModule.FederationHost | null = null;
|
|
212
|
+
// private _args: ConstructorParameters<typeof IndexModule.FederationHost>;
|
|
213
|
+
// constructor(...args: ConstructorParameters<typeof IndexModule.FederationHost>) {
|
|
214
|
+
// this._args = args;
|
|
215
|
+
// return new Proxy(this, {
|
|
216
|
+
// get(target, prop) {
|
|
217
|
+
// if (prop in target) {
|
|
218
|
+
// return target[prop as keyof FederationHost];
|
|
219
|
+
// }
|
|
220
|
+
// const instance = target._getInstance();
|
|
221
|
+
// const value = instance[prop as keyof IndexModule.FederationHost];
|
|
222
|
+
// return typeof value === 'function' ? value.bind(instance) : value;
|
|
223
|
+
// },
|
|
224
|
+
// set(target, prop, value) {
|
|
225
|
+
// const instance = target._getInstance();
|
|
226
|
+
// instance[prop as keyof IndexModule.FederationHost] = value;
|
|
227
|
+
// return true;
|
|
228
|
+
// },
|
|
229
|
+
// });
|
|
230
|
+
// }
|
|
231
|
+
// private _getInstance(): IndexModule.FederationHost {
|
|
232
|
+
// if (!this._instance) {
|
|
233
|
+
// const RealFederationHost = getRuntime().FederationHost;
|
|
234
|
+
// this._instance = new RealFederationHost(...this._args);
|
|
235
|
+
// }
|
|
236
|
+
// return this._instance;
|
|
237
|
+
// }
|
|
238
|
+
// // Keep only the methods that have custom logic
|
|
239
|
+
// formatOptions(...args: Parameters<IndexModule.FederationHost['formatOptions']>) {
|
|
240
|
+
// return this._getInstance().formatOptions(...args);
|
|
241
|
+
// }
|
|
242
|
+
// }
|
|
243
|
+
//function createRuntimeFunction<T extends keyof typeof IndexModule>(
|
|
244
|
+
// name: T
|
|
245
|
+
// ): typeof IndexModule[T] {
|
|
246
|
+
// return (...args: any[]) => {
|
|
247
|
+
// return getRuntime()[name](...args);
|
|
248
|
+
// };
|
|
249
|
+
// }
|
|
250
|
+
// export const registerGlobalPlugins = createRuntimeFunction('registerGlobalPlugins');
|
|
251
|
+
// export const getRemoteEntry = createRuntimeFunction('getRemoteEntry');
|
|
252
|
+
// export const getRemoteInfo = createRuntimeFunction('getRemoteInfo');
|
|
253
|
+
// export const loadScript = createRuntimeFunction('loadScript');
|
|
254
|
+
// export const loadScriptNode = createRuntimeFunction('loadScriptNode');
|
|
255
|
+
// export const init = createRuntimeFunction('init');
|
|
256
|
+
// export const loadRemote = createRuntimeFunction('loadRemote');
|
|
257
|
+
// export const loadShare = createRuntimeFunction('loadShare');
|
|
258
|
+
// export const loadShareSync = createRuntimeFunction('loadShareSync');
|
|
259
|
+
// export const preloadRemote = createRuntimeFunction('preloadRemote');
|
|
260
|
+
// export const registerRemotes = createRuntimeFunction('registerRemotes');
|
|
261
|
+
// export const registerPlugins = createRuntimeFunction('registerPlugins');
|
|
262
|
+
// export const getInstance = createRuntimeFunction('getInstance');
|
|
2
263
|
|
|
3
|
-
export { FederationHost, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes };
|
|
264
|
+
export { FederationHost, Module, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes };
|
package/dist/helpers.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as getRegisteredShare, a as getGlobalShareScope, G as Global, n as nativeGlobal, r as resetFederationGlobalInfo, b as getGlobalFederationInstance, s as setGlobalFederationInstance, c as getGlobalFederationConstructor, d as setGlobalFederationConstructor, e as getInfoWithoutType, f as getGlobalSnapshot, h as getTargetSnapshotInfoByModuleInfo, i as getGlobalSnapshotInfoByModuleInfo, j as setGlobalSnapshotInfoByModuleInfo, k as addGlobalSnapshot, l as getRemoteEntryExports, m as registerGlobalPlugins, o as getGlobalHostPlugins, p as getPreloaded, q as setPreloaded } from './share.esm.js';
|
|
2
2
|
import './polyfills.esm.js';
|
|
3
3
|
import '@module-federation/sdk';
|
|
4
4
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var polyfills = require('./polyfills.cjs.js');
|
|
6
4
|
var sdk = require('@module-federation/sdk');
|
|
7
5
|
var share = require('./share.cjs.js');
|
|
@@ -182,7 +180,7 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, createScriptHook }
|
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
async function loadEntryNode({ remoteInfo, createScriptHook }) {
|
|
185
|
-
const { entry, entryGlobalName: globalName, name } = remoteInfo;
|
|
183
|
+
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
186
184
|
const { entryExports: remoteEntryExports } = share.getRemoteEntryExports(name, globalName);
|
|
187
185
|
if (remoteEntryExports) {
|
|
188
186
|
return remoteEntryExports;
|
|
@@ -190,7 +188,8 @@ async function loadEntryNode({ remoteInfo, createScriptHook }) {
|
|
|
190
188
|
return sdk.loadScriptNode(entry, {
|
|
191
189
|
attrs: {
|
|
192
190
|
name,
|
|
193
|
-
globalName
|
|
191
|
+
globalName,
|
|
192
|
+
type
|
|
194
193
|
},
|
|
195
194
|
createScriptHook: (url, attrs)=>{
|
|
196
195
|
const res = createScriptHook.emit({
|
|
@@ -227,27 +226,24 @@ async function getRemoteEntry({ origin, remoteEntryExports, remoteInfo }) {
|
|
|
227
226
|
}
|
|
228
227
|
if (!share.globalLoading[uniqueKey]) {
|
|
229
228
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (!sdk.isBrowserEnv()) {
|
|
239
|
-
share.globalLoading[uniqueKey] = loadEntryNode({
|
|
240
|
-
remoteInfo,
|
|
241
|
-
createScriptHook
|
|
242
|
-
});
|
|
243
|
-
} else {
|
|
244
|
-
share.globalLoading[uniqueKey] = loadEntryDom({
|
|
245
|
-
remoteInfo,
|
|
246
|
-
remoteEntryExports,
|
|
247
|
-
createScriptHook
|
|
248
|
-
});
|
|
229
|
+
const createScriptHook = origin.loaderHook.lifecycle.createScript;
|
|
230
|
+
share.globalLoading[uniqueKey] = loadEntryHook.emit({
|
|
231
|
+
createScriptHook,
|
|
232
|
+
remoteInfo,
|
|
233
|
+
remoteEntryExports
|
|
234
|
+
}).then((res)=>{
|
|
235
|
+
if (res) {
|
|
236
|
+
return res;
|
|
249
237
|
}
|
|
250
|
-
|
|
238
|
+
return sdk.isBrowserEnv() ? loadEntryDom({
|
|
239
|
+
remoteInfo,
|
|
240
|
+
remoteEntryExports,
|
|
241
|
+
createScriptHook
|
|
242
|
+
}) : loadEntryNode({
|
|
243
|
+
remoteInfo,
|
|
244
|
+
createScriptHook
|
|
245
|
+
});
|
|
246
|
+
});
|
|
251
247
|
}
|
|
252
248
|
return share.globalLoading[uniqueKey];
|
|
253
249
|
}
|
|
@@ -959,7 +955,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
959
955
|
moduleInfo: {
|
|
960
956
|
name: remoteInfo.name,
|
|
961
957
|
entry: remote.entry,
|
|
962
|
-
type: 'global',
|
|
958
|
+
type: remoteInfo.type || 'global',
|
|
963
959
|
entryGlobalName: '',
|
|
964
960
|
shareScope: ''
|
|
965
961
|
}
|
|
@@ -1338,9 +1334,20 @@ class SharedHandler {
|
|
|
1338
1334
|
id: key
|
|
1339
1335
|
});
|
|
1340
1336
|
if (module.getEntry) {
|
|
1341
|
-
|
|
1337
|
+
let remoteEntryExports;
|
|
1338
|
+
try {
|
|
1339
|
+
remoteEntryExports = await module.getEntry();
|
|
1340
|
+
} catch (error) {
|
|
1341
|
+
remoteEntryExports = await host.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1342
|
+
id: key,
|
|
1343
|
+
error,
|
|
1344
|
+
from: 'runtime',
|
|
1345
|
+
lifecycle: 'beforeLoadShare',
|
|
1346
|
+
origin: host
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1342
1349
|
if (!module.inited) {
|
|
1343
|
-
await initFn(
|
|
1350
|
+
await initFn(remoteEntryExports);
|
|
1344
1351
|
module.inited = true;
|
|
1345
1352
|
}
|
|
1346
1353
|
}
|
|
@@ -1980,7 +1987,7 @@ class FederationHost {
|
|
|
1980
1987
|
// maybe will change, temporarily for internal use only
|
|
1981
1988
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1982
1989
|
});
|
|
1983
|
-
this.version = "0.6.
|
|
1990
|
+
this.version = "0.6.8";
|
|
1984
1991
|
this.moduleCache = new Map();
|
|
1985
1992
|
this.loaderHook = new PluginSystem({
|
|
1986
1993
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -2075,11 +2082,11 @@ function getInstance() {
|
|
|
2075
2082
|
// Inject for debug
|
|
2076
2083
|
share.setGlobalFederationConstructor(FederationHost);
|
|
2077
2084
|
|
|
2078
|
-
Object.defineProperty(exports,
|
|
2085
|
+
Object.defineProperty(exports, "loadScript", {
|
|
2079
2086
|
enumerable: true,
|
|
2080
2087
|
get: function () { return sdk.loadScript; }
|
|
2081
2088
|
});
|
|
2082
|
-
Object.defineProperty(exports,
|
|
2089
|
+
Object.defineProperty(exports, "loadScriptNode", {
|
|
2083
2090
|
enumerable: true,
|
|
2084
2091
|
get: function () { return sdk.loadScriptNode; }
|
|
2085
2092
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as _extends, _ as _object_without_properties_loose } from './polyfills.esm.js';
|
|
2
2
|
import { isBrowserEnv, loadScriptNode, composeKeyWithSeparator, loadScript, safeToString, createLink, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
|
|
3
3
|
export { loadScript, loadScriptNode } from '@module-federation/sdk';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
4
|
+
import { o as getGlobalHostPlugins, t as globalLoading, D as DEFAULT_REMOTE_TYPE, u as DEFAULT_SCOPE, l as getRemoteEntryExports, v as assert, w as getFMId, x as isObject, y as error, z as warn, A as isPlainObject, B as isRemoteInfoWithEntry, C as isPureRemoteEntry, E as getRemoteEntryInfoFromSnapshot, e as getInfoWithoutType, p as getPreloaded, q as setPreloaded, g as getRegisteredShare, F as arrayOptions, i as getGlobalSnapshotInfoByModuleInfo, k as addGlobalSnapshot, j as setGlobalSnapshotInfoByModuleInfo, G as Global, f as getGlobalSnapshot, H as formatShareConfigs, I as getTargetSharedOptions, a as getGlobalShareScope, J as addUniqueItem, K as getBuilderId, d as setGlobalFederationConstructor, b as getGlobalFederationInstance, c as getGlobalFederationConstructor, s as setGlobalFederationInstance } from './share.esm.js';
|
|
5
|
+
export { m as registerGlobalPlugins } from './share.esm.js';
|
|
6
6
|
|
|
7
7
|
// Function to match a remote with its name and expose
|
|
8
8
|
// id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
|
|
@@ -180,7 +180,7 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, createScriptHook }
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
async function loadEntryNode({ remoteInfo, createScriptHook }) {
|
|
183
|
-
const { entry, entryGlobalName: globalName, name } = remoteInfo;
|
|
183
|
+
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
184
184
|
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
185
185
|
if (remoteEntryExports) {
|
|
186
186
|
return remoteEntryExports;
|
|
@@ -188,7 +188,8 @@ async function loadEntryNode({ remoteInfo, createScriptHook }) {
|
|
|
188
188
|
return loadScriptNode(entry, {
|
|
189
189
|
attrs: {
|
|
190
190
|
name,
|
|
191
|
-
globalName
|
|
191
|
+
globalName,
|
|
192
|
+
type
|
|
192
193
|
},
|
|
193
194
|
createScriptHook: (url, attrs)=>{
|
|
194
195
|
const res = createScriptHook.emit({
|
|
@@ -225,27 +226,24 @@ async function getRemoteEntry({ origin, remoteEntryExports, remoteInfo }) {
|
|
|
225
226
|
}
|
|
226
227
|
if (!globalLoading[uniqueKey]) {
|
|
227
228
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (!isBrowserEnv()) {
|
|
237
|
-
globalLoading[uniqueKey] = loadEntryNode({
|
|
238
|
-
remoteInfo,
|
|
239
|
-
createScriptHook
|
|
240
|
-
});
|
|
241
|
-
} else {
|
|
242
|
-
globalLoading[uniqueKey] = loadEntryDom({
|
|
243
|
-
remoteInfo,
|
|
244
|
-
remoteEntryExports,
|
|
245
|
-
createScriptHook
|
|
246
|
-
});
|
|
229
|
+
const createScriptHook = origin.loaderHook.lifecycle.createScript;
|
|
230
|
+
globalLoading[uniqueKey] = loadEntryHook.emit({
|
|
231
|
+
createScriptHook,
|
|
232
|
+
remoteInfo,
|
|
233
|
+
remoteEntryExports
|
|
234
|
+
}).then((res)=>{
|
|
235
|
+
if (res) {
|
|
236
|
+
return res;
|
|
247
237
|
}
|
|
248
|
-
|
|
238
|
+
return isBrowserEnv() ? loadEntryDom({
|
|
239
|
+
remoteInfo,
|
|
240
|
+
remoteEntryExports,
|
|
241
|
+
createScriptHook
|
|
242
|
+
}) : loadEntryNode({
|
|
243
|
+
remoteInfo,
|
|
244
|
+
createScriptHook
|
|
245
|
+
});
|
|
246
|
+
});
|
|
249
247
|
}
|
|
250
248
|
return globalLoading[uniqueKey];
|
|
251
249
|
}
|
|
@@ -957,7 +955,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
957
955
|
moduleInfo: {
|
|
958
956
|
name: remoteInfo.name,
|
|
959
957
|
entry: remote.entry,
|
|
960
|
-
type: 'global',
|
|
958
|
+
type: remoteInfo.type || 'global',
|
|
961
959
|
entryGlobalName: '',
|
|
962
960
|
shareScope: ''
|
|
963
961
|
}
|
|
@@ -1336,9 +1334,20 @@ class SharedHandler {
|
|
|
1336
1334
|
id: key
|
|
1337
1335
|
});
|
|
1338
1336
|
if (module.getEntry) {
|
|
1339
|
-
|
|
1337
|
+
let remoteEntryExports;
|
|
1338
|
+
try {
|
|
1339
|
+
remoteEntryExports = await module.getEntry();
|
|
1340
|
+
} catch (error) {
|
|
1341
|
+
remoteEntryExports = await host.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1342
|
+
id: key,
|
|
1343
|
+
error,
|
|
1344
|
+
from: 'runtime',
|
|
1345
|
+
lifecycle: 'beforeLoadShare',
|
|
1346
|
+
origin: host
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1340
1349
|
if (!module.inited) {
|
|
1341
|
-
await initFn(
|
|
1350
|
+
await initFn(remoteEntryExports);
|
|
1342
1351
|
module.inited = true;
|
|
1343
1352
|
}
|
|
1344
1353
|
}
|
|
@@ -1978,7 +1987,7 @@ class FederationHost {
|
|
|
1978
1987
|
// maybe will change, temporarily for internal use only
|
|
1979
1988
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1980
1989
|
});
|
|
1981
|
-
this.version = "0.6.
|
|
1990
|
+
this.version = "0.6.8";
|
|
1982
1991
|
this.moduleCache = new Map();
|
|
1983
1992
|
this.loaderHook = new PluginSystem({
|
|
1984
1993
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./index.cjs.js",
|
|
6
6
|
"module": "./index.esm.js",
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@module-federation/sdk": "workspace:*"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|
package/dist/polyfills.esm.js
CHANGED
package/dist/share.cjs.js
CHANGED
|
@@ -175,7 +175,7 @@ function getGlobalFederationConstructor() {
|
|
|
175
175
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
|
|
176
176
|
if (isDebug) {
|
|
177
177
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
178
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.
|
|
178
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.8";
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -318,6 +318,13 @@ const comparator = `^${gtlt}\\s*(${fullPlain})$|^$`;
|
|
|
318
318
|
const gte0 = '^\\s*>=\\s*0.0.0\\s*$';
|
|
319
319
|
|
|
320
320
|
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
321
|
+
// Copyright (c)
|
|
322
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
323
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
324
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
325
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
326
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
327
|
+
// See the Mulan PSL v2 for more details.
|
|
321
328
|
function parseRegex(source) {
|
|
322
329
|
return new RegExp(source);
|
|
323
330
|
}
|
|
@@ -339,6 +346,13 @@ function combineVersion(major, minor, patch, preRelease) {
|
|
|
339
346
|
}
|
|
340
347
|
|
|
341
348
|
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
349
|
+
// Copyright (c)
|
|
350
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
351
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
352
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
353
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
354
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
355
|
+
// See the Mulan PSL v2 for more details.
|
|
342
356
|
function parseHyphen(range) {
|
|
343
357
|
return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease)=>{
|
|
344
358
|
if (isXVersion(fromMajor)) {
|
|
@@ -565,6 +579,13 @@ function compare(rangeAtom, versionAtom) {
|
|
|
565
579
|
}
|
|
566
580
|
|
|
567
581
|
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
582
|
+
// Copyright (c)
|
|
583
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
584
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
585
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
586
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
587
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
588
|
+
// See the Mulan PSL v2 for more details.
|
|
568
589
|
function parseComparatorString(range) {
|
|
569
590
|
return pipe(// handle caret
|
|
570
591
|
// ^ --> * (any, kinda silly)
|
package/dist/share.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as _object_without_properties_loose, a as _extends } from './polyfills.esm.js';
|
|
2
2
|
import { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
|
|
3
3
|
|
|
4
4
|
function getBuilderId() {
|
|
@@ -173,7 +173,7 @@ function getGlobalFederationConstructor() {
|
|
|
173
173
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
174
174
|
if (isDebug) {
|
|
175
175
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
176
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.
|
|
176
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.8";
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -316,6 +316,13 @@ const comparator = `^${gtlt}\\s*(${fullPlain})$|^$`;
|
|
|
316
316
|
const gte0 = '^\\s*>=\\s*0.0.0\\s*$';
|
|
317
317
|
|
|
318
318
|
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
319
|
+
// Copyright (c)
|
|
320
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
321
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
322
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
323
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
324
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
325
|
+
// See the Mulan PSL v2 for more details.
|
|
319
326
|
function parseRegex(source) {
|
|
320
327
|
return new RegExp(source);
|
|
321
328
|
}
|
|
@@ -337,6 +344,13 @@ function combineVersion(major, minor, patch, preRelease) {
|
|
|
337
344
|
}
|
|
338
345
|
|
|
339
346
|
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
347
|
+
// Copyright (c)
|
|
348
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
349
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
350
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
351
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
352
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
353
|
+
// See the Mulan PSL v2 for more details.
|
|
340
354
|
function parseHyphen(range) {
|
|
341
355
|
return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease)=>{
|
|
342
356
|
if (isXVersion(fromMajor)) {
|
|
@@ -563,6 +577,13 @@ function compare(rangeAtom, versionAtom) {
|
|
|
563
577
|
}
|
|
564
578
|
|
|
565
579
|
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
580
|
+
// Copyright (c)
|
|
581
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
582
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
583
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
584
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
585
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
586
|
+
// See the Mulan PSL v2 for more details.
|
|
566
587
|
function parseComparatorString(range) {
|
|
567
588
|
return pipe(// handle caret
|
|
568
589
|
// ^ --> * (any, kinda silly)
|
|
@@ -844,4 +865,4 @@ function getTargetSharedOptions(options) {
|
|
|
844
865
|
return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
|
|
845
866
|
}
|
|
846
867
|
|
|
847
|
-
export {
|
|
868
|
+
export { isPlainObject as A, isRemoteInfoWithEntry as B, isPureRemoteEntry as C, DEFAULT_REMOTE_TYPE as D, getRemoteEntryInfoFromSnapshot as E, arrayOptions as F, Global as G, formatShareConfigs as H, getTargetSharedOptions as I, addUniqueItem as J, getBuilderId as K, getGlobalShareScope as a, getGlobalFederationInstance as b, getGlobalFederationConstructor as c, setGlobalFederationConstructor as d, getInfoWithoutType as e, getGlobalSnapshot as f, getRegisteredShare as g, getTargetSnapshotInfoByModuleInfo as h, getGlobalSnapshotInfoByModuleInfo as i, setGlobalSnapshotInfoByModuleInfo as j, addGlobalSnapshot as k, getRemoteEntryExports as l, registerGlobalPlugins as m, nativeGlobal as n, getGlobalHostPlugins as o, getPreloaded as p, setPreloaded as q, resetFederationGlobalInfo as r, setGlobalFederationInstance as s, globalLoading as t, DEFAULT_SCOPE as u, assert as v, getFMId as w, isObject as x, error as y, warn as z };
|
package/dist/src/core.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ export declare class FederationHost {
|
|
|
85
85
|
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
|
|
86
86
|
hostShareScopeMap?: ShareScopeMap;
|
|
87
87
|
}): void;
|
|
88
|
-
|
|
88
|
+
formatOptions(globalOptions: Options, userOptions: UserOptions): Options;
|
|
89
89
|
registerPlugins(plugins: UserOptions['plugins']): void;
|
|
90
90
|
registerRemotes(remotes: Remote[], options?: {
|
|
91
91
|
force?: boolean;
|
package/dist/src/embedded.d.ts
CHANGED
|
@@ -1,2 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import type * as IndexModule from './index';
|
|
2
|
+
export declare const registerGlobalPlugins: typeof IndexModule.registerGlobalPlugins;
|
|
3
|
+
export declare const getRemoteEntry: typeof IndexModule.getRemoteEntry;
|
|
4
|
+
export declare const getRemoteInfo: typeof IndexModule.getRemoteInfo;
|
|
5
|
+
export declare const loadScript: typeof IndexModule.loadScript;
|
|
6
|
+
export declare const loadScriptNode: typeof IndexModule.loadScriptNode;
|
|
7
|
+
export declare const init: typeof IndexModule.init;
|
|
8
|
+
export declare const loadRemote: typeof IndexModule.loadRemote;
|
|
9
|
+
export declare const loadShare: typeof IndexModule.loadShare;
|
|
10
|
+
export declare const loadShareSync: typeof IndexModule.loadShareSync;
|
|
11
|
+
export declare const preloadRemote: typeof IndexModule.preloadRemote;
|
|
12
|
+
export declare const registerRemotes: typeof IndexModule.registerRemotes;
|
|
13
|
+
export declare const registerPlugins: typeof IndexModule.registerPlugins;
|
|
14
|
+
export declare const getInstance: typeof IndexModule.getInstance;
|
|
15
|
+
export declare class FederationHost implements IndexModule.FederationHost {
|
|
16
|
+
private _instance;
|
|
17
|
+
private _args;
|
|
18
|
+
constructor(...args: ConstructorParameters<typeof IndexModule.FederationHost>);
|
|
19
|
+
private _getInstance;
|
|
20
|
+
get options(): import("./type").Options;
|
|
21
|
+
set options(value: import("./type").Options);
|
|
22
|
+
get hooks(): import("./utils/hooks").PluginSystem<{
|
|
23
|
+
beforeInit: import("./utils/hooks").SyncWaterfallHook<{
|
|
24
|
+
userOptions: import("./type").UserOptions;
|
|
25
|
+
options: import("./type").Options;
|
|
26
|
+
origin: IndexModule.FederationHost;
|
|
27
|
+
shareInfo: import("./type").ShareInfos;
|
|
28
|
+
}>;
|
|
29
|
+
init: import("./utils/hooks").SyncHook<[{
|
|
30
|
+
options: import("./type").Options;
|
|
31
|
+
origin: IndexModule.FederationHost;
|
|
32
|
+
}], void>;
|
|
33
|
+
beforeInitContainer: import("./utils/hooks").AsyncWaterfallHook<{
|
|
34
|
+
shareScope: import("./type").ShareScopeMap[string];
|
|
35
|
+
initScope: import("./type").InitScope;
|
|
36
|
+
remoteEntryInitOptions: import("./type").RemoteEntryInitOptions;
|
|
37
|
+
remoteInfo: import("./type").RemoteInfo;
|
|
38
|
+
origin: IndexModule.FederationHost;
|
|
39
|
+
}>;
|
|
40
|
+
initContainer: import("./utils/hooks").AsyncWaterfallHook<{
|
|
41
|
+
shareScope: import("./type").ShareScopeMap[string];
|
|
42
|
+
initScope: import("./type").InitScope;
|
|
43
|
+
remoteEntryInitOptions: import("./type").RemoteEntryInitOptions;
|
|
44
|
+
remoteInfo: import("./type").RemoteInfo;
|
|
45
|
+
remoteEntryExports: import("./type").RemoteEntryExports;
|
|
46
|
+
origin: IndexModule.FederationHost;
|
|
47
|
+
id: string;
|
|
48
|
+
remoteSnapshot?: import("packages/sdk/dist/src").ModuleInfo;
|
|
49
|
+
}>;
|
|
50
|
+
}>;
|
|
51
|
+
get version(): string;
|
|
52
|
+
get name(): string;
|
|
53
|
+
get moduleCache(): Map<string, IndexModule.Module>;
|
|
54
|
+
get snapshotHandler(): import("./plugins/snapshot/SnapshotHandler").SnapshotHandler;
|
|
55
|
+
get sharedHandler(): import("./shared").SharedHandler;
|
|
56
|
+
get remoteHandler(): import("./remote").RemoteHandler;
|
|
57
|
+
get shareScopeMap(): import("./type").ShareScopeMap;
|
|
58
|
+
get loaderHook(): import("./utils/hooks").PluginSystem<{
|
|
59
|
+
getModuleInfo: import("./utils/hooks").SyncHook<[{
|
|
60
|
+
target: Record<string, any>;
|
|
61
|
+
key: any;
|
|
62
|
+
}], void | {
|
|
63
|
+
value: any | undefined;
|
|
64
|
+
key: string;
|
|
65
|
+
}>;
|
|
66
|
+
createScript: import("./utils/hooks").SyncHook<[{
|
|
67
|
+
url: string;
|
|
68
|
+
attrs?: Record<string, any>;
|
|
69
|
+
}], import("packages/sdk/dist/src").CreateScriptHookReturn>;
|
|
70
|
+
createLink: import("./utils/hooks").SyncHook<[{
|
|
71
|
+
url: string;
|
|
72
|
+
attrs?: Record<string, any>;
|
|
73
|
+
}], void | HTMLLinkElement>;
|
|
74
|
+
fetch: import("./utils/hooks").AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
|
|
75
|
+
}>;
|
|
76
|
+
initOptions(...args: Parameters<IndexModule.FederationHost['initOptions']>): import("./type").Options;
|
|
77
|
+
loadShare<T>(...args: Parameters<IndexModule.FederationHost['loadShare']>): Promise<false | (() => T | undefined)>;
|
|
78
|
+
loadShareSync<T>(...args: Parameters<IndexModule.FederationHost['loadShareSync']>): () => T | never;
|
|
79
|
+
initializeSharing(...args: Parameters<IndexModule.FederationHost['initializeSharing']>): Promise<void>[];
|
|
80
|
+
initRawContainer(...args: Parameters<IndexModule.FederationHost['initRawContainer']>): IndexModule.Module;
|
|
81
|
+
loadRemote<T>(...args: Parameters<IndexModule.FederationHost['loadRemote']>): Promise<T | null>;
|
|
82
|
+
preloadRemote(...args: Parameters<IndexModule.FederationHost['preloadRemote']>): Promise<void>;
|
|
83
|
+
initShareScopeMap(...args: Parameters<IndexModule.FederationHost['initShareScopeMap']>): void;
|
|
84
|
+
registerPlugins(...args: Parameters<IndexModule.FederationHost['registerPlugins']>): void;
|
|
85
|
+
registerRemotes(...args: Parameters<IndexModule.FederationHost['registerRemotes']>): void;
|
|
86
|
+
formatOptions(...args: Parameters<IndexModule.FederationHost['formatOptions']>): import("./type").Options;
|
|
87
|
+
}
|
|
88
|
+
export interface ModuleInterface {
|
|
89
|
+
remoteInfo: IndexModule.Module['remoteInfo'];
|
|
90
|
+
inited: IndexModule.Module['inited'];
|
|
91
|
+
lib: IndexModule.Module['lib'];
|
|
92
|
+
host: IndexModule.Module['host'];
|
|
93
|
+
getEntry(...args: Parameters<IndexModule.Module['getEntry']>): ReturnType<IndexModule.Module['getEntry']>;
|
|
94
|
+
get(...args: Parameters<IndexModule.Module['get']>): ReturnType<IndexModule.Module['get']>;
|
|
95
|
+
}
|
|
96
|
+
export declare class Module implements ModuleInterface {
|
|
97
|
+
private _instance;
|
|
98
|
+
private _args;
|
|
99
|
+
constructor(...args: ConstructorParameters<typeof IndexModule.Module>);
|
|
100
|
+
private _getInstance;
|
|
101
|
+
get remoteInfo(): import("./type").RemoteInfo;
|
|
102
|
+
set remoteInfo(value: import("./type").RemoteInfo);
|
|
103
|
+
get inited(): boolean;
|
|
104
|
+
set inited(value: boolean);
|
|
105
|
+
get lib(): import("./type").RemoteEntryExports | undefined;
|
|
106
|
+
set lib(value: import("./type").RemoteEntryExports | undefined);
|
|
107
|
+
get host(): IndexModule.FederationHost;
|
|
108
|
+
set host(value: IndexModule.FederationHost);
|
|
109
|
+
getEntry(...args: Parameters<IndexModule.Module['getEntry']>): Promise<import("./type").RemoteEntryExports>;
|
|
110
|
+
get(...args: Parameters<IndexModule.Module['get']>): Promise<any>;
|
|
111
|
+
private wraperFactory;
|
|
112
|
+
}
|
|
@@ -57,7 +57,7 @@ export declare class RemoteHandler {
|
|
|
57
57
|
error: unknown;
|
|
58
58
|
options?: any;
|
|
59
59
|
from: CallFrom;
|
|
60
|
-
lifecycle: "onLoad" | "beforeRequest";
|
|
60
|
+
lifecycle: "onLoad" | "beforeRequest" | "beforeLoadShare";
|
|
61
61
|
origin: FederationHost;
|
|
62
62
|
}], unknown>;
|
|
63
63
|
beforePreloadRemote: AsyncHook<[{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@module-federation/sdk": "0.6.
|
|
53
|
+
"@module-federation/sdk": "0.6.8"
|
|
54
54
|
}
|
|
55
55
|
}
|