@module-federation/bridge-vue3 0.0.0-next-20250515032632 → 0.0.0-next-20250522105937
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 +13 -4
- package/dist/index.cjs +4 -4
- package/dist/index.js +424 -434
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ function _extends$2() {
|
|
|
11
11
|
return t;
|
|
12
12
|
}, _extends$2.apply(this, arguments);
|
|
13
13
|
}
|
|
14
|
-
const MANIFEST_EXT = ".json", BROWSER_LOG_KEY = "FEDERATION_DEBUG",
|
|
14
|
+
const MANIFEST_EXT = ".json", BROWSER_LOG_KEY = "FEDERATION_DEBUG", SEPARATOR = ":";
|
|
15
15
|
function isBrowserEnv() {
|
|
16
16
|
return typeof window < "u" && typeof window.document < "u";
|
|
17
17
|
}
|
|
@@ -22,7 +22,7 @@ function isReactNativeEnv() {
|
|
|
22
22
|
function isBrowserDebug() {
|
|
23
23
|
try {
|
|
24
24
|
if (isBrowserEnv() && window.localStorage)
|
|
25
|
-
return localStorage.getItem(BROWSER_LOG_KEY)
|
|
25
|
+
return !!localStorage.getItem(BROWSER_LOG_KEY);
|
|
26
26
|
} catch {
|
|
27
27
|
return !1;
|
|
28
28
|
}
|
|
@@ -57,8 +57,8 @@ const simpleJoinRemoteEntry = (n, t) => {
|
|
|
57
57
|
if (s.startsWith("./"))
|
|
58
58
|
return s.replace("./", "");
|
|
59
59
|
if (s.startsWith("/")) {
|
|
60
|
-
const
|
|
61
|
-
return
|
|
60
|
+
const a = s.slice(1);
|
|
61
|
+
return a.endsWith("/") ? a.slice(0, -1) : a;
|
|
62
62
|
}
|
|
63
63
|
return s;
|
|
64
64
|
})(n);
|
|
@@ -69,34 +69,34 @@ function inferAutoPublicPath(n) {
|
|
|
69
69
|
}
|
|
70
70
|
function generateSnapshotFromManifest(n, t = {}) {
|
|
71
71
|
var o, r;
|
|
72
|
-
const { remotes: s = {}, overrides:
|
|
72
|
+
const { remotes: s = {}, overrides: a = {}, version: l } = t;
|
|
73
73
|
let i;
|
|
74
|
-
const c = () => "publicPath" in n.metaData ? n.metaData.publicPath === "auto" &&
|
|
74
|
+
const c = () => "publicPath" in n.metaData ? n.metaData.publicPath === "auto" && l ? inferAutoPublicPath(l) : n.metaData.publicPath : n.metaData.getPublicPath, u = Object.keys(a);
|
|
75
75
|
let d = {};
|
|
76
76
|
if (!Object.keys(s).length) {
|
|
77
77
|
var p;
|
|
78
|
-
d = ((p = n.remotes) == null ? void 0 : p.reduce((R,
|
|
78
|
+
d = ((p = n.remotes) == null ? void 0 : p.reduce((R, A) => {
|
|
79
79
|
let T;
|
|
80
|
-
const
|
|
81
|
-
return u.includes(
|
|
80
|
+
const $ = A.federationContainerName;
|
|
81
|
+
return u.includes($) ? T = a[$] : "version" in A ? T = A.version : T = A.entry, R[$] = {
|
|
82
82
|
matchedVersion: T
|
|
83
83
|
}, R;
|
|
84
84
|
}, {})) || {};
|
|
85
85
|
}
|
|
86
86
|
Object.keys(s).forEach((R) => d[R] = {
|
|
87
87
|
// overrides will override dependencies
|
|
88
|
-
matchedVersion: u.includes(R) ?
|
|
88
|
+
matchedVersion: u.includes(R) ? a[R] : s[R]
|
|
89
89
|
});
|
|
90
|
-
const { remoteEntry: { path: m, name: y, type:
|
|
90
|
+
const { remoteEntry: { path: m, name: y, type: E }, types: g, buildInfo: { buildVersion: _ }, globalName: b, ssrRemoteEntry: v } = n.metaData, { exposes: S } = n;
|
|
91
91
|
let I = {
|
|
92
|
-
version:
|
|
92
|
+
version: l || "",
|
|
93
93
|
buildVersion: _,
|
|
94
|
-
globalName:
|
|
94
|
+
globalName: b,
|
|
95
95
|
remoteEntry: simpleJoinRemoteEntry(m, y),
|
|
96
|
-
remoteEntryType:
|
|
97
|
-
remoteTypes: simpleJoinRemoteEntry(
|
|
98
|
-
remoteTypesZip:
|
|
99
|
-
remoteTypesAPI:
|
|
96
|
+
remoteEntryType: E,
|
|
97
|
+
remoteTypes: simpleJoinRemoteEntry(g.path, g.name),
|
|
98
|
+
remoteTypesZip: g.zip || "",
|
|
99
|
+
remoteTypesAPI: g.api || "",
|
|
100
100
|
remotesInfo: d,
|
|
101
101
|
shared: n == null ? void 0 : n.shared.map((R) => ({
|
|
102
102
|
assets: R.assets,
|
|
@@ -116,9 +116,9 @@ function generateSnapshotFromManifest(n, t = {}) {
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
if ((r = n.metaData) != null && r.prefetchEntry) {
|
|
119
|
-
const { path: R, name:
|
|
119
|
+
const { path: R, name: A, type: T } = n.metaData.prefetchEntry;
|
|
120
120
|
I = _extends$2({}, I, {
|
|
121
|
-
prefetchEntry: simpleJoinRemoteEntry(R,
|
|
121
|
+
prefetchEntry: simpleJoinRemoteEntry(R, A),
|
|
122
122
|
prefetchEntryType: T
|
|
123
123
|
});
|
|
124
124
|
}
|
|
@@ -182,9 +182,9 @@ function isStaticResourcesEqual(n, t) {
|
|
|
182
182
|
}
|
|
183
183
|
function createScript(n) {
|
|
184
184
|
let t = null, o = !0, r = 2e4, s;
|
|
185
|
-
const
|
|
186
|
-
for (let i = 0; i <
|
|
187
|
-
const c =
|
|
185
|
+
const a = document.getElementsByTagName("script");
|
|
186
|
+
for (let i = 0; i < a.length; i++) {
|
|
187
|
+
const c = a[i], u = c.getAttribute("src");
|
|
188
188
|
if (u && isStaticResourcesEqual(u, n.url)) {
|
|
189
189
|
t = c, o = !1;
|
|
190
190
|
break;
|
|
@@ -198,7 +198,7 @@ function createScript(n) {
|
|
|
198
198
|
t && (u === "async" || u === "defer" ? t[u] = i[u] : t.getAttribute(u) || t.setAttribute(u, i[u]));
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
const
|
|
201
|
+
const l = async (i, c) => {
|
|
202
202
|
clearTimeout(s);
|
|
203
203
|
const u = () => {
|
|
204
204
|
(c == null ? void 0 : c.type) === "error" ? n != null && n.onErrorCallback && (n == null || n.onErrorCallback(c)) : n != null && n.cb && (n == null || n.cb());
|
|
@@ -216,8 +216,8 @@ function createScript(n) {
|
|
|
216
216
|
}
|
|
217
217
|
u();
|
|
218
218
|
};
|
|
219
|
-
return t.onerror =
|
|
220
|
-
|
|
219
|
+
return t.onerror = l.bind(null, t.onerror), t.onload = l.bind(null, t.onload), s = setTimeout(() => {
|
|
220
|
+
l(null, new Error(`Remote script "${n.url}" time-outed.`));
|
|
221
221
|
}, r), {
|
|
222
222
|
script: t,
|
|
223
223
|
needAttach: o
|
|
@@ -226,30 +226,30 @@ function createScript(n) {
|
|
|
226
226
|
function createLink(n) {
|
|
227
227
|
let t = null, o = !0;
|
|
228
228
|
const r = document.getElementsByTagName("link");
|
|
229
|
-
for (let
|
|
230
|
-
const
|
|
229
|
+
for (let a = 0; a < r.length; a++) {
|
|
230
|
+
const l = r[a], i = l.getAttribute("href"), c = l.getAttribute("rel");
|
|
231
231
|
if (i && isStaticResourcesEqual(i, n.url) && c === n.attrs.rel) {
|
|
232
|
-
t =
|
|
232
|
+
t = l, o = !1;
|
|
233
233
|
break;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
if (!t) {
|
|
237
237
|
t = document.createElement("link"), t.setAttribute("href", n.url);
|
|
238
|
-
let
|
|
239
|
-
const
|
|
240
|
-
n.createLinkHook && (
|
|
241
|
-
t && !t.getAttribute(i) && t.setAttribute(i,
|
|
238
|
+
let a;
|
|
239
|
+
const l = n.attrs;
|
|
240
|
+
n.createLinkHook && (a = n.createLinkHook(n.url, l), a instanceof HTMLLinkElement && (t = a)), l && !a && Object.keys(l).forEach((i) => {
|
|
241
|
+
t && !t.getAttribute(i) && t.setAttribute(i, l[i]);
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
const s = (
|
|
244
|
+
const s = (a, l) => {
|
|
245
245
|
const i = () => {
|
|
246
|
-
(
|
|
246
|
+
(l == null ? void 0 : l.type) === "error" ? n != null && n.onErrorCallback && (n == null || n.onErrorCallback(l)) : n != null && n.cb && (n == null || n.cb());
|
|
247
247
|
};
|
|
248
248
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
249
249
|
const { needDeleteLink: c = !0 } = n;
|
|
250
250
|
c && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
251
|
-
}),
|
|
252
|
-
const c = l
|
|
251
|
+
}), a)) {
|
|
252
|
+
const c = a(l);
|
|
253
253
|
return i(), c;
|
|
254
254
|
}
|
|
255
255
|
i();
|
|
@@ -261,18 +261,18 @@ function createLink(n) {
|
|
|
261
261
|
}
|
|
262
262
|
function loadScript(n, t) {
|
|
263
263
|
const { attrs: o = {}, createScriptHook: r } = t;
|
|
264
|
-
return new Promise((s,
|
|
265
|
-
const { script:
|
|
264
|
+
return new Promise((s, a) => {
|
|
265
|
+
const { script: l, needAttach: i } = createScript({
|
|
266
266
|
url: n,
|
|
267
267
|
cb: s,
|
|
268
|
-
onErrorCallback:
|
|
268
|
+
onErrorCallback: a,
|
|
269
269
|
attrs: _extends$2({
|
|
270
270
|
fetchpriority: "high"
|
|
271
271
|
}, o),
|
|
272
272
|
createScriptHook: r,
|
|
273
273
|
needDeleteScript: !0
|
|
274
274
|
});
|
|
275
|
-
i && document.head.appendChild(
|
|
275
|
+
i && document.head.appendChild(l);
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
278
|
function importNodeModule(n) {
|
|
@@ -286,10 +286,9 @@ const loadNodeFetch = async () => {
|
|
|
286
286
|
const n = await importNodeModule("node-fetch");
|
|
287
287
|
return n.default || n;
|
|
288
288
|
}, lazyLoaderHookFetch = async (n, t, o) => {
|
|
289
|
-
const s = await ((
|
|
289
|
+
const s = await ((a, l) => o.lifecycle.fetch.emit(a, l))(n, t || {});
|
|
290
290
|
return !s || !(s instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(n, t || {}) : s;
|
|
291
|
-
}
|
|
292
|
-
function createScriptNode(url, cb, attrs, loaderHook) {
|
|
291
|
+
}, createScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
|
|
293
292
|
if (loaderHook != null && loaderHook.createScriptHook) {
|
|
294
293
|
const n = loaderHook.createScriptHook(url);
|
|
295
294
|
n && typeof n == "object" && "url" in n && (url = n.url);
|
|
@@ -345,32 +344,33 @@ function createScriptNode(url, cb, attrs, loaderHook) {
|
|
|
345
344
|
}).catch((n) => {
|
|
346
345
|
cb(n);
|
|
347
346
|
});
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
347
|
+
} : (n, t, o, r) => {
|
|
348
|
+
t(new Error("createScriptNode is disabled in non-Node.js environment"));
|
|
349
|
+
}, loadScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (n, t) => new Promise((o, r) => {
|
|
350
|
+
createScriptNode(n, (s, a) => {
|
|
351
|
+
if (s)
|
|
352
|
+
r(s);
|
|
353
|
+
else {
|
|
354
|
+
var l, i;
|
|
355
|
+
const c = (t == null || (l = t.attrs) == null ? void 0 : l.globalName) || `__FEDERATION_${t == null || (i = t.attrs) == null ? void 0 : i.name}:custom__`, u = globalThis[c] = a;
|
|
356
|
+
o(u);
|
|
357
|
+
}
|
|
358
|
+
}, t.attrs, t.loaderHook);
|
|
359
|
+
}) : (n, t) => {
|
|
360
|
+
throw new Error("loadScriptNode is disabled in non-Node.js environment");
|
|
361
|
+
};
|
|
362
362
|
async function loadModule(n, t) {
|
|
363
|
-
const { fetch: o, vm: r } = t,
|
|
363
|
+
const { fetch: o, vm: r } = t, a = await (await o(n)).text(), l = new r.SourceTextModule(a, {
|
|
364
364
|
// @ts-ignore
|
|
365
365
|
importModuleDynamically: async (i, c) => {
|
|
366
366
|
const u = new URL(i, n).href;
|
|
367
367
|
return loadModule(u, t);
|
|
368
368
|
}
|
|
369
369
|
});
|
|
370
|
-
return await
|
|
370
|
+
return await l.link(async (i) => {
|
|
371
371
|
const c = new URL(i, n).href;
|
|
372
372
|
return await loadModule(c, t);
|
|
373
|
-
}),
|
|
373
|
+
}), l;
|
|
374
374
|
}
|
|
375
375
|
const LoggerInstance = createLogger("[ Module Federation Bridge Vue3 ]");
|
|
376
376
|
function _extends$1() {
|
|
@@ -384,9 +384,9 @@ function _extends$1() {
|
|
|
384
384
|
}
|
|
385
385
|
function _object_without_properties_loose(n, t) {
|
|
386
386
|
if (n == null) return {};
|
|
387
|
-
var o = {}, r = Object.keys(n), s,
|
|
388
|
-
for (
|
|
389
|
-
s = r[
|
|
387
|
+
var o = {}, r = Object.keys(n), s, a;
|
|
388
|
+
for (a = 0; a < r.length; a++)
|
|
389
|
+
s = r[a], !(t.indexOf(s) >= 0) && (o[s] = n[s]);
|
|
390
390
|
return o;
|
|
391
391
|
}
|
|
392
392
|
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 = (n) => `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${n.split("-")[0].toLowerCase()}/${n}`, getShortErrorMsg = (n, t, o, r) => {
|
|
@@ -443,7 +443,7 @@ function isRemoteInfoWithEntry(n) {
|
|
|
443
443
|
return typeof n.entry < "u";
|
|
444
444
|
}
|
|
445
445
|
function isPureRemoteEntry(n) {
|
|
446
|
-
return !n.entry.includes(".json")
|
|
446
|
+
return !n.entry.includes(".json");
|
|
447
447
|
}
|
|
448
448
|
function isObject(n) {
|
|
449
449
|
return n && typeof n == "object";
|
|
@@ -496,7 +496,7 @@ function includeOwnProperty(n, t) {
|
|
|
496
496
|
includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
497
497
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
498
498
|
function setGlobalDefaultVal(n) {
|
|
499
|
-
var t, o, r, s,
|
|
499
|
+
var t, o, r, s, a, l;
|
|
500
500
|
includeOwnProperty(n, "__VMOK__") && !includeOwnProperty(n, "__FEDERATION__") && definePropertyGlobalVal(n, "__FEDERATION__", n.__VMOK__), includeOwnProperty(n, "__FEDERATION__") || (definePropertyGlobalVal(n, "__FEDERATION__", {
|
|
501
501
|
__GLOBAL_PLUGIN__: [],
|
|
502
502
|
__INSTANCES__: [],
|
|
@@ -514,14 +514,14 @@ function setGlobalDefaultVal(n) {
|
|
|
514
514
|
var d;
|
|
515
515
|
(d = (s = n.__FEDERATION__).__SHARE__) != null || (s.__SHARE__ = {});
|
|
516
516
|
var p;
|
|
517
|
-
(p = (
|
|
517
|
+
(p = (a = n.__FEDERATION__).__MANIFEST_LOADING__) != null || (a.__MANIFEST_LOADING__ = {});
|
|
518
518
|
var m;
|
|
519
|
-
(m = (
|
|
519
|
+
(m = (l = n.__FEDERATION__).__PRELOADED_MAP__) != null || (l.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
520
520
|
}
|
|
521
521
|
setGlobalDefaultVal(CurrentGlobal);
|
|
522
522
|
setGlobalDefaultVal(nativeGlobal);
|
|
523
523
|
function setGlobalFederationConstructor(n, t = isDebugMode()) {
|
|
524
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = n, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
524
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = n, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.14.0");
|
|
525
525
|
}
|
|
526
526
|
function getInfoWithoutType(n, t) {
|
|
527
527
|
if (typeof t == "string") {
|
|
@@ -533,7 +533,7 @@ function getInfoWithoutType(n, t) {
|
|
|
533
533
|
{
|
|
534
534
|
const r = Object.keys(n);
|
|
535
535
|
for (const s of r) {
|
|
536
|
-
const [
|
|
536
|
+
const [a, l] = s.split(":"), i = `${a}:${t}`, c = n[i];
|
|
537
537
|
if (c)
|
|
538
538
|
return {
|
|
539
539
|
value: c,
|
|
@@ -553,9 +553,9 @@ const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTarge
|
|
|
553
553
|
if (r && !r.version && "version" in n && n.version && (r.version = n.version), r)
|
|
554
554
|
return r;
|
|
555
555
|
if ("version" in n && n.version) {
|
|
556
|
-
const { version: s } = n,
|
|
556
|
+
const { version: s } = n, a = _object_without_properties_loose(n, [
|
|
557
557
|
"version"
|
|
558
|
-
]),
|
|
558
|
+
]), l = getFMId(a), i = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, l).value;
|
|
559
559
|
if ((i == null ? void 0 : i.version) === s)
|
|
560
560
|
return i;
|
|
561
561
|
}
|
|
@@ -590,7 +590,7 @@ function combineVersion(n, t, o, r) {
|
|
|
590
590
|
return r ? `${s}-${r}` : s;
|
|
591
591
|
}
|
|
592
592
|
function parseHyphen(n) {
|
|
593
|
-
return n.replace(parseRegex(hyphenRange), (t, o, r, s,
|
|
593
|
+
return n.replace(parseRegex(hyphenRange), (t, o, r, s, a, l, i, c, u, d, p, m) => (isXVersion(r) ? o = "" : isXVersion(s) ? o = `>=${r}.0.0` : isXVersion(a) ? o = `>=${r}.${s}.0` : o = `>=${o}`, 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}`, `${o} ${c}`.trim()));
|
|
594
594
|
}
|
|
595
595
|
function parseComparatorTrim(n) {
|
|
596
596
|
return n.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -602,15 +602,15 @@ function parseCaretTrim(n) {
|
|
|
602
602
|
return n.replace(parseRegex(caretTrim), "$1^");
|
|
603
603
|
}
|
|
604
604
|
function parseCarets(n) {
|
|
605
|
-
return n.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (o, r, s,
|
|
605
|
+
return n.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (o, r, s, a, l) => isXVersion(r) ? "" : isXVersion(s) ? `>=${r}.0.0 <${Number(r) + 1}.0.0-0` : isXVersion(a) ? r === "0" ? `>=${r}.${s}.0 <${r}.${Number(s) + 1}.0-0` : `>=${r}.${s}.0 <${Number(r) + 1}.0.0-0` : l ? r === "0" ? s === "0" ? `>=${r}.${s}.${a}-${l} <${r}.${s}.${Number(a) + 1}-0` : `>=${r}.${s}.${a}-${l} <${r}.${Number(s) + 1}.0-0` : `>=${r}.${s}.${a}-${l} <${Number(r) + 1}.0.0-0` : r === "0" ? s === "0" ? `>=${r}.${s}.${a} <${r}.${s}.${Number(a) + 1}-0` : `>=${r}.${s}.${a} <${r}.${Number(s) + 1}.0-0` : `>=${r}.${s}.${a} <${Number(r) + 1}.0.0-0`)).join(" ");
|
|
606
606
|
}
|
|
607
607
|
function parseTildes(n) {
|
|
608
|
-
return n.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (o, r, s,
|
|
608
|
+
return n.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (o, r, s, a, l) => isXVersion(r) ? "" : isXVersion(s) ? `>=${r}.0.0 <${Number(r) + 1}.0.0-0` : isXVersion(a) ? `>=${r}.${s}.0 <${r}.${Number(s) + 1}.0-0` : l ? `>=${r}.${s}.${a}-${l} <${r}.${Number(s) + 1}.0-0` : `>=${r}.${s}.${a} <${r}.${Number(s) + 1}.0-0`)).join(" ");
|
|
609
609
|
}
|
|
610
610
|
function parseXRanges(n) {
|
|
611
|
-
return n.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (o, r, s,
|
|
612
|
-
const c = isXVersion(s), u = c || isXVersion(
|
|
613
|
-
return r === "=" && d && (r = ""), i = "", c ? r === ">" || r === "<" ? "<0.0.0-0" : "*" : r && d ? (u && (
|
|
611
|
+
return n.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (o, r, s, a, l, i) => {
|
|
612
|
+
const c = isXVersion(s), u = c || isXVersion(a), d = u || isXVersion(l);
|
|
613
|
+
return r === "=" && d && (r = ""), i = "", c ? r === ">" || r === "<" ? "<0.0.0-0" : "*" : r && d ? (u && (a = 0), l = 0, r === ">" ? (r = ">=", u ? (s = Number(s) + 1, a = 0, l = 0) : (a = Number(a) + 1, l = 0)) : r === "<=" && (r = "<", u ? s = Number(s) + 1 : a = Number(a) + 1), r === "<" && (i = "-0"), `${r + s}.${a}.${l}${i}`) : u ? `>=${s}.0.0${i} <${Number(s) + 1}.0.0-0` : d ? `>=${s}.${a}.0${i} <${s}.${Number(a) + 1}.0-0` : o;
|
|
614
614
|
})).join(" ");
|
|
615
615
|
}
|
|
616
616
|
function parseStar(n) {
|
|
@@ -630,10 +630,10 @@ function comparePreRelease(n, t) {
|
|
|
630
630
|
return -1;
|
|
631
631
|
if (o === void 0 && r === void 0)
|
|
632
632
|
return 0;
|
|
633
|
-
for (let s = 0,
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
636
|
-
return
|
|
633
|
+
for (let s = 0, a = o.length; s <= a; s++) {
|
|
634
|
+
const l = o[s], i = r[s];
|
|
635
|
+
if (l !== i)
|
|
636
|
+
return l === void 0 && i === void 0 ? 0 : l ? i ? compareAtom(l, i) : -1 : 1;
|
|
637
637
|
}
|
|
638
638
|
return 0;
|
|
639
639
|
}
|
|
@@ -703,10 +703,10 @@ function parseRange(n) {
|
|
|
703
703
|
function satisfy(n, t) {
|
|
704
704
|
if (!n)
|
|
705
705
|
return !1;
|
|
706
|
-
const s = parseRange(t).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)),
|
|
707
|
-
if (!
|
|
706
|
+
const s = parseRange(t).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)), a = extractComparator(n);
|
|
707
|
+
if (!a)
|
|
708
708
|
return !1;
|
|
709
|
-
const [,
|
|
709
|
+
const [, l, , i, c, u, d] = a, p = {
|
|
710
710
|
version: combineVersion(i, c, u, d),
|
|
711
711
|
major: i,
|
|
712
712
|
minor: c,
|
|
@@ -717,12 +717,12 @@ function satisfy(n, t) {
|
|
|
717
717
|
const y = extractComparator(m);
|
|
718
718
|
if (!y)
|
|
719
719
|
return !1;
|
|
720
|
-
const [,
|
|
721
|
-
operator:
|
|
722
|
-
version: combineVersion(
|
|
723
|
-
major:
|
|
720
|
+
const [, E, , g, _, b, v] = y, S = {
|
|
721
|
+
operator: E,
|
|
722
|
+
version: combineVersion(g, _, b, v),
|
|
723
|
+
major: g,
|
|
724
724
|
minor: _,
|
|
725
|
-
patch:
|
|
725
|
+
patch: b,
|
|
726
726
|
preRelease: v == null ? void 0 : v.split(".")
|
|
727
727
|
};
|
|
728
728
|
if (!compare(S, p))
|
|
@@ -735,7 +735,7 @@ function formatShare(n, t, o, r) {
|
|
|
735
735
|
"get" in n ? s = n.get : "lib" in n ? s = () => Promise.resolve(n.lib) : s = () => Promise.resolve(() => {
|
|
736
736
|
throw new Error(`Can not get shared '${o}'!`);
|
|
737
737
|
});
|
|
738
|
-
var
|
|
738
|
+
var a, l, i;
|
|
739
739
|
return _extends$1({
|
|
740
740
|
deps: [],
|
|
741
741
|
useIn: [],
|
|
@@ -750,37 +750,37 @@ function formatShare(n, t, o, r) {
|
|
|
750
750
|
}, n.shareConfig),
|
|
751
751
|
get: s,
|
|
752
752
|
loaded: n != null && n.loaded || "lib" in n ? !0 : void 0,
|
|
753
|
-
version: (
|
|
753
|
+
version: (a = n.version) != null ? a : "0",
|
|
754
754
|
scope: Array.isArray(n.scope) ? n.scope : [
|
|
755
|
-
(
|
|
755
|
+
(l = n.scope) != null ? l : "default"
|
|
756
756
|
],
|
|
757
757
|
strategy: ((i = n.strategy) != null ? i : r) || "version-first"
|
|
758
758
|
});
|
|
759
759
|
}
|
|
760
760
|
function formatShareConfigs(n, t) {
|
|
761
|
-
const o = t.shared || {}, r = t.name, s = Object.keys(o).reduce((
|
|
761
|
+
const o = t.shared || {}, r = t.name, s = Object.keys(o).reduce((l, i) => {
|
|
762
762
|
const c = arrayOptions(o[i]);
|
|
763
|
-
return
|
|
764
|
-
|
|
765
|
-
}),
|
|
766
|
-
}, {}),
|
|
767
|
-
return Object.keys(s).forEach((
|
|
768
|
-
l
|
|
769
|
-
l
|
|
770
|
-
}) : l
|
|
763
|
+
return l[i] = l[i] || [], c.forEach((u) => {
|
|
764
|
+
l[i].push(formatShare(u, r, i, t.shareStrategy));
|
|
765
|
+
}), l;
|
|
766
|
+
}, {}), a = _extends$1({}, n.shared);
|
|
767
|
+
return Object.keys(s).forEach((l) => {
|
|
768
|
+
a[l] ? s[l].forEach((i) => {
|
|
769
|
+
a[l].find((u) => u.version === i.version) || a[l].push(i);
|
|
770
|
+
}) : a[l] = s[l];
|
|
771
771
|
}), {
|
|
772
|
-
shared:
|
|
772
|
+
shared: a,
|
|
773
773
|
shareInfos: s
|
|
774
774
|
};
|
|
775
775
|
}
|
|
776
776
|
function versionLt(n, t) {
|
|
777
777
|
const o = (r) => {
|
|
778
778
|
if (!Number.isNaN(Number(r))) {
|
|
779
|
-
const
|
|
780
|
-
let
|
|
781
|
-
for (let i = 0; i < 3 -
|
|
782
|
-
|
|
783
|
-
return
|
|
779
|
+
const a = r.split(".");
|
|
780
|
+
let l = r;
|
|
781
|
+
for (let i = 0; i < 3 - a.length; i++)
|
|
782
|
+
l += ".0";
|
|
783
|
+
return l;
|
|
784
784
|
}
|
|
785
785
|
return r;
|
|
786
786
|
};
|
|
@@ -793,15 +793,15 @@ const findVersion = (n, t) => {
|
|
|
793
793
|
return Object.keys(n).reduce((r, s) => !r || o(r, s) || r === "0" ? s : r, 0);
|
|
794
794
|
}, isLoaded = (n) => !!n.loaded || typeof n.lib == "function", isLoading = (n) => !!n.loading;
|
|
795
795
|
function findSingletonVersionOrderByVersion(n, t, o) {
|
|
796
|
-
const r = n[t][o], s = function(
|
|
797
|
-
return !isLoaded(r[
|
|
796
|
+
const r = n[t][o], s = function(a, l) {
|
|
797
|
+
return !isLoaded(r[a]) && versionLt(a, l);
|
|
798
798
|
};
|
|
799
799
|
return findVersion(n[t][o], s);
|
|
800
800
|
}
|
|
801
801
|
function findSingletonVersionOrderByLoaded(n, t, o) {
|
|
802
|
-
const r = n[t][o], s = function(
|
|
802
|
+
const r = n[t][o], s = function(a, l) {
|
|
803
803
|
const i = (c) => isLoaded(c) || isLoading(c);
|
|
804
|
-
return i(r[
|
|
804
|
+
return i(r[l]) ? i(r[a]) ? !!versionLt(a, l) : !0 : i(r[a]) ? !1 : versionLt(a, l);
|
|
805
805
|
};
|
|
806
806
|
return findVersion(n[t][o], s);
|
|
807
807
|
}
|
|
@@ -811,23 +811,23 @@ function getFindShareFunction(n) {
|
|
|
811
811
|
function getRegisteredShare(n, t, o, r) {
|
|
812
812
|
if (!n)
|
|
813
813
|
return;
|
|
814
|
-
const { shareConfig: s, scope:
|
|
815
|
-
|
|
814
|
+
const { shareConfig: s, scope: a = DEFAULT_SCOPE, strategy: l } = o, i = Array.isArray(a) ? a : [
|
|
815
|
+
a
|
|
816
816
|
];
|
|
817
817
|
for (const c of i)
|
|
818
818
|
if (s && n[c] && n[c][t]) {
|
|
819
|
-
const { requiredVersion: u } = s, p = getFindShareFunction(
|
|
819
|
+
const { requiredVersion: u } = s, p = getFindShareFunction(l)(n, c, t), m = () => {
|
|
820
820
|
if (s.singleton) {
|
|
821
821
|
if (typeof u == "string" && !satisfy(p, u)) {
|
|
822
|
-
const
|
|
823
|
-
s.strictVersion ? error(
|
|
822
|
+
const g = `Version ${p} from ${p && n[c][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${o.from} which needs ${u})`;
|
|
823
|
+
s.strictVersion ? error(g) : warn(g);
|
|
824
824
|
}
|
|
825
825
|
return n[c][t][p];
|
|
826
826
|
} else {
|
|
827
827
|
if (u === !1 || u === "*" || satisfy(p, u))
|
|
828
828
|
return n[c][t][p];
|
|
829
|
-
for (const [
|
|
830
|
-
if (satisfy(
|
|
829
|
+
for (const [g, _] of Object.entries(n[c][t]))
|
|
830
|
+
if (satisfy(g, u))
|
|
831
831
|
return _;
|
|
832
832
|
}
|
|
833
833
|
}, y = {
|
|
@@ -857,9 +857,9 @@ function getTargetSharedOptions(n) {
|
|
|
857
857
|
});
|
|
858
858
|
return c[d];
|
|
859
859
|
};
|
|
860
|
-
var
|
|
861
|
-
const
|
|
862
|
-
return Object.assign({},
|
|
860
|
+
var a;
|
|
861
|
+
const l = (a = o == null ? void 0 : o.resolver) != null ? a : s;
|
|
862
|
+
return Object.assign({}, l(r[t]), o == null ? void 0 : o.customShareInfo);
|
|
863
863
|
}
|
|
864
864
|
function getBuilderId() {
|
|
865
865
|
return typeof FEDERATION_BUILD_IDENTIFIER < "u" ? FEDERATION_BUILD_IDENTIFIER : "";
|
|
@@ -883,17 +883,17 @@ function matchRemoteWithNameAndExpose(n, t) {
|
|
|
883
883
|
remote: o
|
|
884
884
|
};
|
|
885
885
|
}
|
|
886
|
-
const
|
|
887
|
-
let
|
|
888
|
-
if (o.alias &&
|
|
889
|
-
if (
|
|
886
|
+
const a = o.alias && t.startsWith(o.alias);
|
|
887
|
+
let l = o.alias && t.replace(o.alias, "");
|
|
888
|
+
if (o.alias && a) {
|
|
889
|
+
if (l && l.startsWith("/")) {
|
|
890
890
|
const i = o.alias;
|
|
891
|
-
return
|
|
891
|
+
return l = `.${l}`, {
|
|
892
892
|
pkgNameOrAlias: i,
|
|
893
|
-
expose:
|
|
893
|
+
expose: l,
|
|
894
894
|
remote: o
|
|
895
895
|
};
|
|
896
|
-
} else if (
|
|
896
|
+
} else if (l === "")
|
|
897
897
|
return {
|
|
898
898
|
pkgNameOrAlias: o.alias,
|
|
899
899
|
expose: ".",
|
|
@@ -917,10 +917,11 @@ function registerPlugins(n, t) {
|
|
|
917
917
|
});
|
|
918
918
|
}), n;
|
|
919
919
|
}
|
|
920
|
+
const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
|
|
920
921
|
async function loadEsmEntry({ entry: n, remoteEntryExports: t }) {
|
|
921
922
|
return new Promise((o, r) => {
|
|
922
923
|
try {
|
|
923
|
-
t ? o(t) : typeof FEDERATION_ALLOW_NEW_FUNCTION < "u" ? new Function("callbacks", `import("${n}")
|
|
924
|
+
t ? o(t) : typeof FEDERATION_ALLOW_NEW_FUNCTION < "u" ? new Function("callbacks", `import("${n}")${importCallback}`)([
|
|
924
925
|
o,
|
|
925
926
|
r
|
|
926
927
|
]) : import(
|
|
@@ -936,7 +937,7 @@ async function loadEsmEntry({ entry: n, remoteEntryExports: t }) {
|
|
|
936
937
|
async function loadSystemJsEntry({ entry: n, remoteEntryExports: t }) {
|
|
937
938
|
return new Promise((o, r) => {
|
|
938
939
|
try {
|
|
939
|
-
t ? o(t) : typeof __system_context__ > "u" ? System.import(n).then(o).catch(r) : new Function("callbacks", `System.import("${n}")
|
|
940
|
+
t ? o(t) : typeof __system_context__ > "u" ? System.import(n).then(o).catch(r) : new Function("callbacks", `System.import("${n}")${importCallback}`)([
|
|
940
941
|
o,
|
|
941
942
|
r
|
|
942
943
|
]);
|
|
@@ -945,35 +946,36 @@ async function loadSystemJsEntry({ entry: n, remoteEntryExports: t }) {
|
|
|
945
946
|
}
|
|
946
947
|
});
|
|
947
948
|
}
|
|
949
|
+
function handleRemoteEntryLoaded(n, t, o) {
|
|
950
|
+
const { remoteEntryKey: r, entryExports: s } = getRemoteEntryExports(n, t);
|
|
951
|
+
return assert(s, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
952
|
+
remoteName: n,
|
|
953
|
+
remoteEntryUrl: o,
|
|
954
|
+
remoteEntryKey: r
|
|
955
|
+
})), s;
|
|
956
|
+
}
|
|
948
957
|
async function loadEntryScript({ name: n, globalName: t, entry: o, loaderHook: r }) {
|
|
949
958
|
const { entryExports: s } = getRemoteEntryExports(n, t);
|
|
950
959
|
return s || loadScript(o, {
|
|
951
960
|
attrs: {},
|
|
952
|
-
createScriptHook: (
|
|
961
|
+
createScriptHook: (a, l) => {
|
|
953
962
|
const i = r.lifecycle.createScript.emit({
|
|
954
|
-
url:
|
|
955
|
-
attrs:
|
|
963
|
+
url: a,
|
|
964
|
+
attrs: l
|
|
956
965
|
});
|
|
957
966
|
if (i && (i instanceof HTMLScriptElement || "script" in i || "timeout" in i))
|
|
958
967
|
return i;
|
|
959
968
|
}
|
|
960
|
-
}).then(() => {
|
|
961
|
-
const { remoteEntryKey: l, entryExports: a } = getRemoteEntryExports(n, t);
|
|
962
|
-
return assert(a, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
963
|
-
remoteName: n,
|
|
964
|
-
remoteEntryUrl: o,
|
|
965
|
-
remoteEntryKey: l
|
|
966
|
-
})), a;
|
|
967
|
-
}).catch((l) => {
|
|
969
|
+
}).then(() => handleRemoteEntryLoaded(n, t, o)).catch((a) => {
|
|
968
970
|
throw assert(void 0, getShortErrorMsg(RUNTIME_008, runtimeDescMap, {
|
|
969
971
|
remoteName: n,
|
|
970
972
|
resourceUrl: o
|
|
971
|
-
})),
|
|
973
|
+
})), a;
|
|
972
974
|
});
|
|
973
975
|
}
|
|
974
976
|
async function loadEntryDom({ remoteInfo: n, remoteEntryExports: t, loaderHook: o }) {
|
|
975
|
-
const { entry: r, entryGlobalName: s, name:
|
|
976
|
-
switch (
|
|
977
|
+
const { entry: r, entryGlobalName: s, name: a, type: l } = n;
|
|
978
|
+
switch (l) {
|
|
977
979
|
case "esm":
|
|
978
980
|
case "module":
|
|
979
981
|
return loadEsmEntry({
|
|
@@ -989,18 +991,18 @@ async function loadEntryDom({ remoteInfo: n, remoteEntryExports: t, loaderHook:
|
|
|
989
991
|
return loadEntryScript({
|
|
990
992
|
entry: r,
|
|
991
993
|
globalName: s,
|
|
992
|
-
name:
|
|
994
|
+
name: a,
|
|
993
995
|
loaderHook: o
|
|
994
996
|
});
|
|
995
997
|
}
|
|
996
998
|
}
|
|
997
999
|
async function loadEntryNode({ remoteInfo: n, loaderHook: t }) {
|
|
998
|
-
const { entry: o, entryGlobalName: r, name: s, type:
|
|
999
|
-
return
|
|
1000
|
+
const { entry: o, entryGlobalName: r, name: s, type: a } = n, { entryExports: l } = getRemoteEntryExports(s, r);
|
|
1001
|
+
return l || loadScriptNode(o, {
|
|
1000
1002
|
attrs: {
|
|
1001
1003
|
name: s,
|
|
1002
1004
|
globalName: r,
|
|
1003
|
-
type:
|
|
1005
|
+
type: a
|
|
1004
1006
|
},
|
|
1005
1007
|
loaderHook: {
|
|
1006
1008
|
createScriptHook: (i, c = {}) => {
|
|
@@ -1012,14 +1014,7 @@ async function loadEntryNode({ remoteInfo: n, loaderHook: t }) {
|
|
|
1012
1014
|
return u;
|
|
1013
1015
|
}
|
|
1014
1016
|
}
|
|
1015
|
-
}).then(() => {
|
|
1016
|
-
const { remoteEntryKey: i, entryExports: c } = getRemoteEntryExports(s, r);
|
|
1017
|
-
return assert(c, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1018
|
-
remoteName: s,
|
|
1019
|
-
remoteEntryUrl: o,
|
|
1020
|
-
remoteEntryKey: i
|
|
1021
|
-
})), c;
|
|
1022
|
-
}).catch((i) => {
|
|
1017
|
+
}).then(() => handleRemoteEntryLoaded(s, r, o)).catch((i) => {
|
|
1023
1018
|
throw i;
|
|
1024
1019
|
});
|
|
1025
1020
|
}
|
|
@@ -1032,18 +1027,18 @@ async function getRemoteEntry({ origin: n, remoteEntryExports: t, remoteInfo: o
|
|
|
1032
1027
|
if (t)
|
|
1033
1028
|
return t;
|
|
1034
1029
|
if (!globalLoading[r]) {
|
|
1035
|
-
const s = n.remoteHandler.hooks.lifecycle.loadEntry,
|
|
1030
|
+
const s = n.remoteHandler.hooks.lifecycle.loadEntry, a = n.loaderHook;
|
|
1036
1031
|
globalLoading[r] = s.emit({
|
|
1037
|
-
loaderHook:
|
|
1032
|
+
loaderHook: a,
|
|
1038
1033
|
remoteInfo: o,
|
|
1039
1034
|
remoteEntryExports: t
|
|
1040
|
-
}).then((
|
|
1035
|
+
}).then((l) => l || ((typeof ENV_TARGET < "u" ? ENV_TARGET === "web" : isBrowserEnv()) ? loadEntryDom({
|
|
1041
1036
|
remoteInfo: o,
|
|
1042
1037
|
remoteEntryExports: t,
|
|
1043
|
-
loaderHook:
|
|
1038
|
+
loaderHook: a
|
|
1044
1039
|
}) : loadEntryNode({
|
|
1045
1040
|
remoteInfo: o,
|
|
1046
|
-
loaderHook:
|
|
1041
|
+
loaderHook: a
|
|
1047
1042
|
})));
|
|
1048
1043
|
}
|
|
1049
1044
|
return globalLoading[r];
|
|
@@ -1083,21 +1078,21 @@ let Module = class {
|
|
|
1083
1078
|
}
|
|
1084
1079
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1085
1080
|
async get(t, o, r, s) {
|
|
1086
|
-
const { loadFactory:
|
|
1081
|
+
const { loadFactory: a = !0 } = r || {
|
|
1087
1082
|
loadFactory: !0
|
|
1088
|
-
},
|
|
1083
|
+
}, l = await this.getEntry();
|
|
1089
1084
|
if (!this.inited) {
|
|
1090
1085
|
const p = this.host.shareScopeMap, m = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [
|
|
1091
1086
|
this.remoteInfo.shareScope
|
|
1092
1087
|
];
|
|
1093
|
-
m.length || m.push("default"), m.forEach((
|
|
1094
|
-
p[
|
|
1088
|
+
m.length || m.push("default"), m.forEach((b) => {
|
|
1089
|
+
p[b] || (p[b] = {});
|
|
1095
1090
|
});
|
|
1096
|
-
const y = p[m[0]],
|
|
1091
|
+
const y = p[m[0]], E = [], g = {
|
|
1097
1092
|
version: this.remoteInfo.version || "",
|
|
1098
1093
|
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? m : this.remoteInfo.shareScope || "default"
|
|
1099
1094
|
};
|
|
1100
|
-
Object.defineProperty(
|
|
1095
|
+
Object.defineProperty(g, "shareScopeMap", {
|
|
1101
1096
|
value: p,
|
|
1102
1097
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1103
1098
|
enumerable: !1
|
|
@@ -1105,35 +1100,35 @@ let Module = class {
|
|
|
1105
1100
|
const _ = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1106
1101
|
shareScope: y,
|
|
1107
1102
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1108
|
-
remoteEntryInitOptions:
|
|
1109
|
-
initScope:
|
|
1103
|
+
remoteEntryInitOptions: g,
|
|
1104
|
+
initScope: E,
|
|
1110
1105
|
remoteInfo: this.remoteInfo,
|
|
1111
1106
|
origin: this.host
|
|
1112
1107
|
});
|
|
1113
|
-
typeof (
|
|
1108
|
+
typeof (l == null ? void 0 : l.init) > "u" && error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
|
|
1114
1109
|
remoteName: name,
|
|
1115
1110
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1116
1111
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1117
|
-
})), await
|
|
1112
|
+
})), await l.init(_.shareScope, _.initScope, _.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit(_extends$1({}, _, {
|
|
1118
1113
|
id: t,
|
|
1119
1114
|
remoteSnapshot: s,
|
|
1120
|
-
remoteEntryExports:
|
|
1115
|
+
remoteEntryExports: l
|
|
1121
1116
|
}));
|
|
1122
1117
|
}
|
|
1123
|
-
this.lib =
|
|
1118
|
+
this.lib = l, this.inited = !0;
|
|
1124
1119
|
let i;
|
|
1125
1120
|
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1126
|
-
remoteEntryExports:
|
|
1121
|
+
remoteEntryExports: l,
|
|
1127
1122
|
expose: o,
|
|
1128
1123
|
moduleInfo: this.remoteInfo
|
|
1129
|
-
}), i || (i = await
|
|
1124
|
+
}), i || (i = await l.get(o)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${o}.`);
|
|
1130
1125
|
const c = processModuleAlias(this.remoteInfo.name, o), u = this.wraperFactory(i, c);
|
|
1131
|
-
return
|
|
1126
|
+
return a ? await u() : u;
|
|
1132
1127
|
}
|
|
1133
1128
|
wraperFactory(t, o) {
|
|
1134
|
-
function r(s,
|
|
1129
|
+
function r(s, a) {
|
|
1135
1130
|
s && typeof s == "object" && Object.isExtensible(s) && !Object.getOwnPropertyDescriptor(s, Symbol.for("mf_module_id")) && Object.defineProperty(s, Symbol.for("mf_module_id"), {
|
|
1136
|
-
value:
|
|
1131
|
+
value: a,
|
|
1137
1132
|
enumerable: !1
|
|
1138
1133
|
});
|
|
1139
1134
|
}
|
|
@@ -1181,8 +1176,8 @@ class AsyncHook extends SyncHook {
|
|
|
1181
1176
|
const r = Array.from(this.listeners);
|
|
1182
1177
|
if (r.length > 0) {
|
|
1183
1178
|
let s = 0;
|
|
1184
|
-
const
|
|
1185
|
-
o =
|
|
1179
|
+
const a = (l) => l === !1 ? !1 : s < r.length ? Promise.resolve(r[s++].apply(null, t)).then(a) : l;
|
|
1180
|
+
o = a();
|
|
1186
1181
|
}
|
|
1187
1182
|
return Promise.resolve(o);
|
|
1188
1183
|
}
|
|
@@ -1224,11 +1219,11 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1224
1219
|
const o = Array.from(this.listeners);
|
|
1225
1220
|
if (o.length > 0) {
|
|
1226
1221
|
let r = 0;
|
|
1227
|
-
const s = (
|
|
1228
|
-
if (checkReturnData(t,
|
|
1229
|
-
if (t =
|
|
1222
|
+
const s = (l) => (warn(l), this.onerror(l), t), a = (l) => {
|
|
1223
|
+
if (checkReturnData(t, l)) {
|
|
1224
|
+
if (t = l, r < o.length)
|
|
1230
1225
|
try {
|
|
1231
|
-
return Promise.resolve(o[r++](t)).then(
|
|
1226
|
+
return Promise.resolve(o[r++](t)).then(a, s);
|
|
1232
1227
|
} catch (i) {
|
|
1233
1228
|
return s(i);
|
|
1234
1229
|
}
|
|
@@ -1236,7 +1231,7 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1236
1231
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
1237
1232
|
return t;
|
|
1238
1233
|
};
|
|
1239
|
-
return Promise.resolve(
|
|
1234
|
+
return Promise.resolve(a(t));
|
|
1240
1235
|
}
|
|
1241
1236
|
return Promise.resolve(t);
|
|
1242
1237
|
}
|
|
@@ -1296,9 +1291,9 @@ function normalizePreloadExposes(n) {
|
|
|
1296
1291
|
return n ? n.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1297
1292
|
}
|
|
1298
1293
|
function preloadAssets(n, t, o, r = !0) {
|
|
1299
|
-
const { cssAssets: s, jsAssetsWithoutEntry:
|
|
1294
|
+
const { cssAssets: s, jsAssetsWithoutEntry: a, entryAssets: l } = o;
|
|
1300
1295
|
if (t.options.inBrowser) {
|
|
1301
|
-
if (
|
|
1296
|
+
if (l.forEach((i) => {
|
|
1302
1297
|
const { moduleInfo: c } = i, u = t.moduleCache.get(n.name);
|
|
1303
1298
|
getRemoteEntry(u ? {
|
|
1304
1299
|
origin: t,
|
|
@@ -1360,7 +1355,7 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1360
1355
|
rel: "preload",
|
|
1361
1356
|
as: "script"
|
|
1362
1357
|
};
|
|
1363
|
-
|
|
1358
|
+
a.forEach((c) => {
|
|
1364
1359
|
const { link: u, needAttach: d } = createLink({
|
|
1365
1360
|
url: c,
|
|
1366
1361
|
cb: () => {
|
|
@@ -1382,7 +1377,7 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1382
1377
|
fetchpriority: "high",
|
|
1383
1378
|
type: (n == null ? void 0 : n.type) === "module" ? "module" : "text/javascript"
|
|
1384
1379
|
};
|
|
1385
|
-
|
|
1380
|
+
a.forEach((c) => {
|
|
1386
1381
|
const { script: u, needAttach: d } = createScript({
|
|
1387
1382
|
url: c,
|
|
1388
1383
|
cb: () => {
|
|
@@ -1413,11 +1408,14 @@ function snapshotPlugin() {
|
|
|
1413
1408
|
return {
|
|
1414
1409
|
name: "snapshot-plugin",
|
|
1415
1410
|
async afterResolve(n) {
|
|
1416
|
-
const { remote: t, pkgNameOrAlias: o, expose: r, origin: s, remoteInfo: l } = n;
|
|
1411
|
+
const { remote: t, pkgNameOrAlias: o, expose: r, origin: s, remoteInfo: a, id: l } = n;
|
|
1417
1412
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1418
|
-
const { remoteSnapshot:
|
|
1419
|
-
|
|
1420
|
-
|
|
1413
|
+
const { remoteSnapshot: i, globalSnapshot: c } = await s.snapshotHandler.loadRemoteSnapshotInfo({
|
|
1414
|
+
moduleInfo: t,
|
|
1415
|
+
id: l
|
|
1416
|
+
});
|
|
1417
|
+
assignRemoteInfo(a, i);
|
|
1418
|
+
const u = {
|
|
1421
1419
|
remote: t,
|
|
1422
1420
|
preloadConfig: {
|
|
1423
1421
|
nameOrAlias: o,
|
|
@@ -1428,16 +1426,16 @@ function snapshotPlugin() {
|
|
|
1428
1426
|
share: !1,
|
|
1429
1427
|
depsRemote: !1
|
|
1430
1428
|
}
|
|
1431
|
-
},
|
|
1429
|
+
}, d = await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1432
1430
|
origin: s,
|
|
1433
|
-
preloadOptions:
|
|
1434
|
-
remoteInfo:
|
|
1431
|
+
preloadOptions: u,
|
|
1432
|
+
remoteInfo: a,
|
|
1435
1433
|
remote: t,
|
|
1436
|
-
remoteSnapshot:
|
|
1437
|
-
globalSnapshot:
|
|
1434
|
+
remoteSnapshot: i,
|
|
1435
|
+
globalSnapshot: c
|
|
1438
1436
|
});
|
|
1439
|
-
return
|
|
1440
|
-
remoteSnapshot:
|
|
1437
|
+
return d && preloadAssets(a, s, d, !1), _extends$1({}, n, {
|
|
1438
|
+
remoteSnapshot: i
|
|
1441
1439
|
});
|
|
1442
1440
|
}
|
|
1443
1441
|
return n;
|
|
@@ -1457,8 +1455,8 @@ function splitId(n) {
|
|
|
1457
1455
|
version: t[2]
|
|
1458
1456
|
};
|
|
1459
1457
|
}
|
|
1460
|
-
function traverseModuleInfo(n, t, o, r, s = {},
|
|
1461
|
-
const
|
|
1458
|
+
function traverseModuleInfo(n, t, o, r, s = {}, a) {
|
|
1459
|
+
const l = getFMId(t), { value: i } = getInfoWithoutType(n, l), c = a || i;
|
|
1462
1460
|
if (c && !isManifestProvider(c) && (o(c, t, r), c.remotesInfo)) {
|
|
1463
1461
|
const u = Object.keys(c.remotesInfo);
|
|
1464
1462
|
for (const d of u) {
|
|
@@ -1475,83 +1473,83 @@ function traverseModuleInfo(n, t, o, r, s = {}, l) {
|
|
|
1475
1473
|
}
|
|
1476
1474
|
const isExisted = (n, t) => document.querySelector(`${n}[${n === "link" ? "href" : "src"}="${t}"]`);
|
|
1477
1475
|
function generatePreloadAssets(n, t, o, r, s) {
|
|
1478
|
-
const
|
|
1479
|
-
if (traverseModuleInfo(r, o, (_,
|
|
1476
|
+
const a = [], l = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = n, { preloadConfig: p } = t, { depsRemote: m } = p;
|
|
1477
|
+
if (traverseModuleInfo(r, o, (_, b, v) => {
|
|
1480
1478
|
let S;
|
|
1481
1479
|
if (v)
|
|
1482
1480
|
S = p;
|
|
1483
1481
|
else if (Array.isArray(m)) {
|
|
1484
|
-
const
|
|
1485
|
-
if (!
|
|
1482
|
+
const w = m.find((N) => N.nameOrAlias === b.name || N.nameOrAlias === b.alias);
|
|
1483
|
+
if (!w)
|
|
1486
1484
|
return;
|
|
1487
|
-
S = defaultPreloadArgs(
|
|
1485
|
+
S = defaultPreloadArgs(w);
|
|
1488
1486
|
} else if (m === !0)
|
|
1489
1487
|
S = p;
|
|
1490
1488
|
else
|
|
1491
1489
|
return;
|
|
1492
1490
|
const I = getResourceUrl(_, getRemoteEntryInfoFromSnapshot(_).url);
|
|
1493
1491
|
I && i.push({
|
|
1494
|
-
name:
|
|
1492
|
+
name: b.name,
|
|
1495
1493
|
moduleInfo: {
|
|
1496
|
-
name:
|
|
1494
|
+
name: b.name,
|
|
1497
1495
|
entry: I,
|
|
1498
1496
|
type: "remoteEntryType" in _ ? _.remoteEntryType : "global",
|
|
1499
|
-
entryGlobalName: "globalName" in _ ? _.globalName :
|
|
1497
|
+
entryGlobalName: "globalName" in _ ? _.globalName : b.name,
|
|
1500
1498
|
shareScope: "",
|
|
1501
1499
|
version: "version" in _ ? _.version : void 0
|
|
1502
1500
|
},
|
|
1503
1501
|
url: I
|
|
1504
1502
|
});
|
|
1505
1503
|
let R = "modules" in _ ? _.modules : [];
|
|
1506
|
-
const
|
|
1507
|
-
if (
|
|
1504
|
+
const A = normalizePreloadExposes(S.exposes);
|
|
1505
|
+
if (A.length && "modules" in _) {
|
|
1508
1506
|
var T;
|
|
1509
|
-
R = _ == null || (T = _.modules) == null ? void 0 : T.reduce((
|
|
1507
|
+
R = _ == null || (T = _.modules) == null ? void 0 : T.reduce((w, N) => ((A == null ? void 0 : A.indexOf(N.moduleName)) !== -1 && w.push(N), w), []);
|
|
1510
1508
|
}
|
|
1511
|
-
function
|
|
1512
|
-
const
|
|
1513
|
-
return S.filter ?
|
|
1509
|
+
function $(w) {
|
|
1510
|
+
const N = w.map((O) => getResourceUrl(_, O));
|
|
1511
|
+
return S.filter ? N.filter(S.filter) : N;
|
|
1514
1512
|
}
|
|
1515
1513
|
if (R) {
|
|
1516
|
-
const
|
|
1517
|
-
for (let
|
|
1518
|
-
const
|
|
1514
|
+
const w = R.length;
|
|
1515
|
+
for (let N = 0; N < w; N++) {
|
|
1516
|
+
const O = R[N], P = `${b.name}/${O.moduleName}`;
|
|
1519
1517
|
n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1520
|
-
id:
|
|
1521
|
-
name:
|
|
1518
|
+
id: O.moduleName === "." ? b.name : P,
|
|
1519
|
+
name: b.name,
|
|
1522
1520
|
remoteSnapshot: _,
|
|
1523
1521
|
preloadConfig: S,
|
|
1524
|
-
remote:
|
|
1522
|
+
remote: b,
|
|
1525
1523
|
origin: n
|
|
1526
|
-
}), !getPreloaded(
|
|
1524
|
+
}), !getPreloaded(P) && (S.resourceCategory === "all" ? (a.push(...$(O.assets.css.async)), a.push(...$(O.assets.css.sync)), l.push(...$(O.assets.js.async)), l.push(...$(O.assets.js.sync))) : (S.resourceCategory = "sync") && (a.push(...$(O.assets.css.sync)), l.push(...$(O.assets.js.sync))), setPreloaded(P));
|
|
1527
1525
|
}
|
|
1528
1526
|
}
|
|
1529
1527
|
}, !0, {}, s), s.shared) {
|
|
1530
|
-
const _ = (
|
|
1531
|
-
const S = getRegisteredShare(n.shareScopeMap, v.sharedName,
|
|
1528
|
+
const _ = (b, v) => {
|
|
1529
|
+
const S = getRegisteredShare(n.shareScopeMap, v.sharedName, b, n.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1532
1530
|
S && typeof S.lib == "function" && (v.assets.js.sync.forEach((I) => {
|
|
1533
1531
|
c.add(I);
|
|
1534
1532
|
}), v.assets.css.sync.forEach((I) => {
|
|
1535
1533
|
u.add(I);
|
|
1536
1534
|
}));
|
|
1537
1535
|
};
|
|
1538
|
-
s.shared.forEach((
|
|
1536
|
+
s.shared.forEach((b) => {
|
|
1539
1537
|
var v;
|
|
1540
|
-
const S = (v = d.shared) == null ? void 0 : v[
|
|
1538
|
+
const S = (v = d.shared) == null ? void 0 : v[b.sharedName];
|
|
1541
1539
|
if (!S)
|
|
1542
1540
|
return;
|
|
1543
|
-
const I =
|
|
1541
|
+
const I = b.version ? S.find((A) => A.version === b.version) : S;
|
|
1544
1542
|
if (!I)
|
|
1545
1543
|
return;
|
|
1546
|
-
arrayOptions(I).forEach((
|
|
1547
|
-
_(
|
|
1544
|
+
arrayOptions(I).forEach((A) => {
|
|
1545
|
+
_(A, b);
|
|
1548
1546
|
});
|
|
1549
1547
|
});
|
|
1550
1548
|
}
|
|
1551
|
-
const
|
|
1549
|
+
const E = l.filter((_) => !c.has(_) && !isExisted("script", _));
|
|
1552
1550
|
return {
|
|
1553
|
-
cssAssets:
|
|
1554
|
-
jsAssetsWithoutEntry:
|
|
1551
|
+
cssAssets: a.filter((_) => !u.has(_) && !isExisted("link", _)),
|
|
1552
|
+
jsAssetsWithoutEntry: E,
|
|
1555
1553
|
entryAssets: i.filter((_) => !isExisted("script", _.url))
|
|
1556
1554
|
};
|
|
1557
1555
|
}
|
|
@@ -1559,7 +1557,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1559
1557
|
return {
|
|
1560
1558
|
name: "generate-preload-assets-plugin",
|
|
1561
1559
|
async generatePreloadAssets(n) {
|
|
1562
|
-
const { origin: t, preloadOptions: o, remoteInfo: r, remote: s, globalSnapshot:
|
|
1560
|
+
const { origin: t, preloadOptions: o, remoteInfo: r, remote: s, globalSnapshot: a, remoteSnapshot: l } = n;
|
|
1563
1561
|
return isBrowserEnv() ? isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1564
1562
|
cssAssets: [],
|
|
1565
1563
|
jsAssetsWithoutEntry: [],
|
|
@@ -1576,7 +1574,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1576
1574
|
}
|
|
1577
1575
|
}
|
|
1578
1576
|
]
|
|
1579
|
-
} : (assignRemoteInfo(r,
|
|
1577
|
+
} : (assignRemoteInfo(r, l), generatePreloadAssets(t, o, r, a, l)) : {
|
|
1580
1578
|
cssAssets: [],
|
|
1581
1579
|
jsAssetsWithoutEntry: [],
|
|
1582
1580
|
entryAssets: []
|
|
@@ -1586,7 +1584,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1586
1584
|
};
|
|
1587
1585
|
function getGlobalRemoteInfo(n, t) {
|
|
1588
1586
|
const o = getGlobalSnapshotInfoByModuleInfo({
|
|
1589
|
-
name: t.
|
|
1587
|
+
name: t.name,
|
|
1590
1588
|
version: t.options.version
|
|
1591
1589
|
}), r = o && "remotesInfo" in o && o.remotesInfo && getInfoWithoutType(o.remotesInfo, n.name).value;
|
|
1592
1590
|
return r && r.matchedVersion ? {
|
|
@@ -1606,87 +1604,76 @@ function getGlobalRemoteInfo(n, t) {
|
|
|
1606
1604
|
};
|
|
1607
1605
|
}
|
|
1608
1606
|
class SnapshotHandler {
|
|
1609
|
-
async loadSnapshot(t) {
|
|
1610
|
-
const { options: o } = this.HostInstance, { hostGlobalSnapshot: r, remoteSnapshot: s, globalSnapshot: l } = this.getGlobalRemoteInfo(t), { remoteSnapshot: a, globalSnapshot: i } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1611
|
-
options: o,
|
|
1612
|
-
moduleInfo: t,
|
|
1613
|
-
hostGlobalSnapshot: r,
|
|
1614
|
-
remoteSnapshot: s,
|
|
1615
|
-
globalSnapshot: l
|
|
1616
|
-
});
|
|
1617
|
-
return {
|
|
1618
|
-
remoteSnapshot: a,
|
|
1619
|
-
globalSnapshot: i
|
|
1620
|
-
};
|
|
1621
|
-
}
|
|
1622
1607
|
// eslint-disable-next-line max-lines-per-function
|
|
1623
|
-
async loadRemoteSnapshotInfo(t) {
|
|
1624
|
-
const { options:
|
|
1608
|
+
async loadRemoteSnapshotInfo({ moduleInfo: t, id: o, expose: r }) {
|
|
1609
|
+
const { options: s } = this.HostInstance;
|
|
1625
1610
|
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
1626
|
-
options:
|
|
1611
|
+
options: s,
|
|
1627
1612
|
moduleInfo: t
|
|
1628
1613
|
});
|
|
1629
|
-
let
|
|
1614
|
+
let a = getGlobalSnapshotInfoByModuleInfo({
|
|
1630
1615
|
name: this.HostInstance.options.name,
|
|
1631
1616
|
version: this.HostInstance.options.version
|
|
1632
1617
|
});
|
|
1633
|
-
|
|
1618
|
+
a || (a = {
|
|
1634
1619
|
version: this.HostInstance.options.version || "",
|
|
1635
1620
|
remoteEntry: "",
|
|
1636
1621
|
remotesInfo: {}
|
|
1637
1622
|
}, addGlobalSnapshot({
|
|
1638
|
-
[this.HostInstance.options.name]:
|
|
1639
|
-
})),
|
|
1623
|
+
[this.HostInstance.options.name]: a
|
|
1624
|
+
})), a && "remotesInfo" in a && !getInfoWithoutType(a.remotesInfo, t.name).value && ("version" in t || "entry" in t) && (a.remotesInfo = _extends$1({}, a == null ? void 0 : a.remotesInfo, {
|
|
1640
1625
|
[t.name]: {
|
|
1641
1626
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1642
1627
|
}
|
|
1643
1628
|
}));
|
|
1644
|
-
const { hostGlobalSnapshot:
|
|
1645
|
-
options:
|
|
1629
|
+
const { hostGlobalSnapshot: l, remoteSnapshot: i, globalSnapshot: c } = this.getGlobalRemoteInfo(t), { remoteSnapshot: u, globalSnapshot: d } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1630
|
+
options: s,
|
|
1646
1631
|
moduleInfo: t,
|
|
1647
|
-
hostGlobalSnapshot:
|
|
1648
|
-
remoteSnapshot:
|
|
1649
|
-
globalSnapshot:
|
|
1632
|
+
hostGlobalSnapshot: l,
|
|
1633
|
+
remoteSnapshot: i,
|
|
1634
|
+
globalSnapshot: c
|
|
1650
1635
|
});
|
|
1651
|
-
let
|
|
1652
|
-
if (
|
|
1653
|
-
if (isManifestProvider(
|
|
1654
|
-
const
|
|
1636
|
+
let p, m;
|
|
1637
|
+
if (u)
|
|
1638
|
+
if (isManifestProvider(u)) {
|
|
1639
|
+
const y = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "", E = await this.getManifestJson(y, t, {}), g = setGlobalSnapshotInfoByModuleInfo(_extends$1({}, t, {
|
|
1655
1640
|
// The global remote may be overridden
|
|
1656
1641
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1657
|
-
entry:
|
|
1658
|
-
}),
|
|
1659
|
-
|
|
1642
|
+
entry: y
|
|
1643
|
+
}), E);
|
|
1644
|
+
p = E, m = g;
|
|
1660
1645
|
} else {
|
|
1661
|
-
const { remoteSnapshot:
|
|
1646
|
+
const { remoteSnapshot: y } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1662
1647
|
options: this.HostInstance.options,
|
|
1663
1648
|
moduleInfo: t,
|
|
1664
|
-
remoteSnapshot:
|
|
1649
|
+
remoteSnapshot: u,
|
|
1665
1650
|
from: "global"
|
|
1666
1651
|
});
|
|
1667
|
-
|
|
1652
|
+
p = y, m = d;
|
|
1668
1653
|
}
|
|
1669
1654
|
else if (isRemoteInfoWithEntry(t)) {
|
|
1670
|
-
const
|
|
1655
|
+
const y = await this.getManifestJson(t.entry, t, {}), E = setGlobalSnapshotInfoByModuleInfo(t, y), { remoteSnapshot: g } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1671
1656
|
options: this.HostInstance.options,
|
|
1672
1657
|
moduleInfo: t,
|
|
1673
|
-
remoteSnapshot:
|
|
1658
|
+
remoteSnapshot: y,
|
|
1674
1659
|
from: "global"
|
|
1675
1660
|
});
|
|
1676
|
-
|
|
1661
|
+
p = g, m = E;
|
|
1677
1662
|
} else
|
|
1678
1663
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
1679
1664
|
hostName: t.name,
|
|
1680
1665
|
hostVersion: t.version,
|
|
1681
|
-
globalSnapshot: JSON.stringify(
|
|
1666
|
+
globalSnapshot: JSON.stringify(d)
|
|
1682
1667
|
}));
|
|
1683
1668
|
return await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
1684
|
-
|
|
1669
|
+
id: o,
|
|
1670
|
+
host: this.HostInstance,
|
|
1671
|
+
options: s,
|
|
1685
1672
|
moduleInfo: t,
|
|
1686
|
-
remoteSnapshot:
|
|
1673
|
+
remoteSnapshot: p
|
|
1687
1674
|
}), {
|
|
1688
|
-
remoteSnapshot:
|
|
1689
|
-
globalSnapshot:
|
|
1675
|
+
remoteSnapshot: p,
|
|
1676
|
+
globalSnapshot: m
|
|
1690
1677
|
};
|
|
1691
1678
|
}
|
|
1692
1679
|
getGlobalRemoteInfo(t) {
|
|
@@ -1694,40 +1681,40 @@ class SnapshotHandler {
|
|
|
1694
1681
|
}
|
|
1695
1682
|
async getManifestJson(t, o, r) {
|
|
1696
1683
|
const s = async () => {
|
|
1697
|
-
let
|
|
1698
|
-
if (
|
|
1699
|
-
return
|
|
1684
|
+
let l = this.manifestCache.get(t);
|
|
1685
|
+
if (l)
|
|
1686
|
+
return l;
|
|
1700
1687
|
try {
|
|
1701
1688
|
let i = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1702
|
-
(!i || !(i instanceof Response)) && (i = await fetch(t, {})),
|
|
1689
|
+
(!i || !(i instanceof Response)) && (i = await fetch(t, {})), l = await i.json();
|
|
1703
1690
|
} catch (i) {
|
|
1704
|
-
|
|
1691
|
+
l = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1705
1692
|
id: t,
|
|
1706
1693
|
error: i,
|
|
1707
1694
|
from: "runtime",
|
|
1708
1695
|
lifecycle: "afterResolve",
|
|
1709
1696
|
origin: this.HostInstance
|
|
1710
|
-
}),
|
|
1697
|
+
}), l || (delete this.manifestLoading[t], error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
1711
1698
|
manifestUrl: t,
|
|
1712
1699
|
moduleName: o.name,
|
|
1713
1700
|
hostName: this.HostInstance.options.name
|
|
1714
1701
|
}, `${i}`)));
|
|
1715
1702
|
}
|
|
1716
|
-
return assert(
|
|
1717
|
-
},
|
|
1718
|
-
const
|
|
1703
|
+
return assert(l.metaData && l.exposes && l.shared, `${t} is not a federation manifest`), this.manifestCache.set(t, l), l;
|
|
1704
|
+
}, a = async () => {
|
|
1705
|
+
const l = await s(), i = generateSnapshotFromManifest(l, {
|
|
1719
1706
|
version: t
|
|
1720
1707
|
}), { remoteSnapshot: c } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1721
1708
|
options: this.HostInstance.options,
|
|
1722
1709
|
moduleInfo: o,
|
|
1723
|
-
manifestJson:
|
|
1710
|
+
manifestJson: l,
|
|
1724
1711
|
remoteSnapshot: i,
|
|
1725
1712
|
manifestUrl: t,
|
|
1726
1713
|
from: "manifest"
|
|
1727
1714
|
});
|
|
1728
1715
|
return c;
|
|
1729
1716
|
};
|
|
1730
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] =
|
|
1717
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = a().then((l) => l)), this.manifestLoading[t];
|
|
1731
1718
|
}
|
|
1732
1719
|
constructor(t) {
|
|
1733
1720
|
this.loadingHostSnapshot = null, this.manifestCache = /* @__PURE__ */ new Map(), this.hooks = new PluginSystem({
|
|
@@ -1742,10 +1729,10 @@ class SharedHandler {
|
|
|
1742
1729
|
// register shared in shareScopeMap
|
|
1743
1730
|
registerShared(t, o) {
|
|
1744
1731
|
const { shareInfos: r, shared: s } = formatShareConfigs(t, o);
|
|
1745
|
-
return Object.keys(r).forEach((
|
|
1746
|
-
r[
|
|
1747
|
-
!getRegisteredShare(this.shareScopeMap,
|
|
1748
|
-
pkgName:
|
|
1732
|
+
return Object.keys(r).forEach((l) => {
|
|
1733
|
+
r[l].forEach((c) => {
|
|
1734
|
+
!getRegisteredShare(this.shareScopeMap, l, c, this.hooks.lifecycle.resolveShare) && c && c.lib && this.setShared({
|
|
1735
|
+
pkgName: l,
|
|
1749
1736
|
lib: c.lib,
|
|
1750
1737
|
get: c.get,
|
|
1751
1738
|
loaded: !0,
|
|
@@ -1769,14 +1756,14 @@ class SharedHandler {
|
|
|
1769
1756
|
strategy: s.strategy
|
|
1770
1757
|
}));
|
|
1771
1758
|
}));
|
|
1772
|
-
const
|
|
1759
|
+
const a = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1773
1760
|
pkgName: t,
|
|
1774
1761
|
shareInfo: s,
|
|
1775
1762
|
shared: r.options.shared,
|
|
1776
1763
|
origin: r
|
|
1777
|
-
}), { shareInfo:
|
|
1778
|
-
assert(
|
|
1779
|
-
const i = getRegisteredShare(this.shareScopeMap, t,
|
|
1764
|
+
}), { shareInfo: l } = a;
|
|
1765
|
+
assert(l, `Cannot find ${t} Share in the ${r.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1766
|
+
const i = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare), c = (u) => {
|
|
1780
1767
|
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, r.options.name);
|
|
1781
1768
|
};
|
|
1782
1769
|
if (i && i.lib)
|
|
@@ -1787,8 +1774,8 @@ class SharedHandler {
|
|
|
1787
1774
|
} else if (i) {
|
|
1788
1775
|
const d = (async () => {
|
|
1789
1776
|
const p = await i.get();
|
|
1790
|
-
|
|
1791
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1777
|
+
l.lib = p, l.loaded = !0, c(l);
|
|
1778
|
+
const m = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare);
|
|
1792
1779
|
return m && (m.lib = p, m.loaded = !0), p;
|
|
1793
1780
|
})();
|
|
1794
1781
|
return this.setShared({
|
|
@@ -1803,15 +1790,15 @@ class SharedHandler {
|
|
|
1803
1790
|
if (o != null && o.customShareInfo)
|
|
1804
1791
|
return !1;
|
|
1805
1792
|
const d = (async () => {
|
|
1806
|
-
const p = await
|
|
1807
|
-
|
|
1808
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1793
|
+
const p = await l.get();
|
|
1794
|
+
l.lib = p, l.loaded = !0, c(l);
|
|
1795
|
+
const m = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare);
|
|
1809
1796
|
return m && (m.lib = p, m.loaded = !0), p;
|
|
1810
1797
|
})();
|
|
1811
1798
|
return this.setShared({
|
|
1812
1799
|
pkgName: t,
|
|
1813
1800
|
loaded: !1,
|
|
1814
|
-
shared:
|
|
1801
|
+
shared: l,
|
|
1815
1802
|
from: r.options.name,
|
|
1816
1803
|
lib: null,
|
|
1817
1804
|
loading: d
|
|
@@ -1825,52 +1812,52 @@ class SharedHandler {
|
|
|
1825
1812
|
*/
|
|
1826
1813
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1827
1814
|
initializeSharing(t = DEFAULT_SCOPE, o) {
|
|
1828
|
-
const { host: r } = this, s = o == null ? void 0 : o.from,
|
|
1829
|
-
let
|
|
1815
|
+
const { host: r } = this, s = o == null ? void 0 : o.from, a = o == null ? void 0 : o.strategy;
|
|
1816
|
+
let l = o == null ? void 0 : o.initScope;
|
|
1830
1817
|
const i = [];
|
|
1831
1818
|
if (s !== "build") {
|
|
1832
|
-
const { initTokens:
|
|
1833
|
-
|
|
1834
|
-
let
|
|
1835
|
-
if (
|
|
1819
|
+
const { initTokens: E } = this;
|
|
1820
|
+
l || (l = []);
|
|
1821
|
+
let g = E[t];
|
|
1822
|
+
if (g || (g = E[t] = {
|
|
1836
1823
|
from: this.host.name
|
|
1837
|
-
}),
|
|
1838
|
-
|
|
1824
|
+
}), l.indexOf(g) >= 0) return i;
|
|
1825
|
+
l.push(g);
|
|
1839
1826
|
}
|
|
1840
1827
|
const c = this.shareScopeMap, u = r.options.name;
|
|
1841
1828
|
c[t] || (c[t] = {});
|
|
1842
|
-
const d = c[t], p = (
|
|
1829
|
+
const d = c[t], p = (E, g) => {
|
|
1843
1830
|
var _;
|
|
1844
|
-
const { version:
|
|
1845
|
-
d[
|
|
1846
|
-
const S = d[
|
|
1847
|
-
(!I || I.strategy !== "loaded-first" && !I.loaded && (!v != !R ? v : u > I.from)) && (S[
|
|
1848
|
-
}, m = (
|
|
1849
|
-
const { module:
|
|
1850
|
-
id:
|
|
1831
|
+
const { version: b, eager: v } = g;
|
|
1832
|
+
d[E] = d[E] || {};
|
|
1833
|
+
const S = d[E], I = S[b], R = !!(I && (I.eager || (_ = I.shareConfig) != null && _.eager));
|
|
1834
|
+
(!I || I.strategy !== "loaded-first" && !I.loaded && (!v != !R ? v : u > I.from)) && (S[b] = g);
|
|
1835
|
+
}, m = (E) => E && E.init && E.init(c[t], l), y = async (E) => {
|
|
1836
|
+
const { module: g } = await r.remoteHandler.getRemoteModuleAndOptions({
|
|
1837
|
+
id: E
|
|
1851
1838
|
});
|
|
1852
|
-
if (
|
|
1839
|
+
if (g.getEntry) {
|
|
1853
1840
|
let _;
|
|
1854
1841
|
try {
|
|
1855
|
-
_ = await
|
|
1856
|
-
} catch (
|
|
1842
|
+
_ = await g.getEntry();
|
|
1843
|
+
} catch (b) {
|
|
1857
1844
|
_ = await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1858
|
-
id:
|
|
1859
|
-
error:
|
|
1845
|
+
id: E,
|
|
1846
|
+
error: b,
|
|
1860
1847
|
from: "runtime",
|
|
1861
1848
|
lifecycle: "beforeLoadShare",
|
|
1862
1849
|
origin: r
|
|
1863
1850
|
});
|
|
1864
1851
|
}
|
|
1865
|
-
|
|
1852
|
+
g.inited || (await m(_), g.inited = !0);
|
|
1866
1853
|
}
|
|
1867
1854
|
};
|
|
1868
|
-
return Object.keys(r.options.shared).forEach((
|
|
1869
|
-
r.options.shared[
|
|
1870
|
-
_.scope.includes(t) && p(
|
|
1855
|
+
return Object.keys(r.options.shared).forEach((E) => {
|
|
1856
|
+
r.options.shared[E].forEach((_) => {
|
|
1857
|
+
_.scope.includes(t) && p(E, _);
|
|
1871
1858
|
});
|
|
1872
|
-
}), (r.options.shareStrategy === "version-first" ||
|
|
1873
|
-
|
|
1859
|
+
}), (r.options.shareStrategy === "version-first" || a === "version-first") && r.options.remotes.forEach((E) => {
|
|
1860
|
+
E.shareScope === t && i.push(y(E.name));
|
|
1874
1861
|
}), i;
|
|
1875
1862
|
}
|
|
1876
1863
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
@@ -1888,21 +1875,21 @@ class SharedHandler {
|
|
|
1888
1875
|
strategy: s.strategy
|
|
1889
1876
|
});
|
|
1890
1877
|
});
|
|
1891
|
-
const
|
|
1878
|
+
const a = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare), l = (i) => {
|
|
1892
1879
|
i.useIn || (i.useIn = []), addUniqueItem(i.useIn, r.options.name);
|
|
1893
1880
|
};
|
|
1894
|
-
if (
|
|
1895
|
-
if (typeof
|
|
1896
|
-
return a
|
|
1897
|
-
if (typeof
|
|
1898
|
-
const i =
|
|
1881
|
+
if (a) {
|
|
1882
|
+
if (typeof a.lib == "function")
|
|
1883
|
+
return l(a), a.loaded || (a.loaded = !0, a.from === r.options.name && (s.loaded = !0)), a.lib;
|
|
1884
|
+
if (typeof a.get == "function") {
|
|
1885
|
+
const i = a.get();
|
|
1899
1886
|
if (!(i instanceof Promise))
|
|
1900
|
-
return a
|
|
1887
|
+
return l(a), this.setShared({
|
|
1901
1888
|
pkgName: t,
|
|
1902
1889
|
loaded: !0,
|
|
1903
1890
|
from: r.options.name,
|
|
1904
1891
|
lib: i,
|
|
1905
|
-
shared:
|
|
1892
|
+
shared: a
|
|
1906
1893
|
}), i;
|
|
1907
1894
|
}
|
|
1908
1895
|
}
|
|
@@ -1940,7 +1927,7 @@ class SharedHandler {
|
|
|
1940
1927
|
hostShareScopeMap: r.hostShareScopeMap
|
|
1941
1928
|
});
|
|
1942
1929
|
}
|
|
1943
|
-
setShared({ pkgName: t, shared: o, from: r, lib: s, loading:
|
|
1930
|
+
setShared({ pkgName: t, shared: o, from: r, lib: s, loading: a, loaded: l, get: i }) {
|
|
1944
1931
|
const { version: c, scope: u = "default" } = o, d = _object_without_properties_loose(o, [
|
|
1945
1932
|
"version",
|
|
1946
1933
|
"scope"
|
|
@@ -1956,13 +1943,13 @@ class SharedHandler {
|
|
|
1956
1943
|
]
|
|
1957
1944
|
}, d, {
|
|
1958
1945
|
lib: s,
|
|
1959
|
-
loaded:
|
|
1960
|
-
loading:
|
|
1946
|
+
loaded: l,
|
|
1947
|
+
loading: a
|
|
1961
1948
|
}), i && (this.shareScopeMap[m][t][c].get = i);
|
|
1962
1949
|
return;
|
|
1963
1950
|
}
|
|
1964
1951
|
const y = this.shareScopeMap[m][t][c];
|
|
1965
|
-
|
|
1952
|
+
a && !y.loading && (y.loading = a);
|
|
1966
1953
|
});
|
|
1967
1954
|
}
|
|
1968
1955
|
_setGlobalShareScopeMap(t) {
|
|
@@ -1983,25 +1970,25 @@ class SharedHandler {
|
|
|
1983
1970
|
}
|
|
1984
1971
|
class RemoteHandler {
|
|
1985
1972
|
formatAndRegisterRemote(t, o) {
|
|
1986
|
-
return (o.remotes || []).reduce((s,
|
|
1973
|
+
return (o.remotes || []).reduce((s, a) => (this.registerRemote(a, s, {
|
|
1987
1974
|
force: !1
|
|
1988
1975
|
}), s), t.remotes);
|
|
1989
1976
|
}
|
|
1990
1977
|
setIdToRemoteMap(t, o) {
|
|
1991
|
-
const { remote: r, expose: s } = o, { name:
|
|
1978
|
+
const { remote: r, expose: s } = o, { name: a, alias: l } = r;
|
|
1992
1979
|
if (this.idToRemoteMap[t] = {
|
|
1993
1980
|
name: r.name,
|
|
1994
1981
|
expose: s
|
|
1995
|
-
},
|
|
1996
|
-
const i = t.replace(
|
|
1982
|
+
}, l && t.startsWith(a)) {
|
|
1983
|
+
const i = t.replace(a, l);
|
|
1997
1984
|
this.idToRemoteMap[i] = {
|
|
1998
1985
|
name: r.name,
|
|
1999
1986
|
expose: s
|
|
2000
1987
|
};
|
|
2001
1988
|
return;
|
|
2002
1989
|
}
|
|
2003
|
-
if (
|
|
2004
|
-
const i = t.replace(
|
|
1990
|
+
if (l && t.startsWith(l)) {
|
|
1991
|
+
const i = t.replace(l, a);
|
|
2005
1992
|
this.idToRemoteMap[i] = {
|
|
2006
1993
|
name: r.name,
|
|
2007
1994
|
expose: s
|
|
@@ -2015,33 +2002,33 @@ class RemoteHandler {
|
|
|
2015
2002
|
try {
|
|
2016
2003
|
const { loadFactory: s = !0 } = o || {
|
|
2017
2004
|
loadFactory: !0
|
|
2018
|
-
}, { module:
|
|
2005
|
+
}, { module: a, moduleOptions: l, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2019
2006
|
id: t
|
|
2020
|
-
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await
|
|
2007
|
+
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await a.get(p, d, o, m), E = await this.hooks.lifecycle.onLoad.emit({
|
|
2021
2008
|
id: p,
|
|
2022
2009
|
pkgNameOrAlias: c,
|
|
2023
2010
|
expose: d,
|
|
2024
2011
|
exposeModule: s ? y : void 0,
|
|
2025
2012
|
exposeModuleFactory: s ? void 0 : y,
|
|
2026
2013
|
remote: u,
|
|
2027
|
-
options:
|
|
2028
|
-
moduleInstance:
|
|
2014
|
+
options: l,
|
|
2015
|
+
moduleInstance: a,
|
|
2029
2016
|
origin: r
|
|
2030
2017
|
});
|
|
2031
|
-
return this.setIdToRemoteMap(t, i), typeof
|
|
2018
|
+
return this.setIdToRemoteMap(t, i), typeof E == "function" ? E : y;
|
|
2032
2019
|
} catch (s) {
|
|
2033
|
-
const { from:
|
|
2020
|
+
const { from: a = "runtime" } = o || {
|
|
2034
2021
|
from: "runtime"
|
|
2035
|
-
},
|
|
2022
|
+
}, l = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2036
2023
|
id: t,
|
|
2037
2024
|
error: s,
|
|
2038
|
-
from:
|
|
2025
|
+
from: a,
|
|
2039
2026
|
lifecycle: "onLoad",
|
|
2040
2027
|
origin: r
|
|
2041
2028
|
});
|
|
2042
|
-
if (!
|
|
2029
|
+
if (!l)
|
|
2043
2030
|
throw s;
|
|
2044
|
-
return
|
|
2031
|
+
return l;
|
|
2045
2032
|
}
|
|
2046
2033
|
}
|
|
2047
2034
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2054,15 +2041,17 @@ class RemoteHandler {
|
|
|
2054
2041
|
});
|
|
2055
2042
|
const r = formatPreloadArgs(o.options.remotes, t);
|
|
2056
2043
|
await Promise.all(r.map(async (s) => {
|
|
2057
|
-
const { remote:
|
|
2044
|
+
const { remote: a } = s, l = getRemoteInfo(a), { globalSnapshot: i, remoteSnapshot: c } = await o.snapshotHandler.loadRemoteSnapshotInfo({
|
|
2045
|
+
moduleInfo: a
|
|
2046
|
+
}), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2058
2047
|
origin: o,
|
|
2059
2048
|
preloadOptions: s,
|
|
2060
|
-
remote:
|
|
2061
|
-
remoteInfo:
|
|
2049
|
+
remote: a,
|
|
2050
|
+
remoteInfo: l,
|
|
2062
2051
|
globalSnapshot: i,
|
|
2063
2052
|
remoteSnapshot: c
|
|
2064
2053
|
});
|
|
2065
|
-
u && preloadAssets(
|
|
2054
|
+
u && preloadAssets(l, o, u);
|
|
2066
2055
|
}));
|
|
2067
2056
|
}
|
|
2068
2057
|
registerRemotes(t, o) {
|
|
@@ -2082,30 +2071,30 @@ class RemoteHandler {
|
|
|
2082
2071
|
options: o.options,
|
|
2083
2072
|
origin: o
|
|
2084
2073
|
});
|
|
2085
|
-
} catch (
|
|
2074
|
+
} catch (E) {
|
|
2086
2075
|
if (s = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2087
2076
|
id: r,
|
|
2088
2077
|
options: o.options,
|
|
2089
2078
|
origin: o,
|
|
2090
2079
|
from: "runtime",
|
|
2091
|
-
error:
|
|
2080
|
+
error: E,
|
|
2092
2081
|
lifecycle: "beforeRequest"
|
|
2093
2082
|
}), !s)
|
|
2094
|
-
throw
|
|
2083
|
+
throw E;
|
|
2095
2084
|
}
|
|
2096
|
-
const { id:
|
|
2097
|
-
assert(
|
|
2085
|
+
const { id: a } = s, l = matchRemoteWithNameAndExpose(o.options.remotes, a);
|
|
2086
|
+
assert(l, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2098
2087
|
hostName: o.options.name,
|
|
2099
|
-
requestId:
|
|
2088
|
+
requestId: a
|
|
2100
2089
|
}));
|
|
2101
|
-
const { remote: i } =
|
|
2102
|
-
id:
|
|
2103
|
-
},
|
|
2090
|
+
const { remote: i } = l, c = getRemoteInfo(i), u = await o.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2091
|
+
id: a
|
|
2092
|
+
}, l, {
|
|
2104
2093
|
options: o.options,
|
|
2105
2094
|
origin: o,
|
|
2106
2095
|
remoteInfo: c
|
|
2107
2096
|
})), { remote: d, expose: p } = u;
|
|
2108
|
-
assert(d && p, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${
|
|
2097
|
+
assert(d && p, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);
|
|
2109
2098
|
let m = o.moduleCache.get(d.name);
|
|
2110
2099
|
const y = {
|
|
2111
2100
|
host: o,
|
|
@@ -2118,7 +2107,7 @@ class RemoteHandler {
|
|
|
2118
2107
|
};
|
|
2119
2108
|
}
|
|
2120
2109
|
registerRemote(t, o, r) {
|
|
2121
|
-
const { host: s } = this,
|
|
2110
|
+
const { host: s } = this, a = () => {
|
|
2122
2111
|
if (t.alias) {
|
|
2123
2112
|
const i = o.find((c) => {
|
|
2124
2113
|
var u;
|
|
@@ -2132,9 +2121,9 @@ class RemoteHandler {
|
|
|
2132
2121
|
remote: t,
|
|
2133
2122
|
origin: s
|
|
2134
2123
|
});
|
|
2135
|
-
const
|
|
2136
|
-
if (!
|
|
2137
|
-
|
|
2124
|
+
const l = o.find((i) => i.name === t.name);
|
|
2125
|
+
if (!l)
|
|
2126
|
+
a(), o.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2138
2127
|
remote: t,
|
|
2139
2128
|
origin: s
|
|
2140
2129
|
});
|
|
@@ -2143,7 +2132,7 @@ class RemoteHandler {
|
|
|
2143
2132
|
`The remote "${t.name}" is already registered.`,
|
|
2144
2133
|
"Please note that overriding it may cause unexpected errors."
|
|
2145
2134
|
];
|
|
2146
|
-
r != null && r.force && (this.removeRemote(
|
|
2135
|
+
r != null && r.force && (this.removeRemote(l), a(), o.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2147
2136
|
remote: t,
|
|
2148
2137
|
origin: s
|
|
2149
2138
|
}), warn$1(i.join(" ")));
|
|
@@ -2151,40 +2140,40 @@ class RemoteHandler {
|
|
|
2151
2140
|
}
|
|
2152
2141
|
removeRemote(t) {
|
|
2153
2142
|
try {
|
|
2154
|
-
const { host: r } = this, { name: s } = t,
|
|
2155
|
-
|
|
2156
|
-
const
|
|
2157
|
-
if (
|
|
2158
|
-
const i =
|
|
2143
|
+
const { host: r } = this, { name: s } = t, a = r.options.remotes.findIndex((i) => i.name === s);
|
|
2144
|
+
a !== -1 && r.options.remotes.splice(a, 1);
|
|
2145
|
+
const l = r.moduleCache.get(t.name);
|
|
2146
|
+
if (l) {
|
|
2147
|
+
const i = l.remoteInfo, c = i.entryGlobalName;
|
|
2159
2148
|
if (CurrentGlobal[c]) {
|
|
2160
2149
|
var o;
|
|
2161
2150
|
(o = Object.getOwnPropertyDescriptor(CurrentGlobal, c)) != null && o.configurable ? delete CurrentGlobal[c] : CurrentGlobal[c] = void 0;
|
|
2162
2151
|
}
|
|
2163
|
-
const u = getRemoteEntryUniqueKey(
|
|
2152
|
+
const u = getRemoteEntryUniqueKey(l.remoteInfo);
|
|
2164
2153
|
globalLoading[u] && delete globalLoading[u], r.snapshotHandler.manifestCache.delete(i.entry);
|
|
2165
2154
|
let d = i.buildVersion ? composeKeyWithSeparator(i.name, i.buildVersion) : i.name;
|
|
2166
2155
|
const p = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) => i.buildVersion ? y.options.id === d : y.name === d);
|
|
2167
2156
|
if (p !== -1) {
|
|
2168
2157
|
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[p];
|
|
2169
2158
|
d = y.options.id || d;
|
|
2170
|
-
const
|
|
2171
|
-
let
|
|
2159
|
+
const E = getGlobalShareScope();
|
|
2160
|
+
let g = !0;
|
|
2172
2161
|
const _ = [];
|
|
2173
|
-
Object.keys(
|
|
2174
|
-
const v =
|
|
2162
|
+
Object.keys(E).forEach((b) => {
|
|
2163
|
+
const v = E[b];
|
|
2175
2164
|
v && Object.keys(v).forEach((S) => {
|
|
2176
2165
|
const I = v[S];
|
|
2177
2166
|
I && Object.keys(I).forEach((R) => {
|
|
2178
|
-
const
|
|
2179
|
-
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2182
|
-
|
|
2167
|
+
const A = I[R];
|
|
2168
|
+
A && Object.keys(A).forEach((T) => {
|
|
2169
|
+
const $ = A[T];
|
|
2170
|
+
$ && typeof $ == "object" && $.from === i.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((w) => w !== i.name), $.useIn.length ? g = !1 : _.push([
|
|
2171
|
+
b,
|
|
2183
2172
|
S,
|
|
2184
2173
|
R,
|
|
2185
2174
|
T
|
|
2186
2175
|
])) : _.push([
|
|
2187
|
-
|
|
2176
|
+
b,
|
|
2188
2177
|
S,
|
|
2189
2178
|
R,
|
|
2190
2179
|
T
|
|
@@ -2192,9 +2181,9 @@ class RemoteHandler {
|
|
|
2192
2181
|
});
|
|
2193
2182
|
});
|
|
2194
2183
|
});
|
|
2195
|
-
}),
|
|
2196
|
-
var R,
|
|
2197
|
-
(T =
|
|
2184
|
+
}), g && (y.shareScopeMap = {}, delete E[d]), _.forEach(([b, v, S, I]) => {
|
|
2185
|
+
var R, A, T;
|
|
2186
|
+
(T = E[b]) == null || (A = T[v]) == null || (R = A[S]) == null || delete R[I];
|
|
2198
2187
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p, 1);
|
|
2199
2188
|
}
|
|
2200
2189
|
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, r);
|
|
@@ -2224,6 +2213,7 @@ class RemoteHandler {
|
|
|
2224
2213
|
}), this.host = t, this.idToRemoteMap = {};
|
|
2225
2214
|
}
|
|
2226
2215
|
}
|
|
2216
|
+
const USE_SNAPSHOT = typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN == "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : !0;
|
|
2227
2217
|
class FederationHost {
|
|
2228
2218
|
initOptions(t) {
|
|
2229
2219
|
this.registerPlugins(t.plugins);
|
|
@@ -2247,11 +2237,11 @@ class FederationHost {
|
|
|
2247
2237
|
const s = getRemoteInfo({
|
|
2248
2238
|
name: t,
|
|
2249
2239
|
entry: o
|
|
2250
|
-
}),
|
|
2240
|
+
}), a = new Module({
|
|
2251
2241
|
host: this,
|
|
2252
2242
|
remoteInfo: s
|
|
2253
2243
|
});
|
|
2254
|
-
return
|
|
2244
|
+
return a.remoteEntryExports = r, this.moduleCache.set(t, a), a;
|
|
2255
2245
|
}
|
|
2256
2246
|
// eslint-disable-next-line max-lines-per-function
|
|
2257
2247
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2266,20 +2256,20 @@ class FederationHost {
|
|
|
2266
2256
|
this.sharedHandler.initShareScopeMap(t, o, r);
|
|
2267
2257
|
}
|
|
2268
2258
|
formatOptions(t, o) {
|
|
2269
|
-
const { shared: r } = formatShareConfigs(t, o), { userOptions: s, options:
|
|
2259
|
+
const { shared: r } = formatShareConfigs(t, o), { userOptions: s, options: a } = this.hooks.lifecycle.beforeInit.emit({
|
|
2270
2260
|
origin: this,
|
|
2271
2261
|
userOptions: o,
|
|
2272
2262
|
options: t,
|
|
2273
2263
|
shareInfo: r
|
|
2274
|
-
}),
|
|
2275
|
-
...
|
|
2264
|
+
}), l = this.remoteHandler.formatAndRegisterRemote(a, s), { shared: i } = this.sharedHandler.registerShared(a, s), c = [
|
|
2265
|
+
...a.plugins
|
|
2276
2266
|
];
|
|
2277
2267
|
s.plugins && s.plugins.forEach((d) => {
|
|
2278
2268
|
c.includes(d) || c.push(d);
|
|
2279
2269
|
});
|
|
2280
2270
|
const u = _extends$1({}, t, o, {
|
|
2281
2271
|
plugins: c,
|
|
2282
|
-
remotes:
|
|
2272
|
+
remotes: l,
|
|
2283
2273
|
shared: i
|
|
2284
2274
|
});
|
|
2285
2275
|
return this.hooks.lifecycle.init.emit({
|
|
@@ -2296,7 +2286,7 @@ class FederationHost {
|
|
|
2296
2286
|
this.loaderHook,
|
|
2297
2287
|
this.bridgeHook
|
|
2298
2288
|
]);
|
|
2299
|
-
this.options.plugins = this.options.plugins.reduce((r, s) => (s && r && !r.find((
|
|
2289
|
+
this.options.plugins = this.options.plugins.reduce((r, s) => (s && r && !r.find((a) => a.name === s.name) && r.push(s), r), o || []);
|
|
2300
2290
|
}
|
|
2301
2291
|
registerRemotes(t, o) {
|
|
2302
2292
|
return this.remoteHandler.registerRemotes(t, o);
|
|
@@ -2309,7 +2299,7 @@ class FederationHost {
|
|
|
2309
2299
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2310
2300
|
// maybe will change, temporarily for internal use only
|
|
2311
2301
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2312
|
-
}), this.version = "0.
|
|
2302
|
+
}), this.version = "0.14.0", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2313
2303
|
// FIXME: may not be suitable , not open to the public yet
|
|
2314
2304
|
getModuleInfo: new SyncHook(),
|
|
2315
2305
|
createScript: new SyncHook(),
|
|
@@ -2323,21 +2313,21 @@ class FederationHost {
|
|
|
2323
2313
|
beforeBridgeDestroy: new SyncHook(),
|
|
2324
2314
|
afterBridgeDestroy: new SyncHook()
|
|
2325
2315
|
});
|
|
2326
|
-
const o =
|
|
2316
|
+
const o = USE_SNAPSHOT ? [
|
|
2317
|
+
snapshotPlugin(),
|
|
2318
|
+
generatePreloadAssetsPlugin()
|
|
2319
|
+
] : [], r = {
|
|
2327
2320
|
id: getBuilderId(),
|
|
2328
2321
|
name: t.name,
|
|
2329
|
-
plugins:
|
|
2330
|
-
snapshotPlugin(),
|
|
2331
|
-
generatePreloadAssetsPlugin()
|
|
2332
|
-
],
|
|
2322
|
+
plugins: o,
|
|
2333
2323
|
remotes: [],
|
|
2334
2324
|
shared: {},
|
|
2335
2325
|
inBrowser: isBrowserEnv()
|
|
2336
2326
|
};
|
|
2337
|
-
this.name = t.name, this.options =
|
|
2338
|
-
...
|
|
2327
|
+
this.name = t.name, this.options = r, this.snapshotHandler = new SnapshotHandler(this), this.sharedHandler = new SharedHandler(this), this.remoteHandler = new RemoteHandler(this), this.shareScopeMap = this.sharedHandler.shareScopeMap, this.registerPlugins([
|
|
2328
|
+
...r.plugins,
|
|
2339
2329
|
...t.plugins || []
|
|
2340
|
-
]), this.options = this.formatOptions(
|
|
2330
|
+
]), this.options = this.formatOptions(r, t);
|
|
2341
2331
|
}
|
|
2342
2332
|
}
|
|
2343
2333
|
let FederationInstance = null;
|
|
@@ -2348,36 +2338,36 @@ setGlobalFederationConstructor(FederationHost);
|
|
|
2348
2338
|
function createBridgeComponent(n) {
|
|
2349
2339
|
const t = /* @__PURE__ */ new Map(), o = getInstance();
|
|
2350
2340
|
return () => ({
|
|
2351
|
-
__APP_VERSION__: "0.
|
|
2341
|
+
__APP_VERSION__: "0.14.0",
|
|
2352
2342
|
async render(r) {
|
|
2353
|
-
var
|
|
2343
|
+
var E, g, _;
|
|
2354
2344
|
LoggerInstance.debug("createBridgeComponent render Info", r);
|
|
2355
2345
|
const {
|
|
2356
2346
|
moduleName: s,
|
|
2357
|
-
dom:
|
|
2358
|
-
basename:
|
|
2347
|
+
dom: a,
|
|
2348
|
+
basename: l,
|
|
2359
2349
|
memoryRoute: i,
|
|
2360
2350
|
hashRoute: c,
|
|
2361
2351
|
...u
|
|
2362
2352
|
} = r, d = Vue.createApp(n.rootComponent, u);
|
|
2363
|
-
t.set(
|
|
2364
|
-
const p = await ((_ = (
|
|
2353
|
+
t.set(a, d);
|
|
2354
|
+
const p = await ((_ = (g = (E = o == null ? void 0 : o.bridgeHook) == null ? void 0 : E.lifecycle) == null ? void 0 : g.beforeBridgeRender) == null ? void 0 : _.emit(r)), m = p && typeof p == "object" && (p != null && p.extraProps) ? p == null ? void 0 : p.extraProps : {}, y = n.appOptions({
|
|
2365
2355
|
app: d,
|
|
2366
|
-
basename:
|
|
2356
|
+
basename: l,
|
|
2367
2357
|
memoryRoute: i,
|
|
2368
2358
|
hashRoute: c,
|
|
2369
2359
|
...u,
|
|
2370
2360
|
...m
|
|
2371
2361
|
});
|
|
2372
2362
|
if (y != null && y.router) {
|
|
2373
|
-
let
|
|
2374
|
-
r.memoryRoute ?
|
|
2363
|
+
let b, v = y.router.getRoutes();
|
|
2364
|
+
r.memoryRoute ? b = VueRouter.createMemoryHistory(r.basename) : r.hashRoute ? (b = VueRouter.createWebHashHistory(), v = v.map((I) => ({
|
|
2375
2365
|
...I,
|
|
2376
2366
|
path: r.basename + I.path
|
|
2377
|
-
}))) :
|
|
2367
|
+
}))) : b = VueRouter.createWebHistory(r.basename);
|
|
2378
2368
|
const S = VueRouter.createRouter({
|
|
2379
2369
|
...y.router.options,
|
|
2380
|
-
history:
|
|
2370
|
+
history: b,
|
|
2381
2371
|
routes: v
|
|
2382
2372
|
});
|
|
2383
2373
|
LoggerInstance.debug("createBridgeComponent render router info>>>", {
|
|
@@ -2385,7 +2375,7 @@ function createBridgeComponent(n) {
|
|
|
2385
2375
|
router: S
|
|
2386
2376
|
}), i && await S.push(i.entryPath), d.use(S);
|
|
2387
2377
|
}
|
|
2388
|
-
d.mount(
|
|
2378
|
+
d.mount(a);
|
|
2389
2379
|
},
|
|
2390
2380
|
destroy(r) {
|
|
2391
2381
|
LoggerInstance.debug("createBridgeComponent destroy Info", r);
|
|
@@ -2410,12 +2400,12 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2410
2400
|
},
|
|
2411
2401
|
inheritAttrs: !1,
|
|
2412
2402
|
setup(n) {
|
|
2413
|
-
const t = ref(null), o = ref(null), r = ref(""), s = useRoute(),
|
|
2414
|
-
var m, y,
|
|
2403
|
+
const t = ref(null), o = ref(null), r = ref(""), s = useRoute(), a = getInstance(), l = useAttrs(), i = async () => {
|
|
2404
|
+
var m, y, E, g;
|
|
2415
2405
|
const u = (m = n.providerInfo) == null ? void 0 : m.call(n);
|
|
2416
2406
|
o.value = u;
|
|
2417
2407
|
let d = {
|
|
2418
|
-
...
|
|
2408
|
+
...l,
|
|
2419
2409
|
moduleName: n.moduleName,
|
|
2420
2410
|
dom: t.value,
|
|
2421
2411
|
basename: n.basename,
|
|
@@ -2423,7 +2413,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2423
2413
|
hashRoute: n.hashRoute
|
|
2424
2414
|
};
|
|
2425
2415
|
LoggerInstance.debug("createRemoteComponent LazyComponent render >>>", d);
|
|
2426
|
-
const p = await ((
|
|
2416
|
+
const p = await ((g = (E = (y = a == null ? void 0 : a.bridgeHook) == null ? void 0 : y.lifecycle) == null ? void 0 : E.beforeBridgeRender) == null ? void 0 : g.emit(d)) || {};
|
|
2427
2417
|
d = {
|
|
2428
2418
|
...d,
|
|
2429
2419
|
...p.extraProps
|
|
@@ -2450,7 +2440,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2450
2440
|
});
|
|
2451
2441
|
function createRemoteComponent(n) {
|
|
2452
2442
|
return defineAsyncComponent({
|
|
2453
|
-
__APP_VERSION__: "0.
|
|
2443
|
+
__APP_VERSION__: "0.14.0",
|
|
2454
2444
|
...n.asyncComponentOptions,
|
|
2455
2445
|
//@ts-ignore
|
|
2456
2446
|
loader: async () => {
|
|
@@ -2464,15 +2454,15 @@ function createRemoteComponent(n) {
|
|
|
2464
2454
|
basename: o,
|
|
2465
2455
|
info: n
|
|
2466
2456
|
});
|
|
2467
|
-
const
|
|
2457
|
+
const a = await n.loader(), l = a && a[Symbol.for("mf_module_id")], i = a[s];
|
|
2468
2458
|
if (LoggerInstance.debug(
|
|
2469
2459
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
2470
|
-
{ moduleName:
|
|
2471
|
-
), s in
|
|
2460
|
+
{ moduleName: l, module: a, exportName: s, basename: o, route: t }
|
|
2461
|
+
), s in a && typeof i == "function")
|
|
2472
2462
|
return {
|
|
2473
2463
|
render() {
|
|
2474
2464
|
return h(RemoteApp, {
|
|
2475
|
-
moduleName:
|
|
2465
|
+
moduleName: l,
|
|
2476
2466
|
providerInfo: i,
|
|
2477
2467
|
basename: o,
|
|
2478
2468
|
rootAttrs: n.rootAttrs
|