@module-federation/bridge-vue3 0.0.0-next-20240923065315 → 0.0.0-next-20240923073245
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/CHANGELOG.md +3 -3
- package/dist/index.cjs.js +24 -24
- package/dist/index.d.ts +0 -9
- package/dist/index.es.js +524 -530
- package/package.json +3 -3
- package/src/create.ts +0 -1
- package/src/index.ts +0 -1
- package/src/lifecycle.ts +24 -13
- package/src/remoteApp.tsx +17 -11
package/dist/index.es.js
CHANGED
|
@@ -10,10 +10,10 @@ class g {
|
|
|
10
10
|
log(...e) {
|
|
11
11
|
var n, o;
|
|
12
12
|
if (this.isDebugEnabled) {
|
|
13
|
-
const r = `color: ${this.color}; font-weight: bold`,
|
|
13
|
+
const r = `color: ${this.color}; font-weight: bold`, s = `%c[${this.name}]`, l = ((o = (n = new Error().stack) == null ? void 0 : n.split(`
|
|
14
14
|
`)[2]) == null ? void 0 : o.trim()) || "Stack information not available";
|
|
15
|
-
typeof console < "u" && console.debug && console.debug(
|
|
16
|
-
(${
|
|
15
|
+
typeof console < "u" && console.debug && console.debug(s, r, ...e, `
|
|
16
|
+
(${l})`);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
stringToColor(e) {
|
|
@@ -22,8 +22,8 @@ class g {
|
|
|
22
22
|
n = e.charCodeAt(r) + ((n << 5) - n);
|
|
23
23
|
let o = "#";
|
|
24
24
|
for (let r = 0; r < 3; r++) {
|
|
25
|
-
const
|
|
26
|
-
o += ("00" +
|
|
25
|
+
const s = n >> r * 8 & 255;
|
|
26
|
+
o += ("00" + s.toString(16)).substr(-2);
|
|
27
27
|
}
|
|
28
28
|
return o;
|
|
29
29
|
}
|
|
@@ -38,24 +38,24 @@ function createBridgeComponent(t) {
|
|
|
38
38
|
return () => ({
|
|
39
39
|
__APP_VERSION__: "0.6.6",
|
|
40
40
|
render(n) {
|
|
41
|
-
var
|
|
41
|
+
var u;
|
|
42
42
|
LoggerInstance.log("createBridgeComponent render Info", n);
|
|
43
43
|
const o = Vue.createApp(t.rootComponent);
|
|
44
|
-
e.set(n.dom, o), (
|
|
44
|
+
e.set(n.dom, o), (u = t == null ? void 0 : t.renderLifecycle) == null || u.call(t, n);
|
|
45
45
|
const r = t.appOptions({
|
|
46
46
|
basename: n.basename,
|
|
47
47
|
memoryRoute: n.memoryRoute
|
|
48
|
-
}),
|
|
48
|
+
}), s = n.memoryRoute ? VueRouter.createMemoryHistory(n.basename) : VueRouter.createWebHistory(n.basename), l = VueRouter.createRouter({
|
|
49
49
|
...r.router.options,
|
|
50
|
-
history:
|
|
50
|
+
history: s,
|
|
51
51
|
routes: r.router.getRoutes()
|
|
52
52
|
});
|
|
53
53
|
LoggerInstance.log("createBridgeComponent render router info>>>", {
|
|
54
54
|
name: n.moduleName,
|
|
55
|
-
router:
|
|
56
|
-
}), n.memoryRoute ?
|
|
57
|
-
o.use(
|
|
58
|
-
}) : (o.use(
|
|
55
|
+
router: l
|
|
56
|
+
}), n.memoryRoute ? l.push(n.memoryRoute.entryPath).then(() => {
|
|
57
|
+
o.use(l), o.mount(n.dom);
|
|
58
|
+
}) : (o.use(l), o.mount(n.dom));
|
|
59
59
|
},
|
|
60
60
|
destroy(n) {
|
|
61
61
|
var r;
|
|
@@ -78,9 +78,9 @@ function _extends$1() {
|
|
|
78
78
|
function _object_without_properties_loose(t, e) {
|
|
79
79
|
if (t == null)
|
|
80
80
|
return {};
|
|
81
|
-
var n = {}, o = Object.keys(t), r,
|
|
82
|
-
for (
|
|
83
|
-
r = o[
|
|
81
|
+
var n = {}, o = Object.keys(t), r, s;
|
|
82
|
+
for (s = 0; s < o.length; s++)
|
|
83
|
+
r = o[s], !(e.indexOf(r) >= 0) && (n[r] = t[r]);
|
|
84
84
|
return n;
|
|
85
85
|
}
|
|
86
86
|
function _extends() {
|
|
@@ -154,8 +154,8 @@ const simpleJoinRemoteEntry = (t, e) => {
|
|
|
154
154
|
if (r.startsWith("./"))
|
|
155
155
|
return r.replace("./", "");
|
|
156
156
|
if (r.startsWith("/")) {
|
|
157
|
-
const
|
|
158
|
-
return
|
|
157
|
+
const s = r.slice(1);
|
|
158
|
+
return s.endsWith("/") ? s.slice(0, -1) : s;
|
|
159
159
|
}
|
|
160
160
|
return r;
|
|
161
161
|
})(t);
|
|
@@ -166,35 +166,35 @@ function inferAutoPublicPath(t) {
|
|
|
166
166
|
}
|
|
167
167
|
function generateSnapshotFromManifest(t, e = {}) {
|
|
168
168
|
var n, o;
|
|
169
|
-
const { remotes: r = {}, overrides:
|
|
170
|
-
let
|
|
171
|
-
const d = () => "publicPath" in t.metaData ? t.metaData.publicPath === "auto" &&
|
|
172
|
-
let
|
|
169
|
+
const { remotes: r = {}, overrides: s = {}, version: l } = e;
|
|
170
|
+
let u;
|
|
171
|
+
const d = () => "publicPath" in t.metaData ? t.metaData.publicPath === "auto" && l ? inferAutoPublicPath(l) : t.metaData.publicPath : t.metaData.getPublicPath, p = Object.keys(s);
|
|
172
|
+
let y = {};
|
|
173
173
|
if (!Object.keys(r).length) {
|
|
174
|
-
var
|
|
175
|
-
|
|
174
|
+
var _;
|
|
175
|
+
y = ((_ = t.remotes) == null ? void 0 : _.reduce((R, O) => {
|
|
176
176
|
let P;
|
|
177
177
|
const w = O.federationContainerName;
|
|
178
|
-
return p.includes(w) ? P =
|
|
178
|
+
return p.includes(w) ? P = s[w] : "version" in O ? P = O.version : P = O.entry, R[w] = {
|
|
179
179
|
matchedVersion: P
|
|
180
180
|
}, R;
|
|
181
181
|
}, {})) || {};
|
|
182
182
|
}
|
|
183
|
-
Object.keys(r).forEach((R) =>
|
|
183
|
+
Object.keys(r).forEach((R) => y[R] = {
|
|
184
184
|
// overrides will override dependencies
|
|
185
|
-
matchedVersion: p.includes(R) ?
|
|
185
|
+
matchedVersion: p.includes(R) ? s[R] : r[R]
|
|
186
186
|
});
|
|
187
|
-
const { remoteEntry: { path: m, name:
|
|
187
|
+
const { remoteEntry: { path: m, name: E, type: S }, types: $, buildInfo: { buildVersion: b }, globalName: v, ssrRemoteEntry: T } = t.metaData, { exposes: A } = t;
|
|
188
188
|
let I = {
|
|
189
|
-
version:
|
|
190
|
-
buildVersion:
|
|
189
|
+
version: l || "",
|
|
190
|
+
buildVersion: b,
|
|
191
191
|
globalName: v,
|
|
192
|
-
remoteEntry: simpleJoinRemoteEntry(m,
|
|
192
|
+
remoteEntry: simpleJoinRemoteEntry(m, E),
|
|
193
193
|
remoteEntryType: S,
|
|
194
194
|
remoteTypes: simpleJoinRemoteEntry($.path, $.name),
|
|
195
195
|
remoteTypesZip: $.zip || "",
|
|
196
196
|
remoteTypesAPI: $.api || "",
|
|
197
|
-
remotesInfo:
|
|
197
|
+
remotesInfo: y,
|
|
198
198
|
shared: t == null ? void 0 : t.shared.map((R) => ({
|
|
199
199
|
assets: R.assets,
|
|
200
200
|
sharedName: R.name,
|
|
@@ -219,15 +219,15 @@ function generateSnapshotFromManifest(t, e = {}) {
|
|
|
219
219
|
prefetchEntryType: P
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
|
-
if ("publicPath" in t.metaData ?
|
|
222
|
+
if ("publicPath" in t.metaData ? u = _extends({}, I, {
|
|
223
223
|
publicPath: d()
|
|
224
|
-
}) :
|
|
224
|
+
}) : u = _extends({}, I, {
|
|
225
225
|
getPublicPath: d()
|
|
226
226
|
}), T) {
|
|
227
227
|
const R = simpleJoinRemoteEntry(T.path, T.name);
|
|
228
|
-
|
|
228
|
+
u.ssrRemoteEntry = R, u.ssrRemoteEntryType = "commonjs-module";
|
|
229
229
|
}
|
|
230
|
-
return
|
|
230
|
+
return u;
|
|
231
231
|
}
|
|
232
232
|
function isManifestProvider(t) {
|
|
233
233
|
return !!("remoteEntry" in t && t.remoteEntry.includes(MANIFEST_EXT));
|
|
@@ -246,9 +246,9 @@ function isStaticResourcesEqual(t, e) {
|
|
|
246
246
|
}
|
|
247
247
|
function createScript(t) {
|
|
248
248
|
let e = null, n = !0, o = 2e4, r;
|
|
249
|
-
const
|
|
250
|
-
for (let
|
|
251
|
-
const d =
|
|
249
|
+
const s = document.getElementsByTagName("script");
|
|
250
|
+
for (let u = 0; u < s.length; u++) {
|
|
251
|
+
const d = s[u], p = d.getAttribute("src");
|
|
252
252
|
if (p && isStaticResourcesEqual(p, t.url)) {
|
|
253
253
|
e = d, n = !1;
|
|
254
254
|
break;
|
|
@@ -256,32 +256,32 @@ function createScript(t) {
|
|
|
256
256
|
}
|
|
257
257
|
if (!e) {
|
|
258
258
|
e = document.createElement("script"), e.type = "text/javascript", e.src = t.url;
|
|
259
|
-
let
|
|
260
|
-
t.createScriptHook && (
|
|
259
|
+
let u;
|
|
260
|
+
t.createScriptHook && (u = t.createScriptHook(t.url, t.attrs), u instanceof HTMLScriptElement ? e = u : typeof u == "object" && ("script" in u && u.script && (e = u.script), "timeout" in u && u.timeout && (o = u.timeout)));
|
|
261
261
|
const d = t.attrs;
|
|
262
|
-
d && !
|
|
262
|
+
d && !u && Object.keys(d).forEach((p) => {
|
|
263
263
|
e && (p === "async" || p === "defer" ? e[p] = d[p] : e.getAttribute(p) || e.setAttribute(p, d[p]));
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
|
-
const
|
|
266
|
+
const l = async (u, d) => {
|
|
267
267
|
var p;
|
|
268
268
|
if (clearTimeout(r), e && (e.onerror = null, e.onload = null, safeWrapper(() => {
|
|
269
269
|
const { needDeleteScript: m = !0 } = t;
|
|
270
270
|
m && e != null && e.parentNode && e.parentNode.removeChild(e);
|
|
271
|
-
}),
|
|
272
|
-
var
|
|
273
|
-
const m =
|
|
271
|
+
}), u && typeof u == "function")) {
|
|
272
|
+
var y;
|
|
273
|
+
const m = u(d);
|
|
274
274
|
if (m instanceof Promise) {
|
|
275
|
-
var
|
|
276
|
-
const
|
|
277
|
-
return t == null || (
|
|
275
|
+
var _;
|
|
276
|
+
const E = await m;
|
|
277
|
+
return t == null || (_ = t.cb) == null || _.call(t), E;
|
|
278
278
|
}
|
|
279
|
-
return t == null || (
|
|
279
|
+
return t == null || (y = t.cb) == null || y.call(t), m;
|
|
280
280
|
}
|
|
281
281
|
t == null || (p = t.cb) == null || p.call(t);
|
|
282
282
|
};
|
|
283
|
-
return e.onerror =
|
|
284
|
-
|
|
283
|
+
return e.onerror = l.bind(null, e.onerror), e.onload = l.bind(null, e.onload), r = setTimeout(() => {
|
|
284
|
+
l(null, new Error(`Remote script "${t.url}" time-outed.`));
|
|
285
285
|
}, o), {
|
|
286
286
|
script: e,
|
|
287
287
|
needAttach: n
|
|
@@ -290,28 +290,28 @@ function createScript(t) {
|
|
|
290
290
|
function createLink(t) {
|
|
291
291
|
let e = null, n = !0;
|
|
292
292
|
const o = document.getElementsByTagName("link");
|
|
293
|
-
for (let
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
e =
|
|
293
|
+
for (let s = 0; s < o.length; s++) {
|
|
294
|
+
const l = o[s], u = l.getAttribute("href"), d = l.getAttribute("ref");
|
|
295
|
+
if (u && isStaticResourcesEqual(u, t.url) && d === t.attrs.ref) {
|
|
296
|
+
e = l, n = !1;
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
if (!e) {
|
|
301
301
|
e = document.createElement("link"), e.setAttribute("href", t.url);
|
|
302
|
-
let
|
|
303
|
-
const
|
|
304
|
-
t.createLinkHook && (
|
|
305
|
-
e && !e.getAttribute(
|
|
302
|
+
let s;
|
|
303
|
+
const l = t.attrs;
|
|
304
|
+
t.createLinkHook && (s = t.createLinkHook(t.url, l), s instanceof HTMLLinkElement && (e = s)), l && !s && Object.keys(l).forEach((u) => {
|
|
305
|
+
e && !e.getAttribute(u) && e.setAttribute(u, l[u]);
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
|
-
const r = (
|
|
308
|
+
const r = (s, l) => {
|
|
309
309
|
if (e && (e.onerror = null, e.onload = null, safeWrapper(() => {
|
|
310
|
-
const { needDeleteLink:
|
|
311
|
-
|
|
312
|
-
}),
|
|
313
|
-
const
|
|
314
|
-
return t.cb(),
|
|
310
|
+
const { needDeleteLink: u = !0 } = t;
|
|
311
|
+
u && e != null && e.parentNode && e.parentNode.removeChild(e);
|
|
312
|
+
}), s)) {
|
|
313
|
+
const u = s(l);
|
|
314
|
+
return t.cb(), u;
|
|
315
315
|
}
|
|
316
316
|
t.cb();
|
|
317
317
|
};
|
|
@@ -322,8 +322,8 @@ function createLink(t) {
|
|
|
322
322
|
}
|
|
323
323
|
function loadScript(t, e) {
|
|
324
324
|
const { attrs: n = {}, createScriptHook: o } = e;
|
|
325
|
-
return new Promise((r,
|
|
326
|
-
const { script:
|
|
325
|
+
return new Promise((r, s) => {
|
|
326
|
+
const { script: l, needAttach: u } = createScript({
|
|
327
327
|
url: t,
|
|
328
328
|
cb: r,
|
|
329
329
|
attrs: _extends({
|
|
@@ -332,7 +332,7 @@ function loadScript(t, e) {
|
|
|
332
332
|
createScriptHook: o,
|
|
333
333
|
needDeleteScript: !0
|
|
334
334
|
});
|
|
335
|
-
|
|
335
|
+
u && document.head.appendChild(l);
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
338
|
function importNodeModule(t) {
|
|
@@ -346,7 +346,7 @@ const loadNodeFetch = async () => {
|
|
|
346
346
|
const t = await importNodeModule("node-fetch");
|
|
347
347
|
return t.default || t;
|
|
348
348
|
}, lazyLoaderHookFetch = async (t, e) => {
|
|
349
|
-
const n = __webpack_require__.federation.instance.loaderHook, r = await ((
|
|
349
|
+
const n = __webpack_require__.federation.instance.loaderHook, r = await ((s, l) => n.lifecycle.fetch.emit(s, l))(t, e || {});
|
|
350
350
|
return !r || !(r instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(t, e || {}) : r;
|
|
351
351
|
};
|
|
352
352
|
function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
@@ -406,12 +406,12 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
406
406
|
}
|
|
407
407
|
function loadScriptNode(t, e) {
|
|
408
408
|
return new Promise((n, o) => {
|
|
409
|
-
createScriptNode(t, (r,
|
|
409
|
+
createScriptNode(t, (r, s) => {
|
|
410
410
|
if (r)
|
|
411
411
|
o(r);
|
|
412
412
|
else {
|
|
413
|
-
var
|
|
414
|
-
const d = (e == null || (
|
|
413
|
+
var l, u;
|
|
414
|
+
const d = (e == null || (l = e.attrs) == null ? void 0 : l.globalName) || `__FEDERATION_${e == null || (u = e.attrs) == null ? void 0 : u.name}:custom__`, p = globalThis[d] = s;
|
|
415
415
|
n(p);
|
|
416
416
|
}
|
|
417
417
|
}, e.attrs, e.createScriptHook);
|
|
@@ -493,7 +493,7 @@ function includeOwnProperty(t, e) {
|
|
|
493
493
|
includeOwnProperty(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
494
494
|
const globalLoading = globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
495
495
|
function setGlobalDefaultVal(t) {
|
|
496
|
-
var e, n, o, r,
|
|
496
|
+
var e, n, o, r, s, l;
|
|
497
497
|
includeOwnProperty(t, "__VMOK__") && !includeOwnProperty(t, "__FEDERATION__") && definePropertyGlobalVal(t, "__FEDERATION__", t.__VMOK__), includeOwnProperty(t, "__FEDERATION__") || (definePropertyGlobalVal(t, "__FEDERATION__", {
|
|
498
498
|
__GLOBAL_PLUGIN__: [],
|
|
499
499
|
__INSTANCES__: [],
|
|
@@ -502,18 +502,18 @@ function setGlobalDefaultVal(t) {
|
|
|
502
502
|
__MANIFEST_LOADING__: {},
|
|
503
503
|
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
504
504
|
}), definePropertyGlobalVal(t, "__VMOK__", t.__FEDERATION__));
|
|
505
|
-
var
|
|
506
|
-
(
|
|
505
|
+
var u;
|
|
506
|
+
(u = (e = t.__FEDERATION__).__GLOBAL_PLUGIN__) != null || (e.__GLOBAL_PLUGIN__ = []);
|
|
507
507
|
var d;
|
|
508
508
|
(d = (n = t.__FEDERATION__).__INSTANCES__) != null || (n.__INSTANCES__ = []);
|
|
509
509
|
var p;
|
|
510
510
|
(p = (o = t.__FEDERATION__).moduleInfo) != null || (o.moduleInfo = {});
|
|
511
|
-
var _;
|
|
512
|
-
(_ = (r = t.__FEDERATION__).__SHARE__) != null || (r.__SHARE__ = {});
|
|
513
511
|
var y;
|
|
514
|
-
(y = (
|
|
512
|
+
(y = (r = t.__FEDERATION__).__SHARE__) != null || (r.__SHARE__ = {});
|
|
513
|
+
var _;
|
|
514
|
+
(_ = (s = t.__FEDERATION__).__MANIFEST_LOADING__) != null || (s.__MANIFEST_LOADING__ = {});
|
|
515
515
|
var m;
|
|
516
|
-
(m = (
|
|
516
|
+
(m = (l = t.__FEDERATION__).__PRELOADED_MAP__) != null || (l.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
517
517
|
}
|
|
518
518
|
setGlobalDefaultVal(globalThis);
|
|
519
519
|
setGlobalDefaultVal(nativeGlobal);
|
|
@@ -543,11 +543,11 @@ function getInfoWithoutType(t, e) {
|
|
|
543
543
|
{
|
|
544
544
|
const o = Object.keys(t);
|
|
545
545
|
for (const r of o) {
|
|
546
|
-
const [
|
|
546
|
+
const [s, l] = r.split(":"), u = `${s}:${e}`, d = t[u];
|
|
547
547
|
if (d)
|
|
548
548
|
return {
|
|
549
549
|
value: d,
|
|
550
|
-
key:
|
|
550
|
+
key: u
|
|
551
551
|
};
|
|
552
552
|
}
|
|
553
553
|
return {
|
|
@@ -563,11 +563,11 @@ const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTarge
|
|
|
563
563
|
if (o && !o.version && "version" in t && t.version && (o.version = t.version), o)
|
|
564
564
|
return o;
|
|
565
565
|
if ("version" in t && t.version) {
|
|
566
|
-
const { version: r } = t,
|
|
566
|
+
const { version: r } = t, s = _object_without_properties_loose(t, [
|
|
567
567
|
"version"
|
|
568
|
-
]),
|
|
569
|
-
if ((
|
|
570
|
-
return
|
|
568
|
+
]), l = getFMId(s), u = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, l).value;
|
|
569
|
+
if ((u == null ? void 0 : u.version) === r)
|
|
570
|
+
return u;
|
|
571
571
|
}
|
|
572
572
|
}, getGlobalSnapshotInfoByModuleInfo = (t) => getTargetSnapshotInfoByModuleInfo(t, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (t, e) => {
|
|
573
573
|
const n = getFMId(t);
|
|
@@ -631,8 +631,8 @@ class AsyncHook extends SyncHook {
|
|
|
631
631
|
const o = Array.from(this.listeners);
|
|
632
632
|
if (o.length > 0) {
|
|
633
633
|
let r = 0;
|
|
634
|
-
const
|
|
635
|
-
n =
|
|
634
|
+
const s = (l) => l === !1 ? !1 : r < o.length ? Promise.resolve(o[r++].apply(null, e)).then(s) : l;
|
|
635
|
+
n = s();
|
|
636
636
|
}
|
|
637
637
|
return Promise.resolve(n);
|
|
638
638
|
}
|
|
@@ -674,19 +674,19 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
674
674
|
const n = Array.from(this.listeners);
|
|
675
675
|
if (n.length > 0) {
|
|
676
676
|
let o = 0;
|
|
677
|
-
const r = (
|
|
678
|
-
if (checkReturnData(e,
|
|
679
|
-
if (e =
|
|
677
|
+
const r = (l) => (warn(l), this.onerror(l), e), s = (l) => {
|
|
678
|
+
if (checkReturnData(e, l)) {
|
|
679
|
+
if (e = l, o < n.length)
|
|
680
680
|
try {
|
|
681
|
-
return Promise.resolve(n[o++](e)).then(
|
|
682
|
-
} catch (
|
|
683
|
-
return r(
|
|
681
|
+
return Promise.resolve(n[o++](e)).then(s, r);
|
|
682
|
+
} catch (u) {
|
|
683
|
+
return r(u);
|
|
684
684
|
}
|
|
685
685
|
} else
|
|
686
686
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
687
687
|
return e;
|
|
688
688
|
};
|
|
689
|
-
return Promise.resolve(
|
|
689
|
+
return Promise.resolve(s(e));
|
|
690
690
|
}
|
|
691
691
|
return Promise.resolve(e);
|
|
692
692
|
}
|
|
@@ -740,7 +740,7 @@ function combineVersion(t, e, n, o) {
|
|
|
740
740
|
return o ? `${r}-${o}` : r;
|
|
741
741
|
}
|
|
742
742
|
function parseHyphen(t) {
|
|
743
|
-
return t.replace(parseRegex(hyphenRange), (e, n, o, r, l, u,
|
|
743
|
+
return t.replace(parseRegex(hyphenRange), (e, n, o, r, s, l, u, d, p, y, _, m) => (isXVersion(o) ? n = "" : isXVersion(r) ? n = `>=${o}.0.0` : isXVersion(s) ? n = `>=${o}.${r}.0` : n = `>=${n}`, isXVersion(p) ? d = "" : isXVersion(y) ? d = `<${Number(p) + 1}.0.0-0` : isXVersion(_) ? d = `<${p}.${Number(y) + 1}.0-0` : m ? d = `<=${p}.${y}.${_}-${m}` : d = `<=${d}`, `${n} ${d}`.trim()));
|
|
744
744
|
}
|
|
745
745
|
function parseComparatorTrim(t) {
|
|
746
746
|
return t.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -752,15 +752,15 @@ function parseCaretTrim(t) {
|
|
|
752
752
|
return t.replace(parseRegex(caretTrim), "$1^");
|
|
753
753
|
}
|
|
754
754
|
function parseCarets(t) {
|
|
755
|
-
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(caret), (n, o, r,
|
|
755
|
+
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(caret), (n, o, r, s, l) => isXVersion(o) ? "" : isXVersion(r) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(s) ? o === "0" ? `>=${o}.${r}.0 <${o}.${Number(r) + 1}.0-0` : `>=${o}.${r}.0 <${Number(o) + 1}.0.0-0` : l ? o === "0" ? r === "0" ? `>=${o}.${r}.${s}-${l} <${o}.${r}.${Number(s) + 1}-0` : `>=${o}.${r}.${s}-${l} <${o}.${Number(r) + 1}.0-0` : `>=${o}.${r}.${s}-${l} <${Number(o) + 1}.0.0-0` : o === "0" ? r === "0" ? `>=${o}.${r}.${s} <${o}.${r}.${Number(s) + 1}-0` : `>=${o}.${r}.${s} <${o}.${Number(r) + 1}.0-0` : `>=${o}.${r}.${s} <${Number(o) + 1}.0.0-0`)).join(" ");
|
|
756
756
|
}
|
|
757
757
|
function parseTildes(t) {
|
|
758
|
-
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(tilde), (n, o, r,
|
|
758
|
+
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(tilde), (n, o, r, s, l) => isXVersion(o) ? "" : isXVersion(r) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(s) ? `>=${o}.${r}.0 <${o}.${Number(r) + 1}.0-0` : l ? `>=${o}.${r}.${s}-${l} <${o}.${Number(r) + 1}.0-0` : `>=${o}.${r}.${s} <${o}.${Number(r) + 1}.0-0`)).join(" ");
|
|
759
759
|
}
|
|
760
760
|
function parseXRanges(t) {
|
|
761
|
-
return t.split(/\s+/).map((e) => e.trim().replace(parseRegex(xRange), (n, o, r, l, u
|
|
762
|
-
const d = isXVersion(r), p = d || isXVersion(
|
|
763
|
-
return o === "=" &&
|
|
761
|
+
return t.split(/\s+/).map((e) => e.trim().replace(parseRegex(xRange), (n, o, r, s, l, u) => {
|
|
762
|
+
const d = isXVersion(r), p = d || isXVersion(s), y = p || isXVersion(l);
|
|
763
|
+
return o === "=" && y && (o = ""), u = "", d ? o === ">" || o === "<" ? "<0.0.0-0" : "*" : o && y ? (p && (s = 0), l = 0, o === ">" ? (o = ">=", p ? (r = Number(r) + 1, s = 0, l = 0) : (s = Number(s) + 1, l = 0)) : o === "<=" && (o = "<", p ? r = Number(r) + 1 : s = Number(s) + 1), o === "<" && (u = "-0"), `${o + r}.${s}.${l}${u}`) : p ? `>=${r}.0.0${u} <${Number(r) + 1}.0.0-0` : y ? `>=${r}.${s}.0${u} <${r}.${Number(s) + 1}.0-0` : n;
|
|
764
764
|
})).join(" ");
|
|
765
765
|
}
|
|
766
766
|
function parseStar(t) {
|
|
@@ -780,10 +780,10 @@ function comparePreRelease(t, e) {
|
|
|
780
780
|
return -1;
|
|
781
781
|
if (n === void 0 && o === void 0)
|
|
782
782
|
return 0;
|
|
783
|
-
for (let r = 0,
|
|
784
|
-
const
|
|
785
|
-
if (
|
|
786
|
-
return
|
|
783
|
+
for (let r = 0, s = n.length; r <= s; r++) {
|
|
784
|
+
const l = n[r], u = o[r];
|
|
785
|
+
if (l !== u)
|
|
786
|
+
return l === void 0 && u === void 0 ? 0 : l ? u ? compareAtom(l, u) : -1 : 1;
|
|
787
787
|
}
|
|
788
788
|
return 0;
|
|
789
789
|
}
|
|
@@ -853,30 +853,30 @@ function parseRange(t) {
|
|
|
853
853
|
function satisfy(t, e) {
|
|
854
854
|
if (!t)
|
|
855
855
|
return !1;
|
|
856
|
-
const r = parseRange(e).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)),
|
|
857
|
-
if (!
|
|
856
|
+
const r = parseRange(e).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)), s = extractComparator(t);
|
|
857
|
+
if (!s)
|
|
858
858
|
return !1;
|
|
859
|
-
const [,
|
|
860
|
-
operator:
|
|
861
|
-
version: combineVersion(
|
|
862
|
-
major:
|
|
859
|
+
const [, l, , u, d, p, y] = s, _ = {
|
|
860
|
+
operator: l,
|
|
861
|
+
version: combineVersion(u, d, p, y),
|
|
862
|
+
major: u,
|
|
863
863
|
minor: d,
|
|
864
864
|
patch: p,
|
|
865
|
-
preRelease:
|
|
865
|
+
preRelease: y == null ? void 0 : y.split(".")
|
|
866
866
|
};
|
|
867
867
|
for (const m of r) {
|
|
868
|
-
const
|
|
869
|
-
if (!
|
|
868
|
+
const E = extractComparator(m);
|
|
869
|
+
if (!E)
|
|
870
870
|
return !1;
|
|
871
|
-
const [, S, , $,
|
|
871
|
+
const [, S, , $, b, v, T] = E, A = {
|
|
872
872
|
operator: S,
|
|
873
|
-
version: combineVersion($,
|
|
873
|
+
version: combineVersion($, b, v, T),
|
|
874
874
|
major: $,
|
|
875
|
-
minor:
|
|
875
|
+
minor: b,
|
|
876
876
|
patch: v,
|
|
877
877
|
preRelease: T == null ? void 0 : T.split(".")
|
|
878
878
|
};
|
|
879
|
-
if (!compare(A,
|
|
879
|
+
if (!compare(A, _))
|
|
880
880
|
return !1;
|
|
881
881
|
}
|
|
882
882
|
return !0;
|
|
@@ -886,7 +886,7 @@ function formatShare(t, e, n, o) {
|
|
|
886
886
|
"get" in t ? r = t.get : "lib" in t ? r = () => Promise.resolve(t.lib) : r = () => Promise.resolve(() => {
|
|
887
887
|
throw new Error(`Can not get shared '${n}'!`);
|
|
888
888
|
}), t.strategy && warn('"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"');
|
|
889
|
-
var l, u
|
|
889
|
+
var s, l, u;
|
|
890
890
|
return _extends$1({
|
|
891
891
|
deps: [],
|
|
892
892
|
useIn: [],
|
|
@@ -901,37 +901,37 @@ function formatShare(t, e, n, o) {
|
|
|
901
901
|
}, t.shareConfig),
|
|
902
902
|
get: r,
|
|
903
903
|
loaded: t != null && t.loaded || "lib" in t ? !0 : void 0,
|
|
904
|
-
version: (
|
|
904
|
+
version: (s = t.version) != null ? s : "0",
|
|
905
905
|
scope: Array.isArray(t.scope) ? t.scope : [
|
|
906
|
-
(
|
|
906
|
+
(l = t.scope) != null ? l : "default"
|
|
907
907
|
],
|
|
908
|
-
strategy: ((
|
|
908
|
+
strategy: ((u = t.strategy) != null ? u : o) || "version-first"
|
|
909
909
|
});
|
|
910
910
|
}
|
|
911
911
|
function formatShareConfigs(t, e) {
|
|
912
|
-
const n = e.shared || {}, o = e.name, r = Object.keys(n).reduce((
|
|
913
|
-
const d = arrayOptions(n[
|
|
914
|
-
return u
|
|
915
|
-
u
|
|
916
|
-
}),
|
|
917
|
-
}, {}),
|
|
918
|
-
return Object.keys(r).forEach((
|
|
919
|
-
l
|
|
920
|
-
l
|
|
921
|
-
}) : l
|
|
912
|
+
const n = e.shared || {}, o = e.name, r = Object.keys(n).reduce((l, u) => {
|
|
913
|
+
const d = arrayOptions(n[u]);
|
|
914
|
+
return l[u] = l[u] || [], d.forEach((p) => {
|
|
915
|
+
l[u].push(formatShare(p, o, u, e.shareStrategy));
|
|
916
|
+
}), l;
|
|
917
|
+
}, {}), s = _extends$1({}, t.shared);
|
|
918
|
+
return Object.keys(r).forEach((l) => {
|
|
919
|
+
s[l] ? r[l].forEach((u) => {
|
|
920
|
+
s[l].find((p) => p.version === u.version) || s[l].push(u);
|
|
921
|
+
}) : s[l] = r[l];
|
|
922
922
|
}), {
|
|
923
|
-
shared:
|
|
923
|
+
shared: s,
|
|
924
924
|
shareInfos: r
|
|
925
925
|
};
|
|
926
926
|
}
|
|
927
927
|
function versionLt(t, e) {
|
|
928
928
|
const n = (o) => {
|
|
929
929
|
if (!Number.isNaN(Number(o))) {
|
|
930
|
-
const
|
|
931
|
-
let
|
|
932
|
-
for (let
|
|
933
|
-
|
|
934
|
-
return
|
|
930
|
+
const s = o.split(".");
|
|
931
|
+
let l = o;
|
|
932
|
+
for (let u = 0; u < 3 - s.length; u++)
|
|
933
|
+
l += ".0";
|
|
934
|
+
return l;
|
|
935
935
|
}
|
|
936
936
|
return o;
|
|
937
937
|
};
|
|
@@ -944,14 +944,14 @@ const findVersion = (t, e) => {
|
|
|
944
944
|
return Object.keys(t).reduce((o, r) => !o || n(o, r) || o === "0" ? r : o, 0);
|
|
945
945
|
}, isLoaded = (t) => !!t.loaded || typeof t.lib == "function";
|
|
946
946
|
function findSingletonVersionOrderByVersion(t, e, n) {
|
|
947
|
-
const o = t[e][n], r = function(
|
|
948
|
-
return !isLoaded(o[
|
|
947
|
+
const o = t[e][n], r = function(s, l) {
|
|
948
|
+
return !isLoaded(o[s]) && versionLt(s, l);
|
|
949
949
|
};
|
|
950
950
|
return findVersion(t[e][n], r);
|
|
951
951
|
}
|
|
952
952
|
function findSingletonVersionOrderByLoaded(t, e, n) {
|
|
953
|
-
const o = t[e][n], r = function(
|
|
954
|
-
return isLoaded(o[
|
|
953
|
+
const o = t[e][n], r = function(s, l) {
|
|
954
|
+
return isLoaded(o[l]) ? isLoaded(o[s]) ? !!versionLt(s, l) : !0 : isLoaded(o[s]) ? !1 : versionLt(s, l);
|
|
955
955
|
};
|
|
956
956
|
return findVersion(t[e][n], r);
|
|
957
957
|
}
|
|
@@ -961,55 +961,55 @@ function getFindShareFunction(t) {
|
|
|
961
961
|
function getRegisteredShare(t, e, n, o) {
|
|
962
962
|
if (!t)
|
|
963
963
|
return;
|
|
964
|
-
const { shareConfig: r, scope:
|
|
965
|
-
|
|
964
|
+
const { shareConfig: r, scope: s = DEFAULT_SCOPE, strategy: l } = n, u = Array.isArray(s) ? s : [
|
|
965
|
+
s
|
|
966
966
|
];
|
|
967
|
-
for (const d of
|
|
967
|
+
for (const d of u)
|
|
968
968
|
if (r && t[d] && t[d][e]) {
|
|
969
|
-
const { requiredVersion: p } = r,
|
|
969
|
+
const { requiredVersion: p } = r, _ = getFindShareFunction(l)(t, d, e), m = () => {
|
|
970
970
|
if (r.singleton) {
|
|
971
|
-
if (typeof p == "string" && !satisfy(
|
|
972
|
-
const $ = `Version ${
|
|
971
|
+
if (typeof p == "string" && !satisfy(_, p)) {
|
|
972
|
+
const $ = `Version ${_} from ${_ && t[d][e][_].from} of shared singleton module ${e} does not satisfy the requirement of ${n.from} which needs ${p})`;
|
|
973
973
|
r.strictVersion ? error($) : warn($);
|
|
974
974
|
}
|
|
975
|
-
return t[d][e][
|
|
975
|
+
return t[d][e][_];
|
|
976
976
|
} else {
|
|
977
|
-
if (p === !1 || p === "*" || satisfy(
|
|
978
|
-
return t[d][e][
|
|
979
|
-
for (const [$,
|
|
977
|
+
if (p === !1 || p === "*" || satisfy(_, p))
|
|
978
|
+
return t[d][e][_];
|
|
979
|
+
for (const [$, b] of Object.entries(t[d][e]))
|
|
980
980
|
if (satisfy($, p))
|
|
981
|
-
return
|
|
981
|
+
return b;
|
|
982
982
|
}
|
|
983
|
-
},
|
|
983
|
+
}, E = {
|
|
984
984
|
shareScopeMap: t,
|
|
985
985
|
scope: d,
|
|
986
986
|
pkgName: e,
|
|
987
|
-
version:
|
|
987
|
+
version: _,
|
|
988
988
|
GlobalFederation: Global.__FEDERATION__,
|
|
989
989
|
resolver: m
|
|
990
990
|
};
|
|
991
|
-
return (o.emit(
|
|
991
|
+
return (o.emit(E) || E).resolver();
|
|
992
992
|
}
|
|
993
993
|
}
|
|
994
994
|
function getGlobalShareScope() {
|
|
995
995
|
return Global.__FEDERATION__.__SHARE__;
|
|
996
996
|
}
|
|
997
997
|
function getTargetSharedOptions(t) {
|
|
998
|
-
const { pkgName: e, extraOptions: n, shareInfos: o } = t, r = (
|
|
999
|
-
if (!
|
|
998
|
+
const { pkgName: e, extraOptions: n, shareInfos: o } = t, r = (u) => {
|
|
999
|
+
if (!u)
|
|
1000
1000
|
return;
|
|
1001
1001
|
const d = {};
|
|
1002
|
-
|
|
1003
|
-
d[
|
|
1002
|
+
u.forEach((_) => {
|
|
1003
|
+
d[_.version] = _;
|
|
1004
1004
|
});
|
|
1005
|
-
const
|
|
1006
|
-
return !isLoaded(d[
|
|
1005
|
+
const y = findVersion(d, function(_, m) {
|
|
1006
|
+
return !isLoaded(d[_]) && versionLt(_, m);
|
|
1007
1007
|
});
|
|
1008
|
-
return d[
|
|
1008
|
+
return d[y];
|
|
1009
1009
|
};
|
|
1010
|
-
var
|
|
1011
|
-
const
|
|
1012
|
-
return Object.assign({},
|
|
1010
|
+
var s;
|
|
1011
|
+
const l = (s = n == null ? void 0 : n.resolver) != null ? s : r;
|
|
1012
|
+
return Object.assign({}, l(o[e]), n == null ? void 0 : n.customShareInfo);
|
|
1013
1013
|
}
|
|
1014
1014
|
function matchRemoteWithNameAndExpose(t, e) {
|
|
1015
1015
|
for (const n of t) {
|
|
@@ -1017,9 +1017,9 @@ function matchRemoteWithNameAndExpose(t, e) {
|
|
|
1017
1017
|
let r = e.replace(n.name, "");
|
|
1018
1018
|
if (o) {
|
|
1019
1019
|
if (r.startsWith("/")) {
|
|
1020
|
-
const
|
|
1020
|
+
const u = n.name;
|
|
1021
1021
|
return r = `.${r}`, {
|
|
1022
|
-
pkgNameOrAlias:
|
|
1022
|
+
pkgNameOrAlias: u,
|
|
1023
1023
|
expose: r,
|
|
1024
1024
|
remote: n
|
|
1025
1025
|
};
|
|
@@ -1030,17 +1030,17 @@ function matchRemoteWithNameAndExpose(t, e) {
|
|
|
1030
1030
|
remote: n
|
|
1031
1031
|
};
|
|
1032
1032
|
}
|
|
1033
|
-
const
|
|
1034
|
-
let
|
|
1035
|
-
if (n.alias &&
|
|
1036
|
-
if (
|
|
1037
|
-
const
|
|
1038
|
-
return
|
|
1039
|
-
pkgNameOrAlias:
|
|
1040
|
-
expose:
|
|
1033
|
+
const s = n.alias && e.startsWith(n.alias);
|
|
1034
|
+
let l = n.alias && e.replace(n.alias, "");
|
|
1035
|
+
if (n.alias && s) {
|
|
1036
|
+
if (l && l.startsWith("/")) {
|
|
1037
|
+
const u = n.alias;
|
|
1038
|
+
return l = `.${l}`, {
|
|
1039
|
+
pkgNameOrAlias: u,
|
|
1040
|
+
expose: l,
|
|
1041
1041
|
remote: n
|
|
1042
1042
|
};
|
|
1043
|
-
} else if (
|
|
1043
|
+
} else if (l === "")
|
|
1044
1044
|
return {
|
|
1045
1045
|
pkgNameOrAlias: n.alias,
|
|
1046
1046
|
expose: ".",
|
|
@@ -1082,31 +1082,31 @@ async function loadEntryScript({ name: t, globalName: e, entry: n, createScriptH
|
|
|
1082
1082
|
const { entryExports: r } = getRemoteEntryExports(t, e);
|
|
1083
1083
|
return r || loadScript(n, {
|
|
1084
1084
|
attrs: {},
|
|
1085
|
-
createScriptHook: (
|
|
1086
|
-
const
|
|
1087
|
-
url:
|
|
1088
|
-
attrs:
|
|
1085
|
+
createScriptHook: (s, l) => {
|
|
1086
|
+
const u = o.emit({
|
|
1087
|
+
url: s,
|
|
1088
|
+
attrs: l
|
|
1089
1089
|
});
|
|
1090
|
-
if (
|
|
1091
|
-
return
|
|
1090
|
+
if (u && (u instanceof HTMLScriptElement || "script" in u || "timeout" in u))
|
|
1091
|
+
return u;
|
|
1092
1092
|
}
|
|
1093
1093
|
}).then(() => {
|
|
1094
|
-
const { remoteEntryKey:
|
|
1095
|
-
return assert(
|
|
1096
|
-
Unable to use the ${t}'s '${n}' URL with ${
|
|
1094
|
+
const { remoteEntryKey: s, entryExports: l } = getRemoteEntryExports(t, e);
|
|
1095
|
+
return assert(l, `
|
|
1096
|
+
Unable to use the ${t}'s '${n}' URL with ${s}'s globalName to get remoteEntry exports.
|
|
1097
1097
|
Possible reasons could be:
|
|
1098
1098
|
|
|
1099
1099
|
1. '${n}' is not the correct URL, or the remoteEntry resource or name is incorrect.
|
|
1100
1100
|
|
|
1101
|
-
2. ${
|
|
1102
|
-
`),
|
|
1103
|
-
}).catch((
|
|
1104
|
-
throw
|
|
1101
|
+
2. ${s} cannot be used to get remoteEntry exports in the window object.
|
|
1102
|
+
`), l;
|
|
1103
|
+
}).catch((s) => {
|
|
1104
|
+
throw s;
|
|
1105
1105
|
});
|
|
1106
1106
|
}
|
|
1107
1107
|
async function loadEntryDom({ remoteInfo: t, remoteEntryExports: e, createScriptHook: n }) {
|
|
1108
|
-
const { entry: o, entryGlobalName: r, name:
|
|
1109
|
-
switch (
|
|
1108
|
+
const { entry: o, entryGlobalName: r, name: s, type: l } = t;
|
|
1109
|
+
switch (l) {
|
|
1110
1110
|
case "esm":
|
|
1111
1111
|
case "module":
|
|
1112
1112
|
return loadEsmEntry({
|
|
@@ -1122,38 +1122,38 @@ async function loadEntryDom({ remoteInfo: t, remoteEntryExports: e, createScript
|
|
|
1122
1122
|
return loadEntryScript({
|
|
1123
1123
|
entry: o,
|
|
1124
1124
|
globalName: r,
|
|
1125
|
-
name:
|
|
1125
|
+
name: s,
|
|
1126
1126
|
createScriptHook: n
|
|
1127
1127
|
});
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
1130
|
async function loadEntryNode({ remoteInfo: t, createScriptHook: e }) {
|
|
1131
|
-
const { entry: n, entryGlobalName: o, name: r } = t, { entryExports:
|
|
1132
|
-
return
|
|
1131
|
+
const { entry: n, entryGlobalName: o, name: r } = t, { entryExports: s } = getRemoteEntryExports(r, o);
|
|
1132
|
+
return s || loadScriptNode(n, {
|
|
1133
1133
|
attrs: {
|
|
1134
1134
|
name: r,
|
|
1135
1135
|
globalName: o
|
|
1136
1136
|
},
|
|
1137
|
-
createScriptHook: (
|
|
1137
|
+
createScriptHook: (l, u) => {
|
|
1138
1138
|
const d = e.emit({
|
|
1139
|
-
url:
|
|
1140
|
-
attrs:
|
|
1139
|
+
url: l,
|
|
1140
|
+
attrs: u
|
|
1141
1141
|
});
|
|
1142
1142
|
if (d && "url" in d)
|
|
1143
1143
|
return d;
|
|
1144
1144
|
}
|
|
1145
1145
|
}).then(() => {
|
|
1146
|
-
const { remoteEntryKey:
|
|
1147
|
-
return assert(
|
|
1148
|
-
Unable to use the ${r}'s '${n}' URL with ${
|
|
1146
|
+
const { remoteEntryKey: l, entryExports: u } = getRemoteEntryExports(r, o);
|
|
1147
|
+
return assert(u, `
|
|
1148
|
+
Unable to use the ${r}'s '${n}' URL with ${l}'s globalName to get remoteEntry exports.
|
|
1149
1149
|
Possible reasons could be:
|
|
1150
1150
|
|
|
1151
1151
|
1. '${n}' is not the correct URL, or the remoteEntry resource or name is incorrect.
|
|
1152
1152
|
|
|
1153
|
-
2. ${
|
|
1154
|
-
`),
|
|
1155
|
-
}).catch((
|
|
1156
|
-
throw
|
|
1153
|
+
2. ${l} cannot be used to get remoteEntry exports in the window object.
|
|
1154
|
+
`), u;
|
|
1155
|
+
}).catch((l) => {
|
|
1156
|
+
throw l;
|
|
1157
1157
|
});
|
|
1158
1158
|
}
|
|
1159
1159
|
function getRemoteEntryUniqueKey(t) {
|
|
@@ -1171,16 +1171,16 @@ async function getRemoteEntry({ origin: t, remoteEntryExports: e, remoteInfo: n
|
|
|
1171
1171
|
createScriptHook: t.loaderHook.lifecycle.createScript,
|
|
1172
1172
|
remoteInfo: n,
|
|
1173
1173
|
remoteEntryExports: e
|
|
1174
|
-
}).then((
|
|
1174
|
+
}).then((s) => s || void 0);
|
|
1175
1175
|
else {
|
|
1176
|
-
const
|
|
1176
|
+
const s = t.loaderHook.lifecycle.createScript;
|
|
1177
1177
|
isBrowserEnv() ? globalLoading[o] = loadEntryDom({
|
|
1178
1178
|
remoteInfo: n,
|
|
1179
1179
|
remoteEntryExports: e,
|
|
1180
|
-
createScriptHook:
|
|
1180
|
+
createScriptHook: s
|
|
1181
1181
|
}) : globalLoading[o] = loadEntryNode({
|
|
1182
1182
|
remoteInfo: n,
|
|
1183
|
-
createScriptHook:
|
|
1183
|
+
createScriptHook: s
|
|
1184
1184
|
});
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
@@ -1208,46 +1208,46 @@ let Module = class {
|
|
|
1208
1208
|
}
|
|
1209
1209
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1210
1210
|
async get(e, n, o, r) {
|
|
1211
|
-
const { loadFactory:
|
|
1211
|
+
const { loadFactory: s = !0 } = o || {
|
|
1212
1212
|
loadFactory: !0
|
|
1213
|
-
},
|
|
1213
|
+
}, l = await this.getEntry();
|
|
1214
1214
|
if (!this.inited) {
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
const
|
|
1215
|
+
const _ = this.host.shareScopeMap, m = this.remoteInfo.shareScope || "default";
|
|
1216
|
+
_[m] || (_[m] = {});
|
|
1217
|
+
const E = _[m], S = [], $ = {
|
|
1218
1218
|
version: this.remoteInfo.version || ""
|
|
1219
1219
|
};
|
|
1220
1220
|
Object.defineProperty($, "shareScopeMap", {
|
|
1221
|
-
value:
|
|
1221
|
+
value: _,
|
|
1222
1222
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1223
1223
|
enumerable: !1
|
|
1224
1224
|
});
|
|
1225
|
-
const
|
|
1226
|
-
shareScope:
|
|
1225
|
+
const b = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1226
|
+
shareScope: E,
|
|
1227
1227
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1228
1228
|
remoteEntryInitOptions: $,
|
|
1229
1229
|
initScope: S,
|
|
1230
1230
|
remoteInfo: this.remoteInfo,
|
|
1231
1231
|
origin: this.host
|
|
1232
1232
|
});
|
|
1233
|
-
typeof (
|
|
1233
|
+
typeof (l == null ? void 0 : l.init) > "u" && console.error('The remote entry interface does not contain "init"', `
|
|
1234
1234
|
`, "Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]", `
|
|
1235
|
-
`, "Ensure that window[nameOfRemote] is returning a {get,init} object."), await
|
|
1235
|
+
`, "Ensure that window[nameOfRemote] is returning a {get,init} object."), await l.init(b.shareScope, b.initScope, b.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit(_extends$1({}, b, {
|
|
1236
1236
|
id: e,
|
|
1237
1237
|
remoteSnapshot: r,
|
|
1238
|
-
remoteEntryExports:
|
|
1238
|
+
remoteEntryExports: l
|
|
1239
1239
|
}));
|
|
1240
1240
|
}
|
|
1241
|
-
this.lib =
|
|
1242
|
-
const
|
|
1243
|
-
assert(
|
|
1244
|
-
const d = processModuleAlias(this.remoteInfo.name, n), p = this.wraperFactory(
|
|
1245
|
-
return
|
|
1241
|
+
this.lib = l, this.inited = !0;
|
|
1242
|
+
const u = await l.get(n);
|
|
1243
|
+
assert(u, `${getFMId(this.remoteInfo)} remote don't export ${n}.`);
|
|
1244
|
+
const d = processModuleAlias(this.remoteInfo.name, n), p = this.wraperFactory(u, d);
|
|
1245
|
+
return s ? await p() : p;
|
|
1246
1246
|
}
|
|
1247
1247
|
wraperFactory(e, n) {
|
|
1248
|
-
function o(r,
|
|
1248
|
+
function o(r, s) {
|
|
1249
1249
|
r && typeof r == "object" && Object.isExtensible(r) && !Object.getOwnPropertyDescriptor(r, Symbol.for("mf_module_id")) && Object.defineProperty(r, Symbol.for("mf_module_id"), {
|
|
1250
|
-
value:
|
|
1250
|
+
value: s,
|
|
1251
1251
|
enumerable: !1
|
|
1252
1252
|
});
|
|
1253
1253
|
}
|
|
@@ -1287,10 +1287,10 @@ function normalizePreloadExposes(t) {
|
|
|
1287
1287
|
return t ? t.map((e) => e === "." ? e : e.startsWith("./") ? e.replace("./", "") : e) : [];
|
|
1288
1288
|
}
|
|
1289
1289
|
function preloadAssets(t, e, n, o = !0) {
|
|
1290
|
-
const { cssAssets: r, jsAssetsWithoutEntry:
|
|
1290
|
+
const { cssAssets: r, jsAssetsWithoutEntry: s, entryAssets: l } = n;
|
|
1291
1291
|
if (e.options.inBrowser) {
|
|
1292
|
-
if (
|
|
1293
|
-
const { moduleInfo: d } =
|
|
1292
|
+
if (l.forEach((u) => {
|
|
1293
|
+
const { moduleInfo: d } = u, p = e.moduleCache.get(t.name);
|
|
1294
1294
|
getRemoteEntry(p ? {
|
|
1295
1295
|
origin: e,
|
|
1296
1296
|
remoteInfo: d,
|
|
@@ -1301,97 +1301,97 @@ function preloadAssets(t, e, n, o = !0) {
|
|
|
1301
1301
|
remoteEntryExports: void 0
|
|
1302
1302
|
});
|
|
1303
1303
|
}), o) {
|
|
1304
|
-
const
|
|
1304
|
+
const u = {
|
|
1305
1305
|
rel: "preload",
|
|
1306
1306
|
as: "style",
|
|
1307
1307
|
crossorigin: "anonymous"
|
|
1308
1308
|
};
|
|
1309
1309
|
r.forEach((d) => {
|
|
1310
|
-
const { link: p, needAttach:
|
|
1310
|
+
const { link: p, needAttach: y } = createLink({
|
|
1311
1311
|
url: d,
|
|
1312
1312
|
cb: () => {
|
|
1313
1313
|
},
|
|
1314
|
-
attrs:
|
|
1315
|
-
createLinkHook: (
|
|
1316
|
-
const
|
|
1317
|
-
url:
|
|
1314
|
+
attrs: u,
|
|
1315
|
+
createLinkHook: (_, m) => {
|
|
1316
|
+
const E = e.loaderHook.lifecycle.createLink.emit({
|
|
1317
|
+
url: _,
|
|
1318
1318
|
attrs: m
|
|
1319
1319
|
});
|
|
1320
|
-
if (
|
|
1321
|
-
return
|
|
1320
|
+
if (E instanceof HTMLLinkElement)
|
|
1321
|
+
return E;
|
|
1322
1322
|
}
|
|
1323
1323
|
});
|
|
1324
|
-
|
|
1324
|
+
y && document.head.appendChild(p);
|
|
1325
1325
|
});
|
|
1326
1326
|
} else {
|
|
1327
|
-
const
|
|
1327
|
+
const u = {
|
|
1328
1328
|
rel: "stylesheet",
|
|
1329
1329
|
type: "text/css"
|
|
1330
1330
|
};
|
|
1331
1331
|
r.forEach((d) => {
|
|
1332
|
-
const { link: p, needAttach:
|
|
1332
|
+
const { link: p, needAttach: y } = createLink({
|
|
1333
1333
|
url: d,
|
|
1334
1334
|
cb: () => {
|
|
1335
1335
|
},
|
|
1336
|
-
attrs:
|
|
1337
|
-
createLinkHook: (
|
|
1338
|
-
const
|
|
1339
|
-
url:
|
|
1336
|
+
attrs: u,
|
|
1337
|
+
createLinkHook: (_, m) => {
|
|
1338
|
+
const E = e.loaderHook.lifecycle.createLink.emit({
|
|
1339
|
+
url: _,
|
|
1340
1340
|
attrs: m
|
|
1341
1341
|
});
|
|
1342
|
-
if (
|
|
1343
|
-
return
|
|
1342
|
+
if (E instanceof HTMLLinkElement)
|
|
1343
|
+
return E;
|
|
1344
1344
|
},
|
|
1345
1345
|
needDeleteLink: !1
|
|
1346
1346
|
});
|
|
1347
|
-
|
|
1347
|
+
y && document.head.appendChild(p);
|
|
1348
1348
|
});
|
|
1349
1349
|
}
|
|
1350
1350
|
if (o) {
|
|
1351
|
-
const
|
|
1351
|
+
const u = {
|
|
1352
1352
|
rel: "preload",
|
|
1353
1353
|
as: "script",
|
|
1354
1354
|
crossorigin: "anonymous"
|
|
1355
1355
|
};
|
|
1356
|
-
|
|
1357
|
-
const { link: p, needAttach:
|
|
1356
|
+
s.forEach((d) => {
|
|
1357
|
+
const { link: p, needAttach: y } = createLink({
|
|
1358
1358
|
url: d,
|
|
1359
1359
|
cb: () => {
|
|
1360
1360
|
},
|
|
1361
|
-
attrs:
|
|
1362
|
-
createLinkHook: (
|
|
1363
|
-
const
|
|
1364
|
-
url:
|
|
1361
|
+
attrs: u,
|
|
1362
|
+
createLinkHook: (_, m) => {
|
|
1363
|
+
const E = e.loaderHook.lifecycle.createLink.emit({
|
|
1364
|
+
url: _,
|
|
1365
1365
|
attrs: m
|
|
1366
1366
|
});
|
|
1367
|
-
if (
|
|
1368
|
-
return
|
|
1367
|
+
if (E instanceof HTMLLinkElement)
|
|
1368
|
+
return E;
|
|
1369
1369
|
}
|
|
1370
1370
|
});
|
|
1371
|
-
|
|
1371
|
+
y && document.head.appendChild(p);
|
|
1372
1372
|
});
|
|
1373
1373
|
} else {
|
|
1374
|
-
const
|
|
1374
|
+
const u = {
|
|
1375
1375
|
fetchpriority: "high",
|
|
1376
1376
|
type: (t == null ? void 0 : t.type) === "module" ? "module" : "text/javascript"
|
|
1377
1377
|
};
|
|
1378
|
-
|
|
1379
|
-
const { script: p, needAttach:
|
|
1378
|
+
s.forEach((d) => {
|
|
1379
|
+
const { script: p, needAttach: y } = createScript({
|
|
1380
1380
|
url: d,
|
|
1381
1381
|
cb: () => {
|
|
1382
1382
|
},
|
|
1383
|
-
attrs:
|
|
1384
|
-
createScriptHook: (
|
|
1385
|
-
const
|
|
1386
|
-
url:
|
|
1383
|
+
attrs: u,
|
|
1384
|
+
createScriptHook: (_, m) => {
|
|
1385
|
+
const E = e.loaderHook.lifecycle.createScript.emit({
|
|
1386
|
+
url: _,
|
|
1387
1387
|
attrs: m
|
|
1388
1388
|
});
|
|
1389
|
-
if (
|
|
1390
|
-
return
|
|
1389
|
+
if (E instanceof HTMLScriptElement)
|
|
1390
|
+
return E;
|
|
1391
1391
|
},
|
|
1392
1392
|
needDeleteScript: !0
|
|
1393
1393
|
});
|
|
1394
|
-
|
|
1394
|
+
y && document.head.appendChild(p);
|
|
1395
1395
|
});
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
@@ -1406,10 +1406,10 @@ function snapshotPlugin() {
|
|
|
1406
1406
|
return {
|
|
1407
1407
|
name: "snapshot-plugin",
|
|
1408
1408
|
async afterResolve(t) {
|
|
1409
|
-
const { remote: e, pkgNameOrAlias: n, expose: o, origin: r, remoteInfo:
|
|
1409
|
+
const { remote: e, pkgNameOrAlias: n, expose: o, origin: r, remoteInfo: s } = t;
|
|
1410
1410
|
if (!isRemoteInfoWithEntry(e) || !isPureRemoteEntry(e)) {
|
|
1411
|
-
const { remoteSnapshot:
|
|
1412
|
-
assignRemoteInfo(
|
|
1411
|
+
const { remoteSnapshot: l, globalSnapshot: u } = await r.snapshotHandler.loadRemoteSnapshotInfo(e);
|
|
1412
|
+
assignRemoteInfo(s, l);
|
|
1413
1413
|
const d = {
|
|
1414
1414
|
remote: e,
|
|
1415
1415
|
preloadConfig: {
|
|
@@ -1424,13 +1424,13 @@ function snapshotPlugin() {
|
|
|
1424
1424
|
}, p = await r.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1425
1425
|
origin: r,
|
|
1426
1426
|
preloadOptions: d,
|
|
1427
|
-
remoteInfo:
|
|
1427
|
+
remoteInfo: s,
|
|
1428
1428
|
remote: e,
|
|
1429
|
-
remoteSnapshot:
|
|
1430
|
-
globalSnapshot:
|
|
1429
|
+
remoteSnapshot: l,
|
|
1430
|
+
globalSnapshot: u
|
|
1431
1431
|
});
|
|
1432
|
-
return p && preloadAssets(
|
|
1433
|
-
remoteSnapshot:
|
|
1432
|
+
return p && preloadAssets(s, r, p, !1), _extends$1({}, t, {
|
|
1433
|
+
remoteSnapshot: l
|
|
1434
1434
|
});
|
|
1435
1435
|
}
|
|
1436
1436
|
return t;
|
|
@@ -1450,76 +1450,76 @@ function splitId(t) {
|
|
|
1450
1450
|
version: e[2]
|
|
1451
1451
|
};
|
|
1452
1452
|
}
|
|
1453
|
-
function traverseModuleInfo(t, e, n, o, r = {},
|
|
1454
|
-
const
|
|
1453
|
+
function traverseModuleInfo(t, e, n, o, r = {}, s) {
|
|
1454
|
+
const l = getFMId(e), { value: u } = getInfoWithoutType(t, l), d = s || u;
|
|
1455
1455
|
if (d && !isManifestProvider(d) && (n(d, e, o), d.remotesInfo)) {
|
|
1456
1456
|
const p = Object.keys(d.remotesInfo);
|
|
1457
|
-
for (const
|
|
1458
|
-
if (r[
|
|
1457
|
+
for (const y of p) {
|
|
1458
|
+
if (r[y])
|
|
1459
1459
|
continue;
|
|
1460
|
-
r[
|
|
1461
|
-
const
|
|
1460
|
+
r[y] = !0;
|
|
1461
|
+
const _ = splitId(y), m = d.remotesInfo[y];
|
|
1462
1462
|
traverseModuleInfo(t, {
|
|
1463
|
-
name:
|
|
1463
|
+
name: _.name,
|
|
1464
1464
|
version: m.matchedVersion
|
|
1465
1465
|
}, n, !1, r, void 0);
|
|
1466
1466
|
}
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
1469
|
function generatePreloadAssets(t, e, n, o, r) {
|
|
1470
|
-
const
|
|
1471
|
-
if (traverseModuleInfo(o, n, (
|
|
1470
|
+
const s = [], l = [], u = [], d = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), { options: y } = t, { preloadConfig: _ } = e, { depsRemote: m } = _;
|
|
1471
|
+
if (traverseModuleInfo(o, n, (b, v, T) => {
|
|
1472
1472
|
let A;
|
|
1473
1473
|
if (T)
|
|
1474
|
-
A =
|
|
1474
|
+
A = _;
|
|
1475
1475
|
else if (Array.isArray(m)) {
|
|
1476
1476
|
const N = m.find((L) => L.nameOrAlias === v.name || L.nameOrAlias === v.alias);
|
|
1477
1477
|
if (!N)
|
|
1478
1478
|
return;
|
|
1479
1479
|
A = defaultPreloadArgs(N);
|
|
1480
1480
|
} else if (m === !0)
|
|
1481
|
-
A =
|
|
1481
|
+
A = _;
|
|
1482
1482
|
else
|
|
1483
1483
|
return;
|
|
1484
|
-
const I = getResourceUrl(
|
|
1485
|
-
I &&
|
|
1484
|
+
const I = getResourceUrl(b, getRemoteEntryInfoFromSnapshot(b).url);
|
|
1485
|
+
I && u.push({
|
|
1486
1486
|
name: v.name,
|
|
1487
1487
|
moduleInfo: {
|
|
1488
1488
|
name: v.name,
|
|
1489
1489
|
entry: I,
|
|
1490
|
-
type: "remoteEntryType" in
|
|
1491
|
-
entryGlobalName: "globalName" in
|
|
1490
|
+
type: "remoteEntryType" in b ? b.remoteEntryType : "global",
|
|
1491
|
+
entryGlobalName: "globalName" in b ? b.globalName : v.name,
|
|
1492
1492
|
shareScope: "",
|
|
1493
|
-
version: "version" in
|
|
1493
|
+
version: "version" in b ? b.version : void 0
|
|
1494
1494
|
},
|
|
1495
1495
|
url: I
|
|
1496
1496
|
});
|
|
1497
|
-
let R = "modules" in
|
|
1497
|
+
let R = "modules" in b ? b.modules : [];
|
|
1498
1498
|
const O = normalizePreloadExposes(A.exposes);
|
|
1499
|
-
if (O.length && "modules" in
|
|
1499
|
+
if (O.length && "modules" in b) {
|
|
1500
1500
|
var P;
|
|
1501
|
-
R =
|
|
1501
|
+
R = b == null || (P = b.modules) == null ? void 0 : P.reduce((N, L) => ((O == null ? void 0 : O.indexOf(L.moduleName)) !== -1 && N.push(L), N), []);
|
|
1502
1502
|
}
|
|
1503
1503
|
function w(N) {
|
|
1504
|
-
const L = N.map((k) => getResourceUrl(
|
|
1504
|
+
const L = N.map((k) => getResourceUrl(b, k));
|
|
1505
1505
|
return A.filter ? L.filter(A.filter) : L;
|
|
1506
1506
|
}
|
|
1507
1507
|
if (R) {
|
|
1508
1508
|
const N = R.length;
|
|
1509
1509
|
for (let L = 0; L < N; L++) {
|
|
1510
|
-
const k = R[L],
|
|
1510
|
+
const k = R[L], C = `${v.name}/${k.moduleName}`;
|
|
1511
1511
|
t.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1512
|
-
id: k.moduleName === "." ? v.name :
|
|
1512
|
+
id: k.moduleName === "." ? v.name : C,
|
|
1513
1513
|
name: v.name,
|
|
1514
|
-
remoteSnapshot:
|
|
1514
|
+
remoteSnapshot: b,
|
|
1515
1515
|
preloadConfig: A,
|
|
1516
1516
|
remote: v,
|
|
1517
1517
|
origin: t
|
|
1518
|
-
}), !getPreloaded(
|
|
1518
|
+
}), !getPreloaded(C) && (A.resourceCategory === "all" ? (s.push(...w(k.assets.css.async)), s.push(...w(k.assets.css.sync)), l.push(...w(k.assets.js.async)), l.push(...w(k.assets.js.sync))) : (A.resourceCategory = "sync") && (s.push(...w(k.assets.css.sync)), l.push(...w(k.assets.js.sync))), setPreloaded(C));
|
|
1519
1519
|
}
|
|
1520
1520
|
}
|
|
1521
1521
|
}, !0, {}, r), r.shared) {
|
|
1522
|
-
const
|
|
1522
|
+
const b = (v, T) => {
|
|
1523
1523
|
const A = getRegisteredShare(t.shareScopeMap, T.sharedName, v, t.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1524
1524
|
A && typeof A.lib == "function" && (T.assets.js.sync.forEach((I) => {
|
|
1525
1525
|
d.add(I);
|
|
@@ -1529,29 +1529,29 @@ function generatePreloadAssets(t, e, n, o, r) {
|
|
|
1529
1529
|
};
|
|
1530
1530
|
r.shared.forEach((v) => {
|
|
1531
1531
|
var T;
|
|
1532
|
-
const A = (T =
|
|
1532
|
+
const A = (T = y.shared) == null ? void 0 : T[v.sharedName];
|
|
1533
1533
|
if (!A)
|
|
1534
1534
|
return;
|
|
1535
1535
|
const I = v.version ? A.find((O) => O.version === v.version) : A;
|
|
1536
1536
|
if (!I)
|
|
1537
1537
|
return;
|
|
1538
1538
|
arrayOptions(I).forEach((O) => {
|
|
1539
|
-
|
|
1539
|
+
b(O, v);
|
|
1540
1540
|
});
|
|
1541
1541
|
});
|
|
1542
1542
|
}
|
|
1543
|
-
const S =
|
|
1543
|
+
const S = l.filter((b) => !d.has(b));
|
|
1544
1544
|
return {
|
|
1545
|
-
cssAssets:
|
|
1545
|
+
cssAssets: s.filter((b) => !p.has(b)),
|
|
1546
1546
|
jsAssetsWithoutEntry: S,
|
|
1547
|
-
entryAssets:
|
|
1547
|
+
entryAssets: u
|
|
1548
1548
|
};
|
|
1549
1549
|
}
|
|
1550
1550
|
const generatePreloadAssetsPlugin = function() {
|
|
1551
1551
|
return {
|
|
1552
1552
|
name: "generate-preload-assets-plugin",
|
|
1553
1553
|
async generatePreloadAssets(t) {
|
|
1554
|
-
const { origin: e, preloadOptions: n, remoteInfo: o, remote: r, globalSnapshot:
|
|
1554
|
+
const { origin: e, preloadOptions: n, remoteInfo: o, remote: r, globalSnapshot: s, remoteSnapshot: l } = t;
|
|
1555
1555
|
return isRemoteInfoWithEntry(r) && isPureRemoteEntry(r) ? {
|
|
1556
1556
|
cssAssets: [],
|
|
1557
1557
|
jsAssetsWithoutEntry: [],
|
|
@@ -1568,7 +1568,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1568
1568
|
}
|
|
1569
1569
|
}
|
|
1570
1570
|
]
|
|
1571
|
-
} : (assignRemoteInfo(o,
|
|
1571
|
+
} : (assignRemoteInfo(o, l), generatePreloadAssets(e, n, o, s, l));
|
|
1572
1572
|
}
|
|
1573
1573
|
};
|
|
1574
1574
|
};
|
|
@@ -1595,16 +1595,16 @@ function getGlobalRemoteInfo(t, e) {
|
|
|
1595
1595
|
}
|
|
1596
1596
|
class SnapshotHandler {
|
|
1597
1597
|
async loadSnapshot(e) {
|
|
1598
|
-
const { options: n } = this.HostInstance, { hostGlobalSnapshot: o, remoteSnapshot: r, globalSnapshot:
|
|
1598
|
+
const { options: n } = this.HostInstance, { hostGlobalSnapshot: o, remoteSnapshot: r, globalSnapshot: s } = this.getGlobalRemoteInfo(e), { remoteSnapshot: l, globalSnapshot: u } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1599
1599
|
options: n,
|
|
1600
1600
|
moduleInfo: e,
|
|
1601
1601
|
hostGlobalSnapshot: o,
|
|
1602
1602
|
remoteSnapshot: r,
|
|
1603
|
-
globalSnapshot:
|
|
1603
|
+
globalSnapshot: s
|
|
1604
1604
|
});
|
|
1605
1605
|
return {
|
|
1606
|
-
remoteSnapshot:
|
|
1607
|
-
globalSnapshot:
|
|
1606
|
+
remoteSnapshot: l,
|
|
1607
|
+
globalSnapshot: u
|
|
1608
1608
|
};
|
|
1609
1609
|
}
|
|
1610
1610
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -1629,39 +1629,39 @@ class SnapshotHandler {
|
|
|
1629
1629
|
matchedVersion: "version" in e ? e.version : e.entry
|
|
1630
1630
|
}
|
|
1631
1631
|
}));
|
|
1632
|
-
const { hostGlobalSnapshot: r, remoteSnapshot:
|
|
1632
|
+
const { hostGlobalSnapshot: r, remoteSnapshot: s, globalSnapshot: l } = this.getGlobalRemoteInfo(e), { remoteSnapshot: u, globalSnapshot: d } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1633
1633
|
options: n,
|
|
1634
1634
|
moduleInfo: e,
|
|
1635
1635
|
hostGlobalSnapshot: r,
|
|
1636
|
-
remoteSnapshot:
|
|
1637
|
-
globalSnapshot:
|
|
1636
|
+
remoteSnapshot: s,
|
|
1637
|
+
globalSnapshot: l
|
|
1638
1638
|
});
|
|
1639
|
-
let p,
|
|
1640
|
-
if (
|
|
1641
|
-
if (isManifestProvider(
|
|
1642
|
-
const
|
|
1639
|
+
let p, y;
|
|
1640
|
+
if (u)
|
|
1641
|
+
if (isManifestProvider(u)) {
|
|
1642
|
+
const _ = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "", m = await this.getManifestJson(_, e, {}), E = setGlobalSnapshotInfoByModuleInfo(_extends$1({}, e, {
|
|
1643
1643
|
// The global remote may be overridden
|
|
1644
1644
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1645
|
-
entry:
|
|
1645
|
+
entry: _
|
|
1646
1646
|
}), m);
|
|
1647
|
-
p = m,
|
|
1647
|
+
p = m, y = E;
|
|
1648
1648
|
} else {
|
|
1649
|
-
const { remoteSnapshot:
|
|
1649
|
+
const { remoteSnapshot: _ } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1650
1650
|
options: this.HostInstance.options,
|
|
1651
1651
|
moduleInfo: e,
|
|
1652
|
-
remoteSnapshot:
|
|
1652
|
+
remoteSnapshot: u,
|
|
1653
1653
|
from: "global"
|
|
1654
1654
|
});
|
|
1655
|
-
p =
|
|
1655
|
+
p = _, y = d;
|
|
1656
1656
|
}
|
|
1657
1657
|
else if (isRemoteInfoWithEntry(e)) {
|
|
1658
|
-
const
|
|
1658
|
+
const _ = await this.getManifestJson(e.entry, e, {}), m = setGlobalSnapshotInfoByModuleInfo(e, _), { remoteSnapshot: E } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1659
1659
|
options: this.HostInstance.options,
|
|
1660
1660
|
moduleInfo: e,
|
|
1661
|
-
remoteSnapshot:
|
|
1661
|
+
remoteSnapshot: _,
|
|
1662
1662
|
from: "global"
|
|
1663
1663
|
});
|
|
1664
|
-
p =
|
|
1664
|
+
p = E, y = m;
|
|
1665
1665
|
} else
|
|
1666
1666
|
error(`
|
|
1667
1667
|
Cannot get remoteSnapshot with the name: '${e.name}', version: '${e.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:
|
|
@@ -1678,7 +1678,7 @@ class SnapshotHandler {
|
|
|
1678
1678
|
remoteSnapshot: p
|
|
1679
1679
|
}), {
|
|
1680
1680
|
remoteSnapshot: p,
|
|
1681
|
-
globalSnapshot:
|
|
1681
|
+
globalSnapshot: y
|
|
1682
1682
|
};
|
|
1683
1683
|
}
|
|
1684
1684
|
getGlobalRemoteInfo(e) {
|
|
@@ -1686,33 +1686,33 @@ class SnapshotHandler {
|
|
|
1686
1686
|
}
|
|
1687
1687
|
async getManifestJson(e, n, o) {
|
|
1688
1688
|
const r = async () => {
|
|
1689
|
-
let
|
|
1690
|
-
if (
|
|
1691
|
-
return
|
|
1689
|
+
let l = this.manifestCache.get(e);
|
|
1690
|
+
if (l)
|
|
1691
|
+
return l;
|
|
1692
1692
|
try {
|
|
1693
|
-
let
|
|
1694
|
-
return (!
|
|
1695
|
-
} catch (
|
|
1693
|
+
let u = await this.loaderHook.lifecycle.fetch.emit(e, {});
|
|
1694
|
+
return (!u || !(u instanceof Response)) && (u = await fetch(e, {})), l = await u.json(), assert(l.metaData && l.exposes && l.shared, `${e} is not a federation manifest`), this.manifestCache.set(e, l), l;
|
|
1695
|
+
} catch (u) {
|
|
1696
1696
|
delete this.manifestLoading[e], error(`Failed to get manifestJson for ${n.name}. The manifest URL is ${e}. Please ensure that the manifestUrl is accessible.
|
|
1697
1697
|
|
|
1698
1698
|
Error message:
|
|
1699
1699
|
|
|
1700
|
-
${
|
|
1700
|
+
${u}`);
|
|
1701
1701
|
}
|
|
1702
|
-
},
|
|
1703
|
-
const
|
|
1702
|
+
}, s = async () => {
|
|
1703
|
+
const l = await r(), u = generateSnapshotFromManifest(l, {
|
|
1704
1704
|
version: e
|
|
1705
1705
|
}), { remoteSnapshot: d } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1706
1706
|
options: this.HostInstance.options,
|
|
1707
1707
|
moduleInfo: n,
|
|
1708
|
-
manifestJson:
|
|
1709
|
-
remoteSnapshot:
|
|
1708
|
+
manifestJson: l,
|
|
1709
|
+
remoteSnapshot: u,
|
|
1710
1710
|
manifestUrl: e,
|
|
1711
1711
|
from: "manifest"
|
|
1712
1712
|
});
|
|
1713
1713
|
return d;
|
|
1714
1714
|
};
|
|
1715
|
-
return this.manifestLoading[e] || (this.manifestLoading[e] =
|
|
1715
|
+
return this.manifestLoading[e] || (this.manifestLoading[e] = s().then((l) => l)), this.manifestLoading[e];
|
|
1716
1716
|
}
|
|
1717
1717
|
constructor(e) {
|
|
1718
1718
|
this.loadingHostSnapshot = null, this.manifestCache = /* @__PURE__ */ new Map(), this.hooks = new PluginSystem({
|
|
@@ -1727,10 +1727,10 @@ class SharedHandler {
|
|
|
1727
1727
|
// register shared in shareScopeMap
|
|
1728
1728
|
registerShared(e, n) {
|
|
1729
1729
|
const { shareInfos: o, shared: r } = formatShareConfigs(e, n);
|
|
1730
|
-
return Object.keys(o).forEach((
|
|
1731
|
-
o[
|
|
1732
|
-
!getRegisteredShare(this.shareScopeMap,
|
|
1733
|
-
pkgName:
|
|
1730
|
+
return Object.keys(o).forEach((l) => {
|
|
1731
|
+
o[l].forEach((d) => {
|
|
1732
|
+
!getRegisteredShare(this.shareScopeMap, l, d, this.hooks.lifecycle.resolveShare) && d && d.lib && this.setShared({
|
|
1733
|
+
pkgName: l,
|
|
1734
1734
|
lib: d.lib,
|
|
1735
1735
|
get: d.get,
|
|
1736
1736
|
loaded: !0,
|
|
@@ -1754,53 +1754,53 @@ class SharedHandler {
|
|
|
1754
1754
|
strategy: r.strategy
|
|
1755
1755
|
}));
|
|
1756
1756
|
}));
|
|
1757
|
-
const
|
|
1757
|
+
const s = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1758
1758
|
pkgName: e,
|
|
1759
1759
|
shareInfo: r,
|
|
1760
1760
|
shared: o.options.shared,
|
|
1761
1761
|
origin: o
|
|
1762
|
-
}), { shareInfo:
|
|
1763
|
-
assert(
|
|
1764
|
-
const
|
|
1762
|
+
}), { shareInfo: l } = s;
|
|
1763
|
+
assert(l, `Cannot find ${e} Share in the ${o.options.name}. Please ensure that the ${e} Share parameters have been injected`);
|
|
1764
|
+
const u = getRegisteredShare(this.shareScopeMap, e, l, this.hooks.lifecycle.resolveShare), d = (p) => {
|
|
1765
1765
|
p.useIn || (p.useIn = []), addUniqueItem(p.useIn, o.options.name);
|
|
1766
1766
|
};
|
|
1767
|
-
if (
|
|
1768
|
-
return d(
|
|
1769
|
-
if (
|
|
1770
|
-
const p = await
|
|
1771
|
-
return
|
|
1772
|
-
} else if (
|
|
1773
|
-
const
|
|
1774
|
-
const
|
|
1775
|
-
|
|
1776
|
-
const m = getRegisteredShare(this.shareScopeMap, e,
|
|
1777
|
-
return m && (m.lib =
|
|
1767
|
+
if (u && u.lib)
|
|
1768
|
+
return d(u), u.lib;
|
|
1769
|
+
if (u && u.loading && !u.loaded) {
|
|
1770
|
+
const p = await u.loading;
|
|
1771
|
+
return u.loaded = !0, u.lib || (u.lib = p), d(u), p;
|
|
1772
|
+
} else if (u) {
|
|
1773
|
+
const y = (async () => {
|
|
1774
|
+
const _ = await u.get();
|
|
1775
|
+
l.lib = _, l.loaded = !0, d(l);
|
|
1776
|
+
const m = getRegisteredShare(this.shareScopeMap, e, l, this.hooks.lifecycle.resolveShare);
|
|
1777
|
+
return m && (m.lib = _, m.loaded = !0), _;
|
|
1778
1778
|
})();
|
|
1779
1779
|
return this.setShared({
|
|
1780
1780
|
pkgName: e,
|
|
1781
1781
|
loaded: !1,
|
|
1782
|
-
shared:
|
|
1782
|
+
shared: u,
|
|
1783
1783
|
from: o.options.name,
|
|
1784
1784
|
lib: null,
|
|
1785
|
-
loading:
|
|
1786
|
-
}),
|
|
1785
|
+
loading: y
|
|
1786
|
+
}), y;
|
|
1787
1787
|
} else {
|
|
1788
1788
|
if (n != null && n.customShareInfo)
|
|
1789
1789
|
return !1;
|
|
1790
|
-
const
|
|
1791
|
-
const
|
|
1792
|
-
|
|
1793
|
-
const m = getRegisteredShare(this.shareScopeMap, e,
|
|
1794
|
-
return m && (m.lib =
|
|
1790
|
+
const y = (async () => {
|
|
1791
|
+
const _ = await l.get();
|
|
1792
|
+
l.lib = _, l.loaded = !0, d(l);
|
|
1793
|
+
const m = getRegisteredShare(this.shareScopeMap, e, l, this.hooks.lifecycle.resolveShare);
|
|
1794
|
+
return m && (m.lib = _, m.loaded = !0), _;
|
|
1795
1795
|
})();
|
|
1796
1796
|
return this.setShared({
|
|
1797
1797
|
pkgName: e,
|
|
1798
1798
|
loaded: !1,
|
|
1799
|
-
shared:
|
|
1799
|
+
shared: l,
|
|
1800
1800
|
from: o.options.name,
|
|
1801
1801
|
lib: null,
|
|
1802
|
-
loading:
|
|
1803
|
-
}),
|
|
1802
|
+
loading: y
|
|
1803
|
+
}), y;
|
|
1804
1804
|
}
|
|
1805
1805
|
}
|
|
1806
1806
|
/**
|
|
@@ -1810,43 +1810,43 @@ class SharedHandler {
|
|
|
1810
1810
|
*/
|
|
1811
1811
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1812
1812
|
initializeSharing(e = DEFAULT_SCOPE, n) {
|
|
1813
|
-
const { host: o } = this, r = n == null ? void 0 : n.from,
|
|
1814
|
-
let
|
|
1815
|
-
const
|
|
1813
|
+
const { host: o } = this, r = n == null ? void 0 : n.from, s = n == null ? void 0 : n.strategy;
|
|
1814
|
+
let l = n == null ? void 0 : n.initScope;
|
|
1815
|
+
const u = [];
|
|
1816
1816
|
if (r !== "build") {
|
|
1817
1817
|
const { initTokens: S } = this;
|
|
1818
|
-
|
|
1818
|
+
l || (l = []);
|
|
1819
1819
|
let $ = S[e];
|
|
1820
1820
|
if ($ || ($ = S[e] = {
|
|
1821
1821
|
from: this.host.name
|
|
1822
|
-
}),
|
|
1823
|
-
return
|
|
1824
|
-
|
|
1822
|
+
}), l.indexOf($) >= 0)
|
|
1823
|
+
return u;
|
|
1824
|
+
l.push($);
|
|
1825
1825
|
}
|
|
1826
1826
|
const d = this.shareScopeMap, p = o.options.name;
|
|
1827
1827
|
d[e] || (d[e] = {});
|
|
1828
|
-
const
|
|
1829
|
-
var
|
|
1828
|
+
const y = d[e], _ = (S, $) => {
|
|
1829
|
+
var b;
|
|
1830
1830
|
const { version: v, eager: T } = $;
|
|
1831
|
-
|
|
1832
|
-
const A =
|
|
1831
|
+
y[S] = y[S] || {};
|
|
1832
|
+
const A = y[S], I = A[v], R = !!(I && (I.eager || (b = I.shareConfig) != null && b.eager));
|
|
1833
1833
|
(!I || I.strategy !== "loaded-first" && !I.loaded && (!T != !R ? T : p > I.from)) && (A[v] = $);
|
|
1834
|
-
}, m = (S) => S && S.init && S.init(d[e],
|
|
1834
|
+
}, m = (S) => S && S.init && S.init(d[e], l), E = async (S) => {
|
|
1835
1835
|
const { module: $ } = await o.remoteHandler.getRemoteModuleAndOptions({
|
|
1836
1836
|
id: S
|
|
1837
1837
|
});
|
|
1838
1838
|
if ($.getEntry) {
|
|
1839
|
-
const
|
|
1840
|
-
$.inited || (await m(
|
|
1839
|
+
const b = await $.getEntry();
|
|
1840
|
+
$.inited || (await m(b), $.inited = !0);
|
|
1841
1841
|
}
|
|
1842
1842
|
};
|
|
1843
1843
|
return Object.keys(o.options.shared).forEach((S) => {
|
|
1844
|
-
o.options.shared[S].forEach((
|
|
1845
|
-
|
|
1844
|
+
o.options.shared[S].forEach((b) => {
|
|
1845
|
+
b.scope.includes(e) && _(S, b);
|
|
1846
1846
|
});
|
|
1847
|
-
}), (o.options.shareStrategy === "version-first" ||
|
|
1848
|
-
S.shareScope === e &&
|
|
1849
|
-
}),
|
|
1847
|
+
}), (o.options.shareStrategy === "version-first" || s === "version-first") && o.options.remotes.forEach((S) => {
|
|
1848
|
+
S.shareScope === e && u.push(E(S.name));
|
|
1849
|
+
}), u;
|
|
1850
1850
|
}
|
|
1851
1851
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
1852
1852
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
@@ -1858,34 +1858,34 @@ class SharedHandler {
|
|
|
1858
1858
|
extraOptions: n,
|
|
1859
1859
|
shareInfos: o.options.shared
|
|
1860
1860
|
});
|
|
1861
|
-
r != null && r.scope && r.scope.forEach((
|
|
1862
|
-
this.initializeSharing(
|
|
1861
|
+
r != null && r.scope && r.scope.forEach((u) => {
|
|
1862
|
+
this.initializeSharing(u, {
|
|
1863
1863
|
strategy: r.strategy
|
|
1864
1864
|
});
|
|
1865
1865
|
});
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1866
|
+
const s = getRegisteredShare(this.shareScopeMap, e, r, this.hooks.lifecycle.resolveShare), l = (u) => {
|
|
1867
|
+
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, o.options.name);
|
|
1868
1868
|
};
|
|
1869
|
-
if (
|
|
1870
|
-
if (typeof
|
|
1871
|
-
return
|
|
1872
|
-
if (typeof
|
|
1873
|
-
const
|
|
1874
|
-
if (!(
|
|
1875
|
-
return
|
|
1869
|
+
if (s) {
|
|
1870
|
+
if (typeof s.lib == "function")
|
|
1871
|
+
return l(s), s.loaded || (s.loaded = !0, s.from === o.options.name && (r.loaded = !0)), s.lib;
|
|
1872
|
+
if (typeof s.get == "function") {
|
|
1873
|
+
const u = s.get();
|
|
1874
|
+
if (!(u instanceof Promise))
|
|
1875
|
+
return l(s), this.setShared({
|
|
1876
1876
|
pkgName: e,
|
|
1877
1877
|
loaded: !0,
|
|
1878
1878
|
from: o.options.name,
|
|
1879
|
-
lib:
|
|
1880
|
-
shared:
|
|
1881
|
-
}),
|
|
1879
|
+
lib: u,
|
|
1880
|
+
shared: s
|
|
1881
|
+
}), u;
|
|
1882
1882
|
}
|
|
1883
1883
|
}
|
|
1884
1884
|
if (r.lib)
|
|
1885
1885
|
return r.loaded || (r.loaded = !0), r.lib;
|
|
1886
1886
|
if (r.get) {
|
|
1887
|
-
const
|
|
1888
|
-
if (
|
|
1887
|
+
const u = r.get();
|
|
1888
|
+
if (u instanceof Promise)
|
|
1889
1889
|
throw new Error(`
|
|
1890
1890
|
The loadShareSync function was unable to load ${e}. The ${e} could not be found in ${o.options.name}.
|
|
1891
1891
|
Possible reasons for failure:
|
|
@@ -1895,7 +1895,7 @@ class SharedHandler {
|
|
|
1895
1895
|
2. The ${e} share was not registered with the 'lib' attribute.
|
|
1896
1896
|
|
|
1897
1897
|
`);
|
|
1898
|
-
return r.lib =
|
|
1898
|
+
return r.lib = u, this.setShared({
|
|
1899
1899
|
pkgName: e,
|
|
1900
1900
|
loaded: !0,
|
|
1901
1901
|
from: o.options.name,
|
|
@@ -1923,8 +1923,8 @@ class SharedHandler {
|
|
|
1923
1923
|
hostShareScopeMap: o.hostShareScopeMap
|
|
1924
1924
|
});
|
|
1925
1925
|
}
|
|
1926
|
-
setShared({ pkgName: e, shared: n, from: o, lib: r, loading:
|
|
1927
|
-
const { version: d, scope: p = "default" } = n,
|
|
1926
|
+
setShared({ pkgName: e, shared: n, from: o, lib: r, loading: s, loaded: l, get: u }) {
|
|
1927
|
+
const { version: d, scope: p = "default" } = n, y = _object_without_properties_loose(n, [
|
|
1928
1928
|
"version",
|
|
1929
1929
|
"scope"
|
|
1930
1930
|
]);
|
|
@@ -1937,15 +1937,15 @@ class SharedHandler {
|
|
|
1937
1937
|
scope: [
|
|
1938
1938
|
"default"
|
|
1939
1939
|
]
|
|
1940
|
-
},
|
|
1940
|
+
}, y, {
|
|
1941
1941
|
lib: r,
|
|
1942
|
-
loaded:
|
|
1943
|
-
loading:
|
|
1944
|
-
}),
|
|
1942
|
+
loaded: l,
|
|
1943
|
+
loading: s
|
|
1944
|
+
}), u && (this.shareScopeMap[m][e][d].get = u);
|
|
1945
1945
|
return;
|
|
1946
1946
|
}
|
|
1947
|
-
const
|
|
1948
|
-
|
|
1947
|
+
const E = this.shareScopeMap[m][e][d];
|
|
1948
|
+
s && !E.loading && (E.loading = s);
|
|
1949
1949
|
});
|
|
1950
1950
|
}
|
|
1951
1951
|
_setGlobalShareScopeMap(e) {
|
|
@@ -1966,26 +1966,26 @@ class SharedHandler {
|
|
|
1966
1966
|
}
|
|
1967
1967
|
class RemoteHandler {
|
|
1968
1968
|
formatAndRegisterRemote(e, n) {
|
|
1969
|
-
return (n.remotes || []).reduce((r,
|
|
1969
|
+
return (n.remotes || []).reduce((r, s) => (this.registerRemote(s, r, {
|
|
1970
1970
|
force: !1
|
|
1971
1971
|
}), r), e.remotes);
|
|
1972
1972
|
}
|
|
1973
1973
|
setIdToRemoteMap(e, n) {
|
|
1974
|
-
const { remote: o, expose: r } = n, { name:
|
|
1974
|
+
const { remote: o, expose: r } = n, { name: s, alias: l } = o;
|
|
1975
1975
|
if (this.idToRemoteMap[e] = {
|
|
1976
1976
|
name: o.name,
|
|
1977
1977
|
expose: r
|
|
1978
|
-
},
|
|
1979
|
-
const
|
|
1980
|
-
this.idToRemoteMap[
|
|
1978
|
+
}, l && e.startsWith(s)) {
|
|
1979
|
+
const u = e.replace(s, l);
|
|
1980
|
+
this.idToRemoteMap[u] = {
|
|
1981
1981
|
name: o.name,
|
|
1982
1982
|
expose: r
|
|
1983
1983
|
};
|
|
1984
1984
|
return;
|
|
1985
1985
|
}
|
|
1986
|
-
if (
|
|
1987
|
-
const
|
|
1988
|
-
this.idToRemoteMap[
|
|
1986
|
+
if (l && e.startsWith(l)) {
|
|
1987
|
+
const u = e.replace(l, s);
|
|
1988
|
+
this.idToRemoteMap[u] = {
|
|
1989
1989
|
name: o.name,
|
|
1990
1990
|
expose: r
|
|
1991
1991
|
};
|
|
@@ -1998,33 +1998,33 @@ class RemoteHandler {
|
|
|
1998
1998
|
try {
|
|
1999
1999
|
const { loadFactory: r = !0 } = n || {
|
|
2000
2000
|
loadFactory: !0
|
|
2001
|
-
}, { module:
|
|
2001
|
+
}, { module: s, moduleOptions: l, remoteMatchInfo: u } = await this.getRemoteModuleAndOptions({
|
|
2002
2002
|
id: e
|
|
2003
|
-
}), { pkgNameOrAlias: d, remote: p, expose:
|
|
2004
|
-
id:
|
|
2003
|
+
}), { pkgNameOrAlias: d, remote: p, expose: y, id: _, remoteSnapshot: m } = u, E = await s.get(_, y, n, m), S = await this.hooks.lifecycle.onLoad.emit({
|
|
2004
|
+
id: _,
|
|
2005
2005
|
pkgNameOrAlias: d,
|
|
2006
|
-
expose:
|
|
2007
|
-
exposeModule: r ?
|
|
2008
|
-
exposeModuleFactory: r ? void 0 :
|
|
2006
|
+
expose: y,
|
|
2007
|
+
exposeModule: r ? E : void 0,
|
|
2008
|
+
exposeModuleFactory: r ? void 0 : E,
|
|
2009
2009
|
remote: p,
|
|
2010
|
-
options:
|
|
2011
|
-
moduleInstance:
|
|
2010
|
+
options: l,
|
|
2011
|
+
moduleInstance: s,
|
|
2012
2012
|
origin: o
|
|
2013
2013
|
});
|
|
2014
|
-
return this.setIdToRemoteMap(e,
|
|
2014
|
+
return this.setIdToRemoteMap(e, u), typeof S == "function" ? S : E;
|
|
2015
2015
|
} catch (r) {
|
|
2016
|
-
const { from:
|
|
2016
|
+
const { from: s = "runtime" } = n || {
|
|
2017
2017
|
from: "runtime"
|
|
2018
|
-
},
|
|
2018
|
+
}, l = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2019
2019
|
id: e,
|
|
2020
2020
|
error: r,
|
|
2021
|
-
from:
|
|
2021
|
+
from: s,
|
|
2022
2022
|
lifecycle: "onLoad",
|
|
2023
2023
|
origin: o
|
|
2024
2024
|
});
|
|
2025
|
-
if (!
|
|
2025
|
+
if (!l)
|
|
2026
2026
|
throw r;
|
|
2027
|
-
return
|
|
2027
|
+
return l;
|
|
2028
2028
|
}
|
|
2029
2029
|
}
|
|
2030
2030
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2037,15 +2037,15 @@ class RemoteHandler {
|
|
|
2037
2037
|
});
|
|
2038
2038
|
const o = formatPreloadArgs(n.options.remotes, e);
|
|
2039
2039
|
await Promise.all(o.map(async (r) => {
|
|
2040
|
-
const { remote:
|
|
2040
|
+
const { remote: s } = r, l = getRemoteInfo(s), { globalSnapshot: u, remoteSnapshot: d } = await n.snapshotHandler.loadRemoteSnapshotInfo(s), p = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2041
2041
|
origin: n,
|
|
2042
2042
|
preloadOptions: r,
|
|
2043
|
-
remote:
|
|
2044
|
-
remoteInfo:
|
|
2045
|
-
globalSnapshot:
|
|
2043
|
+
remote: s,
|
|
2044
|
+
remoteInfo: l,
|
|
2045
|
+
globalSnapshot: u,
|
|
2046
2046
|
remoteSnapshot: d
|
|
2047
2047
|
});
|
|
2048
|
-
p && preloadAssets(
|
|
2048
|
+
p && preloadAssets(l, n, p);
|
|
2049
2049
|
}));
|
|
2050
2050
|
}
|
|
2051
2051
|
registerRemotes(e, n) {
|
|
@@ -2076,44 +2076,44 @@ class RemoteHandler {
|
|
|
2076
2076
|
}), !r)
|
|
2077
2077
|
throw S;
|
|
2078
2078
|
}
|
|
2079
|
-
const { id:
|
|
2080
|
-
assert(
|
|
2081
|
-
Unable to locate ${
|
|
2079
|
+
const { id: s } = r, l = matchRemoteWithNameAndExpose(n.options.remotes, s);
|
|
2080
|
+
assert(l, `
|
|
2081
|
+
Unable to locate ${s} in ${n.options.name}. Potential reasons for failure include:
|
|
2082
2082
|
|
|
2083
|
-
1. ${
|
|
2083
|
+
1. ${s} was not included in the 'remotes' parameter of ${n.options.name || "the host"}.
|
|
2084
2084
|
|
|
2085
|
-
2. ${
|
|
2086
|
-
3. ${
|
|
2087
|
-
4. ${
|
|
2088
|
-
5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${
|
|
2085
|
+
2. ${s} could not be found in the 'remotes' of ${n.options.name} with either 'name' or 'alias' attributes.
|
|
2086
|
+
3. ${s} is not online, injected, or loaded.
|
|
2087
|
+
4. ${s} cannot be accessed on the expected.
|
|
2088
|
+
5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${s}.
|
|
2089
2089
|
`);
|
|
2090
|
-
const { remote:
|
|
2091
|
-
id:
|
|
2092
|
-
},
|
|
2090
|
+
const { remote: u } = l, d = getRemoteInfo(u), p = await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2091
|
+
id: s
|
|
2092
|
+
}, l, {
|
|
2093
2093
|
options: n.options,
|
|
2094
2094
|
origin: n,
|
|
2095
2095
|
remoteInfo: d
|
|
2096
|
-
})), { remote:
|
|
2097
|
-
assert(
|
|
2098
|
-
let m = n.moduleCache.get(
|
|
2099
|
-
const
|
|
2096
|
+
})), { remote: y, expose: _ } = p;
|
|
2097
|
+
assert(y && _, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${s}.`);
|
|
2098
|
+
let m = n.moduleCache.get(y.name);
|
|
2099
|
+
const E = {
|
|
2100
2100
|
host: n,
|
|
2101
2101
|
remoteInfo: d
|
|
2102
2102
|
};
|
|
2103
|
-
return m || (m = new Module(
|
|
2103
|
+
return m || (m = new Module(E), n.moduleCache.set(y.name, m)), {
|
|
2104
2104
|
module: m,
|
|
2105
|
-
moduleOptions:
|
|
2105
|
+
moduleOptions: E,
|
|
2106
2106
|
remoteMatchInfo: p
|
|
2107
2107
|
};
|
|
2108
2108
|
}
|
|
2109
2109
|
registerRemote(e, n, o) {
|
|
2110
|
-
const { host: r } = this,
|
|
2110
|
+
const { host: r } = this, s = () => {
|
|
2111
2111
|
if (e.alias) {
|
|
2112
|
-
const
|
|
2112
|
+
const u = n.find((d) => {
|
|
2113
2113
|
var p;
|
|
2114
2114
|
return e.alias && (d.name.startsWith(e.alias) || ((p = d.alias) == null ? void 0 : p.startsWith(e.alias)));
|
|
2115
2115
|
});
|
|
2116
|
-
assert(!
|
|
2116
|
+
assert(!u, `The alias ${e.alias} of remote ${e.name} is not allowed to be the prefix of ${u && u.name} name or alias`);
|
|
2117
2117
|
}
|
|
2118
2118
|
"entry" in e && isBrowserEnv() && !e.entry.startsWith("http") && (e.entry = new URL(e.entry, window.location.origin).href), e.shareScope || (e.shareScope = DEFAULT_SCOPE), e.type || (e.type = DEFAULT_REMOTE_TYPE);
|
|
2119
2119
|
};
|
|
@@ -2121,44 +2121,44 @@ class RemoteHandler {
|
|
|
2121
2121
|
remote: e,
|
|
2122
2122
|
origin: r
|
|
2123
2123
|
});
|
|
2124
|
-
const
|
|
2125
|
-
if (!
|
|
2126
|
-
|
|
2124
|
+
const l = n.find((u) => u.name === e.name);
|
|
2125
|
+
if (!l)
|
|
2126
|
+
s(), n.push(e), this.hooks.lifecycle.registerRemote.emit({
|
|
2127
2127
|
remote: e,
|
|
2128
2128
|
origin: r
|
|
2129
2129
|
});
|
|
2130
2130
|
else {
|
|
2131
|
-
const
|
|
2131
|
+
const u = [
|
|
2132
2132
|
`The remote "${e.name}" is already registered.`,
|
|
2133
2133
|
o != null && o.force ? "Hope you have known that OVERRIDE it may have some unexpected errors" : 'If you want to merge the remote, you can set "force: true".'
|
|
2134
2134
|
];
|
|
2135
|
-
o != null && o.force && (this.removeRemote(
|
|
2135
|
+
o != null && o.force && (this.removeRemote(l), s(), n.push(e), this.hooks.lifecycle.registerRemote.emit({
|
|
2136
2136
|
remote: e,
|
|
2137
2137
|
origin: r
|
|
2138
|
-
})), warn$1(
|
|
2138
|
+
})), warn$1(u.join(" "));
|
|
2139
2139
|
}
|
|
2140
2140
|
}
|
|
2141
2141
|
removeRemote(e) {
|
|
2142
2142
|
try {
|
|
2143
|
-
const { host: o } = this, { name: r } = e,
|
|
2144
|
-
|
|
2145
|
-
const
|
|
2146
|
-
if (
|
|
2147
|
-
const
|
|
2143
|
+
const { host: o } = this, { name: r } = e, s = o.options.remotes.findIndex((u) => u.name === r);
|
|
2144
|
+
s !== -1 && o.options.remotes.splice(s, 1);
|
|
2145
|
+
const l = o.moduleCache.get(e.name);
|
|
2146
|
+
if (l) {
|
|
2147
|
+
const u = l.remoteInfo, d = u.entryGlobalName;
|
|
2148
2148
|
if (globalThis[d]) {
|
|
2149
2149
|
var n;
|
|
2150
2150
|
(n = Object.getOwnPropertyDescriptor(globalThis, d)) != null && n.configurable ? delete globalThis[d] : globalThis[d] = void 0;
|
|
2151
2151
|
}
|
|
2152
|
-
const p = getRemoteEntryUniqueKey(
|
|
2153
|
-
globalLoading[p] && delete globalLoading[p], o.snapshotHandler.manifestCache.delete(
|
|
2154
|
-
let
|
|
2155
|
-
const
|
|
2156
|
-
if (
|
|
2157
|
-
const
|
|
2158
|
-
|
|
2152
|
+
const p = getRemoteEntryUniqueKey(l.remoteInfo);
|
|
2153
|
+
globalLoading[p] && delete globalLoading[p], o.snapshotHandler.manifestCache.delete(u.entry);
|
|
2154
|
+
let y = u.buildVersion ? composeKeyWithSeparator(u.name, u.buildVersion) : u.name;
|
|
2155
|
+
const _ = globalThis.__FEDERATION__.__INSTANCES__.findIndex((E) => u.buildVersion ? E.options.id === y : E.name === y);
|
|
2156
|
+
if (_ !== -1) {
|
|
2157
|
+
const E = globalThis.__FEDERATION__.__INSTANCES__[_];
|
|
2158
|
+
y = E.options.id || y;
|
|
2159
2159
|
const S = getGlobalShareScope();
|
|
2160
2160
|
let $ = !0;
|
|
2161
|
-
const
|
|
2161
|
+
const b = [];
|
|
2162
2162
|
Object.keys(S).forEach((v) => {
|
|
2163
2163
|
const T = S[v];
|
|
2164
2164
|
T && Object.keys(T).forEach((A) => {
|
|
@@ -2167,12 +2167,12 @@ class RemoteHandler {
|
|
|
2167
2167
|
const O = I[R];
|
|
2168
2168
|
O && Object.keys(O).forEach((P) => {
|
|
2169
2169
|
const w = O[P];
|
|
2170
|
-
w && typeof w == "object" && w.from ===
|
|
2170
|
+
w && typeof w == "object" && w.from === u.name && (w.loaded || w.loading ? (w.useIn = w.useIn.filter((N) => N !== u.name), w.useIn.length ? $ = !1 : b.push([
|
|
2171
2171
|
v,
|
|
2172
2172
|
A,
|
|
2173
2173
|
R,
|
|
2174
2174
|
P
|
|
2175
|
-
])) :
|
|
2175
|
+
])) : b.push([
|
|
2176
2176
|
v,
|
|
2177
2177
|
A,
|
|
2178
2178
|
R,
|
|
@@ -2181,15 +2181,15 @@ class RemoteHandler {
|
|
|
2181
2181
|
});
|
|
2182
2182
|
});
|
|
2183
2183
|
});
|
|
2184
|
-
}), $ && (
|
|
2184
|
+
}), $ && (E.shareScopeMap = {}, delete S[y]), b.forEach(([v, T, A, I]) => {
|
|
2185
2185
|
var R, O, P;
|
|
2186
2186
|
(P = S[v]) == null || (O = P[T]) == null || (R = O[A]) == null || delete R[I];
|
|
2187
|
-
}), globalThis.__FEDERATION__.__INSTANCES__.splice(
|
|
2187
|
+
}), globalThis.__FEDERATION__.__INSTANCES__.splice(_, 1);
|
|
2188
2188
|
}
|
|
2189
2189
|
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(e, o);
|
|
2190
2190
|
if (m) {
|
|
2191
|
-
const
|
|
2192
|
-
|
|
2191
|
+
const E = m && "remotesInfo" in m && m.remotesInfo && getInfoWithoutType(m.remotesInfo, e.name).key;
|
|
2192
|
+
E && (delete m.remotesInfo[E], Global.__FEDERATION__.__MANIFEST_LOADING__[E] && delete Global.__FEDERATION__.__MANIFEST_LOADING__[E]);
|
|
2193
2193
|
}
|
|
2194
2194
|
o.moduleCache.delete(e.name);
|
|
2195
2195
|
}
|
|
@@ -2236,11 +2236,11 @@ class FederationHost {
|
|
|
2236
2236
|
const r = getRemoteInfo({
|
|
2237
2237
|
name: e,
|
|
2238
2238
|
entry: n
|
|
2239
|
-
}),
|
|
2239
|
+
}), s = new Module({
|
|
2240
2240
|
host: this,
|
|
2241
2241
|
remoteInfo: r
|
|
2242
2242
|
});
|
|
2243
|
-
return
|
|
2243
|
+
return s.remoteEntryExports = o, this.moduleCache.set(e, s), s;
|
|
2244
2244
|
}
|
|
2245
2245
|
// eslint-disable-next-line max-lines-per-function
|
|
2246
2246
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2255,21 +2255,21 @@ class FederationHost {
|
|
|
2255
2255
|
this.sharedHandler.initShareScopeMap(e, n, o);
|
|
2256
2256
|
}
|
|
2257
2257
|
formatOptions(e, n) {
|
|
2258
|
-
const { shared: o } = formatShareConfigs(e, n), { userOptions: r, options:
|
|
2258
|
+
const { shared: o } = formatShareConfigs(e, n), { userOptions: r, options: s } = this.hooks.lifecycle.beforeInit.emit({
|
|
2259
2259
|
origin: this,
|
|
2260
2260
|
userOptions: n,
|
|
2261
2261
|
options: e,
|
|
2262
2262
|
shareInfo: o
|
|
2263
|
-
}),
|
|
2264
|
-
...
|
|
2263
|
+
}), l = this.remoteHandler.formatAndRegisterRemote(s, r), { shared: u } = this.sharedHandler.registerShared(s, r), d = [
|
|
2264
|
+
...s.plugins
|
|
2265
2265
|
];
|
|
2266
|
-
r.plugins && r.plugins.forEach((
|
|
2267
|
-
d.includes(
|
|
2266
|
+
r.plugins && r.plugins.forEach((y) => {
|
|
2267
|
+
d.includes(y) || d.push(y);
|
|
2268
2268
|
});
|
|
2269
2269
|
const p = _extends$1({}, e, n, {
|
|
2270
2270
|
plugins: d,
|
|
2271
|
-
remotes:
|
|
2272
|
-
shared:
|
|
2271
|
+
remotes: l,
|
|
2272
|
+
shared: u
|
|
2273
2273
|
});
|
|
2274
2274
|
return this.hooks.lifecycle.init.emit({
|
|
2275
2275
|
origin: this,
|
|
@@ -2284,7 +2284,7 @@ class FederationHost {
|
|
|
2284
2284
|
this.snapshotHandler.hooks,
|
|
2285
2285
|
this.loaderHook
|
|
2286
2286
|
]);
|
|
2287
|
-
this.options.plugins = this.options.plugins.reduce((o, r) => (r && o && !o.find((
|
|
2287
|
+
this.options.plugins = this.options.plugins.reduce((o, r) => (r && o && !o.find((s) => s.name === r.name) && o.push(r), o), n || []);
|
|
2288
2288
|
}
|
|
2289
2289
|
registerRemotes(e, n) {
|
|
2290
2290
|
return this.remoteHandler.registerRemotes(e, n);
|
|
@@ -2322,12 +2322,8 @@ class FederationHost {
|
|
|
2322
2322
|
]), this.options = this.formatOptions(n, e);
|
|
2323
2323
|
}
|
|
2324
2324
|
}
|
|
2325
|
-
let FederationInstance = null;
|
|
2326
|
-
function getInstance() {
|
|
2327
|
-
return FederationInstance;
|
|
2328
|
-
}
|
|
2329
2325
|
setGlobalFederationConstructor(FederationHost);
|
|
2330
|
-
var pluginHelper
|
|
2326
|
+
var pluginHelper = /* @__PURE__ */ Object.freeze({
|
|
2331
2327
|
__proto__: null,
|
|
2332
2328
|
SyncHook,
|
|
2333
2329
|
AsyncHook,
|
|
@@ -2358,21 +2354,19 @@ const ShareUtils = {
|
|
|
2358
2354
|
getPreloaded,
|
|
2359
2355
|
setPreloaded,
|
|
2360
2356
|
registerPlugins,
|
|
2361
|
-
pluginHelper
|
|
2357
|
+
pluginHelper
|
|
2362
2358
|
};
|
|
2363
2359
|
var helpers = {
|
|
2364
2360
|
global: GlobalUtils,
|
|
2365
2361
|
share: ShareUtils
|
|
2366
2362
|
};
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
[pluginSystem]
|
|
2375
|
-
);
|
|
2363
|
+
function registerBridgeLifeCycle() {
|
|
2364
|
+
const { registerPlugins: t, pluginHelper: e } = helpers.global;
|
|
2365
|
+
return new e.PluginSystem({
|
|
2366
|
+
beforeBridgeRender: new e.SyncHook(),
|
|
2367
|
+
beforeBridgeDestroy: new e.SyncHook()
|
|
2368
|
+
}), null;
|
|
2369
|
+
}
|
|
2376
2370
|
const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
2377
2371
|
name: "RemoteApp",
|
|
2378
2372
|
props: {
|
|
@@ -2382,37 +2376,37 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2382
2376
|
providerInfo: Function
|
|
2383
2377
|
},
|
|
2384
2378
|
setup(t) {
|
|
2385
|
-
const e = ref(null), n = ref(null), o = ref(""), r = useRoute(), l = () => {
|
|
2386
|
-
var
|
|
2387
|
-
const
|
|
2388
|
-
n.value =
|
|
2389
|
-
const
|
|
2379
|
+
const e = ref(null), n = ref(null), o = ref(""), r = useRoute(), s = registerBridgeLifeCycle(), l = () => {
|
|
2380
|
+
var y, _, m;
|
|
2381
|
+
const d = (y = t.providerInfo) == null ? void 0 : y.call(t);
|
|
2382
|
+
n.value = d;
|
|
2383
|
+
const p = {
|
|
2390
2384
|
name: t.moduleName,
|
|
2391
2385
|
dom: e.value,
|
|
2392
2386
|
basename: t.basename,
|
|
2393
2387
|
memoryRoute: t.memoryRoute
|
|
2394
2388
|
};
|
|
2395
|
-
LoggerInstance.log("createRemoteComponent LazyComponent render >>>",
|
|
2396
|
-
...
|
|
2397
|
-
}),
|
|
2398
|
-
}, u = watch(() => r.path, (
|
|
2399
|
-
|
|
2389
|
+
LoggerInstance.log("createRemoteComponent LazyComponent render >>>", p), s && ((_ = s == null ? void 0 : s.lifecycle) != null && _.beforeBridgeRender) && ((m = s == null ? void 0 : s.lifecycle) == null || m.beforeBridgeRender.emit({
|
|
2390
|
+
...p
|
|
2391
|
+
})), d.render(p);
|
|
2392
|
+
}, u = watch(() => r.path, (d) => {
|
|
2393
|
+
d !== r.path && l(), o.value !== "" && o.value !== d && (LoggerInstance.log("createRemoteComponent dispatchPopstateEnv >>>", {
|
|
2400
2394
|
...t,
|
|
2401
2395
|
pathname: r.path
|
|
2402
|
-
}), f()), o.value =
|
|
2396
|
+
}), f()), o.value = d;
|
|
2403
2397
|
});
|
|
2404
2398
|
return onMounted(() => {
|
|
2405
2399
|
l();
|
|
2406
2400
|
}), onBeforeUnmount(() => {
|
|
2407
|
-
var
|
|
2401
|
+
var d, p, y;
|
|
2408
2402
|
LoggerInstance.log("createRemoteComponent LazyComponent destroy >>>", {
|
|
2409
2403
|
...t
|
|
2410
|
-
}), u(),
|
|
2404
|
+
}), u(), s && ((d = s == null ? void 0 : s.lifecycle) != null && d.beforeBridgeRender) && ((p = s == null ? void 0 : s.lifecycle) == null || p.beforeBridgeDestroy.emit({
|
|
2411
2405
|
name: t.moduleName,
|
|
2412
2406
|
dom: e.value,
|
|
2413
2407
|
basename: t.basename,
|
|
2414
2408
|
memoryRoute: t.memoryRoute
|
|
2415
|
-
}), (
|
|
2409
|
+
})), (y = n.value) == null || y.destroy({
|
|
2416
2410
|
dom: e.value
|
|
2417
2411
|
});
|
|
2418
2412
|
}), () => createVNode("div", {
|
|
@@ -2435,17 +2429,17 @@ function createRemoteComponent(t) {
|
|
|
2435
2429
|
basename: n,
|
|
2436
2430
|
info: t
|
|
2437
2431
|
});
|
|
2438
|
-
const
|
|
2432
|
+
const s = await t.loader(), l = s && s[Symbol.for("mf_module_id")], u = s[r];
|
|
2439
2433
|
if (LoggerInstance.log(
|
|
2440
2434
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
2441
|
-
{ name:
|
|
2442
|
-
), r in
|
|
2435
|
+
{ name: l, module: s, exportName: r, basename: n, route: e }
|
|
2436
|
+
), r in s && typeof u == "function")
|
|
2443
2437
|
return {
|
|
2444
2438
|
render() {
|
|
2445
2439
|
return h(RemoteApp, {
|
|
2446
|
-
moduleName:
|
|
2440
|
+
moduleName: l,
|
|
2447
2441
|
...t,
|
|
2448
|
-
providerInfo:
|
|
2442
|
+
providerInfo: u,
|
|
2449
2443
|
basename: n
|
|
2450
2444
|
});
|
|
2451
2445
|
}
|