@module-federation/runtime 1.0.0-canary.5 → 1.1.0-canary.1
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/LICENSE +21 -0
- package/helpers.esm.js +1 -1
- package/index.cjs.js +143 -451
- package/index.esm.js +137 -444
- package/package.json +3 -2
- package/share.cjs.js +42 -48
- package/share.esm.js +43 -45
- package/src/core.d.ts +11 -3
- package/src/global.d.ts +2 -2
- package/src/index.d.ts +1 -1
- package/src/plugins/snapshot/SnapshotHandler.d.ts +1 -0
- package/src/plugins/snapshot/index.d.ts +1 -1
- package/src/type/preload.d.ts +1 -0
- package/src/utils/index.d.ts +0 -1
- package/src/utils/manifest.d.ts +0 -2
- package/src/utils/dom.d.ts +0 -8
package/index.cjs.js
CHANGED
|
@@ -3,19 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var share = require('./share.cjs.js');
|
|
6
|
+
var sdk = require('@module-federation/sdk');
|
|
6
7
|
|
|
7
|
-
// Function to get the URL of a resource
|
|
8
|
-
function getResourceUrl(module, sourceUrl) {
|
|
9
|
-
if ('getPublicPath' in module) {
|
|
10
|
-
const publicPath = new Function(module.getPublicPath)();
|
|
11
|
-
return `${publicPath}${sourceUrl}`;
|
|
12
|
-
} else if ('publicPath' in module) {
|
|
13
|
-
return `${module.publicPath}${sourceUrl}`;
|
|
14
|
-
} else {
|
|
15
|
-
console.warn('Unable to retrieve resource URL. If in debug mode, this warning can be disregarded.', module, sourceUrl);
|
|
16
|
-
return '';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
8
|
// Function to match a remote with its name and expose
|
|
20
9
|
// id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
|
|
21
10
|
// id: alias(app1) + expose(button) = app1/button
|
|
@@ -80,75 +69,6 @@ function matchRemote(remotes, nameOrAlias) {
|
|
|
80
69
|
return;
|
|
81
70
|
}
|
|
82
71
|
|
|
83
|
-
function createScript(url, cb, attrs, createScriptHook) {
|
|
84
|
-
// Retrieve the existing script element by its src attribute
|
|
85
|
-
let script = null;
|
|
86
|
-
let needAttach = true;
|
|
87
|
-
const scripts = document.getElementsByTagName('script');
|
|
88
|
-
for(let i = 0; i < scripts.length; i++){
|
|
89
|
-
const s = scripts[i];
|
|
90
|
-
const scriptSrc = s.getAttribute('src');
|
|
91
|
-
if (scriptSrc && share.isStaticResourcesEqual(scriptSrc, url)) {
|
|
92
|
-
script = s;
|
|
93
|
-
needAttach = false;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (!script) {
|
|
98
|
-
script = document.createElement('script');
|
|
99
|
-
script.type = 'text/javascript';
|
|
100
|
-
script.src = url;
|
|
101
|
-
if (createScriptHook) {
|
|
102
|
-
const createScriptRes = createScriptHook(url);
|
|
103
|
-
if (createScriptRes instanceof HTMLScriptElement) {
|
|
104
|
-
script = createScriptRes;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (attrs) {
|
|
109
|
-
Object.keys(attrs).forEach((name)=>{
|
|
110
|
-
if (script) {
|
|
111
|
-
if (name === 'async' || name === 'defer') {
|
|
112
|
-
script[name] = attrs[name];
|
|
113
|
-
} else {
|
|
114
|
-
script.setAttribute(name, attrs[name]);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
const onScriptComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
-
event)=>{
|
|
121
|
-
// Prevent memory leaks in IE.
|
|
122
|
-
if (script) {
|
|
123
|
-
script.onerror = null;
|
|
124
|
-
script.onload = null;
|
|
125
|
-
share.safeWrapper(()=>{
|
|
126
|
-
(script == null ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
|
|
127
|
-
});
|
|
128
|
-
if (prev) {
|
|
129
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
|
-
const res = prev(event);
|
|
131
|
-
cb();
|
|
132
|
-
return res;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
cb();
|
|
136
|
-
};
|
|
137
|
-
script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
138
|
-
script.onload = onScriptComplete.bind(null, script.onload);
|
|
139
|
-
return {
|
|
140
|
-
script,
|
|
141
|
-
needAttach
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function loadScript(url, info) {
|
|
145
|
-
const { attrs, createScriptHook } = info;
|
|
146
|
-
return new Promise((resolve, _reject)=>{
|
|
147
|
-
const { script, needAttach } = createScript(url, resolve, attrs, createScriptHook);
|
|
148
|
-
needAttach && document.getElementsByTagName('head')[0].appendChild(script);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
72
|
function registerPlugins(plugins, hookInstances) {
|
|
153
73
|
const globalPlugins = share.getGlobalHostPlugins();
|
|
154
74
|
// Incorporate global plugins
|
|
@@ -168,347 +88,20 @@ function registerPlugins(plugins, hookInstances) {
|
|
|
168
88
|
}
|
|
169
89
|
}
|
|
170
90
|
|
|
171
|
-
function
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
function _define_property$2(obj, key, value) {
|
|
179
|
-
if (key in obj) {
|
|
180
|
-
Object.defineProperty(obj, key, {
|
|
181
|
-
value: value,
|
|
182
|
-
enumerable: true,
|
|
183
|
-
configurable: true,
|
|
184
|
-
writable: true
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
obj[key] = value;
|
|
188
|
-
}
|
|
189
|
-
return obj;
|
|
190
|
-
}
|
|
191
|
-
var MANIFEST_EXT = ".json";
|
|
192
|
-
var BROWSER_LOG_KEY = "''";
|
|
193
|
-
var BROWSER_LOG_VALUE = "1";
|
|
194
|
-
var NameTransformSymbol = {
|
|
195
|
-
AT: "@",
|
|
196
|
-
HYPHEN: "-",
|
|
197
|
-
SLASH: "/"
|
|
198
|
-
};
|
|
199
|
-
var _obj;
|
|
200
|
-
var NameTransformMap = (_obj = {}, _define_property$2(_obj, NameTransformSymbol.AT, "scope_"), _define_property$2(_obj, NameTransformSymbol.HYPHEN, "_"), _define_property$2(_obj, NameTransformSymbol.SLASH, "__"), _obj);
|
|
201
|
-
var _obj1;
|
|
202
|
-
(_obj1 = {}, _define_property$2(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$2(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$2(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH), _obj1);
|
|
203
|
-
var SEPARATOR = ":";
|
|
204
|
-
function isBrowserEnv() {
|
|
205
|
-
return typeof window !== "undefined";
|
|
206
|
-
}
|
|
207
|
-
function isDebugMode() {
|
|
208
|
-
if (typeof process !== "undefined" && process.env && process.env["''"]) {
|
|
209
|
-
return Boolean(process.env["''"]);
|
|
210
|
-
}
|
|
211
|
-
return Boolean('');
|
|
212
|
-
}
|
|
213
|
-
function _array_like_to_array$1(arr, len) {
|
|
214
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
215
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
216
|
-
return arr2;
|
|
217
|
-
}
|
|
218
|
-
function _array_without_holes(arr) {
|
|
219
|
-
if (Array.isArray(arr)) return _array_like_to_array$1(arr);
|
|
220
|
-
}
|
|
221
|
-
function _class_call_check(instance, Constructor) {
|
|
222
|
-
if (!_instanceof(instance, Constructor)) {
|
|
223
|
-
throw new TypeError("Cannot call a class as a function");
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
function _defineProperties(target, props) {
|
|
227
|
-
for(var i = 0; i < props.length; i++){
|
|
228
|
-
var descriptor = props[i];
|
|
229
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
230
|
-
descriptor.configurable = true;
|
|
231
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
232
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
236
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
237
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
238
|
-
return Constructor;
|
|
239
|
-
}
|
|
240
|
-
function _define_property$1(obj, key, value) {
|
|
241
|
-
if (key in obj) {
|
|
242
|
-
Object.defineProperty(obj, key, {
|
|
243
|
-
value: value,
|
|
244
|
-
enumerable: true,
|
|
245
|
-
configurable: true,
|
|
246
|
-
writable: true
|
|
247
|
-
});
|
|
248
|
-
} else {
|
|
249
|
-
obj[key] = value;
|
|
250
|
-
}
|
|
251
|
-
return obj;
|
|
252
|
-
}
|
|
253
|
-
function _iterable_to_array$1(iter) {
|
|
254
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
255
|
-
}
|
|
256
|
-
function _non_iterable_spread() {
|
|
257
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
258
|
-
}
|
|
259
|
-
function _to_consumable_array(arr) {
|
|
260
|
-
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread();
|
|
261
|
-
}
|
|
262
|
-
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
263
|
-
if (!o) return;
|
|
264
|
-
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
265
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
266
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
267
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
268
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
269
|
-
}
|
|
270
|
-
function safeToString(info) {
|
|
271
|
-
try {
|
|
272
|
-
return JSON.stringify(info, null, 2);
|
|
273
|
-
} catch (e) {
|
|
274
|
-
return "";
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
var DEBUG_LOG = "[ FEDERATION DEBUG ]";
|
|
278
|
-
var Logger = /*#__PURE__*/ function() {
|
|
279
|
-
function Logger(identifier) {
|
|
280
|
-
_class_call_check(this, Logger);
|
|
281
|
-
_define_property$1(this, "enable", false);
|
|
282
|
-
_define_property$1(this, "identifier", void 0);
|
|
283
|
-
this.identifier = identifier || DEBUG_LOG;
|
|
284
|
-
if (isBrowserEnv() && localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE) {
|
|
285
|
-
this.enable = true;
|
|
286
|
-
} else if (isDebugMode()) {
|
|
287
|
-
this.enable = true;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
_create_class(Logger, [
|
|
291
|
-
{
|
|
292
|
-
key: "info",
|
|
293
|
-
value: function info(msg, info) {
|
|
294
|
-
if (this.enable) {
|
|
295
|
-
var argsToString = safeToString(info) || "";
|
|
296
|
-
if (isBrowserEnv()) {
|
|
297
|
-
console.info("%c ".concat(this.identifier, ": ").concat(msg, " ").concat(argsToString), "color:#3300CC");
|
|
298
|
-
} else {
|
|
299
|
-
console.info("\x1b[34m%s", "".concat(this.identifier, ": ").concat(msg, " ").concat(argsToString ? "\n".concat(argsToString) : ""));
|
|
300
|
-
}
|
|
91
|
+
function _extends$5() {
|
|
92
|
+
_extends$5 = Object.assign || function(target) {
|
|
93
|
+
for(var i = 1; i < arguments.length; i++){
|
|
94
|
+
var source = arguments[i];
|
|
95
|
+
for(var key in source){
|
|
96
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
97
|
+
target[key] = source[key];
|
|
301
98
|
}
|
|
302
99
|
}
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
key: "logOriginalInfo",
|
|
306
|
-
value: function logOriginalInfo() {
|
|
307
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
308
|
-
args[_key] = arguments[_key];
|
|
309
|
-
}
|
|
310
|
-
if (this.enable) {
|
|
311
|
-
if (isBrowserEnv()) {
|
|
312
|
-
var _console;
|
|
313
|
-
console.info("%c ".concat(this.identifier, ": OriginalInfo"), "color:#3300CC");
|
|
314
|
-
(_console = console).log.apply(_console, _to_consumable_array(args));
|
|
315
|
-
} else {
|
|
316
|
-
var _console1;
|
|
317
|
-
console.info("%c ".concat(this.identifier, ": OriginalInfo"), "color:#3300CC");
|
|
318
|
-
(_console1 = console).log.apply(_console1, _to_consumable_array(args));
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
]);
|
|
324
|
-
return Logger;
|
|
325
|
-
}();
|
|
326
|
-
new Logger();
|
|
327
|
-
var composeKeyWithSeparator = function composeKeyWithSeparator() {
|
|
328
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
329
|
-
args[_key] = arguments[_key];
|
|
330
|
-
}
|
|
331
|
-
if (!args.length) {
|
|
332
|
-
return "";
|
|
333
|
-
}
|
|
334
|
-
return args.reduce(function(sum, cur) {
|
|
335
|
-
if (!cur) {
|
|
336
|
-
return sum;
|
|
337
|
-
}
|
|
338
|
-
if (!sum) {
|
|
339
|
-
return cur;
|
|
340
|
-
}
|
|
341
|
-
return "".concat(sum).concat(SEPARATOR).concat(cur);
|
|
342
|
-
}, "");
|
|
343
|
-
};
|
|
344
|
-
function _define_property(obj, key, value) {
|
|
345
|
-
if (key in obj) {
|
|
346
|
-
Object.defineProperty(obj, key, {
|
|
347
|
-
value: value,
|
|
348
|
-
enumerable: true,
|
|
349
|
-
configurable: true,
|
|
350
|
-
writable: true
|
|
351
|
-
});
|
|
352
|
-
} else {
|
|
353
|
-
obj[key] = value;
|
|
354
|
-
}
|
|
355
|
-
return obj;
|
|
356
|
-
}
|
|
357
|
-
function _object_spread(target) {
|
|
358
|
-
for(var i = 1; i < arguments.length; i++){
|
|
359
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
360
|
-
var ownKeys = Object.keys(source);
|
|
361
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
362
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
363
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
364
|
-
}));
|
|
365
|
-
}
|
|
366
|
-
ownKeys.forEach(function(key) {
|
|
367
|
-
_define_property(target, key, source[key]);
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
return target;
|
|
371
|
-
}
|
|
372
|
-
function ownKeys(object, enumerableOnly) {
|
|
373
|
-
var keys = Object.keys(object);
|
|
374
|
-
if (Object.getOwnPropertySymbols) {
|
|
375
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
376
|
-
if (enumerableOnly) {
|
|
377
|
-
symbols = symbols.filter(function(sym) {
|
|
378
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
keys.push.apply(keys, symbols);
|
|
382
|
-
}
|
|
383
|
-
return keys;
|
|
384
|
-
}
|
|
385
|
-
function _object_spread_props(target, source) {
|
|
386
|
-
source = source != null ? source : {};
|
|
387
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
388
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
389
|
-
} else {
|
|
390
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
391
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
return target;
|
|
395
|
-
}
|
|
396
|
-
var simpleJoinRemoteEntry = function simpleJoinRemoteEntry(rPath, rName) {
|
|
397
|
-
if (!rPath) {
|
|
398
|
-
return rName;
|
|
399
|
-
}
|
|
400
|
-
var transformPath = function transformPath(str) {
|
|
401
|
-
if (str === ".") {
|
|
402
|
-
return "";
|
|
403
|
-
}
|
|
404
|
-
if (str.startsWith("./")) {
|
|
405
|
-
return str.replace("./", "");
|
|
406
|
-
}
|
|
407
|
-
if (str.startsWith("/")) {
|
|
408
|
-
var strWithoutSlash = str.slice(1);
|
|
409
|
-
if (strWithoutSlash.endsWith("/")) {
|
|
410
|
-
return strWithoutSlash.slice(0, -1);
|
|
411
|
-
}
|
|
412
|
-
return strWithoutSlash;
|
|
413
|
-
}
|
|
414
|
-
return str;
|
|
415
|
-
};
|
|
416
|
-
var transformedPath = transformPath(rPath);
|
|
417
|
-
if (!transformedPath) {
|
|
418
|
-
return rName;
|
|
419
|
-
}
|
|
420
|
-
if (transformedPath.endsWith("/")) {
|
|
421
|
-
return "".concat(transformedPath).concat(rName);
|
|
422
|
-
}
|
|
423
|
-
return "".concat(transformedPath, "/").concat(rName);
|
|
424
|
-
};
|
|
425
|
-
// Priority: overrides > remotes
|
|
426
|
-
// eslint-disable-next-line max-lines-per-function
|
|
427
|
-
function generateSnapshotFromManifest(manifest) {
|
|
428
|
-
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
429
|
-
var _options_remotes = options.remotes, remotes = _options_remotes === void 0 ? {} : _options_remotes, _options_overrides = options.overrides, overrides = _options_overrides === void 0 ? {} : _options_overrides, version = options.version;
|
|
430
|
-
var remoteSnapshot;
|
|
431
|
-
var getPublicPath = function getPublicPath() {
|
|
432
|
-
if ("publicPath" in manifest.metaData) {
|
|
433
|
-
return manifest.metaData.publicPath;
|
|
434
|
-
} else {
|
|
435
|
-
return manifest.metaData.getPublicPath;
|
|
436
100
|
}
|
|
101
|
+
return target;
|
|
437
102
|
};
|
|
438
|
-
|
|
439
|
-
var remotesInfo = {};
|
|
440
|
-
// If remotes are not provided, only the remotes in the manifest will be read
|
|
441
|
-
if (!Object.keys(remotes).length) {
|
|
442
|
-
var _manifest_remotes;
|
|
443
|
-
remotesInfo = ((_manifest_remotes = manifest.remotes) === null || _manifest_remotes === void 0 ? void 0 : _manifest_remotes.reduce(function(res, next) {
|
|
444
|
-
var matchedVersion;
|
|
445
|
-
var name = next.federationContainerName;
|
|
446
|
-
// overrides have higher priority
|
|
447
|
-
if (overridesKeys.includes(name)) {
|
|
448
|
-
matchedVersion = overrides[name];
|
|
449
|
-
} else {
|
|
450
|
-
if ("version" in next) {
|
|
451
|
-
matchedVersion = next.version;
|
|
452
|
-
} else {
|
|
453
|
-
matchedVersion = next.entry;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
res[name] = {
|
|
457
|
-
matchedVersion: matchedVersion
|
|
458
|
-
};
|
|
459
|
-
return res;
|
|
460
|
-
}, {})) || {};
|
|
461
|
-
}
|
|
462
|
-
// If remotes (deploy scenario) are specified, they need to be traversed again
|
|
463
|
-
Object.keys(remotes).forEach(function(key) {
|
|
464
|
-
return remotesInfo[key] = {
|
|
465
|
-
// overrides will override dependencies
|
|
466
|
-
matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
|
|
467
|
-
};
|
|
468
|
-
});
|
|
469
|
-
var _manifest_metaData = manifest.metaData, _manifest_metaData_remoteEntry = _manifest_metaData.remoteEntry, remoteEntryPath = _manifest_metaData_remoteEntry.path, remoteEntryName = _manifest_metaData_remoteEntry.name, remoteEntryType = _manifest_metaData_remoteEntry.type, remoteTypes = _manifest_metaData.types, buildVersion = _manifest_metaData.buildInfo.buildVersion, globalName = _manifest_metaData.globalName;
|
|
470
|
-
var exposes = manifest.exposes;
|
|
471
|
-
var basicRemoteSnapshot = {
|
|
472
|
-
version: version ? version : "",
|
|
473
|
-
buildVersion: buildVersion,
|
|
474
|
-
globalName: globalName,
|
|
475
|
-
remoteEntry: simpleJoinRemoteEntry(remoteEntryPath, remoteEntryName),
|
|
476
|
-
remoteEntryType: remoteEntryType,
|
|
477
|
-
remoteTypes: simpleJoinRemoteEntry(remoteTypes.path, remoteTypes.name),
|
|
478
|
-
remotesInfo: remotesInfo,
|
|
479
|
-
shared: manifest === null || manifest === void 0 ? void 0 : manifest.shared.map(function(item) {
|
|
480
|
-
return {
|
|
481
|
-
assets: item.assets,
|
|
482
|
-
sharedName: item.name
|
|
483
|
-
};
|
|
484
|
-
}),
|
|
485
|
-
modules: exposes === null || exposes === void 0 ? void 0 : exposes.map(function(expose) {
|
|
486
|
-
return {
|
|
487
|
-
moduleName: expose.name,
|
|
488
|
-
modulePath: expose.path,
|
|
489
|
-
assets: expose.assets
|
|
490
|
-
};
|
|
491
|
-
})
|
|
492
|
-
};
|
|
493
|
-
if ("publicPath" in manifest.metaData) {
|
|
494
|
-
remoteSnapshot = _object_spread_props(_object_spread({}, basicRemoteSnapshot), {
|
|
495
|
-
publicPath: getPublicPath()
|
|
496
|
-
});
|
|
497
|
-
} else {
|
|
498
|
-
remoteSnapshot = _object_spread_props(_object_spread({}, basicRemoteSnapshot), {
|
|
499
|
-
getPublicPath: getPublicPath()
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
return remoteSnapshot;
|
|
103
|
+
return _extends$5.apply(this, arguments);
|
|
503
104
|
}
|
|
504
|
-
function isManifestProvider(moduleInfo) {
|
|
505
|
-
if ("remoteEntry" in moduleInfo && moduleInfo.remoteEntry.endsWith(MANIFEST_EXT)) {
|
|
506
|
-
return true;
|
|
507
|
-
} else {
|
|
508
|
-
return false;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
105
|
async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
513
106
|
return new Promise((resolve, reject)=>{
|
|
514
107
|
try {
|
|
@@ -528,7 +121,7 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
|
|
|
528
121
|
if (remoteEntryExports) {
|
|
529
122
|
return remoteEntryExports;
|
|
530
123
|
}
|
|
531
|
-
return loadScript(entry, {
|
|
124
|
+
return sdk.loadScript(entry, {
|
|
532
125
|
attrs: {},
|
|
533
126
|
createScriptHook
|
|
534
127
|
}).then(()=>{
|
|
@@ -544,7 +137,7 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
|
|
|
544
137
|
}
|
|
545
138
|
async function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook }) {
|
|
546
139
|
const { entry, name, type, entryGlobalName } = remoteInfo;
|
|
547
|
-
const uniqueKey = composeKeyWithSeparator(name, entry);
|
|
140
|
+
const uniqueKey = sdk.composeKeyWithSeparator(name, entry);
|
|
548
141
|
if (remoteEntryExports) {
|
|
549
142
|
return remoteEntryExports;
|
|
550
143
|
}
|
|
@@ -566,7 +159,7 @@ async function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook
|
|
|
566
159
|
return share.globalLoading[uniqueKey];
|
|
567
160
|
}
|
|
568
161
|
function getRemoteInfo(remote) {
|
|
569
|
-
return
|
|
162
|
+
return _extends$5({}, remote, {
|
|
570
163
|
entry: 'entry' in remote ? remote.entry : '',
|
|
571
164
|
type: remote.type || share.DEFAULT_REMOTE_TYPE,
|
|
572
165
|
entryGlobalName: remote.entryGlobalName || remote.name,
|
|
@@ -574,6 +167,20 @@ function getRemoteInfo(remote) {
|
|
|
574
167
|
});
|
|
575
168
|
}
|
|
576
169
|
|
|
170
|
+
function _extends$4() {
|
|
171
|
+
_extends$4 = Object.assign || function(target) {
|
|
172
|
+
for(var i = 1; i < arguments.length; i++){
|
|
173
|
+
var source = arguments[i];
|
|
174
|
+
for(var key in source){
|
|
175
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
176
|
+
target[key] = source[key];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return target;
|
|
181
|
+
};
|
|
182
|
+
return _extends$4.apply(this, arguments);
|
|
183
|
+
}
|
|
577
184
|
let Module = class Module {
|
|
578
185
|
async getEntry() {
|
|
579
186
|
if (this.remoteEntryExports) {
|
|
@@ -618,9 +225,9 @@ let Module = class Module {
|
|
|
618
225
|
region: this.hostInfo.region
|
|
619
226
|
};
|
|
620
227
|
remoteEntryExports.init(shareScope, [], remoteEntryInitOptions);
|
|
621
|
-
const federationInstance = share.Global.__FEDERATION__.__INSTANCES__.find((i)=>i.options.id === composeKeyWithSeparator(this.remoteInfo.name, this.remoteInfo.buildVersion));
|
|
228
|
+
const federationInstance = share.Global.__FEDERATION__.__INSTANCES__.find((i)=>i.options.id === sdk.composeKeyWithSeparator(this.remoteInfo.name, this.remoteInfo.buildVersion));
|
|
622
229
|
if (federationInstance) {
|
|
623
|
-
federationInstance.initOptions(
|
|
230
|
+
federationInstance.initOptions(_extends$4({}, remoteEntryInitOptions, {
|
|
624
231
|
remotes: [],
|
|
625
232
|
name: this.remoteInfo.name
|
|
626
233
|
}));
|
|
@@ -836,11 +443,26 @@ class PluginSystem {
|
|
|
836
443
|
}
|
|
837
444
|
}
|
|
838
445
|
|
|
446
|
+
function _extends$3() {
|
|
447
|
+
_extends$3 = Object.assign || function(target) {
|
|
448
|
+
for(var i = 1; i < arguments.length; i++){
|
|
449
|
+
var source = arguments[i];
|
|
450
|
+
for(var key in source){
|
|
451
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
452
|
+
target[key] = source[key];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return target;
|
|
457
|
+
};
|
|
458
|
+
return _extends$3.apply(this, arguments);
|
|
459
|
+
}
|
|
839
460
|
function defaultPreloadArgs(preloadConfig) {
|
|
840
|
-
return
|
|
461
|
+
return _extends$3({
|
|
841
462
|
resourceCategory: 'sync',
|
|
842
463
|
share: true,
|
|
843
|
-
depsRemote: true
|
|
464
|
+
depsRemote: true,
|
|
465
|
+
prefetchInterface: false
|
|
844
466
|
}, preloadConfig);
|
|
845
467
|
}
|
|
846
468
|
function formatPreloadArgs(remotes, preloadArgs) {
|
|
@@ -916,7 +538,7 @@ function preloadAssets(remoteInfo, host, assets) {
|
|
|
916
538
|
});
|
|
917
539
|
document.head.appendChild(fragment);
|
|
918
540
|
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
919
|
-
const { script: scriptEl } = createScript(jsUrl, ()=>{
|
|
541
|
+
const { script: scriptEl } = sdk.createScript(jsUrl, ()=>{
|
|
920
542
|
// noop
|
|
921
543
|
}, {}, (url)=>{
|
|
922
544
|
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
@@ -932,12 +554,26 @@ function preloadAssets(remoteInfo, host, assets) {
|
|
|
932
554
|
}
|
|
933
555
|
}
|
|
934
556
|
|
|
557
|
+
function _extends$2() {
|
|
558
|
+
_extends$2 = Object.assign || function(target) {
|
|
559
|
+
for(var i = 1; i < arguments.length; i++){
|
|
560
|
+
var source = arguments[i];
|
|
561
|
+
for(var key in source){
|
|
562
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
563
|
+
target[key] = source[key];
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return target;
|
|
568
|
+
};
|
|
569
|
+
return _extends$2.apply(this, arguments);
|
|
570
|
+
}
|
|
935
571
|
function assignRemoteInfo(remoteInfo, remoteSnapshot) {
|
|
936
572
|
if (!('remoteEntry' in remoteSnapshot) || !remoteSnapshot.remoteEntry) {
|
|
937
573
|
share.error(`The attribute remoteEntry of ${name} must not be undefined.`);
|
|
938
574
|
}
|
|
939
575
|
const { remoteEntry } = remoteSnapshot;
|
|
940
|
-
const entryUrl = getResourceUrl(remoteSnapshot, remoteEntry);
|
|
576
|
+
const entryUrl = sdk.getResourceUrl(remoteSnapshot, remoteEntry);
|
|
941
577
|
remoteInfo.type = remoteSnapshot.remoteEntryType;
|
|
942
578
|
remoteInfo.entryGlobalName = remoteSnapshot.globalName;
|
|
943
579
|
remoteInfo.entry = entryUrl;
|
|
@@ -947,7 +583,7 @@ function assignRemoteInfo(remoteInfo, remoteSnapshot) {
|
|
|
947
583
|
function snapshotPlugin() {
|
|
948
584
|
return {
|
|
949
585
|
name: 'snapshot-plugin',
|
|
950
|
-
async
|
|
586
|
+
async afterResolve (args) {
|
|
951
587
|
const { remote, pkgNameOrAlias, expose, origin, remoteInfo } = args;
|
|
952
588
|
if (!share.isRemoteInfoWithEntry(remote) || !share.isPureRemoteEntry(remote)) {
|
|
953
589
|
const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo(remote);
|
|
@@ -976,6 +612,9 @@ function snapshotPlugin() {
|
|
|
976
612
|
if (assets) {
|
|
977
613
|
preloadAssets(remoteInfo, origin, assets);
|
|
978
614
|
}
|
|
615
|
+
return _extends$2({}, args, {
|
|
616
|
+
remoteSnapshot
|
|
617
|
+
});
|
|
979
618
|
}
|
|
980
619
|
return args;
|
|
981
620
|
}
|
|
@@ -1008,7 +647,7 @@ function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo =
|
|
|
1008
647
|
const id = share.getFMId(remoteInfo);
|
|
1009
648
|
const { value: snapshotValue } = share.getInfoWithoutType(globalSnapshot, id, getModuleInfoHook);
|
|
1010
649
|
const effectiveRemoteSnapshot = remoteSnapshot || snapshotValue;
|
|
1011
|
-
if (effectiveRemoteSnapshot && !isManifestProvider(effectiveRemoteSnapshot)) {
|
|
650
|
+
if (effectiveRemoteSnapshot && !sdk.isManifestProvider(effectiveRemoteSnapshot)) {
|
|
1012
651
|
traverse(effectiveRemoteSnapshot, remoteInfo, isRoot);
|
|
1013
652
|
if (effectiveRemoteSnapshot.remotesInfo) {
|
|
1014
653
|
const remoteKeys = Object.keys(effectiveRemoteSnapshot.remotesInfo);
|
|
@@ -1061,7 +700,7 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
|
|
|
1061
700
|
return;
|
|
1062
701
|
}
|
|
1063
702
|
}
|
|
1064
|
-
const remoteEntryUrl = getResourceUrl(moduleInfoSnapshot, 'remoteEntry' in moduleInfoSnapshot ? moduleInfoSnapshot.remoteEntry : '');
|
|
703
|
+
const remoteEntryUrl = sdk.getResourceUrl(moduleInfoSnapshot, 'remoteEntry' in moduleInfoSnapshot ? moduleInfoSnapshot.remoteEntry : '');
|
|
1065
704
|
if (remoteEntryUrl) {
|
|
1066
705
|
entryAssets.push({
|
|
1067
706
|
name: remoteInfo.name,
|
|
@@ -1088,7 +727,7 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
|
|
|
1088
727
|
}, []);
|
|
1089
728
|
}
|
|
1090
729
|
function handleAssets(assets) {
|
|
1091
|
-
const assetsRes = assets.map((asset)=>getResourceUrl(moduleInfoSnapshot, asset));
|
|
730
|
+
const assetsRes = assets.map((asset)=>sdk.getResourceUrl(moduleInfoSnapshot, asset));
|
|
1092
731
|
if (preloadConfig.filter) {
|
|
1093
732
|
return assetsRes.filter(preloadConfig.filter);
|
|
1094
733
|
}
|
|
@@ -1099,6 +738,12 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
|
|
|
1099
738
|
for(let index = 0; index < assetsLength; index++){
|
|
1100
739
|
const assetsInfo = moduleAssetsInfo[index];
|
|
1101
740
|
const exposeFullPath = `${remoteInfo.name}/${assetsInfo.moduleName}`;
|
|
741
|
+
origin.hooks.lifecycle.handlePreloadModule.emit({
|
|
742
|
+
id: assetsInfo.moduleName === '.' ? remoteInfo.name : exposeFullPath,
|
|
743
|
+
name: remoteInfo.name,
|
|
744
|
+
remoteSnapshot: moduleInfoSnapshot,
|
|
745
|
+
preloadConfig
|
|
746
|
+
});
|
|
1102
747
|
const preloaded = share.getPreloaded(exposeFullPath);
|
|
1103
748
|
if (preloaded) {
|
|
1104
749
|
continue;
|
|
@@ -1185,6 +830,20 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1185
830
|
};
|
|
1186
831
|
};
|
|
1187
832
|
|
|
833
|
+
function _extends$1() {
|
|
834
|
+
_extends$1 = Object.assign || function(target) {
|
|
835
|
+
for(var i = 1; i < arguments.length; i++){
|
|
836
|
+
var source = arguments[i];
|
|
837
|
+
for(var key in source){
|
|
838
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
839
|
+
target[key] = source[key];
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return target;
|
|
844
|
+
};
|
|
845
|
+
return _extends$1.apply(this, arguments);
|
|
846
|
+
}
|
|
1188
847
|
class SnapshotHandler {
|
|
1189
848
|
async loadSnapshot(moduleInfo) {
|
|
1190
849
|
const { options } = this.HostInstance;
|
|
@@ -1236,7 +895,7 @@ class SnapshotHandler {
|
|
|
1236
895
|
return;
|
|
1237
896
|
}).value) {
|
|
1238
897
|
if ('version' in moduleInfo || 'entry' in moduleInfo) {
|
|
1239
|
-
hostSnapshot.remotesInfo =
|
|
898
|
+
hostSnapshot.remotesInfo = _extends$1({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
|
|
1240
899
|
[moduleInfo.name]: {
|
|
1241
900
|
matchedVersion: 'version' in moduleInfo ? moduleInfo.version : moduleInfo.entry
|
|
1242
901
|
}
|
|
@@ -1253,10 +912,10 @@ class SnapshotHandler {
|
|
|
1253
912
|
});
|
|
1254
913
|
// global snapshot includes manifest or module info includes manifest
|
|
1255
914
|
if (globalRemoteSnapshot) {
|
|
1256
|
-
if (isManifestProvider(globalRemoteSnapshot)) {
|
|
915
|
+
if (sdk.isManifestProvider(globalRemoteSnapshot)) {
|
|
1257
916
|
const moduleSnapshot = await this.getManifestJson(globalRemoteSnapshot.remoteEntry, moduleInfo, {});
|
|
1258
917
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1259
|
-
const globalSnapshotRes = share.setGlobalSnapshotInfoByModuleInfo(
|
|
918
|
+
const globalSnapshotRes = share.setGlobalSnapshotInfoByModuleInfo(_extends$1({}, moduleInfo), moduleSnapshot);
|
|
1260
919
|
return {
|
|
1261
920
|
remoteSnapshot: moduleSnapshot,
|
|
1262
921
|
globalSnapshot: globalSnapshotRes
|
|
@@ -1374,7 +1033,10 @@ class SnapshotHandler {
|
|
|
1374
1033
|
return manifestJson;
|
|
1375
1034
|
}
|
|
1376
1035
|
try {
|
|
1377
|
-
|
|
1036
|
+
let res = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {});
|
|
1037
|
+
if (!res || !(res instanceof Response)) {
|
|
1038
|
+
res = await fetch(manifestUrl, {});
|
|
1039
|
+
}
|
|
1378
1040
|
manifestJson = await res.json();
|
|
1379
1041
|
share.assert(manifestJson.metaData && manifestJson.exposes && manifestJson.shared, `${manifestUrl} is not a federation manifest`);
|
|
1380
1042
|
this.manifestCache.set(manifestUrl, manifestJson);
|
|
@@ -1387,7 +1049,7 @@ class SnapshotHandler {
|
|
|
1387
1049
|
};
|
|
1388
1050
|
const asyncLoadProcess = async ()=>{
|
|
1389
1051
|
const manifestJson = await getManifest();
|
|
1390
|
-
const remoteSnapshot = generateSnapshotFromManifest(manifestJson, {
|
|
1052
|
+
const remoteSnapshot = sdk.generateSnapshotFromManifest(manifestJson, {
|
|
1391
1053
|
version: manifestUrl
|
|
1392
1054
|
});
|
|
1393
1055
|
const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
@@ -1415,9 +1077,36 @@ class SnapshotHandler {
|
|
|
1415
1077
|
});
|
|
1416
1078
|
this.manifestLoading = share.Global.__FEDERATION__.__MANIFEST_LOADING__;
|
|
1417
1079
|
this.HostInstance = HostInstance;
|
|
1080
|
+
this.loaderHook = HostInstance.loaderHook;
|
|
1418
1081
|
}
|
|
1419
1082
|
}
|
|
1420
1083
|
|
|
1084
|
+
function _extends() {
|
|
1085
|
+
_extends = Object.assign || function(target) {
|
|
1086
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1087
|
+
var source = arguments[i];
|
|
1088
|
+
for(var key in source){
|
|
1089
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1090
|
+
target[key] = source[key];
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
return target;
|
|
1095
|
+
};
|
|
1096
|
+
return _extends.apply(this, arguments);
|
|
1097
|
+
}
|
|
1098
|
+
function _object_without_properties_loose(source, excluded) {
|
|
1099
|
+
if (source == null) return {};
|
|
1100
|
+
var target = {};
|
|
1101
|
+
var sourceKeys = Object.keys(source);
|
|
1102
|
+
var key, i;
|
|
1103
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
1104
|
+
key = sourceKeys[i];
|
|
1105
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
1106
|
+
target[key] = source[key];
|
|
1107
|
+
}
|
|
1108
|
+
return target;
|
|
1109
|
+
}
|
|
1421
1110
|
class FederationHost {
|
|
1422
1111
|
initOptions(userOptions) {
|
|
1423
1112
|
this.registerPlugins(userOptions.plugins);
|
|
@@ -1550,7 +1239,7 @@ class FederationHost {
|
|
|
1550
1239
|
`);
|
|
1551
1240
|
}
|
|
1552
1241
|
async _getRemoteModuleAndOptions(id) {
|
|
1553
|
-
const loadRemoteArgs = await this.hooks.lifecycle.
|
|
1242
|
+
const loadRemoteArgs = await this.hooks.lifecycle.beforeRequest.emit({
|
|
1554
1243
|
id,
|
|
1555
1244
|
options: this.options,
|
|
1556
1245
|
origin: this
|
|
@@ -1559,13 +1248,15 @@ class FederationHost {
|
|
|
1559
1248
|
const remoteSplitInfo = matchRemoteWithNameAndExpose(this.options.remotes, idRes);
|
|
1560
1249
|
share.assert(remoteSplitInfo, `
|
|
1561
1250
|
Unable to locate ${idRes} in ${this.options.name}. Potential reasons for failure include:\n
|
|
1562
|
-
1. ${idRes} was not included in the 'remotes' parameter of ${this.options.name}.\n
|
|
1251
|
+
1. ${idRes} was not included in the 'remotes' parameter of ${this.options.name || 'the host'}.\n
|
|
1563
1252
|
2. ${idRes} could not be found in the 'remotes' of ${this.options.name} with either 'name' or 'alias' attributes.
|
|
1564
|
-
3.
|
|
1253
|
+
3. ${idRes} is not online, injected, or loaded.
|
|
1254
|
+
4. ${idRes} cannot be accessed on the expected.
|
|
1255
|
+
5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${idRes}.
|
|
1565
1256
|
`);
|
|
1566
1257
|
const { remote: rawRemote } = remoteSplitInfo;
|
|
1567
1258
|
const remoteInfo = getRemoteInfo(rawRemote);
|
|
1568
|
-
const matchInfo = await this.hooks.lifecycle.
|
|
1259
|
+
const matchInfo = await this.hooks.lifecycle.afterResolve.emit(_extends({
|
|
1569
1260
|
id: idRes
|
|
1570
1261
|
}, remoteSplitInfo, {
|
|
1571
1262
|
options: this.options,
|
|
@@ -1573,7 +1264,7 @@ class FederationHost {
|
|
|
1573
1264
|
remoteInfo
|
|
1574
1265
|
}));
|
|
1575
1266
|
const { remote, expose } = matchInfo;
|
|
1576
|
-
share.assert(remote && expose, `The '
|
|
1267
|
+
share.assert(remote && expose, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${idRes}.`);
|
|
1577
1268
|
let module = this.moduleCache.get(remote.name);
|
|
1578
1269
|
const moduleOptions = {
|
|
1579
1270
|
hostInfo: {
|
|
@@ -1612,7 +1303,7 @@ class FederationHost {
|
|
|
1612
1303
|
const { module, moduleOptions, remoteMatchInfo } = await this._getRemoteModuleAndOptions(id);
|
|
1613
1304
|
const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
|
|
1614
1305
|
const moduleOrFactory = await module.get(expose, options);
|
|
1615
|
-
await this.hooks.lifecycle.
|
|
1306
|
+
await this.hooks.lifecycle.onLoad.emit({
|
|
1616
1307
|
id: idRes,
|
|
1617
1308
|
pkgNameOrAlias,
|
|
1618
1309
|
expose,
|
|
@@ -1712,7 +1403,7 @@ class FederationHost {
|
|
|
1712
1403
|
}
|
|
1713
1404
|
formatOptions(globalOptions, userOptions) {
|
|
1714
1405
|
const formatShareOptions = share.formatShareConfigs(userOptions.shared || {}, userOptions.name);
|
|
1715
|
-
const shared =
|
|
1406
|
+
const shared = _extends({}, globalOptions.shared, formatShareOptions);
|
|
1716
1407
|
const { userOptions: userOptionsRes, options: globalOptionsRes } = this.hooks.lifecycle.beforeInit.emit({
|
|
1717
1408
|
origin: this,
|
|
1718
1409
|
userOptions,
|
|
@@ -1773,7 +1464,7 @@ class FederationHost {
|
|
|
1773
1464
|
}
|
|
1774
1465
|
});
|
|
1775
1466
|
}
|
|
1776
|
-
const optionsRes =
|
|
1467
|
+
const optionsRes = _extends({}, globalOptions, userOptions, {
|
|
1777
1468
|
plugins,
|
|
1778
1469
|
remotes,
|
|
1779
1470
|
shared
|
|
@@ -1793,7 +1484,7 @@ class FederationHost {
|
|
|
1793
1484
|
}
|
|
1794
1485
|
setShared({ pkgName, shared, from, lib, loading, loaded, get }) {
|
|
1795
1486
|
const target = share.getGlobalShareScope();
|
|
1796
|
-
const { version, scope = 'default' } = shared, shareInfo =
|
|
1487
|
+
const { version, scope = 'default' } = shared, shareInfo = _object_without_properties_loose(shared, [
|
|
1797
1488
|
"version",
|
|
1798
1489
|
"scope"
|
|
1799
1490
|
]);
|
|
@@ -1817,7 +1508,7 @@ class FederationHost {
|
|
|
1817
1508
|
})} has been registered`);
|
|
1818
1509
|
return;
|
|
1819
1510
|
}
|
|
1820
|
-
target[sc][pkgName][version] =
|
|
1511
|
+
target[sc][pkgName][version] = _extends({
|
|
1821
1512
|
version,
|
|
1822
1513
|
scope: [
|
|
1823
1514
|
'default'
|
|
@@ -1836,9 +1527,10 @@ class FederationHost {
|
|
|
1836
1527
|
this.hooks = new PluginSystem({
|
|
1837
1528
|
beforeInit: new SyncWaterfallHook('beforeInit'),
|
|
1838
1529
|
init: new SyncHook(),
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1530
|
+
beforeRequest: new AsyncWaterfallHook('beforeRequest'),
|
|
1531
|
+
afterResolve: new AsyncWaterfallHook('afterResolve'),
|
|
1532
|
+
onLoad: new AsyncHook('onLoad'),
|
|
1533
|
+
handlePreloadModule: new SyncHook('handlePreloadModule'),
|
|
1842
1534
|
errorLoadRemote: new AsyncHook('errorLoadRemote'),
|
|
1843
1535
|
beforeLoadShare: new AsyncWaterfallHook('beforeLoadShare'),
|
|
1844
1536
|
loadShare: new AsyncHook(),
|
|
@@ -1846,12 +1538,13 @@ class FederationHost {
|
|
|
1846
1538
|
generatePreloadAssets: new AsyncHook('generatePreloadAssets'),
|
|
1847
1539
|
afterPreloadRemote: new AsyncHook()
|
|
1848
1540
|
});
|
|
1849
|
-
this.version = '1.0.
|
|
1541
|
+
this.version = '1.0.1-canary.1';
|
|
1850
1542
|
this.moduleCache = new Map();
|
|
1851
1543
|
this.loaderHook = new PluginSystem({
|
|
1852
1544
|
// FIXME: may not be suitable
|
|
1853
1545
|
getModuleInfo: new SyncHook(),
|
|
1854
|
-
createScript: new SyncHook()
|
|
1546
|
+
createScript: new SyncHook(),
|
|
1547
|
+
fetch: new AsyncHook('fetch')
|
|
1855
1548
|
});
|
|
1856
1549
|
this.loadingShare = {};
|
|
1857
1550
|
// TODO: Validate the details of the options
|
|
@@ -1921,7 +1614,6 @@ exports.registerGlobalPlugins = share.registerGlobalPlugins;
|
|
|
1921
1614
|
exports.FederationHost = FederationHost;
|
|
1922
1615
|
exports.init = init;
|
|
1923
1616
|
exports.loadRemote = loadRemote;
|
|
1924
|
-
exports.loadScript = loadScript;
|
|
1925
1617
|
exports.loadShare = loadShare;
|
|
1926
1618
|
exports.loadShareSync = loadShareSync;
|
|
1927
1619
|
exports.preloadRemote = preloadRemote;
|