@module-federation/runtime 0.6.6 → 0.6.7
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 -1
- package/dist/embedded.esm.js +263 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +1 -1
- package/dist/share.esm.js +1 -1
- package/dist/src/core.d.ts +1 -1
- package/dist/src/embedded.d.ts +112 -2
- package/package.json +2 -2
package/dist/embedded.cjs.js
CHANGED
|
@@ -2,9 +2,271 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
function getRuntime() {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
const runtime = __webpack_require__.federation.runtime;
|
|
8
|
+
if (!runtime) {
|
|
9
|
+
throw new Error('Federation runtime accessed before instantiation or installation');
|
|
10
|
+
}
|
|
11
|
+
return runtime;
|
|
12
|
+
}
|
|
13
|
+
const registerGlobalPlugins = (...args)=>{
|
|
14
|
+
return getRuntime().registerGlobalPlugins(...args);
|
|
15
|
+
};
|
|
16
|
+
const getRemoteEntry = (...args)=>{
|
|
17
|
+
return getRuntime().getRemoteEntry(...args);
|
|
18
|
+
};
|
|
19
|
+
const getRemoteInfo = (...args)=>{
|
|
20
|
+
return getRuntime().getRemoteInfo(...args);
|
|
21
|
+
};
|
|
22
|
+
const loadScript = (...args)=>{
|
|
23
|
+
return getRuntime().loadScript(...args);
|
|
24
|
+
};
|
|
25
|
+
const loadScriptNode = (...args)=>{
|
|
26
|
+
return getRuntime().loadScriptNode(...args);
|
|
27
|
+
};
|
|
28
|
+
const init = (...args)=>{
|
|
29
|
+
return getRuntime().init(...args);
|
|
30
|
+
};
|
|
31
|
+
const loadRemote = (...args)=>{
|
|
32
|
+
return getRuntime().loadRemote(...args);
|
|
33
|
+
};
|
|
34
|
+
const loadShare = (...args)=>{
|
|
35
|
+
return getRuntime().loadShare(...args);
|
|
36
|
+
};
|
|
37
|
+
const loadShareSync = (...args)=>{
|
|
38
|
+
return getRuntime().loadShareSync(...args);
|
|
39
|
+
};
|
|
40
|
+
const preloadRemote = (...args)=>{
|
|
41
|
+
return getRuntime().preloadRemote(...args);
|
|
42
|
+
};
|
|
43
|
+
const registerRemotes = (...args)=>{
|
|
44
|
+
return getRuntime().registerRemotes(...args);
|
|
45
|
+
};
|
|
46
|
+
const registerPlugins = (...args)=>{
|
|
47
|
+
return getRuntime().registerPlugins(...args);
|
|
48
|
+
};
|
|
49
|
+
const getInstance = (...args)=>{
|
|
50
|
+
return getRuntime().getInstance(...args);
|
|
51
|
+
};
|
|
52
|
+
class FederationHost {
|
|
53
|
+
_getInstance() {
|
|
54
|
+
if (!this._instance) {
|
|
55
|
+
const RealFederationHost = getRuntime().FederationHost;
|
|
56
|
+
this._instance = new RealFederationHost(...this._args);
|
|
57
|
+
}
|
|
58
|
+
return this._instance;
|
|
59
|
+
}
|
|
60
|
+
get options() {
|
|
61
|
+
return this._getInstance().options;
|
|
62
|
+
}
|
|
63
|
+
set options(value) {
|
|
64
|
+
this._getInstance().options = value;
|
|
65
|
+
}
|
|
66
|
+
get hooks() {
|
|
67
|
+
return this._getInstance().hooks;
|
|
68
|
+
}
|
|
69
|
+
get version() {
|
|
70
|
+
return this._getInstance().version;
|
|
71
|
+
}
|
|
72
|
+
get name() {
|
|
73
|
+
return this._getInstance().name;
|
|
74
|
+
}
|
|
75
|
+
get moduleCache() {
|
|
76
|
+
return this._getInstance().moduleCache;
|
|
77
|
+
}
|
|
78
|
+
get snapshotHandler() {
|
|
79
|
+
return this._getInstance().snapshotHandler;
|
|
80
|
+
}
|
|
81
|
+
get sharedHandler() {
|
|
82
|
+
return this._getInstance().sharedHandler;
|
|
83
|
+
}
|
|
84
|
+
get remoteHandler() {
|
|
85
|
+
return this._getInstance().remoteHandler;
|
|
86
|
+
}
|
|
87
|
+
get shareScopeMap() {
|
|
88
|
+
return this._getInstance().shareScopeMap;
|
|
89
|
+
}
|
|
90
|
+
get loaderHook() {
|
|
91
|
+
return this._getInstance().loaderHook;
|
|
92
|
+
}
|
|
93
|
+
initOptions(...args) {
|
|
94
|
+
return this._getInstance().initOptions(...args);
|
|
95
|
+
}
|
|
96
|
+
loadShare(...args) {
|
|
97
|
+
return this._getInstance().loadShare(...args);
|
|
98
|
+
}
|
|
99
|
+
loadShareSync(...args) {
|
|
100
|
+
return this._getInstance().loadShareSync(...args);
|
|
101
|
+
}
|
|
102
|
+
initializeSharing(...args) {
|
|
103
|
+
return this._getInstance().initializeSharing(...args);
|
|
104
|
+
}
|
|
105
|
+
initRawContainer(...args) {
|
|
106
|
+
return this._getInstance().initRawContainer(...args);
|
|
107
|
+
}
|
|
108
|
+
loadRemote(...args) {
|
|
109
|
+
return this._getInstance().loadRemote(...args);
|
|
110
|
+
}
|
|
111
|
+
preloadRemote(...args) {
|
|
112
|
+
return this._getInstance().preloadRemote(...args);
|
|
113
|
+
}
|
|
114
|
+
initShareScopeMap(...args) {
|
|
115
|
+
return this._getInstance().initShareScopeMap(...args);
|
|
116
|
+
}
|
|
117
|
+
registerPlugins(...args) {
|
|
118
|
+
return this._getInstance().registerPlugins(...args);
|
|
119
|
+
}
|
|
120
|
+
registerRemotes(...args) {
|
|
121
|
+
return this._getInstance().registerRemotes(...args);
|
|
122
|
+
}
|
|
123
|
+
formatOptions(...args) {
|
|
124
|
+
//@ts-ignore
|
|
125
|
+
return this._getInstance().formatOptions(...args);
|
|
126
|
+
}
|
|
127
|
+
constructor(...args){
|
|
128
|
+
this._instance = null;
|
|
129
|
+
this._args = args;
|
|
130
|
+
const RealFederationHost = getRuntime().FederationHost;
|
|
131
|
+
this._instance = new RealFederationHost(...this._args);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
class Module {
|
|
135
|
+
_getInstance() {
|
|
136
|
+
if (!this._instance) {
|
|
137
|
+
const RealModule = getRuntime().Module;
|
|
138
|
+
this._instance = new RealModule(...this._args);
|
|
139
|
+
}
|
|
140
|
+
return this._instance;
|
|
141
|
+
}
|
|
142
|
+
get remoteInfo() {
|
|
143
|
+
return this._getInstance().remoteInfo;
|
|
144
|
+
}
|
|
145
|
+
set remoteInfo(value) {
|
|
146
|
+
this._getInstance().remoteInfo = value;
|
|
147
|
+
}
|
|
148
|
+
get inited() {
|
|
149
|
+
return this._getInstance().inited;
|
|
150
|
+
}
|
|
151
|
+
set inited(value) {
|
|
152
|
+
this._getInstance().inited = value;
|
|
153
|
+
}
|
|
154
|
+
get lib() {
|
|
155
|
+
return this._getInstance().lib;
|
|
156
|
+
}
|
|
157
|
+
set lib(value) {
|
|
158
|
+
this._getInstance().lib = value;
|
|
159
|
+
}
|
|
160
|
+
get host() {
|
|
161
|
+
return this._getInstance().host;
|
|
162
|
+
}
|
|
163
|
+
set host(value) {
|
|
164
|
+
this._getInstance().host = value;
|
|
165
|
+
}
|
|
166
|
+
async getEntry(...args) {
|
|
167
|
+
return this._getInstance().getEntry(...args);
|
|
168
|
+
}
|
|
169
|
+
async get(...args) {
|
|
170
|
+
return this._getInstance().get(...args);
|
|
171
|
+
}
|
|
172
|
+
wraperFactory(...args) {
|
|
173
|
+
//@ts-ignore
|
|
174
|
+
return this._getInstance().wraperFactory(...args);
|
|
175
|
+
}
|
|
176
|
+
constructor(...args){
|
|
177
|
+
this._instance = null;
|
|
178
|
+
this._args = args;
|
|
179
|
+
}
|
|
180
|
+
} //maybe use proxy?
|
|
181
|
+
//export class Module implements ModuleInterface {
|
|
182
|
+
// private _instance: IndexModule.Module | null = null;
|
|
183
|
+
// private _args: ConstructorParameters<typeof IndexModule.Module>;
|
|
184
|
+
// constructor(...args: ConstructorParameters<typeof IndexModule.Module>) {
|
|
185
|
+
// this._args = args;
|
|
186
|
+
// return new Proxy(this, {
|
|
187
|
+
// get(target, prop) {
|
|
188
|
+
// if (prop in target) {
|
|
189
|
+
// return target[prop as keyof Module];
|
|
190
|
+
// }
|
|
191
|
+
// const instance = target._getInstance();
|
|
192
|
+
// const value = instance[prop as keyof IndexModule.Module];
|
|
193
|
+
// return typeof value === 'function' ? value.bind(instance) : value;
|
|
194
|
+
// },
|
|
195
|
+
// set(target, prop, value) {
|
|
196
|
+
// const instance = target._getInstance();
|
|
197
|
+
// instance[prop as keyof IndexModule.Module] = value;
|
|
198
|
+
// return true;
|
|
199
|
+
// },
|
|
200
|
+
// });
|
|
201
|
+
// }
|
|
202
|
+
// private _getInstance(): IndexModule.Module {
|
|
203
|
+
// if (!this._instance) {
|
|
204
|
+
// const RealModule = getRuntime().Module;
|
|
205
|
+
// this._instance = new RealModule(...this._args);
|
|
206
|
+
// }
|
|
207
|
+
// return this._instance;
|
|
208
|
+
// }
|
|
209
|
+
// // Keep only the methods that have custom logic
|
|
210
|
+
// private wraperFactory(...args: Parameters<IndexModule.Module['wraperFactory']>) {
|
|
211
|
+
// return this._getInstance().wraperFactory(...args);
|
|
212
|
+
// }
|
|
213
|
+
// }
|
|
214
|
+
//export class FederationHost implements IndexModule.FederationHost {
|
|
215
|
+
// private _instance: IndexModule.FederationHost | null = null;
|
|
216
|
+
// private _args: ConstructorParameters<typeof IndexModule.FederationHost>;
|
|
217
|
+
// constructor(...args: ConstructorParameters<typeof IndexModule.FederationHost>) {
|
|
218
|
+
// this._args = args;
|
|
219
|
+
// return new Proxy(this, {
|
|
220
|
+
// get(target, prop) {
|
|
221
|
+
// if (prop in target) {
|
|
222
|
+
// return target[prop as keyof FederationHost];
|
|
223
|
+
// }
|
|
224
|
+
// const instance = target._getInstance();
|
|
225
|
+
// const value = instance[prop as keyof IndexModule.FederationHost];
|
|
226
|
+
// return typeof value === 'function' ? value.bind(instance) : value;
|
|
227
|
+
// },
|
|
228
|
+
// set(target, prop, value) {
|
|
229
|
+
// const instance = target._getInstance();
|
|
230
|
+
// instance[prop as keyof IndexModule.FederationHost] = value;
|
|
231
|
+
// return true;
|
|
232
|
+
// },
|
|
233
|
+
// });
|
|
234
|
+
// }
|
|
235
|
+
// private _getInstance(): IndexModule.FederationHost {
|
|
236
|
+
// if (!this._instance) {
|
|
237
|
+
// const RealFederationHost = getRuntime().FederationHost;
|
|
238
|
+
// this._instance = new RealFederationHost(...this._args);
|
|
239
|
+
// }
|
|
240
|
+
// return this._instance;
|
|
241
|
+
// }
|
|
242
|
+
// // Keep only the methods that have custom logic
|
|
243
|
+
// formatOptions(...args: Parameters<IndexModule.FederationHost['formatOptions']>) {
|
|
244
|
+
// return this._getInstance().formatOptions(...args);
|
|
245
|
+
// }
|
|
246
|
+
// }
|
|
247
|
+
//function createRuntimeFunction<T extends keyof typeof IndexModule>(
|
|
248
|
+
// name: T
|
|
249
|
+
// ): typeof IndexModule[T] {
|
|
250
|
+
// return (...args: any[]) => {
|
|
251
|
+
// return getRuntime()[name](...args);
|
|
252
|
+
// };
|
|
253
|
+
// }
|
|
254
|
+
// export const registerGlobalPlugins = createRuntimeFunction('registerGlobalPlugins');
|
|
255
|
+
// export const getRemoteEntry = createRuntimeFunction('getRemoteEntry');
|
|
256
|
+
// export const getRemoteInfo = createRuntimeFunction('getRemoteInfo');
|
|
257
|
+
// export const loadScript = createRuntimeFunction('loadScript');
|
|
258
|
+
// export const loadScriptNode = createRuntimeFunction('loadScriptNode');
|
|
259
|
+
// export const init = createRuntimeFunction('init');
|
|
260
|
+
// export const loadRemote = createRuntimeFunction('loadRemote');
|
|
261
|
+
// export const loadShare = createRuntimeFunction('loadShare');
|
|
262
|
+
// export const loadShareSync = createRuntimeFunction('loadShareSync');
|
|
263
|
+
// export const preloadRemote = createRuntimeFunction('preloadRemote');
|
|
264
|
+
// export const registerRemotes = createRuntimeFunction('registerRemotes');
|
|
265
|
+
// export const registerPlugins = createRuntimeFunction('registerPlugins');
|
|
266
|
+
// export const getInstance = createRuntimeFunction('getInstance');
|
|
6
267
|
|
|
7
268
|
exports.FederationHost = FederationHost;
|
|
269
|
+
exports.Module = Module;
|
|
8
270
|
exports.getInstance = getInstance;
|
|
9
271
|
exports.getRemoteEntry = getRemoteEntry;
|
|
10
272
|
exports.getRemoteInfo = getRemoteInfo;
|
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/index.cjs.js
CHANGED
|
@@ -1980,7 +1980,7 @@ class FederationHost {
|
|
|
1980
1980
|
// maybe will change, temporarily for internal use only
|
|
1981
1981
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1982
1982
|
});
|
|
1983
|
-
this.version = "0.6.
|
|
1983
|
+
this.version = "0.6.7";
|
|
1984
1984
|
this.moduleCache = new Map();
|
|
1985
1985
|
this.loaderHook = new PluginSystem({
|
|
1986
1986
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/index.esm.js
CHANGED
|
@@ -1978,7 +1978,7 @@ class FederationHost {
|
|
|
1978
1978
|
// maybe will change, temporarily for internal use only
|
|
1979
1979
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1980
1980
|
});
|
|
1981
|
-
this.version = "0.6.
|
|
1981
|
+
this.version = "0.6.7";
|
|
1982
1982
|
this.moduleCache = new Map();
|
|
1983
1983
|
this.loaderHook = new PluginSystem({
|
|
1984
1984
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/package.json
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.7";
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/dist/share.esm.js
CHANGED
|
@@ -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.7";
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
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.7"
|
|
54
54
|
}
|
|
55
55
|
}
|