@module-federation/bridge-vue3 0.8.9 → 0.8.11
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 +17 -0
- package/dist/index.cjs.js +5 -5
- package/dist/index.es.js +405 -397
- package/package.json +4 -4
- package/src/provider.ts +5 -3
package/dist/index.es.js
CHANGED
|
@@ -50,8 +50,8 @@ function getLabel(r, t, n) {
|
|
|
50
50
|
let o = [""];
|
|
51
51
|
if ("label" in t)
|
|
52
52
|
if (o = [(r !== "log" ? n[r] : void 0) || t.label || ""], t.color) {
|
|
53
|
-
const
|
|
54
|
-
Array.isArray(
|
|
53
|
+
const l = t.color(o[0]);
|
|
54
|
+
Array.isArray(l) && l.length === 2 ? o = bold([l[0], l[1]]) : o = bold(l[0] || "");
|
|
55
55
|
} else
|
|
56
56
|
o = bold(o[0]);
|
|
57
57
|
return o = o.filter(Boolean), o;
|
|
@@ -74,15 +74,15 @@ function validateOptions(r) {
|
|
|
74
74
|
throw new Error("Level must be a string");
|
|
75
75
|
return t;
|
|
76
76
|
}
|
|
77
|
-
var createLogger$1 = (r = {}, { getLabel: t, handleError: n, finalLog: o, greet: s, LOG_TYPES:
|
|
78
|
-
const
|
|
79
|
-
let i =
|
|
80
|
-
if (LOG_LEVEL[
|
|
77
|
+
var createLogger$1 = (r = {}, { getLabel: t, handleError: n, finalLog: o, greet: s, LOG_TYPES: l }) => {
|
|
78
|
+
const a = validateOptions(r);
|
|
79
|
+
let i = a.level || "log", c = a.labels || {}, u = (p, m, ...y) => {
|
|
80
|
+
if (LOG_LEVEL[l[p].level] > LOG_LEVEL[i])
|
|
81
81
|
return;
|
|
82
82
|
if (m == null)
|
|
83
83
|
return console.log();
|
|
84
|
-
let _ =
|
|
85
|
-
const g = t(
|
|
84
|
+
let _ = l[p], E = "";
|
|
85
|
+
const g = t(p, _, c);
|
|
86
86
|
if (m instanceof Error)
|
|
87
87
|
if (m.stack) {
|
|
88
88
|
let [b, ...S] = m.stack.split(`
|
|
@@ -97,25 +97,25 @@ ${n(S.join(`
|
|
|
97
97
|
`).map((S) => isErrorStackMessage(S) ? n(S) : S).join(`
|
|
98
98
|
`) : E = `${m}`;
|
|
99
99
|
o(g, E, y, m);
|
|
100
|
-
},
|
|
100
|
+
}, d = {
|
|
101
101
|
// greet
|
|
102
|
-
greet: (
|
|
102
|
+
greet: (p) => u("log", s(p))
|
|
103
103
|
};
|
|
104
|
-
return Object.keys(
|
|
105
|
-
p
|
|
106
|
-
}), Object.defineProperty(
|
|
104
|
+
return Object.keys(l).forEach((p) => {
|
|
105
|
+
d[p] = (...m) => u(p, ...m);
|
|
106
|
+
}), Object.defineProperty(d, "level", {
|
|
107
107
|
get: () => i,
|
|
108
|
-
set(
|
|
109
|
-
i =
|
|
108
|
+
set(p) {
|
|
109
|
+
i = p;
|
|
110
110
|
}
|
|
111
|
-
}), Object.defineProperty(
|
|
111
|
+
}), Object.defineProperty(d, "labels", {
|
|
112
112
|
get: () => c,
|
|
113
|
-
set(
|
|
114
|
-
c =
|
|
113
|
+
set(p) {
|
|
114
|
+
c = p;
|
|
115
115
|
}
|
|
116
|
-
}),
|
|
117
|
-
Object.assign(
|
|
118
|
-
},
|
|
116
|
+
}), d.override = (p) => {
|
|
117
|
+
Object.assign(d, p);
|
|
118
|
+
}, d;
|
|
119
119
|
}, startColor = [189, 255, 243], endColor = [74, 194, 154], isWord = (r) => !/[\s\n]/.test(r);
|
|
120
120
|
function gradient(r) {
|
|
121
121
|
if (!supportColor())
|
|
@@ -123,14 +123,14 @@ function gradient(r) {
|
|
|
123
123
|
const t = [...r], n = t.filter(isWord), o = n.length - 1;
|
|
124
124
|
if (o === 0)
|
|
125
125
|
return console.log(`%c${r}`, `color: rgb(${startColor.join(",")}); font-weight: bold;`), [r];
|
|
126
|
-
let s = "",
|
|
127
|
-
return t.forEach((
|
|
128
|
-
if (isWord(
|
|
129
|
-
const i = n.indexOf(
|
|
130
|
-
s += `%c${
|
|
126
|
+
let s = "", l = [];
|
|
127
|
+
return t.forEach((a) => {
|
|
128
|
+
if (isWord(a)) {
|
|
129
|
+
const i = n.indexOf(a) / o, c = Math.round(startColor[0] + (endColor[0] - startColor[0]) * i), u = Math.round(startColor[1] + (endColor[1] - startColor[1]) * i), d = Math.round(startColor[2] + (endColor[2] - startColor[2]) * i);
|
|
130
|
+
s += `%c${a}`, l.push(`color: rgb(${c},${u},${d}); font-weight: bold;`);
|
|
131
131
|
} else
|
|
132
|
-
s +=
|
|
133
|
-
}), [s, ...
|
|
132
|
+
s += a;
|
|
133
|
+
}), [s, ...l];
|
|
134
134
|
}
|
|
135
135
|
var LOG_TYPES = {
|
|
136
136
|
// Level error
|
|
@@ -269,8 +269,8 @@ const simpleJoinRemoteEntry = (r, t) => {
|
|
|
269
269
|
if (s.startsWith("./"))
|
|
270
270
|
return s.replace("./", "");
|
|
271
271
|
if (s.startsWith("/")) {
|
|
272
|
-
const
|
|
273
|
-
return
|
|
272
|
+
const l = s.slice(1);
|
|
273
|
+
return l.endsWith("/") ? l.slice(0, -1) : l;
|
|
274
274
|
}
|
|
275
275
|
return s;
|
|
276
276
|
})(r);
|
|
@@ -281,27 +281,27 @@ function inferAutoPublicPath(r) {
|
|
|
281
281
|
}
|
|
282
282
|
function generateSnapshotFromManifest(r, t = {}) {
|
|
283
283
|
var n, o;
|
|
284
|
-
const { remotes: s = {}, overrides:
|
|
284
|
+
const { remotes: s = {}, overrides: l = {}, version: a } = t;
|
|
285
285
|
let i;
|
|
286
|
-
const c = () => "publicPath" in r.metaData ? r.metaData.publicPath === "auto" &&
|
|
287
|
-
let
|
|
286
|
+
const c = () => "publicPath" in r.metaData ? r.metaData.publicPath === "auto" && a ? inferAutoPublicPath(a) : r.metaData.publicPath : r.metaData.getPublicPath, u = Object.keys(l);
|
|
287
|
+
let d = {};
|
|
288
288
|
if (!Object.keys(s).length) {
|
|
289
|
-
var
|
|
290
|
-
|
|
289
|
+
var p;
|
|
290
|
+
d = ((p = r.remotes) == null ? void 0 : p.reduce((R, $) => {
|
|
291
291
|
let w;
|
|
292
292
|
const O = $.federationContainerName;
|
|
293
|
-
return u.includes(O) ? w =
|
|
293
|
+
return u.includes(O) ? w = l[O] : "version" in $ ? w = $.version : w = $.entry, R[O] = {
|
|
294
294
|
matchedVersion: w
|
|
295
295
|
}, R;
|
|
296
296
|
}, {})) || {};
|
|
297
297
|
}
|
|
298
|
-
Object.keys(s).forEach((R) =>
|
|
298
|
+
Object.keys(s).forEach((R) => d[R] = {
|
|
299
299
|
// overrides will override dependencies
|
|
300
|
-
matchedVersion: u.includes(R) ?
|
|
300
|
+
matchedVersion: u.includes(R) ? l[R] : s[R]
|
|
301
301
|
});
|
|
302
302
|
const { remoteEntry: { path: m, name: y, type: _ }, types: E, buildInfo: { buildVersion: g }, globalName: b, ssrRemoteEntry: S } = r.metaData, { exposes: v } = r;
|
|
303
303
|
let I = {
|
|
304
|
-
version:
|
|
304
|
+
version: a || "",
|
|
305
305
|
buildVersion: g,
|
|
306
306
|
globalName: b,
|
|
307
307
|
remoteEntry: simpleJoinRemoteEntry(m, y),
|
|
@@ -309,7 +309,7 @@ function generateSnapshotFromManifest(r, t = {}) {
|
|
|
309
309
|
remoteTypes: simpleJoinRemoteEntry(E.path, E.name),
|
|
310
310
|
remoteTypesZip: E.zip || "",
|
|
311
311
|
remoteTypesAPI: E.api || "",
|
|
312
|
-
remotesInfo:
|
|
312
|
+
remotesInfo: d,
|
|
313
313
|
shared: r == null ? void 0 : r.shared.map((R) => ({
|
|
314
314
|
assets: R.assets,
|
|
315
315
|
sharedName: R.name,
|
|
@@ -361,9 +361,9 @@ function isStaticResourcesEqual(r, t) {
|
|
|
361
361
|
}
|
|
362
362
|
function createScript(r) {
|
|
363
363
|
let t = null, n = !0, o = 2e4, s;
|
|
364
|
-
const
|
|
365
|
-
for (let i = 0; i <
|
|
366
|
-
const c =
|
|
364
|
+
const l = document.getElementsByTagName("script");
|
|
365
|
+
for (let i = 0; i < l.length; i++) {
|
|
366
|
+
const c = l[i], u = c.getAttribute("src");
|
|
367
367
|
if (u && isStaticResourcesEqual(u, r.url)) {
|
|
368
368
|
t = c, n = !1;
|
|
369
369
|
break;
|
|
@@ -377,26 +377,26 @@ function createScript(r) {
|
|
|
377
377
|
t && (u === "async" || u === "defer" ? t[u] = i[u] : t.getAttribute(u) || t.setAttribute(u, i[u]));
|
|
378
378
|
});
|
|
379
379
|
}
|
|
380
|
-
const
|
|
380
|
+
const a = async (i, c) => {
|
|
381
381
|
clearTimeout(s);
|
|
382
382
|
const u = () => {
|
|
383
383
|
(c == null ? void 0 : c.type) === "error" ? r != null && r.onErrorCallback && (r == null || r.onErrorCallback(c)) : r != null && r.cb && (r == null || r.cb());
|
|
384
384
|
};
|
|
385
385
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
386
|
-
const { needDeleteScript:
|
|
387
|
-
|
|
386
|
+
const { needDeleteScript: d = !0 } = r;
|
|
387
|
+
d && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
388
388
|
}), i && typeof i == "function")) {
|
|
389
|
-
const
|
|
390
|
-
if (
|
|
391
|
-
const
|
|
392
|
-
return u(),
|
|
389
|
+
const d = i(c);
|
|
390
|
+
if (d instanceof Promise) {
|
|
391
|
+
const p = await d;
|
|
392
|
+
return u(), p;
|
|
393
393
|
}
|
|
394
|
-
return u(),
|
|
394
|
+
return u(), d;
|
|
395
395
|
}
|
|
396
396
|
u();
|
|
397
397
|
};
|
|
398
|
-
return t.onerror =
|
|
399
|
-
|
|
398
|
+
return t.onerror = a.bind(null, t.onerror), t.onload = a.bind(null, t.onload), s = setTimeout(() => {
|
|
399
|
+
a(null, new Error(`Remote script "${r.url}" time-outed.`));
|
|
400
400
|
}, o), {
|
|
401
401
|
script: t,
|
|
402
402
|
needAttach: n
|
|
@@ -405,30 +405,30 @@ function createScript(r) {
|
|
|
405
405
|
function createLink(r) {
|
|
406
406
|
let t = null, n = !0;
|
|
407
407
|
const o = document.getElementsByTagName("link");
|
|
408
|
-
for (let
|
|
409
|
-
const
|
|
408
|
+
for (let l = 0; l < o.length; l++) {
|
|
409
|
+
const a = o[l], i = a.getAttribute("href"), c = a.getAttribute("ref");
|
|
410
410
|
if (i && isStaticResourcesEqual(i, r.url) && c === r.attrs.ref) {
|
|
411
|
-
t =
|
|
411
|
+
t = a, n = !1;
|
|
412
412
|
break;
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
if (!t) {
|
|
416
416
|
t = document.createElement("link"), t.setAttribute("href", r.url);
|
|
417
|
-
let
|
|
418
|
-
const
|
|
419
|
-
r.createLinkHook && (
|
|
420
|
-
t && !t.getAttribute(i) && t.setAttribute(i,
|
|
417
|
+
let l;
|
|
418
|
+
const a = r.attrs;
|
|
419
|
+
r.createLinkHook && (l = r.createLinkHook(r.url, a), l instanceof HTMLLinkElement && (t = l)), a && !l && Object.keys(a).forEach((i) => {
|
|
420
|
+
t && !t.getAttribute(i) && t.setAttribute(i, a[i]);
|
|
421
421
|
});
|
|
422
422
|
}
|
|
423
|
-
const s = (
|
|
423
|
+
const s = (l, a) => {
|
|
424
424
|
const i = () => {
|
|
425
|
-
(
|
|
425
|
+
(a == null ? void 0 : a.type) === "error" ? r != null && r.onErrorCallback && (r == null || r.onErrorCallback(a)) : r != null && r.cb && (r == null || r.cb());
|
|
426
426
|
};
|
|
427
427
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
428
428
|
const { needDeleteLink: c = !0 } = r;
|
|
429
429
|
c && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
430
|
-
}),
|
|
431
|
-
const c = a
|
|
430
|
+
}), l)) {
|
|
431
|
+
const c = l(a);
|
|
432
432
|
return i(), c;
|
|
433
433
|
}
|
|
434
434
|
i();
|
|
@@ -440,18 +440,18 @@ function createLink(r) {
|
|
|
440
440
|
}
|
|
441
441
|
function loadScript(r, t) {
|
|
442
442
|
const { attrs: n = {}, createScriptHook: o } = t;
|
|
443
|
-
return new Promise((s,
|
|
444
|
-
const { script:
|
|
443
|
+
return new Promise((s, l) => {
|
|
444
|
+
const { script: a, needAttach: i } = createScript({
|
|
445
445
|
url: r,
|
|
446
446
|
cb: s,
|
|
447
|
-
onErrorCallback:
|
|
447
|
+
onErrorCallback: l,
|
|
448
448
|
attrs: _extends$2({
|
|
449
449
|
fetchpriority: "high"
|
|
450
450
|
}, n),
|
|
451
451
|
createScriptHook: o,
|
|
452
452
|
needDeleteScript: !0
|
|
453
453
|
});
|
|
454
|
-
i && document.head.appendChild(
|
|
454
|
+
i && document.head.appendChild(a);
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
function importNodeModule(r) {
|
|
@@ -465,7 +465,7 @@ const loadNodeFetch = async () => {
|
|
|
465
465
|
const r = await importNodeModule("node-fetch");
|
|
466
466
|
return r.default || r;
|
|
467
467
|
}, lazyLoaderHookFetch = async (r, t, n) => {
|
|
468
|
-
const s = await ((
|
|
468
|
+
const s = await ((l, a) => n.lifecycle.fetch.emit(l, a))(r, t || {});
|
|
469
469
|
return !s || !(s instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(r, t || {}) : s;
|
|
470
470
|
};
|
|
471
471
|
function createScriptNode(url, cb, attrs, loaderHook) {
|
|
@@ -527,29 +527,29 @@ function createScriptNode(url, cb, attrs, loaderHook) {
|
|
|
527
527
|
}
|
|
528
528
|
function loadScriptNode(r, t) {
|
|
529
529
|
return new Promise((n, o) => {
|
|
530
|
-
createScriptNode(r, (s,
|
|
530
|
+
createScriptNode(r, (s, l) => {
|
|
531
531
|
if (s)
|
|
532
532
|
o(s);
|
|
533
533
|
else {
|
|
534
|
-
var
|
|
535
|
-
const c = (t == null || (
|
|
534
|
+
var a, i;
|
|
535
|
+
const c = (t == null || (a = t.attrs) == null ? void 0 : a.globalName) || `__FEDERATION_${t == null || (i = t.attrs) == null ? void 0 : i.name}:custom__`, u = globalThis[c] = l;
|
|
536
536
|
n(u);
|
|
537
537
|
}
|
|
538
538
|
}, t.attrs, t.loaderHook);
|
|
539
539
|
});
|
|
540
540
|
}
|
|
541
541
|
async function loadModule(r, t) {
|
|
542
|
-
const { fetch: n, vm: o } = t,
|
|
542
|
+
const { fetch: n, vm: o } = t, l = await (await n(r)).text(), a = new o.SourceTextModule(l, {
|
|
543
543
|
// @ts-ignore
|
|
544
544
|
importModuleDynamically: async (i, c) => {
|
|
545
545
|
const u = new URL(i, r).href;
|
|
546
546
|
return loadModule(u, t);
|
|
547
547
|
}
|
|
548
548
|
});
|
|
549
|
-
return await
|
|
549
|
+
return await a.link(async (i) => {
|
|
550
550
|
const c = new URL(i, r).href;
|
|
551
551
|
return await loadModule(c, t);
|
|
552
|
-
}),
|
|
552
|
+
}), a;
|
|
553
553
|
}
|
|
554
554
|
const LoggerInstance = createLogger("[ Module Federation Bridge Vue3 ]");
|
|
555
555
|
function _extends$1() {
|
|
@@ -565,9 +565,9 @@ function _extends$1() {
|
|
|
565
565
|
function _object_without_properties_loose(r, t) {
|
|
566
566
|
if (r == null)
|
|
567
567
|
return {};
|
|
568
|
-
var n = {}, o = Object.keys(r), s,
|
|
569
|
-
for (
|
|
570
|
-
s = o[
|
|
568
|
+
var n = {}, o = Object.keys(r), s, l;
|
|
569
|
+
for (l = 0; l < o.length; l++)
|
|
570
|
+
s = o[l], !(t.indexOf(s) >= 0) && (n[s] = r[s]);
|
|
571
571
|
return n;
|
|
572
572
|
}
|
|
573
573
|
const RUNTIME_001 = "RUNTIME-001", RUNTIME_002 = "RUNTIME-002", RUNTIME_003 = "RUNTIME-003", RUNTIME_004 = "RUNTIME-004", RUNTIME_005 = "RUNTIME-005", RUNTIME_006 = "RUNTIME-006", RUNTIME_007 = "RUNTIME-007", RUNTIME_008 = "RUNTIME-008", TYPE_001 = "TYPE-001", BUILD_001 = "BUILD-001", getDocsUrl = (r) => `https://module-federation.io/guide/troubleshooting/${r.split("-")[0].toLowerCase()}/${r}`, getShortErrorMsg = (r, t, n, o) => {
|
|
@@ -678,7 +678,7 @@ function includeOwnProperty(r, t) {
|
|
|
678
678
|
includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
679
679
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
680
680
|
function setGlobalDefaultVal(r) {
|
|
681
|
-
var t, n, o, s,
|
|
681
|
+
var t, n, o, s, l, a;
|
|
682
682
|
includeOwnProperty(r, "__VMOK__") && !includeOwnProperty(r, "__FEDERATION__") && definePropertyGlobalVal(r, "__FEDERATION__", r.__VMOK__), includeOwnProperty(r, "__FEDERATION__") || (definePropertyGlobalVal(r, "__FEDERATION__", {
|
|
683
683
|
__GLOBAL_PLUGIN__: [],
|
|
684
684
|
__INSTANCES__: [],
|
|
@@ -693,17 +693,17 @@ function setGlobalDefaultVal(r) {
|
|
|
693
693
|
(c = (n = r.__FEDERATION__).__INSTANCES__) != null || (n.__INSTANCES__ = []);
|
|
694
694
|
var u;
|
|
695
695
|
(u = (o = r.__FEDERATION__).moduleInfo) != null || (o.moduleInfo = {});
|
|
696
|
-
var p;
|
|
697
|
-
(p = (s = r.__FEDERATION__).__SHARE__) != null || (s.__SHARE__ = {});
|
|
698
696
|
var d;
|
|
699
|
-
(d = (
|
|
697
|
+
(d = (s = r.__FEDERATION__).__SHARE__) != null || (s.__SHARE__ = {});
|
|
698
|
+
var p;
|
|
699
|
+
(p = (l = r.__FEDERATION__).__MANIFEST_LOADING__) != null || (l.__MANIFEST_LOADING__ = {});
|
|
700
700
|
var m;
|
|
701
|
-
(m = (
|
|
701
|
+
(m = (a = r.__FEDERATION__).__PRELOADED_MAP__) != null || (a.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
702
702
|
}
|
|
703
703
|
setGlobalDefaultVal(CurrentGlobal);
|
|
704
704
|
setGlobalDefaultVal(nativeGlobal);
|
|
705
705
|
function setGlobalFederationConstructor(r, t = isDebugMode()) {
|
|
706
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.
|
|
706
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.19");
|
|
707
707
|
}
|
|
708
708
|
function getInfoWithoutType(r, t) {
|
|
709
709
|
if (typeof t == "string") {
|
|
@@ -715,7 +715,7 @@ function getInfoWithoutType(r, t) {
|
|
|
715
715
|
{
|
|
716
716
|
const o = Object.keys(r);
|
|
717
717
|
for (const s of o) {
|
|
718
|
-
const [
|
|
718
|
+
const [l, a] = s.split(":"), i = `${l}:${t}`, c = r[i];
|
|
719
719
|
if (c)
|
|
720
720
|
return {
|
|
721
721
|
value: c,
|
|
@@ -735,9 +735,9 @@ const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTarge
|
|
|
735
735
|
if (o && !o.version && "version" in r && r.version && (o.version = r.version), o)
|
|
736
736
|
return o;
|
|
737
737
|
if ("version" in r && r.version) {
|
|
738
|
-
const { version: s } = r,
|
|
738
|
+
const { version: s } = r, l = _object_without_properties_loose(r, [
|
|
739
739
|
"version"
|
|
740
|
-
]),
|
|
740
|
+
]), a = getFMId(l), i = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, a).value;
|
|
741
741
|
if ((i == null ? void 0 : i.version) === s)
|
|
742
742
|
return i;
|
|
743
743
|
}
|
|
@@ -772,7 +772,7 @@ function combineVersion(r, t, n, o) {
|
|
|
772
772
|
return o ? `${s}-${o}` : s;
|
|
773
773
|
}
|
|
774
774
|
function parseHyphen(r) {
|
|
775
|
-
return r.replace(parseRegex(hyphenRange), (t, n, o, s,
|
|
775
|
+
return r.replace(parseRegex(hyphenRange), (t, n, o, s, l, a, i, c, u, d, p, m) => (isXVersion(o) ? n = "" : isXVersion(s) ? n = `>=${o}.0.0` : isXVersion(l) ? n = `>=${o}.${s}.0` : n = `>=${n}`, isXVersion(u) ? c = "" : isXVersion(d) ? c = `<${Number(u) + 1}.0.0-0` : isXVersion(p) ? c = `<${u}.${Number(d) + 1}.0-0` : m ? c = `<=${u}.${d}.${p}-${m}` : c = `<=${c}`, `${n} ${c}`.trim()));
|
|
776
776
|
}
|
|
777
777
|
function parseComparatorTrim(r) {
|
|
778
778
|
return r.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -784,15 +784,15 @@ function parseCaretTrim(r) {
|
|
|
784
784
|
return r.replace(parseRegex(caretTrim), "$1^");
|
|
785
785
|
}
|
|
786
786
|
function parseCarets(r) {
|
|
787
|
-
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (n, o, s,
|
|
787
|
+
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (n, o, s, l, a) => isXVersion(o) ? "" : isXVersion(s) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(l) ? o === "0" ? `>=${o}.${s}.0 <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.0 <${Number(o) + 1}.0.0-0` : a ? o === "0" ? s === "0" ? `>=${o}.${s}.${l}-${a} <${o}.${s}.${Number(l) + 1}-0` : `>=${o}.${s}.${l}-${a} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${l}-${a} <${Number(o) + 1}.0.0-0` : o === "0" ? s === "0" ? `>=${o}.${s}.${l} <${o}.${s}.${Number(l) + 1}-0` : `>=${o}.${s}.${l} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${l} <${Number(o) + 1}.0.0-0`)).join(" ");
|
|
788
788
|
}
|
|
789
789
|
function parseTildes(r) {
|
|
790
|
-
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (n, o, s,
|
|
790
|
+
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (n, o, s, l, a) => isXVersion(o) ? "" : isXVersion(s) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(l) ? `>=${o}.${s}.0 <${o}.${Number(s) + 1}.0-0` : a ? `>=${o}.${s}.${l}-${a} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${l} <${o}.${Number(s) + 1}.0-0`)).join(" ");
|
|
791
791
|
}
|
|
792
792
|
function parseXRanges(r) {
|
|
793
|
-
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (n, o, s,
|
|
794
|
-
const c = isXVersion(s), u = c || isXVersion(
|
|
795
|
-
return o === "=" &&
|
|
793
|
+
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (n, o, s, l, a, i) => {
|
|
794
|
+
const c = isXVersion(s), u = c || isXVersion(l), d = u || isXVersion(a);
|
|
795
|
+
return o === "=" && d && (o = ""), i = "", c ? o === ">" || o === "<" ? "<0.0.0-0" : "*" : o && d ? (u && (l = 0), a = 0, o === ">" ? (o = ">=", u ? (s = Number(s) + 1, l = 0, a = 0) : (l = Number(l) + 1, a = 0)) : o === "<=" && (o = "<", u ? s = Number(s) + 1 : l = Number(l) + 1), o === "<" && (i = "-0"), `${o + s}.${l}.${a}${i}`) : u ? `>=${s}.0.0${i} <${Number(s) + 1}.0.0-0` : d ? `>=${s}.${l}.0${i} <${s}.${Number(l) + 1}.0-0` : n;
|
|
796
796
|
})).join(" ");
|
|
797
797
|
}
|
|
798
798
|
function parseStar(r) {
|
|
@@ -812,10 +812,10 @@ function comparePreRelease(r, t) {
|
|
|
812
812
|
return -1;
|
|
813
813
|
if (n === void 0 && o === void 0)
|
|
814
814
|
return 0;
|
|
815
|
-
for (let s = 0,
|
|
816
|
-
const
|
|
817
|
-
if (
|
|
818
|
-
return
|
|
815
|
+
for (let s = 0, l = n.length; s <= l; s++) {
|
|
816
|
+
const a = n[s], i = o[s];
|
|
817
|
+
if (a !== i)
|
|
818
|
+
return a === void 0 && i === void 0 ? 0 : a ? i ? compareAtom(a, i) : -1 : 1;
|
|
819
819
|
}
|
|
820
820
|
return 0;
|
|
821
821
|
}
|
|
@@ -885,16 +885,16 @@ function parseRange(r) {
|
|
|
885
885
|
function satisfy(r, t) {
|
|
886
886
|
if (!r)
|
|
887
887
|
return !1;
|
|
888
|
-
const s = parseRange(t).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)),
|
|
889
|
-
if (!
|
|
888
|
+
const s = parseRange(t).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)), l = extractComparator(r);
|
|
889
|
+
if (!l)
|
|
890
890
|
return !1;
|
|
891
|
-
const [,
|
|
892
|
-
operator:
|
|
893
|
-
version: combineVersion(i, c, u,
|
|
891
|
+
const [, a, , i, c, u, d] = l, p = {
|
|
892
|
+
operator: a,
|
|
893
|
+
version: combineVersion(i, c, u, d),
|
|
894
894
|
major: i,
|
|
895
895
|
minor: c,
|
|
896
896
|
patch: u,
|
|
897
|
-
preRelease:
|
|
897
|
+
preRelease: d == null ? void 0 : d.split(".")
|
|
898
898
|
};
|
|
899
899
|
for (const m of s) {
|
|
900
900
|
const y = extractComparator(m);
|
|
@@ -908,7 +908,7 @@ function satisfy(r, t) {
|
|
|
908
908
|
patch: b,
|
|
909
909
|
preRelease: S == null ? void 0 : S.split(".")
|
|
910
910
|
};
|
|
911
|
-
if (!compare(v,
|
|
911
|
+
if (!compare(v, p))
|
|
912
912
|
return !1;
|
|
913
913
|
}
|
|
914
914
|
return !0;
|
|
@@ -918,7 +918,7 @@ function formatShare(r, t, n, o) {
|
|
|
918
918
|
"get" in r ? s = r.get : "lib" in r ? s = () => Promise.resolve(r.lib) : s = () => Promise.resolve(() => {
|
|
919
919
|
throw new Error(`Can not get shared '${n}'!`);
|
|
920
920
|
}), r.strategy && warn('"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"');
|
|
921
|
-
var
|
|
921
|
+
var l, a, i;
|
|
922
922
|
return _extends$1({
|
|
923
923
|
deps: [],
|
|
924
924
|
useIn: [],
|
|
@@ -933,37 +933,37 @@ function formatShare(r, t, n, o) {
|
|
|
933
933
|
}, r.shareConfig),
|
|
934
934
|
get: s,
|
|
935
935
|
loaded: r != null && r.loaded || "lib" in r ? !0 : void 0,
|
|
936
|
-
version: (
|
|
936
|
+
version: (l = r.version) != null ? l : "0",
|
|
937
937
|
scope: Array.isArray(r.scope) ? r.scope : [
|
|
938
|
-
(
|
|
938
|
+
(a = r.scope) != null ? a : "default"
|
|
939
939
|
],
|
|
940
940
|
strategy: ((i = r.strategy) != null ? i : o) || "version-first"
|
|
941
941
|
});
|
|
942
942
|
}
|
|
943
943
|
function formatShareConfigs(r, t) {
|
|
944
|
-
const n = t.shared || {}, o = t.name, s = Object.keys(n).reduce((
|
|
944
|
+
const n = t.shared || {}, o = t.name, s = Object.keys(n).reduce((a, i) => {
|
|
945
945
|
const c = arrayOptions(n[i]);
|
|
946
|
-
return
|
|
947
|
-
|
|
948
|
-
}),
|
|
949
|
-
}, {}),
|
|
950
|
-
return Object.keys(s).forEach((
|
|
951
|
-
a
|
|
952
|
-
a
|
|
953
|
-
}) : a
|
|
946
|
+
return a[i] = a[i] || [], c.forEach((u) => {
|
|
947
|
+
a[i].push(formatShare(u, o, i, t.shareStrategy));
|
|
948
|
+
}), a;
|
|
949
|
+
}, {}), l = _extends$1({}, r.shared);
|
|
950
|
+
return Object.keys(s).forEach((a) => {
|
|
951
|
+
l[a] ? s[a].forEach((i) => {
|
|
952
|
+
l[a].find((u) => u.version === i.version) || l[a].push(i);
|
|
953
|
+
}) : l[a] = s[a];
|
|
954
954
|
}), {
|
|
955
|
-
shared:
|
|
955
|
+
shared: l,
|
|
956
956
|
shareInfos: s
|
|
957
957
|
};
|
|
958
958
|
}
|
|
959
959
|
function versionLt(r, t) {
|
|
960
960
|
const n = (o) => {
|
|
961
961
|
if (!Number.isNaN(Number(o))) {
|
|
962
|
-
const
|
|
963
|
-
let
|
|
964
|
-
for (let i = 0; i < 3 -
|
|
965
|
-
|
|
966
|
-
return
|
|
962
|
+
const l = o.split(".");
|
|
963
|
+
let a = o;
|
|
964
|
+
for (let i = 0; i < 3 - l.length; i++)
|
|
965
|
+
a += ".0";
|
|
966
|
+
return a;
|
|
967
967
|
}
|
|
968
968
|
return o;
|
|
969
969
|
};
|
|
@@ -976,15 +976,15 @@ const findVersion = (r, t) => {
|
|
|
976
976
|
return Object.keys(r).reduce((o, s) => !o || n(o, s) || o === "0" ? s : o, 0);
|
|
977
977
|
}, isLoaded = (r) => !!r.loaded || typeof r.lib == "function", isLoading = (r) => !!r.loading;
|
|
978
978
|
function findSingletonVersionOrderByVersion(r, t, n) {
|
|
979
|
-
const o = r[t][n], s = function(
|
|
980
|
-
return !isLoaded(o[
|
|
979
|
+
const o = r[t][n], s = function(l, a) {
|
|
980
|
+
return !isLoaded(o[l]) && versionLt(l, a);
|
|
981
981
|
};
|
|
982
982
|
return findVersion(r[t][n], s);
|
|
983
983
|
}
|
|
984
984
|
function findSingletonVersionOrderByLoaded(r, t, n) {
|
|
985
|
-
const o = r[t][n], s = function(
|
|
985
|
+
const o = r[t][n], s = function(l, a) {
|
|
986
986
|
const i = (c) => isLoaded(c) || isLoading(c);
|
|
987
|
-
return i(o[
|
|
987
|
+
return i(o[a]) ? i(o[l]) ? !!versionLt(l, a) : !0 : i(o[l]) ? !1 : versionLt(l, a);
|
|
988
988
|
};
|
|
989
989
|
return findVersion(r[t][n], s);
|
|
990
990
|
}
|
|
@@ -994,21 +994,21 @@ function getFindShareFunction(r) {
|
|
|
994
994
|
function getRegisteredShare(r, t, n, o) {
|
|
995
995
|
if (!r)
|
|
996
996
|
return;
|
|
997
|
-
const { shareConfig: s, scope:
|
|
998
|
-
|
|
997
|
+
const { shareConfig: s, scope: l = DEFAULT_SCOPE, strategy: a } = n, i = Array.isArray(l) ? l : [
|
|
998
|
+
l
|
|
999
999
|
];
|
|
1000
1000
|
for (const c of i)
|
|
1001
1001
|
if (s && r[c] && r[c][t]) {
|
|
1002
|
-
const { requiredVersion: u } = s,
|
|
1002
|
+
const { requiredVersion: u } = s, p = getFindShareFunction(a)(r, c, t), m = () => {
|
|
1003
1003
|
if (s.singleton) {
|
|
1004
|
-
if (typeof u == "string" && !satisfy(
|
|
1005
|
-
const E = `Version ${
|
|
1004
|
+
if (typeof u == "string" && !satisfy(p, u)) {
|
|
1005
|
+
const E = `Version ${p} from ${p && r[c][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${n.from} which needs ${u})`;
|
|
1006
1006
|
s.strictVersion ? error(E) : warn(E);
|
|
1007
1007
|
}
|
|
1008
|
-
return r[c][t][
|
|
1008
|
+
return r[c][t][p];
|
|
1009
1009
|
} else {
|
|
1010
|
-
if (u === !1 || u === "*" || satisfy(
|
|
1011
|
-
return r[c][t][
|
|
1010
|
+
if (u === !1 || u === "*" || satisfy(p, u))
|
|
1011
|
+
return r[c][t][p];
|
|
1012
1012
|
for (const [E, g] of Object.entries(r[c][t]))
|
|
1013
1013
|
if (satisfy(E, u))
|
|
1014
1014
|
return g;
|
|
@@ -1017,7 +1017,7 @@ function getRegisteredShare(r, t, n, o) {
|
|
|
1017
1017
|
shareScopeMap: r,
|
|
1018
1018
|
scope: c,
|
|
1019
1019
|
pkgName: t,
|
|
1020
|
-
version:
|
|
1020
|
+
version: p,
|
|
1021
1021
|
GlobalFederation: Global.__FEDERATION__,
|
|
1022
1022
|
resolver: m
|
|
1023
1023
|
};
|
|
@@ -1032,17 +1032,17 @@ function getTargetSharedOptions(r) {
|
|
|
1032
1032
|
if (!i)
|
|
1033
1033
|
return;
|
|
1034
1034
|
const c = {};
|
|
1035
|
-
i.forEach((
|
|
1036
|
-
c[
|
|
1035
|
+
i.forEach((p) => {
|
|
1036
|
+
c[p.version] = p;
|
|
1037
1037
|
});
|
|
1038
|
-
const
|
|
1039
|
-
return !isLoaded(c[
|
|
1038
|
+
const d = findVersion(c, function(p, m) {
|
|
1039
|
+
return !isLoaded(c[p]) && versionLt(p, m);
|
|
1040
1040
|
});
|
|
1041
|
-
return c[
|
|
1041
|
+
return c[d];
|
|
1042
1042
|
};
|
|
1043
|
-
var
|
|
1044
|
-
const
|
|
1045
|
-
return Object.assign({},
|
|
1043
|
+
var l;
|
|
1044
|
+
const a = (l = n == null ? void 0 : n.resolver) != null ? l : s;
|
|
1045
|
+
return Object.assign({}, a(o[t]), n == null ? void 0 : n.customShareInfo);
|
|
1046
1046
|
}
|
|
1047
1047
|
function getBuilderId() {
|
|
1048
1048
|
return typeof FEDERATION_BUILD_IDENTIFIER < "u" ? FEDERATION_BUILD_IDENTIFIER : "";
|
|
@@ -1066,17 +1066,17 @@ function matchRemoteWithNameAndExpose(r, t) {
|
|
|
1066
1066
|
remote: n
|
|
1067
1067
|
};
|
|
1068
1068
|
}
|
|
1069
|
-
const
|
|
1070
|
-
let
|
|
1071
|
-
if (n.alias &&
|
|
1072
|
-
if (
|
|
1069
|
+
const l = n.alias && t.startsWith(n.alias);
|
|
1070
|
+
let a = n.alias && t.replace(n.alias, "");
|
|
1071
|
+
if (n.alias && l) {
|
|
1072
|
+
if (a && a.startsWith("/")) {
|
|
1073
1073
|
const i = n.alias;
|
|
1074
|
-
return
|
|
1074
|
+
return a = `.${a}`, {
|
|
1075
1075
|
pkgNameOrAlias: i,
|
|
1076
|
-
expose:
|
|
1076
|
+
expose: a,
|
|
1077
1077
|
remote: n
|
|
1078
1078
|
};
|
|
1079
|
-
} else if (
|
|
1079
|
+
} else if (a === "")
|
|
1080
1080
|
return {
|
|
1081
1081
|
pkgNameOrAlias: n.alias,
|
|
1082
1082
|
expose: ".",
|
|
@@ -1132,31 +1132,31 @@ async function loadEntryScript({ name: r, globalName: t, entry: n, loaderHook: o
|
|
|
1132
1132
|
const { entryExports: s } = getRemoteEntryExports(r, t);
|
|
1133
1133
|
return s || loadScript(n, {
|
|
1134
1134
|
attrs: {},
|
|
1135
|
-
createScriptHook: (
|
|
1135
|
+
createScriptHook: (l, a) => {
|
|
1136
1136
|
const i = o.lifecycle.createScript.emit({
|
|
1137
|
-
url:
|
|
1138
|
-
attrs:
|
|
1137
|
+
url: l,
|
|
1138
|
+
attrs: a
|
|
1139
1139
|
});
|
|
1140
1140
|
if (i && (i instanceof HTMLScriptElement || "script" in i || "timeout" in i))
|
|
1141
1141
|
return i;
|
|
1142
1142
|
}
|
|
1143
1143
|
}).then(() => {
|
|
1144
|
-
const { remoteEntryKey:
|
|
1145
|
-
return assert(
|
|
1144
|
+
const { remoteEntryKey: l, entryExports: a } = getRemoteEntryExports(r, t);
|
|
1145
|
+
return assert(a, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1146
1146
|
remoteName: r,
|
|
1147
1147
|
remoteEntryUrl: n,
|
|
1148
|
-
remoteEntryKey:
|
|
1149
|
-
})),
|
|
1150
|
-
}).catch((
|
|
1148
|
+
remoteEntryKey: l
|
|
1149
|
+
})), a;
|
|
1150
|
+
}).catch((l) => {
|
|
1151
1151
|
throw assert(void 0, getShortErrorMsg(RUNTIME_008, runtimeDescMap, {
|
|
1152
1152
|
remoteName: r,
|
|
1153
1153
|
resourceUrl: n
|
|
1154
|
-
})),
|
|
1154
|
+
})), l;
|
|
1155
1155
|
});
|
|
1156
1156
|
}
|
|
1157
1157
|
async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook: n }) {
|
|
1158
|
-
const { entry: o, entryGlobalName: s, name:
|
|
1159
|
-
switch (
|
|
1158
|
+
const { entry: o, entryGlobalName: s, name: l, type: a } = r;
|
|
1159
|
+
switch (a) {
|
|
1160
1160
|
case "esm":
|
|
1161
1161
|
case "module":
|
|
1162
1162
|
return loadEsmEntry({
|
|
@@ -1172,18 +1172,18 @@ async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook:
|
|
|
1172
1172
|
return loadEntryScript({
|
|
1173
1173
|
entry: o,
|
|
1174
1174
|
globalName: s,
|
|
1175
|
-
name:
|
|
1175
|
+
name: l,
|
|
1176
1176
|
loaderHook: n
|
|
1177
1177
|
});
|
|
1178
1178
|
}
|
|
1179
1179
|
}
|
|
1180
1180
|
async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
1181
|
-
const { entry: n, entryGlobalName: o, name: s, type:
|
|
1182
|
-
return
|
|
1181
|
+
const { entry: n, entryGlobalName: o, name: s, type: l } = r, { entryExports: a } = getRemoteEntryExports(s, o);
|
|
1182
|
+
return a || loadScriptNode(n, {
|
|
1183
1183
|
attrs: {
|
|
1184
1184
|
name: s,
|
|
1185
1185
|
globalName: o,
|
|
1186
|
-
type:
|
|
1186
|
+
type: l
|
|
1187
1187
|
},
|
|
1188
1188
|
loaderHook: {
|
|
1189
1189
|
createScriptHook: (i, c = {}) => {
|
|
@@ -1215,18 +1215,18 @@ async function getRemoteEntry({ origin: r, remoteEntryExports: t, remoteInfo: n
|
|
|
1215
1215
|
if (t)
|
|
1216
1216
|
return t;
|
|
1217
1217
|
if (!globalLoading[o]) {
|
|
1218
|
-
const s = r.remoteHandler.hooks.lifecycle.loadEntry,
|
|
1218
|
+
const s = r.remoteHandler.hooks.lifecycle.loadEntry, l = r.loaderHook;
|
|
1219
1219
|
globalLoading[o] = s.emit({
|
|
1220
|
-
loaderHook:
|
|
1220
|
+
loaderHook: l,
|
|
1221
1221
|
remoteInfo: n,
|
|
1222
1222
|
remoteEntryExports: t
|
|
1223
|
-
}).then((
|
|
1223
|
+
}).then((a) => a || (isBrowserEnv() ? loadEntryDom({
|
|
1224
1224
|
remoteInfo: n,
|
|
1225
1225
|
remoteEntryExports: t,
|
|
1226
|
-
loaderHook:
|
|
1226
|
+
loaderHook: l
|
|
1227
1227
|
}) : loadEntryNode({
|
|
1228
1228
|
remoteInfo: n,
|
|
1229
|
-
loaderHook:
|
|
1229
|
+
loaderHook: l
|
|
1230
1230
|
})));
|
|
1231
1231
|
}
|
|
1232
1232
|
return globalLoading[o];
|
|
@@ -1266,17 +1266,17 @@ let Module = class {
|
|
|
1266
1266
|
}
|
|
1267
1267
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1268
1268
|
async get(t, n, o, s) {
|
|
1269
|
-
const { loadFactory:
|
|
1269
|
+
const { loadFactory: l = !0 } = o || {
|
|
1270
1270
|
loadFactory: !0
|
|
1271
|
-
},
|
|
1271
|
+
}, a = await this.getEntry();
|
|
1272
1272
|
if (!this.inited) {
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
const y =
|
|
1273
|
+
const p = this.host.shareScopeMap, m = this.remoteInfo.shareScope || "default";
|
|
1274
|
+
p[m] || (p[m] = {});
|
|
1275
|
+
const y = p[m], _ = [], E = {
|
|
1276
1276
|
version: this.remoteInfo.version || ""
|
|
1277
1277
|
};
|
|
1278
1278
|
Object.defineProperty(E, "shareScopeMap", {
|
|
1279
|
-
value:
|
|
1279
|
+
value: p,
|
|
1280
1280
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1281
1281
|
enumerable: !1
|
|
1282
1282
|
});
|
|
@@ -1288,30 +1288,30 @@ let Module = class {
|
|
|
1288
1288
|
remoteInfo: this.remoteInfo,
|
|
1289
1289
|
origin: this.host
|
|
1290
1290
|
});
|
|
1291
|
-
typeof (
|
|
1291
|
+
typeof (a == null ? void 0 : a.init) > "u" && error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
|
|
1292
1292
|
remoteName: name,
|
|
1293
1293
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1294
1294
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1295
|
-
})), await
|
|
1295
|
+
})), await a.init(g.shareScope, g.initScope, g.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit(_extends$1({}, g, {
|
|
1296
1296
|
id: t,
|
|
1297
1297
|
remoteSnapshot: s,
|
|
1298
|
-
remoteEntryExports:
|
|
1298
|
+
remoteEntryExports: a
|
|
1299
1299
|
}));
|
|
1300
1300
|
}
|
|
1301
|
-
this.lib =
|
|
1301
|
+
this.lib = a, this.inited = !0;
|
|
1302
1302
|
let i;
|
|
1303
1303
|
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1304
|
-
remoteEntryExports:
|
|
1304
|
+
remoteEntryExports: a,
|
|
1305
1305
|
expose: n,
|
|
1306
1306
|
moduleInfo: this.remoteInfo
|
|
1307
|
-
}), i || (i = await
|
|
1307
|
+
}), i || (i = await a.get(n)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${n}.`);
|
|
1308
1308
|
const c = processModuleAlias(this.remoteInfo.name, n), u = this.wraperFactory(i, c);
|
|
1309
|
-
return
|
|
1309
|
+
return l ? await u() : u;
|
|
1310
1310
|
}
|
|
1311
1311
|
wraperFactory(t, n) {
|
|
1312
|
-
function o(s,
|
|
1312
|
+
function o(s, l) {
|
|
1313
1313
|
s && typeof s == "object" && Object.isExtensible(s) && !Object.getOwnPropertyDescriptor(s, Symbol.for("mf_module_id")) && Object.defineProperty(s, Symbol.for("mf_module_id"), {
|
|
1314
|
-
value:
|
|
1314
|
+
value: l,
|
|
1315
1315
|
enumerable: !1
|
|
1316
1316
|
});
|
|
1317
1317
|
}
|
|
@@ -1359,8 +1359,8 @@ class AsyncHook extends SyncHook {
|
|
|
1359
1359
|
const o = Array.from(this.listeners);
|
|
1360
1360
|
if (o.length > 0) {
|
|
1361
1361
|
let s = 0;
|
|
1362
|
-
const
|
|
1363
|
-
n =
|
|
1362
|
+
const l = (a) => a === !1 ? !1 : s < o.length ? Promise.resolve(o[s++].apply(null, t)).then(l) : a;
|
|
1363
|
+
n = l();
|
|
1364
1364
|
}
|
|
1365
1365
|
return Promise.resolve(n);
|
|
1366
1366
|
}
|
|
@@ -1402,11 +1402,11 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1402
1402
|
const n = Array.from(this.listeners);
|
|
1403
1403
|
if (n.length > 0) {
|
|
1404
1404
|
let o = 0;
|
|
1405
|
-
const s = (
|
|
1406
|
-
if (checkReturnData(t,
|
|
1407
|
-
if (t =
|
|
1405
|
+
const s = (a) => (warn(a), this.onerror(a), t), l = (a) => {
|
|
1406
|
+
if (checkReturnData(t, a)) {
|
|
1407
|
+
if (t = a, o < n.length)
|
|
1408
1408
|
try {
|
|
1409
|
-
return Promise.resolve(n[o++](t)).then(
|
|
1409
|
+
return Promise.resolve(n[o++](t)).then(l, s);
|
|
1410
1410
|
} catch (i) {
|
|
1411
1411
|
return s(i);
|
|
1412
1412
|
}
|
|
@@ -1414,7 +1414,7 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1414
1414
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
1415
1415
|
return t;
|
|
1416
1416
|
};
|
|
1417
|
-
return Promise.resolve(
|
|
1417
|
+
return Promise.resolve(l(t));
|
|
1418
1418
|
}
|
|
1419
1419
|
return Promise.resolve(t);
|
|
1420
1420
|
}
|
|
@@ -1474,9 +1474,9 @@ function normalizePreloadExposes(r) {
|
|
|
1474
1474
|
return r ? r.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1475
1475
|
}
|
|
1476
1476
|
function preloadAssets(r, t, n, o = !0) {
|
|
1477
|
-
const { cssAssets: s, jsAssetsWithoutEntry:
|
|
1477
|
+
const { cssAssets: s, jsAssetsWithoutEntry: l, entryAssets: a } = n;
|
|
1478
1478
|
if (t.options.inBrowser) {
|
|
1479
|
-
if (
|
|
1479
|
+
if (a.forEach((i) => {
|
|
1480
1480
|
const { moduleInfo: c } = i, u = t.moduleCache.get(r.name);
|
|
1481
1481
|
getRemoteEntry(u ? {
|
|
1482
1482
|
origin: t,
|
|
@@ -1493,21 +1493,21 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1493
1493
|
as: "style"
|
|
1494
1494
|
};
|
|
1495
1495
|
s.forEach((c) => {
|
|
1496
|
-
const { link: u, needAttach:
|
|
1496
|
+
const { link: u, needAttach: d } = createLink({
|
|
1497
1497
|
url: c,
|
|
1498
1498
|
cb: () => {
|
|
1499
1499
|
},
|
|
1500
1500
|
attrs: i,
|
|
1501
|
-
createLinkHook: (
|
|
1501
|
+
createLinkHook: (p, m) => {
|
|
1502
1502
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1503
|
-
url:
|
|
1503
|
+
url: p,
|
|
1504
1504
|
attrs: m
|
|
1505
1505
|
});
|
|
1506
1506
|
if (y instanceof HTMLLinkElement)
|
|
1507
1507
|
return y;
|
|
1508
1508
|
}
|
|
1509
1509
|
});
|
|
1510
|
-
|
|
1510
|
+
d && document.head.appendChild(u);
|
|
1511
1511
|
});
|
|
1512
1512
|
} else {
|
|
1513
1513
|
const i = {
|
|
@@ -1515,14 +1515,14 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1515
1515
|
type: "text/css"
|
|
1516
1516
|
};
|
|
1517
1517
|
s.forEach((c) => {
|
|
1518
|
-
const { link: u, needAttach:
|
|
1518
|
+
const { link: u, needAttach: d } = createLink({
|
|
1519
1519
|
url: c,
|
|
1520
1520
|
cb: () => {
|
|
1521
1521
|
},
|
|
1522
1522
|
attrs: i,
|
|
1523
|
-
createLinkHook: (
|
|
1523
|
+
createLinkHook: (p, m) => {
|
|
1524
1524
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1525
|
-
url:
|
|
1525
|
+
url: p,
|
|
1526
1526
|
attrs: m
|
|
1527
1527
|
});
|
|
1528
1528
|
if (y instanceof HTMLLinkElement)
|
|
@@ -1530,7 +1530,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1530
1530
|
},
|
|
1531
1531
|
needDeleteLink: !1
|
|
1532
1532
|
});
|
|
1533
|
-
|
|
1533
|
+
d && document.head.appendChild(u);
|
|
1534
1534
|
});
|
|
1535
1535
|
}
|
|
1536
1536
|
if (o) {
|
|
@@ -1538,37 +1538,37 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1538
1538
|
rel: "preload",
|
|
1539
1539
|
as: "script"
|
|
1540
1540
|
};
|
|
1541
|
-
|
|
1542
|
-
const { link: u, needAttach:
|
|
1541
|
+
l.forEach((c) => {
|
|
1542
|
+
const { link: u, needAttach: d } = createLink({
|
|
1543
1543
|
url: c,
|
|
1544
1544
|
cb: () => {
|
|
1545
1545
|
},
|
|
1546
1546
|
attrs: i,
|
|
1547
|
-
createLinkHook: (
|
|
1547
|
+
createLinkHook: (p, m) => {
|
|
1548
1548
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1549
|
-
url:
|
|
1549
|
+
url: p,
|
|
1550
1550
|
attrs: m
|
|
1551
1551
|
});
|
|
1552
1552
|
if (y instanceof HTMLLinkElement)
|
|
1553
1553
|
return y;
|
|
1554
1554
|
}
|
|
1555
1555
|
});
|
|
1556
|
-
|
|
1556
|
+
d && document.head.appendChild(u);
|
|
1557
1557
|
});
|
|
1558
1558
|
} else {
|
|
1559
1559
|
const i = {
|
|
1560
1560
|
fetchpriority: "high",
|
|
1561
1561
|
type: (r == null ? void 0 : r.type) === "module" ? "module" : "text/javascript"
|
|
1562
1562
|
};
|
|
1563
|
-
|
|
1564
|
-
const { script: u, needAttach:
|
|
1563
|
+
l.forEach((c) => {
|
|
1564
|
+
const { script: u, needAttach: d } = createScript({
|
|
1565
1565
|
url: c,
|
|
1566
1566
|
cb: () => {
|
|
1567
1567
|
},
|
|
1568
1568
|
attrs: i,
|
|
1569
|
-
createScriptHook: (
|
|
1569
|
+
createScriptHook: (p, m) => {
|
|
1570
1570
|
const y = t.loaderHook.lifecycle.createScript.emit({
|
|
1571
|
-
url:
|
|
1571
|
+
url: p,
|
|
1572
1572
|
attrs: m
|
|
1573
1573
|
});
|
|
1574
1574
|
if (y instanceof HTMLScriptElement)
|
|
@@ -1576,7 +1576,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1576
1576
|
},
|
|
1577
1577
|
needDeleteScript: !0
|
|
1578
1578
|
});
|
|
1579
|
-
|
|
1579
|
+
d && document.head.appendChild(u);
|
|
1580
1580
|
});
|
|
1581
1581
|
}
|
|
1582
1582
|
}
|
|
@@ -1591,10 +1591,10 @@ function snapshotPlugin() {
|
|
|
1591
1591
|
return {
|
|
1592
1592
|
name: "snapshot-plugin",
|
|
1593
1593
|
async afterResolve(r) {
|
|
1594
|
-
const { remote: t, pkgNameOrAlias: n, expose: o, origin: s, remoteInfo:
|
|
1594
|
+
const { remote: t, pkgNameOrAlias: n, expose: o, origin: s, remoteInfo: l } = r;
|
|
1595
1595
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1596
|
-
const { remoteSnapshot:
|
|
1597
|
-
assignRemoteInfo(
|
|
1596
|
+
const { remoteSnapshot: a, globalSnapshot: i } = await s.snapshotHandler.loadRemoteSnapshotInfo(t);
|
|
1597
|
+
assignRemoteInfo(l, a);
|
|
1598
1598
|
const c = {
|
|
1599
1599
|
remote: t,
|
|
1600
1600
|
preloadConfig: {
|
|
@@ -1609,13 +1609,13 @@ function snapshotPlugin() {
|
|
|
1609
1609
|
}, u = await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1610
1610
|
origin: s,
|
|
1611
1611
|
preloadOptions: c,
|
|
1612
|
-
remoteInfo:
|
|
1612
|
+
remoteInfo: l,
|
|
1613
1613
|
remote: t,
|
|
1614
|
-
remoteSnapshot:
|
|
1614
|
+
remoteSnapshot: a,
|
|
1615
1615
|
globalSnapshot: i
|
|
1616
1616
|
});
|
|
1617
|
-
return u && preloadAssets(
|
|
1618
|
-
remoteSnapshot:
|
|
1617
|
+
return u && preloadAssets(l, s, u, !1), _extends$1({}, r, {
|
|
1618
|
+
remoteSnapshot: a
|
|
1619
1619
|
});
|
|
1620
1620
|
}
|
|
1621
1621
|
return r;
|
|
@@ -1635,35 +1635,35 @@ function splitId(r) {
|
|
|
1635
1635
|
version: t[2]
|
|
1636
1636
|
};
|
|
1637
1637
|
}
|
|
1638
|
-
function traverseModuleInfo(r, t, n, o, s = {},
|
|
1639
|
-
const
|
|
1638
|
+
function traverseModuleInfo(r, t, n, o, s = {}, l) {
|
|
1639
|
+
const a = getFMId(t), { value: i } = getInfoWithoutType(r, a), c = l || i;
|
|
1640
1640
|
if (c && !isManifestProvider(c) && (n(c, t, o), c.remotesInfo)) {
|
|
1641
1641
|
const u = Object.keys(c.remotesInfo);
|
|
1642
|
-
for (const
|
|
1643
|
-
if (s[
|
|
1642
|
+
for (const d of u) {
|
|
1643
|
+
if (s[d])
|
|
1644
1644
|
continue;
|
|
1645
|
-
s[
|
|
1646
|
-
const
|
|
1645
|
+
s[d] = !0;
|
|
1646
|
+
const p = splitId(d), m = c.remotesInfo[d];
|
|
1647
1647
|
traverseModuleInfo(r, {
|
|
1648
|
-
name:
|
|
1648
|
+
name: p.name,
|
|
1649
1649
|
version: m.matchedVersion
|
|
1650
1650
|
}, n, !1, s, void 0);
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
1653
|
}
|
|
1654
1654
|
function generatePreloadAssets(r, t, n, o, s) {
|
|
1655
|
-
const
|
|
1655
|
+
const l = [], a = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = r, { preloadConfig: p } = t, { depsRemote: m } = p;
|
|
1656
1656
|
if (traverseModuleInfo(o, n, (g, b, S) => {
|
|
1657
1657
|
let v;
|
|
1658
1658
|
if (S)
|
|
1659
|
-
v =
|
|
1659
|
+
v = p;
|
|
1660
1660
|
else if (Array.isArray(m)) {
|
|
1661
1661
|
const T = m.find((A) => A.nameOrAlias === b.name || A.nameOrAlias === b.alias);
|
|
1662
1662
|
if (!T)
|
|
1663
1663
|
return;
|
|
1664
1664
|
v = defaultPreloadArgs(T);
|
|
1665
1665
|
} else if (m === !0)
|
|
1666
|
-
v =
|
|
1666
|
+
v = p;
|
|
1667
1667
|
else
|
|
1668
1668
|
return;
|
|
1669
1669
|
const I = getResourceUrl(g, getRemoteEntryInfoFromSnapshot(g).url);
|
|
@@ -1700,7 +1700,7 @@ function generatePreloadAssets(r, t, n, o, s) {
|
|
|
1700
1700
|
preloadConfig: v,
|
|
1701
1701
|
remote: b,
|
|
1702
1702
|
origin: r
|
|
1703
|
-
}), !getPreloaded(M) && (v.resourceCategory === "all" ? (
|
|
1703
|
+
}), !getPreloaded(M) && (v.resourceCategory === "all" ? (l.push(...O(P.assets.css.async)), l.push(...O(P.assets.css.sync)), a.push(...O(P.assets.js.async)), a.push(...O(P.assets.js.sync))) : (v.resourceCategory = "sync") && (l.push(...O(P.assets.css.sync)), a.push(...O(P.assets.js.sync))), setPreloaded(M));
|
|
1704
1704
|
}
|
|
1705
1705
|
}
|
|
1706
1706
|
}, !0, {}, s), s.shared) {
|
|
@@ -1714,7 +1714,7 @@ function generatePreloadAssets(r, t, n, o, s) {
|
|
|
1714
1714
|
};
|
|
1715
1715
|
s.shared.forEach((b) => {
|
|
1716
1716
|
var S;
|
|
1717
|
-
const v = (S =
|
|
1717
|
+
const v = (S = d.shared) == null ? void 0 : S[b.sharedName];
|
|
1718
1718
|
if (!v)
|
|
1719
1719
|
return;
|
|
1720
1720
|
const I = b.version ? v.find(($) => $.version === b.version) : v;
|
|
@@ -1725,9 +1725,9 @@ function generatePreloadAssets(r, t, n, o, s) {
|
|
|
1725
1725
|
});
|
|
1726
1726
|
});
|
|
1727
1727
|
}
|
|
1728
|
-
const _ =
|
|
1728
|
+
const _ = a.filter((g) => !c.has(g));
|
|
1729
1729
|
return {
|
|
1730
|
-
cssAssets:
|
|
1730
|
+
cssAssets: l.filter((g) => !u.has(g)),
|
|
1731
1731
|
jsAssetsWithoutEntry: _,
|
|
1732
1732
|
entryAssets: i
|
|
1733
1733
|
};
|
|
@@ -1736,7 +1736,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1736
1736
|
return {
|
|
1737
1737
|
name: "generate-preload-assets-plugin",
|
|
1738
1738
|
async generatePreloadAssets(r) {
|
|
1739
|
-
const { origin: t, preloadOptions: n, remoteInfo: o, remote: s, globalSnapshot:
|
|
1739
|
+
const { origin: t, preloadOptions: n, remoteInfo: o, remote: s, globalSnapshot: l, remoteSnapshot: a } = r;
|
|
1740
1740
|
return isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1741
1741
|
cssAssets: [],
|
|
1742
1742
|
jsAssetsWithoutEntry: [],
|
|
@@ -1753,7 +1753,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1753
1753
|
}
|
|
1754
1754
|
}
|
|
1755
1755
|
]
|
|
1756
|
-
} : (assignRemoteInfo(o,
|
|
1756
|
+
} : (assignRemoteInfo(o, a), generatePreloadAssets(t, n, o, l, a));
|
|
1757
1757
|
}
|
|
1758
1758
|
};
|
|
1759
1759
|
};
|
|
@@ -1780,15 +1780,15 @@ function getGlobalRemoteInfo(r, t) {
|
|
|
1780
1780
|
}
|
|
1781
1781
|
class SnapshotHandler {
|
|
1782
1782
|
async loadSnapshot(t) {
|
|
1783
|
-
const { options: n } = this.HostInstance, { hostGlobalSnapshot: o, remoteSnapshot: s, globalSnapshot:
|
|
1783
|
+
const { options: n } = this.HostInstance, { hostGlobalSnapshot: o, remoteSnapshot: s, globalSnapshot: l } = this.getGlobalRemoteInfo(t), { remoteSnapshot: a, globalSnapshot: i } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1784
1784
|
options: n,
|
|
1785
1785
|
moduleInfo: t,
|
|
1786
1786
|
hostGlobalSnapshot: o,
|
|
1787
1787
|
remoteSnapshot: s,
|
|
1788
|
-
globalSnapshot:
|
|
1788
|
+
globalSnapshot: l
|
|
1789
1789
|
});
|
|
1790
1790
|
return {
|
|
1791
|
-
remoteSnapshot:
|
|
1791
|
+
remoteSnapshot: a,
|
|
1792
1792
|
globalSnapshot: i
|
|
1793
1793
|
};
|
|
1794
1794
|
}
|
|
@@ -1814,39 +1814,39 @@ class SnapshotHandler {
|
|
|
1814
1814
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1815
1815
|
}
|
|
1816
1816
|
}));
|
|
1817
|
-
const { hostGlobalSnapshot: s, remoteSnapshot:
|
|
1817
|
+
const { hostGlobalSnapshot: s, remoteSnapshot: l, globalSnapshot: a } = this.getGlobalRemoteInfo(t), { remoteSnapshot: i, globalSnapshot: c } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1818
1818
|
options: n,
|
|
1819
1819
|
moduleInfo: t,
|
|
1820
1820
|
hostGlobalSnapshot: s,
|
|
1821
|
-
remoteSnapshot:
|
|
1822
|
-
globalSnapshot:
|
|
1821
|
+
remoteSnapshot: l,
|
|
1822
|
+
globalSnapshot: a
|
|
1823
1823
|
});
|
|
1824
|
-
let u,
|
|
1824
|
+
let u, d;
|
|
1825
1825
|
if (i)
|
|
1826
1826
|
if (isManifestProvider(i)) {
|
|
1827
|
-
const
|
|
1827
|
+
const p = isBrowserEnv() ? i.remoteEntry : i.ssrRemoteEntry || i.remoteEntry || "", m = await this.getManifestJson(p, t, {}), y = setGlobalSnapshotInfoByModuleInfo(_extends$1({}, t, {
|
|
1828
1828
|
// The global remote may be overridden
|
|
1829
1829
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1830
|
-
entry:
|
|
1830
|
+
entry: p
|
|
1831
1831
|
}), m);
|
|
1832
|
-
u = m,
|
|
1832
|
+
u = m, d = y;
|
|
1833
1833
|
} else {
|
|
1834
|
-
const { remoteSnapshot:
|
|
1834
|
+
const { remoteSnapshot: p } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1835
1835
|
options: this.HostInstance.options,
|
|
1836
1836
|
moduleInfo: t,
|
|
1837
1837
|
remoteSnapshot: i,
|
|
1838
1838
|
from: "global"
|
|
1839
1839
|
});
|
|
1840
|
-
u =
|
|
1840
|
+
u = p, d = c;
|
|
1841
1841
|
}
|
|
1842
1842
|
else if (isRemoteInfoWithEntry(t)) {
|
|
1843
|
-
const
|
|
1843
|
+
const p = await this.getManifestJson(t.entry, t, {}), m = setGlobalSnapshotInfoByModuleInfo(t, p), { remoteSnapshot: y } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1844
1844
|
options: this.HostInstance.options,
|
|
1845
1845
|
moduleInfo: t,
|
|
1846
|
-
remoteSnapshot:
|
|
1846
|
+
remoteSnapshot: p,
|
|
1847
1847
|
from: "global"
|
|
1848
1848
|
});
|
|
1849
|
-
u = y,
|
|
1849
|
+
u = y, d = m;
|
|
1850
1850
|
} else
|
|
1851
1851
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
1852
1852
|
hostName: t.name,
|
|
@@ -1859,7 +1859,7 @@ class SnapshotHandler {
|
|
|
1859
1859
|
remoteSnapshot: u
|
|
1860
1860
|
}), {
|
|
1861
1861
|
remoteSnapshot: u,
|
|
1862
|
-
globalSnapshot:
|
|
1862
|
+
globalSnapshot: d
|
|
1863
1863
|
};
|
|
1864
1864
|
}
|
|
1865
1865
|
getGlobalRemoteInfo(t) {
|
|
@@ -1867,32 +1867,39 @@ class SnapshotHandler {
|
|
|
1867
1867
|
}
|
|
1868
1868
|
async getManifestJson(t, n, o) {
|
|
1869
1869
|
const s = async () => {
|
|
1870
|
-
let
|
|
1871
|
-
if (
|
|
1872
|
-
return
|
|
1870
|
+
let a = this.manifestCache.get(t);
|
|
1871
|
+
if (a)
|
|
1872
|
+
return a;
|
|
1873
1873
|
try {
|
|
1874
1874
|
let i = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1875
|
-
|
|
1875
|
+
(!i || !(i instanceof Response)) && (i = await fetch(t, {})), a = await i.json();
|
|
1876
1876
|
} catch (i) {
|
|
1877
|
-
|
|
1877
|
+
a = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1878
|
+
id: t,
|
|
1879
|
+
error,
|
|
1880
|
+
from: "runtime",
|
|
1881
|
+
lifecycle: "afterResolve",
|
|
1882
|
+
origin: this.HostInstance
|
|
1883
|
+
}), a || (delete this.manifestLoading[t], error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
1878
1884
|
manifestUrl: t,
|
|
1879
1885
|
moduleName: n.name
|
|
1880
|
-
}, `${i}`));
|
|
1886
|
+
}, `${i}`)));
|
|
1881
1887
|
}
|
|
1882
|
-
|
|
1883
|
-
|
|
1888
|
+
return assert(a.metaData && a.exposes && a.shared, `${t} is not a federation manifest`), this.manifestCache.set(t, a), a;
|
|
1889
|
+
}, l = async () => {
|
|
1890
|
+
const a = await s(), i = generateSnapshotFromManifest(a, {
|
|
1884
1891
|
version: t
|
|
1885
1892
|
}), { remoteSnapshot: c } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1886
1893
|
options: this.HostInstance.options,
|
|
1887
1894
|
moduleInfo: n,
|
|
1888
|
-
manifestJson:
|
|
1895
|
+
manifestJson: a,
|
|
1889
1896
|
remoteSnapshot: i,
|
|
1890
1897
|
manifestUrl: t,
|
|
1891
1898
|
from: "manifest"
|
|
1892
1899
|
});
|
|
1893
1900
|
return c;
|
|
1894
1901
|
};
|
|
1895
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] =
|
|
1902
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = l().then((a) => a)), this.manifestLoading[t];
|
|
1896
1903
|
}
|
|
1897
1904
|
constructor(t) {
|
|
1898
1905
|
this.loadingHostSnapshot = null, this.manifestCache = /* @__PURE__ */ new Map(), this.hooks = new PluginSystem({
|
|
@@ -1907,10 +1914,10 @@ class SharedHandler {
|
|
|
1907
1914
|
// register shared in shareScopeMap
|
|
1908
1915
|
registerShared(t, n) {
|
|
1909
1916
|
const { shareInfos: o, shared: s } = formatShareConfigs(t, n);
|
|
1910
|
-
return Object.keys(o).forEach((
|
|
1911
|
-
o[
|
|
1912
|
-
!getRegisteredShare(this.shareScopeMap,
|
|
1913
|
-
pkgName:
|
|
1917
|
+
return Object.keys(o).forEach((a) => {
|
|
1918
|
+
o[a].forEach((c) => {
|
|
1919
|
+
!getRegisteredShare(this.shareScopeMap, a, c, this.hooks.lifecycle.resolveShare) && c && c.lib && this.setShared({
|
|
1920
|
+
pkgName: a,
|
|
1914
1921
|
lib: c.lib,
|
|
1915
1922
|
get: c.get,
|
|
1916
1923
|
loaded: !0,
|
|
@@ -1934,14 +1941,14 @@ class SharedHandler {
|
|
|
1934
1941
|
strategy: s.strategy
|
|
1935
1942
|
}));
|
|
1936
1943
|
}));
|
|
1937
|
-
const
|
|
1944
|
+
const l = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1938
1945
|
pkgName: t,
|
|
1939
1946
|
shareInfo: s,
|
|
1940
1947
|
shared: o.options.shared,
|
|
1941
1948
|
origin: o
|
|
1942
|
-
}), { shareInfo:
|
|
1943
|
-
assert(
|
|
1944
|
-
const i = getRegisteredShare(this.shareScopeMap, t,
|
|
1949
|
+
}), { shareInfo: a } = l;
|
|
1950
|
+
assert(a, `Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1951
|
+
const i = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare), c = (u) => {
|
|
1945
1952
|
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, o.options.name);
|
|
1946
1953
|
};
|
|
1947
1954
|
if (i && i.lib)
|
|
@@ -1950,11 +1957,11 @@ class SharedHandler {
|
|
|
1950
1957
|
const u = await i.loading;
|
|
1951
1958
|
return i.loaded = !0, i.lib || (i.lib = u), c(i), u;
|
|
1952
1959
|
} else if (i) {
|
|
1953
|
-
const
|
|
1954
|
-
const
|
|
1955
|
-
|
|
1956
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1957
|
-
return m && (m.lib =
|
|
1960
|
+
const d = (async () => {
|
|
1961
|
+
const p = await i.get();
|
|
1962
|
+
a.lib = p, a.loaded = !0, c(a);
|
|
1963
|
+
const m = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare);
|
|
1964
|
+
return m && (m.lib = p, m.loaded = !0), p;
|
|
1958
1965
|
})();
|
|
1959
1966
|
return this.setShared({
|
|
1960
1967
|
pkgName: t,
|
|
@@ -1962,25 +1969,25 @@ class SharedHandler {
|
|
|
1962
1969
|
shared: i,
|
|
1963
1970
|
from: o.options.name,
|
|
1964
1971
|
lib: null,
|
|
1965
|
-
loading:
|
|
1966
|
-
}),
|
|
1972
|
+
loading: d
|
|
1973
|
+
}), d;
|
|
1967
1974
|
} else {
|
|
1968
1975
|
if (n != null && n.customShareInfo)
|
|
1969
1976
|
return !1;
|
|
1970
|
-
const
|
|
1971
|
-
const
|
|
1972
|
-
|
|
1973
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1974
|
-
return m && (m.lib =
|
|
1977
|
+
const d = (async () => {
|
|
1978
|
+
const p = await a.get();
|
|
1979
|
+
a.lib = p, a.loaded = !0, c(a);
|
|
1980
|
+
const m = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare);
|
|
1981
|
+
return m && (m.lib = p, m.loaded = !0), p;
|
|
1975
1982
|
})();
|
|
1976
1983
|
return this.setShared({
|
|
1977
1984
|
pkgName: t,
|
|
1978
1985
|
loaded: !1,
|
|
1979
|
-
shared:
|
|
1986
|
+
shared: a,
|
|
1980
1987
|
from: o.options.name,
|
|
1981
1988
|
lib: null,
|
|
1982
|
-
loading:
|
|
1983
|
-
}),
|
|
1989
|
+
loading: d
|
|
1990
|
+
}), d;
|
|
1984
1991
|
}
|
|
1985
1992
|
}
|
|
1986
1993
|
/**
|
|
@@ -1990,28 +1997,28 @@ class SharedHandler {
|
|
|
1990
1997
|
*/
|
|
1991
1998
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1992
1999
|
initializeSharing(t = DEFAULT_SCOPE, n) {
|
|
1993
|
-
const { host: o } = this, s = n == null ? void 0 : n.from,
|
|
1994
|
-
let
|
|
2000
|
+
const { host: o } = this, s = n == null ? void 0 : n.from, l = n == null ? void 0 : n.strategy;
|
|
2001
|
+
let a = n == null ? void 0 : n.initScope;
|
|
1995
2002
|
const i = [];
|
|
1996
2003
|
if (s !== "build") {
|
|
1997
2004
|
const { initTokens: _ } = this;
|
|
1998
|
-
|
|
2005
|
+
a || (a = []);
|
|
1999
2006
|
let E = _[t];
|
|
2000
2007
|
if (E || (E = _[t] = {
|
|
2001
2008
|
from: this.host.name
|
|
2002
|
-
}),
|
|
2009
|
+
}), a.indexOf(E) >= 0)
|
|
2003
2010
|
return i;
|
|
2004
|
-
|
|
2011
|
+
a.push(E);
|
|
2005
2012
|
}
|
|
2006
2013
|
const c = this.shareScopeMap, u = o.options.name;
|
|
2007
2014
|
c[t] || (c[t] = {});
|
|
2008
|
-
const
|
|
2015
|
+
const d = c[t], p = (_, E) => {
|
|
2009
2016
|
var g;
|
|
2010
2017
|
const { version: b, eager: S } = E;
|
|
2011
|
-
|
|
2012
|
-
const v =
|
|
2018
|
+
d[_] = d[_] || {};
|
|
2019
|
+
const v = d[_], I = v[b], R = !!(I && (I.eager || (g = I.shareConfig) != null && g.eager));
|
|
2013
2020
|
(!I || I.strategy !== "loaded-first" && !I.loaded && (!S != !R ? S : u > I.from)) && (v[b] = E);
|
|
2014
|
-
}, m = (_) => _ && _.init && _.init(c[t],
|
|
2021
|
+
}, m = (_) => _ && _.init && _.init(c[t], a), y = async (_) => {
|
|
2015
2022
|
const { module: E } = await o.remoteHandler.getRemoteModuleAndOptions({
|
|
2016
2023
|
id: _
|
|
2017
2024
|
});
|
|
@@ -2033,9 +2040,9 @@ class SharedHandler {
|
|
|
2033
2040
|
};
|
|
2034
2041
|
return Object.keys(o.options.shared).forEach((_) => {
|
|
2035
2042
|
o.options.shared[_].forEach((g) => {
|
|
2036
|
-
g.scope.includes(t) &&
|
|
2043
|
+
g.scope.includes(t) && p(_, g);
|
|
2037
2044
|
});
|
|
2038
|
-
}), (o.options.shareStrategy === "version-first" ||
|
|
2045
|
+
}), (o.options.shareStrategy === "version-first" || l === "version-first") && o.options.remotes.forEach((_) => {
|
|
2039
2046
|
_.shareScope === t && i.push(y(_.name));
|
|
2040
2047
|
}), i;
|
|
2041
2048
|
}
|
|
@@ -2054,21 +2061,21 @@ class SharedHandler {
|
|
|
2054
2061
|
strategy: s.strategy
|
|
2055
2062
|
});
|
|
2056
2063
|
});
|
|
2057
|
-
const
|
|
2064
|
+
const l = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare), a = (i) => {
|
|
2058
2065
|
i.useIn || (i.useIn = []), addUniqueItem(i.useIn, o.options.name);
|
|
2059
2066
|
};
|
|
2060
|
-
if (
|
|
2061
|
-
if (typeof
|
|
2062
|
-
return l
|
|
2063
|
-
if (typeof
|
|
2064
|
-
const i =
|
|
2067
|
+
if (l) {
|
|
2068
|
+
if (typeof l.lib == "function")
|
|
2069
|
+
return a(l), l.loaded || (l.loaded = !0, l.from === o.options.name && (s.loaded = !0)), l.lib;
|
|
2070
|
+
if (typeof l.get == "function") {
|
|
2071
|
+
const i = l.get();
|
|
2065
2072
|
if (!(i instanceof Promise))
|
|
2066
|
-
return l
|
|
2073
|
+
return a(l), this.setShared({
|
|
2067
2074
|
pkgName: t,
|
|
2068
2075
|
loaded: !0,
|
|
2069
2076
|
from: o.options.name,
|
|
2070
2077
|
lib: i,
|
|
2071
|
-
shared:
|
|
2078
|
+
shared: l
|
|
2072
2079
|
}), i;
|
|
2073
2080
|
}
|
|
2074
2081
|
}
|
|
@@ -2106,8 +2113,8 @@ class SharedHandler {
|
|
|
2106
2113
|
hostShareScopeMap: o.hostShareScopeMap
|
|
2107
2114
|
});
|
|
2108
2115
|
}
|
|
2109
|
-
setShared({ pkgName: t, shared: n, from: o, lib: s, loading:
|
|
2110
|
-
const { version: c, scope: u = "default" } = n,
|
|
2116
|
+
setShared({ pkgName: t, shared: n, from: o, lib: s, loading: l, loaded: a, get: i }) {
|
|
2117
|
+
const { version: c, scope: u = "default" } = n, d = _object_without_properties_loose(n, [
|
|
2111
2118
|
"version",
|
|
2112
2119
|
"scope"
|
|
2113
2120
|
]);
|
|
@@ -2120,15 +2127,15 @@ class SharedHandler {
|
|
|
2120
2127
|
scope: [
|
|
2121
2128
|
"default"
|
|
2122
2129
|
]
|
|
2123
|
-
},
|
|
2130
|
+
}, d, {
|
|
2124
2131
|
lib: s,
|
|
2125
|
-
loaded:
|
|
2126
|
-
loading:
|
|
2132
|
+
loaded: a,
|
|
2133
|
+
loading: l
|
|
2127
2134
|
}), i && (this.shareScopeMap[m][t][c].get = i);
|
|
2128
2135
|
return;
|
|
2129
2136
|
}
|
|
2130
2137
|
const y = this.shareScopeMap[m][t][c];
|
|
2131
|
-
|
|
2138
|
+
l && !y.loading && (y.loading = l);
|
|
2132
2139
|
});
|
|
2133
2140
|
}
|
|
2134
2141
|
_setGlobalShareScopeMap(t) {
|
|
@@ -2149,25 +2156,25 @@ class SharedHandler {
|
|
|
2149
2156
|
}
|
|
2150
2157
|
class RemoteHandler {
|
|
2151
2158
|
formatAndRegisterRemote(t, n) {
|
|
2152
|
-
return (n.remotes || []).reduce((s,
|
|
2159
|
+
return (n.remotes || []).reduce((s, l) => (this.registerRemote(l, s, {
|
|
2153
2160
|
force: !1
|
|
2154
2161
|
}), s), t.remotes);
|
|
2155
2162
|
}
|
|
2156
2163
|
setIdToRemoteMap(t, n) {
|
|
2157
|
-
const { remote: o, expose: s } = n, { name:
|
|
2164
|
+
const { remote: o, expose: s } = n, { name: l, alias: a } = o;
|
|
2158
2165
|
if (this.idToRemoteMap[t] = {
|
|
2159
2166
|
name: o.name,
|
|
2160
2167
|
expose: s
|
|
2161
|
-
},
|
|
2162
|
-
const i = t.replace(
|
|
2168
|
+
}, a && t.startsWith(l)) {
|
|
2169
|
+
const i = t.replace(l, a);
|
|
2163
2170
|
this.idToRemoteMap[i] = {
|
|
2164
2171
|
name: o.name,
|
|
2165
2172
|
expose: s
|
|
2166
2173
|
};
|
|
2167
2174
|
return;
|
|
2168
2175
|
}
|
|
2169
|
-
if (
|
|
2170
|
-
const i = t.replace(
|
|
2176
|
+
if (a && t.startsWith(a)) {
|
|
2177
|
+
const i = t.replace(a, l);
|
|
2171
2178
|
this.idToRemoteMap[i] = {
|
|
2172
2179
|
name: o.name,
|
|
2173
2180
|
expose: s
|
|
@@ -2181,33 +2188,33 @@ class RemoteHandler {
|
|
|
2181
2188
|
try {
|
|
2182
2189
|
const { loadFactory: s = !0 } = n || {
|
|
2183
2190
|
loadFactory: !0
|
|
2184
|
-
}, { module:
|
|
2191
|
+
}, { module: l, moduleOptions: a, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2185
2192
|
id: t
|
|
2186
|
-
}), { pkgNameOrAlias: c, remote: u, expose:
|
|
2187
|
-
id:
|
|
2193
|
+
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await l.get(p, d, n, m), _ = await this.hooks.lifecycle.onLoad.emit({
|
|
2194
|
+
id: p,
|
|
2188
2195
|
pkgNameOrAlias: c,
|
|
2189
|
-
expose:
|
|
2196
|
+
expose: d,
|
|
2190
2197
|
exposeModule: s ? y : void 0,
|
|
2191
2198
|
exposeModuleFactory: s ? void 0 : y,
|
|
2192
2199
|
remote: u,
|
|
2193
|
-
options:
|
|
2194
|
-
moduleInstance:
|
|
2200
|
+
options: a,
|
|
2201
|
+
moduleInstance: l,
|
|
2195
2202
|
origin: o
|
|
2196
2203
|
});
|
|
2197
2204
|
return this.setIdToRemoteMap(t, i), typeof _ == "function" ? _ : y;
|
|
2198
2205
|
} catch (s) {
|
|
2199
|
-
const { from:
|
|
2206
|
+
const { from: l = "runtime" } = n || {
|
|
2200
2207
|
from: "runtime"
|
|
2201
|
-
},
|
|
2208
|
+
}, a = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2202
2209
|
id: t,
|
|
2203
2210
|
error: s,
|
|
2204
|
-
from:
|
|
2211
|
+
from: l,
|
|
2205
2212
|
lifecycle: "onLoad",
|
|
2206
2213
|
origin: o
|
|
2207
2214
|
});
|
|
2208
|
-
if (!
|
|
2215
|
+
if (!a)
|
|
2209
2216
|
throw s;
|
|
2210
|
-
return
|
|
2217
|
+
return a;
|
|
2211
2218
|
}
|
|
2212
2219
|
}
|
|
2213
2220
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2220,15 +2227,15 @@ class RemoteHandler {
|
|
|
2220
2227
|
});
|
|
2221
2228
|
const o = formatPreloadArgs(n.options.remotes, t);
|
|
2222
2229
|
await Promise.all(o.map(async (s) => {
|
|
2223
|
-
const { remote:
|
|
2230
|
+
const { remote: l } = s, a = getRemoteInfo(l), { globalSnapshot: i, remoteSnapshot: c } = await n.snapshotHandler.loadRemoteSnapshotInfo(l), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2224
2231
|
origin: n,
|
|
2225
2232
|
preloadOptions: s,
|
|
2226
|
-
remote:
|
|
2227
|
-
remoteInfo:
|
|
2233
|
+
remote: l,
|
|
2234
|
+
remoteInfo: a,
|
|
2228
2235
|
globalSnapshot: i,
|
|
2229
2236
|
remoteSnapshot: c
|
|
2230
2237
|
});
|
|
2231
|
-
u && preloadAssets(
|
|
2238
|
+
u && preloadAssets(a, n, u);
|
|
2232
2239
|
}));
|
|
2233
2240
|
}
|
|
2234
2241
|
registerRemotes(t, n) {
|
|
@@ -2259,32 +2266,32 @@ class RemoteHandler {
|
|
|
2259
2266
|
}), !s)
|
|
2260
2267
|
throw _;
|
|
2261
2268
|
}
|
|
2262
|
-
const { id:
|
|
2263
|
-
assert(
|
|
2269
|
+
const { id: l } = s, a = matchRemoteWithNameAndExpose(n.options.remotes, l);
|
|
2270
|
+
assert(a, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2264
2271
|
hostName: n.options.name,
|
|
2265
|
-
requestId:
|
|
2272
|
+
requestId: l
|
|
2266
2273
|
}));
|
|
2267
|
-
const { remote: i } =
|
|
2268
|
-
id:
|
|
2269
|
-
},
|
|
2274
|
+
const { remote: i } = a, c = getRemoteInfo(i), u = await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2275
|
+
id: l
|
|
2276
|
+
}, a, {
|
|
2270
2277
|
options: n.options,
|
|
2271
2278
|
origin: n,
|
|
2272
2279
|
remoteInfo: c
|
|
2273
|
-
})), { remote:
|
|
2274
|
-
assert(
|
|
2275
|
-
let m = n.moduleCache.get(
|
|
2280
|
+
})), { remote: d, expose: p } = u;
|
|
2281
|
+
assert(d && p, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${l}.`);
|
|
2282
|
+
let m = n.moduleCache.get(d.name);
|
|
2276
2283
|
const y = {
|
|
2277
2284
|
host: n,
|
|
2278
2285
|
remoteInfo: c
|
|
2279
2286
|
};
|
|
2280
|
-
return m || (m = new Module(y), n.moduleCache.set(
|
|
2287
|
+
return m || (m = new Module(y), n.moduleCache.set(d.name, m)), {
|
|
2281
2288
|
module: m,
|
|
2282
2289
|
moduleOptions: y,
|
|
2283
2290
|
remoteMatchInfo: u
|
|
2284
2291
|
};
|
|
2285
2292
|
}
|
|
2286
2293
|
registerRemote(t, n, o) {
|
|
2287
|
-
const { host: s } = this,
|
|
2294
|
+
const { host: s } = this, l = () => {
|
|
2288
2295
|
if (t.alias) {
|
|
2289
2296
|
const i = n.find((c) => {
|
|
2290
2297
|
var u;
|
|
@@ -2298,9 +2305,9 @@ class RemoteHandler {
|
|
|
2298
2305
|
remote: t,
|
|
2299
2306
|
origin: s
|
|
2300
2307
|
});
|
|
2301
|
-
const
|
|
2302
|
-
if (!
|
|
2303
|
-
|
|
2308
|
+
const a = n.find((i) => i.name === t.name);
|
|
2309
|
+
if (!a)
|
|
2310
|
+
l(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2304
2311
|
remote: t,
|
|
2305
2312
|
origin: s
|
|
2306
2313
|
});
|
|
@@ -2309,7 +2316,7 @@ class RemoteHandler {
|
|
|
2309
2316
|
`The remote "${t.name}" is already registered.`,
|
|
2310
2317
|
"Please note that overriding it may cause unexpected errors."
|
|
2311
2318
|
];
|
|
2312
|
-
o != null && o.force && (this.removeRemote(
|
|
2319
|
+
o != null && o.force && (this.removeRemote(a), l(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2313
2320
|
remote: t,
|
|
2314
2321
|
origin: s
|
|
2315
2322
|
}), warn$1(i.join(" ")));
|
|
@@ -2317,22 +2324,22 @@ class RemoteHandler {
|
|
|
2317
2324
|
}
|
|
2318
2325
|
removeRemote(t) {
|
|
2319
2326
|
try {
|
|
2320
|
-
const { host: o } = this, { name: s } = t,
|
|
2321
|
-
|
|
2322
|
-
const
|
|
2323
|
-
if (
|
|
2324
|
-
const i =
|
|
2327
|
+
const { host: o } = this, { name: s } = t, l = o.options.remotes.findIndex((i) => i.name === s);
|
|
2328
|
+
l !== -1 && o.options.remotes.splice(l, 1);
|
|
2329
|
+
const a = o.moduleCache.get(t.name);
|
|
2330
|
+
if (a) {
|
|
2331
|
+
const i = a.remoteInfo, c = i.entryGlobalName;
|
|
2325
2332
|
if (CurrentGlobal[c]) {
|
|
2326
2333
|
var n;
|
|
2327
2334
|
(n = Object.getOwnPropertyDescriptor(CurrentGlobal, c)) != null && n.configurable ? delete CurrentGlobal[c] : CurrentGlobal[c] = void 0;
|
|
2328
2335
|
}
|
|
2329
|
-
const u = getRemoteEntryUniqueKey(
|
|
2336
|
+
const u = getRemoteEntryUniqueKey(a.remoteInfo);
|
|
2330
2337
|
globalLoading[u] && delete globalLoading[u], o.snapshotHandler.manifestCache.delete(i.entry);
|
|
2331
|
-
let
|
|
2332
|
-
const
|
|
2333
|
-
if (
|
|
2334
|
-
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[
|
|
2335
|
-
|
|
2338
|
+
let d = i.buildVersion ? composeKeyWithSeparator(i.name, i.buildVersion) : i.name;
|
|
2339
|
+
const p = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) => i.buildVersion ? y.options.id === d : y.name === d);
|
|
2340
|
+
if (p !== -1) {
|
|
2341
|
+
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[p];
|
|
2342
|
+
d = y.options.id || d;
|
|
2336
2343
|
const _ = getGlobalShareScope();
|
|
2337
2344
|
let E = !0;
|
|
2338
2345
|
const g = [];
|
|
@@ -2358,10 +2365,10 @@ class RemoteHandler {
|
|
|
2358
2365
|
});
|
|
2359
2366
|
});
|
|
2360
2367
|
});
|
|
2361
|
-
}), E && (y.shareScopeMap = {}, delete _[
|
|
2368
|
+
}), E && (y.shareScopeMap = {}, delete _[d]), g.forEach(([b, S, v, I]) => {
|
|
2362
2369
|
var R, $, w;
|
|
2363
2370
|
(w = _[b]) == null || ($ = w[S]) == null || (R = $[v]) == null || delete R[I];
|
|
2364
|
-
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(
|
|
2371
|
+
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p, 1);
|
|
2365
2372
|
}
|
|
2366
2373
|
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, o);
|
|
2367
2374
|
if (m) {
|
|
@@ -2413,11 +2420,11 @@ class FederationHost {
|
|
|
2413
2420
|
const s = getRemoteInfo({
|
|
2414
2421
|
name: t,
|
|
2415
2422
|
entry: n
|
|
2416
|
-
}),
|
|
2423
|
+
}), l = new Module({
|
|
2417
2424
|
host: this,
|
|
2418
2425
|
remoteInfo: s
|
|
2419
2426
|
});
|
|
2420
|
-
return
|
|
2427
|
+
return l.remoteEntryExports = o, this.moduleCache.set(t, l), l;
|
|
2421
2428
|
}
|
|
2422
2429
|
// eslint-disable-next-line max-lines-per-function
|
|
2423
2430
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2432,20 +2439,20 @@ class FederationHost {
|
|
|
2432
2439
|
this.sharedHandler.initShareScopeMap(t, n, o);
|
|
2433
2440
|
}
|
|
2434
2441
|
formatOptions(t, n) {
|
|
2435
|
-
const { shared: o } = formatShareConfigs(t, n), { userOptions: s, options:
|
|
2442
|
+
const { shared: o } = formatShareConfigs(t, n), { userOptions: s, options: l } = this.hooks.lifecycle.beforeInit.emit({
|
|
2436
2443
|
origin: this,
|
|
2437
2444
|
userOptions: n,
|
|
2438
2445
|
options: t,
|
|
2439
2446
|
shareInfo: o
|
|
2440
|
-
}),
|
|
2441
|
-
...
|
|
2447
|
+
}), a = this.remoteHandler.formatAndRegisterRemote(l, s), { shared: i } = this.sharedHandler.registerShared(l, s), c = [
|
|
2448
|
+
...l.plugins
|
|
2442
2449
|
];
|
|
2443
|
-
s.plugins && s.plugins.forEach((
|
|
2444
|
-
c.includes(
|
|
2450
|
+
s.plugins && s.plugins.forEach((d) => {
|
|
2451
|
+
c.includes(d) || c.push(d);
|
|
2445
2452
|
});
|
|
2446
2453
|
const u = _extends$1({}, t, n, {
|
|
2447
2454
|
plugins: c,
|
|
2448
|
-
remotes:
|
|
2455
|
+
remotes: a,
|
|
2449
2456
|
shared: i
|
|
2450
2457
|
});
|
|
2451
2458
|
return this.hooks.lifecycle.init.emit({
|
|
@@ -2462,7 +2469,7 @@ class FederationHost {
|
|
|
2462
2469
|
this.loaderHook,
|
|
2463
2470
|
this.bridgeHook
|
|
2464
2471
|
]);
|
|
2465
|
-
this.options.plugins = this.options.plugins.reduce((o, s) => (s && o && !o.find((
|
|
2472
|
+
this.options.plugins = this.options.plugins.reduce((o, s) => (s && o && !o.find((l) => l.name === s.name) && o.push(s), o), n || []);
|
|
2466
2473
|
}
|
|
2467
2474
|
registerRemotes(t, n) {
|
|
2468
2475
|
return this.remoteHandler.registerRemotes(t, n);
|
|
@@ -2475,7 +2482,7 @@ class FederationHost {
|
|
|
2475
2482
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2476
2483
|
// maybe will change, temporarily for internal use only
|
|
2477
2484
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2478
|
-
}), this.version = "0.6.
|
|
2485
|
+
}), this.version = "0.6.19", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2479
2486
|
// FIXME: may not be suitable , not open to the public yet
|
|
2480
2487
|
getModuleInfo: new SyncHook(),
|
|
2481
2488
|
createScript: new SyncHook(),
|
|
@@ -2514,30 +2521,31 @@ setGlobalFederationConstructor(FederationHost);
|
|
|
2514
2521
|
function createBridgeComponent(r) {
|
|
2515
2522
|
const t = /* @__PURE__ */ new Map(), n = getInstance();
|
|
2516
2523
|
return () => ({
|
|
2517
|
-
__APP_VERSION__: "0.8.
|
|
2524
|
+
__APP_VERSION__: "0.8.11",
|
|
2518
2525
|
async render(o) {
|
|
2519
|
-
var
|
|
2526
|
+
var y, _, E;
|
|
2520
2527
|
LoggerInstance.debug("createBridgeComponent render Info", o);
|
|
2521
|
-
const s = Vue.createApp(r.rootComponent);
|
|
2522
|
-
t.set(o.dom,
|
|
2523
|
-
const
|
|
2524
|
-
app:
|
|
2525
|
-
basename:
|
|
2526
|
-
memoryRoute:
|
|
2527
|
-
...
|
|
2528
|
+
const { moduleName: s, dom: l, basename: a, memoryRoute: i, ...c } = o, u = Vue.createApp(r.rootComponent, c);
|
|
2529
|
+
t.set(o.dom, u);
|
|
2530
|
+
const d = await ((E = (_ = (y = n == null ? void 0 : n.bridgeHook) == null ? void 0 : y.lifecycle) == null ? void 0 : _.beforeBridgeRender) == null ? void 0 : E.emit(o)), p = d && typeof d == "object" && (d != null && d.extraProps) ? d == null ? void 0 : d.extraProps : {}, m = r.appOptions({
|
|
2531
|
+
app: u,
|
|
2532
|
+
basename: a,
|
|
2533
|
+
memoryRoute: i,
|
|
2534
|
+
...c,
|
|
2535
|
+
...p
|
|
2528
2536
|
});
|
|
2529
|
-
if (
|
|
2530
|
-
const
|
|
2531
|
-
...
|
|
2532
|
-
history:
|
|
2533
|
-
routes:
|
|
2537
|
+
if (m != null && m.router) {
|
|
2538
|
+
const g = o.memoryRoute ? VueRouter.createMemoryHistory(o.basename) : VueRouter.createWebHistory(o.basename), b = VueRouter.createRouter({
|
|
2539
|
+
...m.router.options,
|
|
2540
|
+
history: g,
|
|
2541
|
+
routes: m.router.getRoutes()
|
|
2534
2542
|
});
|
|
2535
2543
|
LoggerInstance.log("createBridgeComponent render router info>>>", {
|
|
2536
2544
|
name: o.moduleName,
|
|
2537
|
-
router:
|
|
2538
|
-
}), o.memoryRoute && await
|
|
2545
|
+
router: b
|
|
2546
|
+
}), o.memoryRoute && await b.push(o.memoryRoute.entryPath), u.use(b);
|
|
2539
2547
|
}
|
|
2540
|
-
|
|
2548
|
+
u.mount(o.dom);
|
|
2541
2549
|
},
|
|
2542
2550
|
destroy(o) {
|
|
2543
2551
|
LoggerInstance.debug("createBridgeComponent destroy Info", o);
|
|
@@ -2559,9 +2567,9 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2559
2567
|
providerInfo: Function
|
|
2560
2568
|
},
|
|
2561
2569
|
setup(r) {
|
|
2562
|
-
const t = ref(null), n = ref(null), o = ref(""), s = useRoute(),
|
|
2563
|
-
var
|
|
2564
|
-
const i = (
|
|
2570
|
+
const t = ref(null), n = ref(null), o = ref(""), s = useRoute(), l = () => {
|
|
2571
|
+
var d;
|
|
2572
|
+
const i = (d = r.providerInfo) == null ? void 0 : d.call(r);
|
|
2565
2573
|
n.value = i;
|
|
2566
2574
|
let c = {
|
|
2567
2575
|
name: r.moduleName,
|
|
@@ -2573,19 +2581,19 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2573
2581
|
...c,
|
|
2574
2582
|
...{}.extraProps
|
|
2575
2583
|
}, i.render(c);
|
|
2576
|
-
},
|
|
2577
|
-
i !== s.path &&
|
|
2584
|
+
}, a = watch(() => s.path, (i) => {
|
|
2585
|
+
i !== s.path && l(), o.value !== "" && o.value !== i && (LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>", {
|
|
2578
2586
|
...r,
|
|
2579
2587
|
pathname: s.path
|
|
2580
2588
|
}), e()), o.value = i;
|
|
2581
2589
|
});
|
|
2582
2590
|
return onMounted(() => {
|
|
2583
|
-
|
|
2591
|
+
l();
|
|
2584
2592
|
}), onBeforeUnmount(() => {
|
|
2585
2593
|
var i;
|
|
2586
2594
|
LoggerInstance.debug("createRemoteComponent LazyComponent destroy >>>", {
|
|
2587
2595
|
...r
|
|
2588
|
-
}),
|
|
2596
|
+
}), a(), (i = n.value) == null || i.destroy({
|
|
2589
2597
|
dom: t.value
|
|
2590
2598
|
});
|
|
2591
2599
|
}), () => createVNode("div", {
|
|
@@ -2595,7 +2603,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2595
2603
|
});
|
|
2596
2604
|
function createRemoteComponent(r) {
|
|
2597
2605
|
return defineAsyncComponent({
|
|
2598
|
-
__APP_VERSION__: "0.8.
|
|
2606
|
+
__APP_VERSION__: "0.8.11",
|
|
2599
2607
|
...r.asyncComponentOptions,
|
|
2600
2608
|
//@ts-ignore
|
|
2601
2609
|
loader: async () => {
|
|
@@ -2609,15 +2617,15 @@ function createRemoteComponent(r) {
|
|
|
2609
2617
|
basename: n,
|
|
2610
2618
|
info: r
|
|
2611
2619
|
});
|
|
2612
|
-
const
|
|
2620
|
+
const l = await r.loader(), a = l && l[Symbol.for("mf_module_id")], i = l[s];
|
|
2613
2621
|
if (LoggerInstance.debug(
|
|
2614
2622
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
2615
|
-
{ name:
|
|
2616
|
-
), s in
|
|
2623
|
+
{ name: a, module: l, exportName: s, basename: n, route: t }
|
|
2624
|
+
), s in l && typeof i == "function")
|
|
2617
2625
|
return {
|
|
2618
2626
|
render() {
|
|
2619
2627
|
return h(RemoteApp, {
|
|
2620
|
-
moduleName:
|
|
2628
|
+
moduleName: a,
|
|
2621
2629
|
providerInfo: i,
|
|
2622
2630
|
basename: n
|
|
2623
2631
|
});
|